Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
#coding=utf8
'''
CloudControl Connection related commands
'''
from cccli.exception import *
from sjrpc.core.exceptions import *
from cccli.printer import Printer, color
from cccli.command.command import Command
class Command_uptime(Command):
'''Show connection uptime'''
def __call__(self, argv):
if len(argv) == 1:
argv.append("a=%s"%self.cli.settings["login"])
tql = "".join(argv[1:]) + "$con"
try:
objs = self.cli.rpc.call("list", tql)
except RpcError as e:
raise cmdError("RPCError: %s"%str(e))
for o in objs:
if "a" in o and "con" in o:
self.printer.out("%s: %ss"%(o["a"], o["con"]))
def usage(self):
return "usage: uptime [tql]"
class Command_remote(Command):
'''Show remote command list'''
def __call__(self, argv):
try:
for cmds in self.cli.rpc.call("list_commands"):
self.printer.out("%s"%cmds["name"])
except RpcError as e:
raise cmdError("RPCError: %s"%str(e))
def usage(self):
return "usage: remote"
class Command_whoami(Command):
'''Show connection login'''
def __call__(self, argv):
self.printer.out(self.cli.settings["login"])
def usage(self):
return "usage: whoami"
class Command_kill(Command):
'''Kill a server connection'''
def __call__(self, argv):
if len(argv) != 2:
raise cmdBadArgument()
try:
self.cli.rpc.call("kill", argv[1])
except RpcError as e:
raise cmdError("RPCError: %s"%str(e))
def usage(self):
return "usage: kill <tql>"