From: stevenvanrossem Date: Thu, 12 May 2016 12:34:12 +0000 (+0200) Subject: minor cleanup, add stop_flow X-Git-Tag: v3.1~124^2~6 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=81955a5f09513f1bba581af38584adbb4bff1eaf;p=osm%2Fvim-emu.git minor cleanup, add stop_flow --- diff --git a/src/emuvim/api/zerorpc/network.py b/src/emuvim/api/zerorpc/network.py index 37b34f9..5fccf4e 100755 --- a/src/emuvim/api/zerorpc/network.py +++ b/src/emuvim/api/zerorpc/network.py @@ -134,6 +134,16 @@ class DCNetworkApi(object): 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") diff --git a/src/emuvim/cli/monitor.py b/src/emuvim/cli/monitor.py index 123abe5..1f2cc36 100755 --- a/src/emuvim/cli/monitor.py +++ b/src/emuvim/cli/monitor.py @@ -56,6 +56,16 @@ class ZeroRpcClient(object): args.get("cookie")) pp.pprint(r) + def stop_flow(self, args): + vnf_name = self._parse_vnf_name(args.get("vnf_name")) + vnf_interface = self._parse_vnf_interface(args.get("vnf_name")) + r = self.c.stop_flow( + vnf_name, + vnf_interface, + args.get("metric"), + args.get("cookie")) + pp.pprint(r) + def prometheus(self, args): vnf_name = self._parse_vnf_name(args.get("vnf_name")) vnf_interface = self._parse_vnf_interface(args.get("vnf_name")) @@ -82,7 +92,8 @@ class ZeroRpcClient(object): parser = argparse.ArgumentParser(description='son-emu monitor') parser.add_argument( "command", - help="Action to be executed") + choices=['setup_metric', 'stop_metric', 'setup_flow', 'stop_flow','prometheus'], + help="setup/stop a metric/flow to be monitored") parser.add_argument( "--vnf_name", "-vnf", dest="vnf_name", help="vnf name:interface to be monitored") diff --git a/src/emuvim/dcemulator/net.py b/src/emuvim/dcemulator/net.py index f5bab44..c29c786 100755 --- a/src/emuvim/dcemulator/net.py +++ b/src/emuvim/dcemulator/net.py @@ -236,15 +236,17 @@ class DCNetwork(Containernet): 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):