]> www.infradead.org Git - users/hch/nvmetcli.git/commitdiff
nvmetcli: expose ls to dump UI configuration
authorSagi Grimberg <sagi@grimberg.me>
Sun, 3 Dec 2017 08:25:34 +0000 (10:25 +0200)
committerChristoph Hellwig <hch@lst.de>
Mon, 4 Dec 2017 20:12:57 +0000 (12:12 -0800)
for running: nvmetcli ls

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Documentation/nvmetcli.txt
nvmetcli

index 1f381cc7ad2e5f794b631f2f57d93240b2ae3454..05a0344dfd912cf9b719aa7a4d48f944fcbadd20 100644 (file)
@@ -105,6 +105,7 @@ and not enter the interactive configuration shell.
                             Without specifying the filename this will use
                             */etc/nvmet/config.json*.
 | clear                   | Clears a current NVMe Target configuration.
+| ls                      | Dumps the current NVMe Target configuration.
 |==================
 
 EXAMPLES
index 4fbc12ec430f465710bcf965340d7b24f5a02a24..0c590c9638f1ca699cf541137637fa8768ccc807 100755 (executable)
--- a/nvmetcli
+++ b/nvmetcli
@@ -549,6 +549,7 @@ def usage():
     print("syntax: %s save [file_to_save_to]" % sys.argv[0])
     print("        %s restore [file_to_restore_from]" % sys.argv[0])
     print("        %s clear" % sys.argv[0])
+    print("        %s ls" % sys.argv[0])
     sys.exit(-1)
 
 
@@ -572,7 +573,14 @@ def clear(unused):
     nvme.Root().clear_existing()
 
 
-funcs = dict(save=save, restore=restore, clear=clear)
+def ls(unused):
+    shell = configshell.shell.ConfigShell('~/.nvmetcli')
+    UIRootNode(shell)
+    shell.run_cmdline("ls")
+    sys.exit(0)
+
+
+funcs = dict(save=save, restore=restore, clear=clear, ls=ls)
 
 
 def main():