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

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/>. 

18 

19"""BIRD BGP protocol attributes.""" 

20 

21import enum 

22from typing import Dict, List, Optional, Union 

23 

24from ......exceptions import BirdPlanError 

25 

26__all__ = [ 

27 "BGPPeerLargeCommunitiesOutgoing", 

28 "BGPPeerLargeCommunities", 

29 "BGPPeerPrependItem", 

30 "BGPPeerPrepend", 

31 "BGPPeerRoutePolicyAccept", 

32 "BGPPeerImportFilterPolicy", 

33 "BGPPeerLocation", 

34 "BGPPeerRoutePolicyRedistribute", 

35 "BGPPeerConstraints", 

36 "BGPPeerAttributes", 

37] 

38 

39# This type is a string as we can have it set to "peeringdb" 

40BGPPeerPrefixLimit = Optional[str] 

41 

42BGPPeerFilterItem = Union[str, List[str]] 

43BGPPeerFilter = Dict[str, BGPPeerFilterItem] 

44 

45 

46# Define BGP prefix limit action enum 

47class BGPPeerImportPrefixLimitAction(enum.Enum): 

48 """BGP peer import prefix limit action.""" 

49 

50 RESTART = "restart" 

51 DISABLE = "disable" 

52 

53 

54class BGPPeerCommunitiesOutgoing: # pylint: disable=too-few-public-methods,too-many-instance-attributes 

55 """ 

56 BGP peer outgoing communities. 

57 

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. 

94 

95 """ 

96 

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] 

115 

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 = [] 

135 

136 

137class BGPPeerCommunities: # pylint: disable=too-few-public-methods 

138 """ 

139 BGP peer communities. 

140 

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. 

147 

148 """ 

149 

150 incoming: List[str] 

151 

152 outgoing: BGPPeerCommunitiesOutgoing 

153 

154 def __init__(self) -> None: 

155 """Initialize object.""" 

156 self.incoming = [] 

157 self.outgoing = BGPPeerCommunitiesOutgoing() 

158 

159 

160class BGPPeerLargeCommunitiesOutgoing: # pylint: disable=too-few-public-methods,too-many-instance-attributes 

161 """ 

162 BGP peer outgoing large communities. 

163 

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. 

200 

201 """ 

202 

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] 

221 

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 = [] 

241 

242 

243class BGPPeerLargeCommunities: # pylint: disable=too-few-public-methods 

244 """ 

245 BGP peer large communities. 

246 

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. 

253 

254 """ 

255 

256 incoming: List[str] 

257 

258 outgoing: BGPPeerLargeCommunitiesOutgoing 

259 

260 def __init__(self) -> None: 

261 """Initialize object.""" 

262 self.incoming = [] 

263 self.outgoing = BGPPeerLargeCommunitiesOutgoing() 

264 

265 

266class BGPPeerPrependItem: # pylint: disable=too-few-public-methods 

267 """ 

268 BGP peer prepending item. 

269 

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. 

276 

277 """ 

278 

279 own_asn: int 

280 # first_asn: int 

281 

282 def __init__(self) -> None: 

283 """Initialize object.""" 

284 self.own_asn = 0 

285 

286 # self.first_asn = 0 

287 

288 

289class BGPPeerPrepend: # pylint: disable=too-few-public-methods,too-many-instance-attributes 

290 """ 

291 BGP peer prepending. 

292 

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. 

329 

330 """ 

331 

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 

349 

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() 

369 

370 

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. 

374 

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. 

385 

386 """ 

387 

388 bgp_customer_blackhole: bool 

389 bgp_own_blackhole: bool 

390 bgp_own_default: bool 

391 bgp_transit_default: bool 

392 

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 

399 

400 

401class BGPPeerImportFilterDenyPolicy: # pylint: disable=too-few-public-methods 

402 """ 

403 BGP filter deny policy for incoming routes from the BGP peer. 

404 

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. 

413 

414 

415 """ 

416 

417 aspath_asns: BGPPeerFilterItem 

418 origin_asns: BGPPeerFilterItem 

419 prefixes: BGPPeerFilterItem 

420 

421 def __init__(self) -> None: 

422 """Initialize object.""" 

423 self.aspath_asns = [] 

424 self.origin_asns = [] 

425 self.prefixes = [] 

426 

427 

428class BGPPeerImportFilterPolicy: # pylint: disable=too-few-public-methods 

429 """ 

430 BGP filter policy for incoming routes from the BGP peer. 

431 

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. 

448 

449 """ 

450 

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] 

458 

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 = [] 

469 

470 

471class BGPPeerExportFilterPolicy: # pylint: disable=too-few-public-methods 

472 """ 

473 BGP filter policy for outgoing routes to the BGP peer. 

474 

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 """ 

482 

483 origin_asns: BGPPeerFilterItem 

484 prefixes: BGPPeerFilterItem 

485 

486 def __init__(self) -> None: 

487 """Initialize object.""" 

488 self.origin_asns = [] 

489 self.prefixes = [] 

490 

491 

492class BGPPeerLocation: # pylint: disable=too-few-public-methods 

493 """ 

494 BGP peer location. 

495 

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. 

502 

503 """ 

504 

505 unm49: Optional[int] 

506 iso3166: Optional[int] 

507 

508 def __init__(self) -> None: 

509 """Initialize object.""" 

510 self.unm49 = None 

511 self.iso3166 = None 

512 

513 

514class BGPPeerRoutePolicyRedistribute: # pylint: disable=too-few-public-methods,too-many-instance-attributes 

515 """ 

516 BGP peer route policy for redistributing of routes. 

517 

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`. 

554 

555 """ 

556 

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 

574 

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 

594 

595 

596class BGPPeerConstraints: # pylint: disable=too-few-public-methods,too-many-instance-attributes 

597 """ 

598 BGP peer prefix limits. 

599 

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. 

644 

645 """ 

646 

647 import_maxlen4: Optional[int] 

648 import_minlen4: Optional[int] 

649 

650 export_maxlen4: Optional[int] 

651 export_minlen4: Optional[int] 

652 

653 import_maxlen6: Optional[int] 

654 import_minlen6: Optional[int] 

655 

656 export_maxlen6: Optional[int] 

657 export_minlen6: Optional[int] 

658 

659 blackhole_import_maxlen4: Optional[int] 

660 blackhole_import_minlen4: Optional[int] 

661 

662 blackhole_export_maxlen4: Optional[int] 

663 blackhole_export_minlen4: Optional[int] 

664 

665 blackhole_import_maxlen6: Optional[int] 

666 blackhole_import_minlen6: Optional[int] 

667 

668 blackhole_export_maxlen6: Optional[int] 

669 blackhole_export_minlen6: Optional[int] 

670 

671 aspath_import_maxlen: Optional[int] 

672 aspath_import_minlen: Optional[int] 

673 

674 community_import_maxlen: Optional[int] 

675 extended_community_import_maxlen: Optional[int] 

676 large_community_import_maxlen: Optional[int] 

677 

678 def __init__(self) -> None: 

679 """Initialize object.""" 

680 

681 self.import_maxlen4 = None 

682 self.import_minlen4 = None 

683 

684 self.export_maxlen4 = None 

685 self.export_minlen4 = None 

686 

687 self.import_maxlen6 = None 

688 self.import_minlen6 = None 

689 

690 self.export_maxlen6 = None 

691 self.export_minlen6 = None 

692 

693 self.blackhole_import_maxlen4 = None 

694 self.blackhole_import_minlen4 = None 

695 

696 self.blackhole_export_maxlen4 = None 

697 self.blackhole_export_minlen4 = None 

698 

699 self.blackhole_import_maxlen6 = None 

700 self.blackhole_import_minlen6 = None 

701 

702 self.blackhole_export_maxlen6 = None 

703 self.blackhole_export_minlen6 = None 

704 

705 self.aspath_import_maxlen = None 

706 self.aspath_import_minlen = None 

707 

708 self.community_import_maxlen = None 

709 self.extended_community_import_maxlen = None 

710 self.large_community_import_maxlen = None 

711 

712 

713class BGPPeerAttributes: # pylint: disable=too-few-public-methods,too-many-instance-attributes 

714 """ 

715 BGP peer attributes. 

716 

717 Attributes 

718 ---------- 

719 name : str 

720 Peer name. 

721 

722 description : str 

723 Description of the peer. 

724 

725 location : BGPPeerLocation 

726 Peer location. 

727 

728 peer_type : str 

729 Peer type. 

730 

731 asn : int 

732 Peers ASN. 

733 

734 neighbor4: Optional[str] 

735 Neighbor IPv4 address. 

736 

737 neighbor6: Optional[str] 

738 Neighbor IPv6 address. 

739 

740 source_address4: Optional[str] 

741 Source IPv4 address. 

742 

743 source_address6: Optional[str] 

744 Source IPv6 address. 

745 

746 connect_delay_time: Optional[str] 

747 BGP connect delay time. 

748 

749 connect_retry_time: Optional[str] 

750 BGP connection retry time. 

751 

752 error_wait_time: Optional[str] 

753 BGP error wait time. 

754 

755 multihop: Optional[str] 

756 BGP multihop value. 

757 

758 password: Optional[str] 

759 BGP password. 

760 

761 ttl_security: bool 

762 Indicate if BGP TTL security should be enabled. 

763 

764 cost : int 

765 Cost of this peer, this is the number minused from the local_pref. 

766 

767 graceful_shutdown : bool 

768 Set peer in GRACEFUL_SHUTDOWN mode. 

769 

770 communities: BGPPeerCommunities 

771 Incoming and outgoing communities. 

772 

773 large_communities: BGPPeerLargeCommunities 

774 Incoming and outgoing large communities. 

775 

776 prepend: 

777 AS-PATH prepending. 

778 

779 passive : bool 

780 Indicate if this is a passive peer or not. 

781 

782 quarantine : bool 

783 Set if the peer is quarantined. 

784 

785 prefix_limit_action : BGPPeerImportPrefixLimitAction 

786 Prefix limit action used when the import prefix count is exceeded. 

787 

788 prefix_limit4 : BGPPeerPrefixLimit 

789 Prefix limit for IPv4. 

790 

791 prefix_limit6 : BGPPeerPrefixLimit 

792 Prefix limit for IPv6. 

793 

794 prefix_limit4_peeringdb : BGPPeerPrefixLimit 

795 Prefix limit for IPv4. 

796 

797 prefix_limit6_peeringdb : BGPPeerPrefixLimit 

798 Prefix limit for IPv6. 

799 

800 replace_aspath : Optional[int] 

801 ASN to substitute in the AS-PATH. 

802 

803 route_policy_accept : BGPPeerRoutePolicyAccept 

804 Route policy for acceptance of routes from BGP peers into our main BGP table. 

805 

806 route_policy_redistribute : BGPPeerRoutePolicyRedistribute 

807 Route policy for redistribution of routes to the BGP peer. 

808 

809 import_filter_policy: BGPPeerImportFilterPolicy 

810 BGP peer import filter policy. 

811 

812 import_filter_deny_policy: BGPPeerImportFilterDenyPolicy 

813 BGP peer import filter deny policy. 

814 

815 export_filter_policy: BGPPeerExportFilterPolicy 

816 BGP peer export filter policy. 

817 

818 blackhole_community: Optional[Union[List[str], bool]] 

819 Blackhole community to use for blackhole routes. 

820 

821 constraints: BGPPeerConstraints 

822 BGP peer constraint overrides. 

823 

824 """ 

825 

826 _name: Optional[str] 

827 _description: Optional[str] 

828 location: BGPPeerLocation 

829 

830 _peer_type: Optional[str] 

831 _asn: Optional[int] 

832 

833 neighbor4: Optional[str] 

834 neighbor6: Optional[str] 

835 source_address4: Optional[str] 

836 source_address6: Optional[str] 

837 

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 

844 

845 cost: int 

846 

847 add_paths: Optional[str] 

848 

849 graceful_shutdown: bool 

850 

851 communities: BGPPeerCommunities 

852 large_communities: BGPPeerLargeCommunities 

853 

854 prepend: BGPPeerPrepend 

855 

856 # Default to disabling passive mode 

857 passive: bool 

858 

859 quarantine: bool 

860 

861 prefix_limit_action: BGPPeerImportPrefixLimitAction 

862 

863 prefix_limit4: BGPPeerPrefixLimit 

864 prefix_limit6: BGPPeerPrefixLimit 

865 

866 prefix_limit4_peeringdb: BGPPeerPrefixLimit 

867 prefix_limit6_peeringdb: BGPPeerPrefixLimit 

868 

869 replace_aspath: bool 

870 

871 route_policy_accept: BGPPeerRoutePolicyAccept 

872 route_policy_redistribute: BGPPeerRoutePolicyRedistribute 

873 

874 import_filter_policy: BGPPeerImportFilterPolicy 

875 import_filter_deny_policy: BGPPeerImportFilterDenyPolicy 

876 export_filter_policy: BGPPeerExportFilterPolicy 

877 

878 blackhole_community: Optional[Union[List[str], bool]] 

879 

880 constraints: BGPPeerConstraints 

881 

882 def __init__(self) -> None: 

883 """Initialize object.""" 

884 

885 self._name = None 

886 self._description = None 

887 self.location = BGPPeerLocation() 

888 

889 self._peer_type = None 

890 self._asn = None 

891 

892 self.neighbor4 = None 

893 self.neighbor6 = None 

894 self.source_address4 = None 

895 self.source_address6 = None 

896 

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 

903 

904 self.cost = 0 

905 

906 self.add_paths = None 

907 

908 self.graceful_shutdown = False 

909 

910 self.communities = BGPPeerCommunities() 

911 self.large_communities = BGPPeerLargeCommunities() 

912 

913 self.prepend = BGPPeerPrepend() 

914 

915 # Default to disabling passive mode 

916 self.passive = False 

917 

918 self.quarantine = False 

919 

920 self.prefix_limit_action = BGPPeerImportPrefixLimitAction.RESTART 

921 

922 self.prefix_limit4 = None 

923 self.prefix_limit6 = None 

924 

925 self.prefix_limit4_peeringdb = None 

926 self.prefix_limit6_peeringdb = None 

927 

928 self.replace_aspath = False 

929 

930 # Route policies 

931 self.route_policy_accept = BGPPeerRoutePolicyAccept() 

932 self.route_policy_redistribute = BGPPeerRoutePolicyRedistribute() 

933 

934 self.import_filter_policy = BGPPeerImportFilterPolicy() 

935 self.import_filter_deny_policy = BGPPeerImportFilterDenyPolicy() 

936 self.export_filter_policy = BGPPeerExportFilterPolicy() 

937 

938 self.blackhole_community = None 

939 

940 self.constraints = BGPPeerConstraints() 

941 

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 

948 

949 @name.setter 

950 def name(self, name: str) -> None: 

951 """Set our name.""" 

952 self._name = name 

953 

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 

960 

961 @description.setter 

962 def description(self, description: str) -> None: 

963 """Set our description.""" 

964 self._description = description 

965 

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 

972 

973 @peer_type.setter 

974 def peer_type(self, peer_type: str) -> None: 

975 """Set our peer_type.""" 

976 self._peer_type = peer_type 

977 

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 

984 

985 @asn.setter 

986 def asn(self, asn: int) -> None: 

987 """Set our asn.""" 

988 self._asn = asn