From 25d1ef34933b4ee2f6710f61eecaa26c3ef11194 Mon Sep 17 00:00:00 2001 From: Jacob McGill Date: Thu, 24 Aug 2017 21:55:27 -0400 Subject: [PATCH] ACI Intf Policy FC: Update module to use new URL Method (#28632) --- .../modules/network/aci/aci_intf_policy_fc.py | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/ansible/modules/network/aci/aci_intf_policy_fc.py b/lib/ansible/modules/network/aci/aci_intf_policy_fc.py index 1c1aead13d..a85d14e78c 100644 --- a/lib/ansible/modules/network/aci/aci_intf_policy_fc.py +++ b/lib/ansible/modules/network/aci/aci_intf_policy_fc.py @@ -81,6 +81,10 @@ def main(): module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, + required_if=[ + ['state', 'absent', ['fc_policy']], + ['state', 'present', ['fc_policy']], + ], ) fc_policy = module.params['fc_policy'] @@ -89,23 +93,19 @@ def main(): state = module.params['state'] aci = ACIModule(module) - - if fc_policy is not None: - # Work with a specific object - path = 'api/mo/uni/infra/fcIfPol-%(fc_policy)s.json' % module.params - elif state == 'query': - # Query all objects - path = 'api/infra/class/fcIfPol.json' - else: - module.fail_json(msg="Parameter 'fc_policy' is required for state 'absent' or 'present'") - - aci.result['url'] = '%(protocol)s://%(hostname)s/' % aci.params + path - + aci.construct_url(root_class='fc_policy') aci.get_existing() if state == 'present': # Filter out module parameters with null values - aci.payload(aci_class='fcIfPol', class_config=dict(name=fc_policy, descr=description, portMode=port_mode)) + aci.payload( + aci_class='fcIfPol', + class_config=dict( + name=fc_policy, + descr=description, + portMode=port_mode, + ), + ) # Generate config diff which will be used as POST request body aci.get_diff(aci_class='fcIfPol')