Loading cccli/command/host.py +19 −7 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ CloudControl physical host related commands from cccli.exception import * from sjrpc.core.exceptions import * from cccli.printer import Printer, color from cccli.command.command import Command from cccli.command.command import Command, OptionCommand class Command_exec(Command): '''Execute a command on the remote host''' Loading @@ -21,15 +21,27 @@ class Command_exec(Command): def usage(self): return "Usage: exec <tql> <command>" class Command_shutdown(Command): class Command_shutdown(OptionCommand): '''Shutdown a physical host''' def __init__(self, cli, argv0): OptionCommand.__init__(self, cli, argv0) self.option.set_usage("%prog [options] <tql>") self.option.add_option("-r", "--reboot", action="store_true", dest="reboot", help="Reboot after shutdown (default)") self.option.add_option("-H", "--halt", action="store_false", dest="reboot", help="Halt after shutdown") self.option.add_option("-n", action="store_false", dest="graceful", default=True, help="do not go through init but go down real fast") def __call__(self, argv): if len(argv) != 2: try: (options, args) = self.option.parse_args(argv[1:]) except SystemExit: return if len(args) != 1: raise cmdBadArgument() try: self.cli.rpc.call("shutdown", argv[1]) self.cli.rpc.call("shutdown", args[0], options.reboot, options.graceful) except RpcError as e: raise cmdError("RPCError: %s"%str(e)) def usage(self): return "Usage: shutdown <tql>" Loading
cccli/command/host.py +19 −7 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ CloudControl physical host related commands from cccli.exception import * from sjrpc.core.exceptions import * from cccli.printer import Printer, color from cccli.command.command import Command from cccli.command.command import Command, OptionCommand class Command_exec(Command): '''Execute a command on the remote host''' Loading @@ -21,15 +21,27 @@ class Command_exec(Command): def usage(self): return "Usage: exec <tql> <command>" class Command_shutdown(Command): class Command_shutdown(OptionCommand): '''Shutdown a physical host''' def __init__(self, cli, argv0): OptionCommand.__init__(self, cli, argv0) self.option.set_usage("%prog [options] <tql>") self.option.add_option("-r", "--reboot", action="store_true", dest="reboot", help="Reboot after shutdown (default)") self.option.add_option("-H", "--halt", action="store_false", dest="reboot", help="Halt after shutdown") self.option.add_option("-n", action="store_false", dest="graceful", default=True, help="do not go through init but go down real fast") def __call__(self, argv): if len(argv) != 2: try: (options, args) = self.option.parse_args(argv[1:]) except SystemExit: return if len(args) != 1: raise cmdBadArgument() try: self.cli.rpc.call("shutdown", argv[1]) self.cli.rpc.call("shutdown", args[0], options.reboot, options.graceful) except RpcError as e: raise cmdError("RPCError: %s"%str(e)) def usage(self): return "Usage: shutdown <tql>"