Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ c87997d2

History | View | Annotate | Download (38.4 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.List ((\\))
40
import Data.Map (Map)
41
import qualified Data.Map as Map (fromList)
42

    
43
import AutoConf
44
import Ganeti.ConstantUtils (FrozenSet, Protocol(..), buildVersion)
45
import qualified Ganeti.ConstantUtils as ConstantUtils
46
import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..),
47
                       ExtraLogReason(..))
48
import Ganeti.Logging (SyslogUsage(..))
49
import qualified Ganeti.Logging as Logging (syslogUsageToRaw)
50
import qualified Ganeti.Runtime as Runtime
51
import Ganeti.Types
52
import qualified Ganeti.Types as Types
53
import Ganeti.Confd.Types (ConfdRequestType(..), ConfdReqField(..),
54
                           ConfdReplyStatus(..), ConfdNodeRole(..),
55
                           ConfdErrorType(..))
56
import qualified Ganeti.Confd.Types as Types
57

    
58
-- * 'autoconf' constants for Python only ('autotools/build-bash-completion')
59

    
60
htoolsProgs :: [String]
61
htoolsProgs = AutoConf.htoolsProgs
62

    
63
-- * 'autoconf' constants for Python only ('lib/constants.py')
64

    
65
drbdBarriers :: String
66
drbdBarriers = AutoConf.drbdBarriers
67

    
68
drbdNoMetaFlush :: Bool
69
drbdNoMetaFlush = AutoConf.drbdNoMetaFlush
70

    
71
lvmStripecount :: Int
72
lvmStripecount = AutoConf.lvmStripecount
73

    
74
-- * 'autoconf' constants for Python only ('lib/pathutils.py')
75

    
76
-- ** Build-time constants
77

    
78
exportDir :: String
79
exportDir = AutoConf.exportDir
80

    
81
osSearchPath :: [String]
82
osSearchPath = AutoConf.osSearchPath
83

    
84
esSearchPath :: [String]
85
esSearchPath = AutoConf.esSearchPath
86

    
87
sshConfigDir :: String
88
sshConfigDir = AutoConf.sshConfigDir
89

    
90
xenConfigDir :: String
91
xenConfigDir = AutoConf.xenConfigDir
92

    
93
sysconfdir :: String
94
sysconfdir = AutoConf.sysconfdir
95

    
96
toolsdir :: String
97
toolsdir = AutoConf.toolsdir
98

    
99
localstatedir :: String
100
localstatedir = AutoConf.localstatedir
101

    
102
-- ** Paths which don't change for a virtual cluster
103

    
104
pkglibdir :: String
105
pkglibdir = AutoConf.pkglibdir
106

    
107
sharedir :: String
108
sharedir = AutoConf.sharedir
109

    
110
-- * 'autoconf' constants for Python only ('lib/build/sphinx_ext.py')
111

    
112
manPages :: Map String Int
113
manPages = Map.fromList AutoConf.manPages
114

    
115
-- * 'autoconf' constants for QA cluster only ('qa/qa_cluster.py')
116

    
117
versionedsharedir :: String
118
versionedsharedir = AutoConf.versionedsharedir
119

    
120
-- * 'autoconf' constants for Python only ('tests/py/docs_unittest.py')
121

    
122
gntScripts :: [String]
123
gntScripts = AutoConf.gntScripts
124

    
125
-- * Various versions
126

    
127
releaseVersion :: String
128
releaseVersion = AutoConf.packageVersion
129

    
130
versionMajor :: Int
131
versionMajor = AutoConf.versionMajor
132

    
133
versionMinor :: Int
134
versionMinor = AutoConf.versionMinor
135

    
136
versionRevision :: Int
137
versionRevision = AutoConf.versionRevision
138

    
139
dirVersion :: String
140
dirVersion = AutoConf.dirVersion
141

    
142
osApiV10 :: Int
143
osApiV10 = 10
144

    
145
osApiV15 :: Int
146
osApiV15 = 15
147

    
148
osApiV20 :: Int
149
osApiV20 = 20
150

    
151
osApiVersions :: FrozenSet Int
152
osApiVersions = ConstantUtils.mkSet [osApiV10, osApiV15, osApiV20]
153

    
154
configMajor :: Int
155
configMajor = AutoConf.versionMajor
156

    
157
configMinor :: Int
158
configMinor = AutoConf.versionMinor
159

    
160
-- | The configuration is supposed to remain stable across
161
-- revisions. Therefore, the revision number is cleared to '0'.
162
configRevision :: Int
163
configRevision = 0
164

    
165
configVersion :: Int
166
configVersion = buildVersion configMajor configMinor configRevision
167

    
168
-- | Similarly to the configuration (see 'configRevision'), the
169
-- protocols are supposed to remain stable across revisions.
170
protocolVersion :: Int
171
protocolVersion = buildVersion configMajor configMinor configRevision
172

    
173
-- * User separation
174

    
175
daemonsGroup :: String
176
daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
177

    
178
adminGroup :: String
179
adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
180

    
181
masterdUser :: String
182
masterdUser = Runtime.daemonUser GanetiMasterd
183

    
184
masterdGroup :: String
185
masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
186

    
187
rapiUser :: String
188
rapiUser = Runtime.daemonUser GanetiRapi
189

    
190
rapiGroup :: String
191
rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
192

    
193
confdUser :: String
194
confdUser = Runtime.daemonUser GanetiConfd
195

    
196
confdGroup :: String
197
confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
198

    
199
luxidUser :: String
200
luxidUser = Runtime.daemonUser GanetiLuxid
201

    
202
luxidGroup :: String
203
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
204

    
205
nodedUser :: String
206
nodedUser = Runtime.daemonUser GanetiNoded
207

    
208
nodedGroup :: String
209
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
210

    
211
mondUser :: String
212
mondUser = Runtime.daemonUser GanetiMond
213

    
214
mondGroup :: String
215
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
216

    
217
sshLoginUser :: String
218
sshLoginUser = AutoConf.sshLoginUser
219

    
220
sshConsoleUser :: String
221
sshConsoleUser = AutoConf.sshConsoleUser
222

    
223
-- * Wipe
224

    
225
ddCmd :: String
226
ddCmd = "dd"
227

    
228
-- | 1GB
229
maxWipeChunk :: Int
230
maxWipeChunk = 1024
231

    
232
minWipeChunkPercent :: Int
233
minWipeChunkPercent = 10
234

    
235
-- * Directories
236

    
237
runDirsMode :: Int
238
runDirsMode = 0o775
239

    
240
secureDirMode :: Int
241
secureDirMode = 0o700
242

    
243
secureFileMode :: Int
244
secureFileMode = 0o600
245

    
246
adoptableBlockdevRoot :: String
247
adoptableBlockdevRoot = "/dev/disk/"
248

    
249
-- * 'autoconf' enable/disable
250

    
251
enableConfd :: Bool
252
enableConfd = AutoConf.enableConfd
253

    
254
enableMond :: Bool
255
enableMond = AutoConf.enableMond
256

    
257
enableRestrictedCommands :: Bool
258
enableRestrictedCommands = AutoConf.enableRestrictedCommands
259

    
260
enableSplitQuery :: Bool
261
enableSplitQuery = AutoConf.enableSplitQuery
262

    
263
-- * SSH constants
264

    
265
ssh :: String
266
ssh = "ssh"
267

    
268
scp :: String
269
scp = "scp"
270

    
271
-- * Daemons
272

    
273
confd :: String
274
confd = Runtime.daemonName GanetiConfd
275

    
276
masterd :: String
277
masterd = Runtime.daemonName GanetiMasterd
278

    
279
mond :: String
280
mond = Runtime.daemonName GanetiMond
281

    
282
noded :: String
283
noded = Runtime.daemonName GanetiNoded
284

    
285
luxid :: String
286
luxid = Runtime.daemonName GanetiLuxid
287

    
288
rapi :: String
289
rapi = Runtime.daemonName GanetiRapi
290

    
291
daemons :: FrozenSet String
292
daemons =
293
  ConstantUtils.mkSet [confd,
294
                       luxid,
295
                       masterd,
296
                       mond,
297
                       noded,
298
                       rapi]
299

    
300
defaultConfdPort :: Int
301
defaultConfdPort = 1814
302

    
303
defaultMondPort :: Int
304
defaultMondPort = 1815
305

    
306
defaultNodedPort :: Int
307
defaultNodedPort = 1811
308

    
309
defaultRapiPort :: Int
310
defaultRapiPort = 5080
311

    
312
daemonsPorts :: Map String (Protocol, Int)
313
daemonsPorts =
314
  Map.fromList [(confd, (Udp, defaultConfdPort)),
315
                (mond, (Tcp, defaultMondPort)),
316
                (noded, (Tcp, defaultNodedPort)),
317
                (rapi, (Tcp, defaultRapiPort)),
318
                (ssh, (Tcp, 22))]
319

    
320
firstDrbdPort :: Int
321
firstDrbdPort = 11000
322

    
323
lastDrbdPort :: Int
324
lastDrbdPort = 14999
325

    
326
daemonsLogbase :: Map String String
327
daemonsLogbase =
328
  Map.fromList
329
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
330

    
331
extraLogreasonAccess :: String
332
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
333

    
334
extraLogreasonError :: String
335
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
336

    
337
devConsole :: String
338
devConsole = ConstantUtils.devConsole
339

    
340
-- * Syslog
341

    
342
syslogUsage :: String
343
syslogUsage = AutoConf.syslogUsage
344

    
345
syslogNo :: String
346
syslogNo = Logging.syslogUsageToRaw SyslogNo
347

    
348
syslogYes :: String
349
syslogYes = Logging.syslogUsageToRaw SyslogYes
350

    
351
syslogOnly :: String
352
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
353

    
354
syslogSocket :: String
355
syslogSocket = "/dev/log"
356

    
357
-- * Xen
358

    
359
xenBootloader :: String
360
xenBootloader = AutoConf.xenBootloader
361

    
362
xenCmdXl :: String
363
xenCmdXl = "xl"
364

    
365
xenCmdXm :: String
366
xenCmdXm = "xm"
367

    
368
xenInitrd :: String
369
xenInitrd = AutoConf.xenInitrd
370

    
371
xenKernel :: String
372
xenKernel = AutoConf.xenKernel
373

    
374
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
375
-- other constants
376
knownXenCommands :: FrozenSet String
377
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
378

    
379
-- * KVM and socat
380

    
381
kvmPath :: String
382
kvmPath = AutoConf.kvmPath
383

    
384
kvmKernel :: String
385
kvmKernel = AutoConf.kvmKernel
386

    
387
socatEscapeCode :: String
388
socatEscapeCode = "0x1d"
389

    
390
socatPath :: String
391
socatPath = AutoConf.socatPath
392

    
393
socatUseCompress :: Bool
394
socatUseCompress = AutoConf.socatUseCompress
395

    
396
socatUseEscape :: Bool
397
socatUseEscape = AutoConf.socatUseEscape
398

    
399
-- * Storage types
400

    
401
stBlock :: String
402
stBlock = Types.storageTypeToRaw StorageBlock
403

    
404
stDiskless :: String
405
stDiskless = Types.storageTypeToRaw StorageDiskless
406

    
407
stExt :: String
408
stExt = Types.storageTypeToRaw StorageExt
409

    
410
stFile :: String
411
stFile = Types.storageTypeToRaw StorageFile
412

    
413
stLvmPv :: String
414
stLvmPv = Types.storageTypeToRaw StorageLvmPv
415

    
416
stLvmVg :: String
417
stLvmVg = Types.storageTypeToRaw StorageLvmVg
418

    
419
stRados :: String
420
stRados = Types.storageTypeToRaw StorageRados
421

    
422
storageTypes :: FrozenSet String
423
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
424

    
425
-- * Storage fields
426
-- ** First two are valid in LU context only, not passed to backend
427

    
428
sfNode :: String
429
sfNode = "node"
430

    
431
sfType :: String
432
sfType = "type"
433

    
434
-- ** and the rest are valid in backend
435

    
436
sfAllocatable :: String
437
sfAllocatable = Types.storageFieldToRaw SFAllocatable
438

    
439
sfFree :: String
440
sfFree = Types.storageFieldToRaw SFFree
441

    
442
sfName :: String
443
sfName = Types.storageFieldToRaw SFName
444

    
445
sfSize :: String
446
sfSize = Types.storageFieldToRaw SFSize
447

    
448
sfUsed :: String
449
sfUsed = Types.storageFieldToRaw SFUsed
450

    
451
-- * Disk template types
452

    
453
dtDiskless :: String
454
dtDiskless = Types.diskTemplateToRaw DTDiskless
455

    
456
dtFile :: String
457
dtFile = Types.diskTemplateToRaw DTFile
458

    
459
dtSharedFile :: String
460
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
461

    
462
dtPlain :: String
463
dtPlain = Types.diskTemplateToRaw DTPlain
464

    
465
dtBlock :: String
466
dtBlock = Types.diskTemplateToRaw DTBlock
467

    
468
dtDrbd8 :: String
469
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
470

    
471
dtRbd :: String
472
dtRbd = Types.diskTemplateToRaw DTRbd
473

    
474
dtExt :: String
475
dtExt = Types.diskTemplateToRaw DTExt
476

    
477
-- | This is used to order determine the default disk template when
478
-- the list of enabled disk templates is inferred from the current
479
-- state of the cluster.  This only happens on an upgrade from a
480
-- version of Ganeti that did not support the 'enabled_disk_templates'
481
-- so far.
482
diskTemplatePreference :: [String]
483
diskTemplatePreference =
484
  map Types.diskTemplateToRaw
485
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile, DTPlain, DTRbd, DTSharedFile]
486

    
487
diskTemplates :: FrozenSet String
488
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
489

    
490
-- | Disk templates that are enabled by default
491
defaultEnabledDiskTemplates :: [String]
492
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
493

    
494
-- * File backend driver
495

    
496
fdBlktap :: String
497
fdBlktap = Types.fileDriverToRaw FileBlktap
498

    
499
fdLoop :: String
500
fdLoop = Types.fileDriverToRaw FileLoop
501

    
502
-- * Disk access mode
503

    
504
diskRdonly :: String
505
diskRdonly = Types.diskModeToRaw DiskRdOnly
506

    
507
diskRdwr :: String
508
diskRdwr = Types.diskModeToRaw DiskRdWr
509

    
510
diskAccessSet :: FrozenSet String
511
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
512

    
513
-- * Instance export mode
514

    
515
exportModeLocal :: String
516
exportModeLocal = Types.exportModeToRaw ExportModeLocal
517

    
518
exportModeRemote :: String
519
exportModeRemote = Types.exportModeToRaw ExportModeRemote
520

    
521
exportModes :: FrozenSet String
522
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
523

    
524
-- * Instance creation modes
525

    
526
instanceCreate :: String
527
instanceCreate = Types.instCreateModeToRaw InstCreate
528

    
529
instanceImport :: String
530
instanceImport = Types.instCreateModeToRaw InstImport
531

    
532
instanceRemoteImport :: String
533
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
534

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

    
539
-- * Dynamic device modification
540

    
541
ddmAdd :: String
542
ddmAdd = Types.ddmFullToRaw DdmFullAdd
543

    
544
ddmModify :: String
545
ddmModify = Types.ddmFullToRaw DdmFullModify
546

    
547
ddmRemove :: String
548
ddmRemove = Types.ddmFullToRaw DdmFullRemove
549

    
550
ddmsValues :: FrozenSet String
551
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
552

    
553
ddmsValuesWithModify :: FrozenSet String
554
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
555

    
556
-- * Common exit codes
557

    
558
exitSuccess :: Int
559
exitSuccess = 0
560

    
561
exitFailure :: Int
562
exitFailure = ConstantUtils.exitFailure
563

    
564
exitNotcluster :: Int
565
exitNotcluster = 5
566

    
567
exitNotmaster :: Int
568
exitNotmaster = 11
569

    
570
exitNodesetupError :: Int
571
exitNodesetupError = 12
572

    
573
-- | Need user confirmation
574
exitConfirmation :: Int
575
exitConfirmation = 13
576

    
577
-- | Exit code for query operations with unknown fields
578
exitUnknownField :: Int
579
exitUnknownField = 14
580

    
581
-- * Tags
582

    
583
tagCluster :: String
584
tagCluster = Types.tagKindToRaw TagKindCluster
585

    
586
tagInstance :: String
587
tagInstance = Types.tagKindToRaw TagKindInstance
588

    
589
tagNetwork :: String
590
tagNetwork = Types.tagKindToRaw TagKindNetwork
591

    
592
tagNode :: String
593
tagNode = Types.tagKindToRaw TagKindNode
594

    
595
tagNodegroup :: String
596
tagNodegroup = Types.tagKindToRaw TagKindGroup
597

    
598
validTagTypes :: FrozenSet String
599
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
600

    
601
maxTagLen :: Int
602
maxTagLen = 128
603

    
604
maxTagsPerObj :: Int
605
maxTagsPerObj = 4096
606

    
607
-- | Node clock skew in seconds
608
nodeMaxClockSkew :: Int
609
nodeMaxClockSkew = 150
610

    
611
-- | Disk index separator
612
diskSeparator :: String
613
diskSeparator = AutoConf.diskSeparator
614

    
615
ipCommandPath :: String
616
ipCommandPath = AutoConf.ipPath
617

    
618
-- * Reboot types
619

    
620
instanceRebootSoft :: String
621
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
622

    
623
instanceRebootHard :: String
624
instanceRebootHard = Types.rebootTypeToRaw RebootHard
625

    
626
instanceRebootFull :: String
627
instanceRebootFull = Types.rebootTypeToRaw RebootFull
628

    
629
rebootTypes :: FrozenSet String
630
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
631

    
632
-- * VTypes
633

    
634
vtypeBool :: String
635
vtypeBool = Types.vTypeToRaw VTypeBool
636

    
637
vtypeInt :: String
638
vtypeInt = Types.vTypeToRaw VTypeInt
639

    
640
vtypeMaybeString :: String
641
vtypeMaybeString = Types.vTypeToRaw VTypeMaybeString
642

    
643
-- | Size in MiBs
644
vtypeSize :: String
645
vtypeSize = Types.vTypeToRaw VTypeSize
646

    
647
vtypeString :: String
648
vtypeString = Types.vTypeToRaw VTypeString
649

    
650
enforceableTypes :: FrozenSet String
651
enforceableTypes = ConstantUtils.mkSet $ map Types.vTypeToRaw [minBound..]
652

    
653
-- * OOB supported commands
654

    
655
oobPowerOn :: String
656
oobPowerOn = Types.oobCommandToRaw OobPowerOn
657

    
658
oobPowerOff :: String
659
oobPowerOff = Types.oobCommandToRaw OobPowerOff
660

    
661
oobPowerCycle :: String
662
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
663

    
664
oobPowerStatus :: String
665
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
666

    
667
oobHealth :: String
668
oobHealth = Types.oobCommandToRaw OobHealth
669

    
670
oobCommands :: FrozenSet String
671
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
672

    
673
oobPowerStatusPowered :: String
674
oobPowerStatusPowered = "powered"
675

    
676
-- | 60 seconds
677
oobTimeout :: Int
678
oobTimeout = 60
679

    
680
-- | 2 seconds
681
oobPowerDelay :: Double
682
oobPowerDelay = 2.0
683

    
684
oobStatusCritical :: String
685
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
686

    
687
oobStatusOk :: String
688
oobStatusOk = Types.oobStatusToRaw OobStatusOk
689

    
690
oobStatusUnknown :: String
691
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
692

    
693
oobStatusWarning :: String
694
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
695

    
696
oobStatuses :: FrozenSet String
697
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
698

    
699
-- * NIC_* constants are used inside the ganeti config
700

    
701
nicLink :: String
702
nicLink = "link"
703

    
704
nicMode :: String
705
nicMode = "mode"
706

    
707
nicVlan :: String
708
nicVlan = "vlan"
709

    
710
nicModeBridged :: String
711
nicModeBridged = Types.nICModeToRaw NMBridged
712

    
713
nicModeRouted :: String
714
nicModeRouted = Types.nICModeToRaw NMRouted
715

    
716
nicModeOvs :: String
717
nicModeOvs = Types.nICModeToRaw NMOvs
718

    
719
nicIpPool :: String
720
nicIpPool = Types.nICModeToRaw NMPool
721

    
722
nicValidModes :: FrozenSet String
723
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
724

    
725
-- * Hypervisor constants
726

    
727
htXenPvm :: String
728
htXenPvm = Types.hypervisorToRaw XenPvm
729

    
730
htFake :: String
731
htFake = Types.hypervisorToRaw Fake
732

    
733
htXenHvm :: String
734
htXenHvm = Types.hypervisorToRaw XenHvm
735

    
736
htKvm :: String
737
htKvm = Types.hypervisorToRaw Kvm
738

    
739
htChroot :: String
740
htChroot = Types.hypervisorToRaw Chroot
741

    
742
htLxc :: String
743
htLxc = Types.hypervisorToRaw Lxc
744

    
745
hyperTypes :: FrozenSet String
746
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
747

    
748
htsReqPort :: FrozenSet String
749
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
750

    
751
-- * Migration type
752

    
753
htMigrationLive :: String
754
htMigrationLive = Types.migrationModeToRaw MigrationLive
755

    
756
htMigrationNonlive :: String
757
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
758

    
759
htMigrationModes :: FrozenSet String
760
htMigrationModes =
761
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
762

    
763
-- * Cluster verify steps
764

    
765
verifyNplusoneMem :: String
766
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
767

    
768
verifyOptionalChecks :: FrozenSet String
769
verifyOptionalChecks =
770
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
771

    
772
-- * Cluster Verify error classes
773

    
774
cvTcluster :: String
775
cvTcluster = "cluster"
776

    
777
cvTgroup :: String
778
cvTgroup = "group"
779

    
780
cvTnode :: String
781
cvTnode = "node"
782

    
783
cvTinstance :: String
784
cvTinstance = "instance"
785

    
786
-- * Cluster Verify error codes and documentation
787

    
788
cvEclustercert :: (String, String, String)
789
cvEclustercert =
790
  ("cluster",
791
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
792
   "Cluster certificate files verification failure")
793

    
794
cvEclustercfg :: (String, String, String)
795
cvEclustercfg =
796
  ("cluster",
797
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
798
   "Cluster configuration verification failure")
799

    
800
cvEclusterdanglinginst :: (String, String, String)
801
cvEclusterdanglinginst =
802
  ("node",
803
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
804
   "Some instances have a non-existing primary node")
805

    
806
cvEclusterdanglingnodes :: (String, String, String)
807
cvEclusterdanglingnodes =
808
  ("node",
809
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
810
   "Some nodes belong to non-existing groups")
811

    
812
cvEclusterfilecheck :: (String, String, String)
813
cvEclusterfilecheck =
814
  ("cluster",
815
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
816
   "Cluster configuration verification failure")
817

    
818
cvEgroupdifferentpvsize :: (String, String, String)
819
cvEgroupdifferentpvsize =
820
  ("group",
821
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
822
   "PVs in the group have different sizes")
823

    
824
cvEinstancebadnode :: (String, String, String)
825
cvEinstancebadnode =
826
  ("instance",
827
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
828
   "Instance marked as running lives on an offline node")
829

    
830
cvEinstancedown :: (String, String, String)
831
cvEinstancedown =
832
  ("instance",
833
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
834
   "Instance not running on its primary node")
835

    
836
cvEinstancefaultydisk :: (String, String, String)
837
cvEinstancefaultydisk =
838
  ("instance",
839
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
840
   "Impossible to retrieve status for a disk")
841

    
842
cvEinstancelayout :: (String, String, String)
843
cvEinstancelayout =
844
  ("instance",
845
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
846
   "Instance has multiple secondary nodes")
847

    
848
cvEinstancemissingcfgparameter :: (String, String, String)
849
cvEinstancemissingcfgparameter =
850
  ("instance",
851
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
852
   "A configuration parameter for an instance is missing")
853

    
854
cvEinstancemissingdisk :: (String, String, String)
855
cvEinstancemissingdisk =
856
  ("instance",
857
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
858
   "Missing volume on an instance")
859

    
860
cvEinstancepolicy :: (String, String, String)
861
cvEinstancepolicy =
862
  ("instance",
863
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
864
   "Instance does not meet policy")
865

    
866
cvEinstancesplitgroups :: (String, String, String)
867
cvEinstancesplitgroups =
868
  ("instance",
869
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
870
   "Instance with primary and secondary nodes in different groups")
871

    
872
cvEinstanceunsuitablenode :: (String, String, String)
873
cvEinstanceunsuitablenode =
874
  ("instance",
875
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
876
   "Instance running on nodes that are not suitable for it")
877

    
878
cvEinstancewrongnode :: (String, String, String)
879
cvEinstancewrongnode =
880
  ("instance",
881
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
882
   "Instance running on the wrong node")
883

    
884
cvEnodedrbd :: (String, String, String)
885
cvEnodedrbd =
886
  ("node",
887
   Types.cVErrorCodeToRaw CvENODEDRBD,
888
   "Error parsing the DRBD status file")
889

    
890
cvEnodedrbdhelper :: (String, String, String)
891
cvEnodedrbdhelper =
892
  ("node",
893
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
894
   "Error caused by the DRBD helper")
895

    
896
cvEnodedrbdversion :: (String, String, String)
897
cvEnodedrbdversion =
898
  ("node",
899
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
900
   "DRBD version mismatch within a node group")
901

    
902
cvEnodefilecheck :: (String, String, String)
903
cvEnodefilecheck =
904
  ("node",
905
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
906
   "Error retrieving the checksum of the node files")
907

    
908
cvEnodefilestoragepaths :: (String, String, String)
909
cvEnodefilestoragepaths =
910
  ("node",
911
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
912
   "Detected bad file storage paths")
913

    
914
cvEnodefilestoragepathunusable :: (String, String, String)
915
cvEnodefilestoragepathunusable =
916
  ("node",
917
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
918
   "File storage path unusable")
919

    
920
cvEnodehooks :: (String, String, String)
921
cvEnodehooks =
922
  ("node",
923
   Types.cVErrorCodeToRaw CvENODEHOOKS,
924
   "Communication failure in hooks execution")
925

    
926
cvEnodehv :: (String, String, String)
927
cvEnodehv =
928
  ("node",
929
   Types.cVErrorCodeToRaw CvENODEHV,
930
   "Hypervisor parameters verification failure")
931

    
932
cvEnodelvm :: (String, String, String)
933
cvEnodelvm =
934
  ("node",
935
   Types.cVErrorCodeToRaw CvENODELVM,
936
   "LVM-related node error")
937

    
938
cvEnoden1 :: (String, String, String)
939
cvEnoden1 =
940
  ("node",
941
   Types.cVErrorCodeToRaw CvENODEN1,
942
   "Not enough memory to accommodate instance failovers")
943

    
944
cvEnodenet :: (String, String, String)
945
cvEnodenet =
946
  ("node",
947
   Types.cVErrorCodeToRaw CvENODENET,
948
   "Network-related node error")
949

    
950
cvEnodeoobpath :: (String, String, String)
951
cvEnodeoobpath =
952
  ("node",
953
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
954
   "Invalid Out Of Band path")
955

    
956
cvEnodeorphaninstance :: (String, String, String)
957
cvEnodeorphaninstance =
958
  ("node",
959
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
960
   "Unknown intance running on a node")
961

    
962
cvEnodeorphanlv :: (String, String, String)
963
cvEnodeorphanlv =
964
  ("node",
965
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
966
   "Unknown LVM logical volume")
967

    
968
cvEnodeos :: (String, String, String)
969
cvEnodeos =
970
  ("node",
971
   Types.cVErrorCodeToRaw CvENODEOS,
972
   "OS-related node error")
973

    
974
cvEnoderpc :: (String, String, String)
975
cvEnoderpc =
976
  ("node",
977
   Types.cVErrorCodeToRaw CvENODERPC,
978
   "Error during connection to the primary node of an instance")
979

    
980
cvEnodesetup :: (String, String, String)
981
cvEnodesetup =
982
  ("node",
983
   Types.cVErrorCodeToRaw CvENODESETUP,
984
   "Node setup error")
985

    
986
cvEnodesharedfilestoragepathunusable :: (String, String, String)
987
cvEnodesharedfilestoragepathunusable =
988
  ("node",
989
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
990
   "Shared file storage path unusable")
991

    
992
cvEnodessh :: (String, String, String)
993
cvEnodessh =
994
  ("node",
995
   Types.cVErrorCodeToRaw CvENODESSH,
996
   "SSH-related node error")
997

    
998
cvEnodetime :: (String, String, String)
999
cvEnodetime =
1000
  ("node",
1001
   Types.cVErrorCodeToRaw CvENODETIME,
1002
   "Node returned invalid time")
1003

    
1004
cvEnodeuserscripts :: (String, String, String)
1005
cvEnodeuserscripts =
1006
  ("node",
1007
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
1008
   "User scripts not present or not executable")
1009

    
1010
cvEnodeversion :: (String, String, String)
1011
cvEnodeversion =
1012
  ("node",
1013
   Types.cVErrorCodeToRaw CvENODEVERSION,
1014
   "Protocol version mismatch or Ganeti version mismatch")
1015

    
1016
cvAllEcodes :: FrozenSet (String, String, String)
1017
cvAllEcodes =
1018
  ConstantUtils.mkSet
1019
  [cvEclustercert,
1020
   cvEclustercfg,
1021
   cvEclusterdanglinginst,
1022
   cvEclusterdanglingnodes,
1023
   cvEclusterfilecheck,
1024
   cvEgroupdifferentpvsize,
1025
   cvEinstancebadnode,
1026
   cvEinstancedown,
1027
   cvEinstancefaultydisk,
1028
   cvEinstancelayout,
1029
   cvEinstancemissingcfgparameter,
1030
   cvEinstancemissingdisk,
1031
   cvEinstancepolicy,
1032
   cvEinstancesplitgroups,
1033
   cvEinstanceunsuitablenode,
1034
   cvEinstancewrongnode,
1035
   cvEnodedrbd,
1036
   cvEnodedrbdhelper,
1037
   cvEnodedrbdversion,
1038
   cvEnodefilecheck,
1039
   cvEnodefilestoragepaths,
1040
   cvEnodefilestoragepathunusable,
1041
   cvEnodehooks,
1042
   cvEnodehv,
1043
   cvEnodelvm,
1044
   cvEnoden1,
1045
   cvEnodenet,
1046
   cvEnodeoobpath,
1047
   cvEnodeorphaninstance,
1048
   cvEnodeorphanlv,
1049
   cvEnodeos,
1050
   cvEnoderpc,
1051
   cvEnodesetup,
1052
   cvEnodesharedfilestoragepathunusable,
1053
   cvEnodessh,
1054
   cvEnodetime,
1055
   cvEnodeuserscripts,
1056
   cvEnodeversion]
1057

    
1058
cvAllEcodesStrings :: FrozenSet String
1059
cvAllEcodesStrings =
1060
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
1061

    
1062
-- * Instance status
1063

    
1064
inststAdmindown :: String
1065
inststAdmindown = Types.instanceStatusToRaw StatusDown
1066

    
1067
inststAdminoffline :: String
1068
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
1069

    
1070
inststErrordown :: String
1071
inststErrordown = Types.instanceStatusToRaw ErrorDown
1072

    
1073
inststErrorup :: String
1074
inststErrorup = Types.instanceStatusToRaw ErrorUp
1075

    
1076
inststNodedown :: String
1077
inststNodedown = Types.instanceStatusToRaw NodeDown
1078

    
1079
inststNodeoffline :: String
1080
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
1081

    
1082
inststRunning :: String
1083
inststRunning = Types.instanceStatusToRaw Running
1084

    
1085
inststWrongnode :: String
1086
inststWrongnode = Types.instanceStatusToRaw WrongNode
1087

    
1088
inststAll :: FrozenSet String
1089
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
1090

    
1091
-- * Admin states
1092

    
1093
adminstDown :: String
1094
adminstDown = Types.adminStateToRaw AdminDown
1095

    
1096
adminstOffline :: String
1097
adminstOffline = Types.adminStateToRaw AdminOffline
1098

    
1099
adminstUp :: String
1100
adminstUp = Types.adminStateToRaw AdminUp
1101

    
1102
adminstAll :: FrozenSet String
1103
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
1104

    
1105
-- * Node roles
1106

    
1107
nrDrained :: String
1108
nrDrained = Types.nodeRoleToRaw NRDrained
1109

    
1110
nrMaster :: String
1111
nrMaster = Types.nodeRoleToRaw NRMaster
1112

    
1113
nrMcandidate :: String
1114
nrMcandidate = Types.nodeRoleToRaw NRCandidate
1115

    
1116
nrOffline :: String
1117
nrOffline = Types.nodeRoleToRaw NROffline
1118

    
1119
nrRegular :: String
1120
nrRegular = Types.nodeRoleToRaw NRRegular
1121

    
1122
nrAll :: FrozenSet String
1123
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
1124

    
1125
-- * Allocator framework constants
1126

    
1127
iallocatorVersion :: Int
1128
iallocatorVersion = 2
1129

    
1130
iallocatorDirIn :: String
1131
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
1132

    
1133
iallocatorDirOut :: String
1134
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
1135

    
1136
validIallocatorDirections :: FrozenSet String
1137
validIallocatorDirections =
1138
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
1139

    
1140
iallocatorModeAlloc :: String
1141
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
1142

    
1143
iallocatorModeChgGroup :: String
1144
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
1145

    
1146
iallocatorModeMultiAlloc :: String
1147
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
1148

    
1149
iallocatorModeNodeEvac :: String
1150
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
1151

    
1152
iallocatorModeReloc :: String
1153
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
1154

    
1155
validIallocatorModes :: FrozenSet String
1156
validIallocatorModes =
1157
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
1158

    
1159
iallocatorSearchPath :: [String]
1160
iallocatorSearchPath = AutoConf.iallocatorSearchPath
1161

    
1162
defaultIallocatorShortcut :: String
1163
defaultIallocatorShortcut = "."
1164

    
1165
-- * Node evacuation
1166

    
1167
nodeEvacPri :: String
1168
nodeEvacPri = Types.evacModeToRaw ChangePrimary
1169

    
1170
nodeEvacSec :: String
1171
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
1172

    
1173
nodeEvacAll :: String
1174
nodeEvacAll = Types.evacModeToRaw ChangeAll
1175

    
1176
nodeEvacModes :: FrozenSet String
1177
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
1178

    
1179
-- * Job status
1180

    
1181
jobStatusQueued :: String
1182
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
1183

    
1184
jobStatusWaiting :: String
1185
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
1186

    
1187
jobStatusCanceling :: String
1188
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
1189

    
1190
jobStatusRunning :: String
1191
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
1192

    
1193
jobStatusCanceled :: String
1194
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
1195

    
1196
jobStatusSuccess :: String
1197
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
1198

    
1199
jobStatusError :: String
1200
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
1201

    
1202
jobsPending :: FrozenSet String
1203
jobsPending =
1204
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
1205

    
1206
jobsFinalized :: FrozenSet String
1207
jobsFinalized =
1208
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
1209

    
1210
jobStatusAll :: FrozenSet String
1211
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
1212

    
1213
-- * OpCode status
1214

    
1215
-- ** Not yet finalized opcodes
1216

    
1217
opStatusCanceling :: String
1218
opStatusCanceling = "canceling"
1219

    
1220
opStatusQueued :: String
1221
opStatusQueued = "queued"
1222

    
1223
opStatusRunning :: String
1224
opStatusRunning = "running"
1225

    
1226
opStatusWaiting :: String
1227
opStatusWaiting = "waiting"
1228

    
1229
-- ** Finalized opcodes
1230

    
1231
opStatusCanceled :: String
1232
opStatusCanceled = "canceled"
1233

    
1234
opStatusError :: String
1235
opStatusError = "error"
1236

    
1237
opStatusSuccess :: String
1238
opStatusSuccess = "success"
1239

    
1240
opsFinalized :: FrozenSet String
1241
opsFinalized =
1242
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
1243

    
1244
-- * OpCode priority
1245

    
1246
opPrioLowest :: Int
1247
opPrioLowest = 19
1248

    
1249
opPrioHighest :: Int
1250
opPrioHighest = -20
1251

    
1252
opPrioLow :: Int
1253
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
1254

    
1255
opPrioNormal :: Int
1256
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
1257

    
1258
opPrioHigh :: Int
1259
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
1260

    
1261
opPrioSubmitValid :: FrozenSet Int
1262
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
1263

    
1264
opPrioDefault :: Int
1265
opPrioDefault = opPrioNormal
1266

    
1267
-- * Execution log types
1268

    
1269
elogMessage :: String
1270
elogMessage = Types.eLogTypeToRaw ELogMessage
1271

    
1272
elogRemoteImport :: String
1273
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
1274

    
1275
elogJqueueTest :: String
1276
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
1277

    
1278
-- * Confd
1279

    
1280
confdProtocolVersion :: Int
1281
confdProtocolVersion = ConstantUtils.confdProtocolVersion
1282

    
1283
-- Confd request type
1284

    
1285
confdReqPing :: Int
1286
confdReqPing = Types.confdRequestTypeToRaw ReqPing
1287

    
1288
confdReqNodeRoleByname :: Int
1289
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
1290

    
1291
confdReqNodePipByInstanceIp :: Int
1292
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
1293

    
1294
confdReqClusterMaster :: Int
1295
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
1296

    
1297
confdReqNodePipList :: Int
1298
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
1299

    
1300
confdReqMcPipList :: Int
1301
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
1302

    
1303
confdReqInstancesIpsList :: Int
1304
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
1305

    
1306
confdReqNodeDrbd :: Int
1307
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
1308

    
1309
confdReqNodeInstances :: Int
1310
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
1311

    
1312
confdReqs :: FrozenSet Int
1313
confdReqs =
1314
  ConstantUtils.mkSet .
1315
  map Types.confdRequestTypeToRaw $
1316
  [minBound..] \\ [ReqNodeInstances]
1317

    
1318
-- * Confd request type
1319

    
1320
confdReqfieldName :: Int
1321
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
1322

    
1323
confdReqfieldIp :: Int
1324
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
1325

    
1326
confdReqfieldMnodePip :: Int
1327
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
1328

    
1329
-- * Confd repl status
1330

    
1331
confdReplStatusOk :: Int
1332
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
1333

    
1334
confdReplStatusError :: Int
1335
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
1336

    
1337
confdReplStatusNotimplemented :: Int
1338
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
1339

    
1340
confdReplStatuses :: FrozenSet Int
1341
confdReplStatuses =
1342
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
1343

    
1344
-- * Confd node role
1345

    
1346
confdNodeRoleMaster :: Int
1347
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
1348

    
1349
confdNodeRoleCandidate :: Int
1350
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
1351

    
1352
confdNodeRoleOffline :: Int
1353
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
1354

    
1355
confdNodeRoleDrained :: Int
1356
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
1357

    
1358
confdNodeRoleRegular :: Int
1359
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
1360

    
1361
-- * A few common errors for confd
1362

    
1363
confdErrorUnknownEntry :: Int
1364
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
1365

    
1366
confdErrorInternal :: Int
1367
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
1368

    
1369
confdErrorArgument :: Int
1370
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
1371

    
1372
-- * Confd request query fields
1373

    
1374
confdReqqLink :: String
1375
confdReqqLink = ConstantUtils.confdReqqLink
1376

    
1377
confdReqqIp :: String
1378
confdReqqIp = ConstantUtils.confdReqqIp
1379

    
1380
confdReqqIplist :: String
1381
confdReqqIplist = ConstantUtils.confdReqqIplist
1382

    
1383
confdReqqFields :: String
1384
confdReqqFields = ConstantUtils.confdReqqFields
1385

    
1386
-- | Each request is "salted" by the current timestamp.
1387
--
1388
-- This constant decides how many seconds of skew to accept.
1389
--
1390
-- TODO: make this a default and allow the value to be more
1391
-- configurable
1392
confdMaxClockSkew :: Int
1393
confdMaxClockSkew = 2 * nodeMaxClockSkew
1394

    
1395
-- | When we haven't reloaded the config for more than this amount of
1396
-- seconds, we force a test to see if inotify is betraying us. Using a
1397
-- prime number to ensure we get less chance of 'same wakeup' with
1398
-- other processes.
1399
confdConfigReloadTimeout :: Int
1400
confdConfigReloadTimeout = 17
1401

    
1402
-- | If we receive more than one update in this amount of
1403
-- microseconds, we move to polling every RATELIMIT seconds, rather
1404
-- than relying on inotify, to be able to serve more requests.
1405
confdConfigReloadRatelimit :: Int
1406
confdConfigReloadRatelimit = 250000
1407

    
1408
-- | Magic number prepended to all confd queries.
1409
--
1410
-- This allows us to distinguish different types of confd protocols
1411
-- and handle them. For example by changing this we can move the whole
1412
-- payload to be compressed, or move away from json.
1413
confdMagicFourcc :: String
1414
confdMagicFourcc = "plj0"
1415

    
1416
-- | By default a confd request is sent to the minimum between this
1417
-- number and all MCs. 6 was chosen because even in the case of a
1418
-- disastrous 50% response rate, we should have enough answers to be
1419
-- able to compare more than one.
1420
confdDefaultReqCoverage :: Int
1421
confdDefaultReqCoverage = 6
1422

    
1423
-- | Timeout in seconds to expire pending query request in the confd
1424
-- client library. We don't actually expect any answer more than 10
1425
-- seconds after we sent a request.
1426
confdClientExpireTimeout :: Int
1427
confdClientExpireTimeout = 10
1428

    
1429
-- * Possible values for NodeGroup.alloc_policy
1430

    
1431
allocPolicyLastResort :: String
1432
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
1433

    
1434
allocPolicyPreferred :: String
1435
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
1436

    
1437
allocPolicyUnallocable :: String
1438
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
1439

    
1440
validAllocPolicies :: [String]
1441
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
1442

    
1443
-- | Temporary external/shared storage parameters
1444
blockdevDriverManual :: String
1445
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
1446

    
1447
-- | 'qemu-img' path, required for 'ovfconverter'
1448
qemuimgPath :: String
1449
qemuimgPath = AutoConf.qemuimgPath
1450

    
1451
-- | Whether htools was enabled at compilation time
1452
--
1453
-- FIXME: this should be moved next to the other enable constants,
1454
-- such as, 'enableConfd', and renamed to 'enableHtools'.
1455
htools :: Bool
1456
htools = AutoConf.htools
1457

    
1458
-- | Path generating random UUID
1459
randomUuidFile :: String
1460
randomUuidFile = ConstantUtils.randomUuidFile
1461

    
1462
-- * Auto-repair tag prefixes
1463

    
1464
autoRepairTagPrefix :: String
1465
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
1466

    
1467
autoRepairTagEnabled :: String
1468
autoRepairTagEnabled = autoRepairTagPrefix
1469

    
1470
autoRepairTagPending :: String
1471
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
1472

    
1473
autoRepairTagResult :: String
1474
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
1475

    
1476
autoRepairTagSuspended :: String
1477
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
1478

    
1479
-- * Auto-repair levels
1480

    
1481
autoRepairFailover :: String
1482
autoRepairFailover = "failover"
1483

    
1484
autoRepairFixStorage :: String
1485
autoRepairFixStorage = "fix-storage"
1486

    
1487
autoRepairMigrate :: String
1488
autoRepairMigrate = "migrate"
1489

    
1490
autoRepairReinstall :: String
1491
autoRepairReinstall = "reinstall"
1492

    
1493
autoRepairAllTypes :: FrozenSet String
1494
autoRepairAllTypes =
1495
  ConstantUtils.mkSet [autoRepairFailover,
1496
                       autoRepairFixStorage,
1497
                       autoRepairMigrate,
1498
                       autoRepairReinstall]
1499

    
1500
-- * Auto-repair results
1501

    
1502
autoRepairEnoperm :: String
1503
autoRepairEnoperm = "enoperm"
1504

    
1505
autoRepairFailure :: String
1506
autoRepairFailure = "failure"
1507

    
1508
autoRepairSuccess :: String
1509
autoRepairSuccess = "success"
1510

    
1511
autoRepairAllResults :: FrozenSet String
1512
autoRepairAllResults =
1513
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
1514

    
1515
-- | The version identifier for builtin data collectors
1516
builtinDataCollectorVersion :: String
1517
builtinDataCollectorVersion = "B"
1518

    
1519
-- | The reason trail opcode parameter name
1520
opcodeReason :: String
1521
opcodeReason = "reason"
1522

    
1523
diskstatsFile :: String
1524
diskstatsFile = "/proc/diskstats"
1525

    
1526
-- *  CPU load collector
1527

    
1528
statFile :: String
1529
statFile = "/proc/stat"
1530

    
1531
cpuavgloadBufferSize :: Int
1532
cpuavgloadBufferSize = 150
1533

    
1534
cpuavgloadWindowSize :: Int
1535
cpuavgloadWindowSize = 600
1536

    
1537
-- | Mond's variable for periodical data collection
1538
mondTimeInterval :: Int
1539
mondTimeInterval = 5
1540

    
1541
-- * Disk access modes
1542

    
1543
diskUserspace :: String
1544
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
1545

    
1546
diskKernelspace :: String
1547
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
1548

    
1549
diskValidAccessModes :: FrozenSet String
1550
diskValidAccessModes =
1551
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
1552

    
1553
-- | Timeout for queue draining in upgrades
1554
upgradeQueueDrainTimeout :: Int
1555
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
1556

    
1557
-- | Intervall at which the queue is polled during upgrades
1558
upgradeQueuePollInterval :: Int
1559
upgradeQueuePollInterval  = 10