ACI Tenant Action Rule Profile: Update module to use new URL Method (#28641)

pull/28550/merge
Jacob McGill 7 years ago committed by Dag Wieers
parent a12ff4468d
commit 8b641688e9

@ -82,31 +82,30 @@ def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=argument_spec, argument_spec=argument_spec,
supports_check_mode=True, supports_check_mode=True,
required_if=[
['state', 'absent', ['action_rule', 'tenant']],
['state', 'present', ['action_rule', 'tenant']],
],
) )
action_rule = module.params['action_rule'] action_rule = module.params['action_rule']
# tenant = module.params['tenant']
description = module.params['description'] description = module.params['description']
state = module.params['state'] state = module.params['state']
aci = ACIModule(module) aci = ACIModule(module)
aci.construct_url(root_class='tenant', subclass_1='action_rule')
# 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.get_existing() aci.get_existing()
if state == 'present': if state == 'present':
# Filter out module parameters with null values # 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 # Generate config diff which will be used as POST request body
aci.get_diff(aci_class='rtctrlAttrP') aci.get_diff(aci_class='rtctrlAttrP')

Loading…
Cancel
Save