Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ 3311e336

History | View | Annotate | Download (27.3 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
import Ganeti.Types
51
import qualified Ganeti.Types as Types
52

    
53
-- * Constants for 'lib/pathutils.py'
54

    
55
osSearchPath :: [String]
56
osSearchPath = AutoConf.osSearchPath
57

    
58
esSearchPath :: [String]
59
esSearchPath = AutoConf.esSearchPath
60

    
61
-- * OOB supported commands
62

    
63
oobPowerOn :: String
64
oobPowerOn = Types.oobCommandToRaw OobPowerOn
65

    
66
oobPowerOff :: String
67
oobPowerOff = Types.oobCommandToRaw OobPowerOff
68

    
69
oobPowerCycle :: String
70
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
71

    
72
oobPowerStatus :: String
73
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
74

    
75
oobHealth :: String
76
oobHealth = Types.oobCommandToRaw OobHealth
77

    
78
oobCommands :: FrozenSet String
79
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
80

    
81
oobPowerStatusPowered :: String
82
oobPowerStatusPowered = "powered"
83

    
84
-- | 60 seconds
85
oobTimeout :: Int
86
oobTimeout = 60
87

    
88
-- | 2 seconds
89
oobPowerDelay :: Double
90
oobPowerDelay = 2.0
91

    
92
oobStatusCritical :: String
93
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
94

    
95
oobStatusOk :: String
96
oobStatusOk = Types.oobStatusToRaw OobStatusOk
97

    
98
oobStatusUnknown :: String
99
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
100

    
101
oobStatusWarning :: String
102
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
103

    
104
oobStatuses :: FrozenSet String
105
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
106

    
107
-- * NIC_* constants are used inside the ganeti config
108

    
109
nicLink :: String
110
nicLink = "link"
111

    
112
nicMode :: String
113
nicMode = "mode"
114

    
115
nicVlan :: String
116
nicVlan = "vlan"
117

    
118
nicModeBridged :: String
119
nicModeBridged = Types.nICModeToRaw NMBridged
120

    
121
nicModeRouted :: String
122
nicModeRouted = Types.nICModeToRaw NMRouted
123

    
124
nicModeOvs :: String
125
nicModeOvs = Types.nICModeToRaw NMOvs
126

    
127
nicIpPool :: String
128
nicIpPool = Types.nICModeToRaw NMPool
129

    
130
nicValidModes :: FrozenSet String
131
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
132

    
133
-- * Hypervisor constants
134

    
135
htXenPvm :: String
136
htXenPvm = Types.hypervisorToRaw XenPvm
137

    
138
htFake :: String
139
htFake = Types.hypervisorToRaw Fake
140

    
141
htXenHvm :: String
142
htXenHvm = Types.hypervisorToRaw XenHvm
143

    
144
htKvm :: String
145
htKvm = Types.hypervisorToRaw Kvm
146

    
147
htChroot :: String
148
htChroot = Types.hypervisorToRaw Chroot
149

    
150
htLxc :: String
151
htLxc = Types.hypervisorToRaw Lxc
152

    
153
hyperTypes :: FrozenSet String
154
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
155

    
156
htsReqPort :: FrozenSet String
157
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
158

    
159
-- * Migration type
160

    
161
htMigrationLive :: String
162
htMigrationLive = Types.migrationModeToRaw MigrationLive
163

    
164
htMigrationNonlive :: String
165
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
166

    
167
htMigrationModes :: FrozenSet String
168
htMigrationModes =
169
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
170

    
171
-- * Cluster verify steps
172

    
173
verifyNplusoneMem :: String
174
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
175

    
176
verifyOptionalChecks :: FrozenSet String
177
verifyOptionalChecks =
178
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
179

    
180
-- * Cluster Verify error classes
181

    
182
cvTcluster :: String
183
cvTcluster = "cluster"
184

    
185
cvTgroup :: String
186
cvTgroup = "group"
187

    
188
cvTnode :: String
189
cvTnode = "node"
190

    
191
cvTinstance :: String
192
cvTinstance = "instance"
193

    
194
-- * Cluster Verify error codes and documentation
195

    
196
cvEclustercert :: (String, String, String)
197
cvEclustercert =
198
  ("cluster",
199
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
200
   "Cluster certificate files verification failure")
201

    
202
cvEclustercfg :: (String, String, String)
203
cvEclustercfg =
204
  ("cluster",
205
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
206
   "Cluster configuration verification failure")
207

    
208
cvEclusterdanglinginst :: (String, String, String)
209
cvEclusterdanglinginst =
210
  ("node",
211
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
212
   "Some instances have a non-existing primary node")
213

    
214
cvEclusterdanglingnodes :: (String, String, String)
215
cvEclusterdanglingnodes =
216
  ("node",
217
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
218
   "Some nodes belong to non-existing groups")
219

    
220
cvEclusterfilecheck :: (String, String, String)
221
cvEclusterfilecheck =
222
  ("cluster",
223
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
224
   "Cluster configuration verification failure")
225

    
226
cvEgroupdifferentpvsize :: (String, String, String)
227
cvEgroupdifferentpvsize =
228
  ("group",
229
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
230
   "PVs in the group have different sizes")
231

    
232
cvEinstancebadnode :: (String, String, String)
233
cvEinstancebadnode =
234
  ("instance",
235
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
236
   "Instance marked as running lives on an offline node")
237

    
238
cvEinstancedown :: (String, String, String)
239
cvEinstancedown =
240
  ("instance",
241
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
242
   "Instance not running on its primary node")
243

    
244
cvEinstancefaultydisk :: (String, String, String)
245
cvEinstancefaultydisk =
246
  ("instance",
247
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
248
   "Impossible to retrieve status for a disk")
249

    
250
cvEinstancelayout :: (String, String, String)
251
cvEinstancelayout =
252
  ("instance",
253
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
254
   "Instance has multiple secondary nodes")
255

    
256
cvEinstancemissingcfgparameter :: (String, String, String)
257
cvEinstancemissingcfgparameter =
258
  ("instance",
259
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
260
   "A configuration parameter for an instance is missing")
261

    
262
cvEinstancemissingdisk :: (String, String, String)
263
cvEinstancemissingdisk =
264
  ("instance",
265
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
266
   "Missing volume on an instance")
267

    
268
cvEinstancepolicy :: (String, String, String)
269
cvEinstancepolicy =
270
  ("instance",
271
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
272
   "Instance does not meet policy")
273

    
274
cvEinstancesplitgroups :: (String, String, String)
275
cvEinstancesplitgroups =
276
  ("instance",
277
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
278
   "Instance with primary and secondary nodes in different groups")
279

    
280
cvEinstanceunsuitablenode :: (String, String, String)
281
cvEinstanceunsuitablenode =
282
  ("instance",
283
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
284
   "Instance running on nodes that are not suitable for it")
285

    
286
cvEinstancewrongnode :: (String, String, String)
287
cvEinstancewrongnode =
288
  ("instance",
289
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
290
   "Instance running on the wrong node")
291

    
292
cvEnodedrbd :: (String, String, String)
293
cvEnodedrbd =
294
  ("node",
295
   Types.cVErrorCodeToRaw CvENODEDRBD,
296
   "Error parsing the DRBD status file")
297

    
298
cvEnodedrbdhelper :: (String, String, String)
299
cvEnodedrbdhelper =
300
  ("node",
301
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
302
   "Error caused by the DRBD helper")
303

    
304
cvEnodedrbdversion :: (String, String, String)
305
cvEnodedrbdversion =
306
  ("node",
307
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
308
   "DRBD version mismatch within a node group")
309

    
310
cvEnodefilecheck :: (String, String, String)
311
cvEnodefilecheck =
312
  ("node",
313
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
314
   "Error retrieving the checksum of the node files")
315

    
316
cvEnodefilestoragepaths :: (String, String, String)
317
cvEnodefilestoragepaths =
318
  ("node",
319
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
320
   "Detected bad file storage paths")
321

    
322
cvEnodefilestoragepathunusable :: (String, String, String)
323
cvEnodefilestoragepathunusable =
324
  ("node",
325
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
326
   "File storage path unusable")
327

    
328
cvEnodehooks :: (String, String, String)
329
cvEnodehooks =
330
  ("node",
331
   Types.cVErrorCodeToRaw CvENODEHOOKS,
332
   "Communication failure in hooks execution")
333

    
334
cvEnodehv :: (String, String, String)
335
cvEnodehv =
336
  ("node",
337
   Types.cVErrorCodeToRaw CvENODEHV,
338
   "Hypervisor parameters verification failure")
339

    
340
cvEnodelvm :: (String, String, String)
341
cvEnodelvm =
342
  ("node",
343
   Types.cVErrorCodeToRaw CvENODELVM,
344
   "LVM-related node error")
345

    
346
cvEnoden1 :: (String, String, String)
347
cvEnoden1 =
348
  ("node",
349
   Types.cVErrorCodeToRaw CvENODEN1,
350
   "Not enough memory to accommodate instance failovers")
351

    
352
cvEnodenet :: (String, String, String)
353
cvEnodenet =
354
  ("node",
355
   Types.cVErrorCodeToRaw CvENODENET,
356
   "Network-related node error")
357

    
358
cvEnodeoobpath :: (String, String, String)
359
cvEnodeoobpath =
360
  ("node",
361
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
362
   "Invalid Out Of Band path")
363

    
364
cvEnodeorphaninstance :: (String, String, String)
365
cvEnodeorphaninstance =
366
  ("node",
367
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
368
   "Unknown intance running on a node")
369

    
370
cvEnodeorphanlv :: (String, String, String)
371
cvEnodeorphanlv =
372
  ("node",
373
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
374
   "Unknown LVM logical volume")
375

    
376
cvEnodeos :: (String, String, String)
377
cvEnodeos =
378
  ("node",
379
   Types.cVErrorCodeToRaw CvENODEOS,
380
   "OS-related node error")
381

    
382
cvEnoderpc :: (String, String, String)
383
cvEnoderpc =
384
  ("node",
385
   Types.cVErrorCodeToRaw CvENODERPC,
386
   "Error during connection to the primary node of an instance")
387

    
388
cvEnodesetup :: (String, String, String)
389
cvEnodesetup =
390
  ("node",
391
   Types.cVErrorCodeToRaw CvENODESETUP,
392
   "Node setup error")
393

    
394
cvEnodesharedfilestoragepathunusable :: (String, String, String)
395
cvEnodesharedfilestoragepathunusable =
396
  ("node",
397
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
398
   "Shared file storage path unusable")
399

    
400
cvEnodessh :: (String, String, String)
401
cvEnodessh =
402
  ("node",
403
   Types.cVErrorCodeToRaw CvENODESSH,
404
   "SSH-related node error")
405

    
406
cvEnodetime :: (String, String, String)
407
cvEnodetime =
408
  ("node",
409
   Types.cVErrorCodeToRaw CvENODETIME,
410
   "Node returned invalid time")
411

    
412
cvEnodeuserscripts :: (String, String, String)
413
cvEnodeuserscripts =
414
  ("node",
415
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
416
   "User scripts not present or not executable")
417

    
418
cvEnodeversion :: (String, String, String)
419
cvEnodeversion =
420
  ("node",
421
   Types.cVErrorCodeToRaw CvENODEVERSION,
422
   "Protocol version mismatch or Ganeti version mismatch")
423

    
424
cvAllEcodes :: FrozenSet (String, String, String)
425
cvAllEcodes =
426
  ConstantUtils.mkSet
427
  [cvEclustercert,
428
   cvEclustercfg,
429
   cvEclusterdanglinginst,
430
   cvEclusterdanglingnodes,
431
   cvEclusterfilecheck,
432
   cvEgroupdifferentpvsize,
433
   cvEinstancebadnode,
434
   cvEinstancedown,
435
   cvEinstancefaultydisk,
436
   cvEinstancelayout,
437
   cvEinstancemissingcfgparameter,
438
   cvEinstancemissingdisk,
439
   cvEinstancepolicy,
440
   cvEinstancesplitgroups,
441
   cvEinstanceunsuitablenode,
442
   cvEinstancewrongnode,
443
   cvEnodedrbd,
444
   cvEnodedrbdhelper,
445
   cvEnodedrbdversion,
446
   cvEnodefilecheck,
447
   cvEnodefilestoragepaths,
448
   cvEnodefilestoragepathunusable,
449
   cvEnodehooks,
450
   cvEnodehv,
451
   cvEnodelvm,
452
   cvEnoden1,
453
   cvEnodenet,
454
   cvEnodeoobpath,
455
   cvEnodeorphaninstance,
456
   cvEnodeorphanlv,
457
   cvEnodeos,
458
   cvEnoderpc,
459
   cvEnodesetup,
460
   cvEnodesharedfilestoragepathunusable,
461
   cvEnodessh,
462
   cvEnodetime,
463
   cvEnodeuserscripts,
464
   cvEnodeversion]
465

    
466
cvAllEcodesStrings :: FrozenSet String
467
cvAllEcodesStrings =
468
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
469

    
470
-- * Instance status
471

    
472
inststAdmindown :: String
473
inststAdmindown = Types.instanceStatusToRaw StatusDown
474

    
475
inststAdminoffline :: String
476
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
477

    
478
inststErrordown :: String
479
inststErrordown = Types.instanceStatusToRaw ErrorDown
480

    
481
inststErrorup :: String
482
inststErrorup = Types.instanceStatusToRaw ErrorUp
483

    
484
inststNodedown :: String
485
inststNodedown = Types.instanceStatusToRaw NodeDown
486

    
487
inststNodeoffline :: String
488
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
489

    
490
inststRunning :: String
491
inststRunning = Types.instanceStatusToRaw Running
492

    
493
inststWrongnode :: String
494
inststWrongnode = Types.instanceStatusToRaw WrongNode
495

    
496
inststAll :: FrozenSet String
497
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
498

    
499
-- * Admin states
500

    
501
adminstDown :: String
502
adminstDown = "down"
503

    
504
adminstOffline :: String
505
adminstOffline = "offline"
506

    
507
adminstUp :: String
508
adminstUp = "up"
509

    
510
adminstAll :: FrozenSet String
511
adminstAll = ConstantUtils.mkSet [adminstDown, adminstOffline, adminstUp]
512

    
513
-- * Allocator framework constants
514

    
515
iallocatorVersion :: Int
516
iallocatorVersion = 2
517

    
518
iallocatorDirIn :: String
519
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
520

    
521
iallocatorDirOut :: String
522
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
523

    
524
validIallocatorDirections :: FrozenSet String
525
validIallocatorDirections =
526
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
527

    
528
iallocatorModeAlloc :: String
529
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
530

    
531
iallocatorModeChgGroup :: String
532
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
533

    
534
iallocatorModeMultiAlloc :: String
535
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
536

    
537
iallocatorModeNodeEvac :: String
538
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
539

    
540
iallocatorModeReloc :: String
541
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
542

    
543
validIallocatorModes :: FrozenSet String
544
validIallocatorModes =
545
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
546

    
547
iallocatorSearchPath :: [String]
548
iallocatorSearchPath = AutoConf.iallocatorSearchPath
549

    
550
defaultIallocatorShortcut :: String
551
defaultIallocatorShortcut = "."
552

    
553
iallocatorNevacPri :: String
554
iallocatorNevacPri = Types.nodeEvacModeToRaw NEvacPrimary
555

    
556
iallocatorNevacSec :: String
557
iallocatorNevacSec = Types.nodeEvacModeToRaw NEvacSecondary
558

    
559
iallocatorNevacAll :: String
560
iallocatorNevacAll = Types.nodeEvacModeToRaw NEvacAll
561

    
562
iallocatorNevacModes :: FrozenSet String
563
iallocatorNevacModes =
564
  ConstantUtils.mkSet $ map Types.nodeEvacModeToRaw [minBound..]
565

    
566
-- * Node evacuation
567

    
568
nodeEvacPri :: String
569
nodeEvacPri = Types.nodeEvacModeToRaw NEvacPrimary
570

    
571
nodeEvacSec :: String
572
nodeEvacSec = Types.nodeEvacModeToRaw NEvacSecondary
573

    
574
nodeEvacAll :: String
575
nodeEvacAll = Types.nodeEvacModeToRaw NEvacAll
576

    
577
nodeEvacModes :: FrozenSet String
578
nodeEvacModes = ConstantUtils.mkSet $ map Types.nodeEvacModeToRaw [minBound..]
579

    
580
-- * Job status
581

    
582
jobStatusQueued :: String
583
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
584

    
585
jobStatusWaiting :: String
586
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
587

    
588
jobStatusCanceling :: String
589
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
590

    
591
jobStatusRunning :: String
592
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
593

    
594
jobStatusCanceled :: String
595
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
596

    
597
jobStatusSuccess :: String
598
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
599

    
600
jobStatusError :: String
601
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
602

    
603
jobsPending :: FrozenSet String
604
jobsPending =
605
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
606

    
607
jobsFinalized :: FrozenSet String
608
jobsFinalized =
609
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
610

    
611
jobStatusAll :: FrozenSet String
612
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
613

    
614
-- * OpCode status
615

    
616
-- ** Not yet finalized opcodes
617

    
618
opStatusCanceling :: String
619
opStatusCanceling = "canceling"
620

    
621
opStatusQueued :: String
622
opStatusQueued = "queued"
623

    
624
opStatusRunning :: String
625
opStatusRunning = "running"
626

    
627
opStatusWaiting :: String
628
opStatusWaiting = "waiting"
629

    
630
-- ** Finalized opcodes
631

    
632
opStatusCanceled :: String
633
opStatusCanceled = "canceled"
634

    
635
opStatusError :: String
636
opStatusError = "error"
637

    
638
opStatusSuccess :: String
639
opStatusSuccess = "success"
640

    
641
opsFinalized :: FrozenSet String
642
opsFinalized =
643
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
644

    
645
-- * OpCode priority
646

    
647
opPrioLowest :: Int
648
opPrioLowest = 19
649

    
650
opPrioHighest :: Int
651
opPrioHighest = -20
652

    
653
opPrioLow :: Int
654
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
655

    
656
opPrioNormal :: Int
657
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
658

    
659
opPrioHigh :: Int
660
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
661

    
662
opPrioSubmitValid :: FrozenSet Int
663
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
664

    
665
opPrioDefault :: Int
666
opPrioDefault = opPrioNormal
667

    
668
-- * Execution log types
669

    
670
elogMessage :: String
671
elogMessage = Types.eLogTypeToRaw ELogMessage
672

    
673
elogRemoteImport :: String
674
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
675

    
676
elogJqueueTest :: String
677
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
678

    
679
-- * User separation
680

    
681
daemonsGroup :: String
682
daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
683

    
684
adminGroup :: String
685
adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
686

    
687
masterdUser :: String
688
masterdUser = Runtime.daemonUser GanetiMasterd
689

    
690
masterdGroup :: String
691
masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
692

    
693
rapiUser :: String
694
rapiUser = Runtime.daemonUser GanetiRapi
695

    
696
rapiGroup :: String
697
rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
698

    
699
confdUser :: String
700
confdUser = Runtime.daemonUser GanetiConfd
701

    
702
confdGroup :: String
703
confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
704

    
705
luxidUser :: String
706
luxidUser = Runtime.daemonUser GanetiLuxid
707

    
708
luxidGroup :: String
709
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
710

    
711
nodedUser :: String
712
nodedUser = Runtime.daemonUser GanetiNoded
713

    
714
nodedGroup :: String
715
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
716

    
717
mondUser :: String
718
mondUser = Runtime.daemonUser GanetiMond
719

    
720
mondGroup :: String
721
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
722

    
723
sshLoginUser :: String
724
sshLoginUser = AutoConf.sshLoginUser
725

    
726
sshConsoleUser :: String
727
sshConsoleUser = AutoConf.sshConsoleUser
728

    
729
-- * SSH constants
730

    
731
ssh :: String
732
ssh = "ssh"
733

    
734
scp :: String
735
scp = "scp"
736

    
737
-- * Daemons
738

    
739
confd :: String
740
confd = Runtime.daemonName GanetiConfd
741

    
742
masterd :: String
743
masterd = Runtime.daemonName GanetiMasterd
744

    
745
mond :: String
746
mond = Runtime.daemonName GanetiMond
747

    
748
noded :: String
749
noded = Runtime.daemonName GanetiNoded
750

    
751
luxid :: String
752
luxid = Runtime.daemonName GanetiLuxid
753

    
754
rapi :: String
755
rapi = Runtime.daemonName GanetiRapi
756

    
757
daemons :: FrozenSet String
758
daemons =
759
  ConstantUtils.mkSet [confd,
760
                       luxid,
761
                       masterd,
762
                       mond,
763
                       noded,
764
                       rapi]
765

    
766
defaultConfdPort :: Int
767
defaultConfdPort = 1814
768

    
769
defaultMondPort :: Int
770
defaultMondPort = 1815
771

    
772
defaultNodedPort :: Int
773
defaultNodedPort = 1811
774

    
775
defaultRapiPort :: Int
776
defaultRapiPort = 5080
777

    
778
daemonsPorts :: Map String (Protocol, Int)
779
daemonsPorts =
780
  Map.fromList [(confd, (Udp, defaultConfdPort)),
781
                (mond, (Tcp, defaultMondPort)),
782
                (noded, (Tcp, defaultNodedPort)),
783
                (rapi, (Tcp, defaultRapiPort)),
784
                (ssh, (Tcp, 22))]
785

    
786
daemonsLogbase :: Map String String
787
daemonsLogbase =
788
  Map.fromList
789
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
790

    
791
extraLogreasonAccess :: String
792
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
793

    
794
extraLogreasonError :: String
795
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
796

    
797
devConsole :: String
798
devConsole = ConstantUtils.devConsole
799

    
800
-- * Syslog
801

    
802
syslogUsage :: String
803
syslogUsage = AutoConf.syslogUsage
804

    
805
syslogNo :: String
806
syslogNo = Logging.syslogUsageToRaw SyslogNo
807

    
808
syslogYes :: String
809
syslogYes = Logging.syslogUsageToRaw SyslogYes
810

    
811
syslogOnly :: String
812
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
813

    
814
syslogSocket :: String
815
syslogSocket = "/dev/log"
816

    
817
-- * Xen
818

    
819
xenBootloader :: String
820
xenBootloader = AutoConf.xenBootloader
821

    
822
xenCmdXl :: String
823
xenCmdXl = "xl"
824

    
825
xenCmdXm :: String
826
xenCmdXm = "xm"
827

    
828
xenInitrd :: String
829
xenInitrd = AutoConf.xenInitrd
830

    
831
xenKernel :: String
832
xenKernel = AutoConf.xenKernel
833

    
834
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
835
-- other constants
836
knownXenCommands :: FrozenSet String
837
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
838

    
839
-- * Storage types
840

    
841
stBlock :: String
842
stBlock = Types.storageTypeToRaw StorageBlock
843

    
844
stDiskless :: String
845
stDiskless = Types.storageTypeToRaw StorageDiskless
846

    
847
stExt :: String
848
stExt = Types.storageTypeToRaw StorageExt
849

    
850
stFile :: String
851
stFile = Types.storageTypeToRaw StorageFile
852

    
853
stLvmPv :: String
854
stLvmPv = Types.storageTypeToRaw StorageLvmPv
855

    
856
stLvmVg :: String
857
stLvmVg = Types.storageTypeToRaw StorageLvmVg
858

    
859
stRados :: String
860
stRados = Types.storageTypeToRaw StorageRados
861

    
862
storageTypes :: FrozenSet String
863
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
864

    
865
-- * Disk template types
866

    
867
dtDiskless :: String
868
dtDiskless = Types.diskTemplateToRaw DTDiskless
869

    
870
dtFile :: String
871
dtFile = Types.diskTemplateToRaw DTFile
872

    
873
dtSharedFile :: String
874
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
875

    
876
dtPlain :: String
877
dtPlain = Types.diskTemplateToRaw DTPlain
878

    
879
dtBlock :: String
880
dtBlock = Types.diskTemplateToRaw DTBlock
881

    
882
dtDrbd8 :: String
883
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
884

    
885
dtRbd :: String
886
dtRbd = Types.diskTemplateToRaw DTRbd
887

    
888
dtExt :: String
889
dtExt = Types.diskTemplateToRaw DTExt
890

    
891
-- | This is used to order determine the default disk template when
892
-- the list of enabled disk templates is inferred from the current
893
-- state of the cluster.  This only happens on an upgrade from a
894
-- version of Ganeti that did not support the 'enabled_disk_templates'
895
-- so far.
896
diskTemplatePreference :: [String]
897
diskTemplatePreference =
898
  map Types.diskTemplateToRaw
899
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile, DTPlain, DTRbd, DTSharedFile]
900

    
901
diskTemplates :: FrozenSet String
902
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
903

    
904
-- | Disk templates that are enabled by default
905
defaultEnabledDiskTemplates :: [String]
906
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
907

    
908
-- * File backend driver
909

    
910
fdBlktap :: String
911
fdBlktap = Types.fileDriverToRaw FileBlktap
912

    
913
fdLoop :: String
914
fdLoop = Types.fileDriverToRaw FileLoop
915

    
916
-- * Instance export mode
917

    
918
exportModeLocal :: String
919
exportModeLocal = Types.exportModeToRaw ExportModeLocal
920

    
921
exportModeRemote :: String
922
exportModeRemote = Types.exportModeToRaw ExportModeRemote
923

    
924
exportModes :: FrozenSet String
925
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
926

    
927
-- * Instance creation modes
928

    
929
instanceCreate :: String
930
instanceCreate = Types.instCreateModeToRaw InstCreate
931

    
932
instanceImport :: String
933
instanceImport = Types.instCreateModeToRaw InstImport
934

    
935
instanceRemoteImport :: String
936
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
937

    
938
instanceCreateModes :: FrozenSet String
939
instanceCreateModes =
940
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
941

    
942
-- * Dynamic device modification
943

    
944
ddmAdd :: String
945
ddmAdd = Types.ddmFullToRaw DdmFullAdd
946

    
947
ddmModify :: String
948
ddmModify = Types.ddmFullToRaw DdmFullModify
949

    
950
ddmRemove :: String
951
ddmRemove = Types.ddmFullToRaw DdmFullRemove
952

    
953
ddmsValues :: FrozenSet String
954
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
955

    
956
ddmsValuesWithModify :: FrozenSet String
957
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
958

    
959
-- * Common exit codes
960

    
961
exitSuccess :: Int
962
exitSuccess = 0
963

    
964
exitFailure :: Int
965
exitFailure = ConstantUtils.exitFailure
966

    
967
exitNotcluster :: Int
968
exitNotcluster = 5
969

    
970
exitNotmaster :: Int
971
exitNotmaster = 11
972

    
973
exitNodesetupError :: Int
974
exitNodesetupError = 12
975

    
976
-- | Need user confirmation
977
exitConfirmation :: Int
978
exitConfirmation = 13
979

    
980
-- | Exit code for query operations with unknown fields
981
exitUnknownField :: Int
982
exitUnknownField = 14
983

    
984
-- * Tags
985

    
986
tagCluster :: String
987
tagCluster = Types.tagKindToRaw TagKindCluster
988

    
989
tagInstance :: String
990
tagInstance = Types.tagKindToRaw TagKindInstance
991

    
992
tagNetwork :: String
993
tagNetwork = Types.tagKindToRaw TagKindNetwork
994

    
995
tagNode :: String
996
tagNode = Types.tagKindToRaw TagKindNode
997

    
998
tagNodegroup :: String
999
tagNodegroup = Types.tagKindToRaw TagKindGroup
1000

    
1001
validTagTypes :: FrozenSet String
1002
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1003

    
1004
maxTagLen :: Int
1005
maxTagLen = 128
1006

    
1007
maxTagsPerObj :: Int
1008
maxTagsPerObj = 4096
1009

    
1010
-- * Reboot types
1011

    
1012
instanceRebootSoft :: String
1013
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1014

    
1015
instanceRebootHard :: String
1016
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1017

    
1018
instanceRebootFull :: String
1019
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1020

    
1021
rebootTypes :: FrozenSet String
1022
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1023

    
1024
-- * Possible values for NodeGroup.alloc_policy
1025

    
1026
allocPolicyLastResort :: String
1027
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
1028

    
1029
allocPolicyPreferred :: String
1030
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
1031

    
1032
allocPolicyUnallocable :: String
1033
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
1034

    
1035
validAllocPolicies :: [String]
1036
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
1037

    
1038
-- | Temporary external/shared storage parameters
1039
blockdevDriverManual :: String
1040
blockdevDriverManual = "manual"
1041

    
1042
-- | Path generating random UUID
1043
randomUuidFile :: String
1044
randomUuidFile = ConstantUtils.randomUuidFile
1045

    
1046
-- * Auto-repair tag prefixes
1047

    
1048
autoRepairTagPrefix :: String
1049
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
1050

    
1051
autoRepairTagEnabled :: String
1052
autoRepairTagEnabled = autoRepairTagPrefix
1053

    
1054
autoRepairTagPending :: String
1055
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
1056

    
1057
autoRepairTagResult :: String
1058
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
1059

    
1060
autoRepairTagSuspended :: String
1061
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
1062

    
1063
-- * Auto-repair levels
1064

    
1065
autoRepairFailover :: String
1066
autoRepairFailover = "failover"
1067

    
1068
autoRepairFixStorage :: String
1069
autoRepairFixStorage = "fix-storage"
1070

    
1071
autoRepairMigrate :: String
1072
autoRepairMigrate = "migrate"
1073

    
1074
autoRepairReinstall :: String
1075
autoRepairReinstall = "reinstall"
1076

    
1077
autoRepairAllTypes :: FrozenSet String
1078
autoRepairAllTypes =
1079
  ConstantUtils.mkSet [autoRepairFailover,
1080
                       autoRepairFixStorage,
1081
                       autoRepairMigrate,
1082
                       autoRepairReinstall]
1083

    
1084
-- * Auto-repair results
1085

    
1086
autoRepairEnoperm :: String
1087
autoRepairEnoperm = "enoperm"
1088

    
1089
autoRepairFailure :: String
1090
autoRepairFailure = "failure"
1091

    
1092
autoRepairSuccess :: String
1093
autoRepairSuccess = "success"
1094

    
1095
autoRepairAllResults :: FrozenSet String
1096
autoRepairAllResults =
1097
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
1098

    
1099
-- | The version identifier for builtin data collectors
1100
builtinDataCollectorVersion :: String
1101
builtinDataCollectorVersion = "B"