Added --enable-snat option for router-gateway-set
If enable_snat_by_default option set to false and disable snat via cli
it becomes unavailable to enable snat again.
This commit allows to enable snat after disabling it.
Change-Id: I01009d5cd5edd5be3eead615c37d6aa2e3224442
Closes-Bug: #1598171
(cherry picked from commit cc1d3fdd35)
This commit is contained in:
@@ -220,6 +220,9 @@ class SetGatewayRouter(neutronV20.NeutronCommand):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'external_network', metavar='EXTERNAL-NETWORK',
|
'external_network', metavar='EXTERNAL-NETWORK',
|
||||||
help=_('ID or name of the external network for the gateway.'))
|
help=_('ID or name of the external network for the gateway.'))
|
||||||
|
parser.add_argument(
|
||||||
|
'--enable-snat', action='store_true',
|
||||||
|
help=_('Enable source NAT on the router gateway.'))
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--disable-snat', action='store_true',
|
'--disable-snat', action='store_true',
|
||||||
help=_('Disable source NAT on the router gateway.'))
|
help=_('Disable source NAT on the router gateway.'))
|
||||||
@@ -242,6 +245,8 @@ class SetGatewayRouter(neutronV20.NeutronCommand):
|
|||||||
_ext_net_id = neutronV20.find_resourceid_by_name_or_id(
|
_ext_net_id = neutronV20.find_resourceid_by_name_or_id(
|
||||||
neutron_client, 'network', parsed_args.external_network)
|
neutron_client, 'network', parsed_args.external_network)
|
||||||
router_dict = {'network_id': _ext_net_id}
|
router_dict = {'network_id': _ext_net_id}
|
||||||
|
if parsed_args.enable_snat:
|
||||||
|
router_dict['enable_snat'] = True
|
||||||
if parsed_args.disable_snat:
|
if parsed_args.disable_snat:
|
||||||
router_dict['enable_snat'] = False
|
router_dict['enable_snat'] = False
|
||||||
if parsed_args.fixed_ip:
|
if parsed_args.fixed_ip:
|
||||||
|
|||||||
@@ -345,6 +345,18 @@ class CLITestV20RouterJSON(test_cli20.CLITestV20Base):
|
|||||||
{"network_id": "externalid"}}
|
{"network_id": "externalid"}}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_set_gateway_enable_snat(self):
|
||||||
|
# enable external gateway for router: myid externalid.
|
||||||
|
resource = 'router'
|
||||||
|
cmd = router.SetGatewayRouter(test_cli20.MyApp(sys.stdout), None)
|
||||||
|
args = ['myid', 'externalid', '--enable-snat']
|
||||||
|
self._test_update_resource(resource, cmd, 'myid',
|
||||||
|
args,
|
||||||
|
{"external_gateway_info":
|
||||||
|
{"network_id": "externalid",
|
||||||
|
"enable_snat": True}}
|
||||||
|
)
|
||||||
|
|
||||||
def test_set_gateway_disable_snat(self):
|
def test_set_gateway_disable_snat(self):
|
||||||
# set external gateway for router: myid externalid.
|
# set external gateway for router: myid externalid.
|
||||||
resource = 'router'
|
resource = 'router'
|
||||||
|
|||||||
Reference in New Issue
Block a user