ACI VRF: Update module to use new URL Method (#28646)
This commit is contained in:
parent
f7a466cbb4
commit
8a966a48c8
1 changed files with 15 additions and 18 deletions
|
@ -117,37 +117,34 @@ 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', 'vrf']],
|
||||||
|
['state', 'present', ['tenant', 'vrf']],
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
description = module.params['description']
|
description = module.params['description']
|
||||||
policy_control_direction = module.params['policy_control_direction']
|
policy_control_direction = module.params['policy_control_direction']
|
||||||
policy_control_preference = module.params['policy_control_preference']
|
policy_control_preference = module.params['policy_control_preference']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
tenant = module.params['tenant']
|
|
||||||
vrf = module.params['vrf']
|
vrf = module.params['vrf']
|
||||||
|
|
||||||
aci = ACIModule(module)
|
aci = ACIModule(module)
|
||||||
|
aci.construct_url(root_class="tenant", subclass_1="vrf")
|
||||||
if vrf is not None:
|
|
||||||
if tenant is not None:
|
|
||||||
path = 'api/mo/uni/tn-%(tenant)s/ctx-%(vrf)s.json' % module.params
|
|
||||||
elif state == 'query':
|
|
||||||
path = 'api/mo/uni/tn-%(tenant)s.json?rsp-subtree=children&rsp-subtree-class=fvCtx&rsp-subtree-include=no-scoped' % module.params
|
|
||||||
else:
|
|
||||||
module.fail_json(msg="Parameter 'tenant' is required for state 'absent' or 'present'")
|
|
||||||
elif state == 'query':
|
|
||||||
path = 'api/class/fvCtx.json'
|
|
||||||
else:
|
|
||||||
module.fail_json(msg="Parameter 'vrf' 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 params with null values
|
# Filter out module params with null values
|
||||||
aci.payload(aci_class='fvCtx', class_config=dict(descr=description, pcEnfDir=policy_control_direction, pcEnfPref=policy_control_preference, name=vrf))
|
aci.payload(
|
||||||
|
aci_class='fvCtx',
|
||||||
|
class_config=dict(
|
||||||
|
descr=description,
|
||||||
|
pcEnfDir=policy_control_direction,
|
||||||
|
pcEnfPref=policy_control_preference,
|
||||||
|
name=vrf,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
# 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='fvCtx')
|
aci.get_diff(aci_class='fvCtx')
|
||||||
|
|
Loading…
Reference in a new issue