aboutsummaryrefslogtreecommitdiffstats
path: root/vswitches/ovs.py
diff options
context:
space:
mode:
authorChristian Trautman <ctrautma@redhat.com>2016-07-08 01:41:39 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-07-08 01:41:39 +0000
commit7a16aa0bc7875b5b3fe6385cf99afa076e1e1cb3 (patch)
treef997b7e84de4fa34ed5e261b568044fcf988e097 /vswitches/ovs.py
parentcead9a3d0571b8afc5ed680475e9bc3ea92c7d79 (diff)
parent45956037d0233bad1a9fc01cb390fcc8e9e30005 (diff)
Merge "rstp-stp: Add basic functions for stp/rstp enable on ovs"
Diffstat (limited to 'vswitches/ovs.py')
-rw-r--r--vswitches/ovs.py76
1 files changed, 73 insertions, 3 deletions
diff --git a/vswitches/ovs.py b/vswitches/ovs.py
index 555d7dec..115ab19b 100644
--- a/vswitches/ovs.py
+++ b/vswitches/ovs.py
@@ -16,18 +16,20 @@
"""
import logging
-import re
import os
-import time
import pexpect
+import re
+import time
+
from conf import settings
-from vswitches.vswitch import IVSwitch
from src.ovs import OFBridge, flow_key, flow_match
from tools import tasks
+from vswitches.vswitch import IVSwitch
_OVS_VAR_DIR = settings.getValue('OVS_VAR_DIR')
_OVS_ETC_DIR = settings.getValue('OVS_ETC_DIR')
+
class IVSwitchOvs(IVSwitch, tasks.Process):
"""Open vSwitch base class implementation
@@ -193,6 +195,50 @@ class IVSwitchOvs(IVSwitch, tasks.Process):
cnt = 0
return cnt
+ def disable_stp(self, switch_name):
+ """
+ Disable stp protocol on the bridge
+ :param switch_name: bridge to disable stp
+ :return: None
+ """
+ bridge = self._bridges[switch_name]
+ bridge.set_stp(False)
+ self._logger.info('Sleeping for 50 secs to allow stp to stop.')
+ time.sleep(50) # needs time to disable
+
+ def enable_stp(self, switch_name):
+ """
+ Enable stp protocol on the bridge
+ :param switch_name: bridge to enable stp
+ :return: None
+ """
+ bridge = self._bridges[switch_name]
+ bridge.set_stp(True)
+ self._logger.info('Sleeping for 50 secs to allow stp to start.')
+ time.sleep(50) # needs time to enable
+
+ def disable_rstp(self, switch_name):
+ """
+ Disable rstp on the bridge
+ :param switch_name: bridge to disable rstp
+ :return: None
+ """
+ bridge = self._bridges[switch_name]
+ bridge.set_rstp(False)
+ self._logger.info('Sleeping for 15 secs to allow rstp to stop.')
+ time.sleep(15) # needs time to disable
+
+ def enable_rstp(self, switch_name):
+ """
+ Enable rstp on the bridge
+ :param switch_name: bridge to enable rstp
+ :return: None
+ """
+ bridge = self._bridges[switch_name]
+ bridge.set_rstp(True)
+ self._logger.info('Sleeping for 15 secs to allow rstp to start.')
+ time.sleep(15) # needs time to enable
+
def kill(self, signal='-15', sleep=10):
"""Kill ``ovs-vswitchd`` and ``ovs-ovsdb`` instances if they are alive.
@@ -354,3 +400,27 @@ class IVSwitchOvs(IVSwitch, tasks.Process):
""" Validate call of flow dump
"""
return True
+
+ def validate_disable_rstp(self, result, switch_name):
+ """ Validate rstp disable
+ """
+ bridge = self._bridges[switch_name]
+ return 'rstp_enable : false' in ''.join(bridge.bridge_info())
+
+ def validate_enable_rstp(self, result, switch_name):
+ """ Validate rstp enable
+ """
+ bridge = self._bridges[switch_name]
+ return 'rstp_enable : true' in ''.join(bridge.bridge_info())
+
+ def validate_disable_stp(self, result, switch_name):
+ """ Validate stp disable
+ """
+ bridge = self._bridges[switch_name]
+ return 'stp_enable : false' in ''.join(bridge.bridge_info())
+
+ def validate_enable_stp(self, result, switch_name):
+ """ Validate stp enable
+ """
+ bridge = self._bridges[switch_name]
+ return 'stp_enable : true' in ''.join(bridge.bridge_info())