Coverage for birdplan/bird_config/globals.py: 100%

31 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"""BirdConfig configuration globals.""" 

20 

21from typing import Any, Dict, Optional 

22 

23__all__ = ["BirdConfigGlobals"] 

24 

25 

26class BirdConfigGlobals: # pylint: disable=too-few-public-methods,too-many-instance-attributes 

27 """ 

28 BirdConfig configuration globals. 

29 

30 Attributes 

31 ---------- 

32 log_file : Optional[str] 

33 BIRD log file 

34 debug : bool 

35 Enable additional output from BIRD while running 

36 supress_info : bool 

37 Supress logging info unless debug is enabled 

38 state : Dict[str, Any] 

39 Current configuration state, used for persistent data storage. 

40 test_mode : bool 

41 Enable test mode, this modifies some internals to allow for better and more complete testing 

42 vrf: str 

43 VRF to use for BIRD. 

44 routing_table: int 

45 Kernel routing table to add the routes to. 

46 """ 

47 

48 log_file: Optional[str] 

49 debug: bool 

50 _suppress_info: bool 

51 ignore_irr_changes: bool 

52 ignore_peeringdb_changes: bool 

53 use_cached: bool 

54 state: Dict[str, Any] 

55 test_mode: bool 

56 vrf: str 

57 routing_table: int | None 

58 

59 def __init__(self, test_mode: bool = False) -> None: 

60 """Initialize object.""" 

61 

62 self.log_file = None 

63 self.ignore_irr_changes = False 

64 self.ignore_peeringdb_changes = False 

65 self.use_cached = False 

66 self.vrf = "default" 

67 self.routing_table = None 

68 

69 # Debugging 

70 self.debug = False 

71 self._suppress_info = False 

72 self.test_mode = test_mode 

73 

74 # State 

75 self.state = {} 

76 

77 @property 

78 def suppress_info(self) -> bool: 

79 """Return suppress info value.""" 

80 return self._suppress_info and not self.debug 

81 

82 @suppress_info.setter 

83 def suppress_info(self, value: bool) -> None: 

84 """Set suppress info value.""" 

85 self._suppress_info = value