[PATCH] nvmetcli: support 'dhchap' attribute group

Hannes Reinecke hare at suse.de
Mon Jun 27 08:13:07 PDT 2022


On 6/27/22 17:08, Sagi Grimberg wrote:
> 
>> 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.
>>
>> Signed-off-by: Hannes Reinecke <hare at suse.de>
>> ---
>>   nvmet/nvme.py | 2 ++
>>   nvmetcli      | 4 ++++
>>   2 files changed, 6 insertions(+)
>>
>> diff --git a/nvmet/nvme.py b/nvmet/nvme.py
>> index d170204..2ad9006 100644
>> --- a/nvmet/nvme.py
>> +++ b/nvmet/nvme.py
>> @@ -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()
>> diff --git a/nvmetcli b/nvmetcli
>> index 8ee8590..8da379b 100755
>> --- a/nvmetcli
>> +++ b/nvmetcli
>> @@ -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:
> diff --git a/nvmetcli b/nvmetcli
> index 8da379bde9db..b06039b2338d 100755
> --- a/nvmetcli
> +++ b/nvmetcli
> @@ -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():

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
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare at suse.de                              +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



More information about the Linux-nvme mailing list