Correct issues with VM output formats

This commit is contained in:
Joshua Boniface 2024-07-15 22:30:32 -04:00
parent 9f85c92dff
commit 174e6e08e3
1 changed files with 30 additions and 11 deletions

View File

@ -1562,7 +1562,7 @@ def format_info(config, domain_information, long_output):
ansiprint.purple(), ansiprint.end(), domain_information["vcpu"] ansiprint.purple(), ansiprint.end(), domain_information["vcpu"]
) )
) )
if long_output is True: if long_output:
ainformation.append( ainformation.append(
"{}Topology (S/C/T):{} {}".format( "{}Topology (S/C/T):{} {}".format(
ansiprint.purple(), ansiprint.end(), domain_information["vcpu_topology"] ansiprint.purple(), ansiprint.end(), domain_information["vcpu_topology"]
@ -1570,22 +1570,32 @@ def format_info(config, domain_information, long_output):
) )
if ( if (
domain_information["vnc"].get("listen", "None") != "None" domain_information["vnc"].get("listen")
and domain_information["vnc"].get("port", "None") != "None" and domain_information["vnc"].get("port")
): ) or long_output:
listen = (
domain_information["vnc"]["listen"]
if domain_information["vnc"].get("listen")
else "N/A"
)
port = (
domain_information["vnc"]["port"]
if domain_information["vnc"].get("port")
else "N/A"
)
ainformation.append("") ainformation.append("")
ainformation.append( ainformation.append(
"{}VNC listen:{} {}".format( "{}VNC listen:{} {}".format(
ansiprint.purple(), ansiprint.end(), domain_information["vnc"]["listen"] ansiprint.purple(), ansiprint.end(), listen
) )
) )
ainformation.append( ainformation.append(
"{}VNC port:{} {}".format( "{}VNC port:{} {}".format(
ansiprint.purple(), ansiprint.end(), domain_information["vnc"]["port"] ansiprint.purple(), ansiprint.end(), port
) )
) )
if long_output is True: if long_output:
# Virtualization information # Virtualization information
ainformation.append("") ainformation.append("")
ainformation.append( ainformation.append(
@ -1706,12 +1716,18 @@ def format_info(config, domain_information, long_output):
) )
) )
if not domain_information.get("node_selector"): if (
not domain_information.get("node_selector")
or domain_information.get("node_selector") == "None"
):
formatted_node_selector = "Default" formatted_node_selector = "Default"
else: else:
formatted_node_selector = str(domain_information["node_selector"]).title() formatted_node_selector = str(domain_information["node_selector"]).title()
if not domain_information.get("node_limit"): if (
not domain_information.get("node_limit")
or domain_information.get("node_limit") == "None"
):
formatted_node_limit = "Any" formatted_node_limit = "Any"
else: else:
formatted_node_limit = ", ".join(domain_information["node_limit"]) formatted_node_limit = ", ".join(domain_information["node_limit"])
@ -1723,7 +1739,10 @@ def format_info(config, domain_information, long_output):
autostart_colour = ansiprint.green() autostart_colour = ansiprint.green()
formatted_node_autostart = "True" formatted_node_autostart = "True"
if not domain_information.get("migration_method"): if (
not domain_information.get("migration_method")
or domain_information.get("migration_method") == "None"
):
formatted_migration_method = "Live, Shutdown" formatted_migration_method = "Live, Shutdown"
else: else:
formatted_migration_method = ( formatted_migration_method = (
@ -1919,7 +1938,7 @@ def format_info(config, domain_information, long_output):
) )
) )
if long_output is True: if long_output:
# Disk list # Disk list
ainformation.append("") ainformation.append("")
name_length = 0 name_length = 0