From 9b8a53ad33616948493183be080168650fb4b511 Mon Sep 17 00:00:00 2001 From: Szymon Basan <116343782+sbasan@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:55:13 +0200 Subject: [PATCH] fix: lookup update, empty vpn list condition check (#752) --- ENDPOINTS.md | 2 +- .../feature_profile/sdwan/topology/custom_control.py | 2 +- .../converters/policy/policy_definitions.py | 6 ++++++ .../utils/config_migration/creators/config_pusher.py | 2 +- pyproject.toml | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ENDPOINTS.md b/ENDPOINTS.md index ca680759..716579b4 100644 --- a/ENDPOINTS.md +++ b/ENDPOINTS.md @@ -1,6 +1,6 @@ **THIS FILE WAS AUTO-GENERATED DO NOT EDIT** -Generated for: catalystwan-0.33.8.dev3 +Generated for: catalystwan-0.33.8.dev4 All URIs are relative to */dataservice* HTTP request | Supported Versions | Method | Payload Type | Return Type | Tenancy Mode diff --git a/catalystwan/models/configuration/feature_profile/sdwan/topology/custom_control.py b/catalystwan/models/configuration/feature_profile/sdwan/topology/custom_control.py index 9c5f3c16..7a848a0d 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/topology/custom_control.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/topology/custom_control.py @@ -314,7 +314,7 @@ def assign_target( self.target = Target( inbound_sites=as_global(inbound_sites) if inbound_sites else None, outbound_sites=as_global(outbound_sites) if outbound_sites else None, - vpn=as_global(vpns), + vpn=Global[List[str]](value=vpns), ) return self.target diff --git a/catalystwan/utils/config_migration/converters/policy/policy_definitions.py b/catalystwan/utils/config_migration/converters/policy/policy_definitions.py index f9fa9fbd..240c3e6b 100644 --- a/catalystwan/utils/config_migration/converters/policy/policy_definitions.py +++ b/catalystwan/utils/config_migration/converters/policy/policy_definitions.py @@ -211,6 +211,8 @@ def target_vpn_convert(target_vpn: TargetVpn, vpn_id_to_map: Dict[Union[str, int def hubspoke(in_: HubAndSpokePolicy, uuid: UUID, context: PolicyConvertContext) -> ConvertResult[HubSpokeParcel]: target_vpns = context.lan_vpns_by_list_id[in_.definition.vpn_list] + if not target_vpns: + return ConvertResult[HubSpokeParcel](status="failed", info=["No VPNs found matching VPN list assignment"]) out = HubSpokeParcel(**_get_parcel_name_desc(in_)) out.target.vpn.value.extend(target_vpns) for isubdef in in_.definition.sub_definitions: @@ -568,10 +570,14 @@ def route(in_: RoutePolicy, uuid: UUID, context: PolicyConvertContext) -> Conver def mesh(in_: MeshPolicy, uuid: UUID, context: PolicyConvertContext) -> ConvertResult[MeshParcel]: target_vpns = context.lan_vpns_by_list_id[in_.definition.vpn_list] + if not target_vpns: + return ConvertResult[MeshParcel](status="failed", info=["No VPNs found matching VPN list assignment"]) mesh_sites: List[str] = [] for region in in_.definition.regions: for site_list in region.site_lists: mesh_sites.extend(context.sites_by_list_id[site_list]) + if not mesh_sites: + return ConvertResult[MeshParcel](status="failed", info=["No Sites found matching Site list assignment"]) out = MeshParcel(**_get_parcel_name_desc(in_)) out.target.vpn.value = target_vpns out.sites.value = mesh_sites diff --git a/catalystwan/utils/config_migration/creators/config_pusher.py b/catalystwan/utils/config_migration/creators/config_pusher.py index b0ba81a2..7a04c5af 100644 --- a/catalystwan/utils/config_migration/creators/config_pusher.py +++ b/catalystwan/utils/config_migration/creators/config_pusher.py @@ -221,6 +221,7 @@ def _create_topology_groups(self, default_policy_object_profile_id: Optional[UUI try: parcel_id = profile_api.create_parcel(profile_id, parcel).id profile_report.add_created_parcel(parcel_name=parcel.parcel_name, parcel_uuid=parcel_id) + self._push_context.id_lookup[transformed_parcel.header.origin] = parcel_id except ManagerHTTPError as e: logger.error(f"Error occured during topology profile parcel creation: {e}") profile_report.add_failed_parcel( @@ -229,6 +230,5 @@ def _create_topology_groups(self, default_policy_object_profile_id: Optional[UUI error_info=e.info, request=e.request, ) - self._push_context.id_lookup[transformed_parcel.header.origin] = parcel_id else: logger.warning(f"Unexpected parcel type {type(parcel)}") diff --git a/pyproject.toml b/pyproject.toml index d2ac7939..cc42e8c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "catalystwan" -version = "0.33.8dev3" +version = "0.33.8dev4" description = "Cisco Catalyst WAN SDK for Python" authors = ["kagorski "] readme = "README.md"