Ejemplo n.º 1
0
    def test_health_status(self):
        self.become_admin()
        machine = factory.make_Machine(owner=self.user)
        commissioning_script_set = factory.make_ScriptSet(
            result_type=RESULT_TYPE.COMMISSIONING, node=machine)
        testing_script_set = factory.make_ScriptSet(
            result_type=RESULT_TYPE.TESTING, node=machine)
        make_script_result = partial(factory.make_ScriptResult,
                                     script_set=testing_script_set,
                                     status=factory.pick_choice(
                                         SCRIPT_STATUS_CHOICES,
                                         but_not=[SCRIPT_STATUS.ABORTED]))
        commissioning_script_result = make_script_result(
            script_set=commissioning_script_set,
            script=factory.make_Script(script_type=SCRIPT_TYPE.COMMISSIONING))
        cpu_script_result = make_script_result(script=factory.make_Script(
            script_type=SCRIPT_TYPE.TESTING, hardware_type=HARDWARE_TYPE.CPU))
        memory_script_result = make_script_result(
            script=factory.make_Script(script_type=SCRIPT_TYPE.TESTING,
                                       hardware_type=HARDWARE_TYPE.MEMORY))
        storage_script_result = make_script_result(
            script=factory.make_Script(script_type=SCRIPT_TYPE.TESTING,
                                       hardware_type=HARDWARE_TYPE.STORAGE))
        node_script_result = make_script_result(script=factory.make_Script(
            script_type=SCRIPT_TYPE.TESTING, hardware_type=HARDWARE_TYPE.NODE))
        testing_script_results = (
            machine.get_latest_testing_script_results.exclude(
                status=SCRIPT_STATUS.ABORTED))
        testing_status = get_status_from_qs(testing_script_results)

        response = self.client.get(self.get_node_uri(machine))
        parsed_result = json_load_bytes(response.content)

        status = lambda s: get_status_from_qs([s])
        status_name = lambda s: SCRIPT_STATUS_CHOICES[status(s)][1]
        self.assertThat(response, HasStatusCode(http.client.OK))
        self.assertEquals(status(commissioning_script_result),
                          parsed_result['commissioning_status'])
        self.assertEquals(status_name(commissioning_script_result),
                          parsed_result['commissioning_status_name'])
        self.assertEquals(testing_status, parsed_result['testing_status'])
        self.assertEquals(SCRIPT_STATUS_CHOICES[testing_status][1],
                          parsed_result['testing_status_name'])
        self.assertEquals(status(cpu_script_result),
                          parsed_result['cpu_test_status'])
        self.assertEquals(status_name(cpu_script_result),
                          parsed_result['cpu_test_status_name'])
        self.assertEquals(status(memory_script_result),
                          parsed_result['memory_test_status'])
        self.assertEquals(status_name(memory_script_result),
                          parsed_result['memory_test_status_name'])
        self.assertEquals(status(storage_script_result),
                          parsed_result['storage_test_status'])
        self.assertEquals(status_name(storage_script_result),
                          parsed_result['storage_test_status_name'])
        self.assertEquals(status(node_script_result),
                          parsed_result['other_test_status'])
        self.assertEquals(status_name(node_script_result),
                          parsed_result['other_test_status_name'])
Ejemplo n.º 2
0
 def interface_test_status(handler, node):
     get_cached_script_results(node)
     return get_status_from_qs([
         script_result
         for script_result in node._cached_testing_script_results
         if script_result.script.hardware_type == HARDWARE_TYPE.NETWORK
     ])
Ejemplo n.º 3
0
 def storage_test_status(handler, node):
     get_cached_script_results(node)
     return get_status_from_qs([
         script_result
         for script_result in node._cached_testing_script_results
         if script_result.script.hardware_type == HARDWARE_TYPE.STORAGE
     ])
Ejemplo n.º 4
0
 def memory_test_status(handler, node):
     get_cached_script_results(node)
     return get_status_from_qs([
         script_result
         for script_result in node._cached_testing_script_results
         if script_result.script.hardware_type == HARDWARE_TYPE.MEMORY
     ])
Ejemplo n.º 5
0
 def dehydrate_test_statuses(self, script_results):
     pending = 0
     running = 0
     passed = 0
     failed = 0
     for script_result in script_results:
         if script_result.status == SCRIPT_STATUS.PENDING:
             pending += 1
         elif script_result.status == SCRIPT_STATUS.RUNNING:
             running += 1
         elif script_result.status in (
             SCRIPT_STATUS.PASSED,
             SCRIPT_STATUS.SKIPPED,
         ):
             passed += 1
         elif script_result.status in (
             SCRIPT_STATUS.ABORTED,
             SCRIPT_STATUS.DEGRADED,
         ):
             # UI doesn't show aborted or degraded status in listing.
             continue
         else:
             failed += 1
     return {
         "status": get_status_from_qs(script_results),
         "pending": pending,
         "running": running,
         "passed": passed,
         "failed": failed,
     }
Ejemplo n.º 6
0
    def dehydrate_blockdevice(self, blockdevice, obj):
        """Return `BlockDevice` formatted for JSON encoding."""
        # model and serial are currently only avalible on physical block
        # devices
        if isinstance(blockdevice, PhysicalBlockDevice):
            model = blockdevice.model
            serial = blockdevice.serial
            firmware_version = blockdevice.firmware_version
        else:
            serial = model = firmware_version = ""
        partition_table = blockdevice.get_partitiontable()
        if partition_table is not None:
            partition_table_type = partition_table.table_type
        else:
            partition_table_type = ""
        is_boot = blockdevice.id == obj.get_boot_disk().id
        data = {
            "id": blockdevice.id,
            "is_boot": is_boot,
            "name": blockdevice.get_name(),
            "tags": blockdevice.tags,
            "type": blockdevice.type,
            "path": blockdevice.path,
            "size": blockdevice.size,
            "size_human": human_readable_bytes(blockdevice.size),
            "used_size": blockdevice.used_size,
            "used_size_human": human_readable_bytes(
                blockdevice.used_size),
            "available_size": blockdevice.available_size,
            "available_size_human": human_readable_bytes(
                blockdevice.available_size),
            "block_size": blockdevice.block_size,
            "model": model,
            "serial": serial,
            "firmware_version": firmware_version,
            "partition_table_type": partition_table_type,
            "used_for": blockdevice.used_for,
            "filesystem": self.dehydrate_filesystem(
                blockdevice.get_effective_filesystem()),
            "partitions": self.dehydrate_partitions(
                blockdevice.get_partitiontable()),
        }
        if isinstance(blockdevice, VirtualBlockDevice):
            data["parent"] = {
                "id": blockdevice.filesystem_group.id,
                "uuid": blockdevice.filesystem_group.uuid,
                "type": blockdevice.filesystem_group.group_type,
            }
        # Calculate script results status for blockdevice
        # if a physical block device.
        blockdevice_script_results = [
            script_result
            for results in self._script_results.values()
            for script_results in results.values()
            for script_result in script_results
            if script_result.physical_blockdevice_id == blockdevice.id
        ]
        data["test_status"] = get_status_from_qs(blockdevice_script_results)

        return data
Ejemplo n.º 7
0
    def dehydrate(self, obj, data, for_list=False):
        """Add extra fields to `data`."""
        data = super(MachineHandler, self).dehydrate(obj,
                                                     data,
                                                     for_list=for_list)
        data.update({
            "locked": obj.locked,
            "pool": self.dehydrate_pool(obj.pool),
        })

        if obj.is_machine or not for_list:
            boot_interface = obj.get_boot_interface()
            if boot_interface is not None:
                data["pxe_mac"] = "%s" % boot_interface.mac_address
                data["pxe_mac_vendor"] = obj.get_pxe_mac_vendor()
                data["power_type"] = obj.power_type
                data["vlan"] = self.dehydrate_vlan(obj, boot_interface)
                if for_list:
                    data["ip_addresses"] = self.dehydrate_all_ip_addresses(obj)
            else:
                data["pxe_mac"] = data["pxe_mac_vendor"] = ""

        # Needed for machines to show up in the Pod details page.
        if obj.bmc is not None and obj.bmc.bmc_type == BMC_TYPE.POD:
            data['pod'] = self.dehydrate_pod(obj.bmc)

        cpu_script_results = [
            script_result for script_result in self._script_results.get(
                obj.id, {}).get(HARDWARE_TYPE.CPU, [])
            if script_result.script_set.result_type == RESULT_TYPE.TESTING
        ]
        data["cpu_test_status"] = get_status_from_qs(cpu_script_results)
        cpu_tooltip = self.dehydrate_hardware_status_tooltip(
            cpu_script_results)
        data["cpu_test_status_tooltip"] = cpu_tooltip

        memory_script_results = [
            script_result for script_result in self._script_results.get(
                obj.id, {}).get(HARDWARE_TYPE.MEMORY, [])
            if script_result.script_set.result_type == RESULT_TYPE.TESTING
        ]
        data["memory_test_status"] = get_status_from_qs(memory_script_results)
        memory_tooltip = self.dehydrate_hardware_status_tooltip(
            memory_script_results)
        data["memory_test_status_tooltip"] = memory_tooltip

        storage_script_results = [
            script_result for script_result in self._script_results.get(
                obj.id, {}).get(HARDWARE_TYPE.STORAGE, [])
            if script_result.script_set.result_type == RESULT_TYPE.TESTING
        ]
        data["storage_test_status"] = get_status_from_qs(
            storage_script_results)
        storage_tooltip = self.dehydrate_hardware_status_tooltip(
            storage_script_results)
        data["storage_test_status_tooltip"] = storage_tooltip

        node_script_results = [
            script_result for script_result in self._script_results.get(
                obj.id, {}).get(HARDWARE_TYPE.NODE, [])
            if script_result.script_set.result_type == RESULT_TYPE.TESTING
        ]
        data["other_test_status"] = get_status_from_qs(node_script_results)
        other_tooltip = self.dehydrate_hardware_status_tooltip(
            node_script_results)
        data["other_test_status_tooltip"] = other_tooltip

        if obj.status in {NODE_STATUS.TESTING, NODE_STATUS.FAILED_TESTING}:
            # Create a list of all results from all types.
            script_results = []
            for hardware_script_results in self._script_results.get(
                    obj.id, {}).values():
                script_results += hardware_script_results
            data["status_tooltip"] = (
                self.dehydrate_hardware_status_tooltip(script_results))
        else:
            data["status_tooltip"] = ""

        if not for_list:
            # Add info specific to a machine.
            data["show_os_info"] = self.dehydrate_show_os_info(obj)
            devices = [
                self.dehydrate_device(device) for device in obj.children.all()
            ]
            data["devices"] = sorted(devices, key=itemgetter("fqdn"))

        return data
Ejemplo n.º 8
0
 def testing_status(handler, node):
     get_cached_script_results(node)
     return get_status_from_qs(node._cached_testing_script_results)
Ejemplo n.º 9
0
 def commissioning_status(handler, node):
     get_cached_script_results(node)
     return get_status_from_qs(node._cached_commissioning_script_results)
Ejemplo n.º 10
0
    def dehydrate(self, obj, data, for_list=False):
        """Add extra fields to `data`."""
        data = super(MachineHandler, self).dehydrate(obj,
                                                     data,
                                                     for_list=for_list)
        bmc = obj.bmc
        if bmc is not None and bmc.bmc_type == BMC_TYPE.POD:
            data['pod'] = bmc.id

        if not for_list:
            # Add info specific to a machine.
            data["show_os_info"] = self.dehydrate_show_os_info(obj)
            devices = [
                self.dehydrate_device(device) for device in obj.children.all()
            ]
            data["devices"] = sorted(devices, key=itemgetter("fqdn"))

        cpu_script_results = [
            script_result for script_result in self._script_results.get(
                obj.id, {}).get(HARDWARE_TYPE.CPU, [])
            if script_result.script_set.result_type == RESULT_TYPE.TESTING
        ]
        data["cpu_test_status"] = get_status_from_qs(cpu_script_results)
        cpu_tooltip = self.dehydrate_hardware_status_tooltip(
            cpu_script_results)
        data["cpu_test_status_tooltip"] = cpu_tooltip

        memory_script_results = [
            script_result for script_result in self._script_results.get(
                obj.id, {}).get(HARDWARE_TYPE.MEMORY, [])
            if script_result.script_set.result_type == RESULT_TYPE.TESTING
        ]
        data["memory_test_status"] = get_status_from_qs(memory_script_results)
        memory_tooltip = self.dehydrate_hardware_status_tooltip(
            memory_script_results)
        data["memory_test_status_tooltip"] = memory_tooltip

        storage_script_results = [
            script_result for script_result in self._script_results.get(
                obj.id, {}).get(HARDWARE_TYPE.STORAGE, [])
            if script_result.script_set.result_type == RESULT_TYPE.TESTING
        ]
        data["storage_test_status"] = get_status_from_qs(
            storage_script_results)
        storage_tooltip = self.dehydrate_hardware_status_tooltip(
            storage_script_results)
        data["storage_test_status_tooltip"] = storage_tooltip

        node_script_results = [
            script_result for script_result in self._script_results.get(
                obj.id, {}).get(HARDWARE_TYPE.NODE, [])
            if script_result.script_set.result_type == RESULT_TYPE.TESTING
        ]
        data["other_test_status"] = get_status_from_qs(node_script_results)
        other_tooltip = self.dehydrate_hardware_status_tooltip(
            node_script_results)
        data["other_test_status_tooltip"] = other_tooltip

        if obj.status in {NODE_STATUS.TESTING, NODE_STATUS.FAILED_TESTING}:
            # Create a list of all results from all types.
            script_results = []
            for hardware_script_results in self._script_results.get(
                    obj.id, {}).values():
                script_results += hardware_script_results
            data["status_tooltip"] = (
                self.dehydrate_hardware_status_tooltip(script_results))
        else:
            data["status_tooltip"] = ""

        return data
Ejemplo n.º 11
0
 def status(s):
     return get_status_from_qs([s])
Ejemplo n.º 12
0
    def test_health_status(self):
        self.become_admin()
        machine = factory.make_Machine(owner=self.user)
        commissioning_script_set = factory.make_ScriptSet(
            result_type=RESULT_TYPE.COMMISSIONING, node=machine)
        testing_script_set = factory.make_ScriptSet(
            result_type=RESULT_TYPE.TESTING, node=machine)
        make_script_result = partial(
            factory.make_ScriptResult,
            script_set=testing_script_set,
            status=factory.pick_choice(SCRIPT_STATUS_CHOICES,
                                       but_not=[SCRIPT_STATUS.ABORTED]),
        )
        commissioning_script_result = make_script_result(
            script_set=commissioning_script_set,
            script=factory.make_Script(script_type=SCRIPT_TYPE.COMMISSIONING),
        )
        cpu_script_result = make_script_result(script=factory.make_Script(
            script_type=SCRIPT_TYPE.TESTING,
            hardware_type=HARDWARE_TYPE.CPU,
        ))
        memory_script_result = make_script_result(script=factory.make_Script(
            script_type=SCRIPT_TYPE.TESTING,
            hardware_type=HARDWARE_TYPE.MEMORY,
        ))
        network_script_result = make_script_result(script=factory.make_Script(
            script_type=SCRIPT_TYPE.TESTING,
            hardware_type=HARDWARE_TYPE.NETWORK,
        ))
        storage_script_result = make_script_result(script=factory.make_Script(
            script_type=SCRIPT_TYPE.TESTING,
            hardware_type=HARDWARE_TYPE.STORAGE,
        ))
        node_script_result = make_script_result(script=factory.make_Script(
            script_type=SCRIPT_TYPE.TESTING,
            hardware_type=HARDWARE_TYPE.NODE,
        ))
        interface_script_result = make_script_result(
            script=factory.make_Script(
                script_type=SCRIPT_TYPE.TESTING,
                hardware_type=HARDWARE_TYPE.NETWORK,
            ))
        testing_script_results = machine.get_latest_testing_script_results.exclude(
            status=SCRIPT_STATUS.ABORTED)
        testing_status = get_status_from_qs(testing_script_results)

        response = self.client.get(self.get_node_uri(machine))
        parsed_result = json_load_bytes(response.content)

        def status(s):
            return get_status_from_qs([s])

        def status_name(s):
            return SCRIPT_STATUS_CHOICES[status(s)][1]

        self.assertThat(response, HasStatusCode(http.client.OK))
        self.assertEquals(
            status(commissioning_script_result),
            parsed_result["commissioning_status"],
        )
        self.assertEquals(
            status_name(commissioning_script_result),
            parsed_result["commissioning_status_name"],
        )
        self.assertEquals(testing_status, parsed_result["testing_status"])
        self.assertEquals(
            SCRIPT_STATUS_CHOICES[testing_status][1],
            parsed_result["testing_status_name"],
        )
        self.assertEquals(status(cpu_script_result),
                          parsed_result["cpu_test_status"])
        self.assertEquals(
            status_name(cpu_script_result),
            parsed_result["cpu_test_status_name"],
        )
        self.assertEquals(status(memory_script_result),
                          parsed_result["memory_test_status"])
        self.assertEquals(
            status_name(memory_script_result),
            parsed_result["memory_test_status_name"],
        )
        self.assertEquals(status(network_script_result),
                          parsed_result["network_test_status"])
        self.assertEquals(
            status_name(network_script_result),
            parsed_result["network_test_status_name"],
        )
        self.assertEquals(status(storage_script_result),
                          parsed_result["storage_test_status"])
        self.assertEquals(
            status_name(storage_script_result),
            parsed_result["storage_test_status_name"],
        )
        self.assertEquals(status(node_script_result),
                          parsed_result["other_test_status"])
        self.assertEquals(
            status_name(node_script_result),
            parsed_result["other_test_status_name"],
        )
        self.assertEquals(
            status(interface_script_result),
            parsed_result["interface_test_status"],
        )
        self.assertEquals(
            status_name(interface_script_result),
            parsed_result["interface_test_status_name"],
        )
Ejemplo n.º 13
0
Archivo: node.py Proyecto: laoyin/maas
    def dehydrate(self, obj, data, for_list=False):
        """Add extra fields to `data`."""
        data["fqdn"] = obj.fqdn
        data["actions"] = list(compile_node_actions(obj, self.user).keys())
        data["node_type_display"] = obj.get_node_type_display()
        data["link_type"] = NODE_TYPE_TO_LINK_TYPE[obj.node_type]

        data["extra_macs"] = [
            "%s" % mac_address for mac_address in obj.get_extra_macs()
        ]
        subnets = self.get_all_subnets(obj)
        data["subnets"] = [subnet.cidr for subnet in subnets]
        data["fabrics"] = self.get_all_fabric_names(obj, subnets)
        data["spaces"] = self.get_all_space_names(subnets)

        data["tags"] = [tag.name for tag in obj.tags.all()]
        data["metadata"] = {
            metadata.key: metadata.value
            for metadata in obj.nodemetadata_set.all()
        }
        if obj.node_type != NODE_TYPE.DEVICE:
            data["architecture"] = obj.architecture
            data["memory"] = obj.display_memory()
            data["status"] = obj.display_status()
            data["status_code"] = obj.status
            boot_interface = obj.get_boot_interface()
            if boot_interface is not None:
                data["pxe_mac"] = "%s" % boot_interface.mac_address
                data["pxe_mac_vendor"] = obj.get_pxe_mac_vendor()
            else:
                data["pxe_mac"] = data["pxe_mac_vendor"] = ""

            blockdevices = self.get_blockdevices_for(obj)
            physical_blockdevices = [
                blockdevice for blockdevice in blockdevices
                if isinstance(blockdevice, PhysicalBlockDevice)
            ]
            data["physical_disk_count"] = len(physical_blockdevices)
            data["storage"] = "%3.1f" % (
                sum(blockdevice.size
                    for blockdevice in physical_blockdevices) / (1000**3))
            data["storage_tags"] = self.get_all_storage_tags(blockdevices)
            data["grouped_storages"] = self.get_grouped_storages(
                physical_blockdevices)

            data["osystem"] = obj.get_osystem(default=self.default_osystem)
            data["distro_series"] = obj.get_distro_series(
                default=self.default_distro_series)
            data["dhcp_on"] = self.get_providing_dhcp(obj)

        if obj.node_type != NODE_TYPE.DEVICE:
            commissioning_script_results = []
            testing_script_results = []
            log_results = set()
            for hw_type in self._script_results.get(obj.id, {}).values():
                for script_result in hw_type:
                    if (script_result.script_set.result_type ==
                            RESULT_TYPE.INSTALLATION):
                        # Don't include installation results in the health
                        # status.
                        continue
                    elif script_result.status == SCRIPT_STATUS.ABORTED:
                        # LP: #1724235 - Ignore aborted scripts.
                        continue
                    elif (script_result.script_set.result_type ==
                          RESULT_TYPE.COMMISSIONING):
                        commissioning_script_results.append(script_result)
                        if (script_result.name in script_output_nsmap and
                                script_result.status == SCRIPT_STATUS.PASSED):
                            log_results.add(script_result.name)
                    elif (script_result.script_set.result_type ==
                          RESULT_TYPE.TESTING):
                        testing_script_results.append(script_result)

            data["commissioning_script_count"] = len(
                commissioning_script_results)
            data["commissioning_status"] = get_status_from_qs(
                commissioning_script_results)
            data["commissioning_status_tooltip"] = (
                self.dehydrate_hardware_status_tooltip(
                    commissioning_script_results).replace(
                        'test', 'commissioning script'))
            data["testing_script_count"] = len(testing_script_results)
            data["testing_status"] = get_status_from_qs(testing_script_results)
            data["testing_status_tooltip"] = (
                self.dehydrate_hardware_status_tooltip(testing_script_results))
            data["has_logs"] = (log_results.difference(
                script_output_nsmap.keys()) == set())

        if not for_list:
            data["on_network"] = obj.on_network()
            if obj.node_type != NODE_TYPE.DEVICE:
                # XXX lamont 2017-02-15 Much of this should be split out into
                # individual methods, rather than having this huge block of
                # dense code here.
                # Network
                data["interfaces"] = [
                    self.dehydrate_interface(interface, obj)
                    for interface in obj.interface_set.all().order_by('name')
                ]

                data["hwe_kernel"] = make_hwe_kernel_ui_text(obj.hwe_kernel)

                data["power_type"] = obj.power_type
                data["power_parameters"] = self.dehydrate_power_parameters(
                    obj.power_parameters)
                data["power_bmc_node_count"] = obj.bmc.node_set.count() if (
                    obj.bmc is not None) else 0

                # Storage
                data["disks"] = sorted(chain(
                    (self.dehydrate_blockdevice(blockdevice, obj)
                     for blockdevice in blockdevices),
                    (self.dehydrate_volume_group(volume_group) for volume_group
                     in VolumeGroup.objects.filter_by_node(obj)),
                    (self.dehydrate_cache_set(cache_set) for cache_set in
                     CacheSet.objects.get_cache_sets_for_node(obj)),
                ),
                                       key=itemgetter("name"))
                data["supported_filesystems"] = [{
                    'key': key,
                    'ui': ui
                } for key, ui in FILESYSTEM_FORMAT_TYPE_CHOICES]
                data["storage_layout_issues"] = obj.storage_layout_issues()
                data["special_filesystems"] = [
                    self.dehydrate_filesystem(filesystem)
                    for filesystem in obj.special_filesystems.order_by("id")
                ]

                # Events
                data["events"] = self.dehydrate_events(obj)

                # Machine logs
                data["installation_status"] = self.dehydrate_script_set_status(
                    obj.current_installation_script_set)

                # Third party drivers
                if Config.objects.get_config('enable_third_party_drivers'):
                    driver = get_third_party_driver(obj)
                    if "module" in driver and "comment" in driver:
                        data["third_party_driver"] = {
                            "module": driver["module"],
                            "comment": driver["comment"],
                        }

        return data
Ejemplo n.º 14
0
    def dehydrate(self, obj, data, for_list=False):
        """Add extra fields to `data`."""
        data["fqdn"] = obj.fqdn
        data["actions"] = list(compile_node_actions(obj, self.user).keys())
        data["node_type_display"] = obj.get_node_type_display()
        data["link_type"] = NODE_TYPE_TO_LINK_TYPE[obj.node_type]
        data["tags"] = [tag.name for tag in obj.tags.all()]

        if obj.node_type == NODE_TYPE.MACHINE or (obj.is_controller
                                                  and not for_list):
            # Disk count and storage amount is shown on the machine listing
            # page and the machine and controllers details page.
            blockdevices = self.get_blockdevices_for(obj)
            physical_blockdevices = [
                blockdevice for blockdevice in blockdevices
                if isinstance(blockdevice, PhysicalBlockDevice)
            ]
            data["physical_disk_count"] = len(physical_blockdevices)
            data["storage"] = round(
                sum(blockdevice.size
                    for blockdevice in physical_blockdevices) / (1000**3), 1)
            data["storage_tags"] = self.get_all_storage_tags(blockdevices)
            commissioning_script_results = []
            testing_script_results = []
            log_results = set()
            for hw_type in self._script_results.get(obj.id, {}).values():
                for script_result in hw_type:
                    if (script_result.script_set.result_type ==
                            RESULT_TYPE.INSTALLATION):
                        # Don't include installation results in the health
                        # status.
                        continue
                    elif script_result.status == SCRIPT_STATUS.ABORTED:
                        # LP: #1724235 - Ignore aborted scripts.
                        continue
                    elif (script_result.script_set.result_type ==
                          RESULT_TYPE.COMMISSIONING):
                        commissioning_script_results.append(script_result)
                        if (script_result.name in script_output_nsmap and
                                script_result.status == SCRIPT_STATUS.PASSED):
                            log_results.add(script_result.name)
                    elif (script_result.script_set.result_type ==
                          RESULT_TYPE.TESTING):
                        testing_script_results.append(script_result)
            data["commissioning_script_count"] = len(
                commissioning_script_results)
            data["commissioning_status"] = get_status_from_qs(
                commissioning_script_results)
            data["commissioning_status_tooltip"] = (
                self.dehydrate_hardware_status_tooltip(
                    commissioning_script_results).replace(
                        'test', 'commissioning script'))
            data["testing_script_count"] = len(testing_script_results)
            data["testing_status"] = get_status_from_qs(testing_script_results)
            data["testing_status_tooltip"] = (
                self.dehydrate_hardware_status_tooltip(testing_script_results))
            data["has_logs"] = (log_results.difference(
                script_output_nsmap.keys()) == set())
        else:
            blockdevices = []

        if obj.node_type != NODE_TYPE.DEVICE:
            # These values are not defined on a device.
            data["architecture"] = obj.architecture
            data["osystem"] = obj.osystem
            data["distro_series"] = obj.distro_series
            data["memory"] = obj.display_memory()
            data["status"] = obj.display_status()
            data["description"] = obj.description
            data["status_code"] = obj.status

        # Filters are only available on machines and devices.
        if not obj.is_controller:
            # For filters
            subnets = self.get_all_subnets(obj)
            data["subnets"] = [subnet.cidr for subnet in subnets]
            data["fabrics"] = self.get_all_fabric_names(obj, subnets)
            data["spaces"] = self.get_all_space_names(subnets)
            data["extra_macs"] = [
                "%s" % mac_address for mac_address in obj.get_extra_macs()
            ]

        if not for_list:
            data["on_network"] = obj.on_network()
            if obj.node_type != NODE_TYPE.DEVICE:
                # XXX lamont 2017-02-15 Much of this should be split out into
                # individual methods, rather than having this huge block of
                # dense code here.
                # Status of the commissioning, testing, and logs tabs
                data["metadata"] = {
                    metadata.key: metadata.value
                    for metadata in obj.nodemetadata_set.all()
                }

                # Network
                data["interfaces"] = [
                    self.dehydrate_interface(interface, obj)
                    for interface in obj.interface_set.all().order_by('name')
                ]
                data["dhcp_on"] = self.get_providing_dhcp(obj)

                data["hwe_kernel"] = make_hwe_kernel_ui_text(obj.hwe_kernel)

                data["power_type"] = obj.power_type
                data["power_parameters"] = self.dehydrate_power_parameters(
                    obj.power_parameters)
                data["power_bmc_node_count"] = obj.bmc.node_set.count() if (
                    obj.bmc is not None) else 0

                # Storage
                data["disks"] = sorted(chain(
                    (self.dehydrate_blockdevice(blockdevice, obj)
                     for blockdevice in blockdevices),
                    (self.dehydrate_volume_group(volume_group) for volume_group
                     in VolumeGroup.objects.filter_by_node(obj)),
                    (self.dehydrate_cache_set(cache_set) for cache_set in
                     CacheSet.objects.get_cache_sets_for_node(obj)),
                ),
                                       key=itemgetter("name"))
                data["supported_filesystems"] = [{
                    'key': key,
                    'ui': ui
                } for key, ui in FILESYSTEM_FORMAT_TYPE_CHOICES]
                data["storage_layout_issues"] = obj.storage_layout_issues()
                data["special_filesystems"] = [
                    self.dehydrate_filesystem(filesystem)
                    for filesystem in obj.get_effective_special_filesystems()
                ]
                data["grouped_storages"] = self.get_grouped_storages(
                    physical_blockdevices)
                layout_bd, detected_layout = (
                    get_applied_storage_layout_for_node(obj))
                data["detected_storage_layout"] = detected_layout
                # The UI knows that a partition is in use when it has a mounted
                # partition. VMware ESXi does not directly mount the partitions
                # used. As MAAS can't model that inject a place holder so the
                # UI knows that these partitions are in use.
                if detected_layout == "vmfs6":
                    for disk in data["disks"]:
                        if disk["id"] == layout_bd.id:
                            for partition in disk["partitions"]:
                                if partition["name"].endswith("-part3"):
                                    # Partition 3 is for the default datastore.
                                    # This partition may be modified by the
                                    # user.
                                    continue
                                partition["used_for"] = (
                                    "VMware ESXi OS partition")
                                partition["filesystem"] = {
                                    "id": -1,
                                    "label": "RESERVED",
                                    "mount_point": "RESERVED",
                                    "mount_options": None,
                                    "fstype": None,
                                    "is_format_fstype": False
                                }
                # Events
                data["events"] = self.dehydrate_events(obj)

                # Machine logs
                data["installation_status"] = self.dehydrate_script_set_status(
                    obj.current_installation_script_set)

                # Third party drivers
                if Config.objects.get_config('enable_third_party_drivers'):
                    # Pull modaliases from the cache
                    modaliases = []
                    for script_result in commissioning_script_results:
                        if script_result.name == LIST_MODALIASES_OUTPUT_NAME:
                            if script_result.status == SCRIPT_STATUS.PASSED:
                                # STDOUT is deferred in the cache so load it.
                                script_result = ScriptResult.objects.filter(
                                    id=script_result.id).only(
                                        'id', 'status', 'stdout').first()
                                modaliases = script_result.stdout.decode(
                                    'utf-8').splitlines()
                    driver = get_third_party_driver(obj, modaliases)
                    if "module" in driver and "comment" in driver:
                        data["third_party_driver"] = {
                            "module": driver["module"],
                            "comment": driver["comment"],
                        }

        return data