Sha256: 3cafd80de304fa300b4e22f1b43ffb4391b908bcb3ad3d8aad084a1423daba8f

Contents?: true

Size: 699 Bytes

Versions: 5

Compression:

Stored size: 699 Bytes

Contents

class MigrateHypervisorsToComputeResources < ActiveRecord::Migration
  class Hypervisor < ActiveRecord::Base; end

  def self.up
    return unless Hypervisor.table_exists?

    Hypervisor.all.each do |hypervisor|
      # check if we have the same compute resource already, if we do, skip it.
      next if Foreman::Model::Libvirt.find_by_url hypervisor.uri

      Foreman::Model::Libvirt.create :name        => hypervisor.name,
                                     :url         => hypervisor.uri,
                                     :description => "Automatically migrated from hypervisor #{hypervisor.name} / #{hypervisor.uri}"
    end
    drop_table :hypervisors
  end

  def self.down
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/db/migrate/20121118120028_migrate_hypervisors_to_compute_resources.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/db/migrate/20121118120028_migrate_hypervisors_to_compute_resources.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/db/migrate/20121118120028_migrate_hypervisors_to_compute_resources.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/db/migrate/20121118120028_migrate_hypervisors_to_compute_resources.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/db/migrate/20121118120028_migrate_hypervisors_to_compute_resources.rb