def show_physical_storage(cls, args, physical_storage_list):
        """

        :param args:
        :param PhysicalStorageList physical_storage_list:
        :return:
        """
        tbl = Table(utf8=not args.no_utf8,
                    colors=not args.no_color,
                    pastable=args.pastable)
        for hdr in cls._phys_storage_headers:
            tbl.add_header(hdr)

        for devices in physical_storage_list.physical_devices:
            node_rows = []
            for node, node_devices in devices.nodes.items():
                s = node + '['
                node_out_devs = []
                for device_obj in node_devices:
                    ns = device_obj.device
                    node_data = []
                    if device_obj.serial:
                        node_data.append(device_obj.serial)
                    if device_obj.wwn:
                        node_data.append(device_obj.wwn)
                    if node_data:
                        ns += '(' + ','.join(node_data) + ')'
                    node_out_devs.append(ns)
                s += ','.join(node_out_devs) + ']'
                node_rows.append(s)
            tbl.add_row(
                [devices.size, devices.rotational, "\n".join(node_rows)])

        tbl.show()
Ejemplo n.º 2
0
    def test_cell_color(self):
        tbl = Table(colors=True, utf8=False)
        tbl.add_header(TableHeader("FirstName"))
        tbl.add_header(TableHeader("LastName"))
        tbl.add_header(TableHeader("Age"))
        tbl.add_header(TableHeader("Comment"))

        tbl.add_row(["Max", "Mustermann", tbl.color_cell("62", Color.RED), ""])
        tbl.add_row(["Heinrich", "Mueller", "29", ""])
        tbl.show()
Ejemplo n.º 3
0
    def show_backups(cls, args, lstmsg):
        tbl = Table(utf8=not args.no_utf8,
                    colors=not args.no_color,
                    pastable=args.pastable)

        if args.others:
            for hdr in cls._backup_other_headers:
                tbl.add_header(hdr)

            for entry in lstmsg.other.files:
                tbl.add_row([entry])
        else:
            backup_hdr = list(cls._backup_headers)
            for hdr in backup_hdr:
                tbl.add_header(hdr)

            if args.show_id:
                tbl.add_header(linstor_client.TableHeader("Backup Name(ID)"))

            for backup in lstmsg.linstor:
                # resource, snapshot, finish time, base, status
                row = [backup.origin_rsc_name, backup.origin_snap_name]
                if backup.finished_timestamp:
                    row += [
                        datetime.fromtimestamp(
                            int(backup.finished_timestamp / 1000))
                    ]
                else:
                    row += [""]
                row += [backup.based_on[0:-5] if backup.based_on else ""]

                status_text = "Success"
                status_color = Color.GREEN
                if backup.shipping:
                    status_text = "Shipping"
                    status_color = Color.YELLOW
                elif not backup.restorable:
                    status_text = "Not restorable"
                    status_color = Color.RED

                row += [tbl.color_cell(status_text, status_color)]

                if args.show_id:
                    row += [backup.id]

                tbl.add_row(row)

        tbl.show()
Ejemplo n.º 4
0
    def test_multiline_colums(self):
        tbl = Table()
        tbl.add_header(TableHeader("id"))
        tbl.add_header(TableHeader("description"))
        tbl.add_header(TableHeader("text"))

        tbl.add_row([
            "0",
            "In a land far far away in a time long long ago\nThere were 3 pigs with 3 wigs and a chair to despair\n"
            + "in a house with no mouse.",
            "PlaceCount: 2\nDisklessOnRemaining: True\nStoragePool: DfltStorPool\nLayerList: storage,drbd"
        ])
        table_out = tbl.show()

        self.assertEqual(
            """+---------------------------------------------------------------------------------------+
| id | description                                          | text                      |
|=======================================================================================|
| 0  | In a land far far away in a time long long ago       | PlaceCount: 2             |
|    | There were 3 pigs with 3 wigs and a chair to despair | DisklessOnRemaining: True |
|    | in a house with no mouse.                            | StoragePool: DfltStorPool |
|    |                                                      | LayerList: storage,drbd   |
+---------------------------------------------------------------------------------------+
""", table_out)

        tbl = Table()
        tbl.add_header(TableHeader("id"))
        tbl.add_header(TableHeader("vlmgroups"))
        tbl.add_header(TableHeader("text"))
        tbl.add_header(TableHeader("description"))

        tbl.add_row(["DfltRscGrp", "", "", ""])
        tbl.add_row(
            ["testrg", "0", "PlaceCount: 2\nStoragePool: DfltStorPool", "bla"])

        table_out = tbl.show()

        self.assertEqual(
            """+------------------------------------------------------------------+
| id         | vlmgroups | text                      | description |
|==================================================================|
| DfltRscGrp |           |                           |             |
|------------------------------------------------------------------|
| testrg     | 0         | PlaceCount: 2             | bla         |
|            |           | StoragePool: DfltStorPool |             |
+------------------------------------------------------------------+
""", table_out)