Coverage for birdplan/bird_config/sections/__init__.py: 100%

57 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 configuration sections.""" 

20 

21from ..globals import BirdConfigGlobals 

22from .base import SectionBase 

23from .constants import SectionConstants 

24from .functions import SectionFunctions 

25from .log import SectionLogging 

26from .main import SectionMain 

27from .protocols import SectionProtocols 

28from .router_id import SectionRouterID 

29from .tables import SectionTables 

30 

31__all__ = ["Sections"] 

32 

33 

34class Sections(SectionBase): 

35 """BIRD configuration sections.""" 

36 

37 _logging: SectionLogging 

38 _main: SectionMain 

39 _router_id: SectionRouterID 

40 _constants: SectionConstants 

41 _functions: SectionFunctions 

42 _tables: SectionTables 

43 _protocols: SectionProtocols 

44 

45 def __init__(self, birdconfig_globals: BirdConfigGlobals): 

46 """Initialize object.""" 

47 super().__init__(birdconfig_globals) 

48 

49 self._logging = SectionLogging(birdconfig_globals) 

50 self._main = SectionMain(birdconfig_globals) 

51 self._router_id = SectionRouterID(birdconfig_globals) 

52 self._constants = SectionConstants(birdconfig_globals) 

53 self._functions = SectionFunctions(birdconfig_globals) 

54 self._tables = SectionTables(birdconfig_globals) 

55 self._protocols = SectionProtocols(birdconfig_globals, self.constants, self.functions, self.tables) 

56 

57 def configure(self) -> None: 

58 """Configure all sections.""" 

59 self.conf.add(self.logging) 

60 self.conf.add(self.main) 

61 self.conf.add(self.router_id) 

62 self.conf.add(self.constants, deferred=True) 

63 self.conf.add(self.functions, deferred=True) 

64 self.conf.add(self.tables, deferred=True) 

65 self.conf.add(self.protocols) 

66 

67 @property 

68 def constants(self) -> SectionConstants: 

69 """Return the constants section.""" 

70 return self._constants 

71 

72 @property 

73 def functions(self) -> SectionFunctions: 

74 """Return the functions section.""" 

75 return self._functions 

76 

77 @property 

78 def logging(self) -> SectionLogging: 

79 """Return the logging section.""" 

80 return self._logging 

81 

82 @property 

83 def main(self) -> SectionMain: 

84 """Return the main section.""" 

85 return self._main 

86 

87 @property 

88 def router_id(self) -> SectionRouterID: 

89 """Return the router_id section.""" 

90 return self._router_id 

91 

92 @property 

93 def tables(self) -> SectionTables: 

94 """Return the tables section.""" 

95 return self._tables 

96 

97 @property 

98 def protocols(self) -> SectionProtocols: 

99 """Return the protocols section.""" 

100 return self._protocols