From 061fe51e9ae0a1e978d0db80de4a72250323b0e6 Mon Sep 17 00:00:00 2001 From: Jacob McGill Date: Thu, 24 Aug 2017 20:46:09 -0400 Subject: [PATCH] ACI AEP: Update module to use new URL Method (#28619) * ACI AEP: Update module to use new URL Method * ACI AEP: Update module to use new URL Method * ACI AEP: Update module to use new URL Method --- lib/ansible/modules/network/aci/aci_aep.py | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/ansible/modules/network/aci/aci_aep.py b/lib/ansible/modules/network/aci/aci_aep.py index dd724a7a11..a0c2aca044 100644 --- a/lib/ansible/modules/network/aci/aci_aep.py +++ b/lib/ansible/modules/network/aci/aci_aep.py @@ -97,6 +97,10 @@ def main(): module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, + required_if=[ + ['state', 'absent', ['aep']], + ['state', 'present', ['aep']], + ], ) aep = module.params['aep'] @@ -104,21 +108,18 @@ def main(): state = module.params['state'] aci = ACIModule(module) - - if aep is not None: - path = 'api/mo/uni/infra/attentp-%(aep)s.json' % module.params - elif state == 'query': - path = 'api/class/infraAttEntityP.json' - else: - module.fail_json(msg="Parameter 'aep' is required for state 'absent' or 'present'") - - aci.result['url'] = '%(protocol)s://%(hostname)s/' % aci.params + path - + aci.construct_url(root_class="aep") aci.get_existing() if state == 'present': # Filter out module parameters with null values - aci.payload(aci_class='infraAttEntityP', class_config=dict(name=aep, descr=description)) + aci.payload( + aci_class='infraAttEntityP', + class_config=dict( + name=aep, + descr=description, + ), + ) # Generate config diff which will be used as POST request body aci.get_diff(aci_class='infraAttEntityP')