Browse Source

Removed built-in transaction support

The below statement has some issues due to which router interface
was not added for the first time.

with context.session.begin(subtransactions=True):

The above statement is removed and transaction is handled like we do
it in ML2 plugin code. We call super.remove_router_interface in case
of an exception

Also added negative unit test cases and enabled L3 tests in
test_discover module

Renamed the following modules:
l3_router_fi_ni_plugin.py to l3_router_plugin.py
test_brocade_l3_router_fi_ni_plugin.py to test_l3_router_plugin.py

Change-Id: Id0de71c758c3c271cc54ed00a5014e7e2fc6609d
Closes-Bug: #1439095
tags/kilo-eol
Pradeep Sathasivam 4 years ago
parent
commit
20aea72cfc

networking_brocade/mlx/services/l3_router/brocade/l3_router_fi_ni_plugin.py → networking_brocade/mlx/services/l3_router/brocade/l3_router_plugin.py View File

@@ -19,16 +19,16 @@
19 19
 
20 20
 from neutron.i18n import _LE
21 21
 from neutron.i18n import _LI
22
-from neutron.plugins.ml2.drivers.brocade.db import models as brocade_db
22
+from neutron.plugins.ml2.driver_context import NetworkContext
23 23
 from neutron.services.l3_router import l3_router_plugin as router
24 24
 from oslo_log import log as logging
25 25
 from oslo_utils import importutils
26 26
 
27 27
 LOG = logging.getLogger(__name__)
28
-NI = "neutron.plugins.ml2.drivers.brocade.fi_ni.ni_driver.NetIronDriver"
29
-BROCADE_CONFIG = ("neutron.plugins.ml2.drivers.brocade.fi_ni.brcd_config."
28
+NI = "networking_brocade.mlx.ml2.fi_ni.ni_driver.NetIronDriver"
29
+BROCADE_CONFIG = ("networking_brocade.mlx.ml2.fi_ni.brcd_config."
30 30
                   "ML2BrocadeConfig")
31
-DRIVER_FACTORY = ("neutron.plugins.ml2.drivers.brocade.fi_ni."
31
+DRIVER_FACTORY = ("networking_brocade.mlx.ml2.fi_ni."
32 32
                   "driver_factory.BrocadeDriverFactory")
33 33
 # Property to identify which device type to use
34 34
 # Currently supports only NI devices. If FI devices needs to be
@@ -37,7 +37,7 @@ DRIVER_FACTORY = ("neutron.plugins.ml2.drivers.brocade.fi_ni."
37 37
 ROUTER_DEVICE_TYPE = ['NI']
38 38
 
39 39
 
40
-class BrocadeFiNiL3RouterPlugin(router.L3RouterPlugin):
40
+class BrocadeRouterPlugin(router.L3RouterPlugin):
41 41
 
42 42
     """
43 43
     SVI Mechanism driver for Brocade ICX and MLX devices. This will take care
@@ -49,9 +49,10 @@ class BrocadeFiNiL3RouterPlugin(router.L3RouterPlugin):
49 49
 
50 50
         Specify switch address and db configuration.
51 51
         """
52
+        self._devices = {}
53
+        self._physical_networks = {}
52 54
         self._driver_map = {}
53
-        self._router_devices_map = {}
54
-        super(BrocadeFiNiL3RouterPlugin, self).__init__()
55
+        super(BrocadeRouterPlugin, self).__init__()
55 56
         self.brocade_init()
56 57
 
57 58
     def brocade_init(self):
@@ -59,18 +60,17 @@ class BrocadeFiNiL3RouterPlugin(router.L3RouterPlugin):
59 60
         and stores all the device information in a dictionary. Then it filters
60 61
         the router devices from it.
61 62
         """
62
-        LOG.debug("BrocadeFiNiL3RouterPlugin::brocade_init()")
63
+        LOG.debug("BrocadeRouterPlugin::brocade_init()")
63 64
 
64 65
         self._devices, self._physical_networks = importutils.import_object(
65
-            BROCADE_CONFIG).create_ml2_brocade_dictionary()
66
-        self._filter_router_devices(self._devices)
66
+            BROCADE_CONFIG).create_brocade_dictionary(isL2=False)
67 67
 
68 68
     def add_router_interface(self, context, router_id, interface_info):
69 69
         """Adds router interface to a vlan on NI device and assigns ip
70 70
          address to configure l3 router interface.
71 71
         """
72 72
 
73
-        self.add_remove_router_interface(context, router_id,
73
+        return self.add_remove_router_interface(context, router_id,
74 74
                                          interface_info,
75 75
                                          True)
76 76
 
@@ -100,79 +100,77 @@ class BrocadeFiNiL3RouterPlugin(router.L3RouterPlugin):
100 100
         else:
101 101
             method = "remove_router_interface"
102 102
             operation = "Remove"
103
-
104
-        with context.session.begin(subtransactions=True):
105
-            info = getattr(super(BrocadeFiNiL3RouterPlugin, self),
106
-                           method)(context, router_id, interface_info)
107
-            interface_info = info
108
-            subnet = self._core_plugin._get_subnet(context,
109
-                                                   interface_info["subnet_id"])
110
-            vlan_id, gateway_ip_cidr = self._get_network_info(context, subnet)
111
-            for device in self._router_devices_map:
112
-                device_info = self._router_devices_map.get(device)
113
-                driver = self._driver_map.get(device)
114
-                address = device_info.get('address')
115
-                LOG.info(_LI("BrocadeFiNiL3RouterPlugin:Before %(op)s l3 "
116
-                             "router to vlan %(vlan_id)s with ip %(gatewayip)s"
117
-                             "on device "
118
-                             "%(host)s"), {'op': operation,
119
-                                           'vlan_id': vlan_id,
120
-                                           'gatewayip': gateway_ip_cidr,
121
-                                           'host': address})
122
-                try:
123
-                    if is_add is True:
124
-                        getattr(driver, method)(vlan_id, gateway_ip_cidr)
125
-                    else:
126
-                        getattr(driver, method)(vlan_id)
127
-                except Exception as e:
128
-                    LOG.exception(_LE("BrocadeFiNiL3RouterPlugin: failed to"
129
-                                      " %(op)s l3 router interface for "
130
-                                      "device= %(device)s exception : "
131
-                                      "%(error)s"), {'op': operation,
132
-                                                     'device': address,
133
-                                                     'error': e.args})
134
-                    raise Exception(
135
-                        _("BrocadeFiNiL3RouterPlugin: %(op)s router "
136
-                          "interface failed"), {'op': operation})
137
-                LOG.info(_LI("BrocadeFiNiL3RouterPlugin:%(op)sed router "
138
-                             "interface in vlan = %(vlan_id)s with ip address"
139
-                             " %(gatewayip)s on device %(host)s "
140
-                             "successful"), {'op': operation,
141
-                                             'vlan_id': vlan_id,
142
-                                             'gatewayip': gateway_ip_cidr,
143
-                                             'host': address})
144
-        return True
145
-
146
-    def _filter_router_devices(self, devices):
103
+        info = getattr(super(BrocadeRouterPlugin, self),
104
+                       method)(context, router_id, interface_info)
105
+        interface_info = info
106
+        subnet = self._core_plugin._get_subnet(context.elevated(),
107
+                                               interface_info["subnet_id"])
108
+        vlan_id, gateway_ip_cidr = self._get_network_info(context, subnet)
109
+        for device in self._devices:
110
+            device_info = self._devices.get(device)
111
+            address = device_info.get('address')
112
+            driver = self._get_driver(device)
113
+            LOG.info(_LI("BrocadeRouterPlugin:Before %(op)s l3 "
114
+                         "router to vlan %(vlan_id)s with ip %(gatewayip)s"
115
+                         "on device "
116
+                         "%(host)s"), {'op': operation,
117
+                                       'vlan_id': vlan_id,
118
+                                       'gatewayip': gateway_ip_cidr,
119
+                                       'host': address})
120
+            try:
121
+                if is_add is True:
122
+                    getattr(driver, method)(vlan_id, gateway_ip_cidr)
123
+                else:
124
+                    getattr(driver, method)(vlan_id)
125
+            except Exception as e:
126
+                if is_add:
127
+                    method = "remove_router_interface"
128
+                    info = getattr(super(BrocadeRouterPlugin, self),
129
+                                   method)(context, router_id, interface_info)
130
+                LOG.exception(_LE("BrocadeRouterPlugin: failed to"
131
+                                  " %(op)s l3 router interface for "
132
+                                  "device= %(device)s exception : "
133
+                                  "%(error)s"), {'op': operation,
134
+                                                 'device': address,
135
+                                                 'error': e.args})
136
+                raise Exception(
137
+                    _("BrocadeRouterPlugin: %(op)s router "
138
+                      "interface failed"), {'op': operation})
139
+            LOG.info(_LI("BrocadeRouterPlugin:%(op)sed router "
140
+                         "interface in vlan = %(vlan_id)s with ip address"
141
+                         " %(gatewayip)s on device %(host)s "
142
+                         "successful"), {'op': operation,
143
+                                         'vlan_id': vlan_id,
144
+                                         'gatewayip': gateway_ip_cidr,
145
+                                         'host': address})
146
+        return info
147
+
148
+    def _get_driver(self, device):
147 149
         """
148
-        Filters devices using the firmware types in the ROUTER_DEVICE_TYPE from
149
-        devices. It stores the filtered devices in another dictionary
150
-        _router_devices_map. This method also identifies the driver for the
151
-        filtered devices and stores them in the map _driver_map with device
152
-        name as key and the driver as value.
153
-
154
-        :param:devices: Contains device name as key and device information
155
-            in a map with key-value pairs as value.
150
+        Gets the driver based on the firmware version of the device.
151
+
152
+        :param:device: Contains device name
156 153
         :raises: Exception
157 154
         """
158
-        driver_factory = importutils.import_object(DRIVER_FACTORY)
159
-        for device in devices:
160
-            device_info = devices.get(device)
155
+        driver = self._driver_map.get(device)
156
+        if driver is None:
157
+            driver_factory = importutils.import_object(DRIVER_FACTORY)
158
+            device_info = self._devices.get(device)
161 159
             address = device_info.get('address')
160
+            os_type = device_info.get('ostype')
162 161
             try:
163 162
                 driver = driver_factory.get_driver(device_info)
164
-                os_type = device_info.get('ostype')
165 163
                 if driver is not None and os_type in ROUTER_DEVICE_TYPE:
166
-                    self._router_devices_map.update({device: device_info})
167 164
                     self._driver_map.update({device: driver})
168 165
             except Exception as e:
169
-                LOG.exception(_LE("BrocadeFiNiL3RouterPlugin:"
166
+                LOG.exception(_LE("BrocadeRouterPlugin:"
170 167
                                   "_filter_router_devices: Error while getting"
171 168
                                   " driver : device - %(host)s: %(error)s"),
172 169
                               {'host': address, 'error': e.args})
173
-                raise Exception(_("BrocadeFiNiL3RouterPlugin:"
170
+                raise Exception(_("BrocadeRouterPlugin:"
174 171
                                   "_filter_router_devices failed for "
175 172
                                   "device %(host)s"), {'host': address})
173
+        return driver
176 174
 
177 175
     def _get_network_info(self, context, subnet):
178 176
         """
@@ -188,8 +186,8 @@ class BrocadeFiNiL3RouterPlugin(router.L3RouterPlugin):
188 186
         net_addr, net_len = self.net_addr(cidr)
189 187
         gateway_ip = subnet["gateway_ip"]
190 188
         network_id = subnet['network_id']
191
-        bnet = brocade_db.get_network(context, network_id)
192
-        vlan_id = bnet['vlan']
189
+        ml2_db = NetworkContext(self, context, {'id': network_id})
190
+        vlan_id = ml2_db.network_segments[0]['segmentation_id']
193 191
         gateway_ip_cidr = gateway_ip + '/' + str(net_len)
194 192
 
195 193
         return vlan_id, gateway_ip_cidr

networking_brocade/mlx/tests/unit/services/l3_router/brocade/test_brocade_l3_router_fi_ni_plugin.py → networking_brocade/mlx/tests/unit/services/l3_router/brocade/test_l3_router_plugin.py View File

@@ -16,7 +16,7 @@
16 16
 
17 17
 import mock
18 18
 from networking_brocade.mlx.services.l3_router.brocade import (
19
-    l3_router_fi_ni_plugin as brocadel3routerfiniplugin)
19
+    l3_router_plugin as brocadel3routerplugin)
20 20
 from neutron import context
21 21
 from neutron.db import l3_db
22 22
 from neutron.i18n import _LE
@@ -26,9 +26,12 @@ from oslo_utils import importutils
26 26
 
27 27
 
28 28
 MECHANISM_NAME = ('networking_brocade.mlx.services.l3_router.brocade.'
29
-                  'l3_router_fi_ni_plugin.BrocadeFiNiL3RouterPlugin')
29
+                  'l3_router_plugin.BrocadeRouterPlugin')
30 30
 VE = 've '
31 31
 config_map = {}
32
+vlan_map = {}
33
+interface_map = {}
34
+
32 35
 device_map = {
33 36
     'mlx': {
34 37
         'address': '2.2.2.2',
@@ -52,6 +55,10 @@ delete_config_map = {
52 55
     }
53 56
 }
54 57
 
58
+interface_info = {
59
+    'subnet_id': 'subnet1',
60
+    'port_id': 'port1'}
61
+
55 62
 vlan_id = '402'
56 63
 gateway_ip_cidr = '12.0.0.1/24'
57 64
 ROUTER = 'router1'
@@ -62,8 +69,7 @@ INVALID_INPUT = "Invalid input"
62 69
 RANGE_ERROR = "outside of allowed max"
63 70
 
64 71
 
65
-class TestBrocadeL3RouterFiNiPlugin(base.BaseTestCase,
66
-                                    router.L3RouterPlugin):
72
+class TestBrocadeL3RouterPlugin(base.BaseTestCase, router.L3RouterPlugin):
67 73
 
68 74
     """
69 75
     Test Brocade L3 Router FI/NI plugin.
@@ -73,131 +79,126 @@ class TestBrocadeL3RouterFiNiPlugin(base.BaseTestCase,
73 79
         _mechanism_name = MECHANISM_NAME
74 80
 
75 81
         def mocked_initialize(self):
76
-            self._router_devices_map = device_map
77
-            self._driver_map = {'mlx': FakeDriver(device_map.get('mlx'))}
82
+            self._devices = device_map
78 83
 
79
-        with mock.patch.object(brocadel3routerfiniplugin
80
-                               .BrocadeFiNiL3RouterPlugin,
84
+        with mock.patch.object(brocadel3routerplugin
85
+                               .BrocadeRouterPlugin,
81 86
                                'brocade_init', new=mocked_initialize):
82
-            super(TestBrocadeL3RouterFiNiPlugin, self).setUp()
83
-            self.interface_info = {'subnet_id': SUBNET,
84
-                                   'port_id': PORT}
87
+            super(TestBrocadeL3RouterPlugin, self).setUp()
85 88
             self.driver = importutils.import_object(_mechanism_name)
86 89
 
87
-    @mock.patch.object(
88
-        brocadel3routerfiniplugin.BrocadeFiNiL3RouterPlugin,
89
-        '_get_network_info')
90
+    @mock.patch.object(brocadel3routerplugin.BrocadeRouterPlugin,
91
+                       '_get_driver')
92
+    @mock.patch.object(brocadel3routerplugin.BrocadeRouterPlugin,
93
+                       '_get_network_info')
90 94
     @mock.patch.object(l3_db.L3_NAT_dbonly_mixin, '_core_plugin')
91
-    @mock.patch.object(router.L3RouterPlugin,
92
-                       'add_router_interface')
95
+    @mock.patch.object(router.L3RouterPlugin, 'add_router_interface')
93 96
     def test_add_router_interface(
94
-            self, mock_super, mock_core_plugin, mock_network_info):
97
+        self, mock_super, mock_core_plugin, mock_network_info,
98
+            mock_driver):
95 99
 
96
-        mech_ctx = _get_network_context('physnet1', 'vlan')
100
+        mock_driver.side_effect = self.side_effect
101
+        mech_ctx = self._get_network_context('physnet1', 'vlan')
97 102
         ctx = mech_ctx._plugin_context
98 103
         ctx.session.begin = mock.MagicMock()
99
-        mock_super.returnValue = self.interface_info
104
+        mock_super.returnValue = interface_info
100 105
         mock_core_plugin.side_effect = mock.MagicMock()
101
-        mock_network_info.side_effect = side_effect_network_info
106
+        mock_network_info.side_effect = self.side_effect_network_info
102 107
         self.driver.add_router_interface(ctx, ROUTER,
103
-                                         self.interface_info)
104
-        global config_map
108
+                                         interface_info)
105 109
         self.assertDictSupersetOf(config_map, add_config_map)
106 110
 
107
-    @mock.patch.object(
108
-        brocadel3routerfiniplugin.BrocadeFiNiL3RouterPlugin,
109
-        '_get_network_info')
110
-    @mock.patch.object(l3_db.L3_NAT_dbonly_mixin, '_core_plugin')
111 111
     @mock.patch.object(router.L3RouterPlugin, 'remove_router_interface')
112
-    def test_remove_router_interface(
113
-            self, mock_super, mock_core_plugin, mock_network_info):
114
-        mech_ctx = _get_network_context('physnet1', 'vlan')
115
-        ctx = mech_ctx._plugin_context
116
-        ctx.session.begin = mock.MagicMock()
117
-        mock_super.returnValue = self.interface_info
118
-        mock_core_plugin.side_effect = mock.MagicMock()
119
-        mock_network_info.side_effect = side_effect_network_info
120
-        self.driver.remove_router_interface(ctx, ROUTER,
121
-                                            self.interface_info)
122
-        global config_map
123
-        self.assertDictSupersetOf(config_map, delete_config_map)
124
-
125
-
126
-class TestBrocadeL3RouterFiNiPluginException(base.BaseTestCase,
127
-                                             router.L3RouterPlugin):
128
-
129
-    """
130
-    Test Brocade L3 Router FI/NI plugin for negative scenario
131
-    """
132
-
133
-    def setUp(self):
134
-        _mechanism_name = MECHANISM_NAME
135
-
136
-        def mocked_initialize(self):
137
-            self._router_devices_map = device_map
138
-            self._driver_map = {
139
-                'mlx': FakeDriver(
140
-                    device_map.get('mlx'),
141
-                    error=True)}
142
-
143
-        with mock.patch.object(brocadel3routerfiniplugin
144
-                               .BrocadeFiNiL3RouterPlugin,
145
-                               'brocade_init', new=mocked_initialize):
146
-            super(TestBrocadeL3RouterFiNiPluginException, self).setUp()
147
-            self.interface_info = {'subnet_id': SUBNET,
148
-                                   'port_id': PORT}
149
-            self.driver = importutils.import_object(_mechanism_name)
150
-
151
-    @mock.patch.object(
152
-        brocadel3routerfiniplugin.BrocadeFiNiL3RouterPlugin,
153
-        '_get_network_info')
112
+    @mock.patch.object(brocadel3routerplugin.BrocadeRouterPlugin,
113
+                       '_get_driver')
114
+    @mock.patch.object(brocadel3routerplugin.BrocadeRouterPlugin,
115
+                       '_get_network_info')
154 116
     @mock.patch.object(l3_db.L3_NAT_dbonly_mixin, '_core_plugin')
155 117
     @mock.patch.object(router.L3RouterPlugin, 'add_router_interface')
156 118
     def test_add_router_interface_exception(
157
-            self, mock_super, mock_core_plugin, mock_network_info):
119
+        self, mock_super, mock_core_plugin, mock_network_info,
120
+            mock_driver, mock_super_remove):
158 121
 
159
-        mech_ctx = _get_network_context('physnet1', 'vlan')
122
+        mock_driver.side_effect = self.side_effect_error
123
+        mech_ctx = self._get_network_context('physnet1', 'vlan')
160 124
         ctx = mech_ctx._plugin_context
161 125
         ctx.session.begin = mock.MagicMock()
162
-        mock_super.returnValue = self.interface_info
126
+        mock_super.returnValue = interface_info
163 127
         mock_core_plugin.side_effect = mock.MagicMock()
164
-        mock_network_info.side_effect = side_effect_network_info
128
+        mock_network_info.side_effect = self.side_effect_network_info
129
+        mock_super_remove.returnValue = interface_info
165 130
         self.assertRaisesRegexp(
166
-            Exception, (_LE("BrocadeFiNiL3RouterPlugin")),
131
+            Exception, (_LE("BrocadeRouterPlugin")),
167 132
             self.driver.add_router_interface,
168
-            ctx, ROUTER, self.interface_info)
169
-
170
-
171
-def _get_network_context(physnet, network_type):
172
-    """
173
-    Create mock network context
174
-    """
175
-    network = {
176
-        'id': 1,
177
-        'name': 'private',
178
-        'tenant_id': 1,
179
-        'vlan': 200,
180
-        'network_type': network_type,
181
-        'provider:segmentation_id': 200
182
-    }
183
-
184
-    network_segments = [{
185
-        'id': 1,
186
-        'segmentation_id': 200,
187
-        'network_type': network_type,
188
-        'physical_network': physnet
189
-    }]
190
-
191
-    _plugin_context = context.get_admin_context()
192
-    return FakeNetworkContext(network, network_segments, _plugin_context)
133
+            ctx, ROUTER, interface_info)
193 134
 
135
+    @mock.patch.object(brocadel3routerplugin.BrocadeRouterPlugin,
136
+                       '_get_driver')
137
+    @mock.patch.object(brocadel3routerplugin.BrocadeRouterPlugin,
138
+                       '_get_network_info')
139
+    @mock.patch.object(l3_db.L3_NAT_dbonly_mixin, '_core_plugin')
140
+    @mock.patch.object(router.L3RouterPlugin, 'remove_router_interface')
141
+    def test_remove_router_interface(
142
+        self, mock_super, mock_core_plugin, mock_network_info,
143
+            mock_driver):
194 144
 
195
-def side_effect_network_info(vlan, ip):
196
-    """
197
-    Mock _get_driver method and return FakeDriver
198
-    """
145
+        mock_driver.side_effect = self.side_effect
146
+        mech_ctx = self._get_network_context('physnet1', 'vlan')
147
+        ctx = mech_ctx._plugin_context
148
+        ctx.session.begin = mock.MagicMock()
149
+        mock_super.returnValue = interface_info
150
+        mock_core_plugin.side_effect = mock.MagicMock()
151
+        mock_network_info.side_effect = self.side_effect_network_info
152
+        ve_map = {'ve 402': '12.0.0.1/24'}
153
+        vlan_map.update({'402': ve_map})
154
+        config_map.update({'2.2.2.2': vlan_map})
155
+        self.driver.remove_router_interface(ctx, ROUTER,
156
+                                            interface_info)
157
+        self.assertDictSupersetOf(config_map, delete_config_map)
199 158
 
200
-    return vlan_id, gateway_ip_cidr
159
+    def side_effect(self, dev_name):
160
+        """
161
+        Mock _get_driver method and return FakeDriver
162
+        """
163
+        device = device_map.get(dev_name)
164
+        return FakeDriver(device)
165
+
166
+    def side_effect_error(self, dev_name):
167
+        """
168
+        Mock _get_driver method and return FakeDriver
169
+        """
170
+        device = device_map.get(dev_name)
171
+        return FakeDriver(device, error=True)
172
+
173
+    def _get_network_context(self, physnet, network_type):
174
+        """
175
+        Create mock network context
176
+        """
177
+        network = {
178
+            'id': 1,
179
+            'name': 'private',
180
+            'tenant_id': 1,
181
+            'vlan': 200,
182
+            'network_type': network_type,
183
+            'provider:segmentation_id': 200
184
+        }
185
+
186
+        network_segments = [{
187
+            'id': 1,
188
+            'segmentation_id': 200,
189
+            'network_type': network_type,
190
+            'physical_network': physnet
191
+        }]
192
+
193
+        _plugin_context = context.get_admin_context()
194
+        return FakeNetworkContext(network, network_segments, _plugin_context)
195
+
196
+    def side_effect_network_info(self, vlan, ip):
197
+        """
198
+        Mock _get_driver method and return FakeDriver
199
+        """
200
+
201
+        return vlan_id, gateway_ip_cidr
201 202
 
202 203
 
203 204
 class FakeNetworkContext(object):
@@ -247,19 +248,13 @@ class FakeDriver(object):
247 248
                             "ve out of range error")
248 249
         elif self.error:
249 250
             raise Exception("Add Router Interface failed")
250
-        vlan_map = {}
251
-        interface_map = {}
251
+
252 252
         interface_map.update({VE + vlan_id: gateway_ip_cidr})
253 253
         vlan_map.update({vlan_id: interface_map})
254
-        global config_map
255 254
         config_map.update({self.address: vlan_map})
256 255
 
257 256
     def remove_router_interface(self, vlan_id):
258
-        vlan_map = delete_config_map.pop(self.address, None)
259
-        interface_map = vlan_map.pop(vlan_id, None)
260
-        if vlan_map is None:
261
-            raise Exception("No Address")
262
-        elif interface_map is None:
263
-            raise Exception("No Router Interface")
257
+        if vlan_id in config_map[self.address]:
258
+            config_map[self.address].update({vlan_id: {}})
264 259
         else:
265
-            interface_map.pop(VE + vlan_id, None)
260
+            raise Exception("vlan is not there")

+ 2
- 1
networking_brocade/test_discover/test_discover.py View File

@@ -29,7 +29,8 @@ def load_tests(loader, tests, pattern):
29 29
     base_path = os.path.split(base_path)[0]
30 30
     test_dirs = {'./networking_brocade/tests',
31 31
                  './networking_brocade/vdx/tests/unit/ml2/drivers/brocade',
32
-                 MLX_TEST_BASE_PATH + '/unit/ml2/drivers/brocade'
32
+                 MLX_TEST_BASE_PATH + '/unit/ml2/drivers/brocade',
33
+                 MLX_TEST_BASE_PATH + '/unit/services/l3_router/brocade'
33 34
                  }
34 35
     for test_dir in test_dirs:
35 36
         if not pattern:

Loading…
Cancel
Save