summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Guerri <davide.guerri@gmail.com>2015-04-19 19:42:35 +0100
committerDavide Guerri <davide.guerri@gmail.com>2015-04-19 19:42:35 +0100
commitde58a1eb954ee69f19275fbe1980ddfe62b7fe34 (patch)
treefa164d5454f3d94eba4e8a3dd24b9559c664882d
parentd46ec30eb268648172f818489446982916dc90e9 (diff)
downloadopenstack-ansible-modules-de58a1eb954ee69f19275fbe1980ddfe62b7fe34.tar.gz
Allow subnet without a gateway
If "subnet" is not present in the request body, Neuton will use the first address available in the specified subnet as the gateway address. Conversely, using "gateway_ip": null will create a subnet without a gateway.
-rw-r--r--neutron_subnet14
1 files changed, 12 insertions, 2 deletions
diff --git a/neutron_subnet b/neutron_subnet
index 8cb622b..314d8ed 100644
--- a/neutron_subnet
+++ b/neutron_subnet
@@ -85,6 +85,11 @@ options:
- Whether DHCP should be enabled for this subnet.
required: false
default: true
+ no_gateway:
+ description:
+ - If "true", no gateway will be created for this subnet
+ required: false
+ default: false
gateway_ip:
description:
- The ip that would be assigned to the gateway for this subnet
@@ -226,8 +231,12 @@ def _create_subnet(module, neutron):
}
]
subnet.update({'allocation_pools': allocation_pools})
- if not module.params['gateway_ip']:
- subnet.pop('gateway_ip')
+ # "subnet['gateway_ip'] = None" means: "no gateway"
+ # no gateway_ip in body means: "automatic gateway"
+ if module.params['no_gateway']:
+ subnet['gateway_ip'] = None
+ elif module.params['gateway_ip'] is not None:
+ subnet['gateway_ip'] = module.params['gateway_ip']
if module.params['dns_nameservers']:
subnet['dns_nameservers'] = module.params['dns_nameservers'].split(',')
else:
@@ -265,6 +274,7 @@ def main():
state = dict(default='present', choices=['absent', 'present']),
ip_version = dict(default='4', choices=['4', '6']),
enable_dhcp = dict(default='true', choices=BOOLEANS),
+ no_gateway = dict(default='false', choices=BOOLEANS),
gateway_ip = dict(default=None),
dns_nameservers = dict(default=None),
allocation_pool_start = dict(default=None),