Skip to content

Commit d563fb9

Browse files
Gerald Elder-VassGeraldEV
Gerald Elder-Vass
authored andcommitted
CA-390512: Improved xenapi error handling
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.
1 parent 54d9b4f commit d563fb9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

XSConsoleData.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ def Update(self):
209209
# NULL or dangling reference
210210
self.data['host']['crash_dump_sr'] = None
211211

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

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

361360
self.DeriveData()
362361

362+
def UpdateHostCPUs(self):
363+
convertCPU = lambda cpu: self.session.xenapi.host_cpu.get_record(cpu)
364+
hostCPUs = list(map(convertCPU, self.data['host']['host_CPUs']))
365+
366+
self.data['host']['host_CPUs'] = []
367+
for cpu in hostCPUs:
368+
if 'HANDLE_INVALID' in cpu:
369+
XSLogError('xenapi host_cpu: ' + ', '.join(cpu))
370+
else:
371+
self.data['host']['host_CPUs'].append(cpu)
372+
363373
def DeriveData(self):
364374
self.data.update({
365375
'derived' : {

0 commit comments

Comments
 (0)