From: Tony Asleson Date: Thu, 26 Mar 2020 18:07:50 +0000 (-0500) Subject: nvmetcli: Report save name correctly X-Git-Tag: v0.8~8 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=fd09200bba73011b4b7086c96e394ce875fdd38f;p=users%2Fhch%2Fnvmetcli.git nvmetcli: Report save name correctly When a user simply does 'nvmetcli restore' without specifying a file name the default is used. However, if the restore fails you end up with the error message: Error processing config file at None, error [Errno 1] Operation not permitted: '/sys/kernel/config/nvmet/ports/0/ana_groups/1', exiting Correct file name if None in error path. Error processing config file at /etc/nvmet/config.json, error \ [Errno 1] Operation not permitted: \ '/sys/kernel/config/nvmet/ports/1/ana_groups/1', exiting Signed-off-by: Tony Asleson Signed-off-by: Christoph Hellwig --- diff --git a/nvmet/__init__.py b/nvmet/__init__.py index ca05de4..cf172bd 100644 --- a/nvmet/__init__.py +++ b/nvmet/__init__.py @@ -1 +1,2 @@ -from .nvme import Root, Subsystem, Namespace, Port, Host, Referral, ANAGroup +from .nvme import Root, Subsystem, Namespace, Port, Host, Referral, ANAGroup,\ + DEFAULT_SAVE_FILE diff --git a/nvmetcli b/nvmetcli index a646232..8ee8590 100755 --- a/nvmetcli +++ b/nvmetcli @@ -680,6 +680,9 @@ def restore(from_file): try: errors = nvme.Root().restore_from_file(from_file) except IOError as e: + if not from_file: + from_file = nvme.DEFAULT_SAVE_FILE + if e.errno == errno.ENOENT: # Not an error if the restore file is not present print("No saved config file at %s, ok, exiting" % from_file)