mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
ACI Intf Policy MCP: Update module to use new URL Method (#28635)
This commit is contained in:
parent
fa6da960db
commit
e434c291ca
1 changed files with 13 additions and 13 deletions
|
@ -81,6 +81,10 @@ 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', ['mcp']],
|
||||||
|
['state', 'present', ['mcp']],
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
mcp = module.params['mcp']
|
mcp = module.params['mcp']
|
||||||
|
@ -89,23 +93,19 @@ def main():
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
|
||||||
aci = ACIModule(module)
|
aci = ACIModule(module)
|
||||||
|
aci.construct_url(root_class='mcp')
|
||||||
# TODO: This logic could be cleaner.
|
|
||||||
if mcp is not None:
|
|
||||||
path = 'api/mo/uni/infra/mcpIfP--%(mcp)s.json' % module.params
|
|
||||||
elif state == 'query':
|
|
||||||
# Query all objects
|
|
||||||
path = 'api/node/class/mcpIfPol.json'
|
|
||||||
else:
|
|
||||||
module.fail_json(msg="Parameter 'mcp' 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='mcpIfPol', class_config=dict(name=mcp, descr=description, adminSt=admin_state))
|
aci.payload(
|
||||||
|
aci_class='mcpIfPol',
|
||||||
|
class_config=dict(
|
||||||
|
name=mcp,
|
||||||
|
descr=description,
|
||||||
|
adminSt=admin_state,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
# 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='mcpIfPol')
|
aci.get_diff(aci_class='mcpIfPol')
|
||||||
|
|
Loading…
Reference in a new issue