All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Asleson <tasleson@redhat.com>
To: linux-nvme@lists.infradead.org
Subject: [PATCH v2 7/7] nvmetcli: Report save name correctly
Date: Thu, 26 Mar 2020 13:07:50 -0500	[thread overview]
Message-ID: <20200326180750.469346-8-tasleson@redhat.com> (raw)
In-Reply-To: <20200326180750.469346-1-tasleson@redhat.com>

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 <tasleson@redhat.com>
---
 nvmet/__init__.py | 3 ++-
 nvmetcli          | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

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)
-- 
2.25.1


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2020-03-26 18:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 18:07 [PATCH v2 0/7] Misc. corrections Tony Asleson
2020-03-26 18:07 ` [PATCH v2 1/7] README: Update URL for configshell-fb Tony Asleson
2020-03-26 18:07 ` [PATCH v2 2/7] nvmetcli: Improve IOError handling on restore Tony Asleson
2020-03-26 18:07 ` [PATCH v2 3/7] nvme.py: Explicit close is redundant Tony Asleson
2020-03-26 18:07 ` [PATCH v2 4/7] nvme.py: Sync the containing directory Tony Asleson
2020-03-26 18:07 ` [PATCH v2 5/7] nvme.py: Make modprobe work for kmod lib too Tony Asleson
2020-03-26 18:07 ` [PATCH v2 6/7] test_nvmet.py: test_invalid_input fails for py3 Tony Asleson
2020-03-26 18:07 ` Tony Asleson [this message]
2020-04-01  9:03 ` [PATCH v2 0/7] Misc. corrections Christoph Hellwig

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=20200326180750.469346-8-tasleson@redhat.com \
    --to=tasleson@redhat.com \
    --cc=linux-nvme@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.