|
1
|
|
|
""" |
|
2
|
|
|
PyStratum |
|
3
|
|
|
|
|
4
|
|
|
Copyright 2015-2016 Set Based IT Consultancy |
|
5
|
|
|
|
|
6
|
|
|
Licence MIT |
|
7
|
|
|
""" |
|
8
|
|
|
from configparser import ConfigParser |
|
9
|
|
|
|
|
10
|
|
|
from enarksh.C import C |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
class Config: |
|
14
|
|
|
""" |
|
15
|
|
|
Singleton for reading configuration parameters |
|
16
|
|
|
""" |
|
17
|
|
|
instance = None |
|
18
|
|
|
""" |
|
19
|
|
|
The singleton of this class. |
|
20
|
|
|
|
|
21
|
|
|
:type: None|enarksh.Config.Config |
|
22
|
|
|
""" |
|
23
|
|
|
|
|
24
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
25
|
|
|
@staticmethod |
|
26
|
|
|
def get(): |
|
27
|
|
|
""" |
|
28
|
|
|
Returns the singleton of this class. |
|
29
|
|
|
|
|
30
|
|
|
:rtype: enarksh.Config.Config |
|
31
|
|
|
""" |
|
32
|
|
|
if not Config.instance: |
|
33
|
|
|
Config.instance = Config() |
|
34
|
|
|
|
|
35
|
|
|
return Config.instance |
|
36
|
|
|
|
|
37
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
38
|
|
|
def __init__(self): |
|
39
|
|
|
""" |
|
40
|
|
|
Object constructor. |
|
41
|
|
|
""" |
|
42
|
|
|
self.__config = ConfigParser() |
|
43
|
|
|
self.__config.read(C.ENARKSH_CFG) |
|
44
|
|
|
|
|
45
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
46
|
|
|
def get_controller_email(self): |
|
47
|
|
|
""" |
|
48
|
|
|
Returns the sender's email address of Enarksh. |
|
49
|
|
|
|
|
50
|
|
|
:rtype: str |
|
51
|
|
|
""" |
|
52
|
|
|
return self.__config.get('controller', 'email') |
|
53
|
|
|
|
|
54
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
55
|
|
|
def get_controller_lockstep_end_point(self): |
|
56
|
|
|
""" |
|
57
|
|
|
Returns the lockstep end point of the controller. |
|
58
|
|
|
|
|
59
|
|
|
:rtype: str |
|
60
|
|
|
""" |
|
61
|
|
|
return self.__config.get('controller', 'lockstep_end_point') |
|
62
|
|
|
|
|
63
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
64
|
|
|
def get_controller_pull_end_point(self): |
|
65
|
|
|
""" |
|
66
|
|
|
Returns the pull end point of the controller. |
|
67
|
|
|
|
|
68
|
|
|
:rtype: str |
|
69
|
|
|
""" |
|
70
|
|
|
return self.__config.get('controller', 'pull_end_point') |
|
71
|
|
|
|
|
72
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
73
|
|
|
def get_enarksh_lock_dir(self): |
|
74
|
|
|
""" |
|
75
|
|
|
Returns the directory name for storing lock files. |
|
76
|
|
|
|
|
77
|
|
|
:rtype: str |
|
78
|
|
|
""" |
|
79
|
|
|
return self.__config.get('enarksh', 'lock_dir') |
|
80
|
|
|
|
|
81
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
82
|
|
|
def get_enarksh_log_dir(self): |
|
83
|
|
|
""" |
|
84
|
|
|
Returns the directory name for storing log files. |
|
85
|
|
|
|
|
86
|
|
|
:rtype: str |
|
87
|
|
|
""" |
|
88
|
|
|
return self.__config.get('enarksh', 'log_dir') |
|
89
|
|
|
|
|
90
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
91
|
|
|
def get_enarksh_log_back(self): |
|
92
|
|
|
""" |
|
93
|
|
|
Returns the number of rotated log files. |
|
94
|
|
|
|
|
95
|
|
|
:rtype: int |
|
96
|
|
|
""" |
|
97
|
|
|
return self.__config.getint('enarksh', 'log_backup') |
|
98
|
|
|
|
|
99
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
100
|
|
|
def get_enarksh_max_log_size(self): |
|
101
|
|
|
""" |
|
102
|
|
|
Returns the maximum size of a log file. |
|
103
|
|
|
|
|
104
|
|
|
:rtype: int |
|
105
|
|
|
""" |
|
106
|
|
|
return self.__config.getint('enarksh', 'max_log_size') |
|
107
|
|
|
|
|
108
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
109
|
|
|
def get_logger_pull_end_point(self): |
|
110
|
|
|
""" |
|
111
|
|
|
Returns the pull end point of the logger. |
|
112
|
|
|
|
|
113
|
|
|
:rtype: str |
|
114
|
|
|
""" |
|
115
|
|
|
return self.__config.get('logger', 'pull_end_point') |
|
116
|
|
|
|
|
117
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
118
|
|
|
def get_spawner_get_users(self): |
|
119
|
|
|
""" |
|
120
|
|
|
Returns the user accounts under which the spawner is allowed to start processes. |
|
121
|
|
|
|
|
122
|
|
|
:rtype: list[str] |
|
123
|
|
|
""" |
|
124
|
|
|
users = self.__config.get('spawner', 'users') |
|
125
|
|
|
if users: |
|
126
|
|
|
return users.split(' ') |
|
127
|
|
|
|
|
128
|
|
|
return [] |
|
129
|
|
|
|
|
130
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
131
|
|
|
def get_spawner_pull_end_point(self): |
|
132
|
|
|
""" |
|
133
|
|
|
Returns the pull end point of the spawner. |
|
134
|
|
|
|
|
135
|
|
|
:rtype: str |
|
136
|
|
|
""" |
|
137
|
|
|
return self.__config.get('spawner', 'pull_end_point') |
|
138
|
|
|
|
|
139
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
|
140
|
|
|
|