1
0
Fork 0
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:
Jacob McGill 2017-08-24 22:21:08 -04:00 committed by Dag Wieers
parent fa6da960db
commit e434c291ca

View file

@ -81,6 +81,10 @@ def main():
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True,
required_if=[
['state', 'absent', ['mcp']],
['state', 'present', ['mcp']],
],
)
mcp = module.params['mcp']
@ -89,23 +93,19 @@ def main():
state = module.params['state']
aci = ACIModule(module)
# 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.construct_url(root_class='mcp')
aci.get_existing()
if state == 'present':
# 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
aci.get_diff(aci_class='mcpIfPol')