Avoid KeyError 'distributed' exception when using NVP <3.x
This patch fixes an issue found when creating routers with NVP plugin and NVP platform 2.2 Fixes bug 1220931 Change-Id: Ia7b358b59e48a723c07efec015bb650accaa3322
This commit is contained in:
parent
0304017da4
commit
d0ed45c033
@ -1420,8 +1420,9 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
r['id'] = lrouter['uuid']
|
r['id'] = lrouter['uuid']
|
||||||
# Update 'distributed' with value returned from NVP
|
# Update 'distributed' with value returned from NVP
|
||||||
# This will be useful for setting the value if the API request
|
# This will be useful for setting the value if the API request
|
||||||
# did not specify any value for the 'distributed' attribute
|
# did not specify any value for the 'distributed' attribute.
|
||||||
r['distributed'] = lrouter['distributed']
|
# Platforms older than 3.x do not support the attribute
|
||||||
|
r['distributed'] = lrouter.get('distributed', False)
|
||||||
except nvp_exc.NvpInvalidVersion:
|
except nvp_exc.NvpInvalidVersion:
|
||||||
msg = _("Cannot create a distributed router with the NVP "
|
msg = _("Cannot create a distributed router with the NVP "
|
||||||
"platform currently in execution. Please, try "
|
"platform currently in execution. Please, try "
|
||||||
|
@ -548,6 +548,17 @@ class TestNiciraL3NatTestCase(test_l3_plugin.L3NatDBTestCase,
|
|||||||
def test_router_create_distributed_returns_400(self):
|
def test_router_create_distributed_returns_400(self):
|
||||||
self._test_router_create_with_distributed(True, None, '3.0', 400)
|
self._test_router_create_with_distributed(True, None, '3.0', 400)
|
||||||
|
|
||||||
|
def test_router_create_on_obsolete_platform(self):
|
||||||
|
|
||||||
|
def obsolete_response(*args, **kwargs):
|
||||||
|
response = nvplib._create_implicit_routing_lrouter(*args, **kwargs)
|
||||||
|
response.pop('distributed')
|
||||||
|
return response
|
||||||
|
|
||||||
|
with mock.patch.object(
|
||||||
|
nvplib, 'create_lrouter', new=obsolete_response):
|
||||||
|
self._test_router_create_with_distributed(None, False, '2.2')
|
||||||
|
|
||||||
def test_router_create_nvp_error_returns_500(self, vlan_id=None):
|
def test_router_create_nvp_error_returns_500(self, vlan_id=None):
|
||||||
with mock.patch.object(nvplib,
|
with mock.patch.object(nvplib,
|
||||||
'create_router_lport',
|
'create_router_lport',
|
||||||
|
Loading…
Reference in New Issue
Block a user