diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 6743556a69c50f1a2a82dfe6f065a5e1cfcd47b6..43042e1e8e44b9ad58566e78957a23407e91e25e 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2609,12 +2609,9 @@ class LUQueryInstances(NoHooksLU): "admin_state", "admin_ram", "disk_template", "ip", "mac", "bridge", "sda_size", "sdb_size", "vcpus", "tags", - "network_port", "kernel_path", "initrd_path", - "hvm_boot_order", "hvm_acpi", "hvm_pae", - "hvm_cdrom_image_path", "hvm_nic_type", - "hvm_disk_type", "vnc_bind_address", - "serial_no", "hypervisor", - ]) + "network_port", + "serial_no", "hypervisor", "hvparams", + ] + ["hv/%s" % name for name in constants.HVS_PARAMETERS]) _CheckOutputFields(static=self.static_fields, dynamic=self.dynamic_fields, selected=self.op.output_fields) @@ -2683,9 +2680,11 @@ class LUQueryInstances(NoHooksLU): # end data gathering + HVPREFIX = "hv/" output = [] for instance in instance_list: iout = [] + i_hv = self.cfg.GetClusterInfo().FillHV(instance) for field in self.op.output_fields: if field == "name": val = instance.name @@ -2746,18 +2745,13 @@ class LUQueryInstances(NoHooksLU): val = list(instance.GetTags()) elif field == "serial_no": val = instance.serial_no - elif field in ("network_port", "kernel_path", "initrd_path", - "hvm_boot_order", "hvm_acpi", "hvm_pae", - "hvm_cdrom_image_path", "hvm_nic_type", - "hvm_disk_type", "vnc_bind_address"): - val = getattr(instance, field, None) - if val is not None: - pass - elif field in ("hvm_nic_type", "hvm_disk_type", - "kernel_path", "initrd_path"): - val = "default" - else: - val = "-" + elif field == "network_port": + val = instance.network_port + elif (field.startswith(HVPREFIX) and + field[len(HVPREFIX):] in constants.HVS_PARAMETERS): + val = i_hv.get(field[len(HVPREFIX):], None) + elif field == "hvparams": + val = i_hv elif field == "hypervisor": val = instance.hypervisor else: diff --git a/lib/constants.py b/lib/constants.py index 3e252a1899653826c909b939a02492028df37560..ebeeb70a1f1e3d59ebcdb3d06281c1bc97041f26 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -263,6 +263,18 @@ HV_PAE = "pae" HV_KERNEL_PATH = "kernel_path" HV_INITRD_PATH = "initrd_path" +HVS_PARAMETERS = frozenset([ + HV_BOOT_ORDER, + HV_CDROM_IMAGE_PATH, + HV_NIC_TYPE, + HV_DISK_TYPE, + HV_VNC_BIND_ADDRESS, + HV_ACPI, + HV_PAE, + HV_KERNEL_PATH, + HV_INITRD_PATH, + ]) + # BE parameter names BE_MEMSIZE = "memory" BE_VCPUS = "vcpus" diff --git a/scripts/gnt-instance b/scripts/gnt-instance index c05bdf579fa0754913d98c345ef461c4f35724df..15b3da380850c292e98e0562d70d369ac0bba3b4 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -188,16 +188,17 @@ def ListInstances(opts, args): "sda_size": "Disk/0", "sdb_size": "Disk/1", "status": "Status", "tags": "Tags", "network_port": "Network_port", - "kernel_path": "Kernel_path", - "initrd_path": "Initrd_path", - "hvm_boot_order": "HVM_boot_order", - "hvm_acpi": "HVM_ACPI", - "hvm_pae": "HVM_PAE", - "hvm_cdrom_image_path": "HVM_CDROM_image_path", - "hvm_nic_type": "HVM_NIC_type", - "hvm_disk_type": "HVM_disk_type", + "hv/kernel_path": "Kernel_path", + "hv/initrd_path": "Initrd_path", + "hv/boot_order": "HVM_boot_order", + "hv/acpi": "HVM_ACPI", + "hv/pae": "HVM_PAE", + "hv/cdrom_image_path": "HVM_CDROM_image_path", + "hv/nic_type": "HVM_NIC_type", + "hv/disk_type": "HVM_Disk_type", "vnc_bind_address": "VNC_bind_address", "serial_no": "SerialNo", "hypervisor": "Hypervisor", + "hvparams": "Hypervisor_parameters", } else: headers = None @@ -237,6 +238,8 @@ def ListInstances(opts, args): val = "N/A" elif field in list_type_fields: val = ",".join(val) + elif val is None: + val = "-" row[idx] = str(val) data = GenerateTable(separator=opts.separator, headers=headers,