Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ 06fd57e5

History | View | Annotate | Download (7.9 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
-- * Xen
204

    
205
xenBootloader :: String
206
xenBootloader = AutoConf.xenBootloader
207

    
208
xenCmdXl :: String
209
xenCmdXl = "xl"
210

    
211
xenCmdXm :: String
212
xenCmdXm = "xm"
213

    
214
xenInitrd :: String
215
xenInitrd = AutoConf.xenInitrd
216

    
217
xenKernel :: String
218
xenKernel = AutoConf.xenKernel
219

    
220
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
221
-- other constants
222
knownXenCommands :: FrozenSet String
223
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
224

    
225
-- * Common exit codes
226

    
227
exitSuccess :: Int
228
exitSuccess = 0
229

    
230
exitFailure :: Int
231
exitFailure = ConstantUtils.exitFailure
232

    
233
exitNotcluster :: Int
234
exitNotcluster = 5
235

    
236
exitNotmaster :: Int
237
exitNotmaster = 11
238

    
239
exitNodesetupError :: Int
240
exitNodesetupError = 12
241

    
242
-- | Need user confirmation
243
exitConfirmation :: Int
244
exitConfirmation = 13
245

    
246
-- | Exit code for query operations with unknown fields
247
exitUnknownField :: Int
248
exitUnknownField = 14
249

    
250
-- * Possible values for NodeGroup.alloc_policy
251

    
252
allocPolicyLastResort :: String
253
allocPolicyLastResort = "last_resort"
254

    
255
allocPolicyPreferred :: String
256
allocPolicyPreferred = "preferred"
257

    
258
allocPolicyUnallocable :: String
259
allocPolicyUnallocable = "unallocable"
260

    
261
validAllocPolicies :: [String]
262
validAllocPolicies =
263
  [allocPolicyLastResort,
264
   allocPolicyPreferred,
265
   allocPolicyUnallocable]
266

    
267
-- | Temporary external/shared storage parameters
268
blockdevDriverManual :: String
269
blockdevDriverManual = "manual"
270

    
271
-- | Path generating random UUID
272
randomUuidFile :: String
273
randomUuidFile = ConstantUtils.randomUuidFile
274

    
275
-- * Auto-repair tag prefixes
276

    
277
autoRepairTagPrefix :: String
278
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
279

    
280
autoRepairTagEnabled :: String
281
autoRepairTagEnabled = autoRepairTagPrefix
282

    
283
autoRepairTagPending :: String
284
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
285

    
286
autoRepairTagResult :: String
287
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
288

    
289
autoRepairTagSuspended :: String
290
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
291

    
292
-- * Auto-repair levels
293

    
294
autoRepairFailover :: String
295
autoRepairFailover = "failover"
296

    
297
autoRepairFixStorage :: String
298
autoRepairFixStorage = "fix-storage"
299

    
300
autoRepairMigrate :: String
301
autoRepairMigrate = "migrate"
302

    
303
autoRepairReinstall :: String
304
autoRepairReinstall = "reinstall"
305

    
306
autoRepairAllTypes :: FrozenSet String
307
autoRepairAllTypes =
308
  ConstantUtils.mkSet [autoRepairFailover,
309
                       autoRepairFixStorage,
310
                       autoRepairMigrate,
311
                       autoRepairReinstall]
312

    
313
-- * Auto-repair results
314

    
315
autoRepairEnoperm :: String
316
autoRepairEnoperm = "enoperm"
317

    
318
autoRepairFailure :: String
319
autoRepairFailure = "failure"
320

    
321
autoRepairSuccess :: String
322
autoRepairSuccess = "success"
323

    
324
autoRepairAllResults :: FrozenSet String
325
autoRepairAllResults =
326
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
327

    
328
-- | The version identifier for builtin data collectors
329
builtinDataCollectorVersion :: String
330
builtinDataCollectorVersion = "B"