OVS_LIB support API for setting fail mode 'standalone'

The current API only support setting a bridge fail mode
to secure, this patch allow the user to set it to 'standalone'
as well

Change-Id: If7e6532dc7f8527c35834a37144ea4386fe1b861
Closes-Bug: #1458924
This commit is contained in:
Gal Sagie 2015-05-26 19:16:34 +03:00
parent 2f8373aff6
commit 7ea278087c
3 changed files with 14 additions and 1 deletions

View File

@ -40,6 +40,7 @@ UNASSIGNED_OFPORT = []
# OVS bridge fail modes
FAILMODE_SECURE = 'secure'
FAILMODE_STANDALONE = 'standalone'
OPTS = [
cfg.IntOpt('ovs_vsctl_timeout',
@ -160,6 +161,10 @@ class OVSBridge(BaseOVS):
self.ovsdb.set_fail_mode(self.br_name, FAILMODE_SECURE).execute(
check_error=True)
def set_standalone_mode(self):
self.ovsdb.set_fail_mode(self.br_name, FAILMODE_STANDALONE).execute(
check_error=True)
def set_protocols(self, protocols):
self.set_db_attribute('Bridge', self.br_name, 'protocols', protocols,
check_error=True)

View File

@ -118,10 +118,14 @@ class OVSBridgeTestCase(OVSBridgeTestBase):
self.br.db_get_val('Controller', self.br.br_name,
'connection_mode'))
def test_set_fail_mode(self):
def test_set_fail_mode_secure(self):
self.br.set_secure_mode()
self._assert_br_fail_mode(ovs_lib.FAILMODE_SECURE)
def test_set_fail_mode_standalone(self):
self.br.set_standalone_mode()
self._assert_br_fail_mode(ovs_lib.FAILMODE_STANDALONE)
def _assert_br_fail_mode(self, fail_mode):
self.assertEqual(
self.br.db_get_val('Bridge', self.br.br_name, 'fail_mode'),

View File

@ -130,6 +130,10 @@ class OVS_Lib_Test(base.BaseTestCase):
self.br.set_secure_mode()
self._verify_vsctl_mock('set-fail-mode', self.BR_NAME, 'secure')
def test_set_standalone_mode(self):
self.br.set_standalone_mode()
self._verify_vsctl_mock('set-fail-mode', self.BR_NAME, 'standalone')
def test_set_protocols(self):
protocols = 'OpenFlow13'
self.br.set_protocols(protocols)