OVS_LIB API addition - change bridge controller connection-mode
Add an API to change controller connection mode to 'out-of-band', feature which might be useful for many projects using Openflow controller with OVS Change-Id: If93f6858f4eed05f5f1d9bdb1667838d80c490cd Closes-Bug: #1433208
This commit is contained in:
parent
8791f8e86d
commit
9e7f484adc
|
@ -22,6 +22,7 @@ from oslo_log import log as logging
|
|||
from oslo_utils import excutils
|
||||
import retrying
|
||||
import six
|
||||
import uuid
|
||||
|
||||
from neutron.agent.common import utils
|
||||
from neutron.agent.linux import ip_lib
|
||||
|
@ -428,6 +429,20 @@ class OVSBridge(BaseOVS):
|
|||
msg = _('Unable to determine mac address for %s') % self.br_name
|
||||
raise Exception(msg)
|
||||
|
||||
def set_controllers_connection_mode(self, connection_mode):
|
||||
"""Set bridge controllers connection mode.
|
||||
|
||||
:param connection_mode: "out-of-band" or "in-band"
|
||||
"""
|
||||
attr = [('connection_mode', connection_mode)]
|
||||
controllers = self.db_get_val('Bridge', self.br_name, 'controller')
|
||||
controllers = [controllers] if isinstance(
|
||||
controllers, uuid.UUID) else controllers
|
||||
with self.ovsdb.transaction(check_error=True) as txn:
|
||||
for controller_uuid in controllers:
|
||||
txn.add(self.ovsdb.db_set('Controller',
|
||||
controller_uuid, *attr))
|
||||
|
||||
def __enter__(self):
|
||||
self.create()
|
||||
return self
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
import collections
|
||||
import uuid
|
||||
|
||||
from neutron.agent.common import ovs_lib
|
||||
from neutron.agent.linux import ip_lib
|
||||
|
@ -229,6 +230,33 @@ class OVSBridgeTestCase(OVSBridgeTestBase):
|
|||
self.br.reset_bridge(secure_mode=True)
|
||||
self._assert_br_fail_mode(ovs_lib.FAILMODE_SECURE)
|
||||
|
||||
def test_set_controller_connection_mode(self):
|
||||
controllers = ['tcp:192.0.2.0:6633']
|
||||
self._set_controllers_connection_mode(controllers)
|
||||
|
||||
def test_set_multi_controllers_connection_mode(self):
|
||||
controllers = ['tcp:192.0.2.0:6633', 'tcp:192.0.2.1:55']
|
||||
self._set_controllers_connection_mode(controllers)
|
||||
|
||||
def _set_controllers_connection_mode(self, controllers):
|
||||
self.br.set_controller(controllers)
|
||||
self.assertEqual(controllers, self.br.get_controller())
|
||||
self.br.set_controllers_connection_mode('out-of-band')
|
||||
self._assert_controllers_connection_mode('out-of-band')
|
||||
self.br.del_controller()
|
||||
self.assertEqual([], self.br.get_controller())
|
||||
|
||||
def _assert_controllers_connection_mode(self, connection_mode):
|
||||
controllers = self.br.db_get_val('Bridge', self.br.br_name,
|
||||
'controller')
|
||||
controllers = [controllers] if isinstance(
|
||||
controllers, uuid.UUID) else controllers
|
||||
for controller in controllers:
|
||||
self.assertEqual(connection_mode,
|
||||
self.br.db_get_val('Controller',
|
||||
controller,
|
||||
'connection_mode'))
|
||||
|
||||
|
||||
class OVSLibTestCase(base.BaseOVSLinuxTestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue