Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ a25fdde9

History | View | Annotate | Download (27.1 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
-- * OOB supported commands
54

    
55
oobPowerOn :: String
56
oobPowerOn = Types.oobCommandToRaw OobPowerOn
57

    
58
oobPowerOff :: String
59
oobPowerOff = Types.oobCommandToRaw OobPowerOff
60

    
61
oobPowerCycle :: String
62
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
63

    
64
oobPowerStatus :: String
65
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
66

    
67
oobHealth :: String
68
oobHealth = Types.oobCommandToRaw OobHealth
69

    
70
oobCommands :: FrozenSet String
71
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
72

    
73
oobPowerStatusPowered :: String
74
oobPowerStatusPowered = "powered"
75

    
76
-- | 60 seconds
77
oobTimeout :: Int
78
oobTimeout = 60
79

    
80
-- | 2 seconds
81
oobPowerDelay :: Double
82
oobPowerDelay = 2.0
83

    
84
oobStatusCritical :: String
85
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
86

    
87
oobStatusOk :: String
88
oobStatusOk = Types.oobStatusToRaw OobStatusOk
89

    
90
oobStatusUnknown :: String
91
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
92

    
93
oobStatusWarning :: String
94
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
95

    
96
oobStatuses :: FrozenSet String
97
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
98

    
99
-- * NIC_* constants are used inside the ganeti config
100

    
101
nicLink :: String
102
nicLink = "link"
103

    
104
nicMode :: String
105
nicMode = "mode"
106

    
107
nicVlan :: String
108
nicVlan = "vlan"
109

    
110
nicModeBridged :: String
111
nicModeBridged = Types.nICModeToRaw NMBridged
112

    
113
nicModeRouted :: String
114
nicModeRouted = Types.nICModeToRaw NMRouted
115

    
116
nicModeOvs :: String
117
nicModeOvs = Types.nICModeToRaw NMOvs
118

    
119
nicIpPool :: String
120
nicIpPool = Types.nICModeToRaw NMPool
121

    
122
nicValidModes :: FrozenSet String
123
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
124

    
125
-- * Hypervisor constants
126

    
127
htXenPvm :: String
128
htXenPvm = Types.hypervisorToRaw XenPvm
129

    
130
htFake :: String
131
htFake = Types.hypervisorToRaw Fake
132

    
133
htXenHvm :: String
134
htXenHvm = Types.hypervisorToRaw XenHvm
135

    
136
htKvm :: String
137
htKvm = Types.hypervisorToRaw Kvm
138

    
139
htChroot :: String
140
htChroot = Types.hypervisorToRaw Chroot
141

    
142
htLxc :: String
143
htLxc = Types.hypervisorToRaw Lxc
144

    
145
hyperTypes :: FrozenSet String
146
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
147

    
148
htsReqPort :: FrozenSet String
149
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
150

    
151
-- * Migration type
152

    
153
htMigrationLive :: String
154
htMigrationLive = Types.migrationModeToRaw MigrationLive
155

    
156
htMigrationNonlive :: String
157
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
158

    
159
htMigrationModes :: FrozenSet String
160
htMigrationModes =
161
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
162

    
163
-- * Cluster verify steps
164

    
165
verifyNplusoneMem :: String
166
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
167

    
168
verifyOptionalChecks :: FrozenSet String
169
verifyOptionalChecks =
170
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
171

    
172
-- * Cluster Verify error classes
173

    
174
cvTcluster :: String
175
cvTcluster = "cluster"
176

    
177
cvTgroup :: String
178
cvTgroup = "group"
179

    
180
cvTnode :: String
181
cvTnode = "node"
182

    
183
cvTinstance :: String
184
cvTinstance = "instance"
185

    
186
-- * Cluster Verify error codes and documentation
187

    
188
cvEclustercert :: (String, String, String)
189
cvEclustercert =
190
  ("cluster",
191
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
192
   "Cluster certificate files verification failure")
193

    
194
cvEclustercfg :: (String, String, String)
195
cvEclustercfg =
196
  ("cluster",
197
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
198
   "Cluster configuration verification failure")
199

    
200
cvEclusterdanglinginst :: (String, String, String)
201
cvEclusterdanglinginst =
202
  ("node",
203
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
204
   "Some instances have a non-existing primary node")
205

    
206
cvEclusterdanglingnodes :: (String, String, String)
207
cvEclusterdanglingnodes =
208
  ("node",
209
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
210
   "Some nodes belong to non-existing groups")
211

    
212
cvEclusterfilecheck :: (String, String, String)
213
cvEclusterfilecheck =
214
  ("cluster",
215
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
216
   "Cluster configuration verification failure")
217

    
218
cvEgroupdifferentpvsize :: (String, String, String)
219
cvEgroupdifferentpvsize =
220
  ("group",
221
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
222
   "PVs in the group have different sizes")
223

    
224
cvEinstancebadnode :: (String, String, String)
225
cvEinstancebadnode =
226
  ("instance",
227
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
228
   "Instance marked as running lives on an offline node")
229

    
230
cvEinstancedown :: (String, String, String)
231
cvEinstancedown =
232
  ("instance",
233
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
234
   "Instance not running on its primary node")
235

    
236
cvEinstancefaultydisk :: (String, String, String)
237
cvEinstancefaultydisk =
238
  ("instance",
239
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
240
   "Impossible to retrieve status for a disk")
241

    
242
cvEinstancelayout :: (String, String, String)
243
cvEinstancelayout =
244
  ("instance",
245
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
246
   "Instance has multiple secondary nodes")
247

    
248
cvEinstancemissingcfgparameter :: (String, String, String)
249
cvEinstancemissingcfgparameter =
250
  ("instance",
251
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
252
   "A configuration parameter for an instance is missing")
253

    
254
cvEinstancemissingdisk :: (String, String, String)
255
cvEinstancemissingdisk =
256
  ("instance",
257
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
258
   "Missing volume on an instance")
259

    
260
cvEinstancepolicy :: (String, String, String)
261
cvEinstancepolicy =
262
  ("instance",
263
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
264
   "Instance does not meet policy")
265

    
266
cvEinstancesplitgroups :: (String, String, String)
267
cvEinstancesplitgroups =
268
  ("instance",
269
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
270
   "Instance with primary and secondary nodes in different groups")
271

    
272
cvEinstanceunsuitablenode :: (String, String, String)
273
cvEinstanceunsuitablenode =
274
  ("instance",
275
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
276
   "Instance running on nodes that are not suitable for it")
277

    
278
cvEinstancewrongnode :: (String, String, String)
279
cvEinstancewrongnode =
280
  ("instance",
281
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
282
   "Instance running on the wrong node")
283

    
284
cvEnodedrbd :: (String, String, String)
285
cvEnodedrbd =
286
  ("node",
287
   Types.cVErrorCodeToRaw CvENODEDRBD,
288
   "Error parsing the DRBD status file")
289

    
290
cvEnodedrbdhelper :: (String, String, String)
291
cvEnodedrbdhelper =
292
  ("node",
293
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
294
   "Error caused by the DRBD helper")
295

    
296
cvEnodedrbdversion :: (String, String, String)
297
cvEnodedrbdversion =
298
  ("node",
299
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
300
   "DRBD version mismatch within a node group")
301

    
302
cvEnodefilecheck :: (String, String, String)
303
cvEnodefilecheck =
304
  ("node",
305
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
306
   "Error retrieving the checksum of the node files")
307

    
308
cvEnodefilestoragepaths :: (String, String, String)
309
cvEnodefilestoragepaths =
310
  ("node",
311
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
312
   "Detected bad file storage paths")
313

    
314
cvEnodefilestoragepathunusable :: (String, String, String)
315
cvEnodefilestoragepathunusable =
316
  ("node",
317
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
318
   "File storage path unusable")
319

    
320
cvEnodehooks :: (String, String, String)
321
cvEnodehooks =
322
  ("node",
323
   Types.cVErrorCodeToRaw CvENODEHOOKS,
324
   "Communication failure in hooks execution")
325

    
326
cvEnodehv :: (String, String, String)
327
cvEnodehv =
328
  ("node",
329
   Types.cVErrorCodeToRaw CvENODEHV,
330
   "Hypervisor parameters verification failure")
331

    
332
cvEnodelvm :: (String, String, String)
333
cvEnodelvm =
334
  ("node",
335
   Types.cVErrorCodeToRaw CvENODELVM,
336
   "LVM-related node error")
337

    
338
cvEnoden1 :: (String, String, String)
339
cvEnoden1 =
340
  ("node",
341
   Types.cVErrorCodeToRaw CvENODEN1,
342
   "Not enough memory to accommodate instance failovers")
343

    
344
cvEnodenet :: (String, String, String)
345
cvEnodenet =
346
  ("node",
347
   Types.cVErrorCodeToRaw CvENODENET,
348
   "Network-related node error")
349

    
350
cvEnodeoobpath :: (String, String, String)
351
cvEnodeoobpath =
352
  ("node",
353
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
354
   "Invalid Out Of Band path")
355

    
356
cvEnodeorphaninstance :: (String, String, String)
357
cvEnodeorphaninstance =
358
  ("node",
359
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
360
   "Unknown intance running on a node")
361

    
362
cvEnodeorphanlv :: (String, String, String)
363
cvEnodeorphanlv =
364
  ("node",
365
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
366
   "Unknown LVM logical volume")
367

    
368
cvEnodeos :: (String, String, String)
369
cvEnodeos =
370
  ("node",
371
   Types.cVErrorCodeToRaw CvENODEOS,
372
   "OS-related node error")
373

    
374
cvEnoderpc :: (String, String, String)
375
cvEnoderpc =
376
  ("node",
377
   Types.cVErrorCodeToRaw CvENODERPC,
378
   "Error during connection to the primary node of an instance")
379

    
380
cvEnodesetup :: (String, String, String)
381
cvEnodesetup =
382
  ("node",
383
   Types.cVErrorCodeToRaw CvENODESETUP,
384
   "Node setup error")
385

    
386
cvEnodesharedfilestoragepathunusable :: (String, String, String)
387
cvEnodesharedfilestoragepathunusable =
388
  ("node",
389
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
390
   "Shared file storage path unusable")
391

    
392
cvEnodessh :: (String, String, String)
393
cvEnodessh =
394
  ("node",
395
   Types.cVErrorCodeToRaw CvENODESSH,
396
   "SSH-related node error")
397

    
398
cvEnodetime :: (String, String, String)
399
cvEnodetime =
400
  ("node",
401
   Types.cVErrorCodeToRaw CvENODETIME,
402
   "Node returned invalid time")
403

    
404
cvEnodeuserscripts :: (String, String, String)
405
cvEnodeuserscripts =
406
  ("node",
407
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
408
   "User scripts not present or not executable")
409

    
410
cvEnodeversion :: (String, String, String)
411
cvEnodeversion =
412
  ("node",
413
   Types.cVErrorCodeToRaw CvENODEVERSION,
414
   "Protocol version mismatch or Ganeti version mismatch")
415

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

    
458
cvAllEcodesStrings :: FrozenSet String
459
cvAllEcodesStrings =
460
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
461

    
462
-- * Instance status
463

    
464
inststAdmindown :: String
465
inststAdmindown = Types.instanceStatusToRaw StatusDown
466

    
467
inststAdminoffline :: String
468
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
469

    
470
inststErrordown :: String
471
inststErrordown = Types.instanceStatusToRaw ErrorDown
472

    
473
inststErrorup :: String
474
inststErrorup = Types.instanceStatusToRaw ErrorUp
475

    
476
inststNodedown :: String
477
inststNodedown = Types.instanceStatusToRaw NodeDown
478

    
479
inststNodeoffline :: String
480
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
481

    
482
inststRunning :: String
483
inststRunning = Types.instanceStatusToRaw Running
484

    
485
inststWrongnode :: String
486
inststWrongnode = Types.instanceStatusToRaw WrongNode
487

    
488
inststAll :: FrozenSet String
489
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
490

    
491
-- * Admin states
492

    
493
adminstDown :: String
494
adminstDown = "down"
495

    
496
adminstOffline :: String
497
adminstOffline = "offline"
498

    
499
adminstUp :: String
500
adminstUp = "up"
501

    
502
adminstAll :: FrozenSet String
503
adminstAll = ConstantUtils.mkSet [adminstDown, adminstOffline, adminstUp]
504

    
505
-- * Allocator framework constants
506

    
507
iallocatorVersion :: Int
508
iallocatorVersion = 2
509

    
510
iallocatorDirIn :: String
511
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
512

    
513
iallocatorDirOut :: String
514
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
515

    
516
validIallocatorDirections :: FrozenSet String
517
validIallocatorDirections =
518
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
519

    
520
iallocatorModeAlloc :: String
521
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
522

    
523
iallocatorModeChgGroup :: String
524
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
525

    
526
iallocatorModeMultiAlloc :: String
527
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
528

    
529
iallocatorModeNodeEvac :: String
530
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
531

    
532
iallocatorModeReloc :: String
533
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
534

    
535
validIallocatorModes :: FrozenSet String
536
validIallocatorModes =
537
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
538

    
539
iallocatorSearchPath :: [String]
540
iallocatorSearchPath = AutoConf.iallocatorSearchPath
541

    
542
defaultIallocatorShortcut :: String
543
defaultIallocatorShortcut = "."
544

    
545
iallocatorNevacPri :: String
546
iallocatorNevacPri = Types.nodeEvacModeToRaw NEvacPrimary
547

    
548
iallocatorNevacSec :: String
549
iallocatorNevacSec = Types.nodeEvacModeToRaw NEvacSecondary
550

    
551
iallocatorNevacAll :: String
552
iallocatorNevacAll = Types.nodeEvacModeToRaw NEvacAll
553

    
554
iallocatorNevacModes :: FrozenSet String
555
iallocatorNevacModes =
556
  ConstantUtils.mkSet $ map Types.nodeEvacModeToRaw [minBound..]
557

    
558
-- * Node evacuation
559

    
560
nodeEvacPri :: String
561
nodeEvacPri = Types.nodeEvacModeToRaw NEvacPrimary
562

    
563
nodeEvacSec :: String
564
nodeEvacSec = Types.nodeEvacModeToRaw NEvacSecondary
565

    
566
nodeEvacAll :: String
567
nodeEvacAll = Types.nodeEvacModeToRaw NEvacAll
568

    
569
nodeEvacModes :: FrozenSet String
570
nodeEvacModes = ConstantUtils.mkSet $ map Types.nodeEvacModeToRaw [minBound..]
571

    
572
-- * Job status
573

    
574
jobStatusQueued :: String
575
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
576

    
577
jobStatusWaiting :: String
578
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
579

    
580
jobStatusCanceling :: String
581
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
582

    
583
jobStatusRunning :: String
584
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
585

    
586
jobStatusCanceled :: String
587
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
588

    
589
jobStatusSuccess :: String
590
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
591

    
592
jobStatusError :: String
593
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
594

    
595
jobsPending :: FrozenSet String
596
jobsPending =
597
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
598

    
599
jobsFinalized :: FrozenSet String
600
jobsFinalized =
601
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
602

    
603
jobStatusAll :: FrozenSet String
604
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
605

    
606
-- * OpCode status
607

    
608
-- ** Not yet finalized opcodes
609

    
610
opStatusCanceling :: String
611
opStatusCanceling = "canceling"
612

    
613
opStatusQueued :: String
614
opStatusQueued = "queued"
615

    
616
opStatusRunning :: String
617
opStatusRunning = "running"
618

    
619
opStatusWaiting :: String
620
opStatusWaiting = "waiting"
621

    
622
-- ** Finalized opcodes
623

    
624
opStatusCanceled :: String
625
opStatusCanceled = "canceled"
626

    
627
opStatusError :: String
628
opStatusError = "error"
629

    
630
opStatusSuccess :: String
631
opStatusSuccess = "success"
632

    
633
opsFinalized :: FrozenSet String
634
opsFinalized =
635
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
636

    
637
-- * OpCode priority
638

    
639
opPrioLowest :: Int
640
opPrioLowest = 19
641

    
642
opPrioHighest :: Int
643
opPrioHighest = -20
644

    
645
opPrioLow :: Int
646
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
647

    
648
opPrioNormal :: Int
649
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
650

    
651
opPrioHigh :: Int
652
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
653

    
654
opPrioSubmitValid :: FrozenSet Int
655
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
656

    
657
opPrioDefault :: Int
658
opPrioDefault = opPrioNormal
659

    
660
-- * Execution log types
661

    
662
elogMessage :: String
663
elogMessage = Types.eLogTypeToRaw ELogMessage
664

    
665
elogRemoteImport :: String
666
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
667

    
668
elogJqueueTest :: String
669
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
670

    
671
-- * User separation
672

    
673
daemonsGroup :: String
674
daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
675

    
676
adminGroup :: String
677
adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
678

    
679
masterdUser :: String
680
masterdUser = Runtime.daemonUser GanetiMasterd
681

    
682
masterdGroup :: String
683
masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
684

    
685
rapiUser :: String
686
rapiUser = Runtime.daemonUser GanetiRapi
687

    
688
rapiGroup :: String
689
rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
690

    
691
confdUser :: String
692
confdUser = Runtime.daemonUser GanetiConfd
693

    
694
confdGroup :: String
695
confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
696

    
697
luxidUser :: String
698
luxidUser = Runtime.daemonUser GanetiLuxid
699

    
700
luxidGroup :: String
701
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
702

    
703
nodedUser :: String
704
nodedUser = Runtime.daemonUser GanetiNoded
705

    
706
nodedGroup :: String
707
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
708

    
709
mondUser :: String
710
mondUser = Runtime.daemonUser GanetiMond
711

    
712
mondGroup :: String
713
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
714

    
715
sshLoginUser :: String
716
sshLoginUser = AutoConf.sshLoginUser
717

    
718
sshConsoleUser :: String
719
sshConsoleUser = AutoConf.sshConsoleUser
720

    
721
-- * SSH constants
722

    
723
ssh :: String
724
ssh = "ssh"
725

    
726
scp :: String
727
scp = "scp"
728

    
729
-- * Daemons
730

    
731
confd :: String
732
confd = Runtime.daemonName GanetiConfd
733

    
734
masterd :: String
735
masterd = Runtime.daemonName GanetiMasterd
736

    
737
mond :: String
738
mond = Runtime.daemonName GanetiMond
739

    
740
noded :: String
741
noded = Runtime.daemonName GanetiNoded
742

    
743
luxid :: String
744
luxid = Runtime.daemonName GanetiLuxid
745

    
746
rapi :: String
747
rapi = Runtime.daemonName GanetiRapi
748

    
749
daemons :: FrozenSet String
750
daemons =
751
  ConstantUtils.mkSet [confd,
752
                       luxid,
753
                       masterd,
754
                       mond,
755
                       noded,
756
                       rapi]
757

    
758
defaultConfdPort :: Int
759
defaultConfdPort = 1814
760

    
761
defaultMondPort :: Int
762
defaultMondPort = 1815
763

    
764
defaultNodedPort :: Int
765
defaultNodedPort = 1811
766

    
767
defaultRapiPort :: Int
768
defaultRapiPort = 5080
769

    
770
daemonsPorts :: Map String (Protocol, Int)
771
daemonsPorts =
772
  Map.fromList [(confd, (Udp, defaultConfdPort)),
773
                (mond, (Tcp, defaultMondPort)),
774
                (noded, (Tcp, defaultNodedPort)),
775
                (rapi, (Tcp, defaultRapiPort)),
776
                (ssh, (Tcp, 22))]
777

    
778
daemonsLogbase :: Map String String
779
daemonsLogbase =
780
  Map.fromList
781
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
782

    
783
extraLogreasonAccess :: String
784
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
785

    
786
extraLogreasonError :: String
787
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
788

    
789
devConsole :: String
790
devConsole = ConstantUtils.devConsole
791

    
792
-- * Syslog
793

    
794
syslogUsage :: String
795
syslogUsage = AutoConf.syslogUsage
796

    
797
syslogNo :: String
798
syslogNo = Logging.syslogUsageToRaw SyslogNo
799

    
800
syslogYes :: String
801
syslogYes = Logging.syslogUsageToRaw SyslogYes
802

    
803
syslogOnly :: String
804
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
805

    
806
syslogSocket :: String
807
syslogSocket = "/dev/log"
808

    
809
-- * Xen
810

    
811
xenBootloader :: String
812
xenBootloader = AutoConf.xenBootloader
813

    
814
xenCmdXl :: String
815
xenCmdXl = "xl"
816

    
817
xenCmdXm :: String
818
xenCmdXm = "xm"
819

    
820
xenInitrd :: String
821
xenInitrd = AutoConf.xenInitrd
822

    
823
xenKernel :: String
824
xenKernel = AutoConf.xenKernel
825

    
826
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
827
-- other constants
828
knownXenCommands :: FrozenSet String
829
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
830

    
831
-- * Storage types
832

    
833
stBlock :: String
834
stBlock = Types.storageTypeToRaw StorageBlock
835

    
836
stDiskless :: String
837
stDiskless = Types.storageTypeToRaw StorageDiskless
838

    
839
stExt :: String
840
stExt = Types.storageTypeToRaw StorageExt
841

    
842
stFile :: String
843
stFile = Types.storageTypeToRaw StorageFile
844

    
845
stLvmPv :: String
846
stLvmPv = Types.storageTypeToRaw StorageLvmPv
847

    
848
stLvmVg :: String
849
stLvmVg = Types.storageTypeToRaw StorageLvmVg
850

    
851
stRados :: String
852
stRados = Types.storageTypeToRaw StorageRados
853

    
854
storageTypes :: FrozenSet String
855
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
856

    
857
-- * Disk template types
858

    
859
dtDiskless :: String
860
dtDiskless = Types.diskTemplateToRaw DTDiskless
861

    
862
dtFile :: String
863
dtFile = Types.diskTemplateToRaw DTFile
864

    
865
dtSharedFile :: String
866
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
867

    
868
dtPlain :: String
869
dtPlain = Types.diskTemplateToRaw DTPlain
870

    
871
dtBlock :: String
872
dtBlock = Types.diskTemplateToRaw DTBlock
873

    
874
dtDrbd8 :: String
875
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
876

    
877
dtRbd :: String
878
dtRbd = Types.diskTemplateToRaw DTRbd
879

    
880
dtExt :: String
881
dtExt = Types.diskTemplateToRaw DTExt
882

    
883
-- | This is used to order determine the default disk template when
884
-- the list of enabled disk templates is inferred from the current
885
-- state of the cluster.  This only happens on an upgrade from a
886
-- version of Ganeti that did not support the 'enabled_disk_templates'
887
-- so far.
888
diskTemplatePreference :: [String]
889
diskTemplatePreference =
890
  map Types.diskTemplateToRaw
891
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile, DTPlain, DTRbd, DTSharedFile]
892

    
893
diskTemplates :: FrozenSet String
894
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
895

    
896
-- | Disk templates that are enabled by default
897
defaultEnabledDiskTemplates :: [String]
898
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
899

    
900
-- * File backend driver
901

    
902
fdBlktap :: String
903
fdBlktap = Types.fileDriverToRaw FileBlktap
904

    
905
fdLoop :: String
906
fdLoop = Types.fileDriverToRaw FileLoop
907

    
908
-- * Instance export mode
909

    
910
exportModeLocal :: String
911
exportModeLocal = Types.exportModeToRaw ExportModeLocal
912

    
913
exportModeRemote :: String
914
exportModeRemote = Types.exportModeToRaw ExportModeRemote
915

    
916
exportModes :: FrozenSet String
917
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
918

    
919
-- * Instance creation modes
920

    
921
instanceCreate :: String
922
instanceCreate = Types.instCreateModeToRaw InstCreate
923

    
924
instanceImport :: String
925
instanceImport = Types.instCreateModeToRaw InstImport
926

    
927
instanceRemoteImport :: String
928
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
929

    
930
instanceCreateModes :: FrozenSet String
931
instanceCreateModes =
932
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
933

    
934
-- * Dynamic device modification
935

    
936
ddmAdd :: String
937
ddmAdd = Types.ddmFullToRaw DdmFullAdd
938

    
939
ddmModify :: String
940
ddmModify = Types.ddmFullToRaw DdmFullModify
941

    
942
ddmRemove :: String
943
ddmRemove = Types.ddmFullToRaw DdmFullRemove
944

    
945
ddmsValues :: FrozenSet String
946
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
947

    
948
ddmsValuesWithModify :: FrozenSet String
949
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
950

    
951
-- * Common exit codes
952

    
953
exitSuccess :: Int
954
exitSuccess = 0
955

    
956
exitFailure :: Int
957
exitFailure = ConstantUtils.exitFailure
958

    
959
exitNotcluster :: Int
960
exitNotcluster = 5
961

    
962
exitNotmaster :: Int
963
exitNotmaster = 11
964

    
965
exitNodesetupError :: Int
966
exitNodesetupError = 12
967

    
968
-- | Need user confirmation
969
exitConfirmation :: Int
970
exitConfirmation = 13
971

    
972
-- | Exit code for query operations with unknown fields
973
exitUnknownField :: Int
974
exitUnknownField = 14
975

    
976
-- * Tags
977

    
978
tagCluster :: String
979
tagCluster = Types.tagKindToRaw TagKindCluster
980

    
981
tagInstance :: String
982
tagInstance = Types.tagKindToRaw TagKindInstance
983

    
984
tagNetwork :: String
985
tagNetwork = Types.tagKindToRaw TagKindNetwork
986

    
987
tagNode :: String
988
tagNode = Types.tagKindToRaw TagKindNode
989

    
990
tagNodegroup :: String
991
tagNodegroup = Types.tagKindToRaw TagKindGroup
992

    
993
validTagTypes :: FrozenSet String
994
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
995

    
996
maxTagLen :: Int
997
maxTagLen = 128
998

    
999
maxTagsPerObj :: Int
1000
maxTagsPerObj = 4096
1001

    
1002
-- * Reboot types
1003

    
1004
instanceRebootSoft :: String
1005
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1006

    
1007
instanceRebootHard :: String
1008
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1009

    
1010
instanceRebootFull :: String
1011
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1012

    
1013
rebootTypes :: FrozenSet String
1014
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1015

    
1016
-- * Possible values for NodeGroup.alloc_policy
1017

    
1018
allocPolicyLastResort :: String
1019
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
1020

    
1021
allocPolicyPreferred :: String
1022
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
1023

    
1024
allocPolicyUnallocable :: String
1025
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
1026

    
1027
validAllocPolicies :: [String]
1028
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
1029

    
1030
-- | Temporary external/shared storage parameters
1031
blockdevDriverManual :: String
1032
blockdevDriverManual = "manual"
1033

    
1034
-- | Path generating random UUID
1035
randomUuidFile :: String
1036
randomUuidFile = ConstantUtils.randomUuidFile
1037

    
1038
-- * Auto-repair tag prefixes
1039

    
1040
autoRepairTagPrefix :: String
1041
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
1042

    
1043
autoRepairTagEnabled :: String
1044
autoRepairTagEnabled = autoRepairTagPrefix
1045

    
1046
autoRepairTagPending :: String
1047
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
1048

    
1049
autoRepairTagResult :: String
1050
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
1051

    
1052
autoRepairTagSuspended :: String
1053
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
1054

    
1055
-- * Auto-repair levels
1056

    
1057
autoRepairFailover :: String
1058
autoRepairFailover = "failover"
1059

    
1060
autoRepairFixStorage :: String
1061
autoRepairFixStorage = "fix-storage"
1062

    
1063
autoRepairMigrate :: String
1064
autoRepairMigrate = "migrate"
1065

    
1066
autoRepairReinstall :: String
1067
autoRepairReinstall = "reinstall"
1068

    
1069
autoRepairAllTypes :: FrozenSet String
1070
autoRepairAllTypes =
1071
  ConstantUtils.mkSet [autoRepairFailover,
1072
                       autoRepairFixStorage,
1073
                       autoRepairMigrate,
1074
                       autoRepairReinstall]
1075

    
1076
-- * Auto-repair results
1077

    
1078
autoRepairEnoperm :: String
1079
autoRepairEnoperm = "enoperm"
1080

    
1081
autoRepairFailure :: String
1082
autoRepairFailure = "failure"
1083

    
1084
autoRepairSuccess :: String
1085
autoRepairSuccess = "success"
1086

    
1087
autoRepairAllResults :: FrozenSet String
1088
autoRepairAllResults =
1089
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
1090

    
1091
-- | The version identifier for builtin data collectors
1092
builtinDataCollectorVersion :: String
1093
builtinDataCollectorVersion = "B"