Newer
Older
#!/usr/bin/env python
#coding=utf8
'''
CloudControl server command
'''
from cccli.exception import *
from sjrpc.core.exceptions import *
from cccli.printer import Printer, color
from cccli.command.command import OptionCommand
class Command_server(OptionCommand):
'''Server manipulation command'''
def __init__(self, cli, argv0):
OptionCommand.__init__(self, cli, argv0)
self.set_usage("%prog <options>")
self.add_option("-c", action="store_true", dest="cache",
help="show server cache")
self.add_option("-l", action="store_true", dest="commands",
help="list server commands")
self.add_option("-v", action="store_true", dest="version",
help="show server version")
self.parse_args(argv)
if len(self.args) > 0:
elif self.options.cache:
elif self.options.commands:
elif self.options.version:
self.show_version()
else:
self.printer.out(self.usage())
def show_commands(self):
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 show_cache(self):
try:
d = self.cli.rpc.call("dbstats")
for i,v in d.items():
self.printer.out("%s: %s"%(i,v))
except RpcError as e:
raise cmdError("RPCError: %s"%str(e))