From fd439fdea9aba448b13fbf0dd62fe53ef9c73129 Mon Sep 17 00:00:00 2001 From: Andrey Menezes Date: Wed, 21 Jun 2017 18:29:28 -0300 Subject: [PATCH] Passing the API Port to Xclarity_client --- .../providers/lenovo/manager_mixin.rb | 10 +++++---- .../event_catcher/stream.rb | 3 ++- .../physical_infra_manager/operations.rb | 3 ++- .../physical_infra_manager/refresh_parser.rb | 3 ++- manageiq-providers-lenovo.gemspec | 2 +- .../event_catcher/stream_spec.rb | 3 ++- .../refresh_parser_spec.rb | 3 ++- .../physical_infra_manager/refresher_spec.rb | 3 ++- .../lenovo/physical_infra_manager_spec.rb | 22 ++++++++++++------- 9 files changed, 33 insertions(+), 19 deletions(-) diff --git a/app/models/manageiq/providers/lenovo/manager_mixin.rb b/app/models/manageiq/providers/lenovo/manager_mixin.rb index 9f8fbb5ab9..b873d49ae8 100644 --- a/app/models/manageiq/providers/lenovo/manager_mixin.rb +++ b/app/models/manageiq/providers/lenovo/manager_mixin.rb @@ -14,9 +14,10 @@ def connect(options = {}) username = options[:user] || authentication_userid(options[:auth_type]) password = options[:pass] || authentication_password(options[:auth_type]) host = options[:host] + port = options[:port] # TODO: improve this SSL verification verify_ssl = options[:verify_ssl] == 1 ? 'PEER' : 'NONE' - self.class.raw_connect(username, password, host, verify_ssl) + self.class.raw_connect(username, password, host, port, verify_ssl) end def translate_exception(err) @@ -31,12 +32,13 @@ module ClassMethods # # Connections # - def raw_connect(username, password, host, verify_ssl) + def raw_connect(username, password, host, port, verify_ssl) require 'xclarity_client' xclarity = XClarityClient::Configuration.new( :username => username, :password => password, :host => host, + :port => port, :verify_ssl => verify_ssl ) XClarityClient::Client.new(xclarity) @@ -49,10 +51,10 @@ def raw_connect(username, password, host, verify_ssl) # Factory method to create EmsLenovo with instances # or images for the given authentication. Created EmsLenovo instances # will automatically have EmsRefreshes queued up. - def discover(username, password, host, verify_ssl = 0) + def discover(username, password, host, port, verify_ssl = 0) new_emses = [] - raw_connect(username, password, host, verify_ssl) + raw_connect(username, password, host, port, verify_ssl) EmsRefresh.queue_refresh(new_emses) unless new_emses.blank? diff --git a/app/models/manageiq/providers/lenovo/physical_infra_manager/event_catcher/stream.rb b/app/models/manageiq/providers/lenovo/physical_infra_manager/event_catcher/stream.rb index 1e803a3c17..20b795d7c3 100755 --- a/app/models/manageiq/providers/lenovo/physical_infra_manager/event_catcher/stream.rb +++ b/app/models/manageiq/providers/lenovo/physical_infra_manager/event_catcher/stream.rb @@ -51,7 +51,8 @@ def create_event_monitor_handle(ems) ems.connect(:user => ems_auth.userid, :pass => ems_auth.password, - :host => ems.endpoints.first.hostname) + :host => ems.endpoints.first.hostname, + :port => ems.endpoints.first.port) end def get_last_cnn_from_events(ems_id) diff --git a/app/models/manageiq/providers/lenovo/physical_infra_manager/operations.rb b/app/models/manageiq/providers/lenovo/physical_infra_manager/operations.rb index f8ab38ef50..b09969d788 100755 --- a/app/models/manageiq/providers/lenovo/physical_infra_manager/operations.rb +++ b/app/models/manageiq/providers/lenovo/physical_infra_manager/operations.rb @@ -35,7 +35,8 @@ def change_resource_state(verb, args, options = {}) endpoint = endpoints.first client = connect(:user => auth.userid, :pass => auth.password, - :host => endpoint.hostname) + :host => endpoint.hostname, + :port => endpoint.port) # Turn on the location LED using the xclarity_client API client.send(verb, args.ems_ref) diff --git a/app/models/manageiq/providers/lenovo/physical_infra_manager/refresh_parser.rb b/app/models/manageiq/providers/lenovo/physical_infra_manager/refresh_parser.rb index 0e379fdda3..e6d485eff7 100644 --- a/app/models/manageiq/providers/lenovo/physical_infra_manager/refresh_parser.rb +++ b/app/models/manageiq/providers/lenovo/physical_infra_manager/refresh_parser.rb @@ -28,7 +28,8 @@ def initialize(ems, options = nil) @ems = ems @connection = ems.connect(:user => ems_auth.userid, :pass => ems_auth.password, - :host => ems.endpoints.first.hostname) + :host => ems.endpoints.first.hostname, + :port => ems.endpoints.first.port) @options = options || {} @data = {} @data_index = {} diff --git a/manageiq-providers-lenovo.gemspec b/manageiq-providers-lenovo.gemspec index 99209a8198..6ae93d0393 100644 --- a/manageiq-providers-lenovo.gemspec +++ b/manageiq-providers-lenovo.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,lib}/**/*"] - s.add_dependency "xclarity_client", "~> 0.4.1" + s.add_dependency "xclarity_client", "~> 0.5.2" s.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0" s.add_development_dependency "simplecov" end diff --git a/spec/models/manageiq/providers/lenovo/physical_infra_manager/event_catcher/stream_spec.rb b/spec/models/manageiq/providers/lenovo/physical_infra_manager/event_catcher/stream_spec.rb index 7fd8099ec5..cb0aebbb21 100644 --- a/spec/models/manageiq/providers/lenovo/physical_infra_manager/event_catcher/stream_spec.rb +++ b/spec/models/manageiq/providers/lenovo/physical_infra_manager/event_catcher/stream_spec.rb @@ -2,7 +2,8 @@ let(:ems) do FactoryGirl.create(:physical_infra_with_authentication, :name => "LXCA", - :hostname => "https://10.243.9.123") + :hostname => "https://10.243.9.123", + :port => "443") end let(:stream) { described_class.new(ems) } diff --git a/spec/models/manageiq/providers/lenovo/physical_infra_manager/refresh_parser_spec.rb b/spec/models/manageiq/providers/lenovo/physical_infra_manager/refresh_parser_spec.rb index 0135e7e491..8861a7327c 100644 --- a/spec/models/manageiq/providers/lenovo/physical_infra_manager/refresh_parser_spec.rb +++ b/spec/models/manageiq/providers/lenovo/physical_infra_manager/refresh_parser_spec.rb @@ -3,7 +3,8 @@ pim = FactoryGirl.create(:physical_infra, :name => "LXCA", :hostname => "https://10.243.9.123", - :ipaddress => "https://10.243.9.123") + :port => "443", + :ipaddress => "https://10.243.9.123:443") auth = FactoryGirl.create(:authentication, :userid => 'admin', :password => 'password', diff --git a/spec/models/manageiq/providers/lenovo/physical_infra_manager/refresher_spec.rb b/spec/models/manageiq/providers/lenovo/physical_infra_manager/refresher_spec.rb index 1045b447f2..38a901f085 100644 --- a/spec/models/manageiq/providers/lenovo/physical_infra_manager/refresher_spec.rb +++ b/spec/models/manageiq/providers/lenovo/physical_infra_manager/refresher_spec.rb @@ -10,7 +10,8 @@ FactoryGirl.create(:physical_infra, :name => "LXCA", :hostname => "https://10.243.9.123", - :ipaddress => "https://10.243.9.123") + :port => "443", + :ipaddress => "https://10.243.9.123:443") end let(:targets) { [ems] } diff --git a/spec/models/manageiq/providers/lenovo/physical_infra_manager_spec.rb b/spec/models/manageiq/providers/lenovo/physical_infra_manager_spec.rb index dbc42793df..cab3765c32 100644 --- a/spec/models/manageiq/providers/lenovo/physical_infra_manager_spec.rb +++ b/spec/models/manageiq/providers/lenovo/physical_infra_manager_spec.rb @@ -2,7 +2,7 @@ describe ManageIQ::Providers::Lenovo::PhysicalInfraManager do before :all do - @auth = { :user => 'admin', :pass => 'smartvm', :host => 'localhost' } + @auth = { :user => 'admin', :pass => 'smartvm', :host => 'localhost', :port => '3000' } end it 'will turn on a location LED successfully' do @@ -12,7 +12,8 @@ pim = FactoryGirl.create(:physical_infra, :name => "LXCA", :hostname => "https://10.243.9.123", - :ipaddress => "https://10.243.9.123") + :port => "443", + :ipaddress => "https://10.243.9.123:443") auth = FactoryGirl.create(:authentication, :userid => 'admin', :password => 'password', @@ -31,7 +32,8 @@ pim = FactoryGirl.create(:physical_infra, :name => "LXCA", :hostname => "https://10.243.9.123", - :ipaddress => "https://10.243.9.123") + :port => "443", + :ipaddress => "https://10.243.9.123:443") auth = FactoryGirl.create(:authentication, :userid => 'admin', :password => 'password', @@ -50,7 +52,8 @@ pim = FactoryGirl.create(:physical_infra, :name => "LXCA", :hostname => "https://10.243.9.123", - :ipaddress => "https://10.243.9.123") + :port => "443", + :ipaddress => "https://10.243.9.123:443") auth = FactoryGirl.create(:authentication, :userid => 'admin', :password => 'password', @@ -69,7 +72,8 @@ pim = FactoryGirl.create(:physical_infra, :name => "LXCA", :hostname => "https://10.243.9.123", - :ipaddress => "https://10.243.9.123") + :port => "443", + :ipaddress => "https://10.243.9.123:443") auth = FactoryGirl.create(:authentication, :userid => 'admin', :password => 'password', @@ -88,7 +92,8 @@ pim = FactoryGirl.create(:physical_infra, :name => "LXCA", :hostname => "https://10.243.9.123", - :ipaddress => "https://10.243.9.123") + :port => "443", + :ipaddress => "https://10.243.9.123:443") auth = FactoryGirl.create(:authentication, :userid => 'admin', :password => 'password', @@ -107,7 +112,8 @@ pim = FactoryGirl.create(:physical_infra, :name => "LXCA", :hostname => "https://10.243.9.123", - :ipaddress => "https://10.243.9.123") + :port => "443", + :ipaddress => "https://10.243.9.123:443") auth = FactoryGirl.create(:authentication, :userid => 'admin', :password => 'password', @@ -120,7 +126,7 @@ end it 'will execute discover successfully' do - result = described_class.new.class.discover(@auth[:user], @auth[:pass], @auth[:host]) + result = described_class.new.class.discover(@auth[:user], @auth[:pass], @auth[:host], @auth[:port]) expect(result).to eq([]) end