Merge pull request #3237 from rcarrillocruz/os_subnet_by_project
Create subnet by project
This commit is contained in:
commit
cea5ceb644
1 changed files with 20 additions and 2 deletions
|
@ -105,6 +105,11 @@ options:
|
|||
choices: ['dhcpv6-stateful', 'dhcpv6-stateless', 'slaac']
|
||||
required: false
|
||||
default: None
|
||||
project:
|
||||
description:
|
||||
- Project name or ID containing the subnet (name admin-only)
|
||||
required: false
|
||||
default: None
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "shade"
|
||||
|
@ -233,6 +238,7 @@ def main():
|
|||
ipv6_ra_mode=dict(default=None, choice=ipv6_mode_choices),
|
||||
ipv6_address_mode=dict(default=None, choice=ipv6_mode_choices),
|
||||
state=dict(default='present', choices=['absent', 'present']),
|
||||
project=dict(default=None)
|
||||
)
|
||||
|
||||
module_kwargs = openstack_module_kwargs()
|
||||
|
@ -256,6 +262,7 @@ def main():
|
|||
host_routes = module.params['host_routes']
|
||||
ipv6_ra_mode = module.params['ipv6_ra_mode']
|
||||
ipv6_a_mode = module.params['ipv6_address_mode']
|
||||
project = module.params.pop('project')
|
||||
|
||||
# Check for required parameters when state == 'present'
|
||||
if state == 'present':
|
||||
|
@ -272,7 +279,17 @@ def main():
|
|||
|
||||
try:
|
||||
cloud = shade.openstack_cloud(**module.params)
|
||||
subnet = cloud.get_subnet(subnet_name)
|
||||
if project is not None:
|
||||
proj = cloud.get_project(project)
|
||||
if proj is None:
|
||||
module.fail_json(msg='Project %s could not be found' % project)
|
||||
project_id = proj['id']
|
||||
filters = {'tenant_id': project_id}
|
||||
else:
|
||||
project_id = None
|
||||
filters = None
|
||||
|
||||
subnet = cloud.get_subnet(subnet_name, filters=filters)
|
||||
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=_system_state_change(module, subnet,
|
||||
|
@ -289,7 +306,8 @@ def main():
|
|||
allocation_pools=pool,
|
||||
host_routes=host_routes,
|
||||
ipv6_ra_mode=ipv6_ra_mode,
|
||||
ipv6_address_mode=ipv6_a_mode)
|
||||
ipv6_address_mode=ipv6_a_mode,
|
||||
tenant_id=project_id)
|
||||
changed = True
|
||||
else:
|
||||
if _needs_update(subnet, module, cloud):
|
||||
|
|
Loading…
Reference in a new issue