Skip to content

Commit

Permalink
Switch the connection type
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyMenezes committed Sep 21, 2017
1 parent eb0a4f9 commit ea1ee31
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 289 deletions.
2 changes: 1 addition & 1 deletion app/models/manageiq/providers/lenovo/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module ManageIQ::Providers::Lenovo::ManagerMixin

AUTH_TYPES = {
'default' => 'token',
nil => 'token'
nil => 'basic_auth'
}.freeze

def description
Expand Down
Original file line number Diff line number Diff line change
@@ -1,70 +1,60 @@
describe ManageIQ::Providers::Lenovo::PhysicalInfraManager::RefreshParser do
context 'refresh parser' do
host = 'https://10.243.9.123'
uri = '/sessions'

before do
WebMock.allow_net_connect!
stub_request(:post, File.join(host, uri)).to_return(:status => [200, 'OK'])
it 'will retrieve physical servers' do
pim = FactoryGirl.create(:physical_infra,
:name => "LXCA",
:hostname => "https://10.243.9.123",
:port => "443",
:ipaddress => "https://10.243.9.123:443")
auth = FactoryGirl.create(:authentication,
:userid => 'admin',
:password => 'password',
:authtype => 'default')
pim.authentications = [auth]
rp = described_class.new(pim)

result = VCR.use_cassette("#{described_class.name.underscore}_ems_inv_to_hashes") do
rp.ems_inv_to_hashes
end

it 'will retrieve physical servers' do
pim = FactoryGirl.create(:physical_infra,
:name => "LXCA",
:hostname => "https://10.243.9.123",
:port => "443",
:ipaddress => "https://10.243.9.123:443")
auth = FactoryGirl.create(:authentication,
:userid => 'admin',
:password => 'password',
:authtype => 'default')
pim.authentications = [auth]
rp = described_class.new(pim)

result = VCR.use_cassette("#{described_class.name.underscore}_ems_inv_to_hashes") do
rp.ems_inv_to_hashes
end
expect(result[:physical_servers].size).to eq(4)
end

expect(result[:physical_servers].size).to eq(4)
it 'will retrieve addin cards on the physical servers' do
pim = FactoryGirl.create(:physical_infra,
:name => "LXCA",
:hostname => "https://10.243.9.123",
:port => "443",
:ipaddress => "https://10.243.9.123:443")
auth = FactoryGirl.create(:authentication,
:userid => 'admin',
:password => 'password',
:authtype => 'default')
pim.authentications = [auth]
rp = described_class.new(pim)

result = VCR.use_cassette("#{described_class.name.underscore}_retrieve_addin_cards") do
rp.ems_inv_to_hashes
end

it 'will retrieve addin cards on the physical servers' do
pim = FactoryGirl.create(:physical_infra,
:name => "LXCA",
:hostname => "https://10.243.9.123",
:port => "443",
:ipaddress => "https://10.243.9.123:443")
auth = FactoryGirl.create(:authentication,
:userid => 'admin',
:password => 'password',
:authtype => 'default')
pim.authentications = [auth]
rp = described_class.new(pim)

result = VCR.use_cassette("#{described_class.name.underscore}_retrieve_addin_cards") do
rp.ems_inv_to_hashes
end

physical_server = result[:physical_servers][0]
computer_system = physical_server[:computer_system]
hardware = computer_system[:hardware]
guest_device = hardware[:guest_devices][0]

expect(guest_device[:device_name]).to eq("Broadcom 2-port 1GbE NIC Card for IBM")
expect(guest_device[:device_type]).to eq("ethernet")
expect(guest_device[:firmwares][0][:name]).to eq("Primary 17.4.4.2a-Active")
expect(guest_device[:firmwares][0][:version]).to eq("17.4.4.2a")
expect(guest_device[:manufacturer]).to eq("IBM")
expect(guest_device[:field_replaceable_unit]).to eq("90Y9373")
expect(guest_device[:location]).to eq("Bay 7")

expect(guest_device[:child_devices][0][:address]).to eq("00:0A:F7:25:67:38")
expect(guest_device[:child_devices][0][:device_type]).to eq("physical_port")
expect(guest_device[:child_devices][0][:device_name]).to eq("Physical Port 1")
end
physical_server = result[:physical_servers][0]
computer_system = physical_server[:computer_system]
hardware = computer_system[:hardware]
guest_device = hardware[:guest_devices][0]

expect(guest_device[:device_name]).to eq("Broadcom 2-port 1GbE NIC Card for IBM")
expect(guest_device[:device_type]).to eq("ethernet")
expect(guest_device[:firmwares][0][:name]).to eq("Primary 17.4.4.2a-Active")
expect(guest_device[:firmwares][0][:version]).to eq("17.4.4.2a")
expect(guest_device[:manufacturer]).to eq("IBM")
expect(guest_device[:field_replaceable_unit]).to eq("90Y9373")
expect(guest_device[:location]).to eq("Bay 7")

expect(guest_device[:child_devices][0][:address]).to eq("00:0A:F7:25:67:38")
expect(guest_device[:child_devices][0][:device_type]).to eq("physical_port")
expect(guest_device[:child_devices][0][:device_name]).to eq("Physical Port 1")
end

it 'will return its miq_template_type' do
expect(described_class.miq_template_type).to eq("ManageIQ::Providers::Lenovo::PhysicalInfraManager::Template")
end
it 'will return its miq_template_type' do
expect(described_class.miq_template_type).to eq("ManageIQ::Providers::Lenovo::PhysicalInfraManager::Template")
end
end
Original file line number Diff line number Diff line change
@@ -1,49 +1,39 @@
describe ManageIQ::Providers::Lenovo::PhysicalInfraManager::Refresher do
context 'inventory' do
host = 'https://10.243.9.123'
uri = '/sessions'

before do
WebMock.allow_net_connect!
stub_request(:post, File.join(host, uri)).to_return(:status => [200, 'OK'])
end

let(:auth) do
FactoryGirl.create(:authentication,
:userid => 'admin',
:password => 'password',
:authtype => 'default')
end

let(:ems) do
FactoryGirl.create(:physical_infra,
:name => "LXCA",
:hostname => "https://10.243.9.123",
:port => "443",
:ipaddress => "https://10.243.9.123:443")
end
let(:auth) do
FactoryGirl.create(:authentication,
:userid => 'admin',
:password => 'password',
:authtype => 'default')
end

let(:targets) { [ems] }
let(:refresher) { described_class.new(targets) }
let(:ems) do
FactoryGirl.create(:physical_infra,
:name => "LXCA",
:hostname => "https://10.243.9.123",
:port => "443",
:ipaddress => "https://10.243.9.123:443")
end

it 'will parse the legacy inventory' do
ems.authentications = [auth]
let(:targets) { [ems] }
let(:refresher) { described_class.new(targets) }

result = VCR.use_cassette("#{described_class.name.underscore}_parse_legacy_inventory") do
refresher.parse_legacy_inventory(ems)
end
it 'will parse the legacy inventory' do
ems.authentications = [auth]

expect(result[:physical_servers].size).to eq(3)
result = VCR.use_cassette("#{described_class.name.underscore}_parse_legacy_inventory") do
refresher.parse_legacy_inventory(ems)
end

it 'will save the inventory' do
ems.authentications = [auth]
expect(result[:physical_servers].size).to eq(3)
end

refresher.save_inventory(ems, {}, {})
end
it 'will save the inventory' do
ems.authentications = [auth]

it 'will execute post_process_refresh_classes' do
expect(refresher.post_process_refresh_classes).to eq([])
end
refresher.save_inventory(ems, {}, {})
end

it 'will execute post_process_refresh_classes' do
expect(refresher.post_process_refresh_classes).to eq([])
end
end
Loading

0 comments on commit ea1ee31

Please sign in to comment.