Skip to content

Commit

Permalink
Merge pull request #114 from dberg1/labels
Browse files Browse the repository at this point in the history
hmc groups as vm labels
  • Loading branch information
agrare committed Nov 17, 2022
2 parents 6b1de84 + e096c8c commit b3289a2
Show file tree
Hide file tree
Showing 7 changed files with 2,215 additions and 2,018 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ def hmc
end
end

def groups
@groups ||= connection.groups.index_by(&:uuid)
rescue => e
$ibm_power_hmc_log.error("groups query failed: #{e}")
raise
end

def ssps
@ssps ||= begin
connection.ssps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def parse_lpar_common(lpar, type)
)
parse_vm_operating_system(vm, lpar)
parse_vm_advanced_settings(vm, lpar)
parse_vm_labels(vm, lpar)

hardware = parse_vm_hardware(vm, lpar)
parse_vm_networks(lpar, hardware)
Expand All @@ -245,6 +246,23 @@ def parse_lpar_common(lpar, type)
[vm, hardware]
end

def parse_vm_labels(vm, lpar)
# Common code for LPARs and VIOSes.
lpar.group_uuids.each do |uuid|
next unless collector.groups.key?(uuid)

group = collector.groups[uuid]
persister.vm_and_template_labels.build(
:resource => vm,
:name => group.name,
:section => "labels",
:source => "ibm_power_hmc",
:value => "",
:description => group.description
)
end
end

def parse_vm_hardware(vm, lpar)
# Common code for LPARs, VIOSes and templates.
persister.hardwares.build(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ def initialize_inventory_collections
add_collection(infra, :resource_pools)
add_collection(infra, :vm_resource_pools)
add_collection(infra, :parent_blue_folders)
add_collection(infra, :vm_and_template_labels)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ def assert_specific_vios
:read_only => true
)

expect(vios.labels.count).to eq(1)
expect(vios.labels.first.name).to eq("ManageIQ")

expect(vios.host).not_to be_nil
expect(vios.host.name).to eq("aramis")

Expand Down Expand Up @@ -271,6 +274,9 @@ def assert_specific_lpar
:read_only => true
)

expect(lpar.labels.count).to eq(1)
expect(lpar.labels.first.name).to eq("ManageIQ")

expect(lpar.host).not_to be_nil
expect(lpar.host.ems_ref).to eq(host_uuid)

Expand Down
3,207 changes: 1,714 additions & 1,493 deletions spec/vcr_cassettes/manageiq/providers/ibm_power_hmc/infra_manager/refresher.yml

Large diffs are not rendered by default.

0 comments on commit b3289a2

Please sign in to comment.