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( "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) 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()
def main(): """ Start SPDK CLI :return: """ spdk_shell = ConfigShell("~/.scripts") spdk_shell.interactive = True add_quotes_to_shell(spdk_shell) parser = argparse.ArgumentParser(description="SPDK command line interface") parser.add_argument('-s', dest='server_addr', help='RPC domain socket path or IP address', default='/var/tmp/spdk.sock') parser.add_argument('-p', dest='port', help='RPC port number (if server_addr is IP address)', default=None, type=int) 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() try: client = rpc.client.JSONRPCClient(args.server_addr, port=args.port) except JSONRPCException as e: spdk_shell.log.error("%s. SPDK not running?" % e) sys.exit(1) with client: root_node = UIRoot(client, spdk_shell) root_node.verbose = args.verbose try: root_node.refresh() except BaseException: pass if len(args.commands) > 0: try: spdk_shell.interactive = False spdk_shell.run_cmdline(" ".join(args.commands)) except Exception as e: sys.stderr.write("%s\n" % e) sys.exit(1) sys.exit(0) spdk_shell.con.display("SPDK CLI v0.1") spdk_shell.con.display("") while not spdk_shell._exit: try: spdk_shell.run_interactive() except (JSONRPCException, ExecutionError) as e: spdk_shell.log.error("%s" % e) except BrokenPipeError as e: spdk_shell.log.error("Lost connection with SPDK: %s" % e) break
def main(): """ Start SPDK CLI :return: """ spdk_shell = ConfigShell("~/.scripts") spdk_shell.interactive = True add_quotes_to_shell(spdk_shell) 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() with rpc.client.JSONRPCClient(args.socket) as client: root_node = UIRoot(client, spdk_shell) root_node.verbose = args.verbose try: root_node.refresh() except BaseException: pass if len(args.commands) > 0: try: spdk_shell.interactive = False spdk_shell.run_cmdline(" ".join(args.commands)) except Exception as e: sys.stderr.write("%s\n" % e) sys.exit(1) sys.exit(0) spdk_shell.con.display("SPDK CLI v0.1") spdk_shell.con.display("") while not spdk_shell._exit: try: spdk_shell.run_interactive() except (JSONRPCException, ExecutionError) as e: spdk_shell.log.error("%s" % e)
def main(): """ Start SPDK CLI :return: """ spdk_shell = ConfigShell("~/.scripts") add_quotes_to_shell(spdk_shell) 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, spdk_shell) root_node.verbose = args.verbose try: root_node.refresh() except BaseException: pass if len(args.commands) > 0: spdk_shell.run_cmdline(" ".join(args.commands)) sys.exit(0) spdk_shell.con.display("SPDK CLI v0.1") spdk_shell.con.display("") spdk_shell.run_interactive()