Loading cloudcontrol/cli/commands/allocate.py 0 → 100644 +56 −0 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 server command """ import json from cloudcontrol.cli.exception import cmdBadArgument from cloudcontrol.cli.printer import color from cloudcontrol.cli.command import RemoteCommand class Command_allocate(RemoteCommand): """VM allocation command""" def __init__(self, cli, argv0): RemoteCommand.__init__(self, cli, argv0) self.set_usage("%prog [options] <path to vmspec>") self.add_option("-t", dest="target", default="id", help="target on which to spawn VMs") def __call__(self, argv): self.parse_args(argv) if len(self.args) != 1: raise cmdBadArgument() # Load vmspec try: vmspec = json.load(open(self.args[0])) except IOError as err: self.printer.error("Unable to load vmspec: %s" % err.args[1]) else: job_id = self.rpc.call("allocate", vmspec, self.options.target) self.printer.out("\n%sA job doing this allocation has been started.%s" % (color["light"], color["reset"])) self.printer.out("%sWatch it%s: watch list id:%s$duration$state$status$title" % (color["light"], color["reset"], job_id)) self.printer.out("%sGet logs:%s attachment id:%s logs" % (color["light"], color["reset"], job_id)) self.printer.out("%sGet results:%s attachment id:%s results\n" % (color["light"], color["reset"], job_id)) def remote_functions(self): return set(("allocate",)) Loading
cloudcontrol/cli/commands/allocate.py 0 → 100644 +56 −0 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 server command """ import json from cloudcontrol.cli.exception import cmdBadArgument from cloudcontrol.cli.printer import color from cloudcontrol.cli.command import RemoteCommand class Command_allocate(RemoteCommand): """VM allocation command""" def __init__(self, cli, argv0): RemoteCommand.__init__(self, cli, argv0) self.set_usage("%prog [options] <path to vmspec>") self.add_option("-t", dest="target", default="id", help="target on which to spawn VMs") def __call__(self, argv): self.parse_args(argv) if len(self.args) != 1: raise cmdBadArgument() # Load vmspec try: vmspec = json.load(open(self.args[0])) except IOError as err: self.printer.error("Unable to load vmspec: %s" % err.args[1]) else: job_id = self.rpc.call("allocate", vmspec, self.options.target) self.printer.out("\n%sA job doing this allocation has been started.%s" % (color["light"], color["reset"])) self.printer.out("%sWatch it%s: watch list id:%s$duration$state$status$title" % (color["light"], color["reset"], job_id)) self.printer.out("%sGet logs:%s attachment id:%s logs" % (color["light"], color["reset"], job_id)) self.printer.out("%sGet results:%s attachment id:%s results\n" % (color["light"], color["reset"], job_id)) def remote_functions(self): return set(("allocate",))