linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH nvmetcli 2/2] nvmetcli: decorate namespace, subsystem and port UI
Date: Tue, 17 Oct 2017 13:34:56 +0300	[thread overview]
Message-ID: <1508236496-23921-2-git-send-email-sagi@grimberg.me> (raw)
In-Reply-To: <1508236496-23921-1-git-send-email-sagi@grimberg.me>

Display some info on the on the UI node.

Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
 nvmetcli | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/nvmetcli b/nvmetcli
index 951b6431e6f0..ae86e89b61aa 100755
--- a/nvmetcli
+++ b/nvmetcli
@@ -24,7 +24,10 @@ import os
 import sys
 import configshell_fb as configshell
 import nvmet as nvme
+import uuid
 
+def ngiud_set(nguid):
+    return any(c.isdigit() and c != '0' for c in nguid)
 
 class UINode(configshell.node.ConfigNode):
     def __init__(self, name, parent=None, cfnode=None, shell=None):
@@ -160,6 +163,13 @@ class UISubsystemNode(UINode):
         UINamespacesNode(self)
         UIAllowedHostsNode(self)
 
+    def summary(self):
+        info = []
+        info.append("version=" + self.cfnode.get_attr("attr","version"))
+        info.append("allow_any=" + self.cfnode.get_attr("attr","allow_any_host"))
+        info.append("serial=" + self.cfnode.get_attr("attr","serial"))
+        return (", ".join(info), True)
+
 
 class UINamespacesNode(UINode):
     def __init__(self, parent):
@@ -247,6 +257,19 @@ class UINamespaceNode(UINode):
                 raise configshell.ExecutionError(
                     "The Namespace could not be disabled.")
 
+    def summary(self):
+        info = []
+        info.append("path=" + self.cfnode.get_attr("device", "path"))
+        ns_uuid = self.cfnode.get_attr("device", "uuid")
+        if uuid.UUID(ns_uuid).int != 0:
+            info.append("uuid=" + str(ns_uuid))
+        ns_nguid = self.cfnode.get_attr("device", "nguid")
+        if ngiud_set(ns_nguid):
+            info.append("nguid=" + ns_nguid)
+        info.append("enabled" if self.cfnode.get_enable() else "disabled")
+        ns_enabled = self.cfnode.get_enable()
+        return (", ".join(info), True if ns_enabled == 1 else ns_enabled)
+
 
 class UIAllowedHostsNode(UINode):
     def __init__(self, parent):
@@ -361,6 +384,13 @@ class UIPortNode(UINode):
             return "enabled"
         return "disabled"
 
+    def summary(self):
+        info = []
+        info.append("traddr=" + self.cfnode.get_attr("addr", "traddr"))
+        info.append("trsvcid=" + self.cfnode.get_attr("addr", "trsvcid"))
+        info.append("trtype=" + self.cfnode.get_attr("addr", "trtype"))
+        return (", ".join(info), True)
+
 
 class UIPortSubsystemsNode(UINode):
     def __init__(self, parent):
-- 
2.7.4

      reply	other threads:[~2017-10-17 10:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-17 10:34 [PATCH nvmetcli 1/2] nvmetcli: Expose ls to dump UI configuration Sagi Grimberg
2017-10-17 10:34 ` Sagi Grimberg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1508236496-23921-2-git-send-email-sagi@grimberg.me \
    --to=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).