Skip to content

Commit

Permalink
Enhancement on PhysicalDisks test
Browse files Browse the repository at this point in the history
  • Loading branch information
felipedf committed Nov 9, 2018
1 parent 814471c commit 3c802d3
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@ def build(storage_xclarity, parent)

canister = @persister.canisters.build(data[:parsed_canister])

build_associations(canister, data[:raw_data])
build_associations(parent[:object], canister, data[:raw_data])
end
end

private

# @param canister [InventoryObject]
# @param canister_raw_data [Hash]
def build_associations(canister, canister_raw_data)
def build_associations(storage, canister, canister_raw_data)
comp_system = build_computer_system(canister)
build_hardware(comp_system, canister_raw_data)
build_physical_disks(storage, canister, canister_raw_data)
end

def build_hardware(comp_system, canister_raw_data)
Expand All @@ -66,33 +67,47 @@ def build_guest_devices(hardware, canister_properties)
:object => hardware)
end

def build_physical_disks(storage, canister, canister_raw_data)
driver_index = 0
canister_raw_data.[]('drives')&.each do |drive|
components(:physical_disks).build(drive, driver_index.to_s, storage, canister)
driver_index += 1
end
end

def parse_canisters_inside_components(components)
canisters = []
canister_index = 0
components.each do |component|
component['canisters'].each do |canister|
canisters << { :parsed_canister => parse_canister(canister),
canisters << { :parsed_canister => parse_canister(canister, canister_index),
:raw_data => canister }
canister_index += 1
end
end
canisters
end

def parse_canisters_inside_storage(storage)
canisters = []
canister_index = 0
storage.canisters.each do |canister|
canisters << { :parsed_canister => parse_canister(canister),
canisters << { :parsed_canister => parse_canister(canister, canister_index),
:raw_data => canister }
canister_index += 1
end
canisters
end

def parse_canister(canister)
def parse_canister(canister, canister_index)
result = {}
CANISTER.each_pair do |key, canister_key|
next unless canister_key.kind_of?(String)

result[key] = canister[canister_key]
end
result[:ems_ref] = (canister['uuid'] || '') + '_' + canister_index.to_s

result
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ module ManageIQ::Providers::Lenovo::Inventory::Persister::Definitions::PhysicalI
extend ActiveSupport::Concern

def initialize_physical_infra_inventory_collections
%i(customization_scripts
%i(canisters
customization_scripts
physical_chassis
physical_disks
physical_racks
physical_servers
physical_storages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,39 +121,46 @@ def assert_specific_server
end

def assert_specific_storage
storage = PhysicalStorage.find_by(:ems_ref => "208000C0FF2683AF")
storage_physical_disk_one = PhysicalDisk.find_by(:ems_ref => "208000C0FF2683AF_0")
storage = PhysicalStorage.find_by(:ems_ref => "123400C0FF261234")
canister = Canister.find_by(:ems_ref => "_0")
physical_disk_one = PhysicalDisk.find_by(:ems_ref => "123400C0FF261234_0")

expect(storage.name).to eq("S3200-1")
expect(storage.uid_ems).to eq("208000C0FF2683AF")
expect(storage.ems_ref).to eq("208000C0FF2683AF")
expect(storage.access_state).to eq("Online")
expect(storage.name).to eq("S8000-1")
expect(storage.uid_ems).to eq("123400C0FF261234")
expect(storage.ems_ref).to eq("123400C0FF261234")
expect(storage.access_state).to eq("Online")
expect(storage.health_state).to eq("Critical")
expect(storage.overall_health_state).to eq("Critical")
expect(storage.type).to eq("ManageIQ::Providers::Lenovo::PhysicalInfraManager::PhysicalStorage")
expect(storage.drive_bays).to eq(12)
expect(storage.enclosures).to eq(1)
expect(storage.canister_slots).to eq(2)
expect(storage.physical_disks.count).to eq(4)
expect(storage.canisters.count).to eq(2)

expect(storage_physical_disk_one.model).to eq("ST9300653SS")
expect(storage_physical_disk_one.vendor).to eq("IBM-ESXS")
expect(storage_physical_disk_one.status).to eq("Up")
expect(storage_physical_disk_one.location).to eq("0.22")
expect(storage_physical_disk_one.serial_number).to eq("6XN43QX50000B349D4LY")
expect(storage_physical_disk_one.health_state).to eq("OK")
expect(storage_physical_disk_one.controller_type).to eq("SAS")
expect(storage_physical_disk_one.disk_size).to eq("300.0GB")
expect(storage_physical_disk_one.physical_storage_id).to eq(storage.id)
expect(storage.physical_disks.size).to eq(1)
expect(storage.canisters.size).to eq(2)

expect(canister.name).to eq("controller_a")
expect(canister.ems_ref).to eq("_0")
expect(canister.status).to eq("Operational")
expect(canister.controller_redundancy_status).to eq("Operational but not redundant")
expect(canister.physical_disks.size).to eq(1)

expect(physical_disk_one.model).to eq("Canister_Driver_Model")
expect(physical_disk_one.vendor).to eq("Canister_Driver_Vendor")
expect(physical_disk_one.status).to eq("Up")
expect(physical_disk_one.location).to eq("0.50")
expect(physical_disk_one.serial_number).to eq("20183QX50000B3492018")
expect(physical_disk_one.health_state).to eq("OK")
expect(physical_disk_one.controller_type).to eq("SAS")
expect(physical_disk_one.disk_size).to eq("300.0GB")
expect(physical_disk_one.physical_storage_id).to eq(storage.id)
expect(physical_disk_one.canister_id).to eq(canister.id)
end

def assert_table_counts
expect(PhysicalRack.count).to eq(3)
expect(PhysicalServer.count).to eq(2)
expect(PhysicalStorage.count).to eq(2)
expect(PhysicalDisk.count).to eq(4)
expect(PhysicalDisk.count).to eq(5)
expect(GuestDevice.count).to eq(8)
expect(PhysicalNetworkPort.count).to eq(50)
end
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3c802d3

Please sign in to comment.