Skip to content
Snippets Groups Projects
Commit 4d9bddaa authored by Seblu's avatar Seblu
Browse files

option exec and shutdown use TqlCommand

parent 2f49c3db
No related branches found
No related tags found
No related merge requests found
...@@ -6,27 +6,29 @@ CloudControl physical host related commands ...@@ -6,27 +6,29 @@ CloudControl physical host related commands
from cccli.exception import * from cccli.exception import *
from sjrpc.core.exceptions import * from sjrpc.core.exceptions import *
from cccli.printer import Printer, color from cccli.printer import Printer, color
from cccli.command.command import Command, OptionCommand from cccli.command.command import TqlCommand
class Command_exec(Command): class Command_exec(TqlCommand):
'''Execute a command on the remote host''' '''Execute a command on the remote host'''
def __init__(self, cli, argv0):
TqlCommand.__init__(self, cli, argv0)
self.set_usage("%prog [options] <tql> <command>")
def __call__(self, argv): def __call__(self, argv):
if len(argv) != 3: # arg parse
self.parse_args(argv)
if len(self.args) != 2:
raise cmdBadArgument() raise cmdBadArgument()
try: # rpc call
self.cli.rpc.call("exec", argv[1], argv[2]) self.rpccall("exec", self.args[0], self.args[1])
except RpcError as e:
raise cmdError("RPCError: %s"%str(e))
def usage(self):
return "Usage: exec <tql> <command>"
class Command_shutdown(OptionCommand): class Command_shutdown(TqlCommand):
'''Shutdown a physical host''' '''Shutdown a physical host'''
def __init__(self, cli, argv0): def __init__(self, cli, argv0):
OptionCommand.__init__(self, cli, argv0) TqlCommand.__init__(self, cli, argv0)
self.set_usage("%prog [options] <tql>") self.set_usage("%prog [options] <tql>")
self.add_option("-r", "--reboot", action="store_true", dest="reboot", self.add_option("-r", "--reboot", action="store_true", dest="reboot",
help="Reboot after shutdown (default)") help="Reboot after shutdown (default)")
...@@ -36,11 +38,9 @@ class Command_shutdown(OptionCommand): ...@@ -36,11 +38,9 @@ class Command_shutdown(OptionCommand):
help="do not go through init but go down real fast") help="do not go through init but go down real fast")
def __call__(self, argv): def __call__(self, argv):
# arg parse
self.parse_args(argv) self.parse_args(argv)
if len(self.args) != 1: if len(self.args) != 1:
raise cmdBadArgument() raise cmdBadArgument()
try: self.rpccall("shutdown", self.args[0], self.options.reboot,
self.cli.rpc.call("shutdown", self.args[0], self.options.reboot, self.options.graceful)
self.options.graceful)
except RpcError as e:
raise cmdError("RPCError: %s"%str(e))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment