1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

ACI Tenant: Update module to use new URL Method (#28640)

This commit is contained in:
Jacob McGill 2017-08-25 02:35:00 -04:00 committed by Dag Wieers
parent 9c564de765
commit f9036133bb

View file

@ -98,6 +98,10 @@ def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=argument_spec, argument_spec=argument_spec,
supports_check_mode=True, supports_check_mode=True,
required_if=[
['state', 'absent', ['tenant']],
['state', 'present', ['tenant']],
],
) )
tenant = module.params['tenant'] tenant = module.params['tenant']
@ -105,23 +109,18 @@ def main():
state = module.params['state'] state = module.params['state']
aci = ACIModule(module) aci = ACIModule(module)
aci.construct_url(root_class="tenant")
if tenant is not None:
# Work with a specific object
path = 'api/mo/uni/tn-%(tenant)s.json' % module.params
elif state == 'query':
# Query all objects
path = 'api/class/fvTenant.json'
else:
module.fail_json(msg="Parameter 'tenant' is required for state 'absent' or 'present'")
aci.result['url'] = '%(protocol)s://%(hostname)s/' % aci.params + path
aci.get_existing() aci.get_existing()
if state == 'present': if state == 'present':
# Filter out module parameters with null values # Filter out module parameters with null values
aci.payload(aci_class='fvTenant', class_config=dict(name=tenant, descr=description)) aci.payload(
aci_class='fvTenant',
class_config=dict(
name=tenant,
descr=description,
),
)
# Generate config diff which will be used as POST request body # Generate config diff which will be used as POST request body
aci.get_diff(aci_class='fvTenant') aci.get_diff(aci_class='fvTenant')