diff --git a/cloudcontrol/cli/commands/execute.py b/cloudcontrol/cli/commands/execute.py deleted file mode 100644 index f720613851591944a75de40690e66628c6844a03..0000000000000000000000000000000000000000 --- a/cloudcontrol/cli/commands/execute.py +++ /dev/null @@ -1,51 +0,0 @@ -#coding=utf8 - -# This file is part of CloudControl. -# -# CloudControl is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# CloudControl is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with CloudControl. If not, see . - -''' -CloudControl execute command -''' - -from cloudcontrol.cli.exception import * -from sjrpc.core.exceptions import * -from cloudcontrol.cli.printer import Printer, color -from cloudcontrol.cli.command import TqlCommand - -class Command_execute(TqlCommand): - '''Execute a command on the remote host''' - - def __init__(self, cli, argv0): - TqlCommand.__init__(self, cli, argv0) - self.set_usage("%prog [options] ") - self.tql_filter += "&con&r~'host|hv'" - - def __call__(self, argv): - # arg parse - self.parse_args(argv) - if len(self.args) != 2: - raise cmdBadArgument() - # rpc call - self.rpccall("execute", self.args[0], self.args[1], _callback=self._cb_print_output) - - def _cb_print_output(self, d): - '''Print output of execute by object''' - for o in d["objects"]: - self.printer.out("%sid:%s%s%s output:"%(self.tdtc("id"), self.tdc("id"), - o["id"], color["reset"])) - self.printer.out(o.get("output", ""), nl="") - - def remote_functions(self): - return set(("execute",)) diff --git a/cloudcontrol/cli/commands/shutdown.py b/cloudcontrol/cli/commands/host.py similarity index 66% rename from cloudcontrol/cli/commands/shutdown.py rename to cloudcontrol/cli/commands/host.py index a5c18f4bf6f2f71979baafbdd7a01b22b160de5c..953f0e6d9b9813ea4c4115be9856475db6de59aa 100644 --- a/cloudcontrol/cli/commands/shutdown.py +++ b/cloudcontrol/cli/commands/host.py @@ -16,7 +16,7 @@ # along with CloudControl. If not, see . ''' -CloudControl physical host related commands +CloudControl host related commands ''' from cloudcontrol.cli.exception import * @@ -49,3 +49,30 @@ class Command_shutdown(TqlCommand): def remote_functions(self): return set(("shutdown",)) + + +class Command_execute(TqlCommand): + '''Execute a command on the remote host''' + + def __init__(self, cli, argv0): + TqlCommand.__init__(self, cli, argv0) + self.set_usage("%prog [options] ") + self.tql_filter += "&con&r~'host|hv'" + + def __call__(self, argv): + # arg parse + self.parse_args(argv) + if len(self.args) != 2: + raise cmdBadArgument() + # rpc call + self.rpccall("execute", self.args[0], self.args[1], _callback=self._cb_print_output) + + def _cb_print_output(self, d): + '''Print output of execute by object''' + for o in d["objects"]: + self.printer.out("%sid:%s%s%s output:"%(self.tdtc("id"), self.tdc("id"), + o["id"], color["reset"])) + self.printer.out(o.get("output", ""), nl="") + + def remote_functions(self): + return set(("execute",))