Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ 14795b58

History | View | Annotate | Download (46.5 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, keys, insert)
42

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

    
61
{-# ANN module "HLint: ignore Use camelCase" #-}
62

    
63
-- * 'autoconf' constants for Python only ('autotools/build-bash-completion')
64

    
65
htoolsProgs :: [String]
66
htoolsProgs = AutoConf.htoolsProgs
67

    
68
-- * 'autoconf' constants for Python only ('lib/constants.py')
69

    
70
drbdBarriers :: String
71
drbdBarriers = AutoConf.drbdBarriers
72

    
73
drbdNoMetaFlush :: Bool
74
drbdNoMetaFlush = AutoConf.drbdNoMetaFlush
75

    
76
lvmStripecount :: Int
77
lvmStripecount = AutoConf.lvmStripecount
78

    
79
-- * 'autoconf' constants for Python only ('lib/pathutils.py')
80

    
81
-- ** Build-time constants
82

    
83
exportDir :: String
84
exportDir = AutoConf.exportDir
85

    
86
osSearchPath :: [String]
87
osSearchPath = AutoConf.osSearchPath
88

    
89
esSearchPath :: [String]
90
esSearchPath = AutoConf.esSearchPath
91

    
92
sshConfigDir :: String
93
sshConfigDir = AutoConf.sshConfigDir
94

    
95
xenConfigDir :: String
96
xenConfigDir = AutoConf.xenConfigDir
97

    
98
sysconfdir :: String
99
sysconfdir = AutoConf.sysconfdir
100

    
101
toolsdir :: String
102
toolsdir = AutoConf.toolsdir
103

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

    
107
-- ** Paths which don't change for a virtual cluster
108

    
109
pkglibdir :: String
110
pkglibdir = AutoConf.pkglibdir
111

    
112
sharedir :: String
113
sharedir = AutoConf.sharedir
114

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

    
117
manPages :: Map String Int
118
manPages = Map.fromList AutoConf.manPages
119

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

    
122
versionedsharedir :: String
123
versionedsharedir = AutoConf.versionedsharedir
124

    
125
-- * 'autoconf' constants for Python only ('tests/py/docs_unittest.py')
126

    
127
gntScripts :: [String]
128
gntScripts = AutoConf.gntScripts
129

    
130
-- * Various versions
131

    
132
releaseVersion :: String
133
releaseVersion = AutoConf.packageVersion
134

    
135
versionMajor :: Int
136
versionMajor = AutoConf.versionMajor
137

    
138
versionMinor :: Int
139
versionMinor = AutoConf.versionMinor
140

    
141
versionRevision :: Int
142
versionRevision = AutoConf.versionRevision
143

    
144
dirVersion :: String
145
dirVersion = AutoConf.dirVersion
146

    
147
osApiV10 :: Int
148
osApiV10 = 10
149

    
150
osApiV15 :: Int
151
osApiV15 = 15
152

    
153
osApiV20 :: Int
154
osApiV20 = 20
155

    
156
osApiVersions :: FrozenSet Int
157
osApiVersions = ConstantUtils.mkSet [osApiV10, osApiV15, osApiV20]
158

    
159
exportVersion :: Int
160
exportVersion = 0
161

    
162
rapiVersion :: Int
163
rapiVersion = 2
164

    
165
configMajor :: Int
166
configMajor = AutoConf.versionMajor
167

    
168
configMinor :: Int
169
configMinor = AutoConf.versionMinor
170

    
171
-- | The configuration is supposed to remain stable across
172
-- revisions. Therefore, the revision number is cleared to '0'.
173
configRevision :: Int
174
configRevision = 0
175

    
176
configVersion :: Int
177
configVersion = buildVersion configMajor configMinor configRevision
178

    
179
-- | Similarly to the configuration (see 'configRevision'), the
180
-- protocols are supposed to remain stable across revisions.
181
protocolVersion :: Int
182
protocolVersion = buildVersion configMajor configMinor configRevision
183

    
184
-- * User separation
185

    
186
daemonsGroup :: String
187
daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
188

    
189
adminGroup :: String
190
adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
191

    
192
masterdUser :: String
193
masterdUser = Runtime.daemonUser GanetiMasterd
194

    
195
masterdGroup :: String
196
masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
197

    
198
rapiUser :: String
199
rapiUser = Runtime.daemonUser GanetiRapi
200

    
201
rapiGroup :: String
202
rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
203

    
204
confdUser :: String
205
confdUser = Runtime.daemonUser GanetiConfd
206

    
207
confdGroup :: String
208
confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
209

    
210
luxidUser :: String
211
luxidUser = Runtime.daemonUser GanetiLuxid
212

    
213
luxidGroup :: String
214
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
215

    
216
nodedUser :: String
217
nodedUser = Runtime.daemonUser GanetiNoded
218

    
219
nodedGroup :: String
220
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
221

    
222
mondUser :: String
223
mondUser = Runtime.daemonUser GanetiMond
224

    
225
mondGroup :: String
226
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
227

    
228
sshLoginUser :: String
229
sshLoginUser = AutoConf.sshLoginUser
230

    
231
sshConsoleUser :: String
232
sshConsoleUser = AutoConf.sshConsoleUser
233

    
234
-- * Wipe
235

    
236
ddCmd :: String
237
ddCmd = "dd"
238

    
239
-- | 1GB
240
maxWipeChunk :: Int
241
maxWipeChunk = 1024
242

    
243
minWipeChunkPercent :: Int
244
minWipeChunkPercent = 10
245

    
246
-- * Directories
247

    
248
runDirsMode :: Int
249
runDirsMode = 0o775
250

    
251
secureDirMode :: Int
252
secureDirMode = 0o700
253

    
254
secureFileMode :: Int
255
secureFileMode = 0o600
256

    
257
adoptableBlockdevRoot :: String
258
adoptableBlockdevRoot = "/dev/disk/"
259

    
260
-- * 'autoconf' enable/disable
261

    
262
enableConfd :: Bool
263
enableConfd = AutoConf.enableConfd
264

    
265
enableMond :: Bool
266
enableMond = AutoConf.enableMond
267

    
268
enableRestrictedCommands :: Bool
269
enableRestrictedCommands = AutoConf.enableRestrictedCommands
270

    
271
enableSplitQuery :: Bool
272
enableSplitQuery = AutoConf.enableSplitQuery
273

    
274
-- * SSH constants
275

    
276
ssh :: String
277
ssh = "ssh"
278

    
279
scp :: String
280
scp = "scp"
281

    
282
-- * Daemons
283

    
284
confd :: String
285
confd = Runtime.daemonName GanetiConfd
286

    
287
masterd :: String
288
masterd = Runtime.daemonName GanetiMasterd
289

    
290
mond :: String
291
mond = Runtime.daemonName GanetiMond
292

    
293
noded :: String
294
noded = Runtime.daemonName GanetiNoded
295

    
296
luxid :: String
297
luxid = Runtime.daemonName GanetiLuxid
298

    
299
rapi :: String
300
rapi = Runtime.daemonName GanetiRapi
301

    
302
daemons :: FrozenSet String
303
daemons =
304
  ConstantUtils.mkSet [confd,
305
                       luxid,
306
                       masterd,
307
                       mond,
308
                       noded,
309
                       rapi]
310

    
311
defaultConfdPort :: Int
312
defaultConfdPort = 1814
313

    
314
defaultMondPort :: Int
315
defaultMondPort = 1815
316

    
317
defaultNodedPort :: Int
318
defaultNodedPort = 1811
319

    
320
defaultRapiPort :: Int
321
defaultRapiPort = 5080
322

    
323
daemonsPorts :: Map String (Protocol, Int)
324
daemonsPorts =
325
  Map.fromList [(confd, (Udp, defaultConfdPort)),
326
                (mond, (Tcp, defaultMondPort)),
327
                (noded, (Tcp, defaultNodedPort)),
328
                (rapi, (Tcp, defaultRapiPort)),
329
                (ssh, (Tcp, 22))]
330

    
331
firstDrbdPort :: Int
332
firstDrbdPort = 11000
333

    
334
lastDrbdPort :: Int
335
lastDrbdPort = 14999
336

    
337
daemonsLogbase :: Map String String
338
daemonsLogbase =
339
  Map.fromList
340
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
341

    
342
extraLogreasonAccess :: String
343
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
344

    
345
extraLogreasonError :: String
346
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
347

    
348
devConsole :: String
349
devConsole = ConstantUtils.devConsole
350

    
351
-- * Luxi (Local UniX Interface) related constants
352

    
353
luxiEom :: PythonChar
354
luxiEom = PythonChar '\x03'
355

    
356
-- | Environment variable for the luxi override socket
357
luxiOverride :: String
358
luxiOverride = "FORCE_LUXI_SOCKET"
359

    
360
luxiOverrideMaster :: String
361
luxiOverrideMaster = "master"
362

    
363
luxiOverrideQuery :: String
364
luxiOverrideQuery = "query"
365

    
366
luxiVersion :: Int
367
luxiVersion = configVersion
368

    
369
-- * Syslog
370

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

    
374
syslogNo :: String
375
syslogNo = Logging.syslogUsageToRaw SyslogNo
376

    
377
syslogYes :: String
378
syslogYes = Logging.syslogUsageToRaw SyslogYes
379

    
380
syslogOnly :: String
381
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
382

    
383
syslogSocket :: String
384
syslogSocket = "/dev/log"
385

    
386
-- * Xen
387

    
388
xenBootloader :: String
389
xenBootloader = AutoConf.xenBootloader
390

    
391
xenCmdXl :: String
392
xenCmdXl = "xl"
393

    
394
xenCmdXm :: String
395
xenCmdXm = "xm"
396

    
397
xenInitrd :: String
398
xenInitrd = AutoConf.xenInitrd
399

    
400
xenKernel :: String
401
xenKernel = AutoConf.xenKernel
402

    
403
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
404
-- other constants
405
knownXenCommands :: FrozenSet String
406
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
407

    
408
-- * KVM and socat
409

    
410
kvmPath :: String
411
kvmPath = AutoConf.kvmPath
412

    
413
kvmKernel :: String
414
kvmKernel = AutoConf.kvmKernel
415

    
416
socatEscapeCode :: String
417
socatEscapeCode = "0x1d"
418

    
419
socatPath :: String
420
socatPath = AutoConf.socatPath
421

    
422
socatUseCompress :: Bool
423
socatUseCompress = AutoConf.socatUseCompress
424

    
425
socatUseEscape :: Bool
426
socatUseEscape = AutoConf.socatUseEscape
427

    
428
-- * Storage types
429

    
430
stBlock :: String
431
stBlock = Types.storageTypeToRaw StorageBlock
432

    
433
stDiskless :: String
434
stDiskless = Types.storageTypeToRaw StorageDiskless
435

    
436
stExt :: String
437
stExt = Types.storageTypeToRaw StorageExt
438

    
439
stFile :: String
440
stFile = Types.storageTypeToRaw StorageFile
441

    
442
stLvmPv :: String
443
stLvmPv = Types.storageTypeToRaw StorageLvmPv
444

    
445
stLvmVg :: String
446
stLvmVg = Types.storageTypeToRaw StorageLvmVg
447

    
448
stRados :: String
449
stRados = Types.storageTypeToRaw StorageRados
450

    
451
storageTypes :: FrozenSet String
452
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
453

    
454
-- * Storage fields
455
-- ** First two are valid in LU context only, not passed to backend
456

    
457
sfNode :: String
458
sfNode = "node"
459

    
460
sfType :: String
461
sfType = "type"
462

    
463
-- ** and the rest are valid in backend
464

    
465
sfAllocatable :: String
466
sfAllocatable = Types.storageFieldToRaw SFAllocatable
467

    
468
sfFree :: String
469
sfFree = Types.storageFieldToRaw SFFree
470

    
471
sfName :: String
472
sfName = Types.storageFieldToRaw SFName
473

    
474
sfSize :: String
475
sfSize = Types.storageFieldToRaw SFSize
476

    
477
sfUsed :: String
478
sfUsed = Types.storageFieldToRaw SFUsed
479

    
480
-- * Local disk status
481

    
482
ldsFaulty :: Int
483
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
484

    
485
ldsOkay :: Int
486
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
487

    
488
ldsUnknown :: Int
489
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
490

    
491
ldsNames :: Map Int String
492
ldsNames =
493
  Map.fromList [ (Types.localDiskStatusToRaw ds,
494
                  localDiskStatusName ds) | ds <- [minBound..] ]
495

    
496
-- * Disk template types
497

    
498
dtDiskless :: String
499
dtDiskless = Types.diskTemplateToRaw DTDiskless
500

    
501
dtFile :: String
502
dtFile = Types.diskTemplateToRaw DTFile
503

    
504
dtSharedFile :: String
505
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
506

    
507
dtPlain :: String
508
dtPlain = Types.diskTemplateToRaw DTPlain
509

    
510
dtBlock :: String
511
dtBlock = Types.diskTemplateToRaw DTBlock
512

    
513
dtDrbd8 :: String
514
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
515

    
516
dtRbd :: String
517
dtRbd = Types.diskTemplateToRaw DTRbd
518

    
519
dtExt :: String
520
dtExt = Types.diskTemplateToRaw DTExt
521

    
522
-- | This is used to order determine the default disk template when
523
-- the list of enabled disk templates is inferred from the current
524
-- state of the cluster.  This only happens on an upgrade from a
525
-- version of Ganeti that did not support the 'enabled_disk_templates'
526
-- so far.
527
diskTemplatePreference :: [String]
528
diskTemplatePreference =
529
  map Types.diskTemplateToRaw
530
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile, DTPlain, DTRbd, DTSharedFile]
531

    
532
diskTemplates :: FrozenSet String
533
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
534

    
535
-- | Disk templates that are enabled by default
536
defaultEnabledDiskTemplates :: [String]
537
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
538

    
539
-- | The set of network-mirrored disk templates
540
dtsIntMirror :: FrozenSet String
541
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
542

    
543
-- | 'DTDiskless' is 'trivially' externally mirrored
544
dtsExtMirror :: FrozenSet String
545
dtsExtMirror =
546
  ConstantUtils.mkSet $
547
  map Types.diskTemplateToRaw [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd]
548

    
549
-- | The set of non-lvm-based disk templates
550
dtsNotLvm :: FrozenSet String
551
dtsNotLvm =
552
  ConstantUtils.mkSet $
553
  map Types.diskTemplateToRaw
554
  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd]
555

    
556
-- | The set of disk templates which can be grown
557
dtsGrowable :: FrozenSet String
558
dtsGrowable =
559
  ConstantUtils.mkSet $
560
  map Types.diskTemplateToRaw
561
  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd]
562

    
563
-- | The set of disk templates that allow adoption
564
dtsMayAdopt :: FrozenSet String
565
dtsMayAdopt =
566
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
567

    
568
-- | The set of disk templates that *must* use adoption
569
dtsMustAdopt :: FrozenSet String
570
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
571

    
572
-- | The set of disk templates that allow migrations
573
dtsMirrored :: FrozenSet String
574
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
575

    
576
-- | The set of file based disk templates
577
dtsFilebased :: FrozenSet String
578
dtsFilebased =
579
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTSharedFile, DTFile]
580

    
581
-- | The set of disk templates that can be moved by copying
582
--
583
-- Note: a requirement is that they're not accessed externally or
584
-- shared between nodes; in particular, sharedfile is not suitable.
585
dtsCopyable :: FrozenSet String
586
dtsCopyable =
587
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
588

    
589
-- | The set of disk templates that are supported by exclusive_storage
590
dtsExclStorage :: FrozenSet String
591
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
592

    
593
-- | Templates for which we don't perform checks on free space
594
dtsNoFreeSpaceCheck :: FrozenSet String
595
dtsNoFreeSpaceCheck =
596
  ConstantUtils.mkSet $
597
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd]
598

    
599
dtsBlock :: FrozenSet String
600
dtsBlock =
601
  ConstantUtils.mkSet $
602
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
603

    
604
-- * File backend driver
605

    
606
fdBlktap :: String
607
fdBlktap = Types.fileDriverToRaw FileBlktap
608

    
609
fdLoop :: String
610
fdLoop = Types.fileDriverToRaw FileLoop
611

    
612
fileDriver :: FrozenSet String
613
fileDriver =
614
  ConstantUtils.mkSet $
615
  map Types.fileDriverToRaw [minBound..]
616

    
617
-- | The set of drbd-like disk types
618
ldsDrbd :: FrozenSet String
619
ldsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
620

    
621
-- * Disk access mode
622

    
623
diskRdonly :: String
624
diskRdonly = Types.diskModeToRaw DiskRdOnly
625

    
626
diskRdwr :: String
627
diskRdwr = Types.diskModeToRaw DiskRdWr
628

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

    
632
-- * Disk replacement mode
633

    
634
replaceDiskAuto :: String
635
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
636

    
637
replaceDiskChg :: String
638
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
639

    
640
replaceDiskPri :: String
641
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
642

    
643
replaceDiskSec :: String
644
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
645

    
646
replaceModes :: FrozenSet String
647
replaceModes =
648
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
649

    
650
-- * Instance export mode
651

    
652
exportModeLocal :: String
653
exportModeLocal = Types.exportModeToRaw ExportModeLocal
654

    
655
exportModeRemote :: String
656
exportModeRemote = Types.exportModeToRaw ExportModeRemote
657

    
658
exportModes :: FrozenSet String
659
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
660

    
661
-- * Instance creation modes
662

    
663
instanceCreate :: String
664
instanceCreate = Types.instCreateModeToRaw InstCreate
665

    
666
instanceImport :: String
667
instanceImport = Types.instCreateModeToRaw InstImport
668

    
669
instanceRemoteImport :: String
670
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
671

    
672
instanceCreateModes :: FrozenSet String
673
instanceCreateModes =
674
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
675

    
676
-- * Dynamic device modification
677

    
678
ddmAdd :: String
679
ddmAdd = Types.ddmFullToRaw DdmFullAdd
680

    
681
ddmModify :: String
682
ddmModify = Types.ddmFullToRaw DdmFullModify
683

    
684
ddmRemove :: String
685
ddmRemove = Types.ddmFullToRaw DdmFullRemove
686

    
687
ddmsValues :: FrozenSet String
688
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
689

    
690
ddmsValuesWithModify :: FrozenSet String
691
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
692

    
693
-- * Common exit codes
694

    
695
exitSuccess :: Int
696
exitSuccess = 0
697

    
698
exitFailure :: Int
699
exitFailure = ConstantUtils.exitFailure
700

    
701
exitNotcluster :: Int
702
exitNotcluster = 5
703

    
704
exitNotmaster :: Int
705
exitNotmaster = 11
706

    
707
exitNodesetupError :: Int
708
exitNodesetupError = 12
709

    
710
-- | Need user confirmation
711
exitConfirmation :: Int
712
exitConfirmation = 13
713

    
714
-- | Exit code for query operations with unknown fields
715
exitUnknownField :: Int
716
exitUnknownField = 14
717

    
718
-- * Tags
719

    
720
tagCluster :: String
721
tagCluster = Types.tagKindToRaw TagKindCluster
722

    
723
tagInstance :: String
724
tagInstance = Types.tagKindToRaw TagKindInstance
725

    
726
tagNetwork :: String
727
tagNetwork = Types.tagKindToRaw TagKindNetwork
728

    
729
tagNode :: String
730
tagNode = Types.tagKindToRaw TagKindNode
731

    
732
tagNodegroup :: String
733
tagNodegroup = Types.tagKindToRaw TagKindGroup
734

    
735
validTagTypes :: FrozenSet String
736
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
737

    
738
maxTagLen :: Int
739
maxTagLen = 128
740

    
741
maxTagsPerObj :: Int
742
maxTagsPerObj = 4096
743

    
744
-- | Node clock skew in seconds
745
nodeMaxClockSkew :: Int
746
nodeMaxClockSkew = 150
747

    
748
-- | Disk index separator
749
diskSeparator :: String
750
diskSeparator = AutoConf.diskSeparator
751

    
752
-- * Timeout table
753
--
754
-- Various time constants for the timeout table
755

    
756
rpcTmoUrgent :: Int
757
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
758

    
759
rpcTmoFast :: Int
760
rpcTmoFast = Types.rpcTimeoutToRaw Fast
761

    
762
rpcTmoNormal :: Int
763
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
764

    
765
rpcTmoSlow :: Int
766
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
767

    
768
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
769
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
770
-- Python name.
771
rpcTmo_4hrs :: Int
772
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
773

    
774
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
775
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
776
-- Python name.
777
rpcTmo_1day :: Int
778
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
779

    
780
-- | Timeout for connecting to nodes (seconds)
781
rpcConnectTimeout :: Int
782
rpcConnectTimeout = 5
783

    
784
-- * VTypes
785

    
786
vtypeBool :: VType
787
vtypeBool = VTypeBool
788

    
789
vtypeInt :: VType
790
vtypeInt = VTypeInt
791

    
792
vtypeMaybeString :: VType
793
vtypeMaybeString = VTypeMaybeString
794

    
795
-- | Size in MiBs
796
vtypeSize :: VType
797
vtypeSize = VTypeSize
798

    
799
vtypeString :: VType
800
vtypeString = VTypeString
801

    
802
enforceableTypes :: FrozenSet VType
803
enforceableTypes = ConstantUtils.mkSet [minBound..]
804

    
805
-- | Instance specs
806
--
807
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
808

    
809
ispecMemSize :: String
810
ispecMemSize = ConstantUtils.ispecMemSize
811

    
812
ispecCpuCount :: String
813
ispecCpuCount = ConstantUtils.ispecCpuCount
814

    
815
ispecDiskCount :: String
816
ispecDiskCount = ConstantUtils.ispecDiskCount
817

    
818
ispecDiskSize :: String
819
ispecDiskSize = ConstantUtils.ispecDiskSize
820

    
821
ispecNicCount :: String
822
ispecNicCount = ConstantUtils.ispecNicCount
823

    
824
ispecSpindleUse :: String
825
ispecSpindleUse = ConstantUtils.ispecSpindleUse
826

    
827
ispecsParameterTypes :: Map String VType
828
ispecsParameterTypes =
829
  Map.fromList
830
  [(ConstantUtils.ispecDiskSize, VTypeInt),
831
   (ConstantUtils.ispecCpuCount, VTypeInt),
832
   (ConstantUtils.ispecSpindleUse, VTypeInt),
833
   (ConstantUtils.ispecMemSize, VTypeInt),
834
   (ConstantUtils.ispecNicCount, VTypeInt),
835
   (ConstantUtils.ispecDiskCount, VTypeInt)]
836

    
837
ispecsParameters :: FrozenSet String
838
ispecsParameters =
839
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
840
                       ConstantUtils.ispecDiskCount,
841
                       ConstantUtils.ispecDiskSize,
842
                       ConstantUtils.ispecMemSize,
843
                       ConstantUtils.ispecNicCount,
844
                       ConstantUtils.ispecSpindleUse]
845

    
846
ispecsMinmax :: String
847
ispecsMinmax = ConstantUtils.ispecsMinmax
848

    
849
ispecsMax :: String
850
ispecsMax = "max"
851

    
852
ispecsMin :: String
853
ispecsMin = "min"
854

    
855
ispecsStd :: String
856
ispecsStd = ConstantUtils.ispecsStd
857

    
858
ipolicyDts :: String
859
ipolicyDts = ConstantUtils.ipolicyDts
860

    
861
ipolicyVcpuRatio :: String
862
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
863

    
864
ipolicySpindleRatio :: String
865
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
866

    
867
ispecsMinmaxKeys :: FrozenSet String
868
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
869

    
870
ipolicyParameters :: FrozenSet String
871
ipolicyParameters =
872
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
873
                       ConstantUtils.ipolicySpindleRatio]
874

    
875
ipolicyAllKeys :: FrozenSet String
876
ipolicyAllKeys =
877
  ConstantUtils.union ipolicyParameters $
878
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
879
                       ConstantUtils.ispecsMinmax,
880
                       ispecsStd]
881

    
882
-- | Node parameter names
883

    
884
ndExclusiveStorage :: String
885
ndExclusiveStorage = "exclusive_storage"
886

    
887
ndOobProgram :: String
888
ndOobProgram = "oob_program"
889

    
890
ndSpindleCount :: String
891
ndSpindleCount = "spindle_count"
892

    
893
ndOvs :: String
894
ndOvs = "ovs"
895

    
896
ndOvsLink :: String
897
ndOvsLink = "ovs_link"
898

    
899
ndOvsName :: String
900
ndOvsName = "ovs_name"
901

    
902
ndsParameterTypes :: Map String VType
903
ndsParameterTypes =
904
  Map.fromList
905
  [(ndExclusiveStorage, VTypeBool),
906
   (ndOobProgram, VTypeString),
907
   (ndOvs, VTypeBool),
908
   (ndOvsLink, VTypeMaybeString),
909
   (ndOvsName, VTypeMaybeString),
910
   (ndSpindleCount, VTypeInt)]
911

    
912
ndsParameters :: FrozenSet String
913
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
914

    
915
ndsParameterTitles :: Map String String
916
ndsParameterTitles =
917
  Map.fromList
918
  [(ndExclusiveStorage, "ExclusiveStorage"),
919
   (ndOobProgram, "OutOfBandProgram"),
920
   (ndOvs, "OpenvSwitch"),
921
   (ndOvsLink, "OpenvSwitchLink"),
922
   (ndOvsName, "OpenvSwitchName"),
923
   (ndSpindleCount, "SpindleCount")]
924

    
925
ipCommandPath :: String
926
ipCommandPath = AutoConf.ipPath
927

    
928
-- * Reboot types
929

    
930
instanceRebootSoft :: String
931
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
932

    
933
instanceRebootHard :: String
934
instanceRebootHard = Types.rebootTypeToRaw RebootHard
935

    
936
instanceRebootFull :: String
937
instanceRebootFull = Types.rebootTypeToRaw RebootFull
938

    
939
rebootTypes :: FrozenSet String
940
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
941

    
942

    
943

    
944

    
945

    
946

    
947

    
948

    
949
-- * OOB supported commands
950

    
951
oobPowerOn :: String
952
oobPowerOn = Types.oobCommandToRaw OobPowerOn
953

    
954
oobPowerOff :: String
955
oobPowerOff = Types.oobCommandToRaw OobPowerOff
956

    
957
oobPowerCycle :: String
958
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
959

    
960
oobPowerStatus :: String
961
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
962

    
963
oobHealth :: String
964
oobHealth = Types.oobCommandToRaw OobHealth
965

    
966
oobCommands :: FrozenSet String
967
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
968

    
969
oobPowerStatusPowered :: String
970
oobPowerStatusPowered = "powered"
971

    
972
-- | 60 seconds
973
oobTimeout :: Int
974
oobTimeout = 60
975

    
976
-- | 2 seconds
977
oobPowerDelay :: Double
978
oobPowerDelay = 2.0
979

    
980
oobStatusCritical :: String
981
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
982

    
983
oobStatusOk :: String
984
oobStatusOk = Types.oobStatusToRaw OobStatusOk
985

    
986
oobStatusUnknown :: String
987
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
988

    
989
oobStatusWarning :: String
990
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
991

    
992
oobStatuses :: FrozenSet String
993
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
994

    
995
-- * NIC_* constants are used inside the ganeti config
996

    
997
nicLink :: String
998
nicLink = "link"
999

    
1000
nicMode :: String
1001
nicMode = "mode"
1002

    
1003
nicVlan :: String
1004
nicVlan = "vlan"
1005

    
1006
nicModeBridged :: String
1007
nicModeBridged = Types.nICModeToRaw NMBridged
1008

    
1009
nicModeRouted :: String
1010
nicModeRouted = Types.nICModeToRaw NMRouted
1011

    
1012
nicModeOvs :: String
1013
nicModeOvs = Types.nICModeToRaw NMOvs
1014

    
1015
nicIpPool :: String
1016
nicIpPool = Types.nICModeToRaw NMPool
1017

    
1018
nicValidModes :: FrozenSet String
1019
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
1020

    
1021
-- * Hypervisor constants
1022

    
1023
htXenPvm :: String
1024
htXenPvm = Types.hypervisorToRaw XenPvm
1025

    
1026
htFake :: String
1027
htFake = Types.hypervisorToRaw Fake
1028

    
1029
htXenHvm :: String
1030
htXenHvm = Types.hypervisorToRaw XenHvm
1031

    
1032
htKvm :: String
1033
htKvm = Types.hypervisorToRaw Kvm
1034

    
1035
htChroot :: String
1036
htChroot = Types.hypervisorToRaw Chroot
1037

    
1038
htLxc :: String
1039
htLxc = Types.hypervisorToRaw Lxc
1040

    
1041
hyperTypes :: FrozenSet String
1042
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
1043

    
1044
htsReqPort :: FrozenSet String
1045
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
1046

    
1047
-- * Migration type
1048

    
1049
htMigrationLive :: String
1050
htMigrationLive = Types.migrationModeToRaw MigrationLive
1051

    
1052
htMigrationNonlive :: String
1053
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
1054

    
1055
htMigrationModes :: FrozenSet String
1056
htMigrationModes =
1057
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
1058

    
1059
-- * Cluster verify steps
1060

    
1061
verifyNplusoneMem :: String
1062
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
1063

    
1064
verifyOptionalChecks :: FrozenSet String
1065
verifyOptionalChecks =
1066
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
1067

    
1068
-- * Cluster Verify error classes
1069

    
1070
cvTcluster :: String
1071
cvTcluster = "cluster"
1072

    
1073
cvTgroup :: String
1074
cvTgroup = "group"
1075

    
1076
cvTnode :: String
1077
cvTnode = "node"
1078

    
1079
cvTinstance :: String
1080
cvTinstance = "instance"
1081

    
1082
-- * Cluster Verify error codes and documentation
1083

    
1084
cvEclustercert :: (String, String, String)
1085
cvEclustercert =
1086
  ("cluster",
1087
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
1088
   "Cluster certificate files verification failure")
1089

    
1090
cvEclustercfg :: (String, String, String)
1091
cvEclustercfg =
1092
  ("cluster",
1093
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
1094
   "Cluster configuration verification failure")
1095

    
1096
cvEclusterdanglinginst :: (String, String, String)
1097
cvEclusterdanglinginst =
1098
  ("node",
1099
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
1100
   "Some instances have a non-existing primary node")
1101

    
1102
cvEclusterdanglingnodes :: (String, String, String)
1103
cvEclusterdanglingnodes =
1104
  ("node",
1105
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
1106
   "Some nodes belong to non-existing groups")
1107

    
1108
cvEclusterfilecheck :: (String, String, String)
1109
cvEclusterfilecheck =
1110
  ("cluster",
1111
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
1112
   "Cluster configuration verification failure")
1113

    
1114
cvEgroupdifferentpvsize :: (String, String, String)
1115
cvEgroupdifferentpvsize =
1116
  ("group",
1117
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
1118
   "PVs in the group have different sizes")
1119

    
1120
cvEinstancebadnode :: (String, String, String)
1121
cvEinstancebadnode =
1122
  ("instance",
1123
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
1124
   "Instance marked as running lives on an offline node")
1125

    
1126
cvEinstancedown :: (String, String, String)
1127
cvEinstancedown =
1128
  ("instance",
1129
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
1130
   "Instance not running on its primary node")
1131

    
1132
cvEinstancefaultydisk :: (String, String, String)
1133
cvEinstancefaultydisk =
1134
  ("instance",
1135
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
1136
   "Impossible to retrieve status for a disk")
1137

    
1138
cvEinstancelayout :: (String, String, String)
1139
cvEinstancelayout =
1140
  ("instance",
1141
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
1142
   "Instance has multiple secondary nodes")
1143

    
1144
cvEinstancemissingcfgparameter :: (String, String, String)
1145
cvEinstancemissingcfgparameter =
1146
  ("instance",
1147
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
1148
   "A configuration parameter for an instance is missing")
1149

    
1150
cvEinstancemissingdisk :: (String, String, String)
1151
cvEinstancemissingdisk =
1152
  ("instance",
1153
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
1154
   "Missing volume on an instance")
1155

    
1156
cvEinstancepolicy :: (String, String, String)
1157
cvEinstancepolicy =
1158
  ("instance",
1159
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
1160
   "Instance does not meet policy")
1161

    
1162
cvEinstancesplitgroups :: (String, String, String)
1163
cvEinstancesplitgroups =
1164
  ("instance",
1165
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
1166
   "Instance with primary and secondary nodes in different groups")
1167

    
1168
cvEinstanceunsuitablenode :: (String, String, String)
1169
cvEinstanceunsuitablenode =
1170
  ("instance",
1171
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
1172
   "Instance running on nodes that are not suitable for it")
1173

    
1174
cvEinstancewrongnode :: (String, String, String)
1175
cvEinstancewrongnode =
1176
  ("instance",
1177
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
1178
   "Instance running on the wrong node")
1179

    
1180
cvEnodedrbd :: (String, String, String)
1181
cvEnodedrbd =
1182
  ("node",
1183
   Types.cVErrorCodeToRaw CvENODEDRBD,
1184
   "Error parsing the DRBD status file")
1185

    
1186
cvEnodedrbdhelper :: (String, String, String)
1187
cvEnodedrbdhelper =
1188
  ("node",
1189
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
1190
   "Error caused by the DRBD helper")
1191

    
1192
cvEnodedrbdversion :: (String, String, String)
1193
cvEnodedrbdversion =
1194
  ("node",
1195
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
1196
   "DRBD version mismatch within a node group")
1197

    
1198
cvEnodefilecheck :: (String, String, String)
1199
cvEnodefilecheck =
1200
  ("node",
1201
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
1202
   "Error retrieving the checksum of the node files")
1203

    
1204
cvEnodefilestoragepaths :: (String, String, String)
1205
cvEnodefilestoragepaths =
1206
  ("node",
1207
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
1208
   "Detected bad file storage paths")
1209

    
1210
cvEnodefilestoragepathunusable :: (String, String, String)
1211
cvEnodefilestoragepathunusable =
1212
  ("node",
1213
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
1214
   "File storage path unusable")
1215

    
1216
cvEnodehooks :: (String, String, String)
1217
cvEnodehooks =
1218
  ("node",
1219
   Types.cVErrorCodeToRaw CvENODEHOOKS,
1220
   "Communication failure in hooks execution")
1221

    
1222
cvEnodehv :: (String, String, String)
1223
cvEnodehv =
1224
  ("node",
1225
   Types.cVErrorCodeToRaw CvENODEHV,
1226
   "Hypervisor parameters verification failure")
1227

    
1228
cvEnodelvm :: (String, String, String)
1229
cvEnodelvm =
1230
  ("node",
1231
   Types.cVErrorCodeToRaw CvENODELVM,
1232
   "LVM-related node error")
1233

    
1234
cvEnoden1 :: (String, String, String)
1235
cvEnoden1 =
1236
  ("node",
1237
   Types.cVErrorCodeToRaw CvENODEN1,
1238
   "Not enough memory to accommodate instance failovers")
1239

    
1240
cvEnodenet :: (String, String, String)
1241
cvEnodenet =
1242
  ("node",
1243
   Types.cVErrorCodeToRaw CvENODENET,
1244
   "Network-related node error")
1245

    
1246
cvEnodeoobpath :: (String, String, String)
1247
cvEnodeoobpath =
1248
  ("node",
1249
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
1250
   "Invalid Out Of Band path")
1251

    
1252
cvEnodeorphaninstance :: (String, String, String)
1253
cvEnodeorphaninstance =
1254
  ("node",
1255
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
1256
   "Unknown intance running on a node")
1257

    
1258
cvEnodeorphanlv :: (String, String, String)
1259
cvEnodeorphanlv =
1260
  ("node",
1261
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
1262
   "Unknown LVM logical volume")
1263

    
1264
cvEnodeos :: (String, String, String)
1265
cvEnodeos =
1266
  ("node",
1267
   Types.cVErrorCodeToRaw CvENODEOS,
1268
   "OS-related node error")
1269

    
1270
cvEnoderpc :: (String, String, String)
1271
cvEnoderpc =
1272
  ("node",
1273
   Types.cVErrorCodeToRaw CvENODERPC,
1274
   "Error during connection to the primary node of an instance")
1275

    
1276
cvEnodesetup :: (String, String, String)
1277
cvEnodesetup =
1278
  ("node",
1279
   Types.cVErrorCodeToRaw CvENODESETUP,
1280
   "Node setup error")
1281

    
1282
cvEnodesharedfilestoragepathunusable :: (String, String, String)
1283
cvEnodesharedfilestoragepathunusable =
1284
  ("node",
1285
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
1286
   "Shared file storage path unusable")
1287

    
1288
cvEnodessh :: (String, String, String)
1289
cvEnodessh =
1290
  ("node",
1291
   Types.cVErrorCodeToRaw CvENODESSH,
1292
   "SSH-related node error")
1293

    
1294
cvEnodetime :: (String, String, String)
1295
cvEnodetime =
1296
  ("node",
1297
   Types.cVErrorCodeToRaw CvENODETIME,
1298
   "Node returned invalid time")
1299

    
1300
cvEnodeuserscripts :: (String, String, String)
1301
cvEnodeuserscripts =
1302
  ("node",
1303
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
1304
   "User scripts not present or not executable")
1305

    
1306
cvEnodeversion :: (String, String, String)
1307
cvEnodeversion =
1308
  ("node",
1309
   Types.cVErrorCodeToRaw CvENODEVERSION,
1310
   "Protocol version mismatch or Ganeti version mismatch")
1311

    
1312
cvAllEcodes :: FrozenSet (String, String, String)
1313
cvAllEcodes =
1314
  ConstantUtils.mkSet
1315
  [cvEclustercert,
1316
   cvEclustercfg,
1317
   cvEclusterdanglinginst,
1318
   cvEclusterdanglingnodes,
1319
   cvEclusterfilecheck,
1320
   cvEgroupdifferentpvsize,
1321
   cvEinstancebadnode,
1322
   cvEinstancedown,
1323
   cvEinstancefaultydisk,
1324
   cvEinstancelayout,
1325
   cvEinstancemissingcfgparameter,
1326
   cvEinstancemissingdisk,
1327
   cvEinstancepolicy,
1328
   cvEinstancesplitgroups,
1329
   cvEinstanceunsuitablenode,
1330
   cvEinstancewrongnode,
1331
   cvEnodedrbd,
1332
   cvEnodedrbdhelper,
1333
   cvEnodedrbdversion,
1334
   cvEnodefilecheck,
1335
   cvEnodefilestoragepaths,
1336
   cvEnodefilestoragepathunusable,
1337
   cvEnodehooks,
1338
   cvEnodehv,
1339
   cvEnodelvm,
1340
   cvEnoden1,
1341
   cvEnodenet,
1342
   cvEnodeoobpath,
1343
   cvEnodeorphaninstance,
1344
   cvEnodeorphanlv,
1345
   cvEnodeos,
1346
   cvEnoderpc,
1347
   cvEnodesetup,
1348
   cvEnodesharedfilestoragepathunusable,
1349
   cvEnodessh,
1350
   cvEnodetime,
1351
   cvEnodeuserscripts,
1352
   cvEnodeversion]
1353

    
1354
cvAllEcodesStrings :: FrozenSet String
1355
cvAllEcodesStrings =
1356
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
1357

    
1358
-- * Instance status
1359

    
1360
inststAdmindown :: String
1361
inststAdmindown = Types.instanceStatusToRaw StatusDown
1362

    
1363
inststAdminoffline :: String
1364
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
1365

    
1366
inststErrordown :: String
1367
inststErrordown = Types.instanceStatusToRaw ErrorDown
1368

    
1369
inststErrorup :: String
1370
inststErrorup = Types.instanceStatusToRaw ErrorUp
1371

    
1372
inststNodedown :: String
1373
inststNodedown = Types.instanceStatusToRaw NodeDown
1374

    
1375
inststNodeoffline :: String
1376
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
1377

    
1378
inststRunning :: String
1379
inststRunning = Types.instanceStatusToRaw Running
1380

    
1381
inststWrongnode :: String
1382
inststWrongnode = Types.instanceStatusToRaw WrongNode
1383

    
1384
inststAll :: FrozenSet String
1385
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
1386

    
1387
-- * Admin states
1388

    
1389
adminstDown :: String
1390
adminstDown = Types.adminStateToRaw AdminDown
1391

    
1392
adminstOffline :: String
1393
adminstOffline = Types.adminStateToRaw AdminOffline
1394

    
1395
adminstUp :: String
1396
adminstUp = Types.adminStateToRaw AdminUp
1397

    
1398
adminstAll :: FrozenSet String
1399
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
1400

    
1401
-- * Node roles
1402

    
1403
nrDrained :: String
1404
nrDrained = Types.nodeRoleToRaw NRDrained
1405

    
1406
nrMaster :: String
1407
nrMaster = Types.nodeRoleToRaw NRMaster
1408

    
1409
nrMcandidate :: String
1410
nrMcandidate = Types.nodeRoleToRaw NRCandidate
1411

    
1412
nrOffline :: String
1413
nrOffline = Types.nodeRoleToRaw NROffline
1414

    
1415
nrRegular :: String
1416
nrRegular = Types.nodeRoleToRaw NRRegular
1417

    
1418
nrAll :: FrozenSet String
1419
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
1420

    
1421
-- * Allocator framework constants
1422

    
1423
iallocatorVersion :: Int
1424
iallocatorVersion = 2
1425

    
1426
iallocatorDirIn :: String
1427
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
1428

    
1429
iallocatorDirOut :: String
1430
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
1431

    
1432
validIallocatorDirections :: FrozenSet String
1433
validIallocatorDirections =
1434
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
1435

    
1436
iallocatorModeAlloc :: String
1437
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
1438

    
1439
iallocatorModeChgGroup :: String
1440
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
1441

    
1442
iallocatorModeMultiAlloc :: String
1443
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
1444

    
1445
iallocatorModeNodeEvac :: String
1446
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
1447

    
1448
iallocatorModeReloc :: String
1449
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
1450

    
1451
validIallocatorModes :: FrozenSet String
1452
validIallocatorModes =
1453
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
1454

    
1455
iallocatorSearchPath :: [String]
1456
iallocatorSearchPath = AutoConf.iallocatorSearchPath
1457

    
1458
defaultIallocatorShortcut :: String
1459
defaultIallocatorShortcut = "."
1460

    
1461
-- * Node evacuation
1462

    
1463
nodeEvacPri :: String
1464
nodeEvacPri = Types.evacModeToRaw ChangePrimary
1465

    
1466
nodeEvacSec :: String
1467
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
1468

    
1469
nodeEvacAll :: String
1470
nodeEvacAll = Types.evacModeToRaw ChangeAll
1471

    
1472
nodeEvacModes :: FrozenSet String
1473
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
1474

    
1475
-- * Job status
1476

    
1477
jobStatusQueued :: String
1478
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
1479

    
1480
jobStatusWaiting :: String
1481
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
1482

    
1483
jobStatusCanceling :: String
1484
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
1485

    
1486
jobStatusRunning :: String
1487
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
1488

    
1489
jobStatusCanceled :: String
1490
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
1491

    
1492
jobStatusSuccess :: String
1493
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
1494

    
1495
jobStatusError :: String
1496
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
1497

    
1498
jobsPending :: FrozenSet String
1499
jobsPending =
1500
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
1501

    
1502
jobsFinalized :: FrozenSet String
1503
jobsFinalized =
1504
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
1505

    
1506
jobStatusAll :: FrozenSet String
1507
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
1508

    
1509
-- * OpCode status
1510

    
1511
-- ** Not yet finalized opcodes
1512

    
1513
opStatusCanceling :: String
1514
opStatusCanceling = "canceling"
1515

    
1516
opStatusQueued :: String
1517
opStatusQueued = "queued"
1518

    
1519
opStatusRunning :: String
1520
opStatusRunning = "running"
1521

    
1522
opStatusWaiting :: String
1523
opStatusWaiting = "waiting"
1524

    
1525
-- ** Finalized opcodes
1526

    
1527
opStatusCanceled :: String
1528
opStatusCanceled = "canceled"
1529

    
1530
opStatusError :: String
1531
opStatusError = "error"
1532

    
1533
opStatusSuccess :: String
1534
opStatusSuccess = "success"
1535

    
1536
opsFinalized :: FrozenSet String
1537
opsFinalized =
1538
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
1539

    
1540
-- * OpCode priority
1541

    
1542
opPrioLowest :: Int
1543
opPrioLowest = 19
1544

    
1545
opPrioHighest :: Int
1546
opPrioHighest = -20
1547

    
1548
opPrioLow :: Int
1549
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
1550

    
1551
opPrioNormal :: Int
1552
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
1553

    
1554
opPrioHigh :: Int
1555
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
1556

    
1557
opPrioSubmitValid :: FrozenSet Int
1558
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
1559

    
1560
opPrioDefault :: Int
1561
opPrioDefault = opPrioNormal
1562

    
1563
-- * Execution log types
1564

    
1565
elogMessage :: String
1566
elogMessage = Types.eLogTypeToRaw ELogMessage
1567

    
1568
elogRemoteImport :: String
1569
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
1570

    
1571
elogJqueueTest :: String
1572
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
1573

    
1574
-- * Confd
1575

    
1576
confdProtocolVersion :: Int
1577
confdProtocolVersion = ConstantUtils.confdProtocolVersion
1578

    
1579
-- Confd request type
1580

    
1581
confdReqPing :: Int
1582
confdReqPing = Types.confdRequestTypeToRaw ReqPing
1583

    
1584
confdReqNodeRoleByname :: Int
1585
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
1586

    
1587
confdReqNodePipByInstanceIp :: Int
1588
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
1589

    
1590
confdReqClusterMaster :: Int
1591
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
1592

    
1593
confdReqNodePipList :: Int
1594
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
1595

    
1596
confdReqMcPipList :: Int
1597
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
1598

    
1599
confdReqInstancesIpsList :: Int
1600
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
1601

    
1602
confdReqNodeDrbd :: Int
1603
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
1604

    
1605
confdReqNodeInstances :: Int
1606
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
1607

    
1608
confdReqs :: FrozenSet Int
1609
confdReqs =
1610
  ConstantUtils.mkSet .
1611
  map Types.confdRequestTypeToRaw $
1612
  [minBound..] \\ [ReqNodeInstances]
1613

    
1614
-- * Confd request type
1615

    
1616
confdReqfieldName :: Int
1617
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
1618

    
1619
confdReqfieldIp :: Int
1620
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
1621

    
1622
confdReqfieldMnodePip :: Int
1623
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
1624

    
1625
-- * Confd repl status
1626

    
1627
confdReplStatusOk :: Int
1628
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
1629

    
1630
confdReplStatusError :: Int
1631
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
1632

    
1633
confdReplStatusNotimplemented :: Int
1634
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
1635

    
1636
confdReplStatuses :: FrozenSet Int
1637
confdReplStatuses =
1638
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
1639

    
1640
-- * Confd node role
1641

    
1642
confdNodeRoleMaster :: Int
1643
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
1644

    
1645
confdNodeRoleCandidate :: Int
1646
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
1647

    
1648
confdNodeRoleOffline :: Int
1649
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
1650

    
1651
confdNodeRoleDrained :: Int
1652
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
1653

    
1654
confdNodeRoleRegular :: Int
1655
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
1656

    
1657
-- * A few common errors for confd
1658

    
1659
confdErrorUnknownEntry :: Int
1660
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
1661

    
1662
confdErrorInternal :: Int
1663
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
1664

    
1665
confdErrorArgument :: Int
1666
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
1667

    
1668
-- * Confd request query fields
1669

    
1670
confdReqqLink :: String
1671
confdReqqLink = ConstantUtils.confdReqqLink
1672

    
1673
confdReqqIp :: String
1674
confdReqqIp = ConstantUtils.confdReqqIp
1675

    
1676
confdReqqIplist :: String
1677
confdReqqIplist = ConstantUtils.confdReqqIplist
1678

    
1679
confdReqqFields :: String
1680
confdReqqFields = ConstantUtils.confdReqqFields
1681

    
1682
-- | Each request is "salted" by the current timestamp.
1683
--
1684
-- This constant decides how many seconds of skew to accept.
1685
--
1686
-- TODO: make this a default and allow the value to be more
1687
-- configurable
1688
confdMaxClockSkew :: Int
1689
confdMaxClockSkew = 2 * nodeMaxClockSkew
1690

    
1691
-- | When we haven't reloaded the config for more than this amount of
1692
-- seconds, we force a test to see if inotify is betraying us. Using a
1693
-- prime number to ensure we get less chance of 'same wakeup' with
1694
-- other processes.
1695
confdConfigReloadTimeout :: Int
1696
confdConfigReloadTimeout = 17
1697

    
1698
-- | If we receive more than one update in this amount of
1699
-- microseconds, we move to polling every RATELIMIT seconds, rather
1700
-- than relying on inotify, to be able to serve more requests.
1701
confdConfigReloadRatelimit :: Int
1702
confdConfigReloadRatelimit = 250000
1703

    
1704
-- | Magic number prepended to all confd queries.
1705
--
1706
-- This allows us to distinguish different types of confd protocols
1707
-- and handle them. For example by changing this we can move the whole
1708
-- payload to be compressed, or move away from json.
1709
confdMagicFourcc :: String
1710
confdMagicFourcc = "plj0"
1711

    
1712
-- | By default a confd request is sent to the minimum between this
1713
-- number and all MCs. 6 was chosen because even in the case of a
1714
-- disastrous 50% response rate, we should have enough answers to be
1715
-- able to compare more than one.
1716
confdDefaultReqCoverage :: Int
1717
confdDefaultReqCoverage = 6
1718

    
1719
-- | Timeout in seconds to expire pending query request in the confd
1720
-- client library. We don't actually expect any answer more than 10
1721
-- seconds after we sent a request.
1722
confdClientExpireTimeout :: Int
1723
confdClientExpireTimeout = 10
1724

    
1725
-- * Possible values for NodeGroup.alloc_policy
1726

    
1727
allocPolicyLastResort :: String
1728
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
1729

    
1730
allocPolicyPreferred :: String
1731
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
1732

    
1733
allocPolicyUnallocable :: String
1734
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
1735

    
1736
validAllocPolicies :: [String]
1737
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
1738

    
1739
-- | Temporary external/shared storage parameters
1740
blockdevDriverManual :: String
1741
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
1742

    
1743
-- | 'qemu-img' path, required for 'ovfconverter'
1744
qemuimgPath :: String
1745
qemuimgPath = AutoConf.qemuimgPath
1746

    
1747
-- | Whether htools was enabled at compilation time
1748
--
1749
-- FIXME: this should be moved next to the other enable constants,
1750
-- such as, 'enableConfd', and renamed to 'enableHtools'.
1751
htools :: Bool
1752
htools = AutoConf.htools
1753

    
1754
-- * Key files for SSH daemon
1755

    
1756
sshHostDsaPriv :: String
1757
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
1758

    
1759
sshHostDsaPub :: String
1760
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
1761

    
1762
sshHostRsaPriv :: String
1763
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
1764

    
1765
sshHostRsaPub :: String
1766
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
1767

    
1768
-- | Path generating random UUID
1769
randomUuidFile :: String
1770
randomUuidFile = ConstantUtils.randomUuidFile
1771

    
1772
-- * Auto-repair tag prefixes
1773

    
1774
autoRepairTagPrefix :: String
1775
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
1776

    
1777
autoRepairTagEnabled :: String
1778
autoRepairTagEnabled = autoRepairTagPrefix
1779

    
1780
autoRepairTagPending :: String
1781
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
1782

    
1783
autoRepairTagResult :: String
1784
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
1785

    
1786
autoRepairTagSuspended :: String
1787
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
1788

    
1789
-- * Auto-repair levels
1790

    
1791
autoRepairFailover :: String
1792
autoRepairFailover = "failover"
1793

    
1794
autoRepairFixStorage :: String
1795
autoRepairFixStorage = "fix-storage"
1796

    
1797
autoRepairMigrate :: String
1798
autoRepairMigrate = "migrate"
1799

    
1800
autoRepairReinstall :: String
1801
autoRepairReinstall = "reinstall"
1802

    
1803
autoRepairAllTypes :: FrozenSet String
1804
autoRepairAllTypes =
1805
  ConstantUtils.mkSet [autoRepairFailover,
1806
                       autoRepairFixStorage,
1807
                       autoRepairMigrate,
1808
                       autoRepairReinstall]
1809

    
1810
-- * Auto-repair results
1811

    
1812
autoRepairEnoperm :: String
1813
autoRepairEnoperm = "enoperm"
1814

    
1815
autoRepairFailure :: String
1816
autoRepairFailure = "failure"
1817

    
1818
autoRepairSuccess :: String
1819
autoRepairSuccess = "success"
1820

    
1821
autoRepairAllResults :: FrozenSet String
1822
autoRepairAllResults =
1823
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
1824

    
1825
-- | The version identifier for builtin data collectors
1826
builtinDataCollectorVersion :: String
1827
builtinDataCollectorVersion = "B"
1828

    
1829
-- | The reason trail opcode parameter name
1830
opcodeReason :: String
1831
opcodeReason = "reason"
1832

    
1833
diskstatsFile :: String
1834
diskstatsFile = "/proc/diskstats"
1835

    
1836
-- *  CPU load collector
1837

    
1838
statFile :: String
1839
statFile = "/proc/stat"
1840

    
1841
cpuavgloadBufferSize :: Int
1842
cpuavgloadBufferSize = 150
1843

    
1844
cpuavgloadWindowSize :: Int
1845
cpuavgloadWindowSize = 600
1846

    
1847
-- | Mond's variable for periodical data collection
1848
mondTimeInterval :: Int
1849
mondTimeInterval = 5
1850

    
1851
-- * Disk access modes
1852

    
1853
diskUserspace :: String
1854
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
1855

    
1856
diskKernelspace :: String
1857
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
1858

    
1859
diskValidAccessModes :: FrozenSet String
1860
diskValidAccessModes =
1861
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
1862

    
1863
-- | Timeout for queue draining in upgrades
1864
upgradeQueueDrainTimeout :: Int
1865
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
1866

    
1867
-- | Intervall at which the queue is polled during upgrades
1868
upgradeQueuePollInterval :: Int
1869
upgradeQueuePollInterval  = 10