logging.exception("RPC error.")
return ex.message
+ # remove the flow metrics measurement
+ def setup_flow(self, vnf_name, vnf_interface, metric, cookie):
+ logging.debug("RPC CALL: stop flow")
+ try:
+ c = self.net.monitor_agent.setup_flow(vnf_name, vnf_interface, metric, cookie)
+ return c
+ except Exception as ex:
+ logging.exception("RPC error.")
+ return ex.message
+
# do prometheus query
def prometheus(self, dc_label, vnf_name, vnf_interface, query):
logging.debug("RPC CALL: query prometheus")
args.get("cookie"))\r
pp.pprint(r)\r
\r
+ def stop_flow(self, args):\r
+ vnf_name = self._parse_vnf_name(args.get("vnf_name"))\r
+ vnf_interface = self._parse_vnf_interface(args.get("vnf_name"))\r
+ r = self.c.stop_flow(\r
+ vnf_name,\r
+ vnf_interface,\r
+ args.get("metric"),\r
+ args.get("cookie"))\r
+ pp.pprint(r)\r
+\r
def prometheus(self, args):\r
vnf_name = self._parse_vnf_name(args.get("vnf_name"))\r
vnf_interface = self._parse_vnf_interface(args.get("vnf_name"))\r
parser = argparse.ArgumentParser(description='son-emu monitor')\r
parser.add_argument(\r
"command",\r
- help="Action to be executed")\r
+ choices=['setup_metric', 'stop_metric', 'setup_flow', 'stop_flow','prometheus'],\r
+ help="setup/stop a metric/flow to be monitored")\r
parser.add_argument(\r
"--vnf_name", "-vnf", dest="vnf_name",\r
help="vnf name:interface to be monitored")\r
if cmd == 'add-flow':
ret = self._chainAddFlow(vnf_src_name, vnf_dst_name, vnf_src_interface, vnf_dst_interface, **kwargs)
if kwargs.get('bidirectional'):
- return ret +'\n' + self._chainAddFlow(vnf_dst_name, vnf_src_name, vnf_dst_interface, vnf_src_interface, **kwargs)
+ ret = ret +'\n' + self._chainAddFlow(vnf_dst_name, vnf_src_name, vnf_dst_interface, vnf_src_interface, **kwargs)
elif cmd == 'del-flows': # TODO: del-flow to be implemented
ret = self._chainAddFlow(vnf_src_name, vnf_dst_name, vnf_src_interface, vnf_dst_interface, **kwargs)
if kwargs.get('bidirectional'):
- return ret + '\n' + self._chainAddFlow(vnf_dst_name, vnf_src_name, vnf_dst_interface, vnf_src_interface, **kwargs)
+ ret = ret + '\n' + self._chainAddFlow(vnf_dst_name, vnf_src_name, vnf_dst_interface, vnf_src_interface, **kwargs)
else:
- return "Command unknown"
+ ret = "Command unknown"
+
+ return ret
def _chainAddFlow(self, vnf_src_name, vnf_dst_name, vnf_src_interface=None, vnf_dst_interface=None, **kwargs):