diff --git a/catalystwan/models/configuration/feature_profile/sdwan/system/aaa.py b/catalystwan/models/configuration/feature_profile/sdwan/system/aaa.py index a30479fa..476bae9a 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/system/aaa.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/system/aaa.py @@ -9,9 +9,7 @@ class PubkeyChainItem(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) + model_config = ConfigDict(extra="forbid", populate_by_name=True) key_string: Global[str] = Field( validation_alias="keyString", serialization_alias="keyString", @@ -30,7 +28,6 @@ class PubkeyChainItem(BaseModel): class UserItem(BaseModel): model_config = ConfigDict(extra="ignore", populate_by_name=True) - model_config = ConfigDict(extra="ignore", populate_by_name=True) name: Union[Global[str], Variable] = Field(description="Set the username") password: Union[Global[str], Variable] = Field( @@ -113,8 +110,7 @@ class RadiusServerItem(BaseModel): class Radius(BaseModel): - model_config = ConfigDict(extra="ignore", populate_by_name=True) - model_config = ConfigDict(extra="ignore", populate_by_name=True) + model_config = ConfigDict(extra="forbid", populate_by_name=True) group_name: Global[str] = Field( validation_alias="groupName", serialization_alias="groupName", description="Set Radius server Group Name" ) @@ -264,6 +260,7 @@ class AuthorizationRuleItem(BaseModel): class AAAParcel(_ParcelBase): type_: Literal["aaa"] = Field(default="aaa", exclude=True) + model_config = ConfigDict(extra="forbid", populate_by_name=True) authentication_group: Union[Variable, Global[bool], Default[bool]] = Field( default=as_default(False), validation_alias=AliasPath("data", "authenticationGroup"), diff --git a/catalystwan/utils/config_migration/converters/feature_template/aaa.py b/catalystwan/utils/config_migration/converters/feature_template/aaa.py index afe533c3..e3503606 100644 --- a/catalystwan/utils/config_migration/converters/feature_template/aaa.py +++ b/catalystwan/utils/config_migration/converters/feature_template/aaa.py @@ -33,12 +33,12 @@ def assign_rules(rules: List) -> None: for rule_item in rules: rule_item["group"] = Global[List[str]](value=rule_item["group"].value.split(",")) - parcel_values = deepcopy(template_values) + parcel_values = deepcopy(template_values["aaa"]) parcel_values["parcel_name"] = name parcel_values["parcel_description"] = description - - if server_auth_order := template_values.get("server_auth_order"): - parcel_values["server_auth_order"] = Global[List[str]](value=server_auth_order.value.split(",")) + print(parcel_values) + if server_auth_order := parcel_values.get("auth_order"): + parcel_values["server_auth_order"] = server_auth_order for server in ["radius", "tacacs"]: if auth_server_list := parcel_values.get(server): @@ -56,6 +56,10 @@ def assign_rules(rules: List) -> None: "auth_type", "port", "cts_auth_list", + "auth_order", + "usergroup", + "ciscotacro_user", + "ciscotacrw_user", ]: parcel_values.pop(key, None) diff --git a/catalystwan/utils/config_migration/converters/feature_template/factory_method.py b/catalystwan/utils/config_migration/converters/feature_template/factory_method.py index afcb71ed..b42d1ba1 100644 --- a/catalystwan/utils/config_migration/converters/feature_template/factory_method.py +++ b/catalystwan/utils/config_migration/converters/feature_template/factory_method.py @@ -5,7 +5,7 @@ from catalystwan.api.template_api import FeatureTemplateInformation from catalystwan.exceptions import CatalystwanException from catalystwan.models.configuration.feature_profile.sdwan.system import AnySystemParcel -from catalystwan.utils.feature_template import find_template_values +from catalystwan.utils.feature_template.find_template_values import find_template_values from .aaa import AAATemplateConverter from .banner import BannerTemplateConverter @@ -76,6 +76,7 @@ def create_parcel_from_template(template: FeatureTemplateInformation) -> AnySyst converter = choose_parcel_converter(template.template_type) template_definition_as_dict = json.loads(cast(str, template.template_definiton)) template_values = find_template_values(template_definition_as_dict) + print(template_values) template_values_normalized = template_definition_normalization(template_values) logger.debug(f"Normalized template {template.name}: {template_values_normalized}") return converter.create_parcel(template.name, template.description, template_values_normalized)