mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
ACI Tenant Action Rule Profile: Update module to use new URL Method (#28641)
This commit is contained in:
parent
a12ff4468d
commit
8b641688e9
1 changed files with 13 additions and 14 deletions
|
@ -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…
Reference in a new issue