Spdk/scripts/spdkcli.py
Pawel Wodkowski b96f97cf29 scripts: use python3 in all scripts
This it to prepare for RPM package. Also lower number of dependencies
needed by SPDK tools.

Update changelog to deprecate Python 2 and explicit interpeter invoking
in scripts.

Change-Id: I2497cca721cbcbadc1c99c675f8b8b7f682d5efa
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/425233
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-09-14 22:24:30 +00:00

42 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
import sys
import argparse
from os import getuid
from configshell_fb import ConfigShell
from spdkcli import UIRoot
def main():
"""
Start SPDK CLI
:return:
"""
shell = ConfigShell("~/.scripts")
parser = argparse.ArgumentParser(description="SPDK command line interface")
parser.add_argument("-s", dest="socket", help="RPC socket path", default="/var/tmp/spdk.sock")
parser.add_argument("-v", dest="verbose", help="Print request/response JSON for configuration calls",
default=False, action="store_true")
parser.add_argument("commands", metavar="command", type=str, nargs="*", default="",
help="commands to execute by SPDKCli as one-line command")
args = parser.parse_args()
root_node = UIRoot(args.socket, shell)
root_node.verbose = args.verbose
try:
root_node.refresh()
except BaseException:
pass
if len(args.commands) > 0:
shell.run_cmdline(" ".join(args.commands))
sys.exit(0)
shell.con.display("SPDK CLI v0.1")
shell.con.display("")
shell.run_interactive()
if __name__ == "__main__":
main()