1 {-| HsConstants contains the Haskell constants
3 This is a transitional module complementary to 'Ganeti.Constants'. It
4 is intended to contain the Haskell constants that are meant to be
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
19 Copyright (C) 2013 Google Inc.
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.
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.
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
37 module Ganeti.HsConstants where
40 import qualified Data.Map as Map (fromList)
43 import Ganeti.ConstantUtils (FrozenSet, Protocol(..))
44 import qualified Ganeti.ConstantUtils as ConstantUtils (mkSet, exitFailure)
45 import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..),
47 import qualified Ganeti.Runtime as Runtime
54 adminstOffline :: String
55 adminstOffline = "offline"
60 adminstAll :: FrozenSet String
61 adminstAll = ConstantUtils.mkSet [adminstDown, adminstOffline, adminstUp]
65 daemonsGroup :: String
66 daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
69 adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
72 masterdUser = Runtime.daemonUser GanetiMasterd
74 masterdGroup :: String
75 masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
78 rapiUser = Runtime.daemonUser GanetiRapi
81 rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
84 confdUser = Runtime.daemonUser GanetiConfd
87 confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
90 luxidUser = Runtime.daemonUser GanetiLuxid
93 luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
96 nodedUser = Runtime.daemonUser GanetiNoded
99 nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
102 mondUser = Runtime.daemonUser GanetiMond
105 mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
107 sshLoginUser :: String
108 sshLoginUser = AutoConf.sshLoginUser
110 sshConsoleUser :: String
111 sshConsoleUser = AutoConf.sshConsoleUser
124 confd = Runtime.daemonName GanetiConfd
127 masterd = Runtime.daemonName GanetiMasterd
130 mond = Runtime.daemonName GanetiMond
133 noded = Runtime.daemonName GanetiNoded
136 luxid = Runtime.daemonName GanetiLuxid
139 rapi = Runtime.daemonName GanetiRapi
141 daemons :: FrozenSet String
143 ConstantUtils.mkSet [confd,
150 defaultConfdPort :: Int
151 defaultConfdPort = 1814
153 defaultMondPort :: Int
154 defaultMondPort = 1815
156 defaultNodedPort :: Int
157 defaultNodedPort = 1811
159 defaultRapiPort :: Int
160 defaultRapiPort = 5080
162 daemonsPorts :: Map String (Protocol, Int)
164 Map.fromList [(confd, (Udp, defaultConfdPort)),
165 (mond, (Tcp, defaultMondPort)),
166 (noded, (Tcp, defaultNodedPort)),
167 (rapi, (Tcp, defaultRapiPort)),
170 daemonsLogbase :: Map String String
173 [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
175 extraLogreasonAccess :: String
176 extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
178 extraLogreasonError :: String
179 extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
181 -- * Common exit codes
187 exitFailure = ConstantUtils.exitFailure
189 exitNotcluster :: Int
195 exitNodesetupError :: Int
196 exitNodesetupError = 12
198 -- | Need user confirmation
199 exitConfirmation :: Int
200 exitConfirmation = 13
202 -- | Exit code for query operations with unknown fields
203 exitUnknownField :: Int
204 exitUnknownField = 14
206 -- * Possible values for NodeGroup.alloc_policy
208 allocPolicyLastResort :: String
209 allocPolicyLastResort = "last_resort"
211 allocPolicyPreferred :: String
212 allocPolicyPreferred = "preferred"
214 allocPolicyUnallocable :: String
215 allocPolicyUnallocable = "unallocable"
217 validAllocPolicies :: [String]
219 [allocPolicyLastResort,
220 allocPolicyPreferred,
221 allocPolicyUnallocable]
223 -- | Temporary external/shared storage parameters
224 blockdevDriverManual :: String
225 blockdevDriverManual = "manual"
227 -- * Auto-repair tag prefixes
229 autoRepairTagPrefix :: String
230 autoRepairTagPrefix = "ganeti:watcher:autorepair:"
232 autoRepairTagEnabled :: String
233 autoRepairTagEnabled = autoRepairTagPrefix
235 autoRepairTagPending :: String
236 autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
238 autoRepairTagResult :: String
239 autoRepairTagResult = autoRepairTagPrefix ++ "result:"
241 autoRepairTagSuspended :: String
242 autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
244 -- * Auto-repair levels
246 autoRepairFailover :: String
247 autoRepairFailover = "failover"
249 autoRepairFixStorage :: String
250 autoRepairFixStorage = "fix-storage"
252 autoRepairMigrate :: String
253 autoRepairMigrate = "migrate"
255 autoRepairReinstall :: String
256 autoRepairReinstall = "reinstall"
258 autoRepairAllTypes :: FrozenSet String
260 ConstantUtils.mkSet [autoRepairFailover,
261 autoRepairFixStorage,
265 -- * Auto-repair results
267 autoRepairEnoperm :: String
268 autoRepairEnoperm = "enoperm"
270 autoRepairFailure :: String
271 autoRepairFailure = "failure"
273 autoRepairSuccess :: String
274 autoRepairSuccess = "success"
276 autoRepairAllResults :: FrozenSet String
277 autoRepairAllResults =
278 ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
280 -- | The version identifier for builtin data collectors
281 builtinDataCollectorVersion :: String
282 builtinDataCollectorVersion = "B"