Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A static leaf is build from the pod id and leaf id #55120

Merged
merged 1 commit into from
Apr 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
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.
Expand Down Expand Up @@ -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']),
Expand All @@ -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']],
],
)

Expand All @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -226,7 +234,7 @@ def main():

elif state == 'present':
payload = dict(
path=leaf,
path=leafpath,
portEncapVlan=vlan,
)

Expand Down