Commit 90f72445 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add support for querying the ctime/mtime



This patch adds querying of ctime/mtime for the cluster/nodes/instances.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent d693c864
......@@ -2224,7 +2224,7 @@ class LUQueryNodes(NoHooksLU):
"name", "pinst_cnt", "sinst_cnt",
"pinst_list", "sinst_list",
"pip", "sip", "tags",
"serial_no",
"serial_no", "ctime", "mtime",
"master_candidate",
"master",
"offline",
......@@ -2348,6 +2348,10 @@ class LUQueryNodes(NoHooksLU):
val = list(node.GetTags())
elif field == "serial_no":
val = node.serial_no
elif field == "ctime":
val = node.ctime
elif field == "mtime":
val = node.mtime
elif field == "master_candidate":
val = node.master_candidate
elif field == "master":
......@@ -3042,6 +3046,8 @@ class LUQueryClusterInfo(NoHooksLU):
"master_netdev": cluster.master_netdev,
"volume_group_name": cluster.volume_group_name,
"file_storage_dir": cluster.file_storage_dir,
"ctime": cluster.ctime,
"mtime": cluster.mtime,
}
return result
......@@ -3919,7 +3925,9 @@ class LUQueryInstances(NoHooksLU):
r"(nic)\.(bridge)/([0-9]+)",
r"(nic)\.(macs|ips|modes|links|bridges)",
r"(disk|nic)\.(count)",
"serial_no", "hypervisor", "hvparams",] +
"serial_no", "hypervisor", "hvparams",
"ctime", "mtime",
] +
["hv/%s" % name
for name in constants.HVS_PARAMETERS] +
["be/%s" % name
......@@ -4104,6 +4112,10 @@ class LUQueryInstances(NoHooksLU):
val = list(instance.GetTags())
elif field == "serial_no":
val = instance.serial_no
elif field == "ctime":
val = instance.ctime
elif field == "mtime":
val = instance.mtime
elif field == "network_port":
val = instance.network_port
elif field == "hypervisor":
......@@ -6734,6 +6746,9 @@ class LUQueryInstanceData(NoHooksLU):
"hv_actual": cluster.FillHV(instance),
"be_instance": instance.beparams,
"be_actual": cluster.FillBE(instance),
"serial_no": instance.serial_no,
"mtime": instance.mtime,
"ctime": instance.ctime,
}
result[instance.name] = idict
......
......@@ -986,6 +986,34 @@ instance5: 11225
to track modifications</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>ctime</term>
<listitem>
<para>
the creation time of the instance; note that this
field contains spaces and as such it's harder to parse
</para>
<para>
if this attribute is not present (e.g. when upgrading
from older versions), then "N/A" will be shown instead
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>mtime</term>
<listitem>
<para>
the last modification time of the instance; note that
this field contains spaces and as such it's harder to
parse
</para>
<para>
if this attribute is not present (e.g. when upgrading
from older versions), then "N/A" will be shown instead
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>network_port</term>
<listitem>
......
......@@ -379,12 +379,38 @@
<varlistentry>
<term>serial_no</term>
<listitem>
<simpara>the so called 'serial number' of the instance;
<simpara>the so called 'serial number' of the node;
this is a numeric field that is incremented each time
the instance is modified, and it can be used to detect
the node is modified, and it can be used to detect
modifications</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>ctime</term>
<listitem>
<para>
the creation time of the node; note that this field
contains spaces and as such it's harder to parse
</para>
<para>
if this attribute is not present (e.g. when upgrading
from older versions), then "N/A" will be shown instead
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>mtime</term>
<listitem>
<para>
the last modification time of the node; note that this
field contains spaces and as such it's harder to parse
</para>
<para>
if this attribute is not present (e.g. when upgrading
from older versions), then "N/A" will be shown instead
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>ctotal</term>
<listitem>
......
......@@ -221,6 +221,9 @@ def ShowClusterConfig(opts, args):
ToStdout("Cluster name: %s", result["name"])
ToStdout("Creation time: %s", utils.FormatTime(result["ctime"]))
ToStdout("Modification time: %s", utils.FormatTime(result["mtime"]))
ToStdout("Master node: %s", result["master"])
ToStdout("Architecture (this node): %s (%s)",
......
......@@ -27,6 +27,7 @@ import sys
import os
import itertools
import simplejson
import time
from optparse import make_option
from cStringIO import StringIO
......@@ -226,6 +227,7 @@ def ListInstances(opts, args):
"nic.count": "NICs", "nic.ips": "NIC_IPs",
"nic.modes": "NIC_modes", "nic.links": "NIC_links",
"nic.bridges": "NIC_bridges", "nic.macs": "NIC_MACs",
"ctime": "CTime", "mtime": "MTime",
}
else:
headers = None
......@@ -260,6 +262,8 @@ def ListInstances(opts, args):
elif field == "sda_size" or field == "sdb_size":
if val is None:
val = "N/A"
elif field == "ctime" or field == "mtime":
val = utils.FormatTime(val)
elif field in list_type_fields:
val = ",".join(str(item) for item in val)
elif val is None:
......@@ -1169,6 +1173,9 @@ def ShowInstanceConfig(opts, args):
for instance_name in result:
instance = result[instance_name]
buf.write("Instance name: %s\n" % instance["name"])
buf.write("Serial number: %s\n" % instance["serial_no"])
buf.write("Creation time: %s\n" % utils.FormatTime(instance["ctime"]))
buf.write("Modification time: %s\n" % utils.FormatTime(instance["mtime"]))
buf.write("State: configured to be %s" % instance["config_state"])
if not opts.static:
buf.write(", actual state is %s" % instance["run_state"])
......
......@@ -57,6 +57,7 @@ _LIST_HEADERS = {
"master": "IsMaster",
"offline": "Offline", "drained": "Drained",
"role": "Role",
"ctime": "CTime", "mtime": "MTime",
}
#: User-facing storage unit types
......@@ -175,6 +176,8 @@ def ListNodes(opts, args):
val = 'Y'
else:
val = 'N'
elif field == "ctime" or field == "mtime":
val = utils.FormatTime(val)
elif val is None:
val = "?"
row[idx] = str(val)
......
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