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

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sbasan committed Feb 23, 2024
1 parent bf4bb0e commit 0609a0a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from pydantic import AliasPath, BaseModel, ConfigDict, Field, field_validator

from catalystwan.api.configuration_groups.parcel import Global, _ParcelBase, as_global
from catalystwan.models.policy.lists_entries import PolicerExceedAction

PolicerExceedAction = Literal[
"drop",
"remark",
]


class PolicierEntry(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

from catalystwan.api.configuration_groups.parcel import Global, _ParcelBase, as_global
from catalystwan.models.common import TLOCColor
from catalystwan.models.policy.lists_entries import PathPreference

PathPreference = Literal[
"direct-path",
"multi-hop-path",
"all-paths",
]


class Preference(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

from catalystwan.api.configuration_groups.parcel import Global, _ParcelBase, as_global
from catalystwan.models.common import TLOCColor
from catalystwan.models.policy.lists_entries import EncapType

EncapType = Literal[
"ipsec",
"gre",
]


class TlocEntry(BaseModel):
Expand Down
28 changes: 27 additions & 1 deletion catalystwan/models/policy/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
DataPrefixEntry,
DataPrefixParcel,
)
from catalystwan.models.configuration.feature_profile.sdwan.policy_object.policy.tloc_list import TlocParcel
from catalystwan.models.configuration.feature_profile.sdwan.policy_object.security.zone import SecurityZoneListParcel
from catalystwan.models.policy.lists_entries import (
AppListEntry,
AppProbeClassListEntry,
Expand Down Expand Up @@ -61,7 +63,7 @@ def _add_entry(self, entry: Any, single: bool = False) -> None:
self.entries.append(entry)

def to_policy_object_parcel(self) -> Optional[AnyPolicyObjectParcel]:
raise NotImplementedError
return None


class DataPrefixList(PolicyListBase):
Expand Down Expand Up @@ -107,6 +109,9 @@ def add_vpn_range(self, vpn_range: Tuple[int, int]):
entry = VPNListEntry(vpn=f"{vpn_range[0]}-{vpn_range[1]}")
self._add_entry(entry)

def to_policy_object_parcel(self) -> None:
return None


class ZoneList(PolicyListBase):
type: Literal["zone"] = "zone"
Expand All @@ -118,6 +123,18 @@ def assign_vpns(self, vpns: Set[int]) -> None:
def assign_interfaces(self, ifs: Set[InterfaceType]) -> None:
self.entries = [ZoneListEntry(interface=interface) for interface in ifs]

def to_policy_object_parcel(self) -> SecurityZoneListParcel:
parcel = SecurityZoneListParcel(
parcel_name=self.name,
parcel_description=self.description,
)
for e in self.entries:
if e.vpn is not None:
parcel.add_vpn(e.vpn)
if e.interface is not None:
parcel.add_interface(e.interface)
return parcel


class FQDNList(PolicyListBase):
type: Literal["fqdn"] = "fqdn"
Expand Down Expand Up @@ -290,6 +307,15 @@ def add_tloc(self, tloc: IPv4Address, color: TLOCColor, encap: EncapType, prefer
_preference = str(preference) if preference is not None else None
self.entries.append(TLOCListEntry(tloc=tloc, color=color, encap=encap, preference=_preference))

def to_policy_object_parcel(self) -> TlocParcel:
parcel = TlocParcel(
parcel_name=self.name,
parcel_description=self.description,
)
for i in self.entries:
parcel.add_entry(i.tloc, i.color, i.encap, i.preference)
return parcel


class PreferredColorGroupList(PolicyListBase):
type: Literal["preferredColorGroup"] = "preferredColorGroup"
Expand Down
2 changes: 1 addition & 1 deletion endpoints-md.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def md(self) -> str:

# this instantiates APIEndpoints classes triggering method decorators
# endpoints not attached to container will be not documented !
_ = APIEndpointContainter(MagicMock())
APIEndpointContainter(MagicMock())

endpoint_registry = EndpointRegistry(
meta_lookup=request.request_lookup,
Expand Down

0 comments on commit 0609a0a

Please sign in to comment.