diff --git a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/standard_community.py b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/standard_community.py index ae7d1f72..62a35c9f 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/standard_community.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/standard_community.py @@ -10,7 +10,7 @@ class StandardCommunityEntry(BaseModel): model_config = ConfigDict(populate_by_name=True) - standard_community: Global[WellKnownBGPCommunities] = Field( + standard_community: Global[str] = Field( serialization_alias="standardCommunity", validation_alias="standardCommunity" ) @@ -19,7 +19,11 @@ class StandardCommunityParcel(_ParcelBase): type_: Literal["standard-community"] = Field(default="standard-community", exclude=True) entries: List[StandardCommunityEntry] = Field(default=[], validation_alias=AliasPath("data", "entries")) - def add_community(self, standard_community: WellKnownBGPCommunities): - self.entries.append( - StandardCommunityEntry(standard_community=as_global(standard_community, WellKnownBGPCommunities)) - ) + def _add_community(self, standard_community: str): + self.entries.append(StandardCommunityEntry(standard_community=as_global(standard_community))) + + def add_well_known_community(self, standard_community: WellKnownBGPCommunities): + self._add_community(standard_community) + + def add_community(self, as_number: int, community_number: int) -> None: + self._add_community(f"{as_number}:{community_number}") diff --git a/catalystwan/utils/config_migration/converters/policies/policy_lists.py b/catalystwan/utils/config_migration/converters/policies/policy_lists.py index 11d7beb8..be30adef 100644 --- a/catalystwan/utils/config_migration/converters/policies/policy_lists.py +++ b/catalystwan/utils/config_migration/converters/policies/policy_lists.py @@ -94,6 +94,8 @@ def color(in_: ColorList) -> ColorParcel: def community(in_: CommunityList) -> StandardCommunityParcel: out = StandardCommunityParcel(**_get_parcel_name_desc(in_)) + for entry in in_.entries: + out._add_community(entry.community) return out