Skip to content

Commit

Permalink
Merge pull request #286 from mansam/combine-infra-refresh-queues
Browse files Browse the repository at this point in the history
Combine InfraManager and child manager refresh queues
  • Loading branch information
aufi authored May 9, 2018
2 parents 70f8b6d + 5864c40 commit 13b43f2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ def self.ems_class
ManageIQ::Providers::Openstack::InfraManager
end

# overriding queue_name_for_ems so PerEmsWorkerMixin picks up *all* of the
# Openstack-manager types from here.
# This way, the refresher for Openstack's InfraManager will refresh *all*
# of the Openstack inventory across all managers.
class << self
def queue_name_for_ems(ems)
return ems unless ems.kind_of?(ExtManagementSystem)
combined_managers(ems).collect(&:queue_name).sort
end

private

def combined_managers(ems)
[ems].concat(ems.child_managers)
end
end

# MiQ complains if this isn't defined
def queue_name_for_ems(ems)
end

def self.settings_name
:ems_refresh_worker_openstack_infra
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
describe ManageIQ::Providers::Openstack::InfraManager::RefreshWorker do
context "EMS with children" do
let!(:network_manager) { FactoryGirl.create(:ems_network) }
let!(:storage_manager) { FactoryGirl.create(:ems_storage) }
let(:ems) do
FactoryGirl.create(:ems_infra).tap do |ems|
network_manager.update_attributes(:parent_ems_id => ems.id)
storage_manager.update_attributes(:parent_ems_id => ems.id)
end
end

it ".queue_name_for_ems" do
queue_name = described_class.queue_name_for_ems(ems)
expect(queue_name.count).to eq(3)
expect(queue_name.sort).to eq(queue_name)
end
end

context "EMS with no children" do
let(:ems) { FactoryGirl.create(:ems_infra) }

it ".queue_name_for_ems" do
queue_name = described_class.queue_name_for_ems(ems)
expect(queue_name.count).to eq(1)
expect(queue_name.first).to eq(ems.queue_name)
end
end
end

0 comments on commit 13b43f2

Please sign in to comment.