Skip to main content

Logical Router Models

Overview

The Logical Router models provide a structured way to represent and validate logical router configuration data for Palo Alto Networks' Strata Cloud Manager. These models ensure data integrity when creating and updating logical routers, enforcing proper VRF configuration, routing protocol settings (BGP, OSPF, ECMP, RIP), static route nexthop types, administrative distances, container specifications, and field validations. With 93 model classes and 20 model_validator implementations, this is the most complex model hierarchy in the SDK.

Models

The module provides the following Pydantic models, organized by functional group:

Top-Level Models (4)

  • LogicalRouterBaseModel: Base model with fields common to all logical router operations
  • LogicalRouterCreateModel: Model for creating new logical routers
  • LogicalRouterUpdateModel: Model for updating existing logical routers
  • LogicalRouterResponseModel: Response model for logical router operations
  • RoutingStackEnum: Enum for routing stack type (legacy or advanced)

VRF & Administrative Distances (4)

  • VrfConfig: VRF (Virtual Routing and Forwarding) configuration
  • AdminDists: Administrative distance settings for a logical router
  • VrAdminDists: VR-level administrative distance settings

RIB Filter Models (4)

  • RibFilter: Top-level RIB filter configuration (IPv4/IPv6)
  • RibFilterIpv4: IPv4 RIB filter by protocol (static, BGP, OSPF, RIP)
  • RibFilterIpv6: IPv6 RIB filter by protocol (static, BGP, OSPFv3)
  • RibFilterProtocol: Individual RIB filter protocol entry with route map

BFD / Path Monitor Models (3)

  • BfdProfile: BFD profile reference
  • PathMonitor: Path monitor configuration for static routes
  • MonitorDestination: Path monitor destination entry

Static Route Models (8)

  • RoutingTable, RoutingTableIp, RoutingTableIpv6: Routing table hierarchy
  • IPv4StaticRoute: IPv4 static route configuration
  • IPv4Nexthop: IPv4 nexthop (oneOf: 8 types)
  • IPv4RouteTable: IPv4 route table selection (oneOf: 4 types)
  • IPv6StaticRoute: IPv6 static route configuration
  • IPv6Nexthop: IPv6 nexthop (oneOf: 7 types)
  • IPv6RouteTable: IPv6 route table selection (oneOf: 4 types)

OSPF Models (19)

  • OspfConfig: Top-level OSPF configuration
  • OspfArea, OspfAreaType, OspfNormalArea, OspfStubArea, OspfNssaArea
  • OspfStubDefaultRoute, OspfNssaDefaultRoute, OspfNssaExtRange
  • OspfAreaRange, OspfAreaVrRange
  • OspfInterface, OspfInterfaceVrTiming, OspfLinkType
  • OspfVirtualLink, OspfVirtualLinkVrTiming
  • OspfAuthProfile, OspfMd5Key
  • OspfExportRule, OspfFloodPrevention, OspfFloodPreventionEntry
  • OspfVrTimers, OspfGracefulRestart, OspfP2mpNeighbor

ECMP Models (5)

  • EcmpConfig: Top-level ECMP configuration
  • EcmpAlgorithm: Algorithm selection (oneOf: 4 types)
  • EcmpIpHash: IP hash algorithm settings
  • EcmpWeightedRoundRobin: Weighted round-robin configuration
  • EcmpWeightedInterface: Weighted interface entry

RIP Models (3)

  • RipConfig: Top-level RIP configuration
  • RipInterface: RIP interface configuration
  • RipDistributeList: RIP distribute list configuration

BGP Models (30+)

  • BgpConfig: Top-level BGP configuration
  • BgpPeerGroup, BgpPeerGroupType, BgpPeerGroupConnectionOptions, BgpPeerGroupAddressFamily, BgpPeerGroupFilteringProfile
  • BgpPeer, BgpPeerAddress, BgpPeerLocalAddress, BgpPeerSubsequentAfi, BgpPeerConnectionOptions, BgpPeerIncomingBgpConnection, BgpPeerOutgoingBgpConnection, BgpPeerBfd, BgpPeerInherit
  • BgpAggregateRoute, BgpAggregateRouteType
  • BgpRedistProfile, BgpRedistRule
  • BgpAdvertiseNetwork, BgpAdvertiseNetworkFamily, BgpAdvertiseNetworkEntry
  • BgpPolicy, BgpPolicyImportExport, BgpPolicyRule, BgpPolicyAction, BgpPolicyActionAllow
  • BgpPolicyMatch, BgpPolicyMatchAddressPrefix, BgpPolicyMatchAsPath, BgpPolicyMatchCommunity
  • BgpPolicyUpdate, BgpPolicyUpdateAsPath, BgpPolicyUpdateCommunity
  • BgpMed, BgpAggregate, BgpGracefulRestart

The LogicalRouterBaseModel and LogicalRouterCreateModel / LogicalRouterUpdateModel use extra="forbid" configuration, which rejects any fields not explicitly defined in the model. All sub-models also use extra="forbid". The LogicalRouterResponseModel uses extra="ignore" to provide resilience against unexpected fields returned by the API.

Model Attributes

LogicalRouterBaseModel

This is the base model containing fields common to all logical router operations.

AttributeTypeRequiredDefaultDescription
namestrYesNoneName of the logical router.
routing_stackRoutingStackEnumNoNoneRouting stack type: legacy or advanced.
vrfList[VrfConfig]NoNoneList of VRF configurations.
folderstrNo**NoneFolder location. Pattern: ^[a-zA-Z\d\-_. ]+$. Max 64 chars.
snippetstrNo**NoneSnippet location. Pattern: ^[a-zA-Z\d\-_. ]+$. Max 64 chars.
devicestrNo**NoneDevice location. Pattern: ^[a-zA-Z\d\-_. ]+$. Max 64 chars.

** Exactly one container (folder/snippet/device) must be provided for create operations

LogicalRouterCreateModel

Inherits all fields from LogicalRouterBaseModel and enforces that exactly one of folder, snippet, or device is provided during creation.

LogicalRouterUpdateModel

Extends LogicalRouterBaseModel by adding:

AttributeTypeRequiredDefaultDescription
idUUIDYesNoneThe unique identifier of the logical router.

LogicalRouterResponseModel

Extends LogicalRouterBaseModel by adding:

AttributeTypeRequiredDefaultDescription
idUUIDYesNoneThe unique identifier of the logical router.
note

The LogicalRouterResponseModel uses extra="ignore" instead of extra="forbid". This means it will silently ignore any extra fields returned by the API that are not defined in the model, providing resilience against API changes.

Supporting Models

VrfConfig

This model defines VRF (Virtual Routing and Forwarding) configuration. Each logical router contains a list of VRFs, which serve as the primary container for all routing configuration.

AttributeTypeRequiredDefaultDescription
namestrYesNoneVRF name.
interfaceList[str]NoNoneInterfaces assigned to this VRF.
global_vridintNoNoneGlobal VRID.
zone_namestrNoNoneZone name.
sdwan_typestrNoNoneSD-WAN type.
admin_distsAdminDistsNoNoneAdministrative distance settings.
vr_admin_distsVrAdminDistsNoNoneVR administrative distances.
rib_filterRibFilterNoNoneRIB filter configuration.
routing_tableRoutingTableNoNoneRouting table with static routes.
ospfOspfConfigNoNoneOSPF configuration.
ospfv3Dict[str, Any]NoNoneOSPFv3 configuration (raw dict).
ecmpEcmpConfigNoNoneECMP configuration.
multicastDict[str, Any]NoNoneMulticast configuration (raw dict).
ripRipConfigNoNoneRIP configuration.
bgpBgpConfigNoNoneBGP configuration.

AdminDists

Administrative distance settings for a logical router.

AttributeTypeRequiredDefaultDescription
staticintNoNoneStatic route admin distance.
static_ipv6intNoNoneStatic IPv6 route admin distance.
ospf_interintNoNoneOSPF inter-area admin distance.
ospf_intraintNoNoneOSPF intra-area admin distance.
ospf_extintNoNoneOSPF external admin distance.
ospfv3_interintNoNoneOSPFv3 inter-area admin distance.
ospfv3_intraintNoNoneOSPFv3 intra-area admin distance.
ospfv3_extintNoNoneOSPFv3 external admin distance.
bgp_internalintNoNoneBGP internal admin distance.
bgp_externalintNoNoneBGP external admin distance.
bgp_localintNoNoneBGP local admin distance.
ripintNoNoneRIP admin distance.

VrAdminDists

VR-level administrative distance settings.

AttributeTypeRequiredDefaultDescription
staticintNoNoneStatic route admin distance.
static_ipv6intNoNoneStatic IPv6 route admin distance.
ospf_intintNoNoneOSPF internal admin distance.
ospf_extintNoNoneOSPF external admin distance.
ospfv3_intintNoNoneOSPFv3 internal admin distance.
ospfv3_extintNoNoneOSPFv3 external admin distance.
ibgpintNoNoneiBGP admin distance.
ebgpintNoNoneeBGP admin distance.
ripintNoNoneRIP admin distance.

RIB Filter Models

The RibFilter model provides protocol-based route filtering for IPv4 and IPv6 address families.

ModelFieldsDescription
RibFilteripv4, ipv6Top-level RIB filter container.
RibFilterIpv4static, bgp, ospf, ripIPv4 RIB filters per routing protocol.
RibFilterIpv6static, bgp, ospfv3IPv6 RIB filters per routing protocol.
RibFilterProtocolroute_mapProtocol entry referencing a route map.

Static Route Models

Static routes are organized under RoutingTable > RoutingTableIp / RoutingTableIpv6 > IPv4StaticRoute / IPv6StaticRoute.

IPv4StaticRoute

AttributeTypeRequiredDefaultDescription
namestrYesNoneStatic route name.
destinationstrNoNoneDestination network (CIDR).
interfacestrNoNoneEgress interface.
nexthopIPv4NexthopNoNoneNexthop configuration.
route_tableIPv4RouteTableNoNoneRoute table selection.
admin_distintNoNoneAdministrative distance.
metricintNoNoneRoute metric.
bfdBfdProfileNoNoneBFD profile reference.
path_monitorPathMonitorNoNonePath monitor configuration.

IPv4Nexthop (oneOf)

At most one of the following nexthop types may be set:

AttributeTypeDescription
receiveDict[str, Any]Receive (drop into local host).
discardDict[str, Any]Discard (silently drop).
ip_addressstrIPv4 address nexthop.
ipv6_addressstrIPv6 address nexthop.
fqdnstrFQDN nexthop.
next_lrstrNext logical router.
next_vrstrNext virtual router.
tunnelstrTunnel nexthop.

IPv4RouteTable (oneOf)

At most one route table type may be set: unicast, multicast, both, or no_install.

IPv6StaticRoute

Same structure as IPv4StaticRoute, with the addition of:

AttributeTypeRequiredDefaultDescription
optionDict[str, Any]NoNoneRoute option.

IPv6Nexthop (oneOf)

Same as IPv4Nexthop but without ip_address (7 nexthop types instead of 8).

PathMonitor

AttributeTypeRequiredDefaultDescription
enableboolNoNoneEnable path monitoring.
failure_conditionstrNoNoneFailure condition: any/all.
hold_timeintNoNoneHold time.
monitor_destinationsList[MonitorDestination]NoNoneList of monitor destinations.

OSPF Models

OSPF configuration is organized hierarchically: OspfConfig > OspfArea > OspfInterface / OspfVirtualLink.

OspfConfig

AttributeTypeRequiredDefaultDescription
router_idstrNoNoneOSPF router ID.
enableboolNoNoneEnable OSPF.
rfc1583boolNoNoneRFC 1583 compatibility.
reject_default_routeboolNoNoneReject default route.
allow_redist_default_routeboolNoNoneAllow redistribution of default.
spf_timerstrNoNoneSPF timer profile.
global_if_timerstrNoNoneGlobal interface timer profile.
redistribution_profilestrNoNoneRedistribution profile name.
global_bfdBfdProfileNoNoneGlobal BFD profile.
flood_preventionOspfFloodPreventionNoNoneFlood prevention configuration.
vr_timersOspfVrTimersNoNoneVR timer settings.
auth_profileList[OspfAuthProfile]NoNoneAuthentication profiles.
areaList[OspfArea]NoNoneOSPF areas.
export_rulesList[OspfExportRule]NoNoneExport rules.
graceful_restartOspfGracefulRestartNoNoneGraceful restart configuration.

OspfArea

AttributeTypeRequiredDefaultDescription
namestrYesNoneArea ID.
authenticationstrNoNoneAuthentication profile.
typeOspfAreaTypeNoNoneArea type (normal/stub/nssa).
rangeList[OspfAreaRange]NoNoneArea ranges.
vr_rangeList[OspfAreaVrRange]NoNoneVR area ranges.
interfaceList[OspfInterface]NoNoneOSPF interfaces.
virtual_linkList[OspfVirtualLink]NoNoneOSPF virtual links.

OspfAreaType (oneOf)

At most one area type may be set: normal (OspfNormalArea), stub (OspfStubArea), or nssa (OspfNssaArea).

OspfAuthProfile (oneOf)

AttributeTypeRequiredDescription
namestrYesAuth profile name.
passwordstrNo*Simple password authentication.
md5List[OspfMd5Key]No*MD5 authentication keys.

* password and md5 are mutually exclusive.

OspfLinkType (oneOf)

At most one link type may be set: broadcast, p2p, or p2mp.

ECMP Models

ECMP (Equal-Cost Multi-Path) configuration controls load balancing across multiple equal-cost paths.

EcmpConfig

AttributeTypeRequiredDefaultDescription
enableboolNoNoneEnable ECMP.
algorithmEcmpAlgorithmNoNoneECMP algorithm selection.
max_pathintNoNoneMaximum number of ECMP paths.
symmetric_returnboolNoNoneEnable symmetric return.
strict_source_pathboolNoNoneEnable strict source path.

EcmpAlgorithm (oneOf)

At most one algorithm may be set:

AttributeTypeDescription
ip_moduloDict[str, Any]IP modulo algorithm.
ip_hashEcmpIpHashIP hash algorithm.
weighted_round_robinEcmpWeightedRoundRobinWeighted round-robin.
balanced_round_robinDict[str, Any]Balanced round-robin.

RIP Models

RipConfig

AttributeTypeRequiredDefaultDescription
enableboolNoNoneEnable RIP.
default_information_originateboolNoNoneOriginate default information.
global_timerstrNoNoneGlobal timer profile.
auth_profilestrNoNoneAuthentication profile name.
redistribution_profilestrNoNoneRedistribution profile name.
global_bfdBfdProfileNoNoneGlobal BFD profile.
global_inbound_distribute_listRipDistributeListNoNoneGlobal inbound distribute list.
global_outbound_distribute_listRipDistributeListNoNoneGlobal outbound distribute list.
interfaceList[RipInterface]NoNoneRIP interfaces.

RipInterface

AttributeTypeRequiredDefaultDescription
namestrYesNoneInterface name.
enableboolNoNoneEnable RIP on interface.
modestrNoNoneRIP mode: active, passive, or send-only.
split_horizonstrNoNoneSplit horizon mode.
authenticationstrNoNoneAuthentication profile name.
bfdBfdProfileNoNoneBFD profile.
interface_inbound_distribute_listRipDistributeListNoNoneInbound distribute list.
interface_outbound_distribute_listRipDistributeListNoNoneOutbound distribute list.

BGP Models

BGP configuration is the most deeply nested section, organized as: BgpConfig > BgpPeerGroup > BgpPeer, with separate sub-trees for policies, aggregate routes, redistribution, and network advertisements.

BgpConfig

AttributeTypeRequiredDefaultDescription
enableboolNoNoneEnable BGP.
router_idstrNoNoneBGP router ID.
local_asstrNoNoneLocal AS number (ASPLAIN format).
confederation_member_asstrNoNoneConfederation member AS.
install_routeboolNoNoneInstall routes.
enforce_first_asboolNoNoneEnforce first AS.
fast_external_failoverboolNoNoneFast external failover.
ecmp_multi_asboolNoNoneECMP multi-AS.
default_local_preferenceintNoNoneDefault local preference.
graceful_shutdownboolNoNoneGraceful shutdown.
always_advertise_network_routeboolNoNoneAlways advertise network route.
reject_default_routeboolNoNoneReject default route.
allow_redist_default_routeboolNoNoneAllow redistribution of default route.
as_formatstrNoNoneAS number format.
medBgpMedNoNoneMED configuration.
aggregateBgpAggregateNoNoneAggregate configuration.
graceful_restartBgpGracefulRestartNoNoneGraceful restart configuration.
global_bfdBfdProfileNoNoneGlobal BFD profile.
peer_groupList[BgpPeerGroup]NoNonePeer groups.
aggregate_routesList[BgpAggregateRoute]NoNoneAggregate routes.
redistribution_profileBgpRedistProfileNoNoneRedistribution profile.
advertise_networkBgpAdvertiseNetworkNoNoneAdvertise network configuration.
policyBgpPolicyNoNoneBGP policy configuration.
redist_rulesList[BgpRedistRule]NoNoneRedistribution rules.

BgpPeerGroup

AttributeTypeRequiredDefaultDescription
namestrYesNonePeer group name.
enableboolNoNoneEnable peer group.
aggregated_confed_as_pathboolNoNoneAggregated confederation AS path.
soft_reset_with_stored_infoboolNoNoneSoft reset with stored info.
typeBgpPeerGroupTypeNoNonePeer group type.
address_familyBgpPeerGroupAddressFamilyNoNoneAddress family configuration.
filtering_profileBgpPeerGroupFilteringProfileNoNoneFiltering profile configuration.
connection_optionsBgpPeerGroupConnectionOptionsNoNoneConnection options.
peerList[BgpPeer]NoNonePeers in this group.

BgpPeerGroupType (oneOf)

At most one peer group type may be set: ibgp, ebgp_confed, ibgp_confed, or ebgp.

BgpPeerAddress (oneOf)

ip and fqdn are mutually exclusive for specifying the peer address.

BgpPeerInherit (oneOf)

ipv4 and no are mutually exclusive for inherit configuration.

BgpAggregateRouteType (oneOf)

ipv4 and ipv6 are mutually exclusive for aggregate route types.

BgpPolicy

AttributeTypeRequiredDefaultDescription
import_ (alias: import)BgpPolicyImportExportNoNoneImport policy rules.
exportBgpPolicyImportExportNoNoneExport policy rules.
conditional_advertisementDict[str, Any]NoNoneConditional advertisement config (raw dict).
aggregationDict[str, Any]NoNoneAggregation policy config (raw dict).

BgpPolicyAction (oneOf)

deny and allow are mutually exclusive. The allow variant accepts an optional BgpPolicyUpdate with route attribute modifications.

BgpPolicyUpdateAsPath (oneOf)

At most one AS path action may be set: none, remove, prepend, or remove_and_prepend.

BgpPolicyUpdateCommunity (oneOf)

At most one community action may be set: none, remove_all, remove_regex, append, or overwrite. This model is used for both community and extended_community update fields.

Fields Using Dict[str, Any]

Several deeply nested or less commonly used configurations are represented as raw dictionaries rather than fully typed models:

Field LocationDescription
VrfConfig.ospfv3OSPFv3 configuration.
VrfConfig.multicastMulticast routing configuration.
BgpPolicy.conditional_advertisementBGP conditional advertisement rules.
BgpPolicy.aggregationBGP aggregation policy.

These fields accept arbitrary nested structures. Fully typed models may be added in a future SDK release.

Exceptions

The models perform strict validation and will raise ValueError in scenarios such as:

  • When creating a logical router (LogicalRouterCreateModel), if not exactly one container (folder, snippet, or device) is provided.
  • When more than one nexthop type is set on IPv4Nexthop or IPv6Nexthop (at most one is allowed).
  • When more than one route table type is set on IPv4RouteTable or IPv6RouteTable.
  • When more than one OSPF area type is set on OspfAreaType (normal, stub, or nssa).
  • When mutually exclusive OSPF fields are both set (e.g., password and md5 on OspfAuthProfile).
  • When more than one ECMP algorithm is set on EcmpAlgorithm.
  • When mutually exclusive BGP fields are both set (e.g., ip and fqdn on BgpPeerAddress).
  • When more than one BGP peer group type is set on BgpPeerGroupType.
  • When more than one BGP policy action is set on BgpPolicyAction (deny or allow).
  • When more than one AS path action or community action is set on BgpPolicyUpdateAsPath or BgpPolicyUpdateCommunity.
  • When container identifiers (folder, snippet, device) do not match the required pattern or exceed the maximum length.

Model Validators

The Logical Router models contain 20 model_validator implementations, all operating in mode="after" to enforce oneOf-style mutual exclusivity constraints.

Nexthop Validators

  • IPv4Nexthop.validate_nexthop_type: Ensures at most one of the 8 nexthop types is set: receive, discard, ip_address, ipv6_address, fqdn, next_lr, next_vr, or tunnel.

  • IPv6Nexthop.validate_nexthop_type: Ensures at most one of the 7 nexthop types is set: receive, discard, ipv6_address, fqdn, next_lr, next_vr, or tunnel.

Route Table Validators

  • IPv4RouteTable.validate_route_table: Ensures at most one route table type is set: unicast, multicast, both, or no_install.

  • IPv6RouteTable.validate_route_table: Same constraint as IPv4 route table.

OSPF Validators

  • OspfAuthProfile.validate_auth_type: Ensures password and md5 are mutually exclusive.

  • OspfLinkType.validate_link_type: Ensures at most one link type is set: broadcast, p2p, or p2mp.

  • OspfAreaVrRange.validate_action: Ensures advertise and suppress are mutually exclusive.

  • OspfStubDefaultRoute.validate_default_route: Ensures disable and advertise are mutually exclusive.

  • OspfNssaDefaultRoute.validate_default_route: Ensures disable and advertise are mutually exclusive.

  • OspfNssaExtRange.validate_action: Ensures advertise and suppress are mutually exclusive.

  • OspfAreaType.validate_area_type: Ensures at most one area type is set: normal, stub, or nssa.

ECMP Validators

  • EcmpAlgorithm.validate_algorithm: Ensures at most one ECMP algorithm is set: ip_modulo, ip_hash, weighted_round_robin, or balanced_round_robin.

BGP Validators

  • BgpPeerAddress.validate_peer_address: Ensures ip and fqdn are mutually exclusive.

  • BgpPeerInherit.validate_inherit: Ensures ipv4 and no are mutually exclusive.

  • BgpPeerGroupType.validate_type: Ensures at most one peer group type is set: ibgp, ebgp_confed, ibgp_confed, or ebgp.

  • BgpAggregateRouteType.validate_type: Ensures ipv4 and ipv6 are mutually exclusive.

  • BgpPolicyUpdateAsPath.validate_as_path_action: Ensures at most one AS path action is set: none, remove, prepend, or remove_and_prepend.

  • BgpPolicyUpdateCommunity.validate_community_action: Ensures at most one community action is set: none, remove_all, remove_regex, append, or overwrite.

  • BgpPolicyAction.validate_action: Ensures deny and allow are mutually exclusive.

Container Validation in LogicalRouterCreateModel

  • validate_container_type: After model initialization, this validator checks that exactly one of the container fields (folder, snippet, or device) is provided. If not, it raises a ValueError.

Usage Examples

Creating a Logical Router

Using a Dictionary

from scm.models.network import LogicalRouterCreateModel

router_data = {
"name": "LR1",
"routing_stack": "advanced",
"vrf": [
{
"name": "default",
"interface": ["ethernet1/1", "ethernet1/2"],
"routing_table": {
"ip": {
"static_route": [
{
"name": "default-route",
"destination": "0.0.0.0/0",
"nexthop": {"ip_address": "10.0.0.1"},
"metric": 10,
"admin_dist": 10,
}
]
}
},
}
],
"folder": "Texas",
}

# Validate and create model instance
router = LogicalRouterCreateModel(**router_data)
payload = router.model_dump(exclude_unset=True, by_alias=True)
print(payload)

Using the Model Directly

from scm.models.network import LogicalRouterCreateModel
from scm.models.network.logical_router import (
VrfConfig,
RoutingTable,
RoutingTableIp,
IPv4StaticRoute,
IPv4Nexthop,
BfdProfile,
PathMonitor,
MonitorDestination,
)

# Create a static route with BFD and path monitoring
static_route = IPv4StaticRoute(
name="default-route",
destination="0.0.0.0/0",
nexthop=IPv4Nexthop(ip_address="10.0.0.1"),
metric=10,
bfd=BfdProfile(profile="bfd-default"),
path_monitor=PathMonitor(
enable=True,
failure_condition="any",
monitor_destinations=[
MonitorDestination(
name="monitor-1",
enable=True,
source="10.0.0.2",
destination="8.8.8.8",
)
],
),
)

# Build the VRF configuration
vrf = VrfConfig(
name="default",
interface=["ethernet1/1", "ethernet1/2"],
routing_table=RoutingTable(
ip=RoutingTableIp(static_route=[static_route])
),
)

# Create logical router
router = LogicalRouterCreateModel(
name="LR1",
routing_stack="advanced",
vrf=[vrf],
folder="Texas",
)
payload = router.model_dump(exclude_unset=True, by_alias=True)
print(payload)

Updating a Logical Router

from scm.client import Scm

# Initialize client
client = Scm(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id",
)

# Fetch existing router
existing = client.logical_router.fetch(name="LR1", folder="Texas")

# Add a new VRF with BGP configuration
existing.vrf.append({
"name": "vrf-production",
"interface": ["ethernet1/3"],
"bgp": {
"enable": True,
"router_id": "10.0.0.1",
"local_as": "65001",
"peer_group": [
{
"name": "upstream",
"enable": True,
"type": {"ebgp": {}},
"peer": [
{
"name": "isp-peer",
"enable": True,
"peer_as": "65002",
"peer_address": {"ip": "192.168.1.1"},
}
],
}
],
},
})

# Pass modified object to update()
updated = client.logical_router.update(existing)
print(f"Updated logical router: {updated.name}")

Creating a Logical Router with OSPF

from scm.models.network import LogicalRouterCreateModel
from scm.models.network.logical_router import (
VrfConfig,
OspfConfig,
OspfArea,
OspfAreaType,
OspfNormalArea,
OspfInterface,
OspfLinkType,
OspfGracefulRestart,
BfdProfile,
)

# Build OSPF area with interfaces
area = OspfArea(
name="0.0.0.0",
type=OspfAreaType(normal=OspfNormalArea()),
interface=[
OspfInterface(
name="ethernet1/1",
enable=True,
passive=False,
metric=10,
link_type=OspfLinkType(broadcast={}),
bfd=BfdProfile(profile="bfd-default"),
),
],
)

# Build OSPF configuration
ospf = OspfConfig(
router_id="10.0.0.1",
enable=True,
area=[area],
graceful_restart=OspfGracefulRestart(
enable=True,
grace_period=120,
),
)

# Create the router
router = LogicalRouterCreateModel(
name="LR-OSPF",
routing_stack="advanced",
vrf=[
VrfConfig(
name="default",
interface=["ethernet1/1"],
ospf=ospf,
)
],
folder="Texas",
)
payload = router.model_dump(exclude_unset=True, by_alias=True)
print(payload)

Creating a Logical Router with ECMP

from scm.models.network import LogicalRouterCreateModel
from scm.models.network.logical_router import (
VrfConfig,
EcmpConfig,
EcmpAlgorithm,
EcmpIpHash,
)

router = LogicalRouterCreateModel(
name="LR-ECMP",
routing_stack="advanced",
vrf=[
VrfConfig(
name="default",
interface=["ethernet1/1", "ethernet1/2"],
ecmp=EcmpConfig(
enable=True,
max_path=4,
symmetric_return=True,
algorithm=EcmpAlgorithm(
ip_hash=EcmpIpHash(
src_only=False,
use_port=True,
hash_seed=12345,
)
),
),
)
],
folder="Texas",
)
payload = router.model_dump(exclude_unset=True, by_alias=True)
print(payload)