Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure EMS relationships are established #103

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions db/migrate/20171023170841_ensure_cloud_managers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
class EnsureCloudManagers < ActiveRecord::Migration[5.0]
class ExtManagementSystem < ActiveRecord::Base
self.inheritance_column = :_type_disabled # disable STI
end

class BaseManager < ExtManagementSystem; end
class Settings; end

class ManageIQ
class Providers
class CloudManager < BaseManager
def ensure_managers
build_network_manager unless network_manager
network_manager.name = "#{name} Network Manager"

build_ebs_storage_manager unless ebs_storage_manager
ebs_storage_manager.name = "#{name} EBS Storage Manager"

if Settings.prototype.amazon.s3
build_s3_storage_manager unless s3_storage_manager
s3_storage_manager.name = "#{name} S3 Storage Manager"
end

ensure_managers_zone_and_provider_region
end

def ensure_managers_zone_and_provider_region
if network_manager
network_manager.zone_id = zone_id
network_manager.provider_region = provider_region
end

if ebs_storage_manager
ebs_storage_manager.zone_id = zone_id
ebs_storage_manager.provider_region = provider_region
end

if s3_storage_manager
s3_storage_manager.zone_id = zone_id
s3_storage_manager.provider_region = provider_region
end
end
end
end
end

def up
ManageIQ::Providers::CloudManager.all.each { |x| x.send(:ensure_managers); x.save!; }
end
end