Commit 4ea3de4e authored by Balazs Lecz's avatar Balazs Lecz
Browse files

Add oper_vcpus instance status field



This introduces a new instance status field, named "oper_vcpus".
It contains the actual number of VCPUs an instance is using as
seen by the hypervisor.
Signed-off-by: default avatarBalazs Lecz <leczb@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 63cef6c3
......@@ -5063,7 +5063,10 @@ class LUQueryInstances(NoHooksLU):
if name not in constants.HVC_GLOBALS] +
["be/%s" % name
for name in constants.BES_PARAMETERS])
_FIELDS_DYNAMIC = utils.FieldSet("oper_state", "oper_ram", "status")
_FIELDS_DYNAMIC = utils.FieldSet("oper_state",
"oper_ram",
"oper_vcpus",
"status")
def CheckArguments(self):
......@@ -5194,6 +5197,13 @@ class LUQueryInstances(NoHooksLU):
val = live_data[instance.name].get("memory", "?")
else:
val = "-"
elif field == "oper_vcpus":
if instance.primary_node in bad_nodes:
val = None
elif instance.name in live_data:
val = live_data[instance.name].get("vcpus", "?")
else:
val = "-"
elif field == "vcpus":
val = i_be[constants.BE_VCPUS]
elif field == "disk_template":
......
......@@ -58,7 +58,7 @@ I_FIELDS = ["name", "admin_state", "os",
"network_port",
"disk.sizes", "disk_usage",
"beparams", "hvparams",
"oper_state", "oper_ram", "status",
"oper_state", "oper_ram", "oper_vcpus", "status",
] + _COMMON_FIELDS
N_FIELDS = ["name", "offline", "master_candidate", "drained",
......
......@@ -1149,6 +1149,13 @@ instance5: 11225
by the hypervisor</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>oper_vcpus</term>
<listitem>
<simpara>the actual number of VCPUs the instance is using
as seen by the hypervisor</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>ip</term>
<listitem>
......@@ -1400,7 +1407,8 @@ instance5: 11225
<para>
There is a subtle grouping about the available output
fields: all fields except for <option>oper_state</option>,
<option>oper_ram</option> and <option>status</option> are
<option>oper_ram</option>, <option>oper_vcpus</option> and
<option>status</option> are
configuration value and not run-time values. So if you don't
select any of the these fields, the query will be satisfied
instantly from the cluster configuration, without having to
......
......@@ -88,7 +88,7 @@ INSTANCE_FIELDS = ("name", "os", "pnode", "snodes",
"disk_template", "disk.sizes",
"nic.ips", "nic.macs", "nic.modes", "nic.links",
"beparams", "hvparams",
"oper_state", "oper_ram", "status", "tags")
"oper_state", "oper_ram", "oper_vcpus", "status", "tags")
NODE_FIELDS = ("name", "dtotal", "dfree",
"mtotal", "mnode", "mfree",
......
......@@ -258,6 +258,7 @@ def ListInstances(opts, args):
"snodes": "Secondary_Nodes", "admin_state": "Autostart",
"oper_state": "Running",
"oper_ram": "Memory", "disk_template": "Disk_template",
"oper_vcpus": "VCPUs",
"ip": "IP_address", "mac": "MAC_address",
"nic_mode": "NIC_Mode", "nic_link": "NIC_Link",
"bridge": "Bridge",
......@@ -316,6 +317,9 @@ def ListInstances(opts, args):
elif field == "oper_ram":
if val is None:
val = "(node down)"
elif field == "oper_vcpus":
if val is None:
val = "(node down)"
elif field == "sda_size" or field == "sdb_size":
if val is None:
val = "N/A"
......@@ -1423,8 +1427,9 @@ commands = {
"[<instance>...]",
"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, nic_mode, nic_link, sda_size, sdb_size, vcpus, serial_no,"
" oper_vcpus, name, os, pnode, snodes, admin_state, admin_ram,"
" disk_template, ip, mac, nic_mode, nic_link, sda_size, sdb_size,"
" vcpus, serial_no,"
" nic.count, nic.mac/N, nic.ip/N, nic.mode/N, nic.link/N,"
" nic.macs, nic.ips, nic.modes, nic.links,"
" disk.count, disk.size/N, disk.sizes,"
......
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