Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix import for factory method, change converter AAA
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkrajewski committed Mar 7, 2024
1 parent 9fee3e6 commit b01c307
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(
Expand Down Expand Up @@ -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"
)
Expand Down Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit b01c307

Please sign in to comment.