Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ 58c09b0e

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 = Types.allocPolicyToRaw AllocLastResort
254

    
255
allocPolicyPreferred :: String
256
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
257

    
258
allocPolicyUnallocable :: String
259
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
260

    
261
validAllocPolicies :: [String]
262
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
263

    
264
-- | Temporary external/shared storage parameters
265
blockdevDriverManual :: String
266
blockdevDriverManual = "manual"
267

    
268
-- | Path generating random UUID
269
randomUuidFile :: String
270
randomUuidFile = ConstantUtils.randomUuidFile
271

    
272
-- * Auto-repair tag prefixes
273

    
274
autoRepairTagPrefix :: String
275
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
276

    
277
autoRepairTagEnabled :: String
278
autoRepairTagEnabled = autoRepairTagPrefix
279

    
280
autoRepairTagPending :: String
281
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
282

    
283
autoRepairTagResult :: String
284
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
285

    
286
autoRepairTagSuspended :: String
287
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
288

    
289
-- * Auto-repair levels
290

    
291
autoRepairFailover :: String
292
autoRepairFailover = "failover"
293

    
294
autoRepairFixStorage :: String
295
autoRepairFixStorage = "fix-storage"
296

    
297
autoRepairMigrate :: String
298
autoRepairMigrate = "migrate"
299

    
300
autoRepairReinstall :: String
301
autoRepairReinstall = "reinstall"
302

    
303
autoRepairAllTypes :: FrozenSet String
304
autoRepairAllTypes =
305
  ConstantUtils.mkSet [autoRepairFailover,
306
                       autoRepairFixStorage,
307
                       autoRepairMigrate,
308
                       autoRepairReinstall]
309

    
310
-- * Auto-repair results
311

    
312
autoRepairEnoperm :: String
313
autoRepairEnoperm = "enoperm"
314

    
315
autoRepairFailure :: String
316
autoRepairFailure = "failure"
317

    
318
autoRepairSuccess :: String
319
autoRepairSuccess = "success"
320

    
321
autoRepairAllResults :: FrozenSet String
322
autoRepairAllResults =
323
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
324

    
325
-- | The version identifier for builtin data collectors
326
builtinDataCollectorVersion :: String
327
builtinDataCollectorVersion = "B"