Skip to content

Commit

Permalink
Merge pull request #60 from AndreyMenezes/master-upstream
Browse files Browse the repository at this point in the history
Passing the API Port to Xclarity_client
  • Loading branch information
juliancheal authored Jul 24, 2017
2 parents d10e68d + fd439fd commit 45b530d
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 19 deletions.
10 changes: 6 additions & 4 deletions app/models/manageiq/providers/lenovo/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
2 changes: 1 addition & 1 deletion manageiq-providers-lenovo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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

Expand Down

0 comments on commit 45b530d

Please sign in to comment.