ACI BD to L3Out: Update module to use new URL Method (#28623)

pull/27817/head
Jacob McGill 7 years ago committed by Dag Wieers
parent 28f76166d0
commit dc232737ba

@ -73,27 +73,28 @@ def main():
argument_spec=argument_spec, argument_spec=argument_spec,
supports_check_mode=True, supports_check_mode=True,
required_together=[['gateway', 'mask']], required_together=[['gateway', 'mask']],
required_if=[['state', 'present', ['bd', 'l3out', 'tenant']], required_if=[
['state', 'absent', ['bd', 'l3out', 'tenant']]] ['state', 'present', ['bd', 'l3out', 'tenant']],
['state', 'absent', ['bd', 'l3out', 'tenant']],
],
) )
l3out = module.params['l3out'] l3out = module.params['l3out']
state = module.params['state'] state = module.params['state']
aci = ACIModule(module) # Add bd_l3out key to module.params for building the URL
module.params['bd_l3out'] = l3out
if state != 'query':
path = 'api/mo/uni/tn-%(tenant)s/BD-%(bd)s/rsBDToOut-%(l3out)s.json' % module.params
else:
path = 'api/class/fvRsBDToOut.json'
aci.result['url'] = '%(protocol)s://%(hostname)s/' % aci.params + path
aci = ACIModule(module)
aci.construct_url(root_class='tenant', subclass_1='bd', subclass_2='bd_l3out')
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='fvRsBDToOut', class_config=dict(tnL3extOutName=l3out)) aci.payload(
aci_class='fvRsBDToOut',
class_config=dict(tnL3extOutName=l3out),
)
# 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='fvRsBDToOut') aci.get_diff(aci_class='fvRsBDToOut')
@ -104,6 +105,9 @@ def main():
elif state == 'absent': elif state == 'absent':
aci.delete_config() aci.delete_config()
# Remove bd_l3out key used for URL building from module.params
module.params.pop('bd_l3out')
module.exit_json(**aci.result) module.exit_json(**aci.result)

Loading…
Cancel
Save