Skip to content

Commit

Permalink
Merge pull request #15053 from borod108/remove_v3_dependency
Browse files Browse the repository at this point in the history
Fix fetching non active ISO domains
  • Loading branch information
agrare authored May 23, 2017
2 parents b28dea8 + d2856f1 commit f0094c9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
11 changes: 2 additions & 9 deletions app/models/iso_datastore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ def synchronize_advertised_images_queue
def advertised_images
return [] unless ext_management_system.kind_of?(ManageIQ::Providers::Redhat::InfraManager)

begin
ext_management_system.with_provider_connection do |rhevm|
rhevm.iso_images.collect { |image| image[:name] }
end
rescue Ovirt::Error => err
_log.error("Error Getting ISO Images on ISO Datastore on Management System <#{name}>: #{err.class.name}: #{err}")
raise
end
ext_management_system.ovirt_services(:use_highest_supported_version => true).advertised_images
end

def synchronize_advertised_images
Expand All @@ -49,6 +42,6 @@ def synchronize_advertised_images
clear_association_cache
update_attribute(:last_refresh_on, Time.now.utc)
_log.info("Synchronizing images on #{log_for}...Complete")
rescue Ovirt::Error
rescue ManageIQ::Providers::Redhat::InfraManager::OvirtServices::Error
end
end
39 changes: 39 additions & 0 deletions spec/models/iso_datastore_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
describe IsoDatastore do
let(:ems) { FactoryGirl.create(:ems_redhat) }
let(:iso_datastore) { FactoryGirl.create(:iso_datastore, :ext_management_system => ems) }

describe "#advertised_images" do
subject(:advertised_images) { iso_datastore.advertised_images }

context "ems is not rhv" do
let(:ems) { FactoryGirl.create(:ems_vmware) }
it "returns empty array" do
expect(advertised_images).to eq([])
end
end

context "ems is rhv" do
before do
allow(ems).to receive(:supported_api_versions).and_return(supported_api_versions)
end

context "supports api4" do
let(:supported_api_versions) { %w(3 4) }
it "send the method to ovirt services v4" do
expect_any_instance_of(ManageIQ::Providers::Redhat::InfraManager::OvirtServices::Strategies::V4)
.to receive(:advertised_images)
advertised_images
end
end

context "does not support api4" do
let(:supported_api_versions) { ["3"] }
it "send the method to ovirt services v4" do
expect_any_instance_of(ManageIQ::Providers::Redhat::InfraManager::OvirtServices::Strategies::V3)
.to receive(:advertised_images)
advertised_images
end
end
end
end
end

0 comments on commit f0094c9

Please sign in to comment.