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

Commit

Permalink
Dev/multicast (#22)
Browse files Browse the repository at this point in the history
* Add converters

* Add tests

* Fix model. Fix integration tests. Add unit test

* Fix formatting
  • Loading branch information
jpkrajewski authored Apr 15, 2024
1 parent 84b3226 commit cafc368
Show file tree
Hide file tree
Showing 5 changed files with 494 additions and 18 deletions.
126 changes: 126 additions & 0 deletions catalystwan/integration_tests/feature_profile/sdwan/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@
)
from catalystwan.models.configuration.feature_profile.sdwan.service.lan.svi import InterfaceSviParcel
from catalystwan.models.configuration.feature_profile.sdwan.service.lan.vpn import LanVpnParcel
from catalystwan.models.configuration.feature_profile.sdwan.service.multicast import (
AutoRpAttributes,
BsrCandidateAttributes,
IgmpAttributes,
IgmpInterfaceParameters,
LocalConfig,
MsdpAttributes,
MsdpPeer,
MsdpPeerAttributes,
MulticastBasicAttributes,
MulticastParcel,
PimAttributes,
PimBsrAttributes,
PimInterfaceParameters,
RPAnnounce,
RpDiscoveryScope,
SmmFlag,
SsmAttributes,
StaticJoin,
StaticRpAddress,
)
from catalystwan.models.configuration.feature_profile.sdwan.service.ospf import OspfParcel
from catalystwan.models.configuration.feature_profile.sdwan.service.ospfv3 import (
Ospfv3InterfaceParametres,
Expand Down Expand Up @@ -241,6 +262,111 @@ def test_when_fully_specified_values_switchport_expect_successful_post(self):
# Assert
assert parcel_id

def test_when_default_values_multicast_expect_successful_post(self):
# Arrange
multicast_parcel = MulticastParcel(
parcel_name="TestMulticastParcel",
parcel_description="Test Multicast Parcel",
basic=MulticastBasicAttributes(),
)
# Act
parcel_id = self.api.create_parcel(self.profile_uuid, multicast_parcel).id
# Assert
assert parcel_id

def test_when_fully_specified_values_multicast_expect_successful_post(self):
# Arrange
multicast_parcel = MulticastParcel(
parcel_name="TestMulticastParcel_FullySpecified",
parcel_description="Test Multicast Parcel",
basic=MulticastBasicAttributes(
spt_only=as_global(True),
local_config=LocalConfig(
local=as_global(True),
threshold=as_global(10),
),
),
igmp=IgmpAttributes(
interface=[
IgmpInterfaceParameters(
interface_name=as_global("GigabitEthernet0/0/0"),
version=as_global(2),
join_group=[
StaticJoin(
group_address=Global[IPv4Address](value=IPv4Address("239.255.255.255")),
)
],
)
]
),
pim=PimAttributes(
ssm=SsmAttributes(ssm_range_config=SmmFlag(enable_ssm_flag=as_global(True), range=as_global("20"))),
interface=[
PimInterfaceParameters(
interface_name=as_global("GigabitEthernet0/0/0"),
query_interval=as_global(10),
join_prune_interval=as_global(10),
)
],
rp_address=[
StaticRpAddress(
address=Global[IPv4Address](value=IPv4Address("40.2.3.1")),
access_list=as_global("TestAccessList"),
override=as_global(True),
)
],
auto_rp=AutoRpAttributes(
enable_auto_rp_flag=as_global(False),
send_rp_announce_list=[
RPAnnounce(interface_name=as_global("GigabitEthernet0/0/0"), scope=as_global(3))
],
send_rp_discovery=[
RPAnnounce(interface_name=as_global("GigabitEthernet0/0/0"), scope=as_global(3))
],
),
pim_bsr=PimBsrAttributes(
rp_candidate=[
RpDiscoveryScope(
interface_name=as_global("GigabitEthernet0/0/0"),
group_list=as_global("TestGroupList"),
interval=as_global(10),
priority=as_global(10),
)
],
bsr_candidate=[
BsrCandidateAttributes(
interface_name=as_global("GigabitEthernet0/0/0"),
mask=as_global(10),
priority=as_global(10),
accept_rp_candidate=as_global("True"),
)
],
),
),
msdp=MsdpAttributes(
msdp_list=[
MsdpPeer(
mesh_group=as_global("TestMeshGroup"),
peer=[
MsdpPeerAttributes(
peer_ip=Global[IPv4Address](value=IPv4Address("5.5.5.5")),
connect_source_intf=as_global("GigabitEthernet0/0/0"),
remote_as=as_global(10),
password=as_global("TestPassword"),
keepalive_holdtime=as_global(20),
keepalive_interval=as_global(10),
sa_limit=as_global(10),
)
],
)
]
),
)
# Act
parcel_id = self.api.create_parcel(self.profile_uuid, multicast_parcel).id
# Assert
assert parcel_id

def test_when_fully_specified_values_wireless_lan_expect_successful_post(self):
# Arrange
wireless_lan_parcel = WirelessLanParcel(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Copyright 2024 Cisco Systems, Inc. and its affiliates

from ipaddress import IPv4Address
from typing import List, Literal, Optional, Union
from uuid import UUID

from pydantic import AliasPath, BaseModel, ConfigDict, Field

from catalystwan.api.configuration_groups.parcel import Default, Global, Variable, _ParcelBase

SptThreshold = Literal["infinity", "0"]


class LocalConfig(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")
Expand All @@ -29,10 +32,12 @@ class MulticastBasicAttributes(BaseModel):
class StaticJoin(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

group_address: Union[Global[str], Variable] = Field(
serialization_alias="groupAddress", validation_alias="groupAddress"
group_address: Union[Global[IPv4Address], Variable] = Field(
serialization_alias="groupAddress",
validation_alias="groupAddress",
description="Address range: 224.0.0.0 ~ 239.255.255.255",
)
source_address: Optional[Union[Global[str], Variable, Default[None]]] = Field(
source_address: Optional[Union[Global[IPv4Address], Variable, Default[None]]] = Field(
serialization_alias="sourceAddress", validation_alias="sourceAddress", default=Default[None](value=None)
)

Expand All @@ -58,23 +63,20 @@ class IgmpAttributes(BaseModel):
class SmmFlag(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

enable_ssm_flag: Global[bool] = Global[bool](value=True)
range: Optional[Union[Global[str], Variable, Default[None]]] = Default[None](value=None)


class SptThreshold:
INFINITY = "infinity"
ZERO = "0"
enable_ssm_flag: Global[bool] = Field(
default=Global[bool](value=True), serialization_alias="enableSSMFlag", validation_alias="enableSSMFlag"
)
range: Union[Global[str], Variable, Default[None]] = Default[None](value=None)


class SsmAttrubutes(BaseModel):
class SsmAttributes(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

ssm_range_config: SmmFlag = Field(serialization_alias="ssmRangeConfig", validation_alias="ssmRangeConfig")
spt_threshold: Optional[Union[Global[SptThreshold], Variable, Default[SptThreshold]]] = Field(
serialization_alias="sptThreshold",
validation_alias="sptThreshold",
default=Default[SptThreshold](value=SptThreshold.ZERO),
default=Default[SptThreshold](value="0"),
)


Expand All @@ -95,7 +97,7 @@ class PimInterfaceParameters(BaseModel):
class StaticRpAddress(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

address: Union[Global[str], Variable]
address: Union[Global[IPv4Address], Variable]
access_list: Union[Global[str], Variable] = Field(serialization_alias="accessList", validation_alias="accessList")
override: Optional[Union[Global[bool], Variable, Default[bool]]] = Default[bool](value=False)

Expand Down Expand Up @@ -156,16 +158,16 @@ class PimBsrAttributes(BaseModel):
serialization_alias="rpCandidate", validation_alias="rpCandidate", default=None
)
bsr_candidate: Optional[List[BsrCandidateAttributes]] = Field(
serialization_alias="bsdCandidate", validation_alias="bsdCandidate", default=None
serialization_alias="bsrCandidate", validation_alias="bsrCandidate", default=None
)


class PimAttributes(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

ssm: SsmAttrubutes
ssm: SsmAttributes
interface: Optional[List[PimInterfaceParameters]] = None
rp_addres: Optional[List[StaticRpAddress]] = Field(
rp_address: Optional[List[StaticRpAddress]] = Field(
serialization_alias="rpAddr", validation_alias="rpAddr", default=None
)
auto_rp: Optional[AutoRpAttributes] = Field(serialization_alias="autoRp", validation_alias="autoRp", default=None)
Expand All @@ -182,7 +184,7 @@ class DefaultMsdpPeer(BaseModel):
class MsdpPeerAttributes(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

peer_ip: Union[Global[str], Variable] = Field(serialization_alias="peerIp", validation_alias="peerIp")
peer_ip: Union[Global[IPv4Address], Variable] = Field(serialization_alias="peerIp", validation_alias="peerIp")
connect_source_intf: Optional[Union[Global[str], Variable, Default[None]]] = Field(
serialization_alias="connectSourceIntf", validation_alias="connectSourceIntf", default=None
)
Expand All @@ -194,7 +196,10 @@ class MsdpPeerAttributes(BaseModel):
serialization_alias="keepaliveInterval", validation_alias="keepaliveInterval", default=None
)
keepalive_holdtime: Optional[Union[Global[int], Variable, Default[None]]] = Field(
serialization_alias="keepaliveHoldTime", validation_alias="keepaliveHoldTime", default=None
serialization_alias="keepaliveHoldTime",
validation_alias="keepaliveHoldTime",
default=None,
description="Hold-Time must be higher than Keep Alive",
)
sa_limit: Optional[Union[Global[int], Variable, Default[None]]] = Field(
serialization_alias="saLimit", validation_alias="saLimit", default=None
Expand Down
2 changes: 2 additions & 0 deletions catalystwan/tests/test_feature_profile_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from catalystwan.models.configuration.feature_profile.sdwan.service.eigrp import EigrpParcel
from catalystwan.models.configuration.feature_profile.sdwan.service.lan.gre import BasicGre
from catalystwan.models.configuration.feature_profile.sdwan.service.lan.ipsec import IpsecAddress, IpsecTunnelMode
from catalystwan.models.configuration.feature_profile.sdwan.service.multicast import MulticastParcel
from catalystwan.models.configuration.feature_profile.sdwan.service.ospfv3 import Ospfv3IPv4Parcel, Ospfv3IPv6Parcel
from catalystwan.models.configuration.feature_profile.sdwan.service.route_policy import RoutePolicyParcel
from catalystwan.models.configuration.feature_profile.sdwan.service.wireless_lan import WirelessLanParcel
Expand Down Expand Up @@ -118,6 +119,7 @@ def test_update_method_with_valid_arguments(self, parcel, expected_path):
Ipv6AclParcel: "ipv6-acl",
Ipv4AclParcel: "ipv4-acl",
SwitchportParcel: "switchport",
MulticastParcel: "routing/multicast",
WirelessLanParcel: "wirelesslan",
}

Expand Down
Loading

0 comments on commit cafc368

Please sign in to comment.