update monitor REST API according to D3.2
[osm/vim-emu.git] / src / emuvim / dcemulator / net.py
index 3b4dd54..8f627b5 100755 (executable)
@@ -342,6 +342,17 @@ class DCNetwork(Containernet):
 
     def _addMonitorFlow(self, vnf_src_name, vnf_dst_name, vnf_src_interface=None, vnf_dst_interface=None,
                        tag=None, **kwargs):
+        """
+        Add a monitoring flow entry that adds a special flowentry/counter at the begin or end of a chain.
+        So this monitoring flowrule exists on top of a previously defined chain rule and uses the same vlan tag/routing.
+        :param vnf_src_name:
+        :param vnf_dst_name:
+        :param vnf_src_interface:
+        :param vnf_dst_interface:
+        :param tag: vlan tag to be used for this chain (same tag as existing chain)
+        :param monitor_placement: 'tx' or 'rx' indicating to place the extra flowentry resp. at the beginning or end of the chain
+        :return:
+        """
 
         src_sw = None
         src_sw_inport_nr = 0
@@ -446,7 +457,7 @@ class DCNetwork(Containernet):
                 kwargs['switch_outport_name'] = dst_sw_outport_name
                 kwargs['skip_vlan_tag'] = True
 
-                monitor_placement = kwargs.get('monitor_placement')
+                monitor_placement = kwargs.get('monitor_placement').strip()
                 # put monitor flow at the dst switch
                 insert_flow = False
                 if monitor_placement == 'tx' and path.index(current_hop) == 0:  # first node:
@@ -454,7 +465,7 @@ class DCNetwork(Containernet):
                 # put monitoring flow at the src switch
                 elif monitor_placement == 'rx' and path.index(current_hop) == len(path) - 1:  # last node:
                     insert_flow = True
-                else:
+                elif monitor_placement not in ['rx', 'tx']:
                     LOG.exception('invalid monitor command: {0}'.format(monitor_placement))
 
 
@@ -489,6 +500,8 @@ class DCNetwork(Containernet):
         :param cookie: cookie for the installed flowrules (can be used later as identifier for a set of installed chains)
         :param match: custom match entry to be added to the flowrules (default: only in_port and vlan tag)
         :param priority: custom flowrule priority
+        :param monitor: boolean to indicate whether this chain is a monitoring chain
+        :param tag: vlan tag to be used for this chain (pre-defined or new one if none is specified)
         :return: output log string
         """
 
@@ -511,7 +524,7 @@ class DCNetwork(Containernet):
                 return ret
             else:
                 # no chain existing (or E-LAN) -> install normal chain
-                LOG.warning('*** installing monitoring chain without pre-defined chain from {0}:{1} -> {2}:{3}'.
+                LOG.warning('*** installing monitoring chain without pre-defined NSD chain from {0}:{1} -> {2}:{3}'.
                             format(vnf_src_name, vnf_src_interface, vnf_dst_name, vnf_dst_interface))
                 pass