Skip to content
Snippets Groups Projects
Commit 2672fc83 authored by Seblu's avatar Seblu
Browse files

command kill and uptime now use TqlCommand

parent 4bee8794
No related branches found
No related tags found
No related merge requests found
......@@ -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
#!/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>"
#!/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])
......@@ -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):
......
#!/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"]))
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