Loading cccli/command/__init__.py +6 −5 Original line number Diff line number Diff line Loading @@ -6,17 +6,18 @@ CloudControl CLI Commands Package ''' # bunch of command from cccli.command.shell import * from cccli.command.alias import * from cccli.command.connection import * from cccli.command.account import * from cccli.command.alias import * from cccli.command.host import * from cccli.command.right import * from cccli.command.shell import * from cccli.command.tag import * from cccli.command.host import * from cccli.command.vm import * # by command module from cccli.command.list import Command_list from cccli.command.expert import Command_expert from cccli.command.kill import Command_kill from cccli.command.list import Command_list from cccli.command.server import Command_server from cccli.command.tagdisplay import Command_tagdisplay from cccli.command.uptime import Command_uptime cccli/command/connection.pydeleted 100644 → 0 +0 −53 Original line number Diff line number Diff line #!/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_whoami(Command): '''Show connection login''' def __call__(self, argv): if len(argv) != 1: raise cmdBadArgument() self.printer.out(self.cli.settings["login"]) 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>" cccli/command/kill.py 0 → 100644 +22 −0 Original line number Diff line number Diff line #!/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 TqlCommand class Command_kill(TqlCommand): '''Kill a server connection''' def __call__(self, argv): # args parse self.parse_args(argv) if len(self.args) != 1: raise cmdBadArgument() # rpccall self.rpccall("kill", self.args[0]) cccli/command/shell.py +9 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,15 @@ class Command_version(Command): self.printer.out(cccli.version) class Command_whoami(Command): '''Show connection login''' def __call__(self, argv): if len(argv) != 1: raise cmdBadArgument() self.printer.out(self.cli.settings["login"]) class Command_history(Command): '''Show commands history''' def __call__(self, argv): Loading cccli/command/uptime.py 0 → 100644 +30 −0 Original line number Diff line number Diff line #!/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 TqlCommand class Command_uptime(TqlCommand): '''Show connection uptime''' def __init__(self, cli, argv0): TqlCommand.__init__(self, cli, argv0) self.set_usage("%prog [options] [tql]") def __call__(self, argv): # args parse self.parse_args(argv) if len(self.args) == 0: _tql = "a=%s$con"%self.cli.settings["login"] else: _tql ="".join(self.args) + "$con" objs = self.rpccall("list", _tql) for o in objs: if "a" in o and "con" in o: self.printer.out("%s: %ss"%(o["a"], o["con"])) Loading
cccli/command/__init__.py +6 −5 Original line number Diff line number Diff line Loading @@ -6,17 +6,18 @@ CloudControl CLI Commands Package ''' # bunch of command from cccli.command.shell import * from cccli.command.alias import * from cccli.command.connection import * from cccli.command.account import * from cccli.command.alias import * from cccli.command.host import * from cccli.command.right import * from cccli.command.shell import * from cccli.command.tag import * from cccli.command.host import * from cccli.command.vm import * # by command module from cccli.command.list import Command_list from cccli.command.expert import Command_expert from cccli.command.kill import Command_kill from cccli.command.list import Command_list from cccli.command.server import Command_server from cccli.command.tagdisplay import Command_tagdisplay from cccli.command.uptime import Command_uptime
cccli/command/connection.pydeleted 100644 → 0 +0 −53 Original line number Diff line number Diff line #!/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_whoami(Command): '''Show connection login''' def __call__(self, argv): if len(argv) != 1: raise cmdBadArgument() self.printer.out(self.cli.settings["login"]) 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>"
cccli/command/kill.py 0 → 100644 +22 −0 Original line number Diff line number Diff line #!/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 TqlCommand class Command_kill(TqlCommand): '''Kill a server connection''' def __call__(self, argv): # args parse self.parse_args(argv) if len(self.args) != 1: raise cmdBadArgument() # rpccall self.rpccall("kill", self.args[0])
cccli/command/shell.py +9 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,15 @@ class Command_version(Command): self.printer.out(cccli.version) class Command_whoami(Command): '''Show connection login''' def __call__(self, argv): if len(argv) != 1: raise cmdBadArgument() self.printer.out(self.cli.settings["login"]) class Command_history(Command): '''Show commands history''' def __call__(self, argv): Loading
cccli/command/uptime.py 0 → 100644 +30 −0 Original line number Diff line number Diff line #!/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 TqlCommand class Command_uptime(TqlCommand): '''Show connection uptime''' def __init__(self, cli, argv0): TqlCommand.__init__(self, cli, argv0) self.set_usage("%prog [options] [tql]") def __call__(self, argv): # args parse self.parse_args(argv) if len(self.args) == 0: _tql = "a=%s$con"%self.cli.settings["login"] else: _tql ="".join(self.args) + "$con" objs = self.rpccall("list", _tql) for o in objs: if "a" in o and "con" in o: self.printer.out("%s: %ss"%(o["a"], o["con"]))