~andreserl/maas/refactor_debconf_selections_preseed

« back to all changes in this revision

Viewing changes to src/maasserver/websockets/handlers/node.py

  • Committer: MAAS Lander
  • Author(s): Lee Trager
  • Date: 2017-03-01 22:46:02 UTC
  • mfrom: (5755.3.5 test_result_ui)
  • Revision ID: maas_lander-20170301224602-pd2kbtwexkqd5r2b
[r=andreserl][bug=][author=ltrager] Add a section to the UI for test results.

Show diffs side-by-side

added added

removed removed

Lines of Context:
189
189
 
190
190
                # Machine output
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(
196
 
                        chain(
197
 
                            obj.current_commissioning_script_set,
198
 
                            obj.current_testing_script_set,
199
 
                        ))
200
 
                else:
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)
 
198
 
205
199
                # Third party drivers
206
200
                if Config.objects.get_config('enable_third_party_drivers'):
207
201
                    driver = get_third_party_driver(obj)
419
413
        return data
420
414
 
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:
424
418
            return []
425
419
        ret = []
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
429
 
        # script_results.
430
420
        for script_result in script_set:
 
421
            if script_result.script is not None:
 
422
                tags = ', '.join(script_result.script.tags)
 
423
            else:
 
424
                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
440
434
            else:
441
 
                data = script_result.output
 
435
                output = script_result.output
442
436
            ret.append({
443
437
                'id': script_result.id,
444
 
                'result': script_result.exit_status,
445
438
                'name': script_result.name,
446
 
                'data': data,
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,
 
441
                'tags': tags,
 
442
                'output': output,
 
443
                'updated': dehydrate_datetime(script_result.updated),
449
444
            })
450
445
            if script_result.stderr != b'':
451
446
                ret.append({
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,
 
451
                    'tags': tags,
 
452
                    'output': script_result.stderr,
 
453
                    'updated': dehydrate_datetime(script_result.updated),
458
454
                })
459
455
        return sorted(ret, key=lambda i: i['name'])
460
456