Add no_gateway_ip option to os_subnet module (#3736)
no_gateway_ip option can provide subnet that is not having a gateway. fixes #1880
This commit is contained in:
parent
170ce382af
commit
215da19511
1 changed files with 16 additions and 0 deletions
|
@ -71,6 +71,12 @@ options:
|
||||||
- The ip that would be assigned to the gateway for this subnet
|
- The ip that would be assigned to the gateway for this subnet
|
||||||
required: false
|
required: false
|
||||||
default: None
|
default: None
|
||||||
|
no_gateway_ip:
|
||||||
|
description:
|
||||||
|
- The gateway IP would not be assigned for this subnet
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
version_added: "2.2"
|
||||||
dns_nameservers:
|
dns_nameservers:
|
||||||
description:
|
description:
|
||||||
- List of DNS nameservers for this subnet.
|
- List of DNS nameservers for this subnet.
|
||||||
|
@ -188,6 +194,7 @@ def _needs_update(subnet, module, cloud):
|
||||||
pool_start = module.params['allocation_pool_start']
|
pool_start = module.params['allocation_pool_start']
|
||||||
pool_end = module.params['allocation_pool_end']
|
pool_end = module.params['allocation_pool_end']
|
||||||
gateway_ip = module.params['gateway_ip']
|
gateway_ip = module.params['gateway_ip']
|
||||||
|
no_gateway_ip = module.params['no_gateway_ip']
|
||||||
dns = module.params['dns_nameservers']
|
dns = module.params['dns_nameservers']
|
||||||
host_routes = module.params['host_routes']
|
host_routes = module.params['host_routes']
|
||||||
curr_pool = subnet['allocation_pools'][0]
|
curr_pool = subnet['allocation_pools'][0]
|
||||||
|
@ -209,6 +216,8 @@ def _needs_update(subnet, module, cloud):
|
||||||
new_hr = sorted(host_routes, key=lambda t: t.keys())
|
new_hr = sorted(host_routes, key=lambda t: t.keys())
|
||||||
if sorted(curr_hr) != sorted(new_hr):
|
if sorted(curr_hr) != sorted(new_hr):
|
||||||
return True
|
return True
|
||||||
|
if no_gateway_ip and subnet['gateway_ip']:
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,6 +241,7 @@ def main():
|
||||||
ip_version=dict(default='4', choices=['4', '6']),
|
ip_version=dict(default='4', choices=['4', '6']),
|
||||||
enable_dhcp=dict(default='true', type='bool'),
|
enable_dhcp=dict(default='true', type='bool'),
|
||||||
gateway_ip=dict(default=None),
|
gateway_ip=dict(default=None),
|
||||||
|
no_gateway_ip=dict(default=False, type='bool'),
|
||||||
dns_nameservers=dict(default=None, type='list'),
|
dns_nameservers=dict(default=None, type='list'),
|
||||||
allocation_pool_start=dict(default=None),
|
allocation_pool_start=dict(default=None),
|
||||||
allocation_pool_end=dict(default=None),
|
allocation_pool_end=dict(default=None),
|
||||||
|
@ -257,6 +267,7 @@ def main():
|
||||||
enable_dhcp = module.params['enable_dhcp']
|
enable_dhcp = module.params['enable_dhcp']
|
||||||
subnet_name = module.params['name']
|
subnet_name = module.params['name']
|
||||||
gateway_ip = module.params['gateway_ip']
|
gateway_ip = module.params['gateway_ip']
|
||||||
|
no_gateway_ip = module.params['no_gateway_ip']
|
||||||
dns = module.params['dns_nameservers']
|
dns = module.params['dns_nameservers']
|
||||||
pool_start = module.params['allocation_pool_start']
|
pool_start = module.params['allocation_pool_start']
|
||||||
pool_end = module.params['allocation_pool_end']
|
pool_end = module.params['allocation_pool_end']
|
||||||
|
@ -278,6 +289,9 @@ def main():
|
||||||
else:
|
else:
|
||||||
pool = None
|
pool = None
|
||||||
|
|
||||||
|
if no_gateway_ip and gateway_ip:
|
||||||
|
module.fail_json(msg='no_gateway_ip is not allowed with gateway_ip')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cloud = shade.openstack_cloud(**module.params)
|
cloud = shade.openstack_cloud(**module.params)
|
||||||
if project is not None:
|
if project is not None:
|
||||||
|
@ -303,6 +317,7 @@ def main():
|
||||||
enable_dhcp=enable_dhcp,
|
enable_dhcp=enable_dhcp,
|
||||||
subnet_name=subnet_name,
|
subnet_name=subnet_name,
|
||||||
gateway_ip=gateway_ip,
|
gateway_ip=gateway_ip,
|
||||||
|
disable_gateway_ip=no_gateway_ip,
|
||||||
dns_nameservers=dns,
|
dns_nameservers=dns,
|
||||||
allocation_pools=pool,
|
allocation_pools=pool,
|
||||||
host_routes=host_routes,
|
host_routes=host_routes,
|
||||||
|
@ -316,6 +331,7 @@ def main():
|
||||||
subnet_name=subnet_name,
|
subnet_name=subnet_name,
|
||||||
enable_dhcp=enable_dhcp,
|
enable_dhcp=enable_dhcp,
|
||||||
gateway_ip=gateway_ip,
|
gateway_ip=gateway_ip,
|
||||||
|
disable_gateway_ip=no_gateway_ip,
|
||||||
dns_nameservers=dns,
|
dns_nameservers=dns,
|
||||||
allocation_pools=pool,
|
allocation_pools=pool,
|
||||||
host_routes=host_routes)
|
host_routes=host_routes)
|
||||||
|
|
Loading…
Reference in a new issue