From 7de09a46521e0c2e31f851b1070c5fe8bf79611d Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Fri, 2 Nov 2018 18:30:32 +0100 Subject: [PATCH] Reorganize code --- .../network/aci/aci_switch_leaf_selector.py | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/ansible/modules/network/aci/aci_switch_leaf_selector.py b/lib/ansible/modules/network/aci/aci_switch_leaf_selector.py index 42e3286fe6f..6544b7e9262 100644 --- a/lib/ansible/modules/network/aci/aci_switch_leaf_selector.py +++ b/lib/ansible/modules/network/aci/aci_switch_leaf_selector.py @@ -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( @@ -283,30 +307,6 @@ def main(): aci.get_existing() if state == 'present': - # 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.payload( aci_class='infraLeafS', class_config=dict(