linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH 4/3 v1 nvmetcli] nvmetcli: expose nvmet port status and state
Date: Thu, 12 Apr 2018 11:06:56 +0300	[thread overview]
Message-ID: <20180412080656.1691-5-sagi@grimberg.me> (raw)
In-Reply-To: <20180412080656.1691-1-sagi@grimberg.me>

status reflects if any subsystems are bound and can
accept existing connections. state reflects the
physical state of the port. Also colorize UI if
port state is down.

Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
 nvmet/nvme.py | 11 +++++++++++
 nvmetcli      |  9 ++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/nvmet/nvme.py b/nvmet/nvme.py
index c245a4240dd9..290de2807930 100644
--- a/nvmet/nvme.py
+++ b/nvmet/nvme.py
@@ -174,6 +174,17 @@ class CFSNode(object):
             self._enable = int(file_fd.read().strip())
         return self._enable
 
+    def get_trstate(self):
+        self._check_self()
+        _trstate = None
+        path = "%s/trstate" % self.path
+        if not os.path.isfile(path):
+            return None
+
+        with open(path, 'r') as file_fd:
+            _trstate = file_fd.read().strip()
+        return _trstate
+
     def set_enable(self, value):
         self._check_self()
         path = "%s/enable" % self.path
diff --git a/nvmetcli b/nvmetcli
index 6b102a235450..fc6b0856c249 100755
--- a/nvmetcli
+++ b/nvmetcli
@@ -388,7 +388,14 @@ class UIPortNode(UINode):
         if trsvcid != "none":
             info.append("trsvcid=%s" % trsvcid)
         enabled = not (not self.cfnode.subsystems and not list(self.cfnode.referrals))
-        return (", ".join(info), True if enabled else 0)
+        info.append("status=" + ("enabled" if enabled else "disabled"))
+        if not enabled:
+            ret = 0
+        else:
+            trstate = self.cfnode.get_trstate()
+            info.append("state=" + trstate)
+            ret = True if trstate == "up" else False
+        return (", ".join(info), ret)
 
 class UIPortSubsystemsNode(UINode):
     def __init__(self, parent):
-- 
2.14.1

  parent reply	other threads:[~2018-04-12  8:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-12  8:06 [PATCH v1 0/3] nvmet-rdma automatic port re-activation Sagi Grimberg
2018-04-12  8:06 ` [PATCH v1 1/3] nvmet-rdma: automatic listening " Sagi Grimberg
2018-04-12 13:08   ` Israel Rukshin
2018-04-12  8:06 ` [PATCH v1 2/3] nvmet: Add fabrics ops to port Sagi Grimberg
2018-04-12  8:06 ` [PATCH v1 3/3] nvmet: Add port transport state flag Sagi Grimberg
2018-04-13 17:14   ` Christoph Hellwig
2018-04-15  8:54     ` Sagi Grimberg
2018-04-17 15:28       ` Christoph Hellwig
2018-05-16 12:40         ` Max Gurtovoy
2018-04-12  8:06 ` Sagi Grimberg [this message]
2018-04-12 11:25   ` [PATCH 4/3 v1 nvmetcli] nvmetcli: expose nvmet port status and state Nitzan Carmi
2018-04-12 12:34     ` Sagi Grimberg
2018-04-13 17:00 ` [PATCH v1 0/3] nvmet-rdma automatic port re-activation Christoph Hellwig
2018-04-15  8:53   ` Sagi Grimberg
2018-04-17 15:43     ` Christoph Hellwig
2018-04-20  2:48     ` Doug Ledford

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=20180412080656.1691-5-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).