Browse Source

Make gateway update work without device info

_validate_gateway_for_update expects now the gw dict to have device
dict. The update thus fails in case of updateing the name only for
example.
This patch makes this kind of easy updates working.

Change-Id: I4368e1fdbe3e539c988f82fd90d4c30b426ac1d2
Closes-Bug: #1834331
changes/20/667620/5
elajkat 7 months ago
parent
commit
d57ae1ad77
2 changed files with 12 additions and 1 deletions
  1. +3
    -1
      networking_l2gw/services/l2gateway/service_drivers/rpc_l2gw.py
  2. +9
    -0
      networking_l2gw/tests/unit/services/l2gateway/service_drivers/test_rpc_l2gw.py

+ 3
- 1
networking_l2gw/services/l2gateway/service_drivers/rpc_l2gw.py View File

@@ -350,7 +350,9 @@ class L2gwRpcDriver(service_drivers.L2gwDriver):
def _validate_gateway_for_update(self, context, gw):
LOG.debug("L2gwRpcDriver._validate_gateway_for_update gw=%s",
gw)
devices = gw.get('l2_gateway').get('devices')
# Note(lajoskatona): If the update is updating other keys than
# devices, just return, as the tricky part is updating devices.
devices = gw['l2_gateway'].get('devices', [])

for device in devices:
interfaces = device.get('interfaces')

+ 9
- 0
networking_l2gw/tests/unit/services/l2gateway/service_drivers/test_rpc_l2gw.py View File

@@ -1390,6 +1390,15 @@ class TestL2gwRpcDriver(test_plugin.Ml2PluginV2TestCase):
self.plugin._validate_gateway_for_update,
self.db_context, fake_l2gw_dict)

def test_validate_gateway_for_update_without_device(self):
self.db_context = ctx.get_admin_context()
fake_l2gw_dict = {"l2_gateway": {"name": "fake_name"}}
with mock.patch.object(db,
'get_physical_switch_by_name',
return_value=None):
self.plugin._validate_gateway_for_update(self.db_context,
fake_l2gw_dict)

def test_update_l2_gateway(self):
self.db_context = ctx.get_admin_context()
fake_l2gw_dict = {'id': 'fake_l2gw_id',

Loading…
Cancel
Save