Skip to content

Commit

Permalink
Override name and delegate name= to provider
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Jun 24, 2020
1 parent 0e91443 commit 27d56b7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
21 changes: 7 additions & 14 deletions app/models/manageiq/providers/foreman/configuration_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class ManageIQ::Providers::Foreman::ConfigurationManager < ManageIQ::Providers::

belongs_to :provider, :autosave => true, :dependent => :destroy

before_save :ensure_provider_name_and_zone

class << self
delegate :params_for_create,
:verify_credentials,
Expand All @@ -41,6 +39,12 @@ def provider
super || ensure_provider
end

def name
"#{provider.name} Configuration Manager"
end

delegate :name=, :zone, :zone=, :zone_id=, :to => :provider

def image_name
"foreman_configuration"
end
Expand All @@ -52,17 +56,6 @@ def self.display_name(number = 1)
private

def ensure_provider
build_provider

provider.configuration_manager = self
provider.name = name
provider.zone = zone

provider
end

def ensure_provider_name_and_zone
provider.name = name.sub(/ Configuration Manager$/, '')
provider.zone = zone
build_provider.tap { |p| p.configuration_manager = self }
end
end
9 changes: 0 additions & 9 deletions app/models/manageiq/providers/foreman/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,10 @@ def verify_credentials(auth_type = nil, options = {})

def ensure_managers
build_provisioning_manager unless provisioning_manager
provisioning_manager.name = "#{name} Provisioning Manager" unless name.end_with?(" Provisioning Manager")
provisioning_manager.provider = self

build_configuration_manager unless configuration_manager
configuration_manager.name = "#{name} Configuration Manager" unless name.end_with?(" Configuration Manager")
configuration_manager.provider = self

if zone_id_changed?
provisioning_manager.enabled = Zone.maintenance_zone&.id != zone_id
provisioning_manager.zone_id = zone_id
configuration_manager.enabled = Zone.maintenance_zone&.id != zone_id
configuration_manager.zone_id = zone_id
end
end

def self.refresh_ems(provider_ids)
Expand Down
16 changes: 16 additions & 0 deletions app/models/manageiq/providers/foreman/provisioning_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,20 @@ def self.description
def self.supported_for_create?
false
end

def provider
super || ensure_provider
end

def name
"#{provider.name} Provisioning Manager"
end

delegate :name=, :zone, :zone=, :zone_id=, :to => :provider

private

def ensure_provider
build_provider.tap { |p| p.provisioning_manager = self }
end
end

0 comments on commit 27d56b7

Please sign in to comment.