Coverage for src/birdplan/bird_config/sections/protocols/bgp/peer/peer_attributes.py: 98%
220 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-25 07:38 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-25 07:38 +0000
1#
2# SPDX-License-Identifier: GPL-3.0-or-later
3#
4# Copyright (c) 2019-2025, AllWorldIT
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
19"""BIRD BGP protocol attributes."""
21import enum
23from ......exceptions import BirdPlanError
24from .actions import BGPPeerActions
26__all__ = [
27 "BGPPeerAttributes",
28 "BGPPeerConstraints",
29 "BGPPeerImportFilterPolicy",
30 "BGPPeerLargeCommunities",
31 "BGPPeerLargeCommunitiesOutgoing",
32 "BGPPeerLocation",
33 "BGPPeerPrepend",
34 "BGPPeerPrependItem",
35 "BGPPeerRoutePolicyAccept",
36 "BGPPeerRoutePolicyRedistribute",
37]
39# This type is a string as we can have it set to "peeringdb"
40BGPPeerPrefixLimit = str | None
42BGPPeerFilterItem = str | list[str]
43BGPPeerFilter = dict[str, BGPPeerFilterItem]
46# Define BGP prefix limit action enum
47class BGPPeerImportPrefixLimitAction(enum.Enum):
48 """BGP peer import prefix limit action."""
50 RESTART = "restart"
51 DISABLE = "disable"
54class BGPPeerCommunitiesOutgoing: # pylint: disable=too-few-public-methods,too-many-instance-attributes
55 """
56 BGP peer outgoing communities.
58 Attributes
59 ----------
60 connected: List[str]
61 Connected route outgoing communities.
62 kernel: List[str]
63 Kernel route outgoing communities.
64 kernel_blackhole: List[str]
65 Kernel blackhole route outgoing communities.
66 kernel_default: List[str]
67 Kernel default route outgoing communities.
68 originated: List[str]
69 Originated route outgoing communities.
70 originated_default: List[str]
71 Originated default route outgoing communities.
72 static: List[str]
73 Static route outgoing communities.
74 static_blackhole: List[str]
75 Static blackhole route outgoing communities.
76 static_default: List[str]
77 Static default route outgoing communities.
78 bgp_own: List[str]
79 BGP own route outgoing communities.
80 bgp_own_blackhole: List[str]
81 BGP own blackhole route outgoing communities.
82 bgp_own_default: List[str]
83 BGP own default route outgoing communities.
84 bgp_customer: List[str]
85 BGP customer route outgoing communities.
86 bgp_customer_blackhole: List[str]
87 BGP customer blackhole route outgoing communities.
88 bgp_peering: List[str]
89 BGP peering route outgoing communities.
90 bgp_transit: List[str]
91 BGP transit route outgoing communities.
92 bgp_transit_default: List[str]
93 BGP transit default route outgoing communities.
95 """
97 connected: list[str]
98 kernel: list[str]
99 kernel_blackhole: list[str]
100 kernel_default: list[str]
101 originated: list[str]
102 originated_default: list[str]
103 static: list[str]
104 static_blackhole: list[str]
105 static_default: list[str]
106 bgp: list[str]
107 bgp_own: list[str]
108 bgp_own_blackhole: list[str]
109 bgp_own_default: list[str]
110 bgp_customer: list[str]
111 bgp_customer_blackhole: list[str]
112 bgp_peering: list[str]
113 bgp_transit: list[str]
114 bgp_transit_default: list[str]
116 def __init__(self) -> None:
117 """Initialize object."""
118 self.connected = []
119 self.kernel = []
120 self.kernel_blackhole = []
121 self.kernel_default = []
122 self.originated = []
123 self.originated_default = []
124 self.static = []
125 self.static_blackhole = []
126 self.static_default = []
127 self.bgp_own = []
128 self.bgp_own_blackhole = []
129 self.bgp_own_default = []
130 self.bgp_customer = []
131 self.bgp_customer_blackhole = []
132 self.bgp_peering = []
133 self.bgp_transit = []
134 self.bgp_transit_default = []
137class BGPPeerCommunities: # pylint: disable=too-few-public-methods
138 """
139 BGP peer communities.
141 Attributes
142 ----------
143 incoming : List[str]
144 List of communities to add to incoming prefixes.
145 outgoing : BGPPeerCommunitiesOutgoing
146 List of communities to add to outgoing prefixes.
148 """
150 incoming: list[str]
152 outgoing: BGPPeerCommunitiesOutgoing
154 def __init__(self) -> None:
155 """Initialize object."""
156 self.incoming = []
157 self.outgoing = BGPPeerCommunitiesOutgoing()
160class BGPPeerLargeCommunitiesOutgoing: # pylint: disable=too-few-public-methods,too-many-instance-attributes
161 """
162 BGP peer outgoing large communities.
164 Attributes
165 ----------
166 connected: List[str]
167 Connected route outgoing large communities.
168 kernel: List[str]
169 Kernel route outgoing large communities.
170 kernel_blackhole: List[str]
171 Kernel blackhole route outgoing large communities.
172 kernel_default: List[str]
173 Kernel default route outgoing large communities.
174 originated: List[str]
175 Originated route outgoing large communities.
176 originated_default: List[str]
177 Originated default route outgoing large communities.
178 static: List[str]
179 Static route outgoing large communities.
180 static_blackhole: List[str]
181 Static blackhole route outgoing large communities.
182 static_default: List[str]
183 Static default route outgoing large communities.
184 bgp_own: List[str]
185 BGP own route outgoing large communities.
186 bgp_own_blackhole: List[str]
187 BGP own blackhole route outgoing large communities.
188 bgp_own_default: List[str]
189 BGP own default route outgoing large communities.
190 bgp_customer: List[str]
191 BGP customer route outgoing large communities.
192 bgp_customer_blackhole: List[str]
193 BGP customer blackhole route outgoing large communities.
194 bgp_peering: List[str]
195 BGP peering route outgoing large communities.
196 bgp_transit: List[str]
197 BGP transit route outgoing large communities.
198 bgp_transit_default: List[str]
199 BGP transit default route outgoing large communities.
201 """
203 connected: list[str]
204 kernel: list[str]
205 kernel_blackhole: list[str]
206 kernel_default: list[str]
207 originated: list[str]
208 originated_default: list[str]
209 static: list[str]
210 static_blackhole: list[str]
211 static_default: list[str]
212 bgp: list[str]
213 bgp_own: list[str]
214 bgp_own_blackhole: list[str]
215 bgp_own_default: list[str]
216 bgp_customer: list[str]
217 bgp_customer_blackhole: list[str]
218 bgp_peering: list[str]
219 bgp_transit: list[str]
220 bgp_transit_default: list[str]
222 def __init__(self) -> None:
223 """Initialize object."""
224 self.connected = []
225 self.kernel = []
226 self.kernel_blackhole = []
227 self.kernel_default = []
228 self.originated = []
229 self.originated_default = []
230 self.static = []
231 self.static_blackhole = []
232 self.static_default = []
233 self.bgp_own = []
234 self.bgp_own_blackhole = []
235 self.bgp_own_default = []
236 self.bgp_customer = []
237 self.bgp_customer_blackhole = []
238 self.bgp_peering = []
239 self.bgp_transit = []
240 self.bgp_transit_default = []
243class BGPPeerLargeCommunities: # pylint: disable=too-few-public-methods
244 """
245 BGP peer large communities.
247 Attributes
248 ----------
249 incoming : List[str]
250 List of large communities to add to incoming prefixes.
251 outgoing : BGPPeerLargeCommunitiesOutgoing
252 List of large communities to add to outgoing prefixes.
254 """
256 incoming: list[str]
258 outgoing: BGPPeerLargeCommunitiesOutgoing
260 def __init__(self) -> None:
261 """Initialize object."""
262 self.incoming = []
263 self.outgoing = BGPPeerLargeCommunitiesOutgoing()
266class BGPPeerPrependItem: # pylint: disable=too-few-public-methods
267 """
268 BGP peer prepending item.
270 Attributes
271 ----------
272 own_asn: int
273 Number of times to prepend our own ASN.
274 first_asn: int
275 Number of times to prepend the first ASN.
277 """
279 own_asn: int
281 def __init__(self) -> None:
282 """Initialize object."""
283 self.own_asn = 0
286class BGPPeerPrepend: # pylint: disable=too-few-public-methods,too-many-instance-attributes
287 """
288 BGP peer prepending.
290 Attributes
291 ----------
292 connected: BGPPeerPrependItem
293 Connected route prepending options.
294 kernel: BGPPeerPrependItem
295 Kernel route prepending options.
296 kernel_blackhole: BGPPeerPrependItem
297 Kernel blackhole route prepending options.
298 kernel_default: BGPPeerPrependItem
299 Kernel default route prepending options.
300 originated: BGPPeerPrependItem
301 Originated route prepending options.
302 originated_default: BGPPeerPrependItem
303 Originated default route prepending options.
304 static: BGPPeerPrependItem
305 Static route prepending options.
306 static_blackhole: BGPPeerPrependItem
307 Static blackhole route prepending options.
308 static_default: BGPPeerPrependItem
309 Static default route prepending options.
310 bgp_own: BGPPeerPrependItem
311 BGP own route prepending options.
312 bgp_own_blackhole: BGPPeerPrependItem
313 BGP own blackhole route prepending options.
314 bgp_own_default: BGPPeerPrependItem
315 BGP own default route prepending options.
316 bgp_customer: BGPPeerPrependItem
317 BGP customer route prepending options.
318 bgp_customer_blackhole: BGPPeerPrependItem
319 BGP customer blackhole route prepending options.
320 bgp_peering: BGPPeerPrependItem
321 BGP peering route prepending options.
322 bgp_transit: BGPPeerPrependItem
323 BGP transit route prepending options.
324 bgp_transit_default: BGPPeerPrependItem
325 BGP transit default route prepending options.
327 """
329 connected: BGPPeerPrependItem
330 kernel: BGPPeerPrependItem
331 kernel_blackhole: BGPPeerPrependItem
332 kernel_default: BGPPeerPrependItem
333 originated: BGPPeerPrependItem
334 originated_default: BGPPeerPrependItem
335 static: BGPPeerPrependItem
336 static_blackhole: BGPPeerPrependItem
337 static_default: BGPPeerPrependItem
338 bgp_own: BGPPeerPrependItem
339 bgp_own_blackhole: BGPPeerPrependItem
340 bgp_own_default: BGPPeerPrependItem
341 bgp_customer: BGPPeerPrependItem
342 bgp_customer_blackhole: BGPPeerPrependItem
343 bgp_peering: BGPPeerPrependItem
344 bgp_transit: BGPPeerPrependItem
345 bgp_transit_default: BGPPeerPrependItem
347 def __init__(self) -> None:
348 """Initialize object."""
349 self.connected = BGPPeerPrependItem()
350 self.kernel = BGPPeerPrependItem()
351 self.kernel_blackhole = BGPPeerPrependItem()
352 self.kernel_default = BGPPeerPrependItem()
353 self.originated = BGPPeerPrependItem()
354 self.originated_default = BGPPeerPrependItem()
355 self.static = BGPPeerPrependItem()
356 self.static_blackhole = BGPPeerPrependItem()
357 self.static_default = BGPPeerPrependItem()
358 self.bgp_own = BGPPeerPrependItem()
359 self.bgp_own_blackhole = BGPPeerPrependItem()
360 self.bgp_own_default = BGPPeerPrependItem()
361 self.bgp_customer = BGPPeerPrependItem()
362 self.bgp_customer_blackhole = BGPPeerPrependItem()
363 self.bgp_peering = BGPPeerPrependItem()
364 self.bgp_transit = BGPPeerPrependItem()
365 self.bgp_transit_default = BGPPeerPrependItem()
368class BGPPeerRoutePolicyAccept: # pylint: disable=too-few-public-methods
369 """
370 BGP route policy for acceptance of routes from BGP peers into the main BGP table.
372 Attributes
373 ----------
374 bgp_customer_blackhole : bool
375 Allow accepting a blackhole route from a customer.
376 bgp_own_blackhole : bool
377 Allow accepting a blackhole route that originated from our own federation.
378 bgp_own_default : bool
379 Allow accepting a default route that originated from our own federation.
380 bgp_transit_default : bool
381 Allow accepting a default route that originated from a transit peer.
383 """
385 bgp_customer_blackhole: bool
386 bgp_own_blackhole: bool
387 bgp_own_default: bool
388 bgp_transit_default: bool
390 def __init__(self) -> None:
391 """Initialize object."""
392 self.bgp_customer_blackhole = False
393 self.bgp_own_blackhole = False
394 self.bgp_own_default = False
395 self.bgp_transit_default = False
398class BGPPeerImportFilterDenyPolicy: # pylint: disable=too-few-public-methods
399 """
400 BGP filter deny policy for incoming routes from the BGP peer.
402 Attributes
403 ----------
404 aspath_asns : BGPPeerFilterItem
405 List of ASNs to filter in the AS-PATH.
406 origin_asns : BGPPeerFilterItem
407 List of origin ASNs to filter on.
408 prefixes : BGPPeerFilterItem
409 List of prefixes to filter on.
412 """
414 aspath_asns: BGPPeerFilterItem
415 origin_asns: BGPPeerFilterItem
416 prefixes: BGPPeerFilterItem
418 def __init__(self) -> None:
419 """Initialize object."""
420 self.aspath_asns = []
421 self.origin_asns = []
422 self.prefixes = []
425class BGPPeerImportFilterPolicy: # pylint: disable=too-few-public-methods
426 """
427 BGP filter policy for incoming routes from the BGP peer.
429 Attributes
430 ----------
431 as_sets : BGPPeerFilterItem
432 List of AS-SET's to filter on.
433 aspath_asns : BGPPeerFilterItem
434 List of ASNs to filter in the AS-PATH.
435 origin_asns : BGPPeerFilterItem
436 List of origin ASNs to filter on.
437 peer_asns : BGPPeerFilterItem
438 List of peer ASNs to filter on.
439 prefixes : BGPPeerFilterItem
440 List of prefixes to filter on.
441 origin_asns_irr : List[str]
442 INTERNAL ONLY. These ASNs are resolved from the `as_sets` attribute.
443 prefixes_irr : List[str]
444 INTERNAL ONLY. These prefixes are resolved from the `as_sets` attribute.
446 """
448 as_sets: BGPPeerFilterItem
449 aspath_asns: BGPPeerFilterItem
450 origin_asns: BGPPeerFilterItem
451 peer_asns: BGPPeerFilterItem
452 prefixes: BGPPeerFilterItem
453 origin_asns_irr: list[str]
454 prefixes_irr: list[str]
456 def __init__(self) -> None:
457 """Initialize object."""
458 self.as_sets = []
459 self.aspath_asns = []
460 self.origin_asns = []
461 self.peer_asns = []
462 self.prefixes = []
463 # INTERNAL attributes, these are populated during initialization
464 self.origin_asns_irr = []
465 self.prefixes_irr = []
468class BGPPeerExportFilterPolicy: # pylint: disable=too-few-public-methods
469 """
470 BGP filter policy for outgoing routes to the BGP peer.
472 Attributes
473 ----------
474 origin_asns : BGPPeerFilterItem
475 List of origin ASNs to filter on.
476 prefixes : BGPPeerFilterItem
477 List of prefixes to filter on.
479 """
481 origin_asns: BGPPeerFilterItem
482 prefixes: BGPPeerFilterItem
484 def __init__(self) -> None:
485 """Initialize object."""
486 self.origin_asns = []
487 self.prefixes = []
490class BGPPeerLocation: # pylint: disable=too-few-public-methods
491 """
492 BGP peer location.
494 Attributes
495 ----------
496 iso3166 : Optional[int]
497 ISO3166 numeric location of the peer.
498 unm49 : Optional[int]
499 UN.M49 location of the peer.
501 """
503 unm49: int | None
504 iso3166: int | None
506 def __init__(self) -> None:
507 """Initialize object."""
508 self.unm49 = None
509 self.iso3166 = None
512class BGPPeerRoutePolicyRedistribute: # pylint: disable=too-few-public-methods,too-many-instance-attributes
513 """
514 BGP peer route policy for redistributing of routes.
516 Attributes
517 ----------
518 connected : bool
519 Redistribute connected routes to the peer BGP table. Defaults to `False`.
520 kernel : bool
521 Redistribute kernel routes to the peer BGP table. Defaults to `False`.
522 kernel_blackhole : bool
523 Redistribute kernel blackhole routes to the peer BGP table. Defaults to `False`.
524 kernel_default : bool
525 Redistribute kernel default routes to the peer BGP table. Defaults to `False`.
526 originated : bool
527 Redistribute originated routes to the peer BGP table. Defaults to `False`.
528 originated_default : bool
529 Redistribute originated default routes to the peer BGP table. Defaults to `False`.
530 static : bool
531 Redistribute static routes to the peer BGP table. Defaults to `False`.
532 static_blackhole : bool
533 Redistribute static blackhole routes to the peer BGP table. Defaults to `False`.
534 static_default : bool
535 Redistribute static default routes to the peer BGP table. Defaults to `False`.
536 bgp_own: bool
537 Redistribute our own originated BGP routes to the peer BGP table. Defaults to `False`.
538 bgp_customer : bool
539 Redistribute customer BGP routes to the peer BGP table. Defaults to `False`.
540 bgp_peering : bool
541 Redistribute peering BGP routes to the peer BGP table. Defaults to `False`.
542 bgp_transit : bool
543 Redistribute transit BGP routes to the peer BGP table. Defaults to `False`.
544 bgp_customer_blackhole : bool
545 Redistribute customer blackhole BGP routes to the peer BGP table. Defaults to `False`.
546 bgp_own_blackhole : bool
547 Redistribute our own blackhole BGP routes to the peer BGP table. Defaults to `False`.
548 bgp_own_default : bool
549 Redistribute our own default BGP routes to the peer BGP table. Defaults to `False`.
550 bgp_transit_default : bool
551 Redistribute transit default BGP routes to the peer BGP table. Defaults to `False`.
553 """
555 connected: bool
556 kernel: bool
557 kernel_blackhole: bool
558 kernel_default: bool
559 originated: bool
560 originated_default: bool
561 static: bool
562 static_blackhole: bool
563 static_default: bool
564 bgp_own: bool
565 bgp_customer: bool
566 bgp_peering: bool
567 bgp_transit: bool
568 bgp_customer_blackhole: bool
569 bgp_own_blackhole: bool
570 bgp_own_default: bool
571 bgp_transit_default: bool
573 def __init__(self) -> None:
574 """Initialize object."""
575 self.connected = False
576 self.kernel = False
577 self.kernel_blackhole = False
578 self.kernel_default = False
579 self.originated = False
580 self.originated_default = False
581 self.static = False
582 self.static_blackhole = False
583 self.static_default = False
584 self.bgp_own = False
585 self.bgp_customer = False
586 self.bgp_peering = False
587 self.bgp_transit = False
588 self.bgp_customer_blackhole = False
589 self.bgp_own_blackhole = False
590 self.bgp_own_default = False
591 self.bgp_transit_default = False
594class BGPPeerConstraints: # pylint: disable=too-few-public-methods,too-many-instance-attributes
595 """
596 BGP peer prefix limits.
598 Attributes
599 ----------
600 import_maxlen4 : Optional[int]
601 Prefix import maximum length for IPv4.
602 import_minlen4 : Optional[int]
603 Prefix import minimum length for IPv4.
604 export_maxlen4 : Optional[int]
605 Prefix export maximum length for IPv4.
606 export_minlen4 : Optional[int]
607 Prefix export minimum length for IPv4.
608 import_maxlen6 : Optional[int]
609 Prefix import maximum length for IPv6.
610 import_minlen6 : Optional[int]
611 Prefix import minimum length for IPv6.
612 export_maxlen6 : Optional[int]
613 Prefix export maximum length for IPv6.
614 export_minlen6 : Optional[int]
615 Prefix export minimum length for IPv6.
616 blackhole_import_maxlen4 : Optional[int]
617 Blackhole maximum length for IPv4.
618 blackhole_import_minlen4 : Optional[int]
619 Blackhole minimum length for IPv4.
620 blackhole_export_maxlen4 : Optional[int]
621 Blackhole maximum length for IPv4.
622 blackhole_export_minlen4 : Optional[int]
623 Blackhole minimum length for IPv4.
624 blackhole_import_maxlen6 : Optional[int]
625 Blackhole maximum length for IPv6.
626 blackhole_import_minlen6 : Optional[int]
627 Blackhole minimum length for IPv6.
628 blackhole_export_maxlen6 : Optional[int]
629 Blackhole maximum length for IPv6.
630 blackhole_export_minlen6 : Optional[int]
631 Blackhole minimum length for IPv6.
632 aspath_import_maxlen : Optional[int]
633 AS-PATH maximum length.
634 aspath_import_minlen : Optional[int]
635 AS-PATH minimum length.
636 community_maxlen : Optional[int]
637 Community maximum length.
638 extended_community_maxlen : Optional[int]
639 Extended community maximum length.
640 large_community_maxlen : Optional[int]
641 Large community maximum length.
643 """
645 import_maxlen4: int | None
646 import_minlen4: int | None
648 export_maxlen4: int | None
649 export_minlen4: int | None
651 import_maxlen6: int | None
652 import_minlen6: int | None
654 export_maxlen6: int | None
655 export_minlen6: int | None
657 blackhole_import_maxlen4: int | None
658 blackhole_import_minlen4: int | None
660 blackhole_export_maxlen4: int | None
661 blackhole_export_minlen4: int | None
663 blackhole_import_maxlen6: int | None
664 blackhole_import_minlen6: int | None
666 blackhole_export_maxlen6: int | None
667 blackhole_export_minlen6: int | None
669 aspath_import_maxlen: int | None
670 aspath_import_minlen: int | None
672 community_import_maxlen: int | None
673 extended_community_import_maxlen: int | None
674 large_community_import_maxlen: int | None
676 def __init__(self) -> None:
677 """Initialize object."""
679 self.import_maxlen4 = None
680 self.import_minlen4 = None
682 self.export_maxlen4 = None
683 self.export_minlen4 = None
685 self.import_maxlen6 = None
686 self.import_minlen6 = None
688 self.export_maxlen6 = None
689 self.export_minlen6 = None
691 self.blackhole_import_maxlen4 = None
692 self.blackhole_import_minlen4 = None
694 self.blackhole_export_maxlen4 = None
695 self.blackhole_export_minlen4 = None
697 self.blackhole_import_maxlen6 = None
698 self.blackhole_import_minlen6 = None
700 self.blackhole_export_maxlen6 = None
701 self.blackhole_export_minlen6 = None
703 self.aspath_import_maxlen = None
704 self.aspath_import_minlen = None
706 self.community_import_maxlen = None
707 self.extended_community_import_maxlen = None
708 self.large_community_import_maxlen = None
711class BGPPeerAttributes: # pylint: disable=too-few-public-methods,too-many-instance-attributes
712 """
713 BGP peer attributes.
715 Attributes
716 ----------
717 name : str
718 Peer name.
720 description : str
721 Description of the peer.
723 location : BGPPeerLocation
724 Peer location.
726 peer_type : str
727 Peer type.
729 asn : int
730 Peers ASN.
732 neighbor4: Optional[str]
733 Neighbor IPv4 address.
735 neighbor6: Optional[str]
736 Neighbor IPv6 address.
738 source_address4: Optional[str]
739 Source IPv4 address.
741 source_address6: Optional[str]
742 Source IPv6 address.
744 connect_delay_time: Optional[str]
745 BGP connect delay time.
747 connect_retry_time: Optional[str]
748 BGP connection retry time.
750 error_wait_time: Optional[str]
751 BGP error wait time.
753 multihop: Optional[str]
754 BGP multihop value.
756 password: Optional[str]
757 BGP password.
759 ttl_security: bool
760 Indicate if BGP TTL security should be enabled.
762 cost : int
763 Cost of this peer, this is the number minused from the local_pref.
765 graceful_shutdown : bool
766 Set peer in GRACEFUL_SHUTDOWN mode.
768 communities: BGPPeerCommunities
769 Incoming and outgoing communities.
771 large_communities: BGPPeerLargeCommunities
772 Incoming and outgoing large communities.
774 prepend:
775 AS-PATH prepending.
777 passive : bool
778 Indicate if this is a passive peer or not.
780 quarantine : bool
781 Set if the peer is quarantined.
783 prefix_limit_action : BGPPeerImportPrefixLimitAction
784 Prefix limit action used when the import prefix count is exceeded.
786 prefix_limit4 : BGPPeerPrefixLimit
787 Prefix limit for IPv4.
789 prefix_limit6 : BGPPeerPrefixLimit
790 Prefix limit for IPv6.
792 prefix_limit4_peeringdb : BGPPeerPrefixLimit
793 Prefix limit for IPv4.
795 prefix_limit6_peeringdb : BGPPeerPrefixLimit
796 Prefix limit for IPv6.
798 replace_aspath : Optional[int]
799 ASN to substitute in the AS-PATH.
801 route_policy_accept : BGPPeerRoutePolicyAccept
802 Route policy for acceptance of routes from BGP peers into our main BGP table.
804 route_policy_redistribute : BGPPeerRoutePolicyRedistribute
805 Route policy for redistribution of routes to the BGP peer.
807 import_filter_policy: BGPPeerImportFilterPolicy
808 BGP peer import filter policy.
810 import_filter_deny_policy: BGPPeerImportFilterDenyPolicy
811 BGP peer import filter deny policy.
813 export_filter_policy: BGPPeerExportFilterPolicy
814 BGP peer export filter policy.
816 blackhole_community: Optional[Union[List[str], bool]]
817 Blackhole community to use for blackhole routes.
819 constraints: BGPPeerConstraints
820 BGP peer constraint overrides.
822 actions: Optional[BGPPeerActions]
824 use_rpki: bool
825 Use RPKI validation for this peer.
827 """
829 _name: str | None
830 _description: str | None
831 location: BGPPeerLocation
833 _peer_type: str | None
834 _asn: int | None
836 neighbor4: str | None
837 neighbor6: str | None
838 source_address4: str | None
839 source_address6: str | None
841 connect_delay_time: str | None
842 connect_retry_time: str | None
843 error_wait_time: str | None
844 multihop: str | None
845 password: str | None
846 ttl_security: bool
848 cost: int
850 add_paths: str | None
852 graceful_shutdown: bool
854 communities: BGPPeerCommunities
855 large_communities: BGPPeerLargeCommunities
857 prepend: BGPPeerPrepend
859 # Default to disabling passive mode
860 passive: bool
862 quarantine: bool
864 prefix_limit_action: BGPPeerImportPrefixLimitAction
866 prefix_limit4: BGPPeerPrefixLimit
867 prefix_limit6: BGPPeerPrefixLimit
869 prefix_limit4_peeringdb: BGPPeerPrefixLimit
870 prefix_limit6_peeringdb: BGPPeerPrefixLimit
872 replace_aspath: bool
874 route_policy_accept: BGPPeerRoutePolicyAccept
875 route_policy_redistribute: BGPPeerRoutePolicyRedistribute
877 import_filter_policy: BGPPeerImportFilterPolicy
878 import_filter_deny_policy: BGPPeerImportFilterDenyPolicy
879 export_filter_policy: BGPPeerExportFilterPolicy
881 blackhole_community: list[str] | bool | None
883 constraints: BGPPeerConstraints
885 actions: BGPPeerActions | None
887 use_rpki: bool
889 def __init__(self) -> None:
890 """Initialize object."""
892 self._name = None
893 self._description = None
894 self.location = BGPPeerLocation()
896 self._peer_type = None
897 self._asn = None
899 self.neighbor4 = None
900 self.neighbor6 = None
901 self.source_address4 = None
902 self.source_address6 = None
904 self.connect_delay_time = None
905 self.connect_retry_time = None
906 self.error_wait_time = None
907 self.multihop = None
908 self.password = None
909 self.ttl_security = False
911 self.cost = 0
913 self.add_paths = None
915 self.graceful_shutdown = False
917 self.communities = BGPPeerCommunities()
918 self.large_communities = BGPPeerLargeCommunities()
920 self.prepend = BGPPeerPrepend()
922 # Default to disabling passive mode
923 self.passive = False
925 self.quarantine = False
927 self.prefix_limit_action = BGPPeerImportPrefixLimitAction.RESTART
929 self.prefix_limit4 = None
930 self.prefix_limit6 = None
932 self.prefix_limit4_peeringdb = None
933 self.prefix_limit6_peeringdb = None
935 self.replace_aspath = False
937 # Route policies
938 self.route_policy_accept = BGPPeerRoutePolicyAccept()
939 self.route_policy_redistribute = BGPPeerRoutePolicyRedistribute()
941 self.import_filter_policy = BGPPeerImportFilterPolicy()
942 self.import_filter_deny_policy = BGPPeerImportFilterDenyPolicy()
943 self.export_filter_policy = BGPPeerExportFilterPolicy()
945 self.blackhole_community = None
947 self.constraints = BGPPeerConstraints()
949 self.actions = None
951 self.use_rpki = False
953 @property
954 def name(self) -> str:
955 """Return our name."""
956 if self._name is None:
957 raise BirdPlanError("Peer name must be set")
958 return self._name
960 @name.setter
961 def name(self, name: str) -> None:
962 """Set our name."""
963 self._name = name
965 @property
966 def description(self) -> str:
967 """Return our description."""
968 if not self._description:
969 raise BirdPlanError("Peer description must be set")
970 return self._description
972 @description.setter
973 def description(self, description: str) -> None:
974 """Set our description."""
975 self._description = description
977 @property
978 def peer_type(self) -> str:
979 """Return our peer_type."""
980 if not self._peer_type:
981 raise BirdPlanError("Peer peer_type must be set")
982 return self._peer_type
984 @peer_type.setter
985 def peer_type(self, peer_type: str) -> None:
986 """Set our peer_type."""
987 self._peer_type = peer_type
989 @property
990 def asn(self) -> int:
991 """Return our asn."""
992 if not self._asn:
993 raise BirdPlanError("Peer asn must be set")
994 return self._asn
996 @asn.setter
997 def asn(self, asn: int) -> None:
998 """Set our asn."""
999 self._asn = asn