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

hmc groups as vm labels #114

Merged
merged 3 commits into from
Nov 17, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -208,6 +208,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 @@ -269,6 +272,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.