Coverage for birdplan/bird_config/sections/protocols/bgp/peer/peer_attributes.py: 99%
369 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-23 03:27 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-23 03:27 +0000
1#
2# SPDX-License-Identifier: GPL-3.0-or-later
3#
4# Copyright (c) 2019-2024, 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
22from typing import Dict, List, Optional, Union
24from ......exceptions import BirdPlanError
26__all__ = [
27 "BGPPeerLargeCommunitiesOutgoing",
28 "BGPPeerLargeCommunities",
29 "BGPPeerPrependItem",
30 "BGPPeerPrepend",
31 "BGPPeerRoutePolicyAccept",
32 "BGPPeerImportFilterPolicy",
33 "BGPPeerLocation",
34 "BGPPeerRoutePolicyRedistribute",
35 "BGPPeerConstraints",
36 "BGPPeerAttributes",
37]
39# This type is a string as we can have it set to "peeringdb"
40BGPPeerPrefixLimit = Optional[str]
42BGPPeerFilterItem = Union[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
280 # first_asn: int
282 def __init__(self) -> None:
283 """Initialize object."""
284 self.own_asn = 0
286 # self.first_asn = 0
289class BGPPeerPrepend: # pylint: disable=too-few-public-methods,too-many-instance-attributes
290 """
291 BGP peer prepending.
293 Attributes
294 ----------
295 connected: BGPPeerPrependItem
296 Connected route prepending options.
297 kernel: BGPPeerPrependItem
298 Kernel route prepending options.
299 kernel_blackhole: BGPPeerPrependItem
300 Kernel blackhole route prepending options.
301 kernel_default: BGPPeerPrependItem
302 Kernel default route prepending options.
303 originated: BGPPeerPrependItem
304 Originated route prepending options.
305 originated_default: BGPPeerPrependItem
306 Originated default route prepending options.
307 static: BGPPeerPrependItem
308 Static route prepending options.
309 static_blackhole: BGPPeerPrependItem
310 Static blackhole route prepending options.
311 static_default: BGPPeerPrependItem
312 Static default route prepending options.
313 bgp_own: BGPPeerPrependItem
314 BGP own route prepending options.
315 bgp_own_blackhole: BGPPeerPrependItem
316 BGP own blackhole route prepending options.
317 bgp_own_default: BGPPeerPrependItem
318 BGP own default route prepending options.
319 bgp_customer: BGPPeerPrependItem
320 BGP customer route prepending options.
321 bgp_customer_blackhole: BGPPeerPrependItem
322 BGP customer blackhole route prepending options.
323 bgp_peering: BGPPeerPrependItem
324 BGP peering route prepending options.
325 bgp_transit: BGPPeerPrependItem
326 BGP transit route prepending options.
327 bgp_transit_default: BGPPeerPrependItem
328 BGP transit default route prepending options.
330 """
332 connected: BGPPeerPrependItem
333 kernel: BGPPeerPrependItem
334 kernel_blackhole: BGPPeerPrependItem
335 kernel_default: BGPPeerPrependItem
336 originated: BGPPeerPrependItem
337 originated_default: BGPPeerPrependItem
338 static: BGPPeerPrependItem
339 static_blackhole: BGPPeerPrependItem
340 static_default: BGPPeerPrependItem
341 bgp_own: BGPPeerPrependItem
342 bgp_own_blackhole: BGPPeerPrependItem
343 bgp_own_default: BGPPeerPrependItem
344 bgp_customer: BGPPeerPrependItem
345 bgp_customer_blackhole: BGPPeerPrependItem
346 bgp_peering: BGPPeerPrependItem
347 bgp_transit: BGPPeerPrependItem
348 bgp_transit_default: BGPPeerPrependItem
350 def __init__(self) -> None:
351 """Initialize object."""
352 self.connected = BGPPeerPrependItem()
353 self.kernel = BGPPeerPrependItem()
354 self.kernel_blackhole = BGPPeerPrependItem()
355 self.kernel_default = BGPPeerPrependItem()
356 self.originated = BGPPeerPrependItem()
357 self.originated_default = BGPPeerPrependItem()
358 self.static = BGPPeerPrependItem()
359 self.static_blackhole = BGPPeerPrependItem()
360 self.static_default = BGPPeerPrependItem()
361 self.bgp_own = BGPPeerPrependItem()
362 self.bgp_own_blackhole = BGPPeerPrependItem()
363 self.bgp_own_default = BGPPeerPrependItem()
364 self.bgp_customer = BGPPeerPrependItem()
365 self.bgp_customer_blackhole = BGPPeerPrependItem()
366 self.bgp_peering = BGPPeerPrependItem()
367 self.bgp_transit = BGPPeerPrependItem()
368 self.bgp_transit_default = BGPPeerPrependItem()
371class BGPPeerRoutePolicyAccept: # pylint: disable=too-few-public-methods
372 """
373 BGP route policy for acceptance of routes from BGP peers into the main BGP table.
375 Attributes
376 ----------
377 bgp_customer_blackhole : bool
378 Allow accepting a blackhole route from a customer.
379 bgp_own_blackhole : bool
380 Allow accepting a blackhole route that originated from our own federation.
381 bgp_own_default : bool
382 Allow accepting a default route that originated from our own federation.
383 bgp_transit_default : bool
384 Allow accepting a default route that originated from a transit peer.
386 """
388 bgp_customer_blackhole: bool
389 bgp_own_blackhole: bool
390 bgp_own_default: bool
391 bgp_transit_default: bool
393 def __init__(self) -> None:
394 """Initialize object."""
395 self.bgp_customer_blackhole = False
396 self.bgp_own_blackhole = False
397 self.bgp_own_default = False
398 self.bgp_transit_default = False
401class BGPPeerImportFilterDenyPolicy: # pylint: disable=too-few-public-methods
402 """
403 BGP filter deny policy for incoming routes from the BGP peer.
405 Attributes
406 ----------
407 aspath_asns : BGPPeerFilterItem
408 List of ASNs to filter in the AS-PATH.
409 origin_asns : BGPPeerFilterItem
410 List of origin ASNs to filter on.
411 prefixes : BGPPeerFilterItem
412 List of prefixes to filter on.
415 """
417 aspath_asns: BGPPeerFilterItem
418 origin_asns: BGPPeerFilterItem
419 prefixes: BGPPeerFilterItem
421 def __init__(self) -> None:
422 """Initialize object."""
423 self.aspath_asns = []
424 self.origin_asns = []
425 self.prefixes = []
428class BGPPeerImportFilterPolicy: # pylint: disable=too-few-public-methods
429 """
430 BGP filter policy for incoming routes from the BGP peer.
432 Attributes
433 ----------
434 as_sets : BGPPeerFilterItem
435 List of AS-SET's to filter on.
436 aspath_asns : BGPPeerFilterItem
437 List of ASNs to filter in the AS-PATH.
438 origin_asns : BGPPeerFilterItem
439 List of origin ASNs to filter on.
440 peer_asns : BGPPeerFilterItem
441 List of peer ASNs to filter on.
442 prefixes : BGPPeerFilterItem
443 List of prefixes to filter on.
444 origin_asns_irr : List[str]
445 INTERNAL ONLY. These ASNs are resolved from the `as_sets` attribute.
446 prefixes_irr : List[str]
447 INTERNAL ONLY. These prefixes are resolved from the `as_sets` attribute.
449 """
451 as_sets: BGPPeerFilterItem
452 aspath_asns: BGPPeerFilterItem
453 origin_asns: BGPPeerFilterItem
454 peer_asns: BGPPeerFilterItem
455 prefixes: BGPPeerFilterItem
456 origin_asns_irr: List[str]
457 prefixes_irr: List[str]
459 def __init__(self) -> None:
460 """Initialize object."""
461 self.as_sets = []
462 self.aspath_asns = []
463 self.origin_asns = []
464 self.peer_asns = []
465 self.prefixes = []
466 # INTERNAL attributes, these are populated during initialization
467 self.origin_asns_irr = []
468 self.prefixes_irr = []
471class BGPPeerExportFilterPolicy: # pylint: disable=too-few-public-methods
472 """
473 BGP filter policy for outgoing routes to the BGP peer.
475 Attributes
476 ----------
477 origin_asns : BGPPeerFilterItem
478 List of origin ASNs to filter on.
479 prefixes : BGPPeerFilterItem
480 List of prefixes to filter on.
481 """
483 origin_asns: BGPPeerFilterItem
484 prefixes: BGPPeerFilterItem
486 def __init__(self) -> None:
487 """Initialize object."""
488 self.origin_asns = []
489 self.prefixes = []
492class BGPPeerLocation: # pylint: disable=too-few-public-methods
493 """
494 BGP peer location.
496 Attributes
497 ----------
498 iso3166 : Optional[int]
499 ISO3166 numeric location of the peer.
500 unm49 : Optional[int]
501 UN.M49 location of the peer.
503 """
505 unm49: Optional[int]
506 iso3166: Optional[int]
508 def __init__(self) -> None:
509 """Initialize object."""
510 self.unm49 = None
511 self.iso3166 = None
514class BGPPeerRoutePolicyRedistribute: # pylint: disable=too-few-public-methods,too-many-instance-attributes
515 """
516 BGP peer route policy for redistributing of routes.
518 Attributes
519 ----------
520 connected : bool
521 Redistribute connected routes to the peer BGP table. Defaults to `False`.
522 kernel : bool
523 Redistribute kernel routes to the peer BGP table. Defaults to `False`.
524 kernel_blackhole : bool
525 Redistribute kernel blackhole routes to the peer BGP table. Defaults to `False`.
526 kernel_default : bool
527 Redistribute kernel default routes to the peer BGP table. Defaults to `False`.
528 originated : bool
529 Redistribute originated routes to the peer BGP table. Defaults to `False`.
530 originated_default : bool
531 Redistribute originated default routes to the peer BGP table. Defaults to `False`.
532 static : bool
533 Redistribute static routes to the peer BGP table. Defaults to `False`.
534 static_blackhole : bool
535 Redistribute static blackhole routes to the peer BGP table. Defaults to `False`.
536 static_default : bool
537 Redistribute static default routes to the peer BGP table. Defaults to `False`.
538 bgp_own: bool
539 Redistribute our own originated BGP routes to the peer BGP table. Defaults to `False`.
540 bgp_customer : bool
541 Redistribute customer BGP routes to the peer BGP table. Defaults to `False`.
542 bgp_peering : bool
543 Redistribute peering BGP routes to the peer BGP table. Defaults to `False`.
544 bgp_transit : bool
545 Redistribute transit BGP routes to the peer BGP table. Defaults to `False`.
546 bgp_customer_blackhole : bool
547 Redistribute customer blackhole BGP routes to the peer BGP table. Defaults to `False`.
548 bgp_own_blackhole : bool
549 Redistribute our own blackhole BGP routes to the peer BGP table. Defaults to `False`.
550 bgp_own_default : bool
551 Redistribute our own default BGP routes to the peer BGP table. Defaults to `False`.
552 bgp_transit_default : bool
553 Redistribute transit default BGP routes to the peer BGP table. Defaults to `False`.
555 """
557 connected: bool
558 kernel: bool
559 kernel_blackhole: bool
560 kernel_default: bool
561 originated: bool
562 originated_default: bool
563 static: bool
564 static_blackhole: bool
565 static_default: bool
566 bgp_own: bool
567 bgp_customer: bool
568 bgp_peering: bool
569 bgp_transit: bool
570 bgp_customer_blackhole: bool
571 bgp_own_blackhole: bool
572 bgp_own_default: bool
573 bgp_transit_default: bool
575 def __init__(self) -> None:
576 """Initialize object."""
577 self.connected = False
578 self.kernel = False
579 self.kernel_blackhole = False
580 self.kernel_default = False
581 self.originated = False
582 self.originated_default = False
583 self.static = False
584 self.static_blackhole = False
585 self.static_default = False
586 self.bgp_own = False
587 self.bgp_customer = False
588 self.bgp_peering = False
589 self.bgp_transit = False
590 self.bgp_customer_blackhole = False
591 self.bgp_own_blackhole = False
592 self.bgp_own_default = False
593 self.bgp_transit_default = False
596class BGPPeerConstraints: # pylint: disable=too-few-public-methods,too-many-instance-attributes
597 """
598 BGP peer prefix limits.
600 Attributes
601 ----------
602 import_maxlen4 : Optional[int]
603 Prefix import maximum length for IPv4.
604 import_minlen4 : Optional[int]
605 Prefix import minimum length for IPv4.
606 export_maxlen4 : Optional[int]
607 Prefix export maximum length for IPv4.
608 export_minlen4 : Optional[int]
609 Prefix export minimum length for IPv4.
610 import_maxlen6 : Optional[int]
611 Prefix import maximum length for IPv6.
612 import_minlen6 : Optional[int]
613 Prefix import minimum length for IPv6.
614 export_maxlen6 : Optional[int]
615 Prefix export maximum length for IPv6.
616 export_minlen6 : Optional[int]
617 Prefix export minimum length for IPv6.
618 blackhole_import_maxlen4 : Optional[int]
619 Blackhole maximum length for IPv4.
620 blackhole_import_minlen4 : Optional[int]
621 Blackhole minimum length for IPv4.
622 blackhole_export_maxlen4 : Optional[int]
623 Blackhole maximum length for IPv4.
624 blackhole_export_minlen4 : Optional[int]
625 Blackhole minimum length for IPv4.
626 blackhole_import_maxlen6 : Optional[int]
627 Blackhole maximum length for IPv6.
628 blackhole_import_minlen6 : Optional[int]
629 Blackhole minimum length for IPv6.
630 blackhole_export_maxlen6 : Optional[int]
631 Blackhole maximum length for IPv6.
632 blackhole_export_minlen6 : Optional[int]
633 Blackhole minimum length for IPv6.
634 aspath_import_maxlen : Optional[int]
635 AS-PATH maximum length.
636 aspath_import_minlen : Optional[int]
637 AS-PATH minimum length.
638 community_maxlen : Optional[int]
639 Community maximum length.
640 extended_community_maxlen : Optional[int]
641 Extended community maximum length.
642 large_community_maxlen : Optional[int]
643 Large community maximum length.
645 """
647 import_maxlen4: Optional[int]
648 import_minlen4: Optional[int]
650 export_maxlen4: Optional[int]
651 export_minlen4: Optional[int]
653 import_maxlen6: Optional[int]
654 import_minlen6: Optional[int]
656 export_maxlen6: Optional[int]
657 export_minlen6: Optional[int]
659 blackhole_import_maxlen4: Optional[int]
660 blackhole_import_minlen4: Optional[int]
662 blackhole_export_maxlen4: Optional[int]
663 blackhole_export_minlen4: Optional[int]
665 blackhole_import_maxlen6: Optional[int]
666 blackhole_import_minlen6: Optional[int]
668 blackhole_export_maxlen6: Optional[int]
669 blackhole_export_minlen6: Optional[int]
671 aspath_import_maxlen: Optional[int]
672 aspath_import_minlen: Optional[int]
674 community_import_maxlen: Optional[int]
675 extended_community_import_maxlen: Optional[int]
676 large_community_import_maxlen: Optional[int]
678 def __init__(self) -> None:
679 """Initialize object."""
681 self.import_maxlen4 = None
682 self.import_minlen4 = None
684 self.export_maxlen4 = None
685 self.export_minlen4 = None
687 self.import_maxlen6 = None
688 self.import_minlen6 = None
690 self.export_maxlen6 = None
691 self.export_minlen6 = None
693 self.blackhole_import_maxlen4 = None
694 self.blackhole_import_minlen4 = None
696 self.blackhole_export_maxlen4 = None
697 self.blackhole_export_minlen4 = None
699 self.blackhole_import_maxlen6 = None
700 self.blackhole_import_minlen6 = None
702 self.blackhole_export_maxlen6 = None
703 self.blackhole_export_minlen6 = None
705 self.aspath_import_maxlen = None
706 self.aspath_import_minlen = None
708 self.community_import_maxlen = None
709 self.extended_community_import_maxlen = None
710 self.large_community_import_maxlen = None
713class BGPPeerAttributes: # pylint: disable=too-few-public-methods,too-many-instance-attributes
714 """
715 BGP peer attributes.
717 Attributes
718 ----------
719 name : str
720 Peer name.
722 description : str
723 Description of the peer.
725 location : BGPPeerLocation
726 Peer location.
728 peer_type : str
729 Peer type.
731 asn : int
732 Peers ASN.
734 neighbor4: Optional[str]
735 Neighbor IPv4 address.
737 neighbor6: Optional[str]
738 Neighbor IPv6 address.
740 source_address4: Optional[str]
741 Source IPv4 address.
743 source_address6: Optional[str]
744 Source IPv6 address.
746 connect_delay_time: Optional[str]
747 BGP connect delay time.
749 connect_retry_time: Optional[str]
750 BGP connection retry time.
752 error_wait_time: Optional[str]
753 BGP error wait time.
755 multihop: Optional[str]
756 BGP multihop value.
758 password: Optional[str]
759 BGP password.
761 ttl_security: bool
762 Indicate if BGP TTL security should be enabled.
764 cost : int
765 Cost of this peer, this is the number minused from the local_pref.
767 graceful_shutdown : bool
768 Set peer in GRACEFUL_SHUTDOWN mode.
770 communities: BGPPeerCommunities
771 Incoming and outgoing communities.
773 large_communities: BGPPeerLargeCommunities
774 Incoming and outgoing large communities.
776 prepend:
777 AS-PATH prepending.
779 passive : bool
780 Indicate if this is a passive peer or not.
782 quarantine : bool
783 Set if the peer is quarantined.
785 prefix_limit_action : BGPPeerImportPrefixLimitAction
786 Prefix limit action used when the import prefix count is exceeded.
788 prefix_limit4 : BGPPeerPrefixLimit
789 Prefix limit for IPv4.
791 prefix_limit6 : BGPPeerPrefixLimit
792 Prefix limit for IPv6.
794 prefix_limit4_peeringdb : BGPPeerPrefixLimit
795 Prefix limit for IPv4.
797 prefix_limit6_peeringdb : BGPPeerPrefixLimit
798 Prefix limit for IPv6.
800 replace_aspath : Optional[int]
801 ASN to substitute in the AS-PATH.
803 route_policy_accept : BGPPeerRoutePolicyAccept
804 Route policy for acceptance of routes from BGP peers into our main BGP table.
806 route_policy_redistribute : BGPPeerRoutePolicyRedistribute
807 Route policy for redistribution of routes to the BGP peer.
809 import_filter_policy: BGPPeerImportFilterPolicy
810 BGP peer import filter policy.
812 import_filter_deny_policy: BGPPeerImportFilterDenyPolicy
813 BGP peer import filter deny policy.
815 export_filter_policy: BGPPeerExportFilterPolicy
816 BGP peer export filter policy.
818 blackhole_community: Optional[Union[List[str], bool]]
819 Blackhole community to use for blackhole routes.
821 constraints: BGPPeerConstraints
822 BGP peer constraint overrides.
824 """
826 _name: Optional[str]
827 _description: Optional[str]
828 location: BGPPeerLocation
830 _peer_type: Optional[str]
831 _asn: Optional[int]
833 neighbor4: Optional[str]
834 neighbor6: Optional[str]
835 source_address4: Optional[str]
836 source_address6: Optional[str]
838 connect_delay_time: Optional[str]
839 connect_retry_time: Optional[str]
840 error_wait_time: Optional[str]
841 multihop: Optional[str]
842 password: Optional[str]
843 ttl_security: bool
845 cost: int
847 add_paths: Optional[str]
849 graceful_shutdown: bool
851 communities: BGPPeerCommunities
852 large_communities: BGPPeerLargeCommunities
854 prepend: BGPPeerPrepend
856 # Default to disabling passive mode
857 passive: bool
859 quarantine: bool
861 prefix_limit_action: BGPPeerImportPrefixLimitAction
863 prefix_limit4: BGPPeerPrefixLimit
864 prefix_limit6: BGPPeerPrefixLimit
866 prefix_limit4_peeringdb: BGPPeerPrefixLimit
867 prefix_limit6_peeringdb: BGPPeerPrefixLimit
869 replace_aspath: bool
871 route_policy_accept: BGPPeerRoutePolicyAccept
872 route_policy_redistribute: BGPPeerRoutePolicyRedistribute
874 import_filter_policy: BGPPeerImportFilterPolicy
875 import_filter_deny_policy: BGPPeerImportFilterDenyPolicy
876 export_filter_policy: BGPPeerExportFilterPolicy
878 blackhole_community: Optional[Union[List[str], bool]]
880 constraints: BGPPeerConstraints
882 def __init__(self) -> None:
883 """Initialize object."""
885 self._name = None
886 self._description = None
887 self.location = BGPPeerLocation()
889 self._peer_type = None
890 self._asn = None
892 self.neighbor4 = None
893 self.neighbor6 = None
894 self.source_address4 = None
895 self.source_address6 = None
897 self.connect_delay_time = None
898 self.connect_retry_time = None
899 self.error_wait_time = None
900 self.multihop = None
901 self.password = None
902 self.ttl_security = False
904 self.cost = 0
906 self.add_paths = None
908 self.graceful_shutdown = False
910 self.communities = BGPPeerCommunities()
911 self.large_communities = BGPPeerLargeCommunities()
913 self.prepend = BGPPeerPrepend()
915 # Default to disabling passive mode
916 self.passive = False
918 self.quarantine = False
920 self.prefix_limit_action = BGPPeerImportPrefixLimitAction.RESTART
922 self.prefix_limit4 = None
923 self.prefix_limit6 = None
925 self.prefix_limit4_peeringdb = None
926 self.prefix_limit6_peeringdb = None
928 self.replace_aspath = False
930 # Route policies
931 self.route_policy_accept = BGPPeerRoutePolicyAccept()
932 self.route_policy_redistribute = BGPPeerRoutePolicyRedistribute()
934 self.import_filter_policy = BGPPeerImportFilterPolicy()
935 self.import_filter_deny_policy = BGPPeerImportFilterDenyPolicy()
936 self.export_filter_policy = BGPPeerExportFilterPolicy()
938 self.blackhole_community = None
940 self.constraints = BGPPeerConstraints()
942 @property
943 def name(self) -> str:
944 """Return our name."""
945 if self._name is None:
946 raise BirdPlanError("Peer name must be set")
947 return self._name
949 @name.setter
950 def name(self, name: str) -> None:
951 """Set our name."""
952 self._name = name
954 @property
955 def description(self) -> str:
956 """Return our description."""
957 if not self._description:
958 raise BirdPlanError("Peer description must be set")
959 return self._description
961 @description.setter
962 def description(self, description: str) -> None:
963 """Set our description."""
964 self._description = description
966 @property
967 def peer_type(self) -> str:
968 """Return our peer_type."""
969 if not self._peer_type:
970 raise BirdPlanError("Peer peer_type must be set")
971 return self._peer_type
973 @peer_type.setter
974 def peer_type(self, peer_type: str) -> None:
975 """Set our peer_type."""
976 self._peer_type = peer_type
978 @property
979 def asn(self) -> int:
980 """Return our asn."""
981 if not self._asn:
982 raise BirdPlanError("Peer asn must be set")
983 return self._asn
985 @asn.setter
986 def asn(self, asn: int) -> None:
987 """Set our asn."""
988 self._asn = asn