Skip to content

Bgp peer

BGP Peer types that are used in input forms.

IPv4BGPPeer

Bases: BaseModel

IPv4 BGP Peer model for use in input forms.

Source code in gso/utils/types/bgp_peer.py
class IPv4BGPPeer(BaseModel):
    """IPv4 BGP Peer model for use in input forms."""

    peer_address: IPv4AddressType
    authentication_key: str | None = None
    has_custom_policies: bool = False
    bfd_enabled: bool = False
    multipath_enabled: bool = False
    prefix_limit: NonNegativeInt | None = None
    ttl_security: NonNegativeInt | None = None
    is_passive: bool = False
    add_v4_multicast: bool = Field(default=False, exclude=True)
    send_default_route: bool = False

    @computed_field  # type: ignore[prop-decorator]
    @property
    def families(self) -> list[IPFamily]:
        """Convert the add multicast boolean into a list of address families."""
        return [IPFamily.V4UNICAST, IPFamily.V4MULTICAST] if self.add_v4_multicast else [IPFamily.V4UNICAST]

    @computed_field  # type: ignore[prop-decorator]
    @property
    def ip_type(self) -> IPTypes:
        """Return the IP version number of this BGP peer.

        This is not an attribute of the class, as that would make it appear in input forms, which we want to avoid.
        """
        return IPTypes.IPV4

families property

Convert the add multicast boolean into a list of address families.

ip_type property

Return the IP version number of this BGP peer.

This is not an attribute of the class, as that would make it appear in input forms, which we want to avoid.

IPv6BGPPeer

Bases: BaseModel

IPv6 BGP Peer model for use in input forms.

Source code in gso/utils/types/bgp_peer.py
class IPv6BGPPeer(BaseModel):
    """IPv6 BGP Peer model for use in input forms."""

    peer_address: IPv6AddressType
    authentication_key: str | None = None
    has_custom_policies: bool = False
    bfd_enabled: bool = False
    multipath_enabled: bool = False
    prefix_limit: NonNegativeInt | None = None
    ttl_security: NonNegativeInt | None = None
    is_passive: bool = False
    add_v6_multicast: bool = Field(default=False, exclude=True)
    send_default_route: bool = False

    @computed_field  # type: ignore[prop-decorator]
    @property
    def families(self) -> list[IPFamily]:
        """Convert the add multicast boolean into a list of address families."""
        return [IPFamily.V6UNICAST, IPFamily.V6MULTICAST] if self.add_v6_multicast else [IPFamily.V6UNICAST]

    @computed_field  # type: ignore[prop-decorator]
    @property
    def ip_type(self) -> IPTypes:
        """Return the IP version number of this BGP peer.

        This is not an attribute of the class, as that would make it appear in input forms, which we want to avoid.
        """
        return IPTypes.IPV6

families property

Convert the add multicast boolean into a list of address families.

ip_type property

Return the IP version number of this BGP peer.

This is not an attribute of the class, as that would make it appear in input forms, which we want to avoid.