Flip dependency between Haskell types and constants
[ganeti-local] / src / Ganeti / HsConstants.hs
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 (mkSet, exitFailure)
45 import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..),
46                        ExtraLogReason(..))
47 import qualified Ganeti.Runtime as Runtime
48
49 -- * Admin states
50
51 adminstDown :: String
52 adminstDown = "down"
53
54 adminstOffline :: String
55 adminstOffline = "offline"
56
57 adminstUp :: String
58 adminstUp = "up"
59
60 adminstAll :: FrozenSet String
61 adminstAll = mkSet [adminstDown, adminstOffline, adminstUp]
62
63 -- * User separation
64
65 daemonsGroup :: String
66 daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
67
68 adminGroup :: String
69 adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
70
71 masterdUser :: String
72 masterdUser = Runtime.daemonUser GanetiMasterd
73
74 masterdGroup :: String
75 masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
76
77 rapiUser :: String
78 rapiUser = Runtime.daemonUser GanetiRapi
79
80 rapiGroup :: String
81 rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
82
83 confdUser :: String
84 confdUser = Runtime.daemonUser GanetiConfd
85
86 confdGroup :: String
87 confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
88
89 luxidUser :: String
90 luxidUser = Runtime.daemonUser GanetiLuxid
91
92 luxidGroup :: String
93 luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
94
95 nodedUser :: String
96 nodedUser = Runtime.daemonUser GanetiNoded
97
98 nodedGroup :: String
99 nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
100
101 mondUser :: String
102 mondUser = Runtime.daemonUser GanetiMond
103
104 mondGroup :: String
105 mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
106
107 sshLoginUser :: String
108 sshLoginUser = AutoConf.sshLoginUser
109
110 sshConsoleUser :: String
111 sshConsoleUser = AutoConf.sshConsoleUser
112
113 -- * SSH constants
114
115 ssh :: String
116 ssh = "ssh"
117
118 scp :: String
119 scp = "scp"
120
121 -- * Daemons
122
123 confd :: String
124 confd = Runtime.daemonName GanetiConfd
125
126 masterd :: String
127 masterd = Runtime.daemonName GanetiMasterd
128
129 mond :: String
130 mond = Runtime.daemonName GanetiMond
131
132 noded :: String
133 noded = Runtime.daemonName GanetiNoded
134
135 luxid :: String
136 luxid = Runtime.daemonName GanetiLuxid
137
138 rapi :: String
139 rapi = Runtime.daemonName GanetiRapi
140
141 daemons :: FrozenSet String
142 daemons =
143   mkSet [confd,
144          luxid,
145          masterd,
146          mond,
147          noded,
148          rapi]
149
150 defaultConfdPort :: Int
151 defaultConfdPort = 1814
152
153 defaultMondPort :: Int
154 defaultMondPort = 1815
155
156 defaultNodedPort :: Int
157 defaultNodedPort = 1811
158
159 defaultRapiPort :: Int
160 defaultRapiPort = 5080
161
162 daemonsPorts :: Map String (Protocol, Int)
163 daemonsPorts =
164   Map.fromList [(confd, (Udp, defaultConfdPort)),
165                 (mond, (Tcp, defaultMondPort)),
166                 (noded, (Tcp, defaultNodedPort)),
167                 (rapi, (Tcp, defaultRapiPort)),
168                 (ssh, (Tcp, 22))]
169
170 extraLogreasonAccess :: String
171 extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
172
173 extraLogreasonError :: String
174 extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
175
176 -- * Possible values for NodeGroup.alloc_policy
177
178 allocPolicyLastResort :: String
179 allocPolicyLastResort = "last_resort"
180
181 allocPolicyPreferred :: String
182 allocPolicyPreferred = "preferred"
183
184 allocPolicyUnallocable :: String
185 allocPolicyUnallocable = "unallocable"
186
187 validAllocPolicies :: [String]
188 validAllocPolicies =
189   [allocPolicyLastResort,
190    allocPolicyPreferred,
191    allocPolicyUnallocable]
192
193 -- | Temporary external/shared storage parameters
194 blockdevDriverManual :: String
195 blockdevDriverManual = "manual"
196
197 -- * Auto-repair tag prefixes
198
199 autoRepairTagPrefix :: String
200 autoRepairTagPrefix = "ganeti:watcher:autorepair:"
201
202 autoRepairTagEnabled :: String
203 autoRepairTagEnabled = autoRepairTagPrefix
204
205 autoRepairTagPending :: String
206 autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
207
208 autoRepairTagResult :: String
209 autoRepairTagResult = autoRepairTagPrefix ++ "result:"
210
211 autoRepairTagSuspended :: String
212 autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
213
214 -- * Auto-repair levels
215
216 autoRepairFailover :: String
217 autoRepairFailover = "failover"
218
219 autoRepairFixStorage :: String
220 autoRepairFixStorage = "fix-storage"
221
222 autoRepairMigrate :: String
223 autoRepairMigrate = "migrate"
224
225 autoRepairReinstall :: String
226 autoRepairReinstall = "reinstall"
227
228 autoRepairAllTypes :: FrozenSet String
229 autoRepairAllTypes =
230   mkSet [autoRepairFailover,
231          autoRepairFixStorage,
232          autoRepairMigrate,
233          autoRepairReinstall]
234
235 -- * Auto-repair results
236
237 autoRepairEnoperm :: String
238 autoRepairEnoperm = "enoperm"
239
240 autoRepairFailure :: String
241 autoRepairFailure = "failure"
242
243 autoRepairSuccess :: String
244 autoRepairSuccess = "success"
245
246 autoRepairAllResults :: FrozenSet String
247 autoRepairAllResults =
248   mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
249
250 -- | The version identifier for builtin data collectors
251 builtinDataCollectorVersion :: String
252 builtinDataCollectorVersion = "B"