This checks that the fields required are valid output fields.
"""
- self.dynamic_fields = frozenset(["oper_state", "oper_ram"])
+ self.dynamic_fields = frozenset(["oper_state", "oper_ram", "status"])
_CheckOutputFields(static=["name", "os", "pnode", "snodes",
"admin_state", "admin_ram",
"disk_template", "ip", "mac", "bridge",
val = None
else:
val = bool(live_data.get(instance.name))
+ elif field == "status":
+ if instance.primary_node in bad_nodes:
+ val = "ERROR_nodedown"
+ else:
+ running = bool(live_data.get(instance.name))
+ if running:
+ if instance.status != "down":
+ val = "running"
+ else:
+ val = "ERROR_up"
+ else:
+ if instance.status != "down":
+ val = "ERROR_down"
+ else:
+ val = "ADMIN_down"
elif field == "admin_ram":
val = instance.memory
elif field == "oper_ram":
<varlistentry>
<term>oper_state</term>
<listitem>
- <simpara>the actual state of the instance; can take of
- the values "running", "stopped", "(node down)"</simpara>
+ <simpara>the actual state of the instance; can be
+ one of the values "running", "stopped", "(node
+ down)"</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>status</term>
+ <listitem>
+ <simpara>combined form of admin_state and oper_stat;
+ this can be one of:
+ <computeroutput>ERROR_nodedown</computeroutput> if the
+ node of the instance is down,
+ <computeroutput>ERROR_down</computeroutput> if the
+ instance should run but is down,
+ <computeroutput>ERROR_up</computeroutput> if the
+ instance should be stopped but is actually running,
+ <computeroutput>ADMIN_down</computeroutput> if the
+ instance has been stopped (and is stopped) and
+ <computeroutput>running</computeroutput> if the
+ instance is set to be running (and is
+ running)</simpara>
</listitem>
</varlistentry>
<varlistentry>
"""
if opts.output is None:
- selected_fields = ["name", "os", "pnode", "admin_state",
- "oper_state", "oper_ram"]
+ selected_fields = ["name", "os", "pnode", "status", "oper_ram"]
else:
selected_fields = opts.output.split(",")
output = SubmitOpCode(op)
if not opts.no_headers:
- headers = {"name": "Instance", "os": "OS", "pnode": "Primary_node",
- "snodes": "Secondary_Nodes", "admin_state": "Autostart",
- "oper_state": "Status", "admin_ram": "Configured_memory",
- "oper_ram": "Memory", "disk_template": "Disk_template",
- "ip": "IP Address", "mac": "MAC Address",
- "bridge": "Bridge", "vcpus": "VCPUs",
- "sda_size": "Disk/0", "sdb_size": "Disk/1"}
+ headers = {
+ "name": "Instance", "os": "OS", "pnode": "Primary_node",
+ "snodes": "Secondary_Nodes", "admin_state": "Autostart",
+ "oper_state": "Running", "admin_ram": "Configured_memory",
+ "oper_ram": "Memory", "disk_template": "Disk_template",
+ "ip": "IP Address", "mac": "MAC Address",
+ "bridge": "Bridge", "vcpus": "VCPUs",
+ "sda_size": "Disk/0", "sdb_size": "Disk/1",
+ "status": "Status",
+ }
else:
headers = None
'info': (ShowInstanceConfig, ARGS_ANY, [DEBUG_OPT], "[<instance>...]",
"Show information on the specified instance"),
'list': (ListInstances, ARGS_NONE,
- [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT],
- "", "Lists the instances and their status. The available fields"
- " are (see the man page for details): oper_state, oper_ram,"
+ [DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT], "",
+ "Lists the instances and their status. The available fields are"
+ " (see the man page for details): status, oper_state, oper_ram,"
" name, os, pnode, snodes, admin_state, admin_ram, disk_template,"
" ip, mac, bridge, sda_size, sdb_size, vcpus. The default field"
- " list is (in order): name, os, pnode, admin_state, oper_state,"
+ " list is (in order): name, os, pnode, status,"
" oper_ram."),
'reinstall': (ReinstallInstance, ARGS_ONE, [DEBUG_OPT, FORCE_OPT, os_opt],
"[-f] <instance>", "Reinstall the instance"),