Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ a5450d2a

History | View | Annotate | Download (38.9 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
-- * Disk replacement mode
514

    
515
replaceDiskAuto :: String
516
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
517

    
518
replaceDiskChg :: String
519
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
520

    
521
replaceDiskPri :: String
522
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
523

    
524
replaceDiskSec :: String
525
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
526

    
527
replaceModes :: FrozenSet String
528
replaceModes =
529
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
530

    
531
-- * Instance export mode
532

    
533
exportModeLocal :: String
534
exportModeLocal = Types.exportModeToRaw ExportModeLocal
535

    
536
exportModeRemote :: String
537
exportModeRemote = Types.exportModeToRaw ExportModeRemote
538

    
539
exportModes :: FrozenSet String
540
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
541

    
542
-- * Instance creation modes
543

    
544
instanceCreate :: String
545
instanceCreate = Types.instCreateModeToRaw InstCreate
546

    
547
instanceImport :: String
548
instanceImport = Types.instCreateModeToRaw InstImport
549

    
550
instanceRemoteImport :: String
551
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
552

    
553
instanceCreateModes :: FrozenSet String
554
instanceCreateModes =
555
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
556

    
557
-- * Dynamic device modification
558

    
559
ddmAdd :: String
560
ddmAdd = Types.ddmFullToRaw DdmFullAdd
561

    
562
ddmModify :: String
563
ddmModify = Types.ddmFullToRaw DdmFullModify
564

    
565
ddmRemove :: String
566
ddmRemove = Types.ddmFullToRaw DdmFullRemove
567

    
568
ddmsValues :: FrozenSet String
569
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
570

    
571
ddmsValuesWithModify :: FrozenSet String
572
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
573

    
574
-- * Common exit codes
575

    
576
exitSuccess :: Int
577
exitSuccess = 0
578

    
579
exitFailure :: Int
580
exitFailure = ConstantUtils.exitFailure
581

    
582
exitNotcluster :: Int
583
exitNotcluster = 5
584

    
585
exitNotmaster :: Int
586
exitNotmaster = 11
587

    
588
exitNodesetupError :: Int
589
exitNodesetupError = 12
590

    
591
-- | Need user confirmation
592
exitConfirmation :: Int
593
exitConfirmation = 13
594

    
595
-- | Exit code for query operations with unknown fields
596
exitUnknownField :: Int
597
exitUnknownField = 14
598

    
599
-- * Tags
600

    
601
tagCluster :: String
602
tagCluster = Types.tagKindToRaw TagKindCluster
603

    
604
tagInstance :: String
605
tagInstance = Types.tagKindToRaw TagKindInstance
606

    
607
tagNetwork :: String
608
tagNetwork = Types.tagKindToRaw TagKindNetwork
609

    
610
tagNode :: String
611
tagNode = Types.tagKindToRaw TagKindNode
612

    
613
tagNodegroup :: String
614
tagNodegroup = Types.tagKindToRaw TagKindGroup
615

    
616
validTagTypes :: FrozenSet String
617
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
618

    
619
maxTagLen :: Int
620
maxTagLen = 128
621

    
622
maxTagsPerObj :: Int
623
maxTagsPerObj = 4096
624

    
625
-- | Node clock skew in seconds
626
nodeMaxClockSkew :: Int
627
nodeMaxClockSkew = 150
628

    
629
-- | Disk index separator
630
diskSeparator :: String
631
diskSeparator = AutoConf.diskSeparator
632

    
633
ipCommandPath :: String
634
ipCommandPath = AutoConf.ipPath
635

    
636
-- * Reboot types
637

    
638
instanceRebootSoft :: String
639
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
640

    
641
instanceRebootHard :: String
642
instanceRebootHard = Types.rebootTypeToRaw RebootHard
643

    
644
instanceRebootFull :: String
645
instanceRebootFull = Types.rebootTypeToRaw RebootFull
646

    
647
rebootTypes :: FrozenSet String
648
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
649

    
650
-- * VTypes
651

    
652
vtypeBool :: String
653
vtypeBool = Types.vTypeToRaw VTypeBool
654

    
655
vtypeInt :: String
656
vtypeInt = Types.vTypeToRaw VTypeInt
657

    
658
vtypeMaybeString :: String
659
vtypeMaybeString = Types.vTypeToRaw VTypeMaybeString
660

    
661
-- | Size in MiBs
662
vtypeSize :: String
663
vtypeSize = Types.vTypeToRaw VTypeSize
664

    
665
vtypeString :: String
666
vtypeString = Types.vTypeToRaw VTypeString
667

    
668
enforceableTypes :: FrozenSet String
669
enforceableTypes = ConstantUtils.mkSet $ map Types.vTypeToRaw [minBound..]
670

    
671
-- * OOB supported commands
672

    
673
oobPowerOn :: String
674
oobPowerOn = Types.oobCommandToRaw OobPowerOn
675

    
676
oobPowerOff :: String
677
oobPowerOff = Types.oobCommandToRaw OobPowerOff
678

    
679
oobPowerCycle :: String
680
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
681

    
682
oobPowerStatus :: String
683
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
684

    
685
oobHealth :: String
686
oobHealth = Types.oobCommandToRaw OobHealth
687

    
688
oobCommands :: FrozenSet String
689
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
690

    
691
oobPowerStatusPowered :: String
692
oobPowerStatusPowered = "powered"
693

    
694
-- | 60 seconds
695
oobTimeout :: Int
696
oobTimeout = 60
697

    
698
-- | 2 seconds
699
oobPowerDelay :: Double
700
oobPowerDelay = 2.0
701

    
702
oobStatusCritical :: String
703
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
704

    
705
oobStatusOk :: String
706
oobStatusOk = Types.oobStatusToRaw OobStatusOk
707

    
708
oobStatusUnknown :: String
709
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
710

    
711
oobStatusWarning :: String
712
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
713

    
714
oobStatuses :: FrozenSet String
715
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
716

    
717
-- * NIC_* constants are used inside the ganeti config
718

    
719
nicLink :: String
720
nicLink = "link"
721

    
722
nicMode :: String
723
nicMode = "mode"
724

    
725
nicVlan :: String
726
nicVlan = "vlan"
727

    
728
nicModeBridged :: String
729
nicModeBridged = Types.nICModeToRaw NMBridged
730

    
731
nicModeRouted :: String
732
nicModeRouted = Types.nICModeToRaw NMRouted
733

    
734
nicModeOvs :: String
735
nicModeOvs = Types.nICModeToRaw NMOvs
736

    
737
nicIpPool :: String
738
nicIpPool = Types.nICModeToRaw NMPool
739

    
740
nicValidModes :: FrozenSet String
741
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
742

    
743
-- * Hypervisor constants
744

    
745
htXenPvm :: String
746
htXenPvm = Types.hypervisorToRaw XenPvm
747

    
748
htFake :: String
749
htFake = Types.hypervisorToRaw Fake
750

    
751
htXenHvm :: String
752
htXenHvm = Types.hypervisorToRaw XenHvm
753

    
754
htKvm :: String
755
htKvm = Types.hypervisorToRaw Kvm
756

    
757
htChroot :: String
758
htChroot = Types.hypervisorToRaw Chroot
759

    
760
htLxc :: String
761
htLxc = Types.hypervisorToRaw Lxc
762

    
763
hyperTypes :: FrozenSet String
764
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
765

    
766
htsReqPort :: FrozenSet String
767
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
768

    
769
-- * Migration type
770

    
771
htMigrationLive :: String
772
htMigrationLive = Types.migrationModeToRaw MigrationLive
773

    
774
htMigrationNonlive :: String
775
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
776

    
777
htMigrationModes :: FrozenSet String
778
htMigrationModes =
779
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
780

    
781
-- * Cluster verify steps
782

    
783
verifyNplusoneMem :: String
784
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
785

    
786
verifyOptionalChecks :: FrozenSet String
787
verifyOptionalChecks =
788
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
789

    
790
-- * Cluster Verify error classes
791

    
792
cvTcluster :: String
793
cvTcluster = "cluster"
794

    
795
cvTgroup :: String
796
cvTgroup = "group"
797

    
798
cvTnode :: String
799
cvTnode = "node"
800

    
801
cvTinstance :: String
802
cvTinstance = "instance"
803

    
804
-- * Cluster Verify error codes and documentation
805

    
806
cvEclustercert :: (String, String, String)
807
cvEclustercert =
808
  ("cluster",
809
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
810
   "Cluster certificate files verification failure")
811

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

    
818
cvEclusterdanglinginst :: (String, String, String)
819
cvEclusterdanglinginst =
820
  ("node",
821
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
822
   "Some instances have a non-existing primary node")
823

    
824
cvEclusterdanglingnodes :: (String, String, String)
825
cvEclusterdanglingnodes =
826
  ("node",
827
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
828
   "Some nodes belong to non-existing groups")
829

    
830
cvEclusterfilecheck :: (String, String, String)
831
cvEclusterfilecheck =
832
  ("cluster",
833
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
834
   "Cluster configuration verification failure")
835

    
836
cvEgroupdifferentpvsize :: (String, String, String)
837
cvEgroupdifferentpvsize =
838
  ("group",
839
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
840
   "PVs in the group have different sizes")
841

    
842
cvEinstancebadnode :: (String, String, String)
843
cvEinstancebadnode =
844
  ("instance",
845
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
846
   "Instance marked as running lives on an offline node")
847

    
848
cvEinstancedown :: (String, String, String)
849
cvEinstancedown =
850
  ("instance",
851
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
852
   "Instance not running on its primary node")
853

    
854
cvEinstancefaultydisk :: (String, String, String)
855
cvEinstancefaultydisk =
856
  ("instance",
857
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
858
   "Impossible to retrieve status for a disk")
859

    
860
cvEinstancelayout :: (String, String, String)
861
cvEinstancelayout =
862
  ("instance",
863
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
864
   "Instance has multiple secondary nodes")
865

    
866
cvEinstancemissingcfgparameter :: (String, String, String)
867
cvEinstancemissingcfgparameter =
868
  ("instance",
869
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
870
   "A configuration parameter for an instance is missing")
871

    
872
cvEinstancemissingdisk :: (String, String, String)
873
cvEinstancemissingdisk =
874
  ("instance",
875
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
876
   "Missing volume on an instance")
877

    
878
cvEinstancepolicy :: (String, String, String)
879
cvEinstancepolicy =
880
  ("instance",
881
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
882
   "Instance does not meet policy")
883

    
884
cvEinstancesplitgroups :: (String, String, String)
885
cvEinstancesplitgroups =
886
  ("instance",
887
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
888
   "Instance with primary and secondary nodes in different groups")
889

    
890
cvEinstanceunsuitablenode :: (String, String, String)
891
cvEinstanceunsuitablenode =
892
  ("instance",
893
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
894
   "Instance running on nodes that are not suitable for it")
895

    
896
cvEinstancewrongnode :: (String, String, String)
897
cvEinstancewrongnode =
898
  ("instance",
899
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
900
   "Instance running on the wrong node")
901

    
902
cvEnodedrbd :: (String, String, String)
903
cvEnodedrbd =
904
  ("node",
905
   Types.cVErrorCodeToRaw CvENODEDRBD,
906
   "Error parsing the DRBD status file")
907

    
908
cvEnodedrbdhelper :: (String, String, String)
909
cvEnodedrbdhelper =
910
  ("node",
911
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
912
   "Error caused by the DRBD helper")
913

    
914
cvEnodedrbdversion :: (String, String, String)
915
cvEnodedrbdversion =
916
  ("node",
917
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
918
   "DRBD version mismatch within a node group")
919

    
920
cvEnodefilecheck :: (String, String, String)
921
cvEnodefilecheck =
922
  ("node",
923
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
924
   "Error retrieving the checksum of the node files")
925

    
926
cvEnodefilestoragepaths :: (String, String, String)
927
cvEnodefilestoragepaths =
928
  ("node",
929
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
930
   "Detected bad file storage paths")
931

    
932
cvEnodefilestoragepathunusable :: (String, String, String)
933
cvEnodefilestoragepathunusable =
934
  ("node",
935
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
936
   "File storage path unusable")
937

    
938
cvEnodehooks :: (String, String, String)
939
cvEnodehooks =
940
  ("node",
941
   Types.cVErrorCodeToRaw CvENODEHOOKS,
942
   "Communication failure in hooks execution")
943

    
944
cvEnodehv :: (String, String, String)
945
cvEnodehv =
946
  ("node",
947
   Types.cVErrorCodeToRaw CvENODEHV,
948
   "Hypervisor parameters verification failure")
949

    
950
cvEnodelvm :: (String, String, String)
951
cvEnodelvm =
952
  ("node",
953
   Types.cVErrorCodeToRaw CvENODELVM,
954
   "LVM-related node error")
955

    
956
cvEnoden1 :: (String, String, String)
957
cvEnoden1 =
958
  ("node",
959
   Types.cVErrorCodeToRaw CvENODEN1,
960
   "Not enough memory to accommodate instance failovers")
961

    
962
cvEnodenet :: (String, String, String)
963
cvEnodenet =
964
  ("node",
965
   Types.cVErrorCodeToRaw CvENODENET,
966
   "Network-related node error")
967

    
968
cvEnodeoobpath :: (String, String, String)
969
cvEnodeoobpath =
970
  ("node",
971
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
972
   "Invalid Out Of Band path")
973

    
974
cvEnodeorphaninstance :: (String, String, String)
975
cvEnodeorphaninstance =
976
  ("node",
977
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
978
   "Unknown intance running on a node")
979

    
980
cvEnodeorphanlv :: (String, String, String)
981
cvEnodeorphanlv =
982
  ("node",
983
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
984
   "Unknown LVM logical volume")
985

    
986
cvEnodeos :: (String, String, String)
987
cvEnodeos =
988
  ("node",
989
   Types.cVErrorCodeToRaw CvENODEOS,
990
   "OS-related node error")
991

    
992
cvEnoderpc :: (String, String, String)
993
cvEnoderpc =
994
  ("node",
995
   Types.cVErrorCodeToRaw CvENODERPC,
996
   "Error during connection to the primary node of an instance")
997

    
998
cvEnodesetup :: (String, String, String)
999
cvEnodesetup =
1000
  ("node",
1001
   Types.cVErrorCodeToRaw CvENODESETUP,
1002
   "Node setup error")
1003

    
1004
cvEnodesharedfilestoragepathunusable :: (String, String, String)
1005
cvEnodesharedfilestoragepathunusable =
1006
  ("node",
1007
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
1008
   "Shared file storage path unusable")
1009

    
1010
cvEnodessh :: (String, String, String)
1011
cvEnodessh =
1012
  ("node",
1013
   Types.cVErrorCodeToRaw CvENODESSH,
1014
   "SSH-related node error")
1015

    
1016
cvEnodetime :: (String, String, String)
1017
cvEnodetime =
1018
  ("node",
1019
   Types.cVErrorCodeToRaw CvENODETIME,
1020
   "Node returned invalid time")
1021

    
1022
cvEnodeuserscripts :: (String, String, String)
1023
cvEnodeuserscripts =
1024
  ("node",
1025
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
1026
   "User scripts not present or not executable")
1027

    
1028
cvEnodeversion :: (String, String, String)
1029
cvEnodeversion =
1030
  ("node",
1031
   Types.cVErrorCodeToRaw CvENODEVERSION,
1032
   "Protocol version mismatch or Ganeti version mismatch")
1033

    
1034
cvAllEcodes :: FrozenSet (String, String, String)
1035
cvAllEcodes =
1036
  ConstantUtils.mkSet
1037
  [cvEclustercert,
1038
   cvEclustercfg,
1039
   cvEclusterdanglinginst,
1040
   cvEclusterdanglingnodes,
1041
   cvEclusterfilecheck,
1042
   cvEgroupdifferentpvsize,
1043
   cvEinstancebadnode,
1044
   cvEinstancedown,
1045
   cvEinstancefaultydisk,
1046
   cvEinstancelayout,
1047
   cvEinstancemissingcfgparameter,
1048
   cvEinstancemissingdisk,
1049
   cvEinstancepolicy,
1050
   cvEinstancesplitgroups,
1051
   cvEinstanceunsuitablenode,
1052
   cvEinstancewrongnode,
1053
   cvEnodedrbd,
1054
   cvEnodedrbdhelper,
1055
   cvEnodedrbdversion,
1056
   cvEnodefilecheck,
1057
   cvEnodefilestoragepaths,
1058
   cvEnodefilestoragepathunusable,
1059
   cvEnodehooks,
1060
   cvEnodehv,
1061
   cvEnodelvm,
1062
   cvEnoden1,
1063
   cvEnodenet,
1064
   cvEnodeoobpath,
1065
   cvEnodeorphaninstance,
1066
   cvEnodeorphanlv,
1067
   cvEnodeos,
1068
   cvEnoderpc,
1069
   cvEnodesetup,
1070
   cvEnodesharedfilestoragepathunusable,
1071
   cvEnodessh,
1072
   cvEnodetime,
1073
   cvEnodeuserscripts,
1074
   cvEnodeversion]
1075

    
1076
cvAllEcodesStrings :: FrozenSet String
1077
cvAllEcodesStrings =
1078
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
1079

    
1080
-- * Instance status
1081

    
1082
inststAdmindown :: String
1083
inststAdmindown = Types.instanceStatusToRaw StatusDown
1084

    
1085
inststAdminoffline :: String
1086
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
1087

    
1088
inststErrordown :: String
1089
inststErrordown = Types.instanceStatusToRaw ErrorDown
1090

    
1091
inststErrorup :: String
1092
inststErrorup = Types.instanceStatusToRaw ErrorUp
1093

    
1094
inststNodedown :: String
1095
inststNodedown = Types.instanceStatusToRaw NodeDown
1096

    
1097
inststNodeoffline :: String
1098
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
1099

    
1100
inststRunning :: String
1101
inststRunning = Types.instanceStatusToRaw Running
1102

    
1103
inststWrongnode :: String
1104
inststWrongnode = Types.instanceStatusToRaw WrongNode
1105

    
1106
inststAll :: FrozenSet String
1107
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
1108

    
1109
-- * Admin states
1110

    
1111
adminstDown :: String
1112
adminstDown = Types.adminStateToRaw AdminDown
1113

    
1114
adminstOffline :: String
1115
adminstOffline = Types.adminStateToRaw AdminOffline
1116

    
1117
adminstUp :: String
1118
adminstUp = Types.adminStateToRaw AdminUp
1119

    
1120
adminstAll :: FrozenSet String
1121
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
1122

    
1123
-- * Node roles
1124

    
1125
nrDrained :: String
1126
nrDrained = Types.nodeRoleToRaw NRDrained
1127

    
1128
nrMaster :: String
1129
nrMaster = Types.nodeRoleToRaw NRMaster
1130

    
1131
nrMcandidate :: String
1132
nrMcandidate = Types.nodeRoleToRaw NRCandidate
1133

    
1134
nrOffline :: String
1135
nrOffline = Types.nodeRoleToRaw NROffline
1136

    
1137
nrRegular :: String
1138
nrRegular = Types.nodeRoleToRaw NRRegular
1139

    
1140
nrAll :: FrozenSet String
1141
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
1142

    
1143
-- * Allocator framework constants
1144

    
1145
iallocatorVersion :: Int
1146
iallocatorVersion = 2
1147

    
1148
iallocatorDirIn :: String
1149
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
1150

    
1151
iallocatorDirOut :: String
1152
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
1153

    
1154
validIallocatorDirections :: FrozenSet String
1155
validIallocatorDirections =
1156
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
1157

    
1158
iallocatorModeAlloc :: String
1159
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
1160

    
1161
iallocatorModeChgGroup :: String
1162
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
1163

    
1164
iallocatorModeMultiAlloc :: String
1165
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
1166

    
1167
iallocatorModeNodeEvac :: String
1168
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
1169

    
1170
iallocatorModeReloc :: String
1171
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
1172

    
1173
validIallocatorModes :: FrozenSet String
1174
validIallocatorModes =
1175
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
1176

    
1177
iallocatorSearchPath :: [String]
1178
iallocatorSearchPath = AutoConf.iallocatorSearchPath
1179

    
1180
defaultIallocatorShortcut :: String
1181
defaultIallocatorShortcut = "."
1182

    
1183
-- * Node evacuation
1184

    
1185
nodeEvacPri :: String
1186
nodeEvacPri = Types.evacModeToRaw ChangePrimary
1187

    
1188
nodeEvacSec :: String
1189
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
1190

    
1191
nodeEvacAll :: String
1192
nodeEvacAll = Types.evacModeToRaw ChangeAll
1193

    
1194
nodeEvacModes :: FrozenSet String
1195
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
1196

    
1197
-- * Job status
1198

    
1199
jobStatusQueued :: String
1200
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
1201

    
1202
jobStatusWaiting :: String
1203
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
1204

    
1205
jobStatusCanceling :: String
1206
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
1207

    
1208
jobStatusRunning :: String
1209
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
1210

    
1211
jobStatusCanceled :: String
1212
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
1213

    
1214
jobStatusSuccess :: String
1215
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
1216

    
1217
jobStatusError :: String
1218
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
1219

    
1220
jobsPending :: FrozenSet String
1221
jobsPending =
1222
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
1223

    
1224
jobsFinalized :: FrozenSet String
1225
jobsFinalized =
1226
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
1227

    
1228
jobStatusAll :: FrozenSet String
1229
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
1230

    
1231
-- * OpCode status
1232

    
1233
-- ** Not yet finalized opcodes
1234

    
1235
opStatusCanceling :: String
1236
opStatusCanceling = "canceling"
1237

    
1238
opStatusQueued :: String
1239
opStatusQueued = "queued"
1240

    
1241
opStatusRunning :: String
1242
opStatusRunning = "running"
1243

    
1244
opStatusWaiting :: String
1245
opStatusWaiting = "waiting"
1246

    
1247
-- ** Finalized opcodes
1248

    
1249
opStatusCanceled :: String
1250
opStatusCanceled = "canceled"
1251

    
1252
opStatusError :: String
1253
opStatusError = "error"
1254

    
1255
opStatusSuccess :: String
1256
opStatusSuccess = "success"
1257

    
1258
opsFinalized :: FrozenSet String
1259
opsFinalized =
1260
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
1261

    
1262
-- * OpCode priority
1263

    
1264
opPrioLowest :: Int
1265
opPrioLowest = 19
1266

    
1267
opPrioHighest :: Int
1268
opPrioHighest = -20
1269

    
1270
opPrioLow :: Int
1271
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
1272

    
1273
opPrioNormal :: Int
1274
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
1275

    
1276
opPrioHigh :: Int
1277
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
1278

    
1279
opPrioSubmitValid :: FrozenSet Int
1280
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
1281

    
1282
opPrioDefault :: Int
1283
opPrioDefault = opPrioNormal
1284

    
1285
-- * Execution log types
1286

    
1287
elogMessage :: String
1288
elogMessage = Types.eLogTypeToRaw ELogMessage
1289

    
1290
elogRemoteImport :: String
1291
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
1292

    
1293
elogJqueueTest :: String
1294
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
1295

    
1296
-- * Confd
1297

    
1298
confdProtocolVersion :: Int
1299
confdProtocolVersion = ConstantUtils.confdProtocolVersion
1300

    
1301
-- Confd request type
1302

    
1303
confdReqPing :: Int
1304
confdReqPing = Types.confdRequestTypeToRaw ReqPing
1305

    
1306
confdReqNodeRoleByname :: Int
1307
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
1308

    
1309
confdReqNodePipByInstanceIp :: Int
1310
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
1311

    
1312
confdReqClusterMaster :: Int
1313
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
1314

    
1315
confdReqNodePipList :: Int
1316
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
1317

    
1318
confdReqMcPipList :: Int
1319
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
1320

    
1321
confdReqInstancesIpsList :: Int
1322
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
1323

    
1324
confdReqNodeDrbd :: Int
1325
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
1326

    
1327
confdReqNodeInstances :: Int
1328
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
1329

    
1330
confdReqs :: FrozenSet Int
1331
confdReqs =
1332
  ConstantUtils.mkSet .
1333
  map Types.confdRequestTypeToRaw $
1334
  [minBound..] \\ [ReqNodeInstances]
1335

    
1336
-- * Confd request type
1337

    
1338
confdReqfieldName :: Int
1339
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
1340

    
1341
confdReqfieldIp :: Int
1342
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
1343

    
1344
confdReqfieldMnodePip :: Int
1345
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
1346

    
1347
-- * Confd repl status
1348

    
1349
confdReplStatusOk :: Int
1350
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
1351

    
1352
confdReplStatusError :: Int
1353
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
1354

    
1355
confdReplStatusNotimplemented :: Int
1356
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
1357

    
1358
confdReplStatuses :: FrozenSet Int
1359
confdReplStatuses =
1360
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
1361

    
1362
-- * Confd node role
1363

    
1364
confdNodeRoleMaster :: Int
1365
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
1366

    
1367
confdNodeRoleCandidate :: Int
1368
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
1369

    
1370
confdNodeRoleOffline :: Int
1371
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
1372

    
1373
confdNodeRoleDrained :: Int
1374
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
1375

    
1376
confdNodeRoleRegular :: Int
1377
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
1378

    
1379
-- * A few common errors for confd
1380

    
1381
confdErrorUnknownEntry :: Int
1382
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
1383

    
1384
confdErrorInternal :: Int
1385
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
1386

    
1387
confdErrorArgument :: Int
1388
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
1389

    
1390
-- * Confd request query fields
1391

    
1392
confdReqqLink :: String
1393
confdReqqLink = ConstantUtils.confdReqqLink
1394

    
1395
confdReqqIp :: String
1396
confdReqqIp = ConstantUtils.confdReqqIp
1397

    
1398
confdReqqIplist :: String
1399
confdReqqIplist = ConstantUtils.confdReqqIplist
1400

    
1401
confdReqqFields :: String
1402
confdReqqFields = ConstantUtils.confdReqqFields
1403

    
1404
-- | Each request is "salted" by the current timestamp.
1405
--
1406
-- This constant decides how many seconds of skew to accept.
1407
--
1408
-- TODO: make this a default and allow the value to be more
1409
-- configurable
1410
confdMaxClockSkew :: Int
1411
confdMaxClockSkew = 2 * nodeMaxClockSkew
1412

    
1413
-- | When we haven't reloaded the config for more than this amount of
1414
-- seconds, we force a test to see if inotify is betraying us. Using a
1415
-- prime number to ensure we get less chance of 'same wakeup' with
1416
-- other processes.
1417
confdConfigReloadTimeout :: Int
1418
confdConfigReloadTimeout = 17
1419

    
1420
-- | If we receive more than one update in this amount of
1421
-- microseconds, we move to polling every RATELIMIT seconds, rather
1422
-- than relying on inotify, to be able to serve more requests.
1423
confdConfigReloadRatelimit :: Int
1424
confdConfigReloadRatelimit = 250000
1425

    
1426
-- | Magic number prepended to all confd queries.
1427
--
1428
-- This allows us to distinguish different types of confd protocols
1429
-- and handle them. For example by changing this we can move the whole
1430
-- payload to be compressed, or move away from json.
1431
confdMagicFourcc :: String
1432
confdMagicFourcc = "plj0"
1433

    
1434
-- | By default a confd request is sent to the minimum between this
1435
-- number and all MCs. 6 was chosen because even in the case of a
1436
-- disastrous 50% response rate, we should have enough answers to be
1437
-- able to compare more than one.
1438
confdDefaultReqCoverage :: Int
1439
confdDefaultReqCoverage = 6
1440

    
1441
-- | Timeout in seconds to expire pending query request in the confd
1442
-- client library. We don't actually expect any answer more than 10
1443
-- seconds after we sent a request.
1444
confdClientExpireTimeout :: Int
1445
confdClientExpireTimeout = 10
1446

    
1447
-- * Possible values for NodeGroup.alloc_policy
1448

    
1449
allocPolicyLastResort :: String
1450
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
1451

    
1452
allocPolicyPreferred :: String
1453
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
1454

    
1455
allocPolicyUnallocable :: String
1456
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
1457

    
1458
validAllocPolicies :: [String]
1459
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
1460

    
1461
-- | Temporary external/shared storage parameters
1462
blockdevDriverManual :: String
1463
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
1464

    
1465
-- | 'qemu-img' path, required for 'ovfconverter'
1466
qemuimgPath :: String
1467
qemuimgPath = AutoConf.qemuimgPath
1468

    
1469
-- | Whether htools was enabled at compilation time
1470
--
1471
-- FIXME: this should be moved next to the other enable constants,
1472
-- such as, 'enableConfd', and renamed to 'enableHtools'.
1473
htools :: Bool
1474
htools = AutoConf.htools
1475

    
1476
-- | Path generating random UUID
1477
randomUuidFile :: String
1478
randomUuidFile = ConstantUtils.randomUuidFile
1479

    
1480
-- * Auto-repair tag prefixes
1481

    
1482
autoRepairTagPrefix :: String
1483
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
1484

    
1485
autoRepairTagEnabled :: String
1486
autoRepairTagEnabled = autoRepairTagPrefix
1487

    
1488
autoRepairTagPending :: String
1489
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
1490

    
1491
autoRepairTagResult :: String
1492
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
1493

    
1494
autoRepairTagSuspended :: String
1495
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
1496

    
1497
-- * Auto-repair levels
1498

    
1499
autoRepairFailover :: String
1500
autoRepairFailover = "failover"
1501

    
1502
autoRepairFixStorage :: String
1503
autoRepairFixStorage = "fix-storage"
1504

    
1505
autoRepairMigrate :: String
1506
autoRepairMigrate = "migrate"
1507

    
1508
autoRepairReinstall :: String
1509
autoRepairReinstall = "reinstall"
1510

    
1511
autoRepairAllTypes :: FrozenSet String
1512
autoRepairAllTypes =
1513
  ConstantUtils.mkSet [autoRepairFailover,
1514
                       autoRepairFixStorage,
1515
                       autoRepairMigrate,
1516
                       autoRepairReinstall]
1517

    
1518
-- * Auto-repair results
1519

    
1520
autoRepairEnoperm :: String
1521
autoRepairEnoperm = "enoperm"
1522

    
1523
autoRepairFailure :: String
1524
autoRepairFailure = "failure"
1525

    
1526
autoRepairSuccess :: String
1527
autoRepairSuccess = "success"
1528

    
1529
autoRepairAllResults :: FrozenSet String
1530
autoRepairAllResults =
1531
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
1532

    
1533
-- | The version identifier for builtin data collectors
1534
builtinDataCollectorVersion :: String
1535
builtinDataCollectorVersion = "B"
1536

    
1537
-- | The reason trail opcode parameter name
1538
opcodeReason :: String
1539
opcodeReason = "reason"
1540

    
1541
diskstatsFile :: String
1542
diskstatsFile = "/proc/diskstats"
1543

    
1544
-- *  CPU load collector
1545

    
1546
statFile :: String
1547
statFile = "/proc/stat"
1548

    
1549
cpuavgloadBufferSize :: Int
1550
cpuavgloadBufferSize = 150
1551

    
1552
cpuavgloadWindowSize :: Int
1553
cpuavgloadWindowSize = 600
1554

    
1555
-- | Mond's variable for periodical data collection
1556
mondTimeInterval :: Int
1557
mondTimeInterval = 5
1558

    
1559
-- * Disk access modes
1560

    
1561
diskUserspace :: String
1562
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
1563

    
1564
diskKernelspace :: String
1565
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
1566

    
1567
diskValidAccessModes :: FrozenSet String
1568
diskValidAccessModes =
1569
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
1570

    
1571
-- | Timeout for queue draining in upgrades
1572
upgradeQueueDrainTimeout :: Int
1573
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
1574

    
1575
-- | Intervall at which the queue is polled during upgrades
1576
upgradeQueuePollInterval :: Int
1577
upgradeQueuePollInterval  = 10