Skip to content

Commit

Permalink
Added the user_agent when is creating the connection
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlleDaniel authored and Charlle Daniel committed Nov 2, 2017
1 parent 56cf327 commit ac18ab4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
20 changes: 12 additions & 8 deletions app/models/manageiq/providers/lenovo/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ module ManageIQ::Providers::Lenovo::ManagerMixin
nil => 'basic_auth'
}.freeze

USER_AGENT = "CFME/#{MiqServer.first.version}".freeze

def description
"Lenovo XClarity"
end
Expand All @@ -20,10 +22,11 @@ def connect(options = {})
host = options[:host] || address
port = options[:port] || self.port
auth_type = AUTH_TYPES[options[:auth_type]]
user_agent_label = USER_AGENT

# TODO: improve this SSL verification
verify_ssl = options[:verify_ssl] == 1 ? 'PEER' : 'NONE'
self.class.raw_connect(username, password, host, port, auth_type, verify_ssl)
self.class.raw_connect(username, password, host, port, auth_type, verify_ssl, user_agent_label)
end

def verify_credentials(auth_type = nil, options = {})
Expand All @@ -39,14 +42,15 @@ def verify_credentials(auth_type = nil, options = {})
end

module ClassMethods
def raw_connect(username, password, host, port, auth_type, verify_ssl)
def raw_connect(username, password, host, port, auth_type, verify_ssl, user_agent_label)
xclarity = XClarityClient::Configuration.new(
:username => username,
:password => password,
:host => host,
:port => port,
:auth_type => auth_type,
:verify_ssl => verify_ssl
:username => username,
:password => password,
:host => host,
:port => port,
:auth_type => auth_type,
:verify_ssl => verify_ssl,
:user_agent_label => user_agent_label,
)
XClarityClient::Client.new(xclarity)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
describe ManageIQ::Providers::Lenovo::PhysicalInfraManager::RefreshParser do
before :all do
FactoryGirl.create(:miq_server, :version=> 'master')
end
it 'will retrieve physical servers' do
pim = FactoryGirl.create(:physical_infra,
:name => "LXCA",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
describe ManageIQ::Providers::Lenovo::PhysicalInfraManager::Refresher do
before :all do
FactoryGirl.create(:miq_server, :version=> 'master')
end

let(:auth) do
FactoryGirl.create(:authentication,
:userid => 'admin',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
describe ManageIQ::Providers::Lenovo::PhysicalInfraManager do
before :all do
@auth = { :user => 'admin', :pass => 'smartvm', :host => 'localhost', :port => '3000' }
FactoryGirl.create(:miq_server, :version=>'master')
end

it 'will turn on a location LED successfully' do
Expand Down

0 comments on commit ac18ab4

Please sign in to comment.