Commit a8340917 authored by Iustin Pop's avatar Iustin Pop
Browse files

Forward-port: show only parameters relevant to the instance

This patch modifies the code for "gnt-instance info .." to only display
instance parameters that actually apply to that instance, i.e. for PVM
instances no HVM parameters are shown and vice versa.

Author: schreiberal
Reviewed-by: iustinp
parent ca9c49d5
......@@ -4253,17 +4253,24 @@ class LUQueryInstanceData(NoHooksLU):
"memory": instance.memory,
"nics": [(nic.mac, nic.ip, nic.bridge) for nic in instance.nics],
"disks": disks,
"network_port": instance.network_port,
"vcpus": instance.vcpus,
"kernel_path": instance.kernel_path,
"initrd_path": instance.initrd_path,
"hvm_boot_order": instance.hvm_boot_order,
"hvm_acpi": instance.hvm_acpi,
"hvm_pae": instance.hvm_pae,
"hvm_cdrom_image_path": instance.hvm_cdrom_image_path,
"vnc_bind_address": instance.vnc_bind_address,
}
htkind = self.sstore.GetHypervisorType()
if htkind == constants.HT_XEN_PVM30:
idict["kernel_path"] = instance.kernel_path
idict["initrd_path"] = instance.initrd_path
if htkind == constants.HT_XEN_HVM31:
idict["hvm_boot_order"] = instance.hvm_boot_order
idict["hvm_acpi"] = instance.hvm_acpi
idict["hvm_pae"] = instance.hvm_pae
idict["hvm_cdrom_image_path"] = instance.hvm_cdrom_image_path
if htkind in constants.HTS_REQ_PORT:
idict["vnc_bind_address"] = instance.vnc_bind_address
idict["network_port"] = instance.network_port
result[instance.name] = idict
return result
......
......@@ -627,6 +627,10 @@ def ShowInstanceConfig(opts, args):
retcode = 0
op = opcodes.OpQueryInstanceData(instances=args)
result = SubmitOpCode(op)
hvm_parameters = ("hvm_acpi", "hvm_pae", "hvm_cdrom_image_path",
"hvm_boot_order")
pvm_parameters = ("kernel_path", "initrd_path")
if not result:
logger.ToStdout("No instances.")
......@@ -643,25 +647,29 @@ def ShowInstanceConfig(opts, args):
buf.write(" - primary: %s\n" % instance["pnode"])
buf.write(" - secondaries: %s\n" % ", ".join(instance["snodes"]))
buf.write(" Operating system: %s\n" % instance["os"])
buf.write(" Allocated network port: %s\n" % instance["network_port"])
if instance["kernel_path"] in (None, constants.VALUE_DEFAULT):
kpath = "(default: %s)" % constants.XEN_KERNEL
else:
kpath = instance["kernel_path"]
buf.write(" Kernel path: %s\n" % kpath)
if instance["initrd_path"] in (None, constants.VALUE_DEFAULT):
initrd = "(default: %s)" % constants.XEN_INITRD
elif instance["initrd_path"] == constants.VALUE_NONE:
initrd = "(none)"
else:
initrd = instance["initrd_path"]
buf.write(" initrd: %s\n" % initrd)
buf.write(" HVM:\n")
buf.write(" - boot order: %s\n" % instance["hvm_boot_order"])
buf.write(" - ACPI support: %s\n" % instance["hvm_acpi"])
buf.write(" - PAE support: %s\n" % instance["hvm_pae"])
buf.write(" - virtual CDROM: %s\n" % instance["hvm_cdrom_image_path"])
buf.write(" VNC bind address: %s\n" % instance["vnc_bind_address"])
if instance.has_key("network_port"):
buf.write(" Allocated network port: %s\n" % instance["network_port"])
if False not in map(instance.has_key, pvm_parameters):
if instance["kernel_path"] in (None, constants.VALUE_DEFAULT):
kpath = "(default: %s)" % constants.XEN_KERNEL
else:
kpath = instance["kernel_path"]
buf.write(" Kernel path: %s\n" % kpath)
if instance["initrd_path"] in (None, constants.VALUE_DEFAULT):
initrd = "(default: %s)" % constants.XEN_INITRD
elif instance["initrd_path"] == constants.VALUE_NONE:
initrd = "(none)"
else:
initrd = instance["initrd_path"]
buf.write(" initrd: %s\n" % initrd)
if False not in map(instance.has_key, hvm_parameters):
buf.write(" HVM:\n")
buf.write(" - boot order: %s\n" % instance["hvm_boot_order"])
buf.write(" - ACPI support: %s\n" % instance["hvm_acpi"])
buf.write(" - PAE support: %s\n" % instance["hvm_pae"])
buf.write(" - virtual CDROM: %s\n" % instance["hvm_cdrom_image_path"])
if instance.has_key("vnc_bind_address"):
buf.write(" VNC bind address: %s\n" % instance["vnc_bind_address"])
buf.write(" Hardware:\n")
buf.write(" - VCPUs: %d\n" % instance["vcpus"])
buf.write(" - memory: %dMiB\n" % instance["memory"])
......
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