Skip to content

Commit

Permalink
CA-390512: Improved xenapi error handling
Browse files Browse the repository at this point in the history
In some cases we may fail to query the host CPUs due to an invalid
reference, in this case we should log the failure and not add it into
the list of host CPUs.
In the event of a failure we receive a list of the form:
['HANDLE_INVALID', 'host_cpu', '<uuid>']
In a success we receive a dictionary which is later used to populate the
number of CPUs per name but does not check that the contents of
host_CPUs is a list of dictionaries.
  • Loading branch information
Gerald Elder-Vass authored and GeraldEV committed Jul 23, 2024
1 parent 54d9b4f commit d563fb9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions XSConsoleData.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ def Update(self):
# NULL or dangling reference
self.data['host']['crash_dump_sr'] = None

convertCPU = lambda cpu: self.session.xenapi.host_cpu.get_record(cpu)
self.data['host']['host_CPUs'] = list(map(convertCPU, self.data['host']['host_CPUs']))
self.UpdateHostCPUs()

def convertPIF(inPIF):
retVal = self.session.xenapi.PIF.get_record(inPIF)
Expand Down Expand Up @@ -360,6 +359,17 @@ def update_SR_reference(inPool, retPool, key):

self.DeriveData()

def UpdateHostCPUs(self):
convertCPU = lambda cpu: self.session.xenapi.host_cpu.get_record(cpu)
hostCPUs = list(map(convertCPU, self.data['host']['host_CPUs']))

self.data['host']['host_CPUs'] = []
for cpu in hostCPUs:
if 'HANDLE_INVALID' in cpu:
XSLogError('xenapi host_cpu: ' + ', '.join(cpu))
else:
self.data['host']['host_CPUs'].append(cpu)

def DeriveData(self):
self.data.update({
'derived' : {
Expand Down

0 comments on commit d563fb9

Please sign in to comment.