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

multiple fixes for push/rollback demo #538

Merged
merged 4 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion catalystwan/api/configuration_groups/parcel.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Default(ParcelAttribute, Generic[T]):
option_type: OptionType = Field(
default=OptionType.DEFAULT, serialization_alias="optionType", validation_alias="optionType"
)
value: Any
value: Optional[Any] = None


def as_global(value: Any, generic_alias: Any = None):
Expand Down
12 changes: 10 additions & 2 deletions catalystwan/models/configuration/config_migration.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright 2024 Cisco Systems, Inc. and its affiliates

from typing import List, Set, Tuple, Union
from typing import Any, Dict, List, Set, Tuple, Union
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field
from pydantic import BaseModel, ConfigDict, Field, model_validator
from typing_extensions import Annotated

from catalystwan.api.template_api import FeatureTemplateInformation
Expand Down Expand Up @@ -110,6 +110,14 @@ class UX2Config(BaseModel):
default=[], serialization_alias="profileParcels", validation_alias="profileParcels"
)

@model_validator(mode="before")
@classmethod
def insert_parcel_type_from_headers(cls, values: Dict[str, Any]):
profile_parcels = values.get("profileParcels", [])
for profile_parcel in profile_parcels:
profile_parcel["parcel"]["type_"] = profile_parcel["header"]["type"]
return values


class UX2ConfigRollback(BaseModel):
config_group_ids: List[UUID] = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BaseURLListEntry(BaseModel):

class URLParcel(_ParcelBase):
type_: Literal["security-urllist"] = Field(default="security-urllist", exclude=True)
parcel_type: Literal["urlallowed", "urlblocked"]
type: Literal["urlallowed", "urlblocked"]
entries: List[BaseURLListEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))

def add_url(self, pattern: str):
Expand All @@ -23,13 +23,9 @@ def add_url(self, pattern: str):

class URLAllowParcel(URLParcel):
type_: Literal["security-urllist"] = Field(default="security-urllist", exclude=True)
parcel_type: Literal["urlallowed"] = Field(
default="urlallowed", validation_alias="type", serialization_alias="type"
)
type: Literal["urlallowed"] = "urlallowed"


class URLBlockParcel(URLParcel):
type_: Literal["security-urllist"] = Field(default="security-urllist", exclude=True)
parcel_type: Literal["urlblocked"] = Field(
default="urlblocked", validation_alias="type", serialization_alias="type"
)
type: Literal["urlblocked"] = "urlblocked"
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ class SimpleParcelPusher(ParcelPusher):
def push(self, profile_uuid: UUID, parcel_uuids: List[UUID], mapping: Dict[UUID, TransformedParcel]):
# Parcels don't have references to other parcels, so we can create them directly
for parcel_uuid in parcel_uuids:
transformed_parcel = mapping[parcel_uuid]
transformed_parcel = mapping.get(parcel_uuid)
if transformed_parcel is None:
continue
self.api.create_parcel(profile_uuid, transformed_parcel.parcel) # type: ignore
12 changes: 6 additions & 6 deletions catalystwan/workflows/config_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"cisco_system",
"system-vsmart",
"system-vedge",
"cisco_bfd",
"bfd-vedge",
# "cisco_bfd",
# "bfd-vedge",
"cedge_global",
"cisco_logging",
"logging",
Expand Down Expand Up @@ -64,8 +64,8 @@
"cisco_system",
"system-vsmart",
"system-vedge",
"cisco_bfd",
"bfd-vedge",
# "cisco_bfd",
# "bfd-vedge",
"cedge_global",
"cisco_logging",
"logging",
Expand All @@ -74,8 +74,8 @@
"omp-vsmart",
"cisco_ntp",
"ntp",
"bgp",
"cisco_bgp",
# "bgp",
# "cisco_bgp",
"cisco_snmp",
]

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "catalystwan"
version = "0.31.2dev0"
version = "0.31.2dev1"
description = "Cisco Catalyst WAN SDK for Python"
authors = ["kagorski <[email protected]>"]
readme = "README.md"
Expand Down
Loading