Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ 1c31b263

History | View | Annotate | Download (6.1 kB)

1 1b2adaa6 Jose A. Lopes
{-| HsConstants contains the Haskell constants
2 1b2adaa6 Jose A. Lopes
3 1b2adaa6 Jose A. Lopes
This is a transitional module complementary to 'Ganeti.Constants'.  It
4 1b2adaa6 Jose A. Lopes
is intended to contain the Haskell constants that are meant to be
5 1b2adaa6 Jose A. Lopes
generated in Python.
6 1b2adaa6 Jose A. Lopes
7 c93041a5 Jose A. Lopes
Do not write any definitions in this file other than constants.  Do
8 c93041a5 Jose A. Lopes
not even write helper functions.  The definitions in this module are
9 c93041a5 Jose A. Lopes
automatically stripped to build the Makefile.am target
10 c93041a5 Jose A. Lopes
'ListConstants.hs'.  If there are helper functions in this module,
11 c93041a5 Jose A. Lopes
they will also be dragged and it will cause compilation to fail.
12 c93041a5 Jose A. Lopes
Therefore, all helper functions should go to a separate module and
13 c93041a5 Jose A. Lopes
imported.
14 c93041a5 Jose A. Lopes
15 1b2adaa6 Jose A. Lopes
-}
16 1b2adaa6 Jose A. Lopes
17 1b2adaa6 Jose A. Lopes
{-
18 1b2adaa6 Jose A. Lopes
19 1b2adaa6 Jose A. Lopes
Copyright (C) 2013 Google Inc.
20 1b2adaa6 Jose A. Lopes
21 1b2adaa6 Jose A. Lopes
This program is free software; you can redistribute it and/or modify
22 1b2adaa6 Jose A. Lopes
it under the terms of the GNU General Public License as published by
23 1b2adaa6 Jose A. Lopes
the Free Software Foundation; either version 2 of the License, or
24 1b2adaa6 Jose A. Lopes
(at your option) any later version.
25 1b2adaa6 Jose A. Lopes
26 1b2adaa6 Jose A. Lopes
This program is distributed in the hope that it will be useful, but
27 1b2adaa6 Jose A. Lopes
WITHOUT ANY WARRANTY; without even the implied warranty of
28 1b2adaa6 Jose A. Lopes
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
29 1b2adaa6 Jose A. Lopes
General Public License for more details.
30 1b2adaa6 Jose A. Lopes
31 1b2adaa6 Jose A. Lopes
You should have received a copy of the GNU General Public License
32 1b2adaa6 Jose A. Lopes
along with this program; if not, write to the Free Software
33 1b2adaa6 Jose A. Lopes
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
34 1b2adaa6 Jose A. Lopes
02110-1301, USA.
35 1b2adaa6 Jose A. Lopes
36 1b2adaa6 Jose A. Lopes
-}
37 1b2adaa6 Jose A. Lopes
module Ganeti.HsConstants where
38 1b2adaa6 Jose A. Lopes
39 6dc0cb59 Jose A. Lopes
import Data.Map (Map)
40 6dc0cb59 Jose A. Lopes
import qualified Data.Map as Map (fromList)
41 6dc0cb59 Jose A. Lopes
42 26eca119 Jose A. Lopes
import AutoConf
43 1c31b263 Jose A. Lopes
import Ganeti.ConstantUtils (FrozenSet, Protocol(..))
44 1c31b263 Jose A. Lopes
import qualified Ganeti.ConstantUtils as ConstantUtils (mkSet, exitFailure)
45 1c31b263 Jose A. Lopes
import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..),
46 1c31b263 Jose A. Lopes
                       ExtraLogReason(..))
47 1c31b263 Jose A. Lopes
import qualified Ganeti.Runtime as Runtime
48 9413ef24 Jose A. Lopes
49 9413ef24 Jose A. Lopes
-- * Admin states
50 9413ef24 Jose A. Lopes
51 1b2adaa6 Jose A. Lopes
adminstDown :: String
52 1b2adaa6 Jose A. Lopes
adminstDown = "down"
53 1b2adaa6 Jose A. Lopes
54 1b2adaa6 Jose A. Lopes
adminstOffline :: String
55 1b2adaa6 Jose A. Lopes
adminstOffline = "offline"
56 1b2adaa6 Jose A. Lopes
57 1b2adaa6 Jose A. Lopes
adminstUp :: String
58 1b2adaa6 Jose A. Lopes
adminstUp = "up"
59 9413ef24 Jose A. Lopes
60 9413ef24 Jose A. Lopes
adminstAll :: FrozenSet String
61 9413ef24 Jose A. Lopes
adminstAll = mkSet [adminstDown, adminstOffline, adminstUp]
62 26eca119 Jose A. Lopes
63 26eca119 Jose A. Lopes
-- * User separation
64 26eca119 Jose A. Lopes
65 26eca119 Jose A. Lopes
daemonsGroup :: String
66 1c31b263 Jose A. Lopes
daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
67 26eca119 Jose A. Lopes
68 26eca119 Jose A. Lopes
adminGroup :: String
69 1c31b263 Jose A. Lopes
adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
70 26eca119 Jose A. Lopes
71 26eca119 Jose A. Lopes
masterdUser :: String
72 1c31b263 Jose A. Lopes
masterdUser = Runtime.daemonUser GanetiMasterd
73 26eca119 Jose A. Lopes
74 26eca119 Jose A. Lopes
masterdGroup :: String
75 1c31b263 Jose A. Lopes
masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
76 26eca119 Jose A. Lopes
77 26eca119 Jose A. Lopes
rapiUser :: String
78 1c31b263 Jose A. Lopes
rapiUser = Runtime.daemonUser GanetiRapi
79 26eca119 Jose A. Lopes
80 26eca119 Jose A. Lopes
rapiGroup :: String
81 1c31b263 Jose A. Lopes
rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
82 26eca119 Jose A. Lopes
83 26eca119 Jose A. Lopes
confdUser :: String
84 1c31b263 Jose A. Lopes
confdUser = Runtime.daemonUser GanetiConfd
85 26eca119 Jose A. Lopes
86 26eca119 Jose A. Lopes
confdGroup :: String
87 1c31b263 Jose A. Lopes
confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
88 26eca119 Jose A. Lopes
89 26eca119 Jose A. Lopes
luxidUser :: String
90 1c31b263 Jose A. Lopes
luxidUser = Runtime.daemonUser GanetiLuxid
91 26eca119 Jose A. Lopes
92 26eca119 Jose A. Lopes
luxidGroup :: String
93 1c31b263 Jose A. Lopes
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
94 26eca119 Jose A. Lopes
95 26eca119 Jose A. Lopes
nodedUser :: String
96 1c31b263 Jose A. Lopes
nodedUser = Runtime.daemonUser GanetiNoded
97 26eca119 Jose A. Lopes
98 26eca119 Jose A. Lopes
nodedGroup :: String
99 1c31b263 Jose A. Lopes
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
100 26eca119 Jose A. Lopes
101 26eca119 Jose A. Lopes
mondUser :: String
102 1c31b263 Jose A. Lopes
mondUser = Runtime.daemonUser GanetiMond
103 26eca119 Jose A. Lopes
104 26eca119 Jose A. Lopes
mondGroup :: String
105 1c31b263 Jose A. Lopes
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
106 26eca119 Jose A. Lopes
107 26eca119 Jose A. Lopes
sshLoginUser :: String
108 26eca119 Jose A. Lopes
sshLoginUser = AutoConf.sshLoginUser
109 26eca119 Jose A. Lopes
110 26eca119 Jose A. Lopes
sshConsoleUser :: String
111 26eca119 Jose A. Lopes
sshConsoleUser = AutoConf.sshConsoleUser
112 f361a6ee Jose A. Lopes
113 f361a6ee Jose A. Lopes
-- * SSH constants
114 f361a6ee Jose A. Lopes
115 f361a6ee Jose A. Lopes
ssh :: String
116 f361a6ee Jose A. Lopes
ssh = "ssh"
117 f361a6ee Jose A. Lopes
118 f361a6ee Jose A. Lopes
scp :: String
119 f361a6ee Jose A. Lopes
scp = "scp"
120 f361a6ee Jose A. Lopes
121 f361a6ee Jose A. Lopes
-- * Daemons
122 f361a6ee Jose A. Lopes
123 f361a6ee Jose A. Lopes
confd :: String
124 1c31b263 Jose A. Lopes
confd = Runtime.daemonName GanetiConfd
125 f361a6ee Jose A. Lopes
126 f361a6ee Jose A. Lopes
masterd :: String
127 1c31b263 Jose A. Lopes
masterd = Runtime.daemonName GanetiMasterd
128 f361a6ee Jose A. Lopes
129 f361a6ee Jose A. Lopes
mond :: String
130 1c31b263 Jose A. Lopes
mond = Runtime.daemonName GanetiMond
131 f361a6ee Jose A. Lopes
132 f361a6ee Jose A. Lopes
noded :: String
133 1c31b263 Jose A. Lopes
noded = Runtime.daemonName GanetiNoded
134 f361a6ee Jose A. Lopes
135 f361a6ee Jose A. Lopes
luxid :: String
136 1c31b263 Jose A. Lopes
luxid = Runtime.daemonName GanetiLuxid
137 f361a6ee Jose A. Lopes
138 f361a6ee Jose A. Lopes
rapi :: String
139 1c31b263 Jose A. Lopes
rapi = Runtime.daemonName GanetiRapi
140 f361a6ee Jose A. Lopes
141 f361a6ee Jose A. Lopes
daemons :: FrozenSet String
142 f361a6ee Jose A. Lopes
daemons =
143 f361a6ee Jose A. Lopes
  mkSet [confd,
144 f361a6ee Jose A. Lopes
         luxid,
145 f361a6ee Jose A. Lopes
         masterd,
146 f361a6ee Jose A. Lopes
         mond,
147 f361a6ee Jose A. Lopes
         noded,
148 f361a6ee Jose A. Lopes
         rapi]
149 f361a6ee Jose A. Lopes
150 6dc0cb59 Jose A. Lopes
defaultConfdPort :: Int
151 6dc0cb59 Jose A. Lopes
defaultConfdPort = 1814
152 6dc0cb59 Jose A. Lopes
153 6dc0cb59 Jose A. Lopes
defaultMondPort :: Int
154 6dc0cb59 Jose A. Lopes
defaultMondPort = 1815
155 6dc0cb59 Jose A. Lopes
156 6dc0cb59 Jose A. Lopes
defaultNodedPort :: Int
157 6dc0cb59 Jose A. Lopes
defaultNodedPort = 1811
158 6dc0cb59 Jose A. Lopes
159 6dc0cb59 Jose A. Lopes
defaultRapiPort :: Int
160 6dc0cb59 Jose A. Lopes
defaultRapiPort = 5080
161 6dc0cb59 Jose A. Lopes
162 6dc0cb59 Jose A. Lopes
daemonsPorts :: Map String (Protocol, Int)
163 6dc0cb59 Jose A. Lopes
daemonsPorts =
164 6dc0cb59 Jose A. Lopes
  Map.fromList [(confd, (Udp, defaultConfdPort)),
165 6dc0cb59 Jose A. Lopes
                (mond, (Tcp, defaultMondPort)),
166 6dc0cb59 Jose A. Lopes
                (noded, (Tcp, defaultNodedPort)),
167 6dc0cb59 Jose A. Lopes
                (rapi, (Tcp, defaultRapiPort)),
168 6dc0cb59 Jose A. Lopes
                (ssh, (Tcp, 22))]
169 6dc0cb59 Jose A. Lopes
170 1c31b263 Jose A. Lopes
extraLogreasonAccess :: String
171 1c31b263 Jose A. Lopes
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
172 1c31b263 Jose A. Lopes
173 1c31b263 Jose A. Lopes
extraLogreasonError :: String
174 1c31b263 Jose A. Lopes
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
175 1c31b263 Jose A. Lopes
176 f361a6ee Jose A. Lopes
-- * Possible values for NodeGroup.alloc_policy
177 f361a6ee Jose A. Lopes
178 f361a6ee Jose A. Lopes
allocPolicyLastResort :: String
179 f361a6ee Jose A. Lopes
allocPolicyLastResort = "last_resort"
180 f361a6ee Jose A. Lopes
181 f361a6ee Jose A. Lopes
allocPolicyPreferred :: String
182 f361a6ee Jose A. Lopes
allocPolicyPreferred = "preferred"
183 f361a6ee Jose A. Lopes
184 f361a6ee Jose A. Lopes
allocPolicyUnallocable :: String
185 f361a6ee Jose A. Lopes
allocPolicyUnallocable = "unallocable"
186 f361a6ee Jose A. Lopes
187 f361a6ee Jose A. Lopes
validAllocPolicies :: [String]
188 f361a6ee Jose A. Lopes
validAllocPolicies =
189 f361a6ee Jose A. Lopes
  [allocPolicyLastResort,
190 f361a6ee Jose A. Lopes
   allocPolicyPreferred,
191 f361a6ee Jose A. Lopes
   allocPolicyUnallocable]
192 f361a6ee Jose A. Lopes
193 f361a6ee Jose A. Lopes
-- | Temporary external/shared storage parameters
194 f361a6ee Jose A. Lopes
blockdevDriverManual :: String
195 f361a6ee Jose A. Lopes
blockdevDriverManual = "manual"
196 f361a6ee Jose A. Lopes
197 f361a6ee Jose A. Lopes
-- * Auto-repair tag prefixes
198 f361a6ee Jose A. Lopes
199 f361a6ee Jose A. Lopes
autoRepairTagPrefix :: String
200 f361a6ee Jose A. Lopes
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
201 f361a6ee Jose A. Lopes
202 f361a6ee Jose A. Lopes
autoRepairTagEnabled :: String
203 f361a6ee Jose A. Lopes
autoRepairTagEnabled = autoRepairTagPrefix
204 f361a6ee Jose A. Lopes
205 f361a6ee Jose A. Lopes
autoRepairTagPending :: String
206 f361a6ee Jose A. Lopes
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
207 f361a6ee Jose A. Lopes
208 f361a6ee Jose A. Lopes
autoRepairTagResult :: String
209 f361a6ee Jose A. Lopes
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
210 f361a6ee Jose A. Lopes
211 f361a6ee Jose A. Lopes
autoRepairTagSuspended :: String
212 f361a6ee Jose A. Lopes
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
213 f361a6ee Jose A. Lopes
214 f361a6ee Jose A. Lopes
-- * Auto-repair levels
215 f361a6ee Jose A. Lopes
216 f361a6ee Jose A. Lopes
autoRepairFailover :: String
217 f361a6ee Jose A. Lopes
autoRepairFailover = "failover"
218 f361a6ee Jose A. Lopes
219 f361a6ee Jose A. Lopes
autoRepairFixStorage :: String
220 f361a6ee Jose A. Lopes
autoRepairFixStorage = "fix-storage"
221 f361a6ee Jose A. Lopes
222 f361a6ee Jose A. Lopes
autoRepairMigrate :: String
223 f361a6ee Jose A. Lopes
autoRepairMigrate = "migrate"
224 f361a6ee Jose A. Lopes
225 f361a6ee Jose A. Lopes
autoRepairReinstall :: String
226 f361a6ee Jose A. Lopes
autoRepairReinstall = "reinstall"
227 f361a6ee Jose A. Lopes
228 f361a6ee Jose A. Lopes
autoRepairAllTypes :: FrozenSet String
229 f361a6ee Jose A. Lopes
autoRepairAllTypes =
230 f361a6ee Jose A. Lopes
  mkSet [autoRepairFailover,
231 f361a6ee Jose A. Lopes
         autoRepairFixStorage,
232 f361a6ee Jose A. Lopes
         autoRepairMigrate,
233 f361a6ee Jose A. Lopes
         autoRepairReinstall]
234 f361a6ee Jose A. Lopes
235 f361a6ee Jose A. Lopes
-- * Auto-repair results
236 f361a6ee Jose A. Lopes
237 f361a6ee Jose A. Lopes
autoRepairEnoperm :: String
238 f361a6ee Jose A. Lopes
autoRepairEnoperm = "enoperm"
239 f361a6ee Jose A. Lopes
240 f361a6ee Jose A. Lopes
autoRepairFailure :: String
241 f361a6ee Jose A. Lopes
autoRepairFailure = "failure"
242 f361a6ee Jose A. Lopes
243 f361a6ee Jose A. Lopes
autoRepairSuccess :: String
244 f361a6ee Jose A. Lopes
autoRepairSuccess = "success"
245 f361a6ee Jose A. Lopes
246 f361a6ee Jose A. Lopes
autoRepairAllResults :: FrozenSet String
247 f361a6ee Jose A. Lopes
autoRepairAllResults =
248 f361a6ee Jose A. Lopes
  mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
249 f361a6ee Jose A. Lopes
250 f361a6ee Jose A. Lopes
-- | The version identifier for builtin data collectors
251 f361a6ee Jose A. Lopes
builtinDataCollectorVersion :: String
252 f361a6ee Jose A. Lopes
builtinDataCollectorVersion = "B"