Skip to content

Commit

Permalink
Add setting to disable OvirtSDK
Browse files Browse the repository at this point in the history
Add a setting that by default will disable the use of the OvirtSDK for
refresh and provisioning.
  • Loading branch information
Boris Odnopozov committed Mar 20, 2017
1 parent ccb1cf8 commit d2cbf43
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ def highest_supported_api_version
supported_api_versions.sort.last
end

def highest_allowed_api_version
return 3 unless use_ovirt_sdk?
highest_supported_api_version
end

def use_ovirt_sdk?
::Settings.ems.ems_redhat.use_ovirt_engine_sdk
end

class_methods do
def api3_supported_features
[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(ems)

def build
strategy_model = ManageIQ::Providers::Redhat::InfraManager::Inventory::Strategies
api_version = ext_management_system.highest_supported_api_version
api_version = ext_management_system.highest_allowed_api_version
"#{strategy_model}::V#{api_version}".constantize
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(ems, options = {})

def build
parse_model = ManageIQ::Providers::Redhat::InfraManager::Refresh::Parse::Strategies
api_version = force_version || ext_management_system.highest_supported_api_version
api_version = force_version || ext_management_system.highest_allowed_api_version
"#{parse_model}::Api#{api_version}".constantize
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(ems)

def build
strategy_model = ManageIQ::Providers::Redhat::InfraManager::Refresh::Strategies
api_version = ext_management_system.highest_supported_api_version
api_version = ext_management_system.highest_allowed_api_version
"#{strategy_model}::Api#{api_version}".constantize
end
end
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
:omit_default_port: true
:read_timeout: 60
:ems_redhat:
:use_ovirt_engine_sdk: false
:resolve_ip_addresses: true
:inventory:
:read_timeout: 1.hour
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
describe ManageIQ::Providers::Redhat::InfraManager::Refresh::Parse::ParserBuilder do
let(:ems) { FactoryGirl.build(:ems_redhat) }
let(:use_ovirt_engine_sdk) { true }
let(:options) { {} }
subject { described_class.new(ems, options).build }
describe 'chooses the right parsing strategy' do
before do
::Settings.ems.ems_redhat.use_ovirt_engine_sdk = use_ovirt_engine_sdk
end

context "when v4 api" do
before(:each) do
allow(ems).to receive(:highest_supported_api_version).and_return(4)
end

it 'returns the api4 parser' do
expect(subject).to eq(ManageIQ::Providers::Redhat::InfraManager::Refresh::Parse::Strategies::Api4)
end

context "when use_ovirt_engine_sdk setting is turned to false" do
let(:use_ovirt_engine_sdk) { false }
it 'returns the api3 parser' do
expect(subject).to eq(ManageIQ::Providers::Redhat::InfraManager::Refresh::Parse::Strategies::Api3)
end
end

context "forced version 3" do
let(:options) { { :force_version => 3 } }

it 'returns the api3 parser' do
expect(subject).to eq(ManageIQ::Providers::Redhat::InfraManager::Refresh::Parse::Strategies::Api3)
end
end

end

context "when v3 api" do
before(:each) do
allow(ems).to receive(:highest_supported_api_version).and_return(3)
end

it 'returns the api3 parser' do
expect(subject).to eq(ManageIQ::Providers::Redhat::InfraManager::Refresh::Parse::Strategies::Api3)
end

context "forced version 4" do
let(:options) { { :force_version => 4 } }

it 'returns the api4 parser' do
expect(subject).to eq(ManageIQ::Providers::Redhat::InfraManager::Refresh::Parse::Strategies::Api4)
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:port => 8443)
@ems.update_authentication(:default => {:userid => "admin@internal", :password => "123456"})
allow(@ems).to receive(:supported_api_versions).and_return([3, 4])
::Settings.ems.ems_redhat.use_ovirt_engine_sdk = true
end

it ".ems_type" do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
describe ManageIQ::Providers::Redhat::InfraManager::Refresh::Refresher do
let(:ems) { FactoryGirl.build(:ems_redhat) }
let(:use_ovirt_engine_sdk) { true }
describe 'chooses the right refresher strategy' do
before do
::Settings.ems.ems_redhat.use_ovirt_engine_sdk = use_ovirt_engine_sdk
end

context "when v4 api" do
before(:each) do
allow(ems).to receive(:highest_supported_api_version).and_return(4)
Expand All @@ -9,6 +14,13 @@
it 'returns the api4 refresher' do
expect(ems.refresher).to eq(ManageIQ::Providers::Redhat::InfraManager::Refresh::Strategies::Api4)
end

context "when use_ovirt_engine_sdk setting is turned to false" do
let(:use_ovirt_engine_sdk) { false }
it 'returns the api4 refresher' do
expect(ems.refresher).to eq(ManageIQ::Providers::Redhat::InfraManager::Refresh::Strategies::Api3)
end
end
end

context "when v3 api" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@ems.default_endpoint.path = "/ovirt-engine/api"
allow(@ems).to receive(:supported_api_versions).and_return([3, 4])
allow(@ems).to receive(:resolve_ip_address).with(ip_address).and_return(ip_address)
::Settings.ems.ems_redhat.use_ovirt_engine_sdk = true
end

it ".ems_type" do
Expand Down

0 comments on commit d2cbf43

Please sign in to comment.