b75b0435601ba07ef6b74fbf998eeda2657b25d8
10 pp
= pprint
.PrettyPrinter(indent
=4)
13 class ZeroRpcClient(object):
16 self
.c
= zerorpc
.Client()
17 self
.c
.connect("tcp://127.0.0.1:4242") # yes, hard coded for now. we'll change this later
20 def execute_command(self
, args
):
21 if getattr(self
, args
["command"]) is not None:
22 # call the local method with the same name as the command arg
23 getattr(self
, args
["command"])(args
)
25 print "Command not implemented."
27 def start(self
, args
):
28 r
= self
.c
.compute_action_start(
29 args
.get("datacenter"), args
.get("name"))
33 r
= self
.c
.compute_action_stop(
34 args
.get("datacenter"), args
.get("name"))
38 print "TODO: Not implemented"
40 def status(self
, args
):
41 print "TODO: Not implemented"
44 parser
= argparse
.ArgumentParser(description
='son-emu compute')
45 parser
.add_argument("command", help="Action to be executed.")
47 "--datacenter", "-d", dest
="datacenter", help="Data center.")
49 "--name", "-n", dest
="name", help="Compute name.")
50 # TODO: IP, image, etc. pp.
54 args
= vars(parser
.parse_args(argv
))
56 c
.execute_command(args
)