Skip to content

Commit

Permalink
Fixes #14643 - fixed FillDiscoveryAttributeSetsForExistingHosts migra…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
lzap committed Apr 14, 2016
1 parent 22eef81 commit b28beea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/host/discovered.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def attributes_to_import_from_facts
super
end

def populate_fields_from_facts(facts = self.facts_hash, ignored_type)
def populate_fields_from_facts(facts = self.facts_hash, ignored_type = nil)
# detect interfaces and primary interface using extensions
parser = super(facts, :foreman_discovery)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
class FillDiscoveryAttributeSetsForExistingHosts < ActiveRecord::Migration
def up
Host::Discovered.all.each { |host| host.populate_fields_from_facts}
Host::Discovered.all.each do |host|
begin
say "Populating attribute set for discovered host #{host.name}"
host.populate_fields_from_facts
rescue Exception => e
say "Error while populating host #{host.name}, deleting: #{e.message}:\n" + e.backtrace.join("\n")
host.destroy
end
end
end

def down
Expand Down

0 comments on commit b28beea

Please sign in to comment.