191
191
data = self.dehydrate_summary_output(obj, data)
192
# XXX ltrager 2017-01-27 - Show the testing results in the
193
# commissioning table until we get the testing UI done.
194
if obj.current_testing_script_set is not None:
195
data["commissioning_results"] = self.dehydrate_script_set(
197
obj.current_commissioning_script_set,
198
obj.current_testing_script_set,
201
data["commissioning_results"] = self.dehydrate_script_set(
202
obj.current_commissioning_script_set)
192
data["commissioning_results"] = self.dehydrate_script_set(
193
obj.current_commissioning_script_set)
194
data["testing_results"] = self.dehydrate_script_set(
195
obj.current_testing_script_set)
203
196
data["installation_results"] = self.dehydrate_script_set(
204
197
obj.current_installation_script_set)
205
199
# Third party drivers
206
200
if Config.objects.get_config('enable_third_party_drivers'):
207
201
driver = get_third_party_driver(obj)
421
415
def dehydrate_script_set(self, script_set):
422
"""Dehydrate ScriptResults in the format NodeResults were returned."""
416
"""Dehydrate ScriptResults."""
423
417
if script_set is None:
426
# XXX ltrager 2016-12-22 - This method currently returns a dictionary
427
# identical to what was return with NodeResults. This method will be
428
# updated when the UI has an understanding of script_sets and
430
420
for script_result in script_set:
421
if script_result.script is not None:
422
tags = ', '.join(script_result.script.tags)
431
425
# MAAS stores stdout, stderr, and the combined output. The
432
426
# metadata API determine which field uploaded data should go
433
427
# into based on the extention of the uploaded file. .out goes
436
430
# install.log so its stored as a combined result. This ensures
437
431
# a result is always returned.
438
432
if script_result.stdout != b'':
439
data = script_result.stdout
433
output = script_result.stdout
441
data = script_result.output
435
output = script_result.output
443
437
'id': script_result.id,
444
'result': script_result.exit_status,
445
438
'name': script_result.name,
447
'line_count': len(data.splitlines()),
448
'created': dehydrate_datetime(script_result.updated),
439
'status': script_result.status,
440
'status_name': script_result.status_name,
443
'updated': dehydrate_datetime(script_result.updated),
450
445
if script_result.stderr != b'':
452
447
'id': script_result.id,
453
'result': script_result.exit_status,
454
448
'name': '%s.err' % script_result.name,
455
'data': script_result.stderr,
456
'line_count': len(script_result.stderr.splitlines()),
457
'created': dehydrate_datetime(script_result.updated),
449
'status': script_result.status,
450
'status_name': script_result.status_name,
452
'output': script_result.stderr,
453
'updated': dehydrate_datetime(script_result.updated),
459
455
return sorted(ret, key=lambda i: i['name'])