Merge "Fix alias for ext-gw-mode extension in nicira plugin"

This commit is contained in:
Jenkins 2013-08-02 17:32:59 +00:00 committed by Gerrit Code Review
commit 256f9743a3
2 changed files with 26 additions and 15 deletions

View File

@ -150,7 +150,7 @@ class NvpPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
supported_extension_aliases = ["agent",
"binding",
"dhcp_agent_scheduler",
"ext_gw_mode",
"ext-gw-mode",
"extraroute",
"mac-learning",
"network-gateway",

View File

@ -326,7 +326,8 @@ class ExtGwModeTestCase(test_db_plugin.NeutronDbPluginV2TestCase,
expected_code=exc.HTTPOk.code,
neutron_context=None):
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
return self._update('routers', router_id,
{'router': {'external_gateway_info':
@ -378,21 +379,27 @@ class ExtGwModeTestCase(test_db_plugin.NeutronDbPluginV2TestCase,
self._test_router_create_show_ext_gwinfo(False, False)
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.subnet() as s:
ext_net_id = s['subnet']['network_id']
self._set_net_external(ext_net_id)
self._set_router_external_gateway(
r['router']['id'], ext_net_id,
snat_enabled=snat_input_value)
body = self._show('routers', r['router']['id'])
res_gw_info = body['router']['external_gateway_info']
self.assertEqual(res_gw_info['network_id'], ext_net_id)
self.assertEqual(res_gw_info['enable_snat'],
snat_expected_value)
self._remove_external_gateway_from_router(
r['router']['id'], ext_net_id)
try:
ext_net_id = s['subnet']['network_id']
self._set_net_external(ext_net_id)
self._set_router_external_gateway(
r['router']['id'], ext_net_id,
snat_enabled=snat_input_value,
expected_code=expected_http_code)
if expected_http_code != exc.HTTPOk.code:
return
body = self._show('routers', r['router']['id'])
res_gw_info = body['router']['external_gateway_info']
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):
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):
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)