headers = {
"name": "Instance", "os": "OS", "pnode": "Primary_node",
"snodes": "Secondary_Nodes", "admin_state": "Autostart",
- "oper_state": "Running", "admin_ram": "Configured_memory",
+ "oper_state": "Running",
"oper_ram": "Memory", "disk_template": "Disk_template",
"ip": "IP_address", "mac": "MAC_address",
- "bridge": "Bridge", "vcpus": "VCPUs",
+ "bridge": "Bridge",
"sda_size": "Disk/0", "sdb_size": "Disk/1",
"status": "Status", "tags": "Tags",
"network_port": "Network_port",
"vnc_bind_address": "VNC_bind_address",
"serial_no": "SerialNo", "hypervisor": "Hypervisor",
"hvparams": "Hypervisor_parameters",
+ "be/memory": "Configured_memory",
+ "be/vcpus": "VCPUs",
+ "be/auto_balance": "Auto_balance",
}
else:
headers = None
if opts.human_readable:
- unitfields = ["admin_ram", "oper_ram", "sda_size", "sdb_size"]
+ unitfields = ["be/memory", "oper_ram", "sda_size", "sdb_size"]
else:
unitfields = None
- numfields = ["admin_ram", "oper_ram", "sda_size", "sdb_size", "vcpus",
+ numfields = ["be/memory", "oper_ram", "sda_size", "sdb_size", "be/vcpus",
"serial_no"]
list_type_fields = ("tags",)
if opts.hypervisor:
hypervisor, hvparams = opts.hypervisor
+ bep = ValidateBeParams(opts.beparams)
+
## kernel_path = _TransformPath(opts.kernel_path)
## initrd_path = _TransformPath(opts.initrd_path)
## else:
## hvm_cdrom_image_path = opts.hvm_cdrom_image_path
- op = opcodes.OpCreateInstance(instance_name=instance, mem_size=opts.mem,
+ op = opcodes.OpCreateInstance(instance_name=instance,
disk_size=opts.size, swap_size=opts.swap,
disk_template=opts.disk_template,
mode=constants.INSTANCE_CREATE,
os_type=opts.os, pnode=pnode,
- snode=snode, vcpus=opts.vcpus,
+ snode=snode,
ip=opts.ip, bridge=opts.bridge,
start=opts.start, ip_check=opts.ip_check,
wait_for_sync=opts.wait_for_sync,
mac=opts.mac,
hypervisor=hypervisor,
hvparams=hvparams,
+ beparams=opts.beparams,
iallocator=opts.iallocator,
file_storage_dir=opts.file_storage_dir,
file_driver=opts.file_driver,
instance = args[0]
disk = args[1]
amount = utils.ParseUnit(args[2])
- op = opcodes.OpGrowDisk(instance_name=instance, disk=disk, amount=amount)
+ op = opcodes.OpGrowDisk(instance_name=instance, disk=disk, amount=amount,
+ wait_for_sync=opts.wait_for_sync)
SubmitOrSend(op, opts)
return 0
os._exit(1)
-def _FormatBlockDevInfo(buf, dev, indent_level):
+def _FormatBlockDevInfo(buf, dev, indent_level, static):
"""Show block device information.
This is only used by ShowInstanceConfig(), but it's too big to be
elif dev["physical_id"] is not None:
data += ", physical_id: %s" % (dev["physical_id"],)
buf.write("%*s%s\n" % (2*indent_level, "", data))
- buf.write("%*s primary: " % (2*indent_level, ""))
- helper(buf, dev["dev_type"], dev["pstatus"])
+ if not static:
+ buf.write("%*s primary: " % (2*indent_level, ""))
+ helper(buf, dev["dev_type"], dev["pstatus"])
- if dev["sstatus"]:
+ if dev["sstatus"] and not static:
buf.write("%*s secondary: " % (2*indent_level, ""))
helper(buf, dev["dev_type"], dev["sstatus"])
if dev["children"]:
for child in dev["children"]:
- _FormatBlockDevInfo(buf, child, indent_level+1)
+ _FormatBlockDevInfo(buf, child, indent_level+1, static)
def ShowInstanceConfig(opts, args):
"""
retcode = 0
- op = opcodes.OpQueryInstanceData(instances=args)
+ op = opcodes.OpQueryInstanceData(instances=args, static=opts.static)
result = SubmitOpCode(op)
- hvm_parameters = ("hvm_acpi", "hvm_pae", "hvm_cdrom_image_path",
- "hvm_boot_order", "hvm_nic_type", "hvm_disk_type")
-
- pvm_parameters = ("kernel_path", "initrd_path")
-
if not result:
logger.ToStdout("No instances.")
return 1
for instance_name in result:
instance = result[instance_name]
buf.write("Instance name: %s\n" % instance["name"])
- buf.write("State: configured to be %s, actual state is %s\n" %
- (instance["config_state"], instance["run_state"]))
+ buf.write("State: configured to be %s" % instance["config_state"])
+ if not opts.static:
+ buf.write(", actual state is %s" % instance["run_state"])
+ buf.write("\n")
+ ##buf.write("Considered for memory checks in cluster verify: %s\n" %
+ ## instance["auto_balance"])
buf.write(" Nodes:\n")
buf.write(" - primary: %s\n" % instance["pnode"])
buf.write(" - secondaries: %s\n" % ", ".join(instance["snodes"]))
- buf.write(" Hypervisor: %s\n" % instance["hypervisor"])
buf.write(" Operating system: %s\n" % instance["os"])
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
+ buf.write(" Hypervisor: %s\n" % instance["hypervisor"])
+ 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"])
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)"
+ vnc_console_port = "%s:%s" % (vnc_bind_address,
+ instance["network_port"])
+ buf.write(" - console connection: vnc to %s\n" % vnc_console_port)
+
+ else:
+ # auto-handle other hypervisor types
+ hvattrs = [(key, key) for key in instance["hv_actual"]]
+
+ for key, desc in hvattrs:
+ if key in instance["hv_instance"]:
+ val = instance["hv_instance"][key]
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"])
- buf.write(" - virtual NIC type: %s\n" % instance["hvm_nic_type"])
- buf.write(" - virtual disk type: %s\n" % instance["hvm_disk_type"])
- if instance.has_key("vnc_bind_address"):
- buf.write(" VNC bind address: %s\n" % instance["vnc_bind_address"])
- buf.write(" VNC console port: %s\n" % instance["vnc_console_port"])
+ val = "default (%s)" % instance["hv_actual"][key]
+ buf.write(" - %s: %s\n" % (desc, val))
buf.write(" Hardware:\n")
- buf.write(" - VCPUs: %d\n" % instance["vcpus"])
- buf.write(" - memory: %dMiB\n" % instance["memory"])
+ buf.write(" - VCPUs: %d\n" %
+ instance["be_actual"][constants.BE_VCPUS])
+ buf.write(" - memory: %dMiB\n" %
+ instance["be_actual"][constants.BE_MEMORY])
buf.write(" - NICs: %s\n" %
- ", ".join(["{MAC: %s, IP: %s, bridge: %s}" %
- (mac, ip, bridge)
- for mac, ip, bridge in instance["nics"]]))
+ ", ".join(["{MAC: %s, IP: %s, bridge: %s}" %
+ (mac, ip, bridge)
+ for mac, ip, bridge in instance["nics"]]))
buf.write(" Block devices:\n")
for device in instance["disks"]:
- _FormatBlockDevInfo(buf, device, 1)
+ _FormatBlockDevInfo(buf, device, 1, opts.static)
logger.ToStdout(buf.getvalue().rstrip('\n'))
return retcode
opts - class with options as members
args - list with a single element, the instance name
Opts used:
- memory - the new memory size
- vcpus - the new number of cpus
mac - the new MAC address of the instance
"""
if not (opts.mem or opts.vcpus or opts.ip or opts.bridge or opts.mac or
- opts.kernel_path or opts.initrd_path or opts.hvm_boot_order or
- opts.hvm_acpi or opts.hvm_pae or opts.hvm_cdrom_image_path or
- opts.vnc_bind_address or opts.hvm_nic_type or opts.hvm_disk_type):
+ opts.hypervisor):
logger.ToStdout("Please give at least one of the parameters.")
return 1
- kernel_path = _TransformPath(opts.kernel_path)
- initrd_path = _TransformPath(opts.initrd_path)
- if opts.hvm_boot_order == 'default':
- hvm_boot_order = constants.VALUE_DEFAULT
- else:
- hvm_boot_order = opts.hvm_boot_order
-
- if opts.hvm_acpi is None:
- hvm_acpi = opts.hvm_acpi
- else:
- hvm_acpi = opts.hvm_acpi == _VALUE_TRUE
-
- if opts.hvm_pae is None:
- hvm_pae = opts.hvm_pae
- else:
- hvm_pae = opts.hvm_pae == _VALUE_TRUE
-
- if opts.hvm_nic_type == constants.VALUE_NONE:
- hvm_nic_type = None
- else:
- hvm_nic_type = opts.hvm_nic_type
-
- if opts.hvm_disk_type == constants.VALUE_NONE:
- hvm_disk_type = None
- else:
- hvm_disk_type = opts.hvm_disk_type
-
- op = opcodes.OpSetInstanceParams(instance_name=args[0], mem=opts.mem,
- vcpus=opts.vcpus, ip=opts.ip,
+ op = opcodes.OpSetInstanceParams(instance_name=args[0],
+ ip=opts.ip,
bridge=opts.bridge, mac=opts.mac,
- kernel_path=opts.kernel_path,
- initrd_path=opts.initrd_path,
- hvm_boot_order=hvm_boot_order,
- hvm_acpi=hvm_acpi, hvm_pae=hvm_pae,
- hvm_cdrom_image_path=
- opts.hvm_cdrom_image_path,
- vnc_bind_address=opts.vnc_bind_address,
- hvm_nic_type=hvm_nic_type,
- hvm_disk_type=hvm_disk_type,
+ hvparams=opts.hypervisor,
+ beparams=opts.beparams,
force=opts.force)
# even if here we process the result, we allow submit only
" suffix is used",
default=4 * 1024, type="unit", metavar="<size>"),
os_opt,
- cli_option("-m", "--memory", dest="mem", help="Memory size (in MiB)",
- default=128, type="unit", metavar="<mem>"),
- make_option("-p", "--cpu", dest="vcpus", help="Number of virtual CPUs",
- default=1, type="int", metavar="<PROC>"),
+ keyval_option("-B", "--backend", dest="beparams",
+ type="keyval", default={},
+ help="Backend parameters"),
make_option("-t", "--disk-template", dest="disk_template",
help="Custom disk setup (diskless, file, plain or drbd)",
default=None, metavar="TEMPL"),
"[-f] <instance>",
"Stops the instance and starts it on the backup node, using"
" the remote mirror (only for instances of type drbd)"),
- 'info': (ShowInstanceConfig, ARGS_ANY, [DEBUG_OPT], "[<instance>...]",
- "Show information on the specified instance"),
+ 'info': (ShowInstanceConfig, ARGS_ANY,
+ [DEBUG_OPT,
+ make_option("-s", "--static", dest="static",
+ action="store_true", default=False,
+ help="Only show configuration data, not runtime data"),
+ ], "[-s] [<instance>...]",
+ "Show information on the specified instance(s)"),
'list': (ListInstances, ARGS_NONE,
[DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT], "",
"Lists the instances and their status. The available fields are"
make_option("--mac", dest="mac",
help="MAC address", default=None,
type="string", metavar="<MACADDRESS>"),
- make_option("--kernel", dest="kernel_path",
- help="Path to the instances' kernel (or"
- " 'default')", default=None,
- type="string", metavar="<FILENAME>"),
- make_option("--initrd", dest="initrd_path",
- help="Path to the instances' initrd (or 'none', or"
- " 'default')", default=None,
- type="string", metavar="<FILENAME>"),
- make_option("--hvm-boot-order", dest="hvm_boot_order",
- help="boot device order for HVM"
- "(either one or more of [acdn] or 'default')",
- default=None, type="string", metavar="<BOOTORDER>"),
- make_option("--hvm-acpi", dest="hvm_acpi",
- help="ACPI support for HVM (true|false)",
- metavar="<BOOL>", choices=["true", "false"]),
- make_option("--hvm-pae", dest="hvm_pae",
- help="PAE support for HVM (true|false)",
- metavar="<BOOL>", choices=["true", "false"]),
- make_option("--hvm-cdrom-image-path",
- dest="hvm_cdrom_image_path",
- help="CDROM image path for HVM"
- "(absolute path or None)",
- default=None, type="string", metavar="<CDROMIMAGE>"),
- make_option("--hvm-nic-type", dest="hvm_nic_type",
- help="Type of virtual NIC for HVM "
- "(rtl8139,ne2k_pci,ne2k_isa,paravirtual)",
- metavar="NICTYPE",
- choices=[constants.HT_HVM_NIC_RTL8139,
- constants.HT_HVM_NIC_NE2K_PCI,
- constants.HT_HVM_NIC_NE2K_ISA,
- constants.HT_HVM_DEV_PARAVIRTUAL],
- default=None),
- make_option("--hvm-disk-type", dest="hvm_disk_type",
- help="Type of virtual disks for HVM "
- "(ioemu,paravirtual)",
- metavar="DISKTYPE",
- choices=[constants.HT_HVM_DEV_IOEMU,
- constants.HT_HVM_DEV_PARAVIRTUAL],
- default=None),
- make_option("--vnc-bind-address", dest="vnc_bind_address",
- help="bind address for VNC (IP address)",
- default=None, type="string", metavar="<VNCADDRESS>"),
+ keyval_option("-H", "--hypervisor", type="keyval",
+ default={}, dest="hypervisor",
+ help="Change hypervisor parameters"),
SUBMIT_OPT,
],
"<instance>", "Alters the parameters of an instance"),
'deactivate-disks': (DeactivateDisks, ARGS_ONE, [DEBUG_OPT, SUBMIT_OPT],
"<instance>",
"Deactivate an instance's disks"),
- 'grow-disk': (GrowDisk, ARGS_FIXED(3), [DEBUG_OPT, SUBMIT_OPT],
+ 'grow-disk': (GrowDisk, ARGS_FIXED(3),
+ [DEBUG_OPT, SUBMIT_OPT,
+ make_option("--no-wait-for-sync",
+ dest="wait_for_sync", default=True,
+ action="store_false",
+ help="Don't wait for sync (DANGEROUS!)"),
+ ],
"<instance> <disk> <size>", "Grow an instance's disk"),
'list-tags': (ListTags, ARGS_ONE, [DEBUG_OPT],
"<instance_name>", "List the tags of the given instance"),