Commit 5018a335 authored by Iustin Pop's avatar Iustin Pop
Browse files

Change gnt-instance list to the hvparams model

This is just a change of the various hvm_ and pvm parameters to the hv
model. Parameters are queried via hv/$name or via the whole dict as
returned by hvparams.

Reviewed-by: ultrotter,imsnah
parent 6785674e
......@@ -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:
......
......@@ -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"
......
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment