Skip to content

Commit

Permalink
Merge pull request #432 from globocom/develop
Browse files Browse the repository at this point in the history
better variables
  • Loading branch information
renan-lopes-rodrigues authored Jul 26, 2024
2 parents ceed523 + 35f1613 commit b02f657
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions networkapi/api_rack/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,19 +509,23 @@ def spine_provision(self, rack, equips):
if iface_name[:3] == self.spine_prefix and int(iface_name[-1]) == 2:
variablestochangespine1["SINGLE2{}INT".format(interface2_counter)] = iface.get("interface")
variablestochangespine1["INT_LF_2{}UPLINK".format(interface2_counter)] = iface.get("eq_interface")
variablestochangespine1["DESCRIPTION1CONNECT"] = equips_sorted[0].get("nome")
variablestochangespine1["DESCRIPTION2CONNECT"] = equips_sorted[1].get("nome")
# variablestochangespine1["DESCRIPTION1CONNECT"] = equips_sorted[1].get("nome")
variablestochangespine1["DESCRIPTION2CONNECT"] = equips_sorted[0].get("nome")
variablestochangespine1["DESCRIPTION1CONNECT"] = equips_sorted[1].get("nome")
variablestochangespine1["PO2CHANNEL"] = variablestochangespine1["SINGLE21INT".format(interface2_counter)].split('/')[-1].split(':')[0]

interface2_counter += 1
# variablestochangespine1["SINGLE2{}INT".format(interface_counter)] = iface.get("interface")

elif iface_name[:3] == self.spine_prefix and int(iface_name[-1]) == 1:
variablestochangespine1["SINGLE1{}INT".format(interface1_counter)] = iface.get("interface")
variablestochangespine1["INT_LF_1{}UPLINK".format(interface1_counter)] = iface.get("eq_interface")
variablestochangespine1["PO1CHANNEL"] = variablestochangespine1["SINGLE11INT".format(interface2_counter)].split('/')[-1].split(':')[0]

# variablestochangespine1["SINGLE2{}INT".format(interface_counter)] = iface.get("interface")
variablestochangespine1["DESCRIPTION1CONNECT"] = equips_sorted[0].get("nome")
variablestochangespine1["DESCRIPTION2CONNECT"] = equips_sorted[1].get("nome")
interface1_counter += 1
variablestochangespine1["DESCRIPTION1CONNECT"] = equips_sorted[1].get("nome")
variablestochangespine1["DESCRIPTION2CONNECT"] = equips_sorted[0].get("nome")
#### END to Berrini Block #####

variablestochangespine1["IPNEIGHLEAFIPV4"] = str(IPLEAFipv4[numero_rack][spine_num - 1])
Expand All @@ -538,6 +542,21 @@ def spine_provision(self, rack, equips):

fileinspine1 = path_to_guide + i.get("roteiro")
fileoutspine1 = path_to_add_config + i.get("nome") + "-ADD-" + rack.nome + ".cfg"
log.debug(i.get("nome"[-1]))
# if self.spine_prefix in fileinspine1 and spine_num in fileinspine1 and spine_num == 1:
if int(i.get("nome")[-1]) == 1:
spn_int_desc1 = variablestochangespine1["DESCRIPTION2CONNECT"]
spn_int_desc2 = variablestochangespine1["DESCRIPTION1CONNECT"]
variablestochangespine1["DESCRIPTION1CONNECT"] = spn_int_desc2
variablestochangespine1["DESCRIPTION2CONNECT"] = spn_int_desc1

# if self.spine_prefix in fileinspine1 and spine_num in fileinspine1 and spine_num == 2:
if int(i.get("nome")[-1]) == 2:
spn_int_desc1 = variablestochangespine1["DESCRIPTION2CONNECT"]
spn_int_desc2 = variablestochangespine1["DESCRIPTION1CONNECT"]
variablestochangespine1["DESCRIPTION2CONNECT"] = spn_int_desc2
variablestochangespine1["DESCRIPTION1CONNECT"] = spn_int_desc1

self.replace_file(fileinspine1, fileoutspine1, variablestochangespine1)
variablestochangespine1 = dict()

Expand Down

0 comments on commit b02f657

Please sign in to comment.