Skip to contentSkip to conversation

nvmetcli: support 'dhchap' attribute group

PATCH In review Hannes Reinecke 2 participants 3 messages Mar 23, 2022 – Jun 27, 2022 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmetcli: support 'dhchap' attribute group

NVMe authentication support added a new attribute group 'dhchap' to the host configfs directories. This patch adds functions to display and modify these entries from nvmetcli.

---
 nvmet/nvme.py | 2 ++
 nvmetcli      | 4 ++++
 2 files changed, 6 insertions(+)
nvmet/nvme.py +2 -0
index d170204..2ad9006 100644
@@ -892,6 +892,7 @@ class Host(CFSNode):
         '''
         super(Host, self).__init__()
 
+        self.attr_groups = ['dhchap']
         self.nqn = nqn
         self._path = "%s/hosts/%s" % (self.configfs_dir, nqn)
         self._create_in_cfs(mode)
@@ -913,6 +914,7 @@ class Host(CFSNode):
         except CFSError as e:
             err_func("Could not create Host object: %s" % e)
             return
+        h._setup_attrs(t, err_func)
 
     def dump(self):
         d = super(Host, self).dump()
nvmetcli +4 -0
index 8ee8590..8da379b 100755
@@ -661,6 +661,10 @@ class UIHostNode(UINode):
     def __init__(self, parent, cfnode):
         UINode.__init__(self, cfnode.nqn, parent, cfnode)
 
+    def summary(self):
+        info = []
+        info.append("key=" + self.cfnode.get_attr("dhchap", "key"))
+        return (", ".join(info), True)
 
 def usage():
     print("syntax: %s save [file_to_save_to]" % sys.argv[0])
Signature · 1 line
2.29.2
maintainer
#1 lore raw
Quoted 36 lines

NVMe authentication support added a new attribute group 'dhchap' to the host configfs directories. This patch adds functions to display and modify these entries from nvmetcli.

---
  nvmet/nvme.py | 2 ++
  nvmetcli      | 4 ++++
  2 files changed, 6 insertions(+)
nvmet/nvme.py +2 -0
index d170204..2ad9006 100644
@@ -892,6 +892,7 @@ class Host(CFSNode):
          '''
          super(Host, self).__init__()
 
+        self.attr_groups = ['dhchap']
          self.nqn = nqn
          self._path = "%s/hosts/%s" % (self.configfs_dir, nqn)
          self._create_in_cfs(mode)
@@ -913,6 +914,7 @@ class Host(CFSNode):
          except CFSError as e:
              err_func("Could not create Host object: %s" % e)
              return
+        h._setup_attrs(t, err_func)
 
      def dump(self):
          d = super(Host, self).dump()
nvmetcli +0 -0
index 8ee8590..8da379b 100755

nvmetcli class UIHostNode(UINode): · line 667

Quoted 7 lines
nvmetcli +4 -0
@@ -661,6 +661,10 @@ class UIHostNode(UINode):
      def __init__(self, parent, cfnode):
          UINode.__init__(self, cfnode.nqn, parent, cfnode)
 
+    def summary(self):
+        info = []
+        info.append("key=" + self.cfnode.get_attr("dhchap", "key"))
+        return (", ".join(info), True)

We shouldn't have a UI to the secrets themselves I think, we probably should do this instead:

nvmetcli +8 -1
index 8da379bde9db..b06039b2338d 100755
@@ -663,7 +663,14 @@ class UIHostNode(UINode):
 
     def summary(self):
         info = []
-        info.append("key=" + self.cfnode.get_attr("dhchap", "key"))
+        if self.cfnode.get_attr("dhchap", "key"):
+            info.append("hostkey=set")
+        else:
+            info.append("hostkey=unset")
+        if self.cfnode.get_attr("dhchap", "ctrl_key"):
+            info.append("ctrlkey=set")
+        else:
+            info.append("ctrlkey=unset")
         return (", ".join(info), True)
 
 def usage():
#2 lore raw
Quoted 54 lines · Sagi Grimberg
Quoted 34 lines

NVMe authentication support added a new attribute group 'dhchap' to the host configfs directories. This patch adds functions to display and modify these entries from nvmetcli.

---
  nvmet/nvme.py | 2 ++
  nvmetcli      | 4 ++++

  2 files changed, 6 insertions(+)
nvmet/nvme.py +0 -0
index d170204..2ad9006 100644
@@ -892,6 +892,7 @@ class Host(CFSNode):

          '''
          super(Host, self).__init__()
+        self.attr_groups = ['dhchap']
          self.nqn = nqn
          self._path = "%s/hosts/%s" % (self.configfs_dir, nqn) self._create_in_cfs(mode)

nvmet/nvme.py +0 -0
@@ -913,6 +914,7 @@ class Host(CFSNode):

          except CFSError as e:
              err_func("Could not create Host object: %s" % e) return
+        h._setup_attrs(t, err_func)
      def dump(self):
          d = super(Host, self).dump()

nvmetcli +0 -0
index 8ee8590..8da379b 100755
@@ -661,6 +661,10 @@ class UIHostNode(UINode):
Quoted 6 lines

      def __init__(self, parent, cfnode):
          UINode.__init__(self, cfnode.nqn, parent, cfnode) +    def summary(self):
+        info = []
+        info.append("key=" + self.cfnode.get_attr("dhchap", "key")) +        return (", ".join(info), True)

We shouldn't have a UI to the secrets themselves I think, we probably should do this instead:

nvmetcli +1 -1
index 8da379bde9db..b06039b2338d 100755
@@ -663,7 +663,14 @@ class UIHostNode(UINode):
 
      def summary(self):
          info = []
-        info.append("key=" + self.cfnode.get_attr("dhchap", "key"))
+        if self.cfnode.get_attr("dhchap", "key"):

nvmetcli class UIHostNode(UINode): · line 676

Quoted 10 lines
nvmetcli +7 -0
+            info.append("hostkey=set")
+        else:
+            info.append("hostkey=unset")
+        if self.cfnode.get_attr("dhchap", "ctrl_key"):
+            info.append("ctrlkey=set")
+        else:
+            info.append("ctrlkey=unset")
          return (", ".join(info), True)
 
  def usage():

Or just append 'hostkey' and/or 'ctrlkey' if set, and register nothing if the keys are unset.

Good point, though. I'll be sending a new patch.

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke                Kernel Storage Architect
[email protected]                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew
Myers, Andrew McDonald, Martje Boudien Moerman