[PATCH 16/37] Add savefile, clear_existing option to save/restore commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Default save file to /etc/target/saveconfig.json.

Signed-off-by: Andy Grover <agrover@xxxxxxxxxx>
---
 targetcli/ui_root.py |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/targetcli/ui_root.py b/targetcli/ui_root.py
index 3b76b04..4ef836a 100644
--- a/targetcli/ui_root.py
+++ b/targetcli/ui_root.py
@@ -25,6 +25,8 @@ from ui_target import UIFabricModule
 from tcm_dump import tcm_full_backup
 from ui_backstore import UIBackstores
 
+default_save_file = "/etc/target/saveconfig.json"
+
 class UIRoot(UINode):
     '''
     The targetcli hierarchy root node.
@@ -70,24 +72,24 @@ class UIRoot(UINode):
                 self.shell.log.debug("Loading %s." % fabric_module.name)
                 UIFabricModule(fabric_module, self)
 
-    def ui_command_save(self):
+    def ui_command_save(self, savefile=default_save_file):
         from rtslib.root import RTSRoot
         import json
 
         self.assert_root()
 
-        with open("/savecfg.json", "w+") as f:
+        with open(savefile, "w+") as f:
             f.write(json.dumps(RTSRoot().dump(), sort_keys=True, indent=2))
             f.write("\n")
 
-    def ui_command_restore(self):
+    def ui_command_restore(self, savefile=default_save_file, clear_existing=False):
         from rtslib.root import RTSRoot
         import json
 
         self.assert_root()
 
-        with open("/savecfg.json", "r") as f:
-            RTSRoot().restore(json.loads(f.read()))
+        with open(savefile, "r") as f:
+            RTSRoot().restore(json.loads(f.read()), clear_existing)
 
         self.refresh()
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux