- 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))