Skip to content

Commit 1760c3c

Browse files
committed
Update prepare_msite_data.py
1 parent 5806ac2 commit 1760c3c

1 file changed

Lines changed: 29 additions & 15 deletions

File tree

plugins/action/dtc/prepare_msite_data.py

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,25 +172,39 @@ def run(self, tmp=None, task_vars=None):
172172
tor_fabrics = {}
173173
for switch in all_child_fabric_switches:
174174
if switch['role'] == 'tor' and switch['fabric_name'] not in tor_fabrics:
175-
tor_fabrics[switch['fabric_name']] = switch['serial_number'], switch['fabric_cluster']
175+
if parent_fabric_type == 'MCFG':
176+
tor_fabrics[switch['fabric_name']] = switch['serial_number'], switch['fabric_cluster']
177+
else:
178+
tor_fabrics[switch['fabric_name']] = (switch['serial_number'])
176179

177180
tor_ndfc_responses = {}
178181
if tor_fabrics != {}:
179182
for fabric in tor_fabrics.keys():
180-
proxy = ''
181-
if version_compare(nd_major_minor_patch, '3.2.2', '<='):
182-
proxy = f'/onepath/{tor_fabrics[fabric][1]}'
183-
elif version_compare(nd_major_minor_patch, '4.1.1', '>='):
184-
proxy = f'/fedproxy/{tor_fabrics[fabric][1]}'
185-
tor_response = self._execute_module(
186-
module_name="cisco.dcnm.dcnm_rest",
187-
module_args={
188-
"method": "GET",
189-
"path": f"{proxy}/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/tor/fabrics/{fabric}/switches/{tor_fabrics[fabric][0]}",
190-
},
191-
task_vars=task_vars,
192-
tmp=tmp
193-
)
183+
if parent_fabric_type == 'MCFG':
184+
proxy = ''
185+
if version_compare(nd_major_minor_patch, '3.2.2', '<='):
186+
proxy = f'/onepath/{tor_fabrics[fabric][1]}'
187+
elif version_compare(nd_major_minor_patch, '4.1.1', '>='):
188+
proxy = f'/fedproxy/{tor_fabrics[fabric][1]}'
189+
tor_response = self._execute_module(
190+
module_name="cisco.dcnm.dcnm_rest",
191+
module_args={
192+
"method": "GET",
193+
"path": f"{proxy}/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/tor/fabrics/{fabric}/switches/{tor_fabrics[fabric][0]}",
194+
},
195+
task_vars=task_vars,
196+
tmp=tmp
197+
)
198+
else:
199+
tor_response = self._execute_module(
200+
module_name="cisco.dcnm.dcnm_rest",
201+
module_args={
202+
"method": "GET",
203+
"path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/tor/fabrics/{fabric}/switches/{tor_fabrics[fabric]}",
204+
},
205+
task_vars=task_vars,
206+
tmp=tmp
207+
)
194208
if 'response' in tor_response and 'DATA' in tor_response['response']:
195209
tor_ndfc_responses = []
196210
for pair in tor_response['response']['DATA']['torPairs']:

0 commit comments

Comments
 (0)