diff --git a/cccli/command/vm.py b/cccli/command/vm.py index 8aa7f097e8a03df4f6fc119d56acc9f8843385d9..b53de5c0a1868bd23a95473f37a629679ce345b5 100644 --- a/cccli/command/vm.py +++ b/cccli/command/vm.py @@ -6,13 +6,13 @@ CloudControl VM related commands from cccli.exception import * from sjrpc.core.exceptions import * from cccli.printer import Printer, color -from cccli.command.command import OptionCommand +from cccli.command.command import TqlCommand -class VmCommand(OptionCommand): +class VmCommand(TqlCommand): '''Command for vm style''' def __init__(self, cli, argv0): - OptionCommand.__init__(self, cli, argv0) + TqlCommand.__init__(self, cli, argv0) self.set_usage("%prog [options] <tql>") self.add_option("--raw", action="store_true", dest="raw", help="Don't append filter on request") @@ -22,16 +22,17 @@ class VmCommand(OptionCommand): help="Don't ask confirmation (Dangerous)") def _vm_action(self, argv, filters=None): - self.parse_args() - if len(args) == 0: + # parse args + self.parse_args(argv) + if len(self.args) == 0: raise cmdBadArgument() - tql = str.join("", args) + tql = str.join("", self.args) # append securty options by command name if filters is not None and not self.options.raw: tql += filters if self.options.direct: try: - objs = self.cli.rpc.call(argv[0], tql) + objs = self.cli.rpc.call(self.args[0], tql) except RpcError as e: raise cmdError("RPCError: %s"%str(e)) else: @@ -43,7 +44,7 @@ class VmCommand(OptionCommand): # no result, goodbye if len(objs) == 0: raise cmdWarning("tql: '%s': No result."%tql) - self.printer.out("You will %s:"%argv[0]) + self.printer.out("You will %s:"%self.args[0]) for obj in objs: self.printer.out("%sid:%s%s%s"%(color["green"],color["yellow"],obj["id"],color["reset"])) self.printer.out("%sCount: %s%s"%(color["green"],color["reset"], len(objs))) diff --git a/cccli/printer.py b/cccli/printer.py index bc0a4aab4c3de996cbc924b715456380ad0b96f7..ef36e6857089c5011243061d416e7c62926b687c 100644 --- a/cccli/printer.py +++ b/cccli/printer.py @@ -147,7 +147,7 @@ class Printer(object): h = list(self.history) self.history.clear() try: - r = self.getline(prompt, history=False) + r = self.getline(prompt) finally: self.history.load(h) return r