Add formatters for Node and VM, fix handling

This commit is contained in:
Joshua Boniface 2023-08-09 13:13:03 -04:00
parent 01122415f6
commit a032dcc5c8
4 changed files with 235 additions and 238 deletions

View File

@ -84,8 +84,12 @@ def finish(success=True, data=None, formatter=None):
"""
if data is not None:
if formatter is not None:
echo(CLI_CONFIG, formatter(data))
if formatter is not None and success:
if formatter.__name__ == "<lambda>":
# We don't pass CLI_CONFIG into lambdas
echo(CLI_CONFIG, formatter(data))
else:
echo(CLI_CONFIG, formatter(CLI_CONFIG, data))
else:
echo(CLI_CONFIG, data)
@ -1597,34 +1601,26 @@ def cli_vm_tag():
###############################################################################
# > pvc vm tag get TODO:formatter
# > pvc vm tag get
###############################################################################
@click.command(name="get", short_help="Get the current tags of a virtual machine.")
@connection_req
@click.argument("domain")
@click.option(
"-r",
"--raw",
"raw",
is_flag=True,
default=False,
help="Display the raw value only without formatting.",
@format_opt(
{
"pretty": cli_vm_tag_get_format_pretty,
"raw": lambda d: "\n".join([t["name"] for t in d["tags"]]),
"json": lambda d: jdumps(d),
"json-pretty": lambda d: jdumps(d, indent=2),
}
)
def cli_vm_tag_get(domain, raw):
def cli_vm_tag_get(domain, format_function):
"""
Get the current tags of the virtual machine DOMAIN.
"""
retcode, retdata = pvc.lib.vm.vm_tags_get(CLI_CONFIG, domain)
if retcode:
if not raw:
retdata = pvc.lib.vm.format_vm_tags(CLI_CONFIG, domain, retdata["tags"])
else:
if len(retdata["tags"]) > 0:
retdata = "\n".join([tag["name"] for tag in retdata["tags"]])
else:
retdata = "No tags found."
finish(retcode, retdata)
finish(retcode, retdata, format_function)
###############################################################################
@ -1684,32 +1680,28 @@ def cli_vm_vcpu():
###############################################################################
# > pvc vm vcpu get TODO:formatter
# > pvc vm vcpu get
###############################################################################
@click.command(
name="get", short_help="Get the current vCPU count of a virtual machine."
)
@connection_req
@click.argument("domain")
@click.option(
"-r",
"--raw",
"raw",
is_flag=True,
default=False,
help="Display the raw value only without formatting.",
@format_opt(
{
"pretty": cli_vm_vcpu_get_format_pretty,
"raw": lambda d: d["vcpus"],
"json": lambda d: jdumps(d),
"json-pretty": lambda d: jdumps(d, indent=2),
}
)
def cli_vm_vcpu_get(domain, raw):
def cli_vm_vcpu_get(domain, format_function):
"""
Get the current vCPU count of the virtual machine DOMAIN.
"""
retcode, retmsg = pvc.lib.vm.vm_vcpus_get(CLI_CONFIG, domain)
if not raw:
retmsg = pvc.lib.vm.format_vm_vcpus(CLI_CONFIG, domain, retmsg)
else:
retmsg = retmsg[0] # Get only the first part of the tuple (vm_vcpus)
finish(retcode, retmsg)
finish(retcode, retmsg, format_function)
###############################################################################
@ -1767,30 +1759,28 @@ def cli_vm_memory():
###############################################################################
# > pvc vm memory get TODO:formatter
# > pvc vm memory get
###############################################################################
@click.command(
name="get", short_help="Get the current provisioned memory of a virtual machine."
)
@connection_req
@click.argument("domain")
@click.option(
"-r",
"--raw",
"raw",
is_flag=True,
default=False,
help="Display the raw value only without formatting.",
@format_opt(
{
"pretty": cli_vm_memory_get_format_pretty,
"raw": lambda d: d["memory"],
"json": lambda d: jdumps(d),
"json-pretty": lambda d: jdumps(d, indent=2),
}
)
def cli_vm_memory_get(domain, raw):
def cli_vm_memory_get(domain, format_function):
"""
Get the current provisioned memory of the virtual machine DOMAIN.
"""
retcode, retmsg = pvc.lib.vm.vm_memory_get(CLI_CONFIG, domain)
if not raw:
retmsg = pvc.lib.vm.format_vm_memory(CLI_CONFIG, domain, retmsg)
finish(retcode, retmsg)
finish(retcode, retmsg, format_function)
###############################################################################
@ -1829,33 +1819,26 @@ def cli_vm_network():
###############################################################################
# > pvc vm network get TODO:formatter
# > pvc vm network get
###############################################################################
@click.command(name="get", short_help="Get the networks of a virtual machine.")
@connection_req
@click.argument("domain")
@click.option(
"-r",
"--raw",
"raw",
is_flag=True,
default=False,
help="Display the raw values only without formatting.",
@format_opt(
{
"pretty": cli_vm_network_get_format_pretty,
"raw": lambda d: ",".join([t["network"] for t in d["networks"]]),
"json": lambda d: jdumps(d),
"json-pretty": lambda d: jdumps(d, indent=2),
}
)
def cli_vm_network_get(domain, raw):
def cli_vm_network_get(domain, format_function):
"""
Get the networks of the virtual machine DOMAIN.
"""
retcode, retdata = pvc.lib.vm.vm_networks_get(CLI_CONFIG, domain)
if not raw:
retmsg = pvc.lib.vm.format_vm_networks(CLI_CONFIG, domain, retdata)
else:
network_vnis = list()
for network in retdata:
network_vnis.append(network[0])
retmsg = ",".join(network_vnis)
finish(retcode, retmsg)
finish(retcode, retdata, format_function)
###############################################################################
@ -2013,33 +1996,28 @@ def cli_vm_volume():
###############################################################################
# > pvc vm volume get TODO:formatter
# > pvc vm volume get
###############################################################################
@click.command(name="get", short_help="Get the volumes of a virtual machine.")
@connection_req
@click.argument("domain")
@click.option(
"-r",
"--raw",
"raw",
is_flag=True,
default=False,
help="Display the raw values only without formatting.",
@format_opt(
{
"pretty": cli_vm_volume_get_format_pretty,
"raw": lambda d: ",".join(
[f"{v['protocol']}:{v['volume']}" for v in d["volumes"]]
),
"json": lambda d: jdumps(d),
"json-pretty": lambda d: jdumps(d, indent=2),
}
)
def cli_vm_volume_get(domain, raw):
def cli_vm_volume_get(domain, format_function):
"""
Get the volumes of the virtual machine DOMAIN.
"""
retcode, retdata = pvc.lib.vm.vm_volumes_get(CLI_CONFIG, domain)
if not raw:
retmsg = pvc.lib.vm.format_vm_volumes(CLI_CONFIG, domain, retdata)
else:
volume_paths = list()
for volume in retdata:
volume_paths.append("{}:{}".format(volume[2], volume[0]))
retmsg = ",".join(volume_paths)
finish(retcode, retmsg)
finish(retcode, retdata, format_function)
###############################################################################
@ -2208,32 +2186,30 @@ def cli_vm_dump(filename, domain):
###############################################################################
# > pvc vm info TODO:formatter
# > pvc vm info
###############################################################################
@click.command(name="info", short_help="Show details of a VM object.")
@connection_req
@click.argument("domain")
@click.option(
"-l",
"--long",
"long_output",
is_flag=True,
default=False,
help="Display more detailed information.",
@format_opt(
{
"pretty": cli_vm_info_format_pretty,
"long": cli_vm_info_format_long,
"json": lambda d: jdumps(d),
"json-pretty": lambda d: jdumps(d, indent=2),
}
)
def cli_vm_info(domain, long_output):
def cli_vm_info(domain, format_function):
"""
Show information about virtual machine DOMAIN. DOMAIN may be a UUID or name.
"""
retcode, retdata = pvc.lib.vm.vm_info(CLI_CONFIG, domain)
if retcode:
retdata = pvc.lib.vm.format_info(CLI_CONFIG, retdata, long_output)
finish(retcode, retdata)
finish(retcode, retdata, format_function)
###############################################################################
# > pvc vm list TODO:formatter
# > pvc vm list
###############################################################################
@click.command(name="list", short_help="List all VM objects.")
@connection_req
@ -2259,14 +2235,6 @@ def cli_vm_info(domain, long_output):
default=None,
help="Limit list to VMs with the specified tag.",
)
@click.option(
"-r",
"--raw",
"raw",
is_flag=True,
default=False,
help="Display the raw list of VM names only.",
)
@click.option(
"-n",
"--negate",
@ -2275,7 +2243,15 @@ def cli_vm_info(domain, long_output):
default=False,
help="Negate the specified node, state, or tag limit(s).",
)
def cli_vm_list(target_node, target_state, target_tag, limit, raw, negate):
@format_opt(
{
"pretty": cli_vm_list_format_pretty,
"raw": lambda d: "\n".join([v["name"] for v in d]),
"json": lambda d: jdumps(d),
"json-pretty": lambda d: jdumps(d, indent=2),
}
)
def cli_vm_list(target_node, target_state, target_tag, limit, negate, format_function):
"""
List all virtual machines; optionally only match names or full UUIDs matching regex LIMIT.
@ -2285,12 +2261,7 @@ def cli_vm_list(target_node, target_state, target_tag, limit, raw, negate):
retcode, retdata = pvc.lib.vm.vm_list(
CLI_CONFIG, limit, target_node, target_state, target_tag, negate
)
if retcode:
retdata = pvc.lib.vm.format_list(CLI_CONFIG, retdata, raw)
else:
if raw:
retdata = ""
finish(retcode, retdata)
finish(retcode, retdata, format_function)
###############################################################################
@ -3347,8 +3318,8 @@ def cli_storage_osd_set(osd_property):
# > pvc storage osd unset
###############################################################################
@click.command(name="unset", short_help="Unset OSD property.")
@connection_req
@click.argument("osd_property")
@cluster_req
def cli_storage_osd_unset(osd_property):
"""
Unset (disable) a Ceph OSD property OSD_PROPERTY on the cluster.
@ -5218,7 +5189,7 @@ def cli_provisioner_create(
# > pvc provisioner status TODO:formatter
###############################################################################
@click.command(name="status", short_help="Show status of provisioner job.")
@connection_Req
@connection_req
@click.argument("job", required=False, default=None)
def cli_provisioner_status(job):
"""

View File

@ -21,6 +21,13 @@
from pvc.lib.node import format_info as node_format_info
from pvc.lib.node import format_list as node_format_list
from pvc.lib.vm import format_vm_tags as vm_format_tags
from pvc.lib.vm import format_vm_vcpus as vm_format_vcpus
from pvc.lib.vm import format_vm_memory as vm_format_memory
from pvc.lib.vm import format_vm_networks as vm_format_networks
from pvc.lib.vm import format_vm_volumes as vm_format_volumes
from pvc.lib.vm import format_info as vm_format_info
from pvc.lib.vm import format_list as vm_format_list
# Define colour values for use in formatters
@ -36,7 +43,7 @@ ansii = {
}
def cli_cluster_status_format_pretty(data):
def cli_cluster_status_format_pretty(CLI_CONFIG, data):
"""
Pretty format the full output of cli_cluster_status
"""
@ -188,7 +195,7 @@ def cli_cluster_status_format_pretty(data):
return "\n".join(output)
def cli_cluster_status_format_short(data):
def cli_cluster_status_format_short(CLI_CONFIG, data):
"""
Pretty format the health-only output of cli_cluster_status
"""
@ -233,7 +240,7 @@ def cli_cluster_status_format_short(data):
return "\n".join(output)
def cli_connection_list_format_pretty(data):
def cli_connection_list_format_pretty(CLI_CONFIG, data):
"""
Pretty format the output of cli_connection_list
"""
@ -305,7 +312,7 @@ def cli_connection_list_format_pretty(data):
return "\n".join(output)
def cli_connection_detail_format_pretty(data):
def cli_connection_detail_format_pretty(CLI_CONFIG, data):
"""
Pretty format the output of cli_connection_detail
"""
@ -425,25 +432,89 @@ def cli_connection_detail_format_pretty(data):
return "\n".join(output)
def cli_node_info_format_pretty(data):
def cli_node_info_format_pretty(CLI_CONFIG, data):
"""
Pretty format the basic output of cli_node_info
"""
return node_format_info(data, long_output=False)
return node_format_info(CLI_CONFIG, data, long_output=False)
def cli_node_info_format_long(data):
def cli_node_info_format_long(CLI_CONFIG, data):
"""
Pretty format the full output of cli_node_info
"""
return node_format_info(data, long_output=True)
return node_format_info(CLI_CONFIG, data, long_output=True)
def cli_node_list_format_pretty(data):
def cli_node_list_format_pretty(CLI_CONFIG, data):
"""
Pretty format the output of cli_node_list
"""
return node_format_list(data)
return node_format_list(CLI_CONFIG, data)
def cli_vm_tag_get_format_pretty(CLI_CONFIG, data):
"""
Pretty format the output of cli_vm_tag_get
"""
return vm_format_tags(CLI_CONFIG, data)
def cli_vm_vcpu_get_format_pretty(CLI_CONFIG, data):
"""
Pretty format the output of cli_vm_vcpu_get
"""
return vm_format_vcpus(CLI_CONFIG, data)
def cli_vm_memory_get_format_pretty(CLI_CONFIG, data):
"""
Pretty format the output of cli_vm_memory_get
"""
return vm_format_memory(CLI_CONFIG, data)
def cli_vm_network_get_format_pretty(CLI_CONFIG, data):
"""
Pretty format the output of cli_vm_network_get
"""
return vm_format_networks(CLI_CONFIG, data)
def cli_vm_volume_get_format_pretty(CLI_CONFIG, data):
"""
Pretty format the output of cli_vm_volume_get
"""
return vm_format_volumes(CLI_CONFIG, data)
def cli_vm_info_format_pretty(CLI_CONFIG, data):
"""
Pretty format the basic output of cli_vm_info
"""
return vm_format_info(CLI_CONFIG, data, long_output=False)
def cli_vm_info_format_long(CLI_CONFIG, data):
"""
Pretty format the full output of cli_vm_info
"""
return vm_format_info(CLI_CONFIG, data, long_output=True)
def cli_vm_list_format_pretty(CLI_CONFIG, data):
"""
Pretty format the output of cli_vm_list
"""
return vm_format_list(CLI_CONFIG, data)

View File

@ -273,7 +273,7 @@ def getOutputColours(node_information):
)
def format_info(node_information, long_output):
def format_info(config, node_information, long_output):
(
health_colour,
daemon_state_colour,
@ -442,7 +442,7 @@ def format_info(node_information, long_output):
return "\n".join(ainformation)
def format_list(node_list):
def format_list(config, node_list):
if node_list == "Node not found.":
return node_list

View File

@ -286,20 +286,18 @@ def vm_tag_set(config, vm, action, tag, protected=False):
return retstatus, response.json().get("message", "")
def format_vm_tags(config, name, tags):
def format_vm_tags(config, data):
"""
Format the output of a tags dictionary in a nice table
"""
tags = data.get("tags", [])
if len(tags) < 1:
return "No tags found."
output_list = []
name_length = 5
_name_length = len(name) + 1
if _name_length > name_length:
name_length = _name_length
tags_name_length = 4
tags_type_length = 5
tags_protected_length = 10
@ -495,44 +493,38 @@ def vm_vcpus_get(config, vm):
except Exception:
return False, "ERROR: Failed to parse XML data."
vm_vcpus = int(parsed_xml.vcpu.text)
vm_sockets = parsed_xml.cpu.topology.attrib.get("sockets")
vm_cores = parsed_xml.cpu.topology.attrib.get("cores")
vm_threads = parsed_xml.cpu.topology.attrib.get("threads")
data = dict()
data["name"] = vm
data["vcpus"] = int(parsed_xml.vcpu.text)
data["sockets"] = parsed_xml.cpu.topology.attrib.get("sockets")
data["cores"] = parsed_xml.cpu.topology.attrib.get("cores")
data["threads"] = parsed_xml.cpu.topology.attrib.get("threads")
return True, (vm_vcpus, (vm_sockets, vm_cores, vm_threads))
return True, data
def format_vm_vcpus(config, name, vcpus):
def format_vm_vcpus(config, data):
"""
Format the output of a vCPU value in a nice table
"""
output_list = []
name_length = 5
_name_length = len(name) + 1
if _name_length > name_length:
name_length = _name_length
vcpus_length = 6
sockets_length = 8
cores_length = 6
threads_length = 8
output_list.append(
"{bold}{name: <{name_length}} \
{vcpus: <{vcpus_length}} \
"{bold}{vcpus: <{vcpus_length}} \
{sockets: <{sockets_length}} \
{cores: <{cores_length}} \
{threads: <{threads_length}}{end_bold}".format(
name_length=name_length,
vcpus_length=vcpus_length,
sockets_length=sockets_length,
cores_length=cores_length,
threads_length=threads_length,
bold=ansiprint.bold(),
end_bold=ansiprint.end(),
name="Name",
vcpus="vCPUs",
sockets="Sockets",
cores="Cores",
@ -540,23 +532,20 @@ def format_vm_vcpus(config, name, vcpus):
)
)
output_list.append(
"{bold}{name: <{name_length}} \
{vcpus: <{vcpus_length}} \
"{bold}{vcpus: <{vcpus_length}} \
{sockets: <{sockets_length}} \
{cores: <{cores_length}} \
{threads: <{threads_length}}{end_bold}".format(
name_length=name_length,
vcpus_length=vcpus_length,
sockets_length=sockets_length,
cores_length=cores_length,
threads_length=threads_length,
bold="",
end_bold="",
name=name,
vcpus=vcpus[0],
sockets=vcpus[1][0],
cores=vcpus[1][1],
threads=vcpus[1][2],
vcpus=data["vcpus"],
sockets=data["sockets"],
cores=data["cores"],
threads=data["threads"],
)
)
return "\n".join(output_list)
@ -619,44 +608,35 @@ def vm_memory_get(config, vm):
except Exception:
return False, "ERROR: Failed to parse XML data."
vm_memory = int(parsed_xml.memory.text)
data = dict()
data["name"] = vm
data["memory"] = int(parsed_xml.memory.text)
return True, vm_memory
return True, data
def format_vm_memory(config, name, memory):
def format_vm_memory(config, data):
"""
Format the output of a memory value in a nice table
"""
output_list = []
name_length = 5
_name_length = len(name) + 1
if _name_length > name_length:
name_length = _name_length
memory_length = 6
output_list.append(
"{bold}{name: <{name_length}} \
{memory: <{memory_length}}{end_bold}".format(
name_length=name_length,
"{bold}{memory: <{memory_length}}{end_bold}".format(
memory_length=memory_length,
bold=ansiprint.bold(),
end_bold=ansiprint.end(),
name="Name",
memory="RAM (M)",
)
)
output_list.append(
"{bold}{name: <{name_length}} \
{memory: <{memory_length}}{end_bold}".format(
name_length=name_length,
"{bold}{memory: <{memory_length}}{end_bold}".format(
memory_length=memory_length,
bold="",
end_bold="",
name=name,
memory=memory,
memory=data["memory"],
)
)
return "\n".join(output_list)
@ -946,7 +926,9 @@ def vm_networks_get(config, vm):
except Exception:
return False, "ERROR: Failed to parse XML data."
network_data = list()
data = dict()
data["name"] = vm
data["networks"] = list()
for interface in parsed_xml.devices.find("interface"):
mac_address = interface.mac.attrib.get("address")
model = interface.model.attrib.get("type")
@ -960,76 +942,65 @@ def vm_networks_get(config, vm):
elif interface_type == "hostdev":
network = "hostdev:{}".format(interface.source.attrib.get("dev"))
network_data.append((network, mac_address, model))
data["networks"].append(
{"network": network, "mac_address": mac_address, "model": model}
)
return True, network_data
return True, data
def format_vm_networks(config, name, networks):
def format_vm_networks(config, data):
"""
Format the output of a network list in a nice table
"""
output_list = []
name_length = 5
vni_length = 8
network_length = 8
macaddr_length = 12
model_length = 6
_name_length = len(name) + 1
if _name_length > name_length:
name_length = _name_length
for network in data["networks"]:
_network_length = len(network["network"]) + 1
if _network_length > network_length:
network_length = _network_length
for network in networks:
_vni_length = len(network[0]) + 1
if _vni_length > vni_length:
vni_length = _vni_length
_macaddr_length = len(network[1]) + 1
_macaddr_length = len(network["mac_address"]) + 1
if _macaddr_length > macaddr_length:
macaddr_length = _macaddr_length
_model_length = len(network[2]) + 1
_model_length = len(network["model"]) + 1
if _model_length > model_length:
model_length = _model_length
output_list.append(
"{bold}{name: <{name_length}} \
{vni: <{vni_length}} \
"{bold}{network: <{network_length}} \
{macaddr: <{macaddr_length}} \
{model: <{model_length}}{end_bold}".format(
name_length=name_length,
vni_length=vni_length,
network_length=network_length,
macaddr_length=macaddr_length,
model_length=model_length,
bold=ansiprint.bold(),
end_bold=ansiprint.end(),
name="Name",
vni="Network",
network="Network",
macaddr="MAC Address",
model="Model",
)
)
count = 0
for network in networks:
if count > 0:
name = ""
for network in data["networks"]:
count += 1
output_list.append(
"{bold}{name: <{name_length}} \
{vni: <{vni_length}} \
"{bold}{network: <{network_length}} \
{macaddr: <{macaddr_length}} \
{model: <{model_length}}{end_bold}".format(
name_length=name_length,
vni_length=vni_length,
network_length=network_length,
macaddr_length=macaddr_length,
model_length=model_length,
bold="",
end_bold="",
name=name,
vni=network[0],
macaddr=network[1],
model=network[2],
network=network["network"],
macaddr=network["mac_address"],
model=network["model"],
)
)
return "\n".join(output_list)
@ -1270,7 +1241,9 @@ def vm_volumes_get(config, vm):
except Exception:
return False, "ERROR: Failed to parse XML data."
volume_data = list()
data = dict()
data["name"] = vm
data["volumes"] = list()
for disk in parsed_xml.devices.find("disk"):
protocol = disk.attrib.get("type")
disk_id = disk.target.attrib.get("dev")
@ -1285,58 +1258,52 @@ def vm_volumes_get(config, vm):
protocol = "unknown"
source = "unknown"
volume_data.append((source, disk_id, protocol, bus))
data["volumes"].append(
{"volume": source, "disk_id": disk_id, "protocol": protocol, "bus": bus}
)
return True, volume_data
return True, data
def format_vm_volumes(config, name, volumes):
def format_vm_volumes(config, data):
"""
Format the output of a volume value in a nice table
"""
output_list = []
name_length = 5
volume_length = 7
disk_id_length = 4
protocol_length = 5
bus_length = 4
_name_length = len(name) + 1
if _name_length > name_length:
name_length = _name_length
for volume in volumes:
_volume_length = len(volume[0]) + 1
for volume in data["volumes"]:
_volume_length = len(volume["volume"]) + 1
if _volume_length > volume_length:
volume_length = _volume_length
_disk_id_length = len(volume[1]) + 1
_disk_id_length = len(volume["disk_id"]) + 1
if _disk_id_length > disk_id_length:
disk_id_length = _disk_id_length
_protocol_length = len(volume[2]) + 1
_protocol_length = len(volume["protocol"]) + 1
if _protocol_length > protocol_length:
protocol_length = _protocol_length
_bus_length = len(volume[3]) + 1
_bus_length = len(volume["bus"]) + 1
if _bus_length > bus_length:
bus_length = _bus_length
output_list.append(
"{bold}{name: <{name_length}} \
{volume: <{volume_length}} \
"{bold}{volume: <{volume_length}} \
{disk_id: <{disk_id_length}} \
{protocol: <{protocol_length}} \
{bus: <{bus_length}}{end_bold}".format(
name_length=name_length,
volume_length=volume_length,
disk_id_length=disk_id_length,
protocol_length=protocol_length,
bus_length=bus_length,
bold=ansiprint.bold(),
end_bold=ansiprint.end(),
name="Name",
volume="Volume",
disk_id="Dev",
protocol="Type",
@ -1344,28 +1311,23 @@ def format_vm_volumes(config, name, volumes):
)
)
count = 0
for volume in volumes:
if count > 0:
name = ""
for volume in data["volumes"]:
count += 1
output_list.append(
"{bold}{name: <{name_length}} \
{volume: <{volume_length}} \
"{bold}{volume: <{volume_length}} \
{disk_id: <{disk_id_length}} \
{protocol: <{protocol_length}} \
{bus: <{bus_length}}{end_bold}".format(
name_length=name_length,
volume_length=volume_length,
disk_id_length=disk_id_length,
protocol_length=protocol_length,
bus_length=bus_length,
bold="",
end_bold="",
name=name,
volume=volume[0],
disk_id=volume[1],
protocol=volume[2],
bus=volume[3],
volume=volume["volume"],
disk_id=volume["disk_id"],
protocol=volume["protocol"],
bus=volume["bus"],
)
)
return "\n".join(output_list)
@ -1869,7 +1831,7 @@ def format_info(config, domain_information, long_output):
return "\n".join(ainformation)
def format_list(config, vm_list, raw):
def format_list(config, vm_list):
# Function to strip the "br" off of nets and return a nicer list
def getNiceNetID(domain_information):
# Network list
@ -1888,13 +1850,6 @@ def format_list(config, vm_list, raw):
tag_list.append(tag["name"])
return tag_list
# Handle raw mode since it just lists the names
if raw:
ainformation = list()
for vm in sorted(item["name"] for item in vm_list):
ainformation.append(vm)
return "\n".join(ainformation)
vm_list_output = []
# Determine optimal column widths