Skip to content
Snippets Groups Projects
Commit 367c4e22 authored by Seblu's avatar Seblu
Browse files

add command cancel

parent 0993258c
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ from cccli.command.tag import *
from cccli.command.vm import *
# by command module
from cccli.command.cancel import Command_cancel
from cccli.command.execute import Command_execute
from cccli.command.expert import Command_expert
from cccli.command.jobs import Command_jobs
......
#!/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 OptionCommand
class Command_cancel(OptionCommand):
'''Cancel a job'''
def __init__(self, cli, argv0):
OptionCommand.__init__(self, cli, argv0)
self.set_usage("%prog [options] <job_id> ...")
def __call__(self, argv):
# Parse argline
self.parse_args(argv)
# append current login if nothing asked
if len(self.args) == 0:
raise cmdBadArgument()
# ask server
for jid in self.args:
try:
self.cli.rpc.call("cancel", int(jid))
self.printer.out("Job %s: cancelled."%jid)
except ValueError:
self.printer.error("Invalid job id: %s"%jid)
except RpcError as e:
self.printer.error("%s"%e)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment