ACI Intf Policy LLDP: Update module to use new URL Method (#28634)

This commit is contained in:
Jacob McGill 2017-08-24 21:57:03 -04:00 committed by Dag Wieers
parent 6109a6c093
commit fa6da960db

View file

@ -89,6 +89,10 @@ def main():
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True,
required_if=[
['state', 'absent', ['lldp_policy']],
['state', 'present', ['lldp_policy']],
],
)
lldp_policy = module.params['lldp_policy']
@ -98,23 +102,20 @@ def main():
state = module.params['state']
aci = ACIModule(module)
if lldp_policy is not None:
# Work with a specific object
path = 'api/mo/uni/infra/lldpIfP-%(lldp_policy)s.json' % module.params
elif state == 'query':
# Query all objects
path = 'api/node/class/lldpIfPol.json'
else:
module.fail_json(msg="Parameter 'lldp_policy' is required for state 'absent' or 'present'")
aci.result['url'] = '%(protocol)s://%(hostname)s/' % aci.params + path
aci.construct_url(root_class='lldp_policy')
aci.get_existing()
if state == 'present':
# Filter out module parameters with null values
aci.payload(aci_class='lldpIfPol', class_config=dict(name=lldp_policy, descr=description, adminRxSt=receive_state, adminTxSt=transmit_state))
aci.payload(
aci_class='lldpIfPol',
class_config=dict(
name=lldp_policy,
descr=description,
adminRxSt=receive_state,
adminTxSt=transmit_state,
),
)
# Generate config diff which will be used as POST request body
aci.get_diff(aci_class='lldpIfPol')