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

This commit is contained in:
Jacob McGill 2017-08-25 02:36:51 -04:00 committed by Dag Wieers
parent a12ff4468d
commit 8b641688e9

View file

@ -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')