summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Klozik <martinx.klozik@intel.com>2015-12-11 14:29:18 +0000
committerMaryam Tahhan <maryam.tahhan@intel.com>2016-01-21 09:40:34 +0000
commit7caf7a6be0fae6b341181b3e6286372e2e93b4b8 (patch)
tree2a8284cc39b85eb095a0c5a4763fd2e558d166c2 /src
parent2a3ff071bd08ff02610286a5ad4ba46690b6bc6b (diff)
testcase: scalability - configurable installation of flows to the vswitch
Stream specific flows can be pre-installed into the vswitch based on the value of testcase specific configuration option "Pre-installed Flows". In case, it is set to 'Yes', then specific flow for each stream will be inserted into the switch. Otherwise only generic flows will be installed. Default value of "Pre-installed Flows" is set to 'No'. Its value can be overridden by CLI parameter pre-installed_flows. This configuration parameter is an enhancement of "MultiSream" feature and it is ignored if "MultiStream" is disabled. Python module 'netaddr' is required by this implementation and it has been added to requirements.txt file. Change-Id: I8a17577a702bf2be2753134eb203b936a87fc2e5 JIRA: VSPERF-83 Signed-off-by: Martin Klozik <martinx.klozik@intel.com> Reviewed-by: Maryam Tahhan <maryam.tahhan@intel.com> Reviewed-by: Brian Castelli <brian.castelli@spirent.com>
Diffstat (limited to 'src')
-rw-r--r--src/ovs/ofctl.py34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/ovs/ofctl.py b/src/ovs/ofctl.py
index c052f85c..9d16ef76 100644
--- a/src/ovs/ofctl.py
+++ b/src/ovs/ofctl.py
@@ -34,6 +34,8 @@ _OVS_OFCTL_BIN = os.path.join(settings.getValue('OVS_DIR'), 'utilities',
_OVS_BRIDGE_NAME = settings.getValue('VSWITCH_BRIDGE_NAME')
+_CACHE_FILE_NAME = '/tmp/vsperf_flows_cache'
+
class OFBase(object):
"""Add/remove/show datapaths using ``ovs-ofctl``.
"""
@@ -103,6 +105,7 @@ class OFBridge(OFBase):
super(OFBridge, self).__init__(timeout)
self.br_name = br_name
self._ports = {}
+ self._cache_file = None
# context manager
@@ -121,7 +124,7 @@ class OFBridge(OFBase):
# helpers
- def run_ofctl(self, args, check_error=False):
+ def run_ofctl(self, args, check_error=False, timeout=None):
"""Run ``ovs-ofctl`` with supplied arguments.
:param args: Arguments to pass to ``ovs-ofctl``
@@ -129,8 +132,9 @@ class OFBridge(OFBase):
:return: None
"""
+ tmp_timeout = self.timeout if timeout == None else timeout
cmd = ['sudo', _OVS_OFCTL_BIN, '-O', 'OpenFlow13', '--timeout',
- str(self.timeout)] + args
+ str(tmp_timeout)] + args
return tasks.run_task(
cmd, self.logger, 'Running ovs-ofctl...', check_error)
@@ -233,7 +237,7 @@ class OFBridge(OFBase):
# flow mangement
- def add_flow(self, flow):
+ def add_flow(self, flow, cache='off'):
"""Add flow to bridge.
:param flow: Flow description as a dictionary
@@ -241,14 +245,32 @@ class OFBridge(OFBase):
:return: None
"""
+ # insert flows from cache into OVS if needed
+ if cache == 'flush':
+ if self._cache_file == None:
+ self.logger.error('flow cache flush called, but nothing is cached')
+ return
+ self.logger.debug('flows cached in %s will be added to the bridge', _CACHE_FILE_NAME)
+ self._cache_file.close()
+ self._cache_file = None
+ self.run_ofctl(['add-flows', self.br_name, _CACHE_FILE_NAME], timeout=600)
+ return
+
if not flow.get('actions'):
self.logger.error('add flow requires actions')
return
- self.logger.debug('add flow')
_flow_key = flow_key(flow)
self.logger.debug('key : %s', _flow_key)
- self.run_ofctl(['add-flow', self.br_name, _flow_key])
+
+ # insert flow to the cache or OVS
+ if cache == 'on':
+ # create and open cache file if needed
+ if self._cache_file == None:
+ self._cache_file = open(_CACHE_FILE_NAME, 'w')
+ self._cache_file.write(_flow_key + '\n')
+ else:
+ self.run_ofctl(['add-flow', self.br_name, _flow_key])
def del_flow(self, flow):
"""Delete flow from bridge.
@@ -274,7 +296,7 @@ class OFBridge(OFBase):
"""Dump all flows from bridge.
"""
self.logger.debug('dump flows')
- self.run_ofctl(['dump-flows', self.br_name])
+ self.run_ofctl(['dump-flows', self.br_name], timeout=120)
#
# helper functions