Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to switch connection type #79

Merged
merged 1 commit into from
Sep 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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