aci_switch_leaf_selector: Support missing policy_group (#47992)

* aci_switch_leaf_selector: Support empty policy_group

* Reorganize code

* Adapt integration tests to fix
This commit is contained in:
Dag Wieers 2018-11-05 19:02:06 +01:00 committed by GitHub
parent ee13bc248b
commit 591b074e43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 20 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- aci_switch_leaf_selector - Support empty policy_group

View file

@ -260,6 +260,30 @@ def main():
policy_group = module.params['policy_group']
state = module.params['state']
# Build child_configs dynamically
child_configs = [
dict(
infraNodeBlk=dict(
attributes=dict(
descr=leaf_node_blk_description,
name=leaf_node_blk,
from_=from_,
to_=to_,
),
),
),
]
# Add infraRsAccNodePGrp only when policy_group was defined
if policy_group is not None:
child_configs.append(dict(
infraRsAccNodePGrp=dict(
attributes=dict(
tDn='uni/infra/funcprof/accnodepgrp-{0}'.format(policy_group),
),
),
))
aci = ACIModule(module)
aci.construct_url(
root_class=dict(
@ -289,25 +313,7 @@ def main():
descr=description,
name=leaf,
),
child_configs=[
dict(
infraNodeBlk=dict(
attributes=dict(
descr=leaf_node_blk_description,
name=leaf_node_blk,
from_=from_,
to_=to_,
),
),
),
dict(
infraRsAccNodePGrp=dict(
attributes=dict(
tDn='uni/infra/funcprof/accnodepgrp-{0}'.format(policy_group),
),
),
),
],
child_configs=child_configs,
)
aci.get_diff(aci_class='infraLeafS')

View file

@ -68,7 +68,7 @@
- sw_leaf_selec_check_mode_present is changed
- sw_leaf_selec_present is changed
- sw_leaf_selec_present.previous == []
- 'sw_leaf_selec_present.sent == {"infraLeafS": {"attributes": {"name": "leaf_selector_name"}, "children": [{"infraNodeBlk": {"attributes": {"from_": "1011", "name": "node_blk_name", "to_": "1011"}}},{"infraRsAccNodePGrp": {"attributes": {"tDn": "uni/infra/funcprof/accnodepgrp-None"}}}]}}'
- 'sw_leaf_selec_present.sent == {"infraLeafS": {"attributes": {"name": "leaf_selector_name"}, "children": [{"infraNodeBlk": {"attributes": {"from_": "1011", "name": "node_blk_name", "to_": "1011"}}}]}}'
- sw_leaf_selec_idempotent is not changed
- sw_leaf_selec_idempotent.sent == {}
- sw_leaf_selec_update is changed