Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ ad6f2bf3

History | View | Annotate | Download (43.6 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 (FrozenSet, Protocol(..), buildVersion)
45
import qualified Ganeti.ConstantUtils as ConstantUtils
46
import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..),
47
                       ExtraLogReason(..))
48
import Ganeti.HTools.Types (AutoRepairResult(..), AutoRepairType(..))
49
import qualified Ganeti.HTools.Types as Types
50
import Ganeti.Logging (SyslogUsage(..))
51
import qualified Ganeti.Logging as Logging (syslogUsageToRaw)
52
import qualified Ganeti.Runtime as Runtime
53
import Ganeti.Types
54
import qualified Ganeti.Types as Types
55
import Ganeti.Confd.Types (ConfdRequestType(..), ConfdReqField(..),
56
                           ConfdReplyStatus(..), ConfdNodeRole(..),
57
                           ConfdErrorType(..))
58
import qualified Ganeti.Confd.Types as Types
59

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

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

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

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

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

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

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

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

    
80
-- ** Build-time constants
81

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
129
-- * Various versions
130

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

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

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

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

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

    
146
osApiV10 :: Int
147
osApiV10 = 10
148

    
149
osApiV15 :: Int
150
osApiV15 = 15
151

    
152
osApiV20 :: Int
153
osApiV20 = 20
154

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

    
158
configMajor :: Int
159
configMajor = AutoConf.versionMajor
160

    
161
configMinor :: Int
162
configMinor = AutoConf.versionMinor
163

    
164
-- | The configuration is supposed to remain stable across
165
-- revisions. Therefore, the revision number is cleared to '0'.
166
configRevision :: Int
167
configRevision = 0
168

    
169
configVersion :: Int
170
configVersion = buildVersion configMajor configMinor configRevision
171

    
172
-- | Similarly to the configuration (see 'configRevision'), the
173
-- protocols are supposed to remain stable across revisions.
174
protocolVersion :: Int
175
protocolVersion = buildVersion configMajor configMinor configRevision
176

    
177
-- * User separation
178

    
179
daemonsGroup :: String
180
daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
181

    
182
adminGroup :: String
183
adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
184

    
185
masterdUser :: String
186
masterdUser = Runtime.daemonUser GanetiMasterd
187

    
188
masterdGroup :: String
189
masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
190

    
191
rapiUser :: String
192
rapiUser = Runtime.daemonUser GanetiRapi
193

    
194
rapiGroup :: String
195
rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
196

    
197
confdUser :: String
198
confdUser = Runtime.daemonUser GanetiConfd
199

    
200
confdGroup :: String
201
confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
202

    
203
luxidUser :: String
204
luxidUser = Runtime.daemonUser GanetiLuxid
205

    
206
luxidGroup :: String
207
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
208

    
209
nodedUser :: String
210
nodedUser = Runtime.daemonUser GanetiNoded
211

    
212
nodedGroup :: String
213
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
214

    
215
mondUser :: String
216
mondUser = Runtime.daemonUser GanetiMond
217

    
218
mondGroup :: String
219
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
220

    
221
sshLoginUser :: String
222
sshLoginUser = AutoConf.sshLoginUser
223

    
224
sshConsoleUser :: String
225
sshConsoleUser = AutoConf.sshConsoleUser
226

    
227
-- * Wipe
228

    
229
ddCmd :: String
230
ddCmd = "dd"
231

    
232
-- | 1GB
233
maxWipeChunk :: Int
234
maxWipeChunk = 1024
235

    
236
minWipeChunkPercent :: Int
237
minWipeChunkPercent = 10
238

    
239
-- * Directories
240

    
241
runDirsMode :: Int
242
runDirsMode = 0o775
243

    
244
secureDirMode :: Int
245
secureDirMode = 0o700
246

    
247
secureFileMode :: Int
248
secureFileMode = 0o600
249

    
250
adoptableBlockdevRoot :: String
251
adoptableBlockdevRoot = "/dev/disk/"
252

    
253
-- * 'autoconf' enable/disable
254

    
255
enableConfd :: Bool
256
enableConfd = AutoConf.enableConfd
257

    
258
enableMond :: Bool
259
enableMond = AutoConf.enableMond
260

    
261
enableRestrictedCommands :: Bool
262
enableRestrictedCommands = AutoConf.enableRestrictedCommands
263

    
264
enableSplitQuery :: Bool
265
enableSplitQuery = AutoConf.enableSplitQuery
266

    
267
-- * SSH constants
268

    
269
ssh :: String
270
ssh = "ssh"
271

    
272
scp :: String
273
scp = "scp"
274

    
275
-- * Daemons
276

    
277
confd :: String
278
confd = Runtime.daemonName GanetiConfd
279

    
280
masterd :: String
281
masterd = Runtime.daemonName GanetiMasterd
282

    
283
mond :: String
284
mond = Runtime.daemonName GanetiMond
285

    
286
noded :: String
287
noded = Runtime.daemonName GanetiNoded
288

    
289
luxid :: String
290
luxid = Runtime.daemonName GanetiLuxid
291

    
292
rapi :: String
293
rapi = Runtime.daemonName GanetiRapi
294

    
295
daemons :: FrozenSet String
296
daemons =
297
  ConstantUtils.mkSet [confd,
298
                       luxid,
299
                       masterd,
300
                       mond,
301
                       noded,
302
                       rapi]
303

    
304
defaultConfdPort :: Int
305
defaultConfdPort = 1814
306

    
307
defaultMondPort :: Int
308
defaultMondPort = 1815
309

    
310
defaultNodedPort :: Int
311
defaultNodedPort = 1811
312

    
313
defaultRapiPort :: Int
314
defaultRapiPort = 5080
315

    
316
daemonsPorts :: Map String (Protocol, Int)
317
daemonsPorts =
318
  Map.fromList [(confd, (Udp, defaultConfdPort)),
319
                (mond, (Tcp, defaultMondPort)),
320
                (noded, (Tcp, defaultNodedPort)),
321
                (rapi, (Tcp, defaultRapiPort)),
322
                (ssh, (Tcp, 22))]
323

    
324
firstDrbdPort :: Int
325
firstDrbdPort = 11000
326

    
327
lastDrbdPort :: Int
328
lastDrbdPort = 14999
329

    
330
daemonsLogbase :: Map String String
331
daemonsLogbase =
332
  Map.fromList
333
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
334

    
335
extraLogreasonAccess :: String
336
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
337

    
338
extraLogreasonError :: String
339
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
340

    
341
devConsole :: String
342
devConsole = ConstantUtils.devConsole
343

    
344
-- * Syslog
345

    
346
syslogUsage :: String
347
syslogUsage = AutoConf.syslogUsage
348

    
349
syslogNo :: String
350
syslogNo = Logging.syslogUsageToRaw SyslogNo
351

    
352
syslogYes :: String
353
syslogYes = Logging.syslogUsageToRaw SyslogYes
354

    
355
syslogOnly :: String
356
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
357

    
358
syslogSocket :: String
359
syslogSocket = "/dev/log"
360

    
361
-- * Xen
362

    
363
xenBootloader :: String
364
xenBootloader = AutoConf.xenBootloader
365

    
366
xenCmdXl :: String
367
xenCmdXl = "xl"
368

    
369
xenCmdXm :: String
370
xenCmdXm = "xm"
371

    
372
xenInitrd :: String
373
xenInitrd = AutoConf.xenInitrd
374

    
375
xenKernel :: String
376
xenKernel = AutoConf.xenKernel
377

    
378
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
379
-- other constants
380
knownXenCommands :: FrozenSet String
381
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
382

    
383
-- * KVM and socat
384

    
385
kvmPath :: String
386
kvmPath = AutoConf.kvmPath
387

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

    
391
socatEscapeCode :: String
392
socatEscapeCode = "0x1d"
393

    
394
socatPath :: String
395
socatPath = AutoConf.socatPath
396

    
397
socatUseCompress :: Bool
398
socatUseCompress = AutoConf.socatUseCompress
399

    
400
socatUseEscape :: Bool
401
socatUseEscape = AutoConf.socatUseEscape
402

    
403
-- * Storage types
404

    
405
stBlock :: String
406
stBlock = Types.storageTypeToRaw StorageBlock
407

    
408
stDiskless :: String
409
stDiskless = Types.storageTypeToRaw StorageDiskless
410

    
411
stExt :: String
412
stExt = Types.storageTypeToRaw StorageExt
413

    
414
stFile :: String
415
stFile = Types.storageTypeToRaw StorageFile
416

    
417
stLvmPv :: String
418
stLvmPv = Types.storageTypeToRaw StorageLvmPv
419

    
420
stLvmVg :: String
421
stLvmVg = Types.storageTypeToRaw StorageLvmVg
422

    
423
stRados :: String
424
stRados = Types.storageTypeToRaw StorageRados
425

    
426
storageTypes :: FrozenSet String
427
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
428

    
429
-- * Storage fields
430
-- ** First two are valid in LU context only, not passed to backend
431

    
432
sfNode :: String
433
sfNode = "node"
434

    
435
sfType :: String
436
sfType = "type"
437

    
438
-- ** and the rest are valid in backend
439

    
440
sfAllocatable :: String
441
sfAllocatable = Types.storageFieldToRaw SFAllocatable
442

    
443
sfFree :: String
444
sfFree = Types.storageFieldToRaw SFFree
445

    
446
sfName :: String
447
sfName = Types.storageFieldToRaw SFName
448

    
449
sfSize :: String
450
sfSize = Types.storageFieldToRaw SFSize
451

    
452
sfUsed :: String
453
sfUsed = Types.storageFieldToRaw SFUsed
454

    
455
-- * Local disk status
456

    
457
ldsFaulty :: Int
458
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
459

    
460
ldsOkay :: Int
461
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
462

    
463
ldsUnknown :: Int
464
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
465

    
466
ldsNames :: Map Int String
467
ldsNames =
468
  Map.fromList [ (Types.localDiskStatusToRaw ds,
469
                  localDiskStatusName ds) | ds <- [minBound..] ]
470

    
471
-- * Disk template types
472

    
473
dtDiskless :: String
474
dtDiskless = Types.diskTemplateToRaw DTDiskless
475

    
476
dtFile :: String
477
dtFile = Types.diskTemplateToRaw DTFile
478

    
479
dtSharedFile :: String
480
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
481

    
482
dtPlain :: String
483
dtPlain = Types.diskTemplateToRaw DTPlain
484

    
485
dtBlock :: String
486
dtBlock = Types.diskTemplateToRaw DTBlock
487

    
488
dtDrbd8 :: String
489
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
490

    
491
dtRbd :: String
492
dtRbd = Types.diskTemplateToRaw DTRbd
493

    
494
dtExt :: String
495
dtExt = Types.diskTemplateToRaw DTExt
496

    
497
-- | This is used to order determine the default disk template when
498
-- the list of enabled disk templates is inferred from the current
499
-- state of the cluster.  This only happens on an upgrade from a
500
-- version of Ganeti that did not support the 'enabled_disk_templates'
501
-- so far.
502
diskTemplatePreference :: [String]
503
diskTemplatePreference =
504
  map Types.diskTemplateToRaw
505
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile, DTPlain, DTRbd, DTSharedFile]
506

    
507
diskTemplates :: FrozenSet String
508
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
509

    
510
-- | Disk templates that are enabled by default
511
defaultEnabledDiskTemplates :: [String]
512
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
513

    
514
-- * File backend driver
515

    
516
fdBlktap :: String
517
fdBlktap = Types.fileDriverToRaw FileBlktap
518

    
519
fdLoop :: String
520
fdLoop = Types.fileDriverToRaw FileLoop
521

    
522
fileDriver :: FrozenSet String
523
fileDriver =
524
  ConstantUtils.mkSet $
525
  map Types.fileDriverToRaw [minBound..]
526

    
527
-- | The set of drbd-like disk types
528
ldsDrbd :: FrozenSet String
529
ldsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
530

    
531
-- * Disk access mode
532

    
533
diskRdonly :: String
534
diskRdonly = Types.diskModeToRaw DiskRdOnly
535

    
536
diskRdwr :: String
537
diskRdwr = Types.diskModeToRaw DiskRdWr
538

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

    
542
-- * Disk replacement mode
543

    
544
replaceDiskAuto :: String
545
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
546

    
547
replaceDiskChg :: String
548
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
549

    
550
replaceDiskPri :: String
551
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
552

    
553
replaceDiskSec :: String
554
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
555

    
556
replaceModes :: FrozenSet String
557
replaceModes =
558
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
559

    
560
-- * Instance export mode
561

    
562
exportModeLocal :: String
563
exportModeLocal = Types.exportModeToRaw ExportModeLocal
564

    
565
exportModeRemote :: String
566
exportModeRemote = Types.exportModeToRaw ExportModeRemote
567

    
568
exportModes :: FrozenSet String
569
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
570

    
571
-- * Instance creation modes
572

    
573
instanceCreate :: String
574
instanceCreate = Types.instCreateModeToRaw InstCreate
575

    
576
instanceImport :: String
577
instanceImport = Types.instCreateModeToRaw InstImport
578

    
579
instanceRemoteImport :: String
580
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
581

    
582
instanceCreateModes :: FrozenSet String
583
instanceCreateModes =
584
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
585

    
586
-- * Dynamic device modification
587

    
588
ddmAdd :: String
589
ddmAdd = Types.ddmFullToRaw DdmFullAdd
590

    
591
ddmModify :: String
592
ddmModify = Types.ddmFullToRaw DdmFullModify
593

    
594
ddmRemove :: String
595
ddmRemove = Types.ddmFullToRaw DdmFullRemove
596

    
597
ddmsValues :: FrozenSet String
598
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
599

    
600
ddmsValuesWithModify :: FrozenSet String
601
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
602

    
603
-- * Common exit codes
604

    
605
exitSuccess :: Int
606
exitSuccess = 0
607

    
608
exitFailure :: Int
609
exitFailure = ConstantUtils.exitFailure
610

    
611
exitNotcluster :: Int
612
exitNotcluster = 5
613

    
614
exitNotmaster :: Int
615
exitNotmaster = 11
616

    
617
exitNodesetupError :: Int
618
exitNodesetupError = 12
619

    
620
-- | Need user confirmation
621
exitConfirmation :: Int
622
exitConfirmation = 13
623

    
624
-- | Exit code for query operations with unknown fields
625
exitUnknownField :: Int
626
exitUnknownField = 14
627

    
628
-- * Tags
629

    
630
tagCluster :: String
631
tagCluster = Types.tagKindToRaw TagKindCluster
632

    
633
tagInstance :: String
634
tagInstance = Types.tagKindToRaw TagKindInstance
635

    
636
tagNetwork :: String
637
tagNetwork = Types.tagKindToRaw TagKindNetwork
638

    
639
tagNode :: String
640
tagNode = Types.tagKindToRaw TagKindNode
641

    
642
tagNodegroup :: String
643
tagNodegroup = Types.tagKindToRaw TagKindGroup
644

    
645
validTagTypes :: FrozenSet String
646
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
647

    
648
maxTagLen :: Int
649
maxTagLen = 128
650

    
651
maxTagsPerObj :: Int
652
maxTagsPerObj = 4096
653

    
654
-- | Node clock skew in seconds
655
nodeMaxClockSkew :: Int
656
nodeMaxClockSkew = 150
657

    
658
-- | Disk index separator
659
diskSeparator :: String
660
diskSeparator = AutoConf.diskSeparator
661

    
662
-- * Timeout table
663
--
664
-- Various time constants for the timeout table
665

    
666
rpcTmoUrgent :: Int
667
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
668

    
669
rpcTmoFast :: Int
670
rpcTmoFast = Types.rpcTimeoutToRaw Fast
671

    
672
rpcTmoNormal :: Int
673
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
674

    
675
rpcTmoSlow :: Int
676
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
677

    
678
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
679
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
680
-- Python name.
681
rpcTmo_4hrs :: Int
682
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
683

    
684
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
685
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
686
-- Python name.
687
rpcTmo_1day :: Int
688
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
689

    
690
-- | Timeout for connecting to nodes (seconds)
691
rpcConnectTimeout :: Int
692
rpcConnectTimeout = 5
693

    
694

    
695
-- | Instance specs
696
--
697
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
698

    
699
ispecMemSize :: String
700
ispecMemSize = ConstantUtils.ispecMemSize
701

    
702
ispecCpuCount :: String
703
ispecCpuCount = ConstantUtils.ispecCpuCount
704

    
705
ispecDiskCount :: String
706
ispecDiskCount = ConstantUtils.ispecDiskCount
707

    
708
ispecDiskSize :: String
709
ispecDiskSize = ConstantUtils.ispecDiskSize
710

    
711
ispecNicCount :: String
712
ispecNicCount = ConstantUtils.ispecNicCount
713

    
714
ispecSpindleUse :: String
715
ispecSpindleUse = ConstantUtils.ispecSpindleUse
716

    
717
ispecsParameterTypes :: Map String VType
718
ispecsParameterTypes =
719
  Map.fromList
720
  [(ConstantUtils.ispecDiskSize, VTypeInt),
721
   (ConstantUtils.ispecCpuCount, VTypeInt),
722
   (ConstantUtils.ispecSpindleUse, VTypeInt),
723
   (ConstantUtils.ispecMemSize, VTypeInt),
724
   (ConstantUtils.ispecNicCount, VTypeInt),
725
   (ConstantUtils.ispecDiskCount, VTypeInt)]
726

    
727
ispecsParameters :: FrozenSet String
728
ispecsParameters =
729
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
730
                       ConstantUtils.ispecDiskCount,
731
                       ConstantUtils.ispecDiskSize,
732
                       ConstantUtils.ispecMemSize,
733
                       ConstantUtils.ispecNicCount,
734
                       ConstantUtils.ispecSpindleUse]
735

    
736
ispecsMinmax :: String
737
ispecsMinmax = ConstantUtils.ispecsMinmax
738

    
739
ispecsMax :: String
740
ispecsMax = "max"
741

    
742
ispecsMin :: String
743
ispecsMin = "min"
744

    
745
ispecsStd :: String
746
ispecsStd = ConstantUtils.ispecsStd
747

    
748
ipolicyDts :: String
749
ipolicyDts = ConstantUtils.ipolicyDts
750

    
751
ipolicyVcpuRatio :: String
752
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
753

    
754
ipolicySpindleRatio :: String
755
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
756

    
757
ispecsMinmaxKeys :: FrozenSet String
758
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
759

    
760
ipolicyParameters :: FrozenSet String
761
ipolicyParameters =
762
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
763
                       ConstantUtils.ipolicySpindleRatio]
764

    
765
ipolicyAllKeys :: FrozenSet String
766
ipolicyAllKeys =
767
  ConstantUtils.union ipolicyParameters $
768
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
769
                       ConstantUtils.ispecsMinmax,
770
                       ispecsStd]
771

    
772
-- | Node parameter names
773

    
774
ndExclusiveStorage :: String
775
ndExclusiveStorage = "exclusive_storage"
776

    
777
ndOobProgram :: String
778
ndOobProgram = "oob_program"
779

    
780
ndSpindleCount :: String
781
ndSpindleCount = "spindle_count"
782

    
783
ndOvs :: String
784
ndOvs = "ovs"
785

    
786
ndOvsLink :: String
787
ndOvsLink = "ovs_link"
788

    
789
ndOvsName :: String
790
ndOvsName = "ovs_name"
791

    
792
ndsParameterTypes :: Map String VType
793
ndsParameterTypes =
794
  Map.fromList
795
  [(ndExclusiveStorage, VTypeBool),
796
   (ndOobProgram, VTypeString),
797
   (ndOvs, VTypeBool),
798
   (ndOvsLink, VTypeMaybeString),
799
   (ndOvsName, VTypeMaybeString),
800
   (ndSpindleCount, VTypeInt)]
801

    
802
ndsParameters :: FrozenSet String
803
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
804

    
805
ndsParameterTitles :: Map String String
806
ndsParameterTitles =
807
  Map.fromList
808
  [(ndExclusiveStorage, "ExclusiveStorage"),
809
   (ndOobProgram, "OutOfBandProgram"),
810
   (ndOvs, "OpenvSwitch"),
811
   (ndOvsLink, "OpenvSwitchLink"),
812
   (ndOvsName, "OpenvSwitchName"),
813
   (ndSpindleCount, "SpindleCount")]
814

    
815
ipCommandPath :: String
816
ipCommandPath = AutoConf.ipPath
817

    
818
-- * Reboot types
819

    
820
instanceRebootSoft :: String
821
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
822

    
823
instanceRebootHard :: String
824
instanceRebootHard = Types.rebootTypeToRaw RebootHard
825

    
826
instanceRebootFull :: String
827
instanceRebootFull = Types.rebootTypeToRaw RebootFull
828

    
829
rebootTypes :: FrozenSet String
830
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
831

    
832
-- * VTypes
833

    
834
vtypeBool :: String
835
vtypeBool = Types.vTypeToRaw VTypeBool
836

    
837
vtypeInt :: String
838
vtypeInt = Types.vTypeToRaw VTypeInt
839

    
840
vtypeMaybeString :: String
841
vtypeMaybeString = Types.vTypeToRaw VTypeMaybeString
842

    
843
-- | Size in MiBs
844
vtypeSize :: String
845
vtypeSize = Types.vTypeToRaw VTypeSize
846

    
847
vtypeString :: String
848
vtypeString = Types.vTypeToRaw VTypeString
849

    
850
enforceableTypes :: FrozenSet String
851
enforceableTypes = ConstantUtils.mkSet $ map Types.vTypeToRaw [minBound..]
852

    
853
-- * OOB supported commands
854

    
855
oobPowerOn :: String
856
oobPowerOn = Types.oobCommandToRaw OobPowerOn
857

    
858
oobPowerOff :: String
859
oobPowerOff = Types.oobCommandToRaw OobPowerOff
860

    
861
oobPowerCycle :: String
862
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
863

    
864
oobPowerStatus :: String
865
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
866

    
867
oobHealth :: String
868
oobHealth = Types.oobCommandToRaw OobHealth
869

    
870
oobCommands :: FrozenSet String
871
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
872

    
873
oobPowerStatusPowered :: String
874
oobPowerStatusPowered = "powered"
875

    
876
-- | 60 seconds
877
oobTimeout :: Int
878
oobTimeout = 60
879

    
880
-- | 2 seconds
881
oobPowerDelay :: Double
882
oobPowerDelay = 2.0
883

    
884
oobStatusCritical :: String
885
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
886

    
887
oobStatusOk :: String
888
oobStatusOk = Types.oobStatusToRaw OobStatusOk
889

    
890
oobStatusUnknown :: String
891
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
892

    
893
oobStatusWarning :: String
894
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
895

    
896
oobStatuses :: FrozenSet String
897
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
898

    
899
-- * NIC_* constants are used inside the ganeti config
900

    
901
nicLink :: String
902
nicLink = "link"
903

    
904
nicMode :: String
905
nicMode = "mode"
906

    
907
nicVlan :: String
908
nicVlan = "vlan"
909

    
910
nicModeBridged :: String
911
nicModeBridged = Types.nICModeToRaw NMBridged
912

    
913
nicModeRouted :: String
914
nicModeRouted = Types.nICModeToRaw NMRouted
915

    
916
nicModeOvs :: String
917
nicModeOvs = Types.nICModeToRaw NMOvs
918

    
919
nicIpPool :: String
920
nicIpPool = Types.nICModeToRaw NMPool
921

    
922
nicValidModes :: FrozenSet String
923
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
924

    
925
-- * Hypervisor constants
926

    
927
htXenPvm :: String
928
htXenPvm = Types.hypervisorToRaw XenPvm
929

    
930
htFake :: String
931
htFake = Types.hypervisorToRaw Fake
932

    
933
htXenHvm :: String
934
htXenHvm = Types.hypervisorToRaw XenHvm
935

    
936
htKvm :: String
937
htKvm = Types.hypervisorToRaw Kvm
938

    
939
htChroot :: String
940
htChroot = Types.hypervisorToRaw Chroot
941

    
942
htLxc :: String
943
htLxc = Types.hypervisorToRaw Lxc
944

    
945
hyperTypes :: FrozenSet String
946
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
947

    
948
htsReqPort :: FrozenSet String
949
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
950

    
951
-- * Migration type
952

    
953
htMigrationLive :: String
954
htMigrationLive = Types.migrationModeToRaw MigrationLive
955

    
956
htMigrationNonlive :: String
957
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
958

    
959
htMigrationModes :: FrozenSet String
960
htMigrationModes =
961
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
962

    
963
-- * Cluster verify steps
964

    
965
verifyNplusoneMem :: String
966
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
967

    
968
verifyOptionalChecks :: FrozenSet String
969
verifyOptionalChecks =
970
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
971

    
972
-- * Cluster Verify error classes
973

    
974
cvTcluster :: String
975
cvTcluster = "cluster"
976

    
977
cvTgroup :: String
978
cvTgroup = "group"
979

    
980
cvTnode :: String
981
cvTnode = "node"
982

    
983
cvTinstance :: String
984
cvTinstance = "instance"
985

    
986
-- * Cluster Verify error codes and documentation
987

    
988
cvEclustercert :: (String, String, String)
989
cvEclustercert =
990
  ("cluster",
991
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
992
   "Cluster certificate files verification failure")
993

    
994
cvEclustercfg :: (String, String, String)
995
cvEclustercfg =
996
  ("cluster",
997
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
998
   "Cluster configuration verification failure")
999

    
1000
cvEclusterdanglinginst :: (String, String, String)
1001
cvEclusterdanglinginst =
1002
  ("node",
1003
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
1004
   "Some instances have a non-existing primary node")
1005

    
1006
cvEclusterdanglingnodes :: (String, String, String)
1007
cvEclusterdanglingnodes =
1008
  ("node",
1009
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
1010
   "Some nodes belong to non-existing groups")
1011

    
1012
cvEclusterfilecheck :: (String, String, String)
1013
cvEclusterfilecheck =
1014
  ("cluster",
1015
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
1016
   "Cluster configuration verification failure")
1017

    
1018
cvEgroupdifferentpvsize :: (String, String, String)
1019
cvEgroupdifferentpvsize =
1020
  ("group",
1021
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
1022
   "PVs in the group have different sizes")
1023

    
1024
cvEinstancebadnode :: (String, String, String)
1025
cvEinstancebadnode =
1026
  ("instance",
1027
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
1028
   "Instance marked as running lives on an offline node")
1029

    
1030
cvEinstancedown :: (String, String, String)
1031
cvEinstancedown =
1032
  ("instance",
1033
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
1034
   "Instance not running on its primary node")
1035

    
1036
cvEinstancefaultydisk :: (String, String, String)
1037
cvEinstancefaultydisk =
1038
  ("instance",
1039
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
1040
   "Impossible to retrieve status for a disk")
1041

    
1042
cvEinstancelayout :: (String, String, String)
1043
cvEinstancelayout =
1044
  ("instance",
1045
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
1046
   "Instance has multiple secondary nodes")
1047

    
1048
cvEinstancemissingcfgparameter :: (String, String, String)
1049
cvEinstancemissingcfgparameter =
1050
  ("instance",
1051
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
1052
   "A configuration parameter for an instance is missing")
1053

    
1054
cvEinstancemissingdisk :: (String, String, String)
1055
cvEinstancemissingdisk =
1056
  ("instance",
1057
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
1058
   "Missing volume on an instance")
1059

    
1060
cvEinstancepolicy :: (String, String, String)
1061
cvEinstancepolicy =
1062
  ("instance",
1063
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
1064
   "Instance does not meet policy")
1065

    
1066
cvEinstancesplitgroups :: (String, String, String)
1067
cvEinstancesplitgroups =
1068
  ("instance",
1069
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
1070
   "Instance with primary and secondary nodes in different groups")
1071

    
1072
cvEinstanceunsuitablenode :: (String, String, String)
1073
cvEinstanceunsuitablenode =
1074
  ("instance",
1075
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
1076
   "Instance running on nodes that are not suitable for it")
1077

    
1078
cvEinstancewrongnode :: (String, String, String)
1079
cvEinstancewrongnode =
1080
  ("instance",
1081
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
1082
   "Instance running on the wrong node")
1083

    
1084
cvEnodedrbd :: (String, String, String)
1085
cvEnodedrbd =
1086
  ("node",
1087
   Types.cVErrorCodeToRaw CvENODEDRBD,
1088
   "Error parsing the DRBD status file")
1089

    
1090
cvEnodedrbdhelper :: (String, String, String)
1091
cvEnodedrbdhelper =
1092
  ("node",
1093
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
1094
   "Error caused by the DRBD helper")
1095

    
1096
cvEnodedrbdversion :: (String, String, String)
1097
cvEnodedrbdversion =
1098
  ("node",
1099
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
1100
   "DRBD version mismatch within a node group")
1101

    
1102
cvEnodefilecheck :: (String, String, String)
1103
cvEnodefilecheck =
1104
  ("node",
1105
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
1106
   "Error retrieving the checksum of the node files")
1107

    
1108
cvEnodefilestoragepaths :: (String, String, String)
1109
cvEnodefilestoragepaths =
1110
  ("node",
1111
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
1112
   "Detected bad file storage paths")
1113

    
1114
cvEnodefilestoragepathunusable :: (String, String, String)
1115
cvEnodefilestoragepathunusable =
1116
  ("node",
1117
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
1118
   "File storage path unusable")
1119

    
1120
cvEnodehooks :: (String, String, String)
1121
cvEnodehooks =
1122
  ("node",
1123
   Types.cVErrorCodeToRaw CvENODEHOOKS,
1124
   "Communication failure in hooks execution")
1125

    
1126
cvEnodehv :: (String, String, String)
1127
cvEnodehv =
1128
  ("node",
1129
   Types.cVErrorCodeToRaw CvENODEHV,
1130
   "Hypervisor parameters verification failure")
1131

    
1132
cvEnodelvm :: (String, String, String)
1133
cvEnodelvm =
1134
  ("node",
1135
   Types.cVErrorCodeToRaw CvENODELVM,
1136
   "LVM-related node error")
1137

    
1138
cvEnoden1 :: (String, String, String)
1139
cvEnoden1 =
1140
  ("node",
1141
   Types.cVErrorCodeToRaw CvENODEN1,
1142
   "Not enough memory to accommodate instance failovers")
1143

    
1144
cvEnodenet :: (String, String, String)
1145
cvEnodenet =
1146
  ("node",
1147
   Types.cVErrorCodeToRaw CvENODENET,
1148
   "Network-related node error")
1149

    
1150
cvEnodeoobpath :: (String, String, String)
1151
cvEnodeoobpath =
1152
  ("node",
1153
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
1154
   "Invalid Out Of Band path")
1155

    
1156
cvEnodeorphaninstance :: (String, String, String)
1157
cvEnodeorphaninstance =
1158
  ("node",
1159
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
1160
   "Unknown intance running on a node")
1161

    
1162
cvEnodeorphanlv :: (String, String, String)
1163
cvEnodeorphanlv =
1164
  ("node",
1165
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
1166
   "Unknown LVM logical volume")
1167

    
1168
cvEnodeos :: (String, String, String)
1169
cvEnodeos =
1170
  ("node",
1171
   Types.cVErrorCodeToRaw CvENODEOS,
1172
   "OS-related node error")
1173

    
1174
cvEnoderpc :: (String, String, String)
1175
cvEnoderpc =
1176
  ("node",
1177
   Types.cVErrorCodeToRaw CvENODERPC,
1178
   "Error during connection to the primary node of an instance")
1179

    
1180
cvEnodesetup :: (String, String, String)
1181
cvEnodesetup =
1182
  ("node",
1183
   Types.cVErrorCodeToRaw CvENODESETUP,
1184
   "Node setup error")
1185

    
1186
cvEnodesharedfilestoragepathunusable :: (String, String, String)
1187
cvEnodesharedfilestoragepathunusable =
1188
  ("node",
1189
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
1190
   "Shared file storage path unusable")
1191

    
1192
cvEnodessh :: (String, String, String)
1193
cvEnodessh =
1194
  ("node",
1195
   Types.cVErrorCodeToRaw CvENODESSH,
1196
   "SSH-related node error")
1197

    
1198
cvEnodetime :: (String, String, String)
1199
cvEnodetime =
1200
  ("node",
1201
   Types.cVErrorCodeToRaw CvENODETIME,
1202
   "Node returned invalid time")
1203

    
1204
cvEnodeuserscripts :: (String, String, String)
1205
cvEnodeuserscripts =
1206
  ("node",
1207
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
1208
   "User scripts not present or not executable")
1209

    
1210
cvEnodeversion :: (String, String, String)
1211
cvEnodeversion =
1212
  ("node",
1213
   Types.cVErrorCodeToRaw CvENODEVERSION,
1214
   "Protocol version mismatch or Ganeti version mismatch")
1215

    
1216
cvAllEcodes :: FrozenSet (String, String, String)
1217
cvAllEcodes =
1218
  ConstantUtils.mkSet
1219
  [cvEclustercert,
1220
   cvEclustercfg,
1221
   cvEclusterdanglinginst,
1222
   cvEclusterdanglingnodes,
1223
   cvEclusterfilecheck,
1224
   cvEgroupdifferentpvsize,
1225
   cvEinstancebadnode,
1226
   cvEinstancedown,
1227
   cvEinstancefaultydisk,
1228
   cvEinstancelayout,
1229
   cvEinstancemissingcfgparameter,
1230
   cvEinstancemissingdisk,
1231
   cvEinstancepolicy,
1232
   cvEinstancesplitgroups,
1233
   cvEinstanceunsuitablenode,
1234
   cvEinstancewrongnode,
1235
   cvEnodedrbd,
1236
   cvEnodedrbdhelper,
1237
   cvEnodedrbdversion,
1238
   cvEnodefilecheck,
1239
   cvEnodefilestoragepaths,
1240
   cvEnodefilestoragepathunusable,
1241
   cvEnodehooks,
1242
   cvEnodehv,
1243
   cvEnodelvm,
1244
   cvEnoden1,
1245
   cvEnodenet,
1246
   cvEnodeoobpath,
1247
   cvEnodeorphaninstance,
1248
   cvEnodeorphanlv,
1249
   cvEnodeos,
1250
   cvEnoderpc,
1251
   cvEnodesetup,
1252
   cvEnodesharedfilestoragepathunusable,
1253
   cvEnodessh,
1254
   cvEnodetime,
1255
   cvEnodeuserscripts,
1256
   cvEnodeversion]
1257

    
1258
cvAllEcodesStrings :: FrozenSet String
1259
cvAllEcodesStrings =
1260
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
1261

    
1262
-- * Instance status
1263

    
1264
inststAdmindown :: String
1265
inststAdmindown = Types.instanceStatusToRaw StatusDown
1266

    
1267
inststAdminoffline :: String
1268
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
1269

    
1270
inststErrordown :: String
1271
inststErrordown = Types.instanceStatusToRaw ErrorDown
1272

    
1273
inststErrorup :: String
1274
inststErrorup = Types.instanceStatusToRaw ErrorUp
1275

    
1276
inststNodedown :: String
1277
inststNodedown = Types.instanceStatusToRaw NodeDown
1278

    
1279
inststNodeoffline :: String
1280
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
1281

    
1282
inststRunning :: String
1283
inststRunning = Types.instanceStatusToRaw Running
1284

    
1285
inststWrongnode :: String
1286
inststWrongnode = Types.instanceStatusToRaw WrongNode
1287

    
1288
inststAll :: FrozenSet String
1289
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
1290

    
1291
-- * Admin states
1292

    
1293
adminstDown :: String
1294
adminstDown = Types.adminStateToRaw AdminDown
1295

    
1296
adminstOffline :: String
1297
adminstOffline = Types.adminStateToRaw AdminOffline
1298

    
1299
adminstUp :: String
1300
adminstUp = Types.adminStateToRaw AdminUp
1301

    
1302
adminstAll :: FrozenSet String
1303
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
1304

    
1305
-- * Node roles
1306

    
1307
nrDrained :: String
1308
nrDrained = Types.nodeRoleToRaw NRDrained
1309

    
1310
nrMaster :: String
1311
nrMaster = Types.nodeRoleToRaw NRMaster
1312

    
1313
nrMcandidate :: String
1314
nrMcandidate = Types.nodeRoleToRaw NRCandidate
1315

    
1316
nrOffline :: String
1317
nrOffline = Types.nodeRoleToRaw NROffline
1318

    
1319
nrRegular :: String
1320
nrRegular = Types.nodeRoleToRaw NRRegular
1321

    
1322
nrAll :: FrozenSet String
1323
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
1324

    
1325
-- * Allocator framework constants
1326

    
1327
iallocatorVersion :: Int
1328
iallocatorVersion = 2
1329

    
1330
iallocatorDirIn :: String
1331
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
1332

    
1333
iallocatorDirOut :: String
1334
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
1335

    
1336
validIallocatorDirections :: FrozenSet String
1337
validIallocatorDirections =
1338
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
1339

    
1340
iallocatorModeAlloc :: String
1341
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
1342

    
1343
iallocatorModeChgGroup :: String
1344
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
1345

    
1346
iallocatorModeMultiAlloc :: String
1347
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
1348

    
1349
iallocatorModeNodeEvac :: String
1350
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
1351

    
1352
iallocatorModeReloc :: String
1353
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
1354

    
1355
validIallocatorModes :: FrozenSet String
1356
validIallocatorModes =
1357
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
1358

    
1359
iallocatorSearchPath :: [String]
1360
iallocatorSearchPath = AutoConf.iallocatorSearchPath
1361

    
1362
defaultIallocatorShortcut :: String
1363
defaultIallocatorShortcut = "."
1364

    
1365
-- * Node evacuation
1366

    
1367
nodeEvacPri :: String
1368
nodeEvacPri = Types.evacModeToRaw ChangePrimary
1369

    
1370
nodeEvacSec :: String
1371
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
1372

    
1373
nodeEvacAll :: String
1374
nodeEvacAll = Types.evacModeToRaw ChangeAll
1375

    
1376
nodeEvacModes :: FrozenSet String
1377
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
1378

    
1379
-- * Job status
1380

    
1381
jobStatusQueued :: String
1382
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
1383

    
1384
jobStatusWaiting :: String
1385
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
1386

    
1387
jobStatusCanceling :: String
1388
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
1389

    
1390
jobStatusRunning :: String
1391
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
1392

    
1393
jobStatusCanceled :: String
1394
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
1395

    
1396
jobStatusSuccess :: String
1397
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
1398

    
1399
jobStatusError :: String
1400
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
1401

    
1402
jobsPending :: FrozenSet String
1403
jobsPending =
1404
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
1405

    
1406
jobsFinalized :: FrozenSet String
1407
jobsFinalized =
1408
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
1409

    
1410
jobStatusAll :: FrozenSet String
1411
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
1412

    
1413
-- * OpCode status
1414

    
1415
-- ** Not yet finalized opcodes
1416

    
1417
opStatusCanceling :: String
1418
opStatusCanceling = "canceling"
1419

    
1420
opStatusQueued :: String
1421
opStatusQueued = "queued"
1422

    
1423
opStatusRunning :: String
1424
opStatusRunning = "running"
1425

    
1426
opStatusWaiting :: String
1427
opStatusWaiting = "waiting"
1428

    
1429
-- ** Finalized opcodes
1430

    
1431
opStatusCanceled :: String
1432
opStatusCanceled = "canceled"
1433

    
1434
opStatusError :: String
1435
opStatusError = "error"
1436

    
1437
opStatusSuccess :: String
1438
opStatusSuccess = "success"
1439

    
1440
opsFinalized :: FrozenSet String
1441
opsFinalized =
1442
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
1443

    
1444
-- * OpCode priority
1445

    
1446
opPrioLowest :: Int
1447
opPrioLowest = 19
1448

    
1449
opPrioHighest :: Int
1450
opPrioHighest = -20
1451

    
1452
opPrioLow :: Int
1453
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
1454

    
1455
opPrioNormal :: Int
1456
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
1457

    
1458
opPrioHigh :: Int
1459
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
1460

    
1461
opPrioSubmitValid :: FrozenSet Int
1462
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
1463

    
1464
opPrioDefault :: Int
1465
opPrioDefault = opPrioNormal
1466

    
1467
-- * Execution log types
1468

    
1469
elogMessage :: String
1470
elogMessage = Types.eLogTypeToRaw ELogMessage
1471

    
1472
elogRemoteImport :: String
1473
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
1474

    
1475
elogJqueueTest :: String
1476
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
1477

    
1478
-- * Confd
1479

    
1480
confdProtocolVersion :: Int
1481
confdProtocolVersion = ConstantUtils.confdProtocolVersion
1482

    
1483
-- Confd request type
1484

    
1485
confdReqPing :: Int
1486
confdReqPing = Types.confdRequestTypeToRaw ReqPing
1487

    
1488
confdReqNodeRoleByname :: Int
1489
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
1490

    
1491
confdReqNodePipByInstanceIp :: Int
1492
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
1493

    
1494
confdReqClusterMaster :: Int
1495
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
1496

    
1497
confdReqNodePipList :: Int
1498
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
1499

    
1500
confdReqMcPipList :: Int
1501
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
1502

    
1503
confdReqInstancesIpsList :: Int
1504
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
1505

    
1506
confdReqNodeDrbd :: Int
1507
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
1508

    
1509
confdReqNodeInstances :: Int
1510
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
1511

    
1512
confdReqs :: FrozenSet Int
1513
confdReqs =
1514
  ConstantUtils.mkSet .
1515
  map Types.confdRequestTypeToRaw $
1516
  [minBound..] \\ [ReqNodeInstances]
1517

    
1518
-- * Confd request type
1519

    
1520
confdReqfieldName :: Int
1521
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
1522

    
1523
confdReqfieldIp :: Int
1524
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
1525

    
1526
confdReqfieldMnodePip :: Int
1527
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
1528

    
1529
-- * Confd repl status
1530

    
1531
confdReplStatusOk :: Int
1532
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
1533

    
1534
confdReplStatusError :: Int
1535
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
1536

    
1537
confdReplStatusNotimplemented :: Int
1538
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
1539

    
1540
confdReplStatuses :: FrozenSet Int
1541
confdReplStatuses =
1542
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
1543

    
1544
-- * Confd node role
1545

    
1546
confdNodeRoleMaster :: Int
1547
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
1548

    
1549
confdNodeRoleCandidate :: Int
1550
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
1551

    
1552
confdNodeRoleOffline :: Int
1553
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
1554

    
1555
confdNodeRoleDrained :: Int
1556
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
1557

    
1558
confdNodeRoleRegular :: Int
1559
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
1560

    
1561
-- * A few common errors for confd
1562

    
1563
confdErrorUnknownEntry :: Int
1564
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
1565

    
1566
confdErrorInternal :: Int
1567
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
1568

    
1569
confdErrorArgument :: Int
1570
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
1571

    
1572
-- * Confd request query fields
1573

    
1574
confdReqqLink :: String
1575
confdReqqLink = ConstantUtils.confdReqqLink
1576

    
1577
confdReqqIp :: String
1578
confdReqqIp = ConstantUtils.confdReqqIp
1579

    
1580
confdReqqIplist :: String
1581
confdReqqIplist = ConstantUtils.confdReqqIplist
1582

    
1583
confdReqqFields :: String
1584
confdReqqFields = ConstantUtils.confdReqqFields
1585

    
1586
-- | Each request is "salted" by the current timestamp.
1587
--
1588
-- This constant decides how many seconds of skew to accept.
1589
--
1590
-- TODO: make this a default and allow the value to be more
1591
-- configurable
1592
confdMaxClockSkew :: Int
1593
confdMaxClockSkew = 2 * nodeMaxClockSkew
1594

    
1595
-- | When we haven't reloaded the config for more than this amount of
1596
-- seconds, we force a test to see if inotify is betraying us. Using a
1597
-- prime number to ensure we get less chance of 'same wakeup' with
1598
-- other processes.
1599
confdConfigReloadTimeout :: Int
1600
confdConfigReloadTimeout = 17
1601

    
1602
-- | If we receive more than one update in this amount of
1603
-- microseconds, we move to polling every RATELIMIT seconds, rather
1604
-- than relying on inotify, to be able to serve more requests.
1605
confdConfigReloadRatelimit :: Int
1606
confdConfigReloadRatelimit = 250000
1607

    
1608
-- | Magic number prepended to all confd queries.
1609
--
1610
-- This allows us to distinguish different types of confd protocols
1611
-- and handle them. For example by changing this we can move the whole
1612
-- payload to be compressed, or move away from json.
1613
confdMagicFourcc :: String
1614
confdMagicFourcc = "plj0"
1615

    
1616
-- | By default a confd request is sent to the minimum between this
1617
-- number and all MCs. 6 was chosen because even in the case of a
1618
-- disastrous 50% response rate, we should have enough answers to be
1619
-- able to compare more than one.
1620
confdDefaultReqCoverage :: Int
1621
confdDefaultReqCoverage = 6
1622

    
1623
-- | Timeout in seconds to expire pending query request in the confd
1624
-- client library. We don't actually expect any answer more than 10
1625
-- seconds after we sent a request.
1626
confdClientExpireTimeout :: Int
1627
confdClientExpireTimeout = 10
1628

    
1629
-- * Possible values for NodeGroup.alloc_policy
1630

    
1631
allocPolicyLastResort :: String
1632
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
1633

    
1634
allocPolicyPreferred :: String
1635
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
1636

    
1637
allocPolicyUnallocable :: String
1638
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
1639

    
1640
validAllocPolicies :: [String]
1641
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
1642

    
1643
-- | Temporary external/shared storage parameters
1644
blockdevDriverManual :: String
1645
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
1646

    
1647
-- | 'qemu-img' path, required for 'ovfconverter'
1648
qemuimgPath :: String
1649
qemuimgPath = AutoConf.qemuimgPath
1650

    
1651
-- | Whether htools was enabled at compilation time
1652
--
1653
-- FIXME: this should be moved next to the other enable constants,
1654
-- such as, 'enableConfd', and renamed to 'enableHtools'.
1655
htools :: Bool
1656
htools = AutoConf.htools
1657

    
1658
-- | Path generating random UUID
1659
randomUuidFile :: String
1660
randomUuidFile = ConstantUtils.randomUuidFile
1661

    
1662
-- * Auto-repair tag prefixes
1663

    
1664
autoRepairTagPrefix :: String
1665
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
1666

    
1667
autoRepairTagEnabled :: String
1668
autoRepairTagEnabled = autoRepairTagPrefix
1669

    
1670
autoRepairTagPending :: String
1671
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
1672

    
1673
autoRepairTagResult :: String
1674
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
1675

    
1676
autoRepairTagSuspended :: String
1677
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
1678

    
1679
-- * Auto-repair levels
1680

    
1681
autoRepairFailover :: String
1682
autoRepairFailover = "failover"
1683

    
1684
autoRepairFixStorage :: String
1685
autoRepairFixStorage = "fix-storage"
1686

    
1687
autoRepairMigrate :: String
1688
autoRepairMigrate = "migrate"
1689

    
1690
autoRepairReinstall :: String
1691
autoRepairReinstall = "reinstall"
1692

    
1693
autoRepairAllTypes :: FrozenSet String
1694
autoRepairAllTypes =
1695
  ConstantUtils.mkSet [autoRepairFailover,
1696
                       autoRepairFixStorage,
1697
                       autoRepairMigrate,
1698
                       autoRepairReinstall]
1699

    
1700
-- * Auto-repair results
1701

    
1702
autoRepairEnoperm :: String
1703
autoRepairEnoperm = "enoperm"
1704

    
1705
autoRepairFailure :: String
1706
autoRepairFailure = "failure"
1707

    
1708
autoRepairSuccess :: String
1709
autoRepairSuccess = "success"
1710

    
1711
autoRepairAllResults :: FrozenSet String
1712
autoRepairAllResults =
1713
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
1714

    
1715
-- | The version identifier for builtin data collectors
1716
builtinDataCollectorVersion :: String
1717
builtinDataCollectorVersion = "B"
1718

    
1719
-- | The reason trail opcode parameter name
1720
opcodeReason :: String
1721
opcodeReason = "reason"
1722

    
1723
diskstatsFile :: String
1724
diskstatsFile = "/proc/diskstats"
1725

    
1726
-- *  CPU load collector
1727

    
1728
statFile :: String
1729
statFile = "/proc/stat"
1730

    
1731
cpuavgloadBufferSize :: Int
1732
cpuavgloadBufferSize = 150
1733

    
1734
cpuavgloadWindowSize :: Int
1735
cpuavgloadWindowSize = 600
1736

    
1737
-- | Mond's variable for periodical data collection
1738
mondTimeInterval :: Int
1739
mondTimeInterval = 5
1740

    
1741
-- * Disk access modes
1742

    
1743
diskUserspace :: String
1744
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
1745

    
1746
diskKernelspace :: String
1747
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
1748

    
1749
diskValidAccessModes :: FrozenSet String
1750
diskValidAccessModes =
1751
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
1752

    
1753
-- | Timeout for queue draining in upgrades
1754
upgradeQueueDrainTimeout :: Int
1755
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
1756

    
1757
-- | Intervall at which the queue is polled during upgrades
1758
upgradeQueuePollInterval :: Int
1759
upgradeQueuePollInterval  = 10