A static leaf is build from the pod id and leaf id (#55120)
This commit is contained in:
parent
62f4eb7053
commit
b6bf910bf4
1 changed files with 13 additions and 5 deletions
|
@ -44,6 +44,10 @@ options:
|
|||
description:
|
||||
- The name of the EPG.
|
||||
type: str
|
||||
pod:
|
||||
description:
|
||||
- The pod of the static leaf.
|
||||
type: str
|
||||
leaf:
|
||||
description:
|
||||
- The path of the static leaf.
|
||||
|
@ -140,6 +144,7 @@ def main():
|
|||
template=dict(type='str', required=True),
|
||||
anp=dict(type='str', required=True),
|
||||
epg=dict(type='str', required=True),
|
||||
pod=dict(type='str'), # This parameter is not required for querying all objects
|
||||
leaf=dict(type='str', aliases=['name']),
|
||||
vlan=dict(type='int'),
|
||||
state=dict(type='str', default='present', choices=['absent', 'present', 'query']),
|
||||
|
@ -149,8 +154,8 @@ def main():
|
|||
argument_spec=argument_spec,
|
||||
supports_check_mode=True,
|
||||
required_if=[
|
||||
['state', 'absent', ['leaf', 'vlan']],
|
||||
['state', 'present', ['leaf', 'vlan']],
|
||||
['state', 'absent', ['pod', 'leaf', 'vlan']],
|
||||
['state', 'present', ['pod', 'leaf', 'vlan']],
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -159,10 +164,13 @@ def main():
|
|||
template = module.params['template']
|
||||
anp = module.params['anp']
|
||||
epg = module.params['epg']
|
||||
pod = module.params['pod']
|
||||
leaf = module.params['leaf']
|
||||
vlan = module.params['vlan']
|
||||
state = module.params['state']
|
||||
|
||||
leafpath = 'topology/{0}/node-{1}'.format(pod, leaf)
|
||||
|
||||
mso = MSOModule(module)
|
||||
|
||||
# Get schema_id
|
||||
|
@ -202,8 +210,8 @@ def main():
|
|||
|
||||
# Get Leaf
|
||||
leafs = [(l['path'], l['portEncapVlan']) for l in schema_obj['sites'][site_idx]['anps'][anp_idx]['epgs'][epg_idx]['staticLeafs']]
|
||||
if (leaf, vlan) in leafs:
|
||||
leaf_idx = leafs.index((leaf, vlan))
|
||||
if (leafpath, vlan) in leafs:
|
||||
leaf_idx = leafs.index((leafpath, vlan))
|
||||
# FIXME: Changes based on index are DANGEROUS
|
||||
leaf_path = '/sites/{0}/anps/{1}/epgs/{2}/staticLeafs/{3}'.format(site_template, anp, epg, leaf_idx)
|
||||
mso.existing = schema_obj['sites'][site_idx]['anps'][anp_idx]['epgs'][epg_idx]['staticLeafs'][leaf_idx]
|
||||
|
@ -226,7 +234,7 @@ def main():
|
|||
|
||||
elif state == 'present':
|
||||
payload = dict(
|
||||
path=leaf,
|
||||
path=leafpath,
|
||||
portEncapVlan=vlan,
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue