From f80f795e8c4a36ba07c6b0fd2d52bfc5fcafe4b4 Mon Sep 17 00:00:00 2001 From: marcusgc Date: Thu, 18 Jul 2024 14:20:20 -0300 Subject: [PATCH 1/4] workaround bug bugged db table. do not create prefix-list for bgp route-maps in switches --- networkapi/api_neighbor/models.py | 12 +++++---- networkapi/api_rack/rackenvironments.py | 28 +++++++++++++++++---- networkapi/plugins/Dell/FTOS/BGP/Cli.py | 4 +-- networkapi/plugins/Juniper/JUNOS/BGP/Cli.py | 12 ++++----- 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/networkapi/api_neighbor/models.py b/networkapi/api_neighbor/models.py index cf85a476f..5a8c6b21d 100644 --- a/networkapi/api_neighbor/models.py +++ b/networkapi/api_neighbor/models.py @@ -271,10 +271,12 @@ def deploy(self): list_config_bgp=entry.list_config_bgp ) if not eqpt_list_config: - EquipmentListConfig().create_v4({ - 'equipment': equipment.id, - 'list_config_bgp': entry.list_config_bgp.id - }) + self.log.debug('equipment id %s' % equipment.id) + self.log.debug('id_list_config_bgp %s' % entry.list_config_bgp.id) + # EquipmentListConfig().create_v4({ + # 'equipment': equipment.id, + # 'list_config_bgp': entry.list_config_bgp.id + # }) def undeploy(self): """Undeploy NeighborV4.""" @@ -611,7 +613,7 @@ def deploy(self): 'route_map': route_map_out.id }) - entries = route_map_out.route_map_entries | route_map_in.route_map_entries + entries = route_map_out.route_map_entries | route_map_in.:619: for entry in entries: eqpt_list_config = EquipmentListConfig.objects.filter( equipment=equipment, diff --git a/networkapi/api_rack/rackenvironments.py b/networkapi/api_rack/rackenvironments.py index 945f80326..ee6b709a4 100644 --- a/networkapi/api_rack/rackenvironments.py +++ b/networkapi/api_rack/rackenvironments.py @@ -56,12 +56,14 @@ def spines_environment_save(self): environment_spn_lf_list = list() spines = int(self.rack.dcroom.spines) fabric = self.rack.dcroom.name + rackname = self.rack.nome + grupoL3name = fabric+"_"+racknome try: - id_grupo_l3 = models_env.GrupoL3().get_by_name(fabric).id + id_grupo_l3 = models_env.GrupoL3().get_by_name(grupoL3name).id except: grupo_l3_dict = models_env.GrupoL3() - grupo_l3_dict.nome = fabric + grupo_l3_dict.nome = grupoL3name grupo_l3_dict.save() id_grupo_l3 = grupo_l3_dict.id pass @@ -483,13 +485,29 @@ def manage_vlan_save(self): def rack_environment_remove(self): log.info("_remove_envs") - envs = models_env.Ambiente.objects.filter(dcroom=int(self.rack.dcroom.id), + envs_racks = models_env.Ambiente.objects.filter(dcroom=int(self.rack.dcroom.id), grupo_l3__nome=str(self.rack.nome)) - for env in envs: + log.debug("PROD RACK environments to be removed: %s. Total: %s" % (str(envs_racks), len(envs_racks))) + + for env in envs_racks: + env.delete_v3() + + log.debug("PROD RACK environments removed.") + + envs_spines = models_env.Ambiente.objects.filter(dcroom=int(rack.dcroom.id), + grupo_l3__nome=str(rack.dcroom.name), + ambiente_logico__nome__in=["SPINE01LEAF", + "SPINE02LEAF", + "SPINE03LEAF", + "SPINE04LEAF"]) + + log.debug("PROD SPINELEAF environments to be removed: %s. Total: %s" % (str(envs_spines), len(envs_spines))) + + for env in envs_spines: env.delete_v3() - log.debug("PROD environments: %s. Total: %s" % (str(envs), len(envs))) + log.debug("PROD SPINELEAF environments removed.") def rack_vlans_remove(self): log.info("remove_vlans") diff --git a/networkapi/plugins/Dell/FTOS/BGP/Cli.py b/networkapi/plugins/Dell/FTOS/BGP/Cli.py index 811f2aba2..1028b77ac 100644 --- a/networkapi/plugins/Dell/FTOS/BGP/Cli.py +++ b/networkapi/plugins/Dell/FTOS/BGP/Cli.py @@ -76,8 +76,8 @@ def _deploy_pre_req(self, neighbor): for rm_entry in rms: list_config_bgp = rm_entry.list_config_bgp - if not list_config_bgp.equipments.filter(id=self.equipment.id): - self.deploy_list_config_bgp(list_config_bgp) + # if not list_config_bgp.equipments.filter(id=self.equipment.id): + # self.deploy_list_config_bgp(list_config_bgp) if not route_map_in.equipments.filter(id=self.equipment.id): self.deploy_route_map(neighbor.peer_group.route_map_in) diff --git a/networkapi/plugins/Juniper/JUNOS/BGP/Cli.py b/networkapi/plugins/Juniper/JUNOS/BGP/Cli.py index b99ca5172..7a35e7d4b 100644 --- a/networkapi/plugins/Juniper/JUNOS/BGP/Cli.py +++ b/networkapi/plugins/Juniper/JUNOS/BGP/Cli.py @@ -65,14 +65,14 @@ def _deploy_pre_req(self, neighbor): route_map_out.route_map_entries for rm_entry in rms: list_config_bgp = rm_entry.list_config_bgp - if not list_config_bgp.equipments.filter(id=self.equipment.id): - self.deploy_list_config_bgp(list_config_bgp) + # if not list_config_bgp.equipments.filter(id=self.equipment.id): + # self.deploy_list_config_bgp(list_config_bgp) - if not route_map_in.equipments.filter(id=self.equipment.id): - self.deploy_route_map(neighbor.peer_group.route_map_in) + # if not route_map_in.equipments.filter(id=self.equipment.id): + # self.deploy_route_map(neighbor.peer_group.route_map_in) - if not route_map_out.equipments.filter(id=self.equipment.id): - self.deploy_route_map(neighbor.peer_group.route_map_out) + # if not route_map_out.equipments.filter(id=self.equipment.id): + # self.deploy_route_map(neighbor.peer_group.route_map_out) def _undeploy_pre_req(self, neighbor, ip_version): log.info("_undeploy_pre_req") From 8fd248d167852d390a0600059443da328200acff Mon Sep 17 00:00:00 2001 From: marcusgc Date: Thu, 18 Jul 2024 14:37:55 -0300 Subject: [PATCH 2/4] fix mistypo --- networkapi/api_neighbor/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/networkapi/api_neighbor/models.py b/networkapi/api_neighbor/models.py index 5a8c6b21d..036775ca6 100644 --- a/networkapi/api_neighbor/models.py +++ b/networkapi/api_neighbor/models.py @@ -613,7 +613,7 @@ def deploy(self): 'route_map': route_map_out.id }) - entries = route_map_out.route_map_entries | route_map_in.:619: + entries = route_map_out.route_map_entries | route_map_in.route_map_entries for entry in entries: eqpt_list_config = EquipmentListConfig.objects.filter( equipment=equipment, From 5357135af30826817f5ec1beb7e4efa63f4b037b Mon Sep 17 00:00:00 2001 From: Renan Lopes Date: Mon, 22 Jul 2024 10:59:13 -0300 Subject: [PATCH 3/4] added reck_num variable to add rack template --- networkapi/api_rack/autoprovision.py | 1 + 1 file changed, 1 insertion(+) diff --git a/networkapi/api_rack/autoprovision.py b/networkapi/api_rack/autoprovision.py index 61648ccf9..56dc63d4c 100644 --- a/networkapi/api_rack/autoprovision.py +++ b/networkapi/api_rack/autoprovision.py @@ -511,6 +511,7 @@ def autoprovision_splf(rack, equips): variablestochangespine1["ASLEAF"] = str(ASLEAF[numero_rack][0]) variablestochangespine1["IPNEIGHLEAFIPV4"] = str(IPLEAFipv4[numero_rack][spine_num-1]) variablestochangespine1["IPNEIGHLEAFIPV6"] = str(IPLEAFipv6[numero_rack][spine_num-1]) + variablestochangespine1["RACK_NUM"] = str(numero_rack) if spine_num in [1, 3]: variablestochangeleaf1["SP1_HOSTNAME"] = i.get("nome") variablestochangeleaf1["INTERFACE_SP1"] = i.get("interface") From 83ecc1706dd9a5731b34dba6d9a9d94c3a2b90a5 Mon Sep 17 00:00:00 2001 From: Renan Lopes Date: Tue, 23 Jul 2024 09:33:44 -0300 Subject: [PATCH 4/4] fixed model --- networkapi/api_list_config_bgp/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/networkapi/api_list_config_bgp/models.py b/networkapi/api_list_config_bgp/models.py index 50bafab6c..45f95650b 100644 --- a/networkapi/api_list_config_bgp/models.py +++ b/networkapi/api_list_config_bgp/models.py @@ -156,7 +156,7 @@ class EquipmentListConfig(BaseModel): ) list_config_bgp = models.ForeignKey( 'api_list_config_bgp.ListConfigBGP', - db_column='id' + db_column='id_list_config_bgp' ) class Meta(BaseModel.Meta):