[PATCH 1/3] nvmetcli: add 'merge' parameter to set_config()
Hannes Reinecke
hare at suse.de
Fri Feb 12 10:52:27 EST 2021
Add a parameter 'merge' to set_config() to allow for merge a given
configuration with the existing one.
Signed-off-by: Hannes Reinecke <hare at suse.de>
---
nvmet/nvme.py | 8 +++++---
nvmetcli | 4 ++--
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/nvmet/nvme.py b/nvmet/nvme.py
index 83fd75b..22aef5a 100644
--- a/nvmet/nvme.py
+++ b/nvmet/nvme.py
@@ -331,17 +331,19 @@ class Root(CFSNode):
for h in self.hosts:
h.delete()
- def restore(self, config, clear_existing=False, abort_on_error=False):
+ def restore(self, config, clear_existing=False, abort_on_error=False, merge=False):
'''
Takes a dict generated by dump() and reconfigures the target to match.
Returns list of non-fatal errors that were encountered.
Will refuse to restore over an existing configuration unless
- clear_existing is True.
+ clear_existing or merge is True. If clear_existing is True the
+ existing configuration will be cleared. If merge is True the
+ given configuration will be attempted to be merged.
'''
if clear_existing:
self.clear_existing()
else:
- if any(self.subsystems):
+ if any(self.subsystems) and not merge:
raise CFSError("subsystems present, not restoring")
errors = []
diff --git a/nvmetcli b/nvmetcli
index 8ee8590..f2b59bb 100755
--- a/nvmetcli
+++ b/nvmetcli
@@ -104,11 +104,11 @@ class UIRootNode(UINode):
UIPortsNode(self)
UIHostsNode(self)
- def ui_command_restoreconfig(self, savefile=None, clear_existing=False):
+ def ui_command_restoreconfig(self, savefile=None, clear_existing=False, merge=False):
'''
Restores configuration from a file.
'''
- errors = self.cfnode.restore_from_file(savefile, clear_existing)
+ errors = self.cfnode.restore_from_file(savefile, clear_existing, merge)
self.refresh()
if errors:
--
2.29.2
More information about the Linux-nvme
mailing list