Coverage for birdplan/bird_config/sections/protocols/ospf/ospf_attributes.py: 100%

25 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 OSPF protocol attributes.""" 

20 

21from typing import List, Union 

22 

23__all__ = ["OSPFRoutePolicyAccept", "OSPFRoutePolicyRedistribute", "OSPFAttributes"] 

24 

25 

26class OSPFRoutePolicyAccept: # pylint: disable=too-few-public-methods 

27 """ 

28 OSPF route policy for acceptance of routes from OSPF peers into the main OSPF table. 

29 

30 Attributes 

31 ---------- 

32 default : bool 

33 Accept default route. Defaults to `False`. 

34 

35 """ 

36 

37 default: bool 

38 

39 def __init__(self) -> None: 

40 """Initialize object.""" 

41 self.default = False 

42 

43 

44class OSPFRoutePolicyRedistribute: # pylint: disable=too-few-public-methods 

45 r""" 

46 OSPF route policy for redistributing of routes. 

47 

48 Attributes 

49 ---------- 

50 connected : Union[bool, List[str]] 

51 Redistribute connected routes to the main OSPF table. This attribute is indexed by interface name with a boolean option. 

52 The interface name can be an exact interface match, or a wildcard with a \*. 

53 kernel : bool 

54 Redistribute kernel routes to the main OSPF table. Defaults to `False`. 

55 kernel_default : bool 

56 Redistribute kernel default routes to the main OSPF table. Defaults to `False`. 

57 static : bool 

58 Redistribute static routes to the main OSPF table. Defaults to `False`. 

59 static_default : bool 

60 Redistribute static default routes to the main OSPF table. Defaults to `False`. 

61 

62 """ 

63 

64 connected: Union[bool, List[str]] 

65 kernel: bool 

66 kernel_default: bool 

67 static: bool 

68 static_default: bool 

69 

70 def __init__(self) -> None: 

71 """Initialize object.""" 

72 self.connected = False 

73 self.kernel = False 

74 self.kernel_default = False 

75 self.static = False 

76 self.static_default = False 

77 

78 

79class OSPFAttributes: # pylint: disable=too-few-public-methods 

80 """ 

81 OSPF attributes. 

82 

83 Attributes 

84 ---------- 

85 route_policy_accept : OSPFRoutePolicyAccept 

86 Route policy for acceptance of routes from OSPF peers into our main OSPF table. 

87 route_policy_redistribute : OSPFRoutePolicyRedistribute 

88 Route policy for importing of routes from internal tables into our main OSPF table. 

89 

90 """ 

91 

92 route_policy_accept: OSPFRoutePolicyAccept 

93 route_policy_redistribute: OSPFRoutePolicyRedistribute 

94 

95 def __init__(self) -> None: 

96 """Initialize object.""" 

97 

98 self.route_policy_accept = OSPFRoutePolicyAccept() 

99 self.route_policy_redistribute = OSPFRoutePolicyRedistribute()