return choice
-def _TransformPath(user_input):
- """Transform a user path into a canonical value.
-
- This function transforms the a path passed as textual information
- into the constants that the LU code expects.
-
- """
- if user_input:
- if user_input.lower() == "default":
- result_path = constants.VALUE_DEFAULT
- elif user_input.lower() == "none":
- result_path = constants.VALUE_NONE
- else:
- if not os.path.isabs(user_input):
- raise errors.OpPrereqError("Path '%s' is not an absolute filename" %
- user_input)
- result_path = user_input
- else:
- result_path = constants.VALUE_DEFAULT
-
- return result_path
-
-
def _EnsureInstancesExist(client, names):
"""Check for and ensure the given instance names exist.
"hvparams": "Hypervisor_parameters",
"be/memory": "Configured_memory",
"be/vcpus": "VCPUs",
+ "vcpus": "VCPUs",
"be/auto_balance": "Auto_balance",
"disk.count": "Disks", "disk.sizes": "Disk_sizes",
"nic.count": "NICs", "nic.ips": "NIC_IPs",
for name in inames:
op = opcodes.OpStartupInstance(instance_name=name,
force=opts.force)
+ # do not add these parameters to the opcode unless they're defined
+ if opts.hvparams:
+ op.hvparams = opts.hvparams
+ if opts.beparams:
+ op.beparams = opts.beparams
jex.QueueJob(name, op)
jex.WaitOrShow(not opts.submit_only)
return 0
txt = "disk %d" % idx
else:
txt = "child %d" % idx
- d1 = ["- %s: %s" % (txt, dev["dev_type"])]
+ if isinstance(dev["size"], int):
+ nice_size = utils.FormatUnit(dev["size"], "h")
+ else:
+ nice_size = dev["size"]
+ d1 = ["- %s: %s, size %s" % (txt, dev["dev_type"], nice_size)]
data = []
if top_level:
data.append(("access mode", dev["mode"]))
@return: the desired exit code
"""
+ if not args and not opts.show_all:
+ ToStderr("No instance selected."
+ " Please pass in --all if you want to query all instances.\n"
+ "Note that this can take a long time on a big cluster.")
+ return 1
+ elif args and opts.show_all:
+ ToStderr("Cannot use --all if you specify instance names.")
+ return 1
+
retcode = 0
op = opcodes.OpQueryInstanceData(instances=args, static=opts.static)
result = SubmitOpCode(op)
make_option("-s", "--static", dest="static",
action="store_true", default=False,
help="Only show configuration data, not runtime data"),
- ], "[-s] [<instance>...]",
+ make_option("--all", dest="show_all",
+ default=False, action="store_true",
+ help="Show info on all instances on the cluster."
+ " This can take a long time to run, use wisely."),
+ ], "[-s] {--all | <instance>...}",
"Show information on the specified instance(s)"),
'list': (ListInstances, ARGS_ANY,
[DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT, SYNC_OPT],
m_node_opt, m_pri_node_opt, m_sec_node_opt,
m_clust_opt, m_inst_opt,
SUBMIT_OPT,
+ keyval_option("-H", "--hypervisor", type="keyval",
+ default={}, dest="hvparams",
+ help="Temporary hypervisor parameters"),
+ keyval_option("-B", "--backend", type="keyval",
+ default={}, dest="beparams",
+ help="Temporary backend parameters"),
],
- "<instance>", "Starts an instance"),
+ "<instance>", "Starts an instance"),
'reboot': (RebootInstance, ARGS_ANY,
[DEBUG_OPT, m_force_multi,