3 (c) 2016 by Manuel Peuster <manuel.peuster@upb.de>
8 from tabulate
import tabulate
12 pp
= pprint
.PrettyPrinter(indent
=4)
14 class ZeroRpcClient(object):
17 self
.c
= zerorpc
.Client()
18 # TODO connect to DCNetwork API
19 #self.c.connect("tcp://127.0.0.1:4242") # TODO hard coded for now. we'll change this later
20 self
.c
.connect("tcp://127.0.0.1:5151")
23 def execute_command(self
, args
):
24 if getattr(self
, args
["command"]) is not None:
25 # call the local method with the same name as the command arg
26 getattr(self
, args
["command"])(args
)
28 print "Command not implemented."
30 def get_rate(self
, args
):
31 r
= self
.c
.monitor_get_rate(
33 args
.get("direction"))
37 parser
= argparse
.ArgumentParser(description
='son-emu network')
40 help="Action to be executed: get_rate")
42 "--vnf_name", "-vnf", dest
="vnf_name",
43 help="vnf name to be monitored")
45 "--direction", "-d", dest
="direction",
46 help="in (ingress rate) or out (egress rate)")
49 print "This is the son-emu monitor CLI."
50 print "Arguments: %s" % str(argv
)
51 args
= vars(parser
.parse_args(argv
))
53 c
.execute_command(args
)