Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ df726590

History | View | Annotate | Download (7.3 kB)

1
{-| HsConstants contains the Haskell constants
2

    
3
This is a transitional module complementary to 'Ganeti.Constants'.  It
4
is intended to contain the Haskell constants that are meant to be
5
generated in Python.
6

    
7
Do not write any definitions in this file other than constants.  Do
8
not even write helper functions.  The definitions in this module are
9
automatically stripped to build the Makefile.am target
10
'ListConstants.hs'.  If there are helper functions in this module,
11
they will also be dragged and it will cause compilation to fail.
12
Therefore, all helper functions should go to a separate module and
13
imported.
14

    
15
-}
16

    
17
{-
18

    
19
Copyright (C) 2013 Google Inc.
20

    
21
This program is free software; you can redistribute it and/or modify
22
it under the terms of the GNU General Public License as published by
23
the Free Software Foundation; either version 2 of the License, or
24
(at your option) any later version.
25

    
26
This program is distributed in the hope that it will be useful, but
27
WITHOUT ANY WARRANTY; without even the implied warranty of
28
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
29
General Public License for more details.
30

    
31
You should have received a copy of the GNU General Public License
32
along with this program; if not, write to the Free Software
33
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
34
02110-1301, USA.
35

    
36
-}
37
module Ganeti.HsConstants where
38

    
39
import Data.Map (Map)
40
import qualified Data.Map as Map (fromList)
41

    
42
import AutoConf
43
import Ganeti.ConstantUtils (FrozenSet, Protocol(..))
44
import qualified Ganeti.ConstantUtils as ConstantUtils
45
import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..),
46
                       ExtraLogReason(..))
47
import Ganeti.Logging (SyslogUsage(..))
48
import qualified Ganeti.Logging as Logging (syslogUsageToRaw)
49
import qualified Ganeti.Runtime as Runtime
50

    
51
-- * Admin states
52

    
53
adminstDown :: String
54
adminstDown = "down"
55

    
56
adminstOffline :: String
57
adminstOffline = "offline"
58

    
59
adminstUp :: String
60
adminstUp = "up"
61

    
62
adminstAll :: FrozenSet String
63
adminstAll = ConstantUtils.mkSet [adminstDown, adminstOffline, adminstUp]
64

    
65
-- * User separation
66

    
67
daemonsGroup :: String
68
daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
69

    
70
adminGroup :: String
71
adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
72

    
73
masterdUser :: String
74
masterdUser = Runtime.daemonUser GanetiMasterd
75

    
76
masterdGroup :: String
77
masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
78

    
79
rapiUser :: String
80
rapiUser = Runtime.daemonUser GanetiRapi
81

    
82
rapiGroup :: String
83
rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
84

    
85
confdUser :: String
86
confdUser = Runtime.daemonUser GanetiConfd
87

    
88
confdGroup :: String
89
confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
90

    
91
luxidUser :: String
92
luxidUser = Runtime.daemonUser GanetiLuxid
93

    
94
luxidGroup :: String
95
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
96

    
97
nodedUser :: String
98
nodedUser = Runtime.daemonUser GanetiNoded
99

    
100
nodedGroup :: String
101
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
102

    
103
mondUser :: String
104
mondUser = Runtime.daemonUser GanetiMond
105

    
106
mondGroup :: String
107
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
108

    
109
sshLoginUser :: String
110
sshLoginUser = AutoConf.sshLoginUser
111

    
112
sshConsoleUser :: String
113
sshConsoleUser = AutoConf.sshConsoleUser
114

    
115
-- * SSH constants
116

    
117
ssh :: String
118
ssh = "ssh"
119

    
120
scp :: String
121
scp = "scp"
122

    
123
-- * Daemons
124

    
125
confd :: String
126
confd = Runtime.daemonName GanetiConfd
127

    
128
masterd :: String
129
masterd = Runtime.daemonName GanetiMasterd
130

    
131
mond :: String
132
mond = Runtime.daemonName GanetiMond
133

    
134
noded :: String
135
noded = Runtime.daemonName GanetiNoded
136

    
137
luxid :: String
138
luxid = Runtime.daemonName GanetiLuxid
139

    
140
rapi :: String
141
rapi = Runtime.daemonName GanetiRapi
142

    
143
daemons :: FrozenSet String
144
daemons =
145
  ConstantUtils.mkSet [confd,
146
                       luxid,
147
                       masterd,
148
                       mond,
149
                       noded,
150
                       rapi]
151

    
152
defaultConfdPort :: Int
153
defaultConfdPort = 1814
154

    
155
defaultMondPort :: Int
156
defaultMondPort = 1815
157

    
158
defaultNodedPort :: Int
159
defaultNodedPort = 1811
160

    
161
defaultRapiPort :: Int
162
defaultRapiPort = 5080
163

    
164
daemonsPorts :: Map String (Protocol, Int)
165
daemonsPorts =
166
  Map.fromList [(confd, (Udp, defaultConfdPort)),
167
                (mond, (Tcp, defaultMondPort)),
168
                (noded, (Tcp, defaultNodedPort)),
169
                (rapi, (Tcp, defaultRapiPort)),
170
                (ssh, (Tcp, 22))]
171

    
172
daemonsLogbase :: Map String String
173
daemonsLogbase =
174
  Map.fromList
175
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
176

    
177
extraLogreasonAccess :: String
178
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
179

    
180
extraLogreasonError :: String
181
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
182

    
183
devConsole :: String
184
devConsole = ConstantUtils.devConsole
185

    
186
-- * Syslog
187

    
188
syslogUsage :: String
189
syslogUsage = AutoConf.syslogUsage
190

    
191
syslogNo :: String
192
syslogNo = Logging.syslogUsageToRaw SyslogNo
193

    
194
syslogYes :: String
195
syslogYes = Logging.syslogUsageToRaw SyslogYes
196

    
197
syslogOnly :: String
198
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
199

    
200
syslogSocket :: String
201
syslogSocket = "/dev/log"
202

    
203
-- * Common exit codes
204

    
205
exitSuccess :: Int
206
exitSuccess = 0
207

    
208
exitFailure :: Int
209
exitFailure = ConstantUtils.exitFailure
210

    
211
exitNotcluster :: Int
212
exitNotcluster = 5
213

    
214
exitNotmaster :: Int
215
exitNotmaster = 11
216

    
217
exitNodesetupError :: Int
218
exitNodesetupError = 12
219

    
220
-- | Need user confirmation
221
exitConfirmation :: Int
222
exitConfirmation = 13
223

    
224
-- | Exit code for query operations with unknown fields
225
exitUnknownField :: Int
226
exitUnknownField = 14
227

    
228
-- * Possible values for NodeGroup.alloc_policy
229

    
230
allocPolicyLastResort :: String
231
allocPolicyLastResort = "last_resort"
232

    
233
allocPolicyPreferred :: String
234
allocPolicyPreferred = "preferred"
235

    
236
allocPolicyUnallocable :: String
237
allocPolicyUnallocable = "unallocable"
238

    
239
validAllocPolicies :: [String]
240
validAllocPolicies =
241
  [allocPolicyLastResort,
242
   allocPolicyPreferred,
243
   allocPolicyUnallocable]
244

    
245
-- | Temporary external/shared storage parameters
246
blockdevDriverManual :: String
247
blockdevDriverManual = "manual"
248

    
249
-- * Auto-repair tag prefixes
250

    
251
autoRepairTagPrefix :: String
252
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
253

    
254
autoRepairTagEnabled :: String
255
autoRepairTagEnabled = autoRepairTagPrefix
256

    
257
autoRepairTagPending :: String
258
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
259

    
260
autoRepairTagResult :: String
261
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
262

    
263
autoRepairTagSuspended :: String
264
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
265

    
266
-- * Auto-repair levels
267

    
268
autoRepairFailover :: String
269
autoRepairFailover = "failover"
270

    
271
autoRepairFixStorage :: String
272
autoRepairFixStorage = "fix-storage"
273

    
274
autoRepairMigrate :: String
275
autoRepairMigrate = "migrate"
276

    
277
autoRepairReinstall :: String
278
autoRepairReinstall = "reinstall"
279

    
280
autoRepairAllTypes :: FrozenSet String
281
autoRepairAllTypes =
282
  ConstantUtils.mkSet [autoRepairFailover,
283
                       autoRepairFixStorage,
284
                       autoRepairMigrate,
285
                       autoRepairReinstall]
286

    
287
-- * Auto-repair results
288

    
289
autoRepairEnoperm :: String
290
autoRepairEnoperm = "enoperm"
291

    
292
autoRepairFailure :: String
293
autoRepairFailure = "failure"
294

    
295
autoRepairSuccess :: String
296
autoRepairSuccess = "success"
297

    
298
autoRepairAllResults :: FrozenSet String
299
autoRepairAllResults =
300
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
301

    
302
-- | The version identifier for builtin data collectors
303
builtinDataCollectorVersion :: String
304
builtinDataCollectorVersion = "B"