Loading cloudcontrol/cli/commands/execute.pydeleted 100644 → 0 +0 −51 Original line number Diff line number Diff line #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 <http://www.gnu.org/licenses/>. ''' 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] <tql> <command>") 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",)) cloudcontrol/cli/commands/shutdown.py→cloudcontrol/cli/commands/host.py +28 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ # along with CloudControl. If not, see <http://www.gnu.org/licenses/>. ''' CloudControl physical host related commands CloudControl host related commands ''' from cloudcontrol.cli.exception import * Loading Loading @@ -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] <tql> <command>") 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",)) Loading
cloudcontrol/cli/commands/execute.pydeleted 100644 → 0 +0 −51 Original line number Diff line number Diff line #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 <http://www.gnu.org/licenses/>. ''' 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] <tql> <command>") 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",))
cloudcontrol/cli/commands/shutdown.py→cloudcontrol/cli/commands/host.py +28 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ # along with CloudControl. If not, see <http://www.gnu.org/licenses/>. ''' CloudControl physical host related commands CloudControl host related commands ''' from cloudcontrol.cli.exception import * Loading Loading @@ -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] <tql> <command>") 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",))