3 (c) 2016 by Manuel Peuster <manuel.peuster@upb.de>
8 from tabulate
import tabulate
13 pp
= pprint
.PrettyPrinter(indent
=4)
15 class ZeroRpcClient(object):
18 self
.c
= zerorpc
.Client()
19 # TODO connect to DCNetwork API
20 #self.c.connect("tcp://127.0.0.1:4242") # TODO hard coded for now. we'll change this later
21 self
.c
.connect("tcp://127.0.0.1:5151")
24 def execute_command(self
, args
):
25 if getattr(self
, args
["command"]) is not None:
26 # call the local method with the same name as the command arg
27 getattr(self
, args
["command"])(args
)
29 print "Command not implemented."
31 def setup_metric(self
, args
):
32 vnf_name
= self
._parse
_vnf
_name
(args
.get("vnf_name"))
33 vnf_interface
= self
._parse
_vnf
_interface
(args
.get("vnf_name"))
34 r
= self
.c
.setup_metric(
40 self.c.monitor_setup_rate_measurement(
45 r = self.c.monitor_get_rate(
53 def _parse_vnf_name(self
, vnf_name_str
):
54 vnf_name
= vnf_name_str
.split(':')[0]
57 def _parse_vnf_interface(self
, vnf_name_str
):
59 vnf_interface
= vnf_name_str
.split(':')[1]
65 parser
= argparse
.ArgumentParser(description
='son-emu network')
68 help="Action to be executed: get_rate")
70 "--vnf_name", "-vnf", dest
="vnf_name",
71 help="vnf name to be monitored")
73 "--metric", "-m", dest
="metric",
74 help="tx_bytes, rx_bytes, tx_packets, rx_packets")
77 #print "This is the son-emu monitor CLI."
78 #print "Arguments: %s" % str(argv)
79 args
= vars(parser
.parse_args(argv
))
81 c
.execute_command(args
)