From 0993258ca2003475afc1ee8872f7c95f08d5b24e Mon Sep 17 00:00:00 2001 From: Seblu <sebastien.luttringer@smartjog.com> Date: Wed, 2 Mar 2011 16:53:31 +0100 Subject: [PATCH] Add command jobs --- cccli/command/__init__.py | 1 + cccli/command/jobs.py | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 cccli/command/jobs.py diff --git a/cccli/command/__init__.py b/cccli/command/__init__.py index 7b76b8d..1a62dc8 100644 --- a/cccli/command/__init__.py +++ b/cccli/command/__init__.py @@ -16,6 +16,7 @@ from cccli.command.vm import * # by command module from cccli.command.execute import Command_execute from cccli.command.expert import Command_expert +from cccli.command.jobs import Command_jobs from cccli.command.kill import Command_kill from cccli.command.list import Command_list from cccli.command.server import Command_server diff --git a/cccli/command/jobs.py b/cccli/command/jobs.py new file mode 100644 index 0000000..9162d18 --- /dev/null +++ b/cccli/command/jobs.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +#coding=utf8 + +''' +CloudControl jobs command +''' + +from cccli.exception import * +from sjrpc.core.exceptions import * +from cccli.printer import Printer, color +from cccli.command.command import TqlCommand + +class Command_jobs(TqlCommand): + '''List jobs''' + + def __init__(self, cli, argv0): + TqlCommand.__init__(self, cli, argv0) + self.set_usage("%prog [options] [tql]") + self.remove_option("--quiet") + self.remove_option("--direct") + self.add_option("-d", "--done", action="store_true", dest="done", default=False, + help="Show done jobs") + self.add_option("-R", "--no-running", action="store_false", dest="running", default=True, + help="Don't show running jobs") + + def __call__(self, argv): + # Parse argline + self.parse_args(argv) + # append current login if nothing asked + if len(self.args) == 0: + tql = "" + else: + tql = "".join(self.args) + # ask server + objs = self.rpccall("jobs", tql, + _direct=True, + _status=False, + show_done=self.options.done, + show_running=self.options.running) + self.print_objects(objs, index=self.options.index) -- GitLab