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>
Signed-off-by: Christoph Hellwig <hch@lst.de>
-from .nvme import Root, Subsystem, Namespace, Port, Host, Referral, ANAGroup
+from .nvme import Root, Subsystem, Namespace, Port, Host, Referral, ANAGroup,\
+ DEFAULT_SAVE_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)