From dfff41f850dbde8e2fab9c2a0bc8873afb3abc64 Mon Sep 17 00:00:00 2001 From: Guido Trotter Date: Tue, 24 Feb 2009 12:59:13 +0000 Subject: [PATCH] gnt-instance info: remove hvattr descriptions Having hvattr descriptions is only confusing for the user, because even if they explain better what an attribute is about, they don't help in deciding what keyword should be used to actually set it. If in the future we want descriptions they should probably live in constants.py, and be displayed together with the key, rather than instead of it. This patch also changes the handling of the vnc console connection description, making compatible work with both kvm and xen-hvm. Reviewed-by: iustinp --- scripts/gnt-instance | 49 ++++++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/scripts/gnt-instance b/scripts/gnt-instance index fd8a455..e2c6eca 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -1110,42 +1110,33 @@ def ShowInstanceConfig(opts, args): if instance.has_key("network_port"): buf.write(" Allocated network port: %s\n" % instance["network_port"]) buf.write(" Hypervisor: %s\n" % instance["hypervisor"]) - if instance["hypervisor"] == constants.HT_XEN_PVM: - hvattrs = ((constants.HV_KERNEL_PATH, "kernel path"), - (constants.HV_INITRD_PATH, "initrd path")) - elif instance["hypervisor"] == constants.HT_XEN_HVM: - hvattrs = ((constants.HV_BOOT_ORDER, "boot order"), - (constants.HV_ACPI, "ACPI"), - (constants.HV_PAE, "PAE"), - (constants.HV_CDROM_IMAGE_PATH, "virtual CDROM"), - (constants.HV_NIC_TYPE, "NIC type"), - (constants.HV_DISK_TYPE, "Disk type"), - (constants.HV_VNC_BIND_ADDRESS, "VNC bind address"), - ) - # custom console information for HVM - vnc_bind_address = instance["hv_actual"][constants.HV_VNC_BIND_ADDRESS] - if vnc_bind_address == constants.BIND_ADDRESS_GLOBAL: - vnc_console_port = "%s:%s" % (instance["pnode"], - instance["network_port"]) - elif vnc_bind_address == constants.LOCALHOST_IP_ADDRESS: - vnc_console_port = "%s:%s on node %s" % (vnc_bind_address, - instance["network_port"], - instance["pnode"]) + + # custom VNC console information + vnc_bind_address = instance["hv_actual"].get(constants.HV_VNC_BIND_ADDRESS, + None) + if vnc_bind_address: + port = instance["network_port"] + display = int(port) - constants.VNC_BASE_PORT + if display > 0 and vnc_bind_address == constants.BIND_ADDRESS_GLOBAL: + vnc_console_port = "%s:%s (display %s)" % (instance["pnode"], + port, + display) + elif display > 0 and utils.IsValidIP(vnc_bind_address): + vnc_console_port = ("%s:%s (node %s) (display %s)" % + (vnc_bind_address, port, + instance["pnode"], display)) else: - vnc_console_port = "%s:%s" % (vnc_bind_address, - instance["network_port"]) + # vnc bind address is a file + vnc_console_port = "%s:%s" % (instance["pnode"], + vnc_bind_address) buf.write(" - console connection: vnc to %s\n" % vnc_console_port) - else: - # auto-handle other hypervisor types - hvattrs = [(key, key) for key in instance["hv_actual"]] - - for key, desc in hvattrs: + for key in instance["hv_actual"]: if key in instance["hv_instance"]: val = instance["hv_instance"][key] else: val = "default (%s)" % instance["hv_actual"][key] - buf.write(" - %s: %s\n" % (desc, val)) + buf.write(" - %s: %s\n" % (key, val)) buf.write(" Hardware:\n") buf.write(" - VCPUs: %d\n" % instance["be_actual"][constants.BE_VCPUS]) -- 1.7.10.4