"cloudcontrol/node/jobs.py" did not exist on "f4553ddc307d77cc90f2572c3c46d652c0116b61"
Newer
Older
#!/usr/bin/env python
#coding=utf8
'''
CloudControl right releated commands
'''
from cccli.exception import *
from sjrpc.core.exceptions import *
from cccli.printer import Printer, color
from cccli.command.command import Command, TqlCommand
class Command_rights(TqlCommand):
TqlCommand.__init__(self, cli, argv0)
self.set_usage("%prog [options] [tql]")
self.add_option("--raw", action="store_true", dest="raw",
help="Don't append filter on request")
self.remove_option("-s")
self.parse_args(argv)
if len(self.args) == 0:
tql = "".join(self.args)
if not self.options.raw:
al = self.rpccall("rights", tql)
# display answer
for (a, rl) in al.items():
self.printer.out("%srights of %s%s"%(color["lblue"], a, color["reset"]))
for i,r in enumerate(rl):
tags = " ".join([ "%s%s:%s%s"%(color["green"], t, color["reset"], v) for (t,v) in r.items() ])
self.printer.out("[%s] %s"%(i,tags))
class Command_addright(TqlCommand):
def __init__(self, cli, argv0):
TqlCommand.__init__(self, cli, argv0)
self.set_usage('''%prog [options] <account tql> <right tql> <method> <target> [index]
<method> is the name of the rpc command to allow
<target> can be allow or deny''')
# argv check
self.parse_args(argv)
if len(self.args) == 4:
self.args.append(None)
elif len(self.args) == 5:
self.args[5] = int(self.args[5])
# rpc call
self.rpccall("addright",
self.args[0],
self.args[1],
self.args[2],
self.args[3],
self.args[4])
class Command_delright(TqlCommand):
'''Delete account right'''
def __init__(self, cli, argv0):
TqlCommand.__init__(self, cli, argv0)
self.set_usage('''%prog [options] <tql> <index>
<index> * means all''')
# argv check
self.parse_args(argv)
if len(self.args) != 2:
# building list of index
l = self.args[1:]
# if all is detected
self.rpccall("delright", self.args[0], None)
self.rpccall("delright", self.args[0], index)