scripts/spdkcli: override configshell init
Override configshell constructor to allow command paramaters to use whitespaces and quotes. "This patch will be obsolete once https://github.com/open-iscsi/configshell-fb/issues/46 is fixed." Change-Id: Ia5f883991b031901be7dadf61cbe7ebdcf5a9cb7 Signed-off-by: Karol Latecki <karol.latecki@intel.com> Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com> Reviewed-on: https://review.gerrithub.io/426037 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
99ca58e082
commit
ad06d03a86
@ -1,9 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import argparse
|
||||
import configshell_fb
|
||||
from os import getuid
|
||||
from configshell_fb import ConfigShell
|
||||
from configshell_fb import ConfigShell, shell
|
||||
from spdkcli import UIRoot
|
||||
from pyparsing import (alphanums, Optional, Suppress, Word, Regex,
|
||||
removeQuotes, dblQuotedString, OneOrMore)
|
||||
|
||||
|
||||
def add_quotes_to_shell(spdk_shell):
|
||||
command = shell.locatedExpr(Word(alphanums + '_'))('command')
|
||||
value = dblQuotedString.addParseAction(removeQuotes)
|
||||
value_word = Word(alphanums + ';,=_\+/.<>()~@:-%[]')
|
||||
keyword = Word(alphanums + '_\-')
|
||||
kparam = shell.locatedExpr(keyword + Suppress('=') +
|
||||
Optional(value | value_word, default=''))('kparams*')
|
||||
pparam = shell.locatedExpr(value | value_word)('pparams*')
|
||||
parameters = OneOrMore(kparam | pparam)
|
||||
bookmark = Regex('@([A-Za-z0-9:_.]|-)+')
|
||||
pathstd = Regex('([A-Za-z0-9:_.\[\]]|-)*' + '/' + '([A-Za-z0-9:_.\[\]/]|-)*') \
|
||||
| '..' | '.'
|
||||
path = shell.locatedExpr(bookmark | pathstd | '*')('path')
|
||||
spdk_shell._parser = Optional(path) + Optional(command) + Optional(parameters)
|
||||
|
||||
|
||||
def main():
|
||||
@ -11,7 +30,8 @@ def main():
|
||||
Start SPDK CLI
|
||||
:return:
|
||||
"""
|
||||
shell = ConfigShell("~/.scripts")
|
||||
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")
|
||||
@ -21,7 +41,7 @@ def main():
|
||||
help="commands to execute by SPDKCli as one-line command")
|
||||
args = parser.parse_args()
|
||||
|
||||
root_node = UIRoot(args.socket, shell)
|
||||
root_node = UIRoot(args.socket, spdk_shell)
|
||||
root_node.verbose = args.verbose
|
||||
try:
|
||||
root_node.refresh()
|
||||
@ -29,12 +49,12 @@ def main():
|
||||
pass
|
||||
|
||||
if len(args.commands) > 0:
|
||||
shell.run_cmdline(" ".join(args.commands))
|
||||
spdk_shell.run_cmdline(" ".join(args.commands))
|
||||
sys.exit(0)
|
||||
|
||||
shell.con.display("SPDK CLI v0.1")
|
||||
shell.con.display("")
|
||||
shell.run_interactive()
|
||||
spdk_shell.con.display("SPDK CLI v0.1")
|
||||
spdk_shell.con.display("")
|
||||
spdk_shell.run_interactive()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user