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

pull/28550/merge
Jacob McGill 7 years ago committed by Dag Wieers
parent 9c564de765
commit f9036133bb

@ -98,6 +98,10 @@ def main():
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True,
required_if=[
['state', 'absent', ['tenant']],
['state', 'present', ['tenant']],
],
)
tenant = module.params['tenant']
@ -105,23 +109,18 @@ def main():
state = module.params['state']
aci = ACIModule(module)
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.construct_url(root_class="tenant")
aci.get_existing()
if state == 'present':
# 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
aci.get_diff(aci_class='fvTenant')

Loading…
Cancel
Save