mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
ACI Taboo Contract: Update module to use new URL Method (#28639)
This commit is contained in:
parent
8b641688e9
commit
bac617acef
1 changed files with 15 additions and 16 deletions
|
@ -46,8 +46,9 @@ options:
|
||||||
scope:
|
scope:
|
||||||
description:
|
description:
|
||||||
- The scope of a service contract.
|
- The scope of a service contract.
|
||||||
- The APIC defaults new Taboo Contracts to a scope of context (VRF).
|
- The APIC defaults new Taboo Contracts to C(context).
|
||||||
choices: [ application-profile, context, global, tenant ]
|
choices: [ application-profile, context, global, tenant ]
|
||||||
|
default: context
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Use C(present) or C(absent) for adding or removing.
|
- Use C(present) or C(absent) for adding or removing.
|
||||||
|
@ -90,35 +91,33 @@ 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', ['tenant', 'taboo_contract']],
|
||||||
|
['state', 'present', ['tenant', 'taboo_contract']],
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
taboo_contract = module.params['taboo_contract']
|
taboo_contract = module.params['taboo_contract']
|
||||||
# tenant = module.params['tenant']
|
|
||||||
description = module.params['description']
|
description = module.params['description']
|
||||||
scope = module.params['scope']
|
scope = module.params['scope']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
|
||||||
aci = ACIModule(module)
|
aci = ACIModule(module)
|
||||||
|
aci.construct_url(root_class='tenant', subclass_1='taboo_contract')
|
||||||
# TODO: This logic could be cleaner.
|
|
||||||
if taboo_contract is not None:
|
|
||||||
path = 'api/mo/uni/tn-%(tenant)s/taboo-%(taboo_contract)s.json' % module.params
|
|
||||||
elif state == 'query':
|
|
||||||
# Query all objects
|
|
||||||
path = 'api/node/class/vzTaboo.json'
|
|
||||||
else:
|
|
||||||
module.fail_json(msg="Parameter 'taboo_contract' 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='vzBrCP', class_config=dict(name=taboo_contract, descr=description, scope=scope))
|
aci.payload(
|
||||||
|
aci_class='vzTaboo',
|
||||||
|
class_config=dict(
|
||||||
|
name=taboo_contract,
|
||||||
|
descr=description, scope=scope,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
# 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='vzBrCP')
|
aci.get_diff(aci_class='vzTaboo')
|
||||||
|
|
||||||
# Submit changes if module not in check_mode and the proposed is different than existing
|
# Submit changes if module not in check_mode and the proposed is different than existing
|
||||||
aci.post_config()
|
aci.post_config()
|
||||||
|
|
Loading…
Reference in a new issue