Merge "Allow explicitly setting enable_snat to either value"
This commit is contained in:
@@ -4086,11 +4086,9 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
info = {}
|
info = {}
|
||||||
if ext_gateway_net_id:
|
if ext_gateway_net_id:
|
||||||
info['network_id'] = ext_gateway_net_id
|
info['network_id'] = ext_gateway_net_id
|
||||||
# Only send enable_snat if it is different from the Neutron
|
# Only send enable_snat if it is explicitly set.
|
||||||
# default of True. Sending it can cause a policy violation error
|
if enable_snat is not None:
|
||||||
# on some clouds.
|
info['enable_snat'] = enable_snat
|
||||||
if enable_snat is not None and not enable_snat:
|
|
||||||
info['enable_snat'] = False
|
|
||||||
if ext_fixed_ips:
|
if ext_fixed_ips:
|
||||||
info['external_fixed_ips'] = ext_fixed_ips
|
info['external_fixed_ips'] = ext_fixed_ips
|
||||||
if info:
|
if info:
|
||||||
|
|||||||
@@ -144,8 +144,8 @@ class TestRouter(base.TestCase):
|
|||||||
availability_zone_hints=['nova'])
|
availability_zone_hints=['nova'])
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
def test_create_router_with_enable_snat_True(self):
|
def test_create_router_without_enable_snat(self):
|
||||||
"""Do not send enable_snat when same as neutron default."""
|
"""Do not send enable_snat when not given."""
|
||||||
self.register_uris([
|
self.register_uris([
|
||||||
dict(method='POST',
|
dict(method='POST',
|
||||||
uri=self.get_mock_url(
|
uri=self.get_mock_url(
|
||||||
@@ -156,6 +156,23 @@ class TestRouter(base.TestCase):
|
|||||||
'name': self.router_name,
|
'name': self.router_name,
|
||||||
'admin_state_up': True}}))
|
'admin_state_up': True}}))
|
||||||
])
|
])
|
||||||
|
self.cloud.create_router(
|
||||||
|
name=self.router_name, admin_state_up=True)
|
||||||
|
self.assert_calls()
|
||||||
|
|
||||||
|
def test_create_router_with_enable_snat_True(self):
|
||||||
|
"""Send enable_snat when it is True."""
|
||||||
|
self.register_uris([
|
||||||
|
dict(method='POST',
|
||||||
|
uri=self.get_mock_url(
|
||||||
|
'network', 'public', append=['v2.0', 'routers.json']),
|
||||||
|
json={'router': self.mock_router_rep},
|
||||||
|
validate=dict(
|
||||||
|
json={'router': {
|
||||||
|
'name': self.router_name,
|
||||||
|
'admin_state_up': True,
|
||||||
|
'external_gateway_info': {'enable_snat': True}}}))
|
||||||
|
])
|
||||||
self.cloud.create_router(
|
self.cloud.create_router(
|
||||||
name=self.router_name, admin_state_up=True, enable_snat=True)
|
name=self.router_name, admin_state_up=True, enable_snat=True)
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|||||||
Reference in New Issue
Block a user