Revision 24838135 scripts/gnt-instance

b/scripts/gnt-instance
693 693
  retcode = 0
694 694
  op = opcodes.OpQueryInstanceData(instances=args)
695 695
  result = SubmitOpCode(op)
696
  hvm_parameters = ("hvm_acpi", "hvm_pae", "hvm_cdrom_image_path",
697
                    "hvm_boot_order", "hvm_nic_type", "hvm_disk_type")
698

  
699
  pvm_parameters = ("kernel_path", "initrd_path")
700

  
701 696
  if not result:
702 697
    logger.ToStdout("No instances.")
703 698
    return 1
......
712 707
    buf.write("  Nodes:\n")
713 708
    buf.write("    - primary: %s\n" % instance["pnode"])
714 709
    buf.write("    - secondaries: %s\n" % ", ".join(instance["snodes"]))
715
    buf.write("  Hypervisor: %s\n" % instance["hypervisor"])
716 710
    buf.write("  Operating system: %s\n" % instance["os"])
717 711
    if instance.has_key("network_port"):
718 712
      buf.write("  Allocated network port: %s\n" % instance["network_port"])
719
    if False not in map(instance.has_key, pvm_parameters):
720
      if instance["kernel_path"] in (None, constants.VALUE_DEFAULT):
721
        kpath = "(default: %s)" % constants.XEN_KERNEL
713
    buf.write("  Hypervisor: %s\n" % instance["hypervisor"])
714
    if instance["hypervisor"] == constants.HT_XEN_PVM:
715
      hvattrs = ((constants.HV_KERNEL_PATH, "kernel path"),
716
                 (constants.HV_INITRD_PATH, "initrd path"))
717
    elif instance["hypervisor"] == constants.HT_XEN_HVM:
718
      hvattrs = ((constants.HV_BOOT_ORDER, "boot order"),
719
                 (constants.HV_ACPI, "ACPI"),
720
                 (constants.HV_PAE, "PAE"),
721
                 (constants.HV_CDROM_IMAGE_PATH, "virtual CDROM"),
722
                 (constants.HV_NIC_TYPE, "NIC type"),
723
                 (constants.HV_DISK_TYPE, "Disk type"),
724
                 (constants.HV_VNC_BIND_ADDRESS, "VNC bind address"),
725
                 )
726
      # custom console information for HVM
727
      vnc_bind_address = instance["hv_actual"][constants.HV_VNC_BIND_ADDRESS]
728
      if vnc_bind_address == constants.BIND_ADDRESS_GLOBAL:
729
        vnc_console_port = "%s:%s" % (instance["pnode"],
730
                                      instance["network_port"])
731
      elif vnc_bind_address == constants.LOCALHOST_IP_ADDRESS:
732
        vnc_console_port = "%s:%s on node %s" % (vnc_bind_address,
733
                                                 instance["network_port"],
734
                                                 instance["pnode"])
722 735
      else:
723
        kpath = instance["kernel_path"]
724
      buf.write("  Kernel path: %s\n" % kpath)
725
      if instance["initrd_path"] in (None, constants.VALUE_DEFAULT):
726
        initrd = "(default: %s)" % constants.XEN_INITRD
727
      elif instance["initrd_path"] == constants.VALUE_NONE:
728
        initrd = "(none)"
736
        vnc_console_port = "%s:%s" % (vnc_bind_address,
737
                                      instance["network_port"])
738
      buf.write("    - console connection: vnc to %s\n" % vnc_console_port)
739

  
740
    else:
741
      # auto-handle other hypervisor types
742
      hvattrs = [(key, key) for key in instance["hv_actual"]]
743

  
744
    for key, desc in hvattrs:
745
      if key in instance["hv_instance"]:
746
        val = instance["hv_instance"][key]
729 747
      else:
730
        initrd = instance["initrd_path"]
731
      buf.write("       initrd: %s\n" % initrd)
732
    if False not in map(instance.has_key, hvm_parameters):
733
      buf.write("  HVM:\n")
734
      buf.write("    - boot order: %s\n" % instance["hvm_boot_order"])
735
      buf.write("    - ACPI support: %s\n" % instance["hvm_acpi"])
736
      buf.write("    - PAE support: %s\n" % instance["hvm_pae"])
737
      buf.write("    - virtual CDROM: %s\n" % instance["hvm_cdrom_image_path"])
738
      buf.write("    - virtual NIC type: %s\n" %  instance["hvm_nic_type"])
739
      buf.write("    - virtual disk type: %s\n" %  instance["hvm_disk_type"])
740
    if instance.has_key("vnc_bind_address"):
741
      buf.write("  VNC bind address: %s\n" % instance["vnc_bind_address"])
742
      buf.write("  VNC console port: %s\n" % instance["vnc_console_port"])
748
        val = "default (%s)" % instance["hv_actual"][key]
749
      buf.write("    - %s: %s\n" % (desc, val))
743 750
    buf.write("  Hardware:\n")
744 751
    buf.write("    - VCPUs: %d\n" % instance["vcpus"])
745 752
    buf.write("    - memory: %dMiB\n" % instance["memory"])
746 753
    buf.write("    - NICs: %s\n" %
747
        ", ".join(["{MAC: %s, IP: %s, bridge: %s}" %
748
                   (mac, ip, bridge)
749
                     for mac, ip, bridge in instance["nics"]]))
754
              ", ".join(["{MAC: %s, IP: %s, bridge: %s}" %
755
                         (mac, ip, bridge)
756
                         for mac, ip, bridge in instance["nics"]]))
750 757
    buf.write("  Block devices:\n")
751 758

  
752 759
    for device in instance["disks"]:

Also available in: Unified diff