From 38d7239a7a7182b919b3b8dbeac809b08075ce87 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Sat, 27 Sep 2008 15:58:41 +0000 Subject: [PATCH] Allow listing of the serial_no via gnt-* list This patch adds listing of the serial_no attribute in gnt-instance and gnt-node list, and updates to the manpages to reflect the change. Reviewed-by: ultrotter --- lib/cmdlib.py | 6 ++++++ man/gnt-instance.sgml | 9 +++++++++ man/gnt-node.sgml | 9 +++++++++ scripts/gnt-instance | 7 +++++-- scripts/gnt-node | 6 ++++-- 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 6a975263f..c9474b0ef 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -1423,6 +1423,7 @@ class LUQueryNodes(NoHooksLU): "name", "pinst_cnt", "sinst_cnt", "pinst_list", "sinst_list", "pip", "sip", "tags", + "serial_no", ]) _CheckOutputFields(static=self.static_fields, @@ -1528,6 +1529,8 @@ class LUQueryNodes(NoHooksLU): val = node.secondary_ip elif field == "tags": val = list(node.GetTags()) + elif field == "serial_no": + val = node.serial_no elif field in self.dynamic_fields: val = live_data[node.name].get(field, None) else: @@ -2576,6 +2579,7 @@ class LUQueryInstances(NoHooksLU): "hvm_boot_order", "hvm_acpi", "hvm_pae", "hvm_cdrom_image_path", "hvm_nic_type", "hvm_disk_type", "vnc_bind_address", + "serial_no", ]) _CheckOutputFields(static=self.static_fields, dynamic=self.dynamic_fields, @@ -2705,6 +2709,8 @@ class LUQueryInstances(NoHooksLU): val = instance.vcpus elif field == "tags": val = list(instance.GetTags()) + elif field == "serial_no": + val = instance.serial_no elif field in ("network_port", "kernel_path", "initrd_path", "hvm_boot_order", "hvm_acpi", "hvm_pae", "hvm_cdrom_image_path", "hvm_nic_type", diff --git a/man/gnt-instance.sgml b/man/gnt-instance.sgml index 15cb4c818..1dd11525e 100644 --- a/man/gnt-instance.sgml +++ b/man/gnt-instance.sgml @@ -612,6 +612,15 @@ tags</simpara> </listitem> </varlistentry> + <varlistentry> + <term>serial_no</term> + <listitem> + <simpara>the so called 'serial number' of the + instance; this is a numeric field that is incremented + each time the instance is modified, and it can be used + to detect modifications</simpara> + </listitem> + </varlistentry> </variablelist> </para> diff --git a/man/gnt-node.sgml b/man/gnt-node.sgml index 65b8d81f5..5b1b46871 100644 --- a/man/gnt-node.sgml +++ b/man/gnt-node.sgml @@ -333,6 +333,15 @@ tags</simpara> </listitem> </varlistentry> + <varlistentry> + <term>serial_no</term> + <listitem> + <simpara>the so called 'serial number' of the instance; + this is a numeric field that is incremented each time + the instance is modified, and it can be used to detect + modifications</simpara> + </listitem> + </varlistentry> </variablelist> </para> diff --git a/scripts/gnt-instance b/scripts/gnt-instance index 7b8ce9db3..3452d0862 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -197,6 +197,7 @@ def ListInstances(opts, args): "hvm_nic_type": "HVM_NIC_type", "hvm_disk_type": "HVM_disk_type", "vnc_bind_address": "VNC_bind_address", + "serial_no": "SerialNo", } else: headers = None @@ -206,7 +207,8 @@ def ListInstances(opts, args): else: unitfields = None - numfields = ["admin_ram", "oper_ram", "sda_size", "sdb_size", "vcpus"] + numfields = ["admin_ram", "oper_ram", "sda_size", "sdb_size", "vcpus", + "serial_no"] list_type_fields = ("tags",) # change raw values to nicer strings @@ -972,7 +974,8 @@ commands = { "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" + " ip, mac, bridge, sda_size, sdb_size, vcpus, serial_no." + " The default field" " list is (in order): %s." % ", ".join(_LIST_DEF_FIELDS), ), 'reinstall': (ReinstallInstance, ARGS_ONE, diff --git a/scripts/gnt-node b/scripts/gnt-node index 8acf34a8e..46dc36e8d 100755 --- a/scripts/gnt-node +++ b/scripts/gnt-node @@ -91,6 +91,7 @@ def ListNodes(opts, args): "bootid": "BootID", "ctotal": "CTotal", "tags": "Tags", + "serial_no": "SerialNo", } else: headers = None @@ -103,7 +104,7 @@ def ListNodes(opts, args): numfields = ["dtotal", "dfree", "mtotal", "mnode", "mfree", "pinst_cnt", "sinst_cnt", - "ctotal"] + "ctotal", "serial_no"] list_type_fields = ("pinst_list", "sinst_list", "tags") # change raw values to nicer strings @@ -344,7 +345,8 @@ commands = { "", "Lists the nodes in the cluster. The available fields" " are (see the man page for details): name, pinst_cnt, pinst_list," " sinst_cnt, sinst_list, pip, sip, dtotal, dfree, mtotal, mnode," - " mfree, bootid, cpu_count. The default field list is" + " mfree, bootid, cpu_count, serial_no." + " The default field list is" " (in order): %s." % ", ".join(_LIST_DEF_FIELDS), ), 'remove': (RemoveNode, ARGS_ONE, [DEBUG_OPT], -- GitLab