Fix alias for ext-gw-mode extension in nicira plugin
Also add a unit test for verifying that a 400 is raised when enable_snat is an invalid string. Bug 1207556 Change-Id: If33b8c72a08fbf7de1a837a65f083f09903c1809
This commit is contained in:
parent
fd20853e51
commit
5006288ba0
@ -150,7 +150,7 @@ class NvpPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
supported_extension_aliases = ["agent",
|
supported_extension_aliases = ["agent",
|
||||||
"binding",
|
"binding",
|
||||||
"dhcp_agent_scheduler",
|
"dhcp_agent_scheduler",
|
||||||
"ext_gw_mode",
|
"ext-gw-mode",
|
||||||
"extraroute",
|
"extraroute",
|
||||||
"mac-learning",
|
"mac-learning",
|
||||||
"network-gateway",
|
"network-gateway",
|
||||||
|
@ -326,7 +326,8 @@ class ExtGwModeTestCase(test_db_plugin.NeutronDbPluginV2TestCase,
|
|||||||
expected_code=exc.HTTPOk.code,
|
expected_code=exc.HTTPOk.code,
|
||||||
neutron_context=None):
|
neutron_context=None):
|
||||||
ext_gw_info = {'network_id': network_id}
|
ext_gw_info = {'network_id': network_id}
|
||||||
if snat_enabled in (True, False):
|
# Need to set enable_snat also if snat_enabled == False
|
||||||
|
if snat_enabled is not None:
|
||||||
ext_gw_info['enable_snat'] = snat_enabled
|
ext_gw_info['enable_snat'] = snat_enabled
|
||||||
return self._update('routers', router_id,
|
return self._update('routers', router_id,
|
||||||
{'router': {'external_gateway_info':
|
{'router': {'external_gateway_info':
|
||||||
@ -378,21 +379,27 @@ class ExtGwModeTestCase(test_db_plugin.NeutronDbPluginV2TestCase,
|
|||||||
self._test_router_create_show_ext_gwinfo(False, False)
|
self._test_router_create_show_ext_gwinfo(False, False)
|
||||||
|
|
||||||
def _test_router_update_ext_gwinfo(self, snat_input_value,
|
def _test_router_update_ext_gwinfo(self, snat_input_value,
|
||||||
snat_expected_value):
|
snat_expected_value=False,
|
||||||
|
expected_http_code=exc.HTTPOk.code):
|
||||||
with self.router() as r:
|
with self.router() as r:
|
||||||
with self.subnet() as s:
|
with self.subnet() as s:
|
||||||
ext_net_id = s['subnet']['network_id']
|
try:
|
||||||
self._set_net_external(ext_net_id)
|
ext_net_id = s['subnet']['network_id']
|
||||||
self._set_router_external_gateway(
|
self._set_net_external(ext_net_id)
|
||||||
r['router']['id'], ext_net_id,
|
self._set_router_external_gateway(
|
||||||
snat_enabled=snat_input_value)
|
r['router']['id'], ext_net_id,
|
||||||
body = self._show('routers', r['router']['id'])
|
snat_enabled=snat_input_value,
|
||||||
res_gw_info = body['router']['external_gateway_info']
|
expected_code=expected_http_code)
|
||||||
self.assertEqual(res_gw_info['network_id'], ext_net_id)
|
if expected_http_code != exc.HTTPOk.code:
|
||||||
self.assertEqual(res_gw_info['enable_snat'],
|
return
|
||||||
snat_expected_value)
|
body = self._show('routers', r['router']['id'])
|
||||||
self._remove_external_gateway_from_router(
|
res_gw_info = body['router']['external_gateway_info']
|
||||||
r['router']['id'], ext_net_id)
|
self.assertEqual(res_gw_info['network_id'], ext_net_id)
|
||||||
|
self.assertEqual(res_gw_info['enable_snat'],
|
||||||
|
snat_expected_value)
|
||||||
|
finally:
|
||||||
|
self._remove_external_gateway_from_router(
|
||||||
|
r['router']['id'], ext_net_id)
|
||||||
|
|
||||||
def test_router_update_ext_gwinfo_default(self):
|
def test_router_update_ext_gwinfo_default(self):
|
||||||
self._test_router_update_ext_gwinfo(None, True)
|
self._test_router_update_ext_gwinfo(None, True)
|
||||||
@ -402,3 +409,7 @@ class ExtGwModeTestCase(test_db_plugin.NeutronDbPluginV2TestCase,
|
|||||||
|
|
||||||
def test_router_update_ext_gwinfo_with_snat_disabled(self):
|
def test_router_update_ext_gwinfo_with_snat_disabled(self):
|
||||||
self._test_router_update_ext_gwinfo(False, False)
|
self._test_router_update_ext_gwinfo(False, False)
|
||||||
|
|
||||||
|
def test_router_update_ext_gwinfo_with_invalid_snat_setting(self):
|
||||||
|
self._test_router_update_ext_gwinfo(
|
||||||
|
'xxx', None, expected_http_code=exc.HTTPBadRequest.code)
|
||||||
|
Loading…
Reference in New Issue
Block a user