Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ 9be1ff8c

History | View | Annotate | Download (52.2 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 Control.Arrow ((***))
40
import Data.List ((\\))
41
import Data.Map (Map)
42
import qualified Data.Map as Map (fromList, keys, insert)
43

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

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

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

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

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

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

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

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

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

    
82
-- ** Build-time constants
83

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
131
-- * Various versions
132

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

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

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

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

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

    
148
osApiV10 :: Int
149
osApiV10 = 10
150

    
151
osApiV15 :: Int
152
osApiV15 = 15
153

    
154
osApiV20 :: Int
155
osApiV20 = 20
156

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

    
160
exportVersion :: Int
161
exportVersion = 0
162

    
163
rapiVersion :: Int
164
rapiVersion = 2
165

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

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

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

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

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

    
185
-- * User separation
186

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
235
-- * Cpu pinning separators and constants
236

    
237
cpuPinningSep :: String
238
cpuPinningSep = ":"
239

    
240
cpuPinningAll :: String
241
cpuPinningAll = "all"
242

    
243
-- | Internal representation of "all"
244
cpuPinningAllVal :: Int
245
cpuPinningAllVal = -1
246

    
247
-- | One "all" entry in a CPU list means CPU pinning is off
248
cpuPinningOff :: [Int]
249
cpuPinningOff = [cpuPinningAllVal]
250

    
251
-- | A Xen-specific implementation detail is that there is no way to
252
-- actually say "use any cpu for pinning" in a Xen configuration file,
253
-- as opposed to the command line, where you can say
254
-- @
255
-- xm vcpu-pin <domain> <vcpu> all
256
-- @
257
--
258
-- The workaround used in Xen is "0-63" (see source code function
259
-- "xm_vcpu_pin" in @<xen-source>/tools/python/xen/xm/main.py@).
260
--
261
-- To support future changes, the following constant is treated as a
262
-- blackbox string that simply means "use any cpu for pinning under
263
-- xen".
264
cpuPinningAllXen :: String
265
cpuPinningAllXen = "0-63"
266

    
267
-- | A KVM-specific implementation detail - the following value is
268
-- used to set CPU affinity to all processors (--0 through --31), per
269
-- taskset man page.
270
--
271
-- FIXME: This only works for machines with up to 32 CPU cores
272
cpuPinningAllKvm :: Int
273
cpuPinningAllKvm = 0xFFFFFFFF
274

    
275
-- * Wipe
276

    
277
ddCmd :: String
278
ddCmd = "dd"
279

    
280
-- | 1GB
281
maxWipeChunk :: Int
282
maxWipeChunk = 1024
283

    
284
minWipeChunkPercent :: Int
285
minWipeChunkPercent = 10
286

    
287
-- * Directories
288

    
289
runDirsMode :: Int
290
runDirsMode = 0o775
291

    
292
secureDirMode :: Int
293
secureDirMode = 0o700
294

    
295
secureFileMode :: Int
296
secureFileMode = 0o600
297

    
298
adoptableBlockdevRoot :: String
299
adoptableBlockdevRoot = "/dev/disk/"
300

    
301
-- * 'autoconf' enable/disable
302

    
303
enableConfd :: Bool
304
enableConfd = AutoConf.enableConfd
305

    
306
enableMond :: Bool
307
enableMond = AutoConf.enableMond
308

    
309
enableRestrictedCommands :: Bool
310
enableRestrictedCommands = AutoConf.enableRestrictedCommands
311

    
312
enableSplitQuery :: Bool
313
enableSplitQuery = AutoConf.enableSplitQuery
314

    
315
-- * SSH constants
316

    
317
ssh :: String
318
ssh = "ssh"
319

    
320
scp :: String
321
scp = "scp"
322

    
323
-- * Daemons
324

    
325
confd :: String
326
confd = Runtime.daemonName GanetiConfd
327

    
328
masterd :: String
329
masterd = Runtime.daemonName GanetiMasterd
330

    
331
mond :: String
332
mond = Runtime.daemonName GanetiMond
333

    
334
noded :: String
335
noded = Runtime.daemonName GanetiNoded
336

    
337
luxid :: String
338
luxid = Runtime.daemonName GanetiLuxid
339

    
340
rapi :: String
341
rapi = Runtime.daemonName GanetiRapi
342

    
343
daemons :: FrozenSet String
344
daemons =
345
  ConstantUtils.mkSet [confd,
346
                       luxid,
347
                       masterd,
348
                       mond,
349
                       noded,
350
                       rapi]
351

    
352
defaultConfdPort :: Int
353
defaultConfdPort = 1814
354

    
355
defaultMondPort :: Int
356
defaultMondPort = 1815
357

    
358
defaultNodedPort :: Int
359
defaultNodedPort = 1811
360

    
361
defaultRapiPort :: Int
362
defaultRapiPort = 5080
363

    
364
daemonsPorts :: Map String (Protocol, Int)
365
daemonsPorts =
366
  Map.fromList [(confd, (Udp, defaultConfdPort)),
367
                (mond, (Tcp, defaultMondPort)),
368
                (noded, (Tcp, defaultNodedPort)),
369
                (rapi, (Tcp, defaultRapiPort)),
370
                (ssh, (Tcp, 22))]
371

    
372
firstDrbdPort :: Int
373
firstDrbdPort = 11000
374

    
375
lastDrbdPort :: Int
376
lastDrbdPort = 14999
377

    
378
daemonsLogbase :: Map String String
379
daemonsLogbase =
380
  Map.fromList
381
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
382

    
383
extraLogreasonAccess :: String
384
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
385

    
386
extraLogreasonError :: String
387
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
388

    
389
devConsole :: String
390
devConsole = ConstantUtils.devConsole
391

    
392
procMounts :: String
393
procMounts = "/proc/mounts"
394

    
395
-- * Luxi (Local UniX Interface) related constants
396

    
397
luxiEom :: PythonChar
398
luxiEom = PythonChar '\x03'
399

    
400
-- | Environment variable for the luxi override socket
401
luxiOverride :: String
402
luxiOverride = "FORCE_LUXI_SOCKET"
403

    
404
luxiOverrideMaster :: String
405
luxiOverrideMaster = "master"
406

    
407
luxiOverrideQuery :: String
408
luxiOverrideQuery = "query"
409

    
410
luxiVersion :: Int
411
luxiVersion = configVersion
412

    
413
-- * Syslog
414

    
415
syslogUsage :: String
416
syslogUsage = AutoConf.syslogUsage
417

    
418
syslogNo :: String
419
syslogNo = Logging.syslogUsageToRaw SyslogNo
420

    
421
syslogYes :: String
422
syslogYes = Logging.syslogUsageToRaw SyslogYes
423

    
424
syslogOnly :: String
425
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
426

    
427
syslogSocket :: String
428
syslogSocket = "/dev/log"
429

    
430
exportConfFile :: String
431
exportConfFile = "config.ini"
432

    
433
-- * Xen
434

    
435
xenBootloader :: String
436
xenBootloader = AutoConf.xenBootloader
437

    
438
xenCmdXl :: String
439
xenCmdXl = "xl"
440

    
441
xenCmdXm :: String
442
xenCmdXm = "xm"
443

    
444
xenInitrd :: String
445
xenInitrd = AutoConf.xenInitrd
446

    
447
xenKernel :: String
448
xenKernel = AutoConf.xenKernel
449

    
450
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
451
-- other constants
452
knownXenCommands :: FrozenSet String
453
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
454

    
455
-- * KVM and socat
456

    
457
kvmPath :: String
458
kvmPath = AutoConf.kvmPath
459

    
460
kvmKernel :: String
461
kvmKernel = AutoConf.kvmKernel
462

    
463
socatEscapeCode :: String
464
socatEscapeCode = "0x1d"
465

    
466
socatPath :: String
467
socatPath = AutoConf.socatPath
468

    
469
socatUseCompress :: Bool
470
socatUseCompress = AutoConf.socatUseCompress
471

    
472
socatUseEscape :: Bool
473
socatUseEscape = AutoConf.socatUseEscape
474

    
475
-- * Console types
476

    
477
-- | Display a message for console access
478
consMessage :: String
479
consMessage = "msg"
480

    
481
-- | Console as SPICE server
482
consSpice :: String
483
consSpice = "spice"
484

    
485
-- | Console as SSH command
486
consSsh :: String
487
consSsh = "ssh"
488

    
489
-- | Console as VNC server
490
consVnc :: String
491
consVnc = "vnc"
492

    
493
consAll :: FrozenSet String
494
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
495

    
496
-- | RSA key bit length
497
--
498
-- For RSA keys more bits are better, but they also make operations
499
-- more expensive. NIST SP 800-131 recommends a minimum of 2048 bits
500
-- from the year 2010 on.
501
rsaKeyBits :: Int
502
rsaKeyBits = 2048
503

    
504
-- | Ciphers allowed for SSL connections.
505
--
506
-- For the format, see ciphers(1). A better way to disable ciphers
507
-- would be to use the exclamation mark (!), but socat versions below
508
-- 1.5 can't parse exclamation marks in options properly. When
509
-- modifying the ciphers, ensure not to accidentially add something
510
-- after it's been removed. Use the "openssl" utility to check the
511
-- allowed ciphers, e.g.  "openssl ciphers -v HIGH:-DES".
512
opensslCiphers :: String
513
opensslCiphers = "HIGH:-DES:-3DES:-EXPORT:-ADH"
514

    
515
-- * X509
516

    
517
-- | commonName (CN) used in certificates
518
x509CertCn :: String
519
x509CertCn = "ganeti.example.com"
520

    
521
-- | Default validity of certificates in days
522
x509CertDefaultValidity :: Int
523
x509CertDefaultValidity = 365 * 5
524

    
525
x509CertSignatureHeader :: String
526
x509CertSignatureHeader = "X-Ganeti-Signature"
527

    
528
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
529
x509CertSignDigest :: String
530
x509CertSignDigest = "SHA1"
531

    
532
-- * Import/export daemon mode
533

    
534
iemExport :: String
535
iemExport = "export"
536

    
537
iemImport :: String
538
iemImport = "import"
539

    
540
-- * Import/export transport compression
541

    
542
iecGzip :: String
543
iecGzip = "gzip"
544

    
545
iecNone :: String
546
iecNone = "none"
547

    
548
iecAll :: [String]
549
iecAll = [iecGzip, iecNone]
550

    
551
ieCustomSize :: String
552
ieCustomSize = "fd"
553

    
554
-- * Import/export I/O
555

    
556
-- | Direct file I/O, equivalent to a shell's I/O redirection using
557
-- '<' or '>'
558
ieioFile :: String
559
ieioFile = "file"
560

    
561
-- | Raw block device I/O using "dd"
562
ieioRawDisk :: String
563
ieioRawDisk = "raw"
564

    
565
-- | OS definition import/export script
566
ieioScript :: String
567
ieioScript = "script"
568

    
569
-- * Hooks
570

    
571
hooksNameCfgupdate :: String
572
hooksNameCfgupdate = "config-update"
573

    
574
hooksNameWatcher :: String
575
hooksNameWatcher = "watcher"
576

    
577
hooksPath :: String
578
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
579

    
580
hooksPhasePost :: String
581
hooksPhasePost = "post"
582

    
583
hooksPhasePre :: String
584
hooksPhasePre = "pre"
585

    
586
hooksVersion :: Int
587
hooksVersion = 2
588

    
589
-- * Hooks subject type (what object type does the LU deal with)
590

    
591
htypeCluster :: String
592
htypeCluster = "CLUSTER"
593

    
594
htypeGroup :: String
595
htypeGroup = "GROUP"
596

    
597
htypeInstance :: String
598
htypeInstance = "INSTANCE"
599

    
600
htypeNetwork :: String
601
htypeNetwork = "NETWORK"
602

    
603
htypeNode :: String
604
htypeNode = "NODE"
605

    
606
-- * Hkr
607

    
608
hkrSkip :: Int
609
hkrSkip = 0
610

    
611
hkrFail :: Int
612
hkrFail = 1
613

    
614
hkrSuccess :: Int
615
hkrSuccess = 2
616

    
617
-- * Storage types
618

    
619
stBlock :: String
620
stBlock = Types.storageTypeToRaw StorageBlock
621

    
622
stDiskless :: String
623
stDiskless = Types.storageTypeToRaw StorageDiskless
624

    
625
stExt :: String
626
stExt = Types.storageTypeToRaw StorageExt
627

    
628
stFile :: String
629
stFile = Types.storageTypeToRaw StorageFile
630

    
631
stLvmPv :: String
632
stLvmPv = Types.storageTypeToRaw StorageLvmPv
633

    
634
stLvmVg :: String
635
stLvmVg = Types.storageTypeToRaw StorageLvmVg
636

    
637
stRados :: String
638
stRados = Types.storageTypeToRaw StorageRados
639

    
640
storageTypes :: FrozenSet String
641
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
642

    
643
-- | The set of storage types for which storage reporting is available
644
--
645
-- FIXME: Remove this, once storage reporting is available for all
646
-- types.
647
stsReport :: FrozenSet String
648
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
649

    
650
-- * Storage fields
651
-- ** First two are valid in LU context only, not passed to backend
652

    
653
sfNode :: String
654
sfNode = "node"
655

    
656
sfType :: String
657
sfType = "type"
658

    
659
-- ** and the rest are valid in backend
660

    
661
sfAllocatable :: String
662
sfAllocatable = Types.storageFieldToRaw SFAllocatable
663

    
664
sfFree :: String
665
sfFree = Types.storageFieldToRaw SFFree
666

    
667
sfName :: String
668
sfName = Types.storageFieldToRaw SFName
669

    
670
sfSize :: String
671
sfSize = Types.storageFieldToRaw SFSize
672

    
673
sfUsed :: String
674
sfUsed = Types.storageFieldToRaw SFUsed
675

    
676
validStorageFields :: FrozenSet String
677
validStorageFields =
678
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
679
                        [sfNode, sfType]
680

    
681
modifiableStorageFields :: Map String (FrozenSet String)
682
modifiableStorageFields =
683
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
684
                 ConstantUtils.mkSet [sfAllocatable])]
685

    
686
-- * Storage operations
687

    
688
soFixConsistency :: String
689
soFixConsistency = "fix-consistency"
690

    
691
validStorageOperations :: Map String (FrozenSet String)
692
validStorageOperations =
693
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
694
                 ConstantUtils.mkSet [soFixConsistency])]
695

    
696
-- * Volume fields
697

    
698
vfDev :: String
699
vfDev = "dev"
700

    
701
vfInstance :: String
702
vfInstance = "instance"
703

    
704
vfName :: String
705
vfName = "name"
706

    
707
vfNode :: String
708
vfNode = "node"
709

    
710
vfPhys :: String
711
vfPhys = "phys"
712

    
713
vfSize :: String
714
vfSize = "size"
715

    
716
vfVg :: String
717
vfVg = "vg"
718

    
719
-- * Local disk status
720

    
721
ldsFaulty :: Int
722
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
723

    
724
ldsOkay :: Int
725
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
726

    
727
ldsUnknown :: Int
728
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
729

    
730
ldsNames :: Map Int String
731
ldsNames =
732
  Map.fromList [ (Types.localDiskStatusToRaw ds,
733
                  localDiskStatusName ds) | ds <- [minBound..] ]
734

    
735
-- * Disk template types
736

    
737
dtDiskless :: String
738
dtDiskless = Types.diskTemplateToRaw DTDiskless
739

    
740
dtFile :: String
741
dtFile = Types.diskTemplateToRaw DTFile
742

    
743
dtSharedFile :: String
744
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
745

    
746
dtPlain :: String
747
dtPlain = Types.diskTemplateToRaw DTPlain
748

    
749
dtBlock :: String
750
dtBlock = Types.diskTemplateToRaw DTBlock
751

    
752
dtDrbd8 :: String
753
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
754

    
755
dtRbd :: String
756
dtRbd = Types.diskTemplateToRaw DTRbd
757

    
758
dtExt :: String
759
dtExt = Types.diskTemplateToRaw DTExt
760

    
761
-- | This is used to order determine the default disk template when
762
-- the list of enabled disk templates is inferred from the current
763
-- state of the cluster.  This only happens on an upgrade from a
764
-- version of Ganeti that did not support the 'enabled_disk_templates'
765
-- so far.
766
diskTemplatePreference :: [String]
767
diskTemplatePreference =
768
  map Types.diskTemplateToRaw
769
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile, DTPlain, DTRbd, DTSharedFile]
770

    
771
diskTemplates :: FrozenSet String
772
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
773

    
774
-- | Disk templates that are enabled by default
775
defaultEnabledDiskTemplates :: [String]
776
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
777

    
778
-- | Mapping of disk templates to storage types
779
mapDiskTemplateStorageType :: Map String String
780
mapDiskTemplateStorageType =
781
  Map.fromList $
782
  map (Types.diskTemplateToRaw *** Types.storageTypeToRaw)
783
  [(DTBlock, StorageBlock),
784
   (DTDrbd8, StorageLvmVg),
785
   (DTExt, StorageExt),
786
   (DTSharedFile, StorageFile),
787
   (DTFile, StorageFile),
788
   (DTDiskless, StorageDiskless),
789
   (DTPlain, StorageLvmVg),
790
   (DTRbd, StorageRados)]
791

    
792
-- | The set of network-mirrored disk templates
793
dtsIntMirror :: FrozenSet String
794
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
795

    
796
-- | 'DTDiskless' is 'trivially' externally mirrored
797
dtsExtMirror :: FrozenSet String
798
dtsExtMirror =
799
  ConstantUtils.mkSet $
800
  map Types.diskTemplateToRaw [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd]
801

    
802
-- | The set of non-lvm-based disk templates
803
dtsNotLvm :: FrozenSet String
804
dtsNotLvm =
805
  ConstantUtils.mkSet $
806
  map Types.diskTemplateToRaw
807
  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd]
808

    
809
-- | The set of disk templates which can be grown
810
dtsGrowable :: FrozenSet String
811
dtsGrowable =
812
  ConstantUtils.mkSet $
813
  map Types.diskTemplateToRaw
814
  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd]
815

    
816
-- | The set of disk templates that allow adoption
817
dtsMayAdopt :: FrozenSet String
818
dtsMayAdopt =
819
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
820

    
821
-- | The set of disk templates that *must* use adoption
822
dtsMustAdopt :: FrozenSet String
823
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
824

    
825
-- | The set of disk templates that allow migrations
826
dtsMirrored :: FrozenSet String
827
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
828

    
829
-- | The set of file based disk templates
830
dtsFilebased :: FrozenSet String
831
dtsFilebased =
832
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTSharedFile, DTFile]
833

    
834
-- | The set of disk templates that can be moved by copying
835
--
836
-- Note: a requirement is that they're not accessed externally or
837
-- shared between nodes; in particular, sharedfile is not suitable.
838
dtsCopyable :: FrozenSet String
839
dtsCopyable =
840
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
841

    
842
-- | The set of disk templates that are supported by exclusive_storage
843
dtsExclStorage :: FrozenSet String
844
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
845

    
846
-- | Templates for which we don't perform checks on free space
847
dtsNoFreeSpaceCheck :: FrozenSet String
848
dtsNoFreeSpaceCheck =
849
  ConstantUtils.mkSet $
850
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd]
851

    
852
dtsBlock :: FrozenSet String
853
dtsBlock =
854
  ConstantUtils.mkSet $
855
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
856

    
857
-- * File backend driver
858

    
859
fdBlktap :: String
860
fdBlktap = Types.fileDriverToRaw FileBlktap
861

    
862
fdLoop :: String
863
fdLoop = Types.fileDriverToRaw FileLoop
864

    
865
fileDriver :: FrozenSet String
866
fileDriver =
867
  ConstantUtils.mkSet $
868
  map Types.fileDriverToRaw [minBound..]
869

    
870
-- | The set of drbd-like disk types
871
ldsDrbd :: FrozenSet String
872
ldsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
873

    
874
-- * Disk access mode
875

    
876
diskRdonly :: String
877
diskRdonly = Types.diskModeToRaw DiskRdOnly
878

    
879
diskRdwr :: String
880
diskRdwr = Types.diskModeToRaw DiskRdWr
881

    
882
diskAccessSet :: FrozenSet String
883
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
884

    
885
-- * Disk replacement mode
886

    
887
replaceDiskAuto :: String
888
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
889

    
890
replaceDiskChg :: String
891
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
892

    
893
replaceDiskPri :: String
894
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
895

    
896
replaceDiskSec :: String
897
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
898

    
899
replaceModes :: FrozenSet String
900
replaceModes =
901
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
902

    
903
-- * Instance export mode
904

    
905
exportModeLocal :: String
906
exportModeLocal = Types.exportModeToRaw ExportModeLocal
907

    
908
exportModeRemote :: String
909
exportModeRemote = Types.exportModeToRaw ExportModeRemote
910

    
911
exportModes :: FrozenSet String
912
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
913

    
914
-- * Instance creation modes
915

    
916
instanceCreate :: String
917
instanceCreate = Types.instCreateModeToRaw InstCreate
918

    
919
instanceImport :: String
920
instanceImport = Types.instCreateModeToRaw InstImport
921

    
922
instanceRemoteImport :: String
923
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
924

    
925
instanceCreateModes :: FrozenSet String
926
instanceCreateModes =
927
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
928

    
929
-- * Dynamic device modification
930

    
931
ddmAdd :: String
932
ddmAdd = Types.ddmFullToRaw DdmFullAdd
933

    
934
ddmModify :: String
935
ddmModify = Types.ddmFullToRaw DdmFullModify
936

    
937
ddmRemove :: String
938
ddmRemove = Types.ddmFullToRaw DdmFullRemove
939

    
940
ddmsValues :: FrozenSet String
941
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
942

    
943
ddmsValuesWithModify :: FrozenSet String
944
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
945

    
946
-- * Common exit codes
947

    
948
exitSuccess :: Int
949
exitSuccess = 0
950

    
951
exitFailure :: Int
952
exitFailure = ConstantUtils.exitFailure
953

    
954
exitNotcluster :: Int
955
exitNotcluster = 5
956

    
957
exitNotmaster :: Int
958
exitNotmaster = 11
959

    
960
exitNodesetupError :: Int
961
exitNodesetupError = 12
962

    
963
-- | Need user confirmation
964
exitConfirmation :: Int
965
exitConfirmation = 13
966

    
967
-- | Exit code for query operations with unknown fields
968
exitUnknownField :: Int
969
exitUnknownField = 14
970

    
971
-- * Tags
972

    
973
tagCluster :: String
974
tagCluster = Types.tagKindToRaw TagKindCluster
975

    
976
tagInstance :: String
977
tagInstance = Types.tagKindToRaw TagKindInstance
978

    
979
tagNetwork :: String
980
tagNetwork = Types.tagKindToRaw TagKindNetwork
981

    
982
tagNode :: String
983
tagNode = Types.tagKindToRaw TagKindNode
984

    
985
tagNodegroup :: String
986
tagNodegroup = Types.tagKindToRaw TagKindGroup
987

    
988
validTagTypes :: FrozenSet String
989
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
990

    
991
maxTagLen :: Int
992
maxTagLen = 128
993

    
994
maxTagsPerObj :: Int
995
maxTagsPerObj = 4096
996

    
997
-- | Node clock skew in seconds
998
nodeMaxClockSkew :: Int
999
nodeMaxClockSkew = 150
1000

    
1001
-- | Disk index separator
1002
diskSeparator :: String
1003
diskSeparator = AutoConf.diskSeparator
1004

    
1005
-- * Timeout table
1006
--
1007
-- Various time constants for the timeout table
1008

    
1009
rpcTmoUrgent :: Int
1010
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1011

    
1012
rpcTmoFast :: Int
1013
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1014

    
1015
rpcTmoNormal :: Int
1016
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1017

    
1018
rpcTmoSlow :: Int
1019
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1020

    
1021
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1022
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1023
-- Python name.
1024
rpcTmo_4hrs :: Int
1025
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1026

    
1027
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1028
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1029
-- Python name.
1030
rpcTmo_1day :: Int
1031
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1032

    
1033
-- | Timeout for connecting to nodes (seconds)
1034
rpcConnectTimeout :: Int
1035
rpcConnectTimeout = 5
1036

    
1037
-- * VTypes
1038

    
1039
vtypeBool :: VType
1040
vtypeBool = VTypeBool
1041

    
1042
vtypeInt :: VType
1043
vtypeInt = VTypeInt
1044

    
1045
vtypeMaybeString :: VType
1046
vtypeMaybeString = VTypeMaybeString
1047

    
1048
-- | Size in MiBs
1049
vtypeSize :: VType
1050
vtypeSize = VTypeSize
1051

    
1052
vtypeString :: VType
1053
vtypeString = VTypeString
1054

    
1055
enforceableTypes :: FrozenSet VType
1056
enforceableTypes = ConstantUtils.mkSet [minBound..]
1057

    
1058
-- | Instance specs
1059
--
1060
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1061

    
1062
ispecMemSize :: String
1063
ispecMemSize = ConstantUtils.ispecMemSize
1064

    
1065
ispecCpuCount :: String
1066
ispecCpuCount = ConstantUtils.ispecCpuCount
1067

    
1068
ispecDiskCount :: String
1069
ispecDiskCount = ConstantUtils.ispecDiskCount
1070

    
1071
ispecDiskSize :: String
1072
ispecDiskSize = ConstantUtils.ispecDiskSize
1073

    
1074
ispecNicCount :: String
1075
ispecNicCount = ConstantUtils.ispecNicCount
1076

    
1077
ispecSpindleUse :: String
1078
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1079

    
1080
ispecsParameterTypes :: Map String VType
1081
ispecsParameterTypes =
1082
  Map.fromList
1083
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1084
   (ConstantUtils.ispecCpuCount, VTypeInt),
1085
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1086
   (ConstantUtils.ispecMemSize, VTypeInt),
1087
   (ConstantUtils.ispecNicCount, VTypeInt),
1088
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1089

    
1090
ispecsParameters :: FrozenSet String
1091
ispecsParameters =
1092
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1093
                       ConstantUtils.ispecDiskCount,
1094
                       ConstantUtils.ispecDiskSize,
1095
                       ConstantUtils.ispecMemSize,
1096
                       ConstantUtils.ispecNicCount,
1097
                       ConstantUtils.ispecSpindleUse]
1098

    
1099
ispecsMinmax :: String
1100
ispecsMinmax = ConstantUtils.ispecsMinmax
1101

    
1102
ispecsMax :: String
1103
ispecsMax = "max"
1104

    
1105
ispecsMin :: String
1106
ispecsMin = "min"
1107

    
1108
ispecsStd :: String
1109
ispecsStd = ConstantUtils.ispecsStd
1110

    
1111
ipolicyDts :: String
1112
ipolicyDts = ConstantUtils.ipolicyDts
1113

    
1114
ipolicyVcpuRatio :: String
1115
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1116

    
1117
ipolicySpindleRatio :: String
1118
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
1119

    
1120
ispecsMinmaxKeys :: FrozenSet String
1121
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1122

    
1123
ipolicyParameters :: FrozenSet String
1124
ipolicyParameters =
1125
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1126
                       ConstantUtils.ipolicySpindleRatio]
1127

    
1128
ipolicyAllKeys :: FrozenSet String
1129
ipolicyAllKeys =
1130
  ConstantUtils.union ipolicyParameters $
1131
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1132
                       ConstantUtils.ispecsMinmax,
1133
                       ispecsStd]
1134

    
1135
-- | Node parameter names
1136

    
1137
ndExclusiveStorage :: String
1138
ndExclusiveStorage = "exclusive_storage"
1139

    
1140
ndOobProgram :: String
1141
ndOobProgram = "oob_program"
1142

    
1143
ndSpindleCount :: String
1144
ndSpindleCount = "spindle_count"
1145

    
1146
ndOvs :: String
1147
ndOvs = "ovs"
1148

    
1149
ndOvsLink :: String
1150
ndOvsLink = "ovs_link"
1151

    
1152
ndOvsName :: String
1153
ndOvsName = "ovs_name"
1154

    
1155
ndsParameterTypes :: Map String VType
1156
ndsParameterTypes =
1157
  Map.fromList
1158
  [(ndExclusiveStorage, VTypeBool),
1159
   (ndOobProgram, VTypeString),
1160
   (ndOvs, VTypeBool),
1161
   (ndOvsLink, VTypeMaybeString),
1162
   (ndOvsName, VTypeMaybeString),
1163
   (ndSpindleCount, VTypeInt)]
1164

    
1165
ndsParameters :: FrozenSet String
1166
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
1167

    
1168
ndsParameterTitles :: Map String String
1169
ndsParameterTitles =
1170
  Map.fromList
1171
  [(ndExclusiveStorage, "ExclusiveStorage"),
1172
   (ndOobProgram, "OutOfBandProgram"),
1173
   (ndOvs, "OpenvSwitch"),
1174
   (ndOvsLink, "OpenvSwitchLink"),
1175
   (ndOvsName, "OpenvSwitchName"),
1176
   (ndSpindleCount, "SpindleCount")]
1177

    
1178
ipCommandPath :: String
1179
ipCommandPath = AutoConf.ipPath
1180

    
1181
-- * Reboot types
1182

    
1183
instanceRebootSoft :: String
1184
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1185

    
1186
instanceRebootHard :: String
1187
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1188

    
1189
instanceRebootFull :: String
1190
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1191

    
1192
rebootTypes :: FrozenSet String
1193
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1194

    
1195

    
1196

    
1197

    
1198

    
1199

    
1200

    
1201

    
1202
-- * OOB supported commands
1203

    
1204
oobPowerOn :: String
1205
oobPowerOn = Types.oobCommandToRaw OobPowerOn
1206

    
1207
oobPowerOff :: String
1208
oobPowerOff = Types.oobCommandToRaw OobPowerOff
1209

    
1210
oobPowerCycle :: String
1211
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
1212

    
1213
oobPowerStatus :: String
1214
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
1215

    
1216
oobHealth :: String
1217
oobHealth = Types.oobCommandToRaw OobHealth
1218

    
1219
oobCommands :: FrozenSet String
1220
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
1221

    
1222
oobPowerStatusPowered :: String
1223
oobPowerStatusPowered = "powered"
1224

    
1225
-- | 60 seconds
1226
oobTimeout :: Int
1227
oobTimeout = 60
1228

    
1229
-- | 2 seconds
1230
oobPowerDelay :: Double
1231
oobPowerDelay = 2.0
1232

    
1233
oobStatusCritical :: String
1234
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
1235

    
1236
oobStatusOk :: String
1237
oobStatusOk = Types.oobStatusToRaw OobStatusOk
1238

    
1239
oobStatusUnknown :: String
1240
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
1241

    
1242
oobStatusWarning :: String
1243
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
1244

    
1245
oobStatuses :: FrozenSet String
1246
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
1247

    
1248
-- * NIC_* constants are used inside the ganeti config
1249

    
1250
nicLink :: String
1251
nicLink = "link"
1252

    
1253
nicMode :: String
1254
nicMode = "mode"
1255

    
1256
nicVlan :: String
1257
nicVlan = "vlan"
1258

    
1259
nicModeBridged :: String
1260
nicModeBridged = Types.nICModeToRaw NMBridged
1261

    
1262
nicModeRouted :: String
1263
nicModeRouted = Types.nICModeToRaw NMRouted
1264

    
1265
nicModeOvs :: String
1266
nicModeOvs = Types.nICModeToRaw NMOvs
1267

    
1268
nicIpPool :: String
1269
nicIpPool = Types.nICModeToRaw NMPool
1270

    
1271
nicValidModes :: FrozenSet String
1272
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
1273

    
1274
-- * Hypervisor constants
1275

    
1276
htXenPvm :: String
1277
htXenPvm = Types.hypervisorToRaw XenPvm
1278

    
1279
htFake :: String
1280
htFake = Types.hypervisorToRaw Fake
1281

    
1282
htXenHvm :: String
1283
htXenHvm = Types.hypervisorToRaw XenHvm
1284

    
1285
htKvm :: String
1286
htKvm = Types.hypervisorToRaw Kvm
1287

    
1288
htChroot :: String
1289
htChroot = Types.hypervisorToRaw Chroot
1290

    
1291
htLxc :: String
1292
htLxc = Types.hypervisorToRaw Lxc
1293

    
1294
hyperTypes :: FrozenSet String
1295
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
1296

    
1297
htsReqPort :: FrozenSet String
1298
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
1299

    
1300
-- * Migration type
1301

    
1302
htMigrationLive :: String
1303
htMigrationLive = Types.migrationModeToRaw MigrationLive
1304

    
1305
htMigrationNonlive :: String
1306
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
1307

    
1308
htMigrationModes :: FrozenSet String
1309
htMigrationModes =
1310
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
1311

    
1312
-- * Cluster verify steps
1313

    
1314
verifyNplusoneMem :: String
1315
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
1316

    
1317
verifyOptionalChecks :: FrozenSet String
1318
verifyOptionalChecks =
1319
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
1320

    
1321
-- * Cluster Verify error classes
1322

    
1323
cvTcluster :: String
1324
cvTcluster = "cluster"
1325

    
1326
cvTgroup :: String
1327
cvTgroup = "group"
1328

    
1329
cvTnode :: String
1330
cvTnode = "node"
1331

    
1332
cvTinstance :: String
1333
cvTinstance = "instance"
1334

    
1335
-- * Cluster Verify error codes and documentation
1336

    
1337
cvEclustercert :: (String, String, String)
1338
cvEclustercert =
1339
  ("cluster",
1340
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
1341
   "Cluster certificate files verification failure")
1342

    
1343
cvEclustercfg :: (String, String, String)
1344
cvEclustercfg =
1345
  ("cluster",
1346
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
1347
   "Cluster configuration verification failure")
1348

    
1349
cvEclusterdanglinginst :: (String, String, String)
1350
cvEclusterdanglinginst =
1351
  ("node",
1352
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
1353
   "Some instances have a non-existing primary node")
1354

    
1355
cvEclusterdanglingnodes :: (String, String, String)
1356
cvEclusterdanglingnodes =
1357
  ("node",
1358
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
1359
   "Some nodes belong to non-existing groups")
1360

    
1361
cvEclusterfilecheck :: (String, String, String)
1362
cvEclusterfilecheck =
1363
  ("cluster",
1364
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
1365
   "Cluster configuration verification failure")
1366

    
1367
cvEgroupdifferentpvsize :: (String, String, String)
1368
cvEgroupdifferentpvsize =
1369
  ("group",
1370
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
1371
   "PVs in the group have different sizes")
1372

    
1373
cvEinstancebadnode :: (String, String, String)
1374
cvEinstancebadnode =
1375
  ("instance",
1376
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
1377
   "Instance marked as running lives on an offline node")
1378

    
1379
cvEinstancedown :: (String, String, String)
1380
cvEinstancedown =
1381
  ("instance",
1382
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
1383
   "Instance not running on its primary node")
1384

    
1385
cvEinstancefaultydisk :: (String, String, String)
1386
cvEinstancefaultydisk =
1387
  ("instance",
1388
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
1389
   "Impossible to retrieve status for a disk")
1390

    
1391
cvEinstancelayout :: (String, String, String)
1392
cvEinstancelayout =
1393
  ("instance",
1394
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
1395
   "Instance has multiple secondary nodes")
1396

    
1397
cvEinstancemissingcfgparameter :: (String, String, String)
1398
cvEinstancemissingcfgparameter =
1399
  ("instance",
1400
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
1401
   "A configuration parameter for an instance is missing")
1402

    
1403
cvEinstancemissingdisk :: (String, String, String)
1404
cvEinstancemissingdisk =
1405
  ("instance",
1406
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
1407
   "Missing volume on an instance")
1408

    
1409
cvEinstancepolicy :: (String, String, String)
1410
cvEinstancepolicy =
1411
  ("instance",
1412
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
1413
   "Instance does not meet policy")
1414

    
1415
cvEinstancesplitgroups :: (String, String, String)
1416
cvEinstancesplitgroups =
1417
  ("instance",
1418
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
1419
   "Instance with primary and secondary nodes in different groups")
1420

    
1421
cvEinstanceunsuitablenode :: (String, String, String)
1422
cvEinstanceunsuitablenode =
1423
  ("instance",
1424
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
1425
   "Instance running on nodes that are not suitable for it")
1426

    
1427
cvEinstancewrongnode :: (String, String, String)
1428
cvEinstancewrongnode =
1429
  ("instance",
1430
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
1431
   "Instance running on the wrong node")
1432

    
1433
cvEnodedrbd :: (String, String, String)
1434
cvEnodedrbd =
1435
  ("node",
1436
   Types.cVErrorCodeToRaw CvENODEDRBD,
1437
   "Error parsing the DRBD status file")
1438

    
1439
cvEnodedrbdhelper :: (String, String, String)
1440
cvEnodedrbdhelper =
1441
  ("node",
1442
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
1443
   "Error caused by the DRBD helper")
1444

    
1445
cvEnodedrbdversion :: (String, String, String)
1446
cvEnodedrbdversion =
1447
  ("node",
1448
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
1449
   "DRBD version mismatch within a node group")
1450

    
1451
cvEnodefilecheck :: (String, String, String)
1452
cvEnodefilecheck =
1453
  ("node",
1454
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
1455
   "Error retrieving the checksum of the node files")
1456

    
1457
cvEnodefilestoragepaths :: (String, String, String)
1458
cvEnodefilestoragepaths =
1459
  ("node",
1460
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
1461
   "Detected bad file storage paths")
1462

    
1463
cvEnodefilestoragepathunusable :: (String, String, String)
1464
cvEnodefilestoragepathunusable =
1465
  ("node",
1466
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
1467
   "File storage path unusable")
1468

    
1469
cvEnodehooks :: (String, String, String)
1470
cvEnodehooks =
1471
  ("node",
1472
   Types.cVErrorCodeToRaw CvENODEHOOKS,
1473
   "Communication failure in hooks execution")
1474

    
1475
cvEnodehv :: (String, String, String)
1476
cvEnodehv =
1477
  ("node",
1478
   Types.cVErrorCodeToRaw CvENODEHV,
1479
   "Hypervisor parameters verification failure")
1480

    
1481
cvEnodelvm :: (String, String, String)
1482
cvEnodelvm =
1483
  ("node",
1484
   Types.cVErrorCodeToRaw CvENODELVM,
1485
   "LVM-related node error")
1486

    
1487
cvEnoden1 :: (String, String, String)
1488
cvEnoden1 =
1489
  ("node",
1490
   Types.cVErrorCodeToRaw CvENODEN1,
1491
   "Not enough memory to accommodate instance failovers")
1492

    
1493
cvEnodenet :: (String, String, String)
1494
cvEnodenet =
1495
  ("node",
1496
   Types.cVErrorCodeToRaw CvENODENET,
1497
   "Network-related node error")
1498

    
1499
cvEnodeoobpath :: (String, String, String)
1500
cvEnodeoobpath =
1501
  ("node",
1502
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
1503
   "Invalid Out Of Band path")
1504

    
1505
cvEnodeorphaninstance :: (String, String, String)
1506
cvEnodeorphaninstance =
1507
  ("node",
1508
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
1509
   "Unknown intance running on a node")
1510

    
1511
cvEnodeorphanlv :: (String, String, String)
1512
cvEnodeorphanlv =
1513
  ("node",
1514
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
1515
   "Unknown LVM logical volume")
1516

    
1517
cvEnodeos :: (String, String, String)
1518
cvEnodeos =
1519
  ("node",
1520
   Types.cVErrorCodeToRaw CvENODEOS,
1521
   "OS-related node error")
1522

    
1523
cvEnoderpc :: (String, String, String)
1524
cvEnoderpc =
1525
  ("node",
1526
   Types.cVErrorCodeToRaw CvENODERPC,
1527
   "Error during connection to the primary node of an instance")
1528

    
1529
cvEnodesetup :: (String, String, String)
1530
cvEnodesetup =
1531
  ("node",
1532
   Types.cVErrorCodeToRaw CvENODESETUP,
1533
   "Node setup error")
1534

    
1535
cvEnodesharedfilestoragepathunusable :: (String, String, String)
1536
cvEnodesharedfilestoragepathunusable =
1537
  ("node",
1538
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
1539
   "Shared file storage path unusable")
1540

    
1541
cvEnodessh :: (String, String, String)
1542
cvEnodessh =
1543
  ("node",
1544
   Types.cVErrorCodeToRaw CvENODESSH,
1545
   "SSH-related node error")
1546

    
1547
cvEnodetime :: (String, String, String)
1548
cvEnodetime =
1549
  ("node",
1550
   Types.cVErrorCodeToRaw CvENODETIME,
1551
   "Node returned invalid time")
1552

    
1553
cvEnodeuserscripts :: (String, String, String)
1554
cvEnodeuserscripts =
1555
  ("node",
1556
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
1557
   "User scripts not present or not executable")
1558

    
1559
cvEnodeversion :: (String, String, String)
1560
cvEnodeversion =
1561
  ("node",
1562
   Types.cVErrorCodeToRaw CvENODEVERSION,
1563
   "Protocol version mismatch or Ganeti version mismatch")
1564

    
1565
cvAllEcodes :: FrozenSet (String, String, String)
1566
cvAllEcodes =
1567
  ConstantUtils.mkSet
1568
  [cvEclustercert,
1569
   cvEclustercfg,
1570
   cvEclusterdanglinginst,
1571
   cvEclusterdanglingnodes,
1572
   cvEclusterfilecheck,
1573
   cvEgroupdifferentpvsize,
1574
   cvEinstancebadnode,
1575
   cvEinstancedown,
1576
   cvEinstancefaultydisk,
1577
   cvEinstancelayout,
1578
   cvEinstancemissingcfgparameter,
1579
   cvEinstancemissingdisk,
1580
   cvEinstancepolicy,
1581
   cvEinstancesplitgroups,
1582
   cvEinstanceunsuitablenode,
1583
   cvEinstancewrongnode,
1584
   cvEnodedrbd,
1585
   cvEnodedrbdhelper,
1586
   cvEnodedrbdversion,
1587
   cvEnodefilecheck,
1588
   cvEnodefilestoragepaths,
1589
   cvEnodefilestoragepathunusable,
1590
   cvEnodehooks,
1591
   cvEnodehv,
1592
   cvEnodelvm,
1593
   cvEnoden1,
1594
   cvEnodenet,
1595
   cvEnodeoobpath,
1596
   cvEnodeorphaninstance,
1597
   cvEnodeorphanlv,
1598
   cvEnodeos,
1599
   cvEnoderpc,
1600
   cvEnodesetup,
1601
   cvEnodesharedfilestoragepathunusable,
1602
   cvEnodessh,
1603
   cvEnodetime,
1604
   cvEnodeuserscripts,
1605
   cvEnodeversion]
1606

    
1607
cvAllEcodesStrings :: FrozenSet String
1608
cvAllEcodesStrings =
1609
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
1610

    
1611
-- * Instance status
1612

    
1613
inststAdmindown :: String
1614
inststAdmindown = Types.instanceStatusToRaw StatusDown
1615

    
1616
inststAdminoffline :: String
1617
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
1618

    
1619
inststErrordown :: String
1620
inststErrordown = Types.instanceStatusToRaw ErrorDown
1621

    
1622
inststErrorup :: String
1623
inststErrorup = Types.instanceStatusToRaw ErrorUp
1624

    
1625
inststNodedown :: String
1626
inststNodedown = Types.instanceStatusToRaw NodeDown
1627

    
1628
inststNodeoffline :: String
1629
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
1630

    
1631
inststRunning :: String
1632
inststRunning = Types.instanceStatusToRaw Running
1633

    
1634
inststWrongnode :: String
1635
inststWrongnode = Types.instanceStatusToRaw WrongNode
1636

    
1637
inststAll :: FrozenSet String
1638
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
1639

    
1640
-- * Admin states
1641

    
1642
adminstDown :: String
1643
adminstDown = Types.adminStateToRaw AdminDown
1644

    
1645
adminstOffline :: String
1646
adminstOffline = Types.adminStateToRaw AdminOffline
1647

    
1648
adminstUp :: String
1649
adminstUp = Types.adminStateToRaw AdminUp
1650

    
1651
adminstAll :: FrozenSet String
1652
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
1653

    
1654
-- * Node roles
1655

    
1656
nrDrained :: String
1657
nrDrained = Types.nodeRoleToRaw NRDrained
1658

    
1659
nrMaster :: String
1660
nrMaster = Types.nodeRoleToRaw NRMaster
1661

    
1662
nrMcandidate :: String
1663
nrMcandidate = Types.nodeRoleToRaw NRCandidate
1664

    
1665
nrOffline :: String
1666
nrOffline = Types.nodeRoleToRaw NROffline
1667

    
1668
nrRegular :: String
1669
nrRegular = Types.nodeRoleToRaw NRRegular
1670

    
1671
nrAll :: FrozenSet String
1672
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
1673

    
1674
-- * Allocator framework constants
1675

    
1676
iallocatorVersion :: Int
1677
iallocatorVersion = 2
1678

    
1679
iallocatorDirIn :: String
1680
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
1681

    
1682
iallocatorDirOut :: String
1683
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
1684

    
1685
validIallocatorDirections :: FrozenSet String
1686
validIallocatorDirections =
1687
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
1688

    
1689
iallocatorModeAlloc :: String
1690
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
1691

    
1692
iallocatorModeChgGroup :: String
1693
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
1694

    
1695
iallocatorModeMultiAlloc :: String
1696
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
1697

    
1698
iallocatorModeNodeEvac :: String
1699
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
1700

    
1701
iallocatorModeReloc :: String
1702
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
1703

    
1704
validIallocatorModes :: FrozenSet String
1705
validIallocatorModes =
1706
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
1707

    
1708
iallocatorSearchPath :: [String]
1709
iallocatorSearchPath = AutoConf.iallocatorSearchPath
1710

    
1711
defaultIallocatorShortcut :: String
1712
defaultIallocatorShortcut = "."
1713

    
1714
-- * Node evacuation
1715

    
1716
nodeEvacPri :: String
1717
nodeEvacPri = Types.evacModeToRaw ChangePrimary
1718

    
1719
nodeEvacSec :: String
1720
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
1721

    
1722
nodeEvacAll :: String
1723
nodeEvacAll = Types.evacModeToRaw ChangeAll
1724

    
1725
nodeEvacModes :: FrozenSet String
1726
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
1727

    
1728
-- * Job status
1729

    
1730
jobStatusQueued :: String
1731
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
1732

    
1733
jobStatusWaiting :: String
1734
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
1735

    
1736
jobStatusCanceling :: String
1737
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
1738

    
1739
jobStatusRunning :: String
1740
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
1741

    
1742
jobStatusCanceled :: String
1743
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
1744

    
1745
jobStatusSuccess :: String
1746
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
1747

    
1748
jobStatusError :: String
1749
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
1750

    
1751
jobsPending :: FrozenSet String
1752
jobsPending =
1753
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
1754

    
1755
jobsFinalized :: FrozenSet String
1756
jobsFinalized =
1757
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
1758

    
1759
jobStatusAll :: FrozenSet String
1760
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
1761

    
1762
-- * OpCode status
1763

    
1764
-- ** Not yet finalized opcodes
1765

    
1766
opStatusCanceling :: String
1767
opStatusCanceling = "canceling"
1768

    
1769
opStatusQueued :: String
1770
opStatusQueued = "queued"
1771

    
1772
opStatusRunning :: String
1773
opStatusRunning = "running"
1774

    
1775
opStatusWaiting :: String
1776
opStatusWaiting = "waiting"
1777

    
1778
-- ** Finalized opcodes
1779

    
1780
opStatusCanceled :: String
1781
opStatusCanceled = "canceled"
1782

    
1783
opStatusError :: String
1784
opStatusError = "error"
1785

    
1786
opStatusSuccess :: String
1787
opStatusSuccess = "success"
1788

    
1789
opsFinalized :: FrozenSet String
1790
opsFinalized =
1791
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
1792

    
1793
-- * OpCode priority
1794

    
1795
opPrioLowest :: Int
1796
opPrioLowest = 19
1797

    
1798
opPrioHighest :: Int
1799
opPrioHighest = -20
1800

    
1801
opPrioLow :: Int
1802
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
1803

    
1804
opPrioNormal :: Int
1805
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
1806

    
1807
opPrioHigh :: Int
1808
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
1809

    
1810
opPrioSubmitValid :: FrozenSet Int
1811
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
1812

    
1813
opPrioDefault :: Int
1814
opPrioDefault = opPrioNormal
1815

    
1816
-- * Execution log types
1817

    
1818
elogMessage :: String
1819
elogMessage = Types.eLogTypeToRaw ELogMessage
1820

    
1821
elogRemoteImport :: String
1822
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
1823

    
1824
elogJqueueTest :: String
1825
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
1826

    
1827
-- * Confd
1828

    
1829
confdProtocolVersion :: Int
1830
confdProtocolVersion = ConstantUtils.confdProtocolVersion
1831

    
1832
-- Confd request type
1833

    
1834
confdReqPing :: Int
1835
confdReqPing = Types.confdRequestTypeToRaw ReqPing
1836

    
1837
confdReqNodeRoleByname :: Int
1838
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
1839

    
1840
confdReqNodePipByInstanceIp :: Int
1841
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
1842

    
1843
confdReqClusterMaster :: Int
1844
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
1845

    
1846
confdReqNodePipList :: Int
1847
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
1848

    
1849
confdReqMcPipList :: Int
1850
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
1851

    
1852
confdReqInstancesIpsList :: Int
1853
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
1854

    
1855
confdReqNodeDrbd :: Int
1856
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
1857

    
1858
confdReqNodeInstances :: Int
1859
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
1860

    
1861
confdReqs :: FrozenSet Int
1862
confdReqs =
1863
  ConstantUtils.mkSet .
1864
  map Types.confdRequestTypeToRaw $
1865
  [minBound..] \\ [ReqNodeInstances]
1866

    
1867
-- * Confd request type
1868

    
1869
confdReqfieldName :: Int
1870
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
1871

    
1872
confdReqfieldIp :: Int
1873
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
1874

    
1875
confdReqfieldMnodePip :: Int
1876
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
1877

    
1878
-- * Confd repl status
1879

    
1880
confdReplStatusOk :: Int
1881
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
1882

    
1883
confdReplStatusError :: Int
1884
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
1885

    
1886
confdReplStatusNotimplemented :: Int
1887
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
1888

    
1889
confdReplStatuses :: FrozenSet Int
1890
confdReplStatuses =
1891
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
1892

    
1893
-- * Confd node role
1894

    
1895
confdNodeRoleMaster :: Int
1896
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
1897

    
1898
confdNodeRoleCandidate :: Int
1899
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
1900

    
1901
confdNodeRoleOffline :: Int
1902
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
1903

    
1904
confdNodeRoleDrained :: Int
1905
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
1906

    
1907
confdNodeRoleRegular :: Int
1908
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
1909

    
1910
-- * A few common errors for confd
1911

    
1912
confdErrorUnknownEntry :: Int
1913
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
1914

    
1915
confdErrorInternal :: Int
1916
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
1917

    
1918
confdErrorArgument :: Int
1919
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
1920

    
1921
-- * Confd request query fields
1922

    
1923
confdReqqLink :: String
1924
confdReqqLink = ConstantUtils.confdReqqLink
1925

    
1926
confdReqqIp :: String
1927
confdReqqIp = ConstantUtils.confdReqqIp
1928

    
1929
confdReqqIplist :: String
1930
confdReqqIplist = ConstantUtils.confdReqqIplist
1931

    
1932
confdReqqFields :: String
1933
confdReqqFields = ConstantUtils.confdReqqFields
1934

    
1935
-- | Each request is "salted" by the current timestamp.
1936
--
1937
-- This constant decides how many seconds of skew to accept.
1938
--
1939
-- TODO: make this a default and allow the value to be more
1940
-- configurable
1941
confdMaxClockSkew :: Int
1942
confdMaxClockSkew = 2 * nodeMaxClockSkew
1943

    
1944
-- | When we haven't reloaded the config for more than this amount of
1945
-- seconds, we force a test to see if inotify is betraying us. Using a
1946
-- prime number to ensure we get less chance of 'same wakeup' with
1947
-- other processes.
1948
confdConfigReloadTimeout :: Int
1949
confdConfigReloadTimeout = 17
1950

    
1951
-- | If we receive more than one update in this amount of
1952
-- microseconds, we move to polling every RATELIMIT seconds, rather
1953
-- than relying on inotify, to be able to serve more requests.
1954
confdConfigReloadRatelimit :: Int
1955
confdConfigReloadRatelimit = 250000
1956

    
1957
-- | Magic number prepended to all confd queries.
1958
--
1959
-- This allows us to distinguish different types of confd protocols
1960
-- and handle them. For example by changing this we can move the whole
1961
-- payload to be compressed, or move away from json.
1962
confdMagicFourcc :: String
1963
confdMagicFourcc = "plj0"
1964

    
1965
-- | By default a confd request is sent to the minimum between this
1966
-- number and all MCs. 6 was chosen because even in the case of a
1967
-- disastrous 50% response rate, we should have enough answers to be
1968
-- able to compare more than one.
1969
confdDefaultReqCoverage :: Int
1970
confdDefaultReqCoverage = 6
1971

    
1972
-- | Timeout in seconds to expire pending query request in the confd
1973
-- client library. We don't actually expect any answer more than 10
1974
-- seconds after we sent a request.
1975
confdClientExpireTimeout :: Int
1976
confdClientExpireTimeout = 10
1977

    
1978
-- * Possible values for NodeGroup.alloc_policy
1979

    
1980
allocPolicyLastResort :: String
1981
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
1982

    
1983
allocPolicyPreferred :: String
1984
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
1985

    
1986
allocPolicyUnallocable :: String
1987
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
1988

    
1989
validAllocPolicies :: [String]
1990
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
1991

    
1992
-- | Temporary external/shared storage parameters
1993
blockdevDriverManual :: String
1994
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
1995

    
1996
-- | 'qemu-img' path, required for 'ovfconverter'
1997
qemuimgPath :: String
1998
qemuimgPath = AutoConf.qemuimgPath
1999

    
2000
-- | Whether htools was enabled at compilation time
2001
--
2002
-- FIXME: this should be moved next to the other enable constants,
2003
-- such as, 'enableConfd', and renamed to 'enableHtools'.
2004
htools :: Bool
2005
htools = AutoConf.htools
2006

    
2007
-- * Key files for SSH daemon
2008

    
2009
sshHostDsaPriv :: String
2010
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
2011

    
2012
sshHostDsaPub :: String
2013
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
2014

    
2015
sshHostRsaPriv :: String
2016
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
2017

    
2018
sshHostRsaPub :: String
2019
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
2020

    
2021
-- | Path generating random UUID
2022
randomUuidFile :: String
2023
randomUuidFile = ConstantUtils.randomUuidFile
2024

    
2025
-- * Auto-repair tag prefixes
2026

    
2027
autoRepairTagPrefix :: String
2028
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
2029

    
2030
autoRepairTagEnabled :: String
2031
autoRepairTagEnabled = autoRepairTagPrefix
2032

    
2033
autoRepairTagPending :: String
2034
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
2035

    
2036
autoRepairTagResult :: String
2037
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
2038

    
2039
autoRepairTagSuspended :: String
2040
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
2041

    
2042
-- * Auto-repair levels
2043

    
2044
autoRepairFailover :: String
2045
autoRepairFailover = "failover"
2046

    
2047
autoRepairFixStorage :: String
2048
autoRepairFixStorage = "fix-storage"
2049

    
2050
autoRepairMigrate :: String
2051
autoRepairMigrate = "migrate"
2052

    
2053
autoRepairReinstall :: String
2054
autoRepairReinstall = "reinstall"
2055

    
2056
autoRepairAllTypes :: FrozenSet String
2057
autoRepairAllTypes =
2058
  ConstantUtils.mkSet [autoRepairFailover,
2059
                       autoRepairFixStorage,
2060
                       autoRepairMigrate,
2061
                       autoRepairReinstall]
2062

    
2063
-- * Auto-repair results
2064

    
2065
autoRepairEnoperm :: String
2066
autoRepairEnoperm = "enoperm"
2067

    
2068
autoRepairFailure :: String
2069
autoRepairFailure = "failure"
2070

    
2071
autoRepairSuccess :: String
2072
autoRepairSuccess = "success"
2073

    
2074
autoRepairAllResults :: FrozenSet String
2075
autoRepairAllResults =
2076
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
2077

    
2078
-- | The version identifier for builtin data collectors
2079
builtinDataCollectorVersion :: String
2080
builtinDataCollectorVersion = "B"
2081

    
2082
-- | The reason trail opcode parameter name
2083
opcodeReason :: String
2084
opcodeReason = "reason"
2085

    
2086
diskstatsFile :: String
2087
diskstatsFile = "/proc/diskstats"
2088

    
2089
-- *  CPU load collector
2090

    
2091
statFile :: String
2092
statFile = "/proc/stat"
2093

    
2094
cpuavgloadBufferSize :: Int
2095
cpuavgloadBufferSize = 150
2096

    
2097
cpuavgloadWindowSize :: Int
2098
cpuavgloadWindowSize = 600
2099

    
2100
-- | Mond's variable for periodical data collection
2101
mondTimeInterval :: Int
2102
mondTimeInterval = 5
2103

    
2104
-- * Disk access modes
2105

    
2106
diskUserspace :: String
2107
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
2108

    
2109
diskKernelspace :: String
2110
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
2111

    
2112
diskValidAccessModes :: FrozenSet String
2113
diskValidAccessModes =
2114
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
2115

    
2116
-- | Timeout for queue draining in upgrades
2117
upgradeQueueDrainTimeout :: Int
2118
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
2119

    
2120
-- | Intervall at which the queue is polled during upgrades
2121
upgradeQueuePollInterval :: Int
2122
upgradeQueuePollInterval  = 10