From 8b641688e9386cd235b30e410f7d990a2e98ddb9 Mon Sep 17 00:00:00 2001 From: Jacob McGill Date: Fri, 25 Aug 2017 02:36:51 -0400 Subject: [PATCH] ACI Tenant Action Rule Profile: Update module to use new URL Method (#28641) --- .../aci/aci_tenant_action_rule_profile.py | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/ansible/modules/network/aci/aci_tenant_action_rule_profile.py b/lib/ansible/modules/network/aci/aci_tenant_action_rule_profile.py index b0f6d139bd..e85bd2ae5b 100644 --- a/lib/ansible/modules/network/aci/aci_tenant_action_rule_profile.py +++ b/lib/ansible/modules/network/aci/aci_tenant_action_rule_profile.py @@ -82,31 +82,30 @@ def main(): module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, + required_if=[ + ['state', 'absent', ['action_rule', 'tenant']], + ['state', 'present', ['action_rule', 'tenant']], + ], ) action_rule = module.params['action_rule'] - # tenant = module.params['tenant'] description = module.params['description'] state = module.params['state'] aci = ACIModule(module) - - # TODO: This logic could be cleaner. - if action_rule is not None: - path = 'api/mo/uni/tn-%(tenant)s/attr-%(action_rule)s.json' % module.params - elif state == 'query': - # Query all objects - path = 'api/node/class/rtctrlAttrP.json' - else: - module.fail_json(msg="Parameter 'action_rule' is required for state 'absent' or 'present'") - - aci.result['url'] = '%(protocol)s://%(hostname)s/' % aci.params + path - + aci.construct_url(root_class='tenant', subclass_1='action_rule') aci.get_existing() if state == 'present': # Filter out module parameters with null values - aci.payload(aci_class='rtctrlAttrP', class_config=dict(name=action_rule, descr=description)) + aci.payload( + aci_class='rtctrlAttrP', + class_config=dict( + name=action_rule, + descr=description, + ), + + ) # Generate config diff which will be used as POST request body aci.get_diff(aci_class='rtctrlAttrP')