From fa6da960dba258b511cdebc750df015b2d0ebe0d Mon Sep 17 00:00:00 2001 From: Jacob McGill Date: Thu, 24 Aug 2017 21:57:03 -0400 Subject: [PATCH] ACI Intf Policy LLDP: Update module to use new URL Method (#28634) --- .../network/aci/aci_intf_policy_lldp.py | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/ansible/modules/network/aci/aci_intf_policy_lldp.py b/lib/ansible/modules/network/aci/aci_intf_policy_lldp.py index e5da0c4b985..2b7937f67f1 100644 --- a/lib/ansible/modules/network/aci/aci_intf_policy_lldp.py +++ b/lib/ansible/modules/network/aci/aci_intf_policy_lldp.py @@ -89,6 +89,10 @@ def main(): module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, + required_if=[ + ['state', 'absent', ['lldp_policy']], + ['state', 'present', ['lldp_policy']], + ], ) lldp_policy = module.params['lldp_policy'] @@ -98,23 +102,20 @@ def main(): state = module.params['state'] aci = ACIModule(module) - - if lldp_policy is not None: - # Work with a specific object - path = 'api/mo/uni/infra/lldpIfP-%(lldp_policy)s.json' % module.params - elif state == 'query': - # Query all objects - path = 'api/node/class/lldpIfPol.json' - else: - module.fail_json(msg="Parameter 'lldp_policy' is required for state 'absent' or 'present'") - - aci.result['url'] = '%(protocol)s://%(hostname)s/' % aci.params + path - + aci.construct_url(root_class='lldp_policy') aci.get_existing() if state == 'present': # Filter out module parameters with null values - aci.payload(aci_class='lldpIfPol', class_config=dict(name=lldp_policy, descr=description, adminRxSt=receive_state, adminTxSt=transmit_state)) + aci.payload( + aci_class='lldpIfPol', + class_config=dict( + name=lldp_policy, + descr=description, + adminRxSt=receive_state, + adminTxSt=transmit_state, + ), + ) # Generate config diff which will be used as POST request body aci.get_diff(aci_class='lldpIfPol')