Skip to content

Commit

Permalink
Merge pull request #164 from jaywcarman/refresh_entire_ems_on_default…
Browse files Browse the repository at this point in the history
…_lpar_uuid

Refresh entire provider for special LPAR UUID

(cherry picked from commit 7eec25f)
  • Loading branch information
Fryguy committed Nov 19, 2024
1 parent 6755ec9 commit d9927f7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class ManageIQ::Providers::IbmPowerHmc::InfraManager::EventTargetParser
attr_reader :ems_event

NO_UUID_VALUE = "88888888-8888-8888-8888-888888888888" # Returned when no UUID assigned to LPAR

def initialize(ems_event)
@ems_event = ems_event
end
Expand All @@ -25,6 +27,7 @@ def parse
)
new_targets = []

ems = ems_event.ext_management_system
raw_event = ems_event.full_data

case ems_event.event_type
Expand All @@ -39,7 +42,12 @@ def parse
# have changed (e.g. RMCState, PartitionName, PartitionState etc...)
# This may be used to perform quick property REST API calls to the HMC
# instead of querying the full LPAR data.
new_targets << {:assoc => :vms, :ems_ref => elems[:uuid]}
if elems[:uuid] == NO_UUID_VALUE
$ibm_power_hmc_log.info("#{self.class}##{__method__} #{elems[:type]} Missing LPAR UUID. Escalating to full refresh for EMS: [#{ems.name}], id: [#{ems.id}].")
target_collection << ems
else
new_targets << {:assoc => :vms, :ems_ref => elems[:uuid]}
end
when "VirtualSwitch", "VirtualNetwork"
if elems.key?(:manager_uuid)
new_targets << {:assoc => :hosts, :ems_ref => elems[:manager_uuid]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@
[[:hosts, {:ems_ref => '977848c8-3bed-360a-c9d2-ae4b7e46b5d1'}]]
)
end
it "LogicalPartition" do
assert_event_triggers_target(
"test_data/logical_partition_long_url.xml",
[[:vms, {:ems_ref => '74CC38E2-C6DD-4B03-A0C6-088F7882EF0E'}]]
)
context "LogicalPartition" do
it "targets the logical partition" do
assert_event_triggers_target(
"test_data/logical_partition_long_url.xml",
[[:vms, {:ems_ref => '74CC38E2-C6DD-4B03-A0C6-088F7882EF0E'}]]
)
end

context "with a missing LPAR UUID" do
it "targets the whole EMS" do
ems_event = create_ems_event("test_data/logical_partition_invalid_uuid.xml")
parsed_targets = described_class.new(ems_event).parse

expect(parsed_targets).to eq([@ems])
end
end
end
it "VirtualIOServer" do
assert_event_triggers_target(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<feed>
<entry>
<id>1afb3833-8a85-369f-977a-bb8741b1a15a</id>
<title>Event</title>
<published>2022-02-02T15:05:12.772Z</published>
<link rel="SELF" href="https://te.st:12443/rest/api/uom/Event/1afb3833-8a85-369f-977a-bb8741b1a15a"/>
<author>
<name>IBM Power Systems Management Console</name>
</author>
<etag:etag xmlns:etag="http://www.ibm.com/xmlns/systems/power/firmware/uom/mc/2012_10/" xmlns="http://www.ibm.com/xmlns/systems/power/firmware/uom/mc/2012_10/">-83524495</etag:etag>
<content type="application/vnd.ibm.powervm.uom+xml; type=Event">
<Event:Event xmlns:Event="http://www.ibm.com/xmlns/systems/power/firmware/uom/mc/2012_10/" xmlns="http://www.ibm.com/xmlns/systems/power/firmware/uom/mc/2012_10/" xmlns:ns2="http://www.w3.org/XML/1998/namespace/k2" schemaVersion="V1_6_0">
<Metadata>
<Atom>
<AtomID>1afb3833-8a85-369f-977a-bb8741b1a15a</AtomID>
<AtomCreated>1639561179310</AtomCreated>
</Atom>
</Metadata>
<EventType kb="ROR" kxe="false">ADD_URI</EventType>
<EventID kb="ROR" kxe="false">1639561179310</EventID>
<EventData kxe="false" kb="ROR">https://te.st:12443/rest/api/uom/ManagedSystem/e4acf909-6d0b-3c03-b75a-4d8495e5fc49/LogicalPartition/88888888-8888-8888-8888-888888888888</EventData>
<EventDetail kxe="false" kb="ROR">Other</EventDetail>
</Event:Event>
</content>
</entry>
</feed>

0 comments on commit d9927f7

Please sign in to comment.