Sha256: 0992801d9774db828b35868570ccc396d3489b4fda22e964c2e369f38656b86b

Contents?: true

Size: 662 Bytes

Versions: 49

Compression:

Stored size: 662 Bytes

Contents

class FakeDiscoveredHost < ApplicationRecord
  self.table_name = 'hosts'
end

class FillDiscoveryAttributeSetsForExistingHosts < ActiveRecord::Migration[4.2]
  def up
    FakeDiscoveredHost.where(:type => "Host::Discovered").all.each do |host|
      begin
        say "Populating attribute set for discovered host #{host.name}"
        ForemanDiscovery::ImportHooks::DiscoveryAttribute.new(host: host, facts: host.facts_hash).after_populate
        host.save!
      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
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
foreman_discovery-23.0.2 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-24.0.1 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-24.0.0 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-23.0.1 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-23.0.0 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-22.0.4 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-21.0.5 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-22.0.2 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-21.0.4 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-21.0.3 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-21.0.2 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-19.0.5 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-19.0.4 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-21.0.1 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-19.0.3 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-21.0.0 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-19.0.2 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-20.0.1 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-20.0.0 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb
foreman_discovery-19.0.1 db/migrate/20141223142759_fill_discovery_attribute_sets_for_existing_hosts.rb