Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ ae8e7986

History | View | Annotate | Download (57.3 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
-- * Drbd
858

    
859
drbdHmacAlg :: String
860
drbdHmacAlg = "md5"
861

    
862
drbdDefaultNetProtocol :: String
863
drbdDefaultNetProtocol = "C"
864

    
865
drbdMigrationNetProtocol :: String
866
drbdMigrationNetProtocol = "C"
867

    
868
drbdStatusFile :: String
869
drbdStatusFile = "/proc/drbd"
870

    
871
-- | Size of DRBD meta block device
872
drbdMetaSize :: Int
873
drbdMetaSize = 128
874

    
875
-- * Drbd barrier types
876

    
877
drbdBDiskBarriers :: String
878
drbdBDiskBarriers = "b"
879

    
880
drbdBDiskDrain :: String
881
drbdBDiskDrain = "d"
882

    
883
drbdBDiskFlush :: String
884
drbdBDiskFlush = "f"
885

    
886
drbdBNone :: String
887
drbdBNone = "n"
888

    
889
-- | Rbd tool command
890
rbdCmd :: String
891
rbdCmd = "rbd"
892

    
893
-- * File backend driver
894

    
895
fdBlktap :: String
896
fdBlktap = Types.fileDriverToRaw FileBlktap
897

    
898
fdLoop :: String
899
fdLoop = Types.fileDriverToRaw FileLoop
900

    
901
fileDriver :: FrozenSet String
902
fileDriver =
903
  ConstantUtils.mkSet $
904
  map Types.fileDriverToRaw [minBound..]
905

    
906
-- | The set of drbd-like disk types
907
ldsDrbd :: FrozenSet String
908
ldsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
909

    
910
-- * Disk access mode
911

    
912
diskRdonly :: String
913
diskRdonly = Types.diskModeToRaw DiskRdOnly
914

    
915
diskRdwr :: String
916
diskRdwr = Types.diskModeToRaw DiskRdWr
917

    
918
diskAccessSet :: FrozenSet String
919
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
920

    
921
-- * Disk replacement mode
922

    
923
replaceDiskAuto :: String
924
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
925

    
926
replaceDiskChg :: String
927
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
928

    
929
replaceDiskPri :: String
930
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
931

    
932
replaceDiskSec :: String
933
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
934

    
935
replaceModes :: FrozenSet String
936
replaceModes =
937
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
938

    
939
-- * Instance export mode
940

    
941
exportModeLocal :: String
942
exportModeLocal = Types.exportModeToRaw ExportModeLocal
943

    
944
exportModeRemote :: String
945
exportModeRemote = Types.exportModeToRaw ExportModeRemote
946

    
947
exportModes :: FrozenSet String
948
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
949

    
950
-- * Instance creation modes
951

    
952
instanceCreate :: String
953
instanceCreate = Types.instCreateModeToRaw InstCreate
954

    
955
instanceImport :: String
956
instanceImport = Types.instCreateModeToRaw InstImport
957

    
958
instanceRemoteImport :: String
959
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
960

    
961
instanceCreateModes :: FrozenSet String
962
instanceCreateModes =
963
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
964

    
965
-- * Remote import/export handshake message and version
966

    
967
rieHandshake :: String
968
rieHandshake = "Hi, I'm Ganeti"
969

    
970
rieVersion :: Int
971
rieVersion = 0
972

    
973
-- | Remote import/export certificate validity in seconds
974
rieCertValidity :: Int
975
rieCertValidity = 24 * 60 * 60
976

    
977
-- | Export only: how long to wait per connection attempt (seconds)
978
rieConnectAttemptTimeout :: Int
979
rieConnectAttemptTimeout = 20
980

    
981
-- | Export only: number of attempts to connect
982
rieConnectRetries :: Int
983
rieConnectRetries = 10
984

    
985
-- | Overall timeout for establishing connection
986
rieConnectTimeout :: Int
987
rieConnectTimeout = 180
988

    
989
-- | Give child process up to 5 seconds to exit after sending a signal
990
childLingerTimeout :: Double
991
childLingerTimeout = 5.0
992

    
993
-- * Import/export config options
994

    
995
inisectBep :: String
996
inisectBep = "backend"
997

    
998
inisectExp :: String
999
inisectExp = "export"
1000

    
1001
inisectHyp :: String
1002
inisectHyp = "hypervisor"
1003

    
1004
inisectIns :: String
1005
inisectIns = "instance"
1006

    
1007
inisectOsp :: String
1008
inisectOsp = "os"
1009

    
1010
-- * Dynamic device modification
1011

    
1012
ddmAdd :: String
1013
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1014

    
1015
ddmModify :: String
1016
ddmModify = Types.ddmFullToRaw DdmFullModify
1017

    
1018
ddmRemove :: String
1019
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1020

    
1021
ddmsValues :: FrozenSet String
1022
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1023

    
1024
ddmsValuesWithModify :: FrozenSet String
1025
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1026

    
1027
-- * Common exit codes
1028

    
1029
exitSuccess :: Int
1030
exitSuccess = 0
1031

    
1032
exitFailure :: Int
1033
exitFailure = ConstantUtils.exitFailure
1034

    
1035
exitNotcluster :: Int
1036
exitNotcluster = 5
1037

    
1038
exitNotmaster :: Int
1039
exitNotmaster = 11
1040

    
1041
exitNodesetupError :: Int
1042
exitNodesetupError = 12
1043

    
1044
-- | Need user confirmation
1045
exitConfirmation :: Int
1046
exitConfirmation = 13
1047

    
1048
-- | Exit code for query operations with unknown fields
1049
exitUnknownField :: Int
1050
exitUnknownField = 14
1051

    
1052
-- * Tags
1053

    
1054
tagCluster :: String
1055
tagCluster = Types.tagKindToRaw TagKindCluster
1056

    
1057
tagInstance :: String
1058
tagInstance = Types.tagKindToRaw TagKindInstance
1059

    
1060
tagNetwork :: String
1061
tagNetwork = Types.tagKindToRaw TagKindNetwork
1062

    
1063
tagNode :: String
1064
tagNode = Types.tagKindToRaw TagKindNode
1065

    
1066
tagNodegroup :: String
1067
tagNodegroup = Types.tagKindToRaw TagKindGroup
1068

    
1069
validTagTypes :: FrozenSet String
1070
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1071

    
1072
maxTagLen :: Int
1073
maxTagLen = 128
1074

    
1075
maxTagsPerObj :: Int
1076
maxTagsPerObj = 4096
1077

    
1078
-- * Others
1079

    
1080
defaultBridge :: String
1081
defaultBridge = "xen-br0"
1082

    
1083
defaultOvs :: String
1084
defaultOvs = "switch1"
1085

    
1086
-- | 60 MiB, expressed in KiB
1087
classicDrbdSyncSpeed :: Int
1088
classicDrbdSyncSpeed = 60 * 1024
1089

    
1090
ip4AddressAny :: String
1091
ip4AddressAny = "0.0.0.0"
1092

    
1093
ip4AddressLocalhost :: String
1094
ip4AddressLocalhost = "127.0.0.1"
1095

    
1096
ip6AddressAny :: String
1097
ip6AddressAny = "::"
1098

    
1099
ip6AddressLocalhost :: String
1100
ip6AddressLocalhost = "::1"
1101

    
1102
ip4Version :: Int
1103
ip4Version = 4
1104

    
1105
ip6Version :: Int
1106
ip6Version = 6
1107

    
1108
validIpVersions :: FrozenSet Int
1109
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1110

    
1111
tcpPingTimeout :: Int
1112
tcpPingTimeout = 10
1113

    
1114
defaultVg :: String
1115
defaultVg = "xenvg"
1116

    
1117
defaultDrbdHelper :: String
1118
defaultDrbdHelper = "/bin/true"
1119

    
1120
minVgSize :: Int
1121
minVgSize = 20480
1122

    
1123
defaultMacPrefix :: String
1124
defaultMacPrefix = "aa:00:00"
1125

    
1126
-- | Default maximum instance wait time, in seconds.
1127
defaultShutdownTimeout :: Int
1128
defaultShutdownTimeout = 120
1129

    
1130
-- | Node clock skew in seconds
1131
nodeMaxClockSkew :: Int
1132
nodeMaxClockSkew = 150
1133

    
1134
-- | Time for an intra-cluster disk transfer to wait for a connection
1135
diskTransferConnectTimeout :: Int
1136
diskTransferConnectTimeout = 60
1137

    
1138
-- | Disk index separator
1139
diskSeparator :: String
1140
diskSeparator = AutoConf.diskSeparator
1141

    
1142
ipCommandPath :: String
1143
ipCommandPath = AutoConf.ipPath
1144

    
1145
-- | Key for job IDs in opcode result
1146
jobIdsKey :: String
1147
jobIdsKey = "jobs"
1148

    
1149
-- * Runparts results
1150

    
1151
runpartsErr :: Int
1152
runpartsErr = 2
1153

    
1154
runpartsRun :: Int
1155
runpartsRun = 1
1156

    
1157
runpartsSkip :: Int
1158
runpartsSkip = 0
1159

    
1160
runpartsStatus :: [Int]
1161
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1162

    
1163
-- * RPC
1164

    
1165
rpcEncodingNone :: Int
1166
rpcEncodingNone = 0
1167

    
1168
rpcEncodingZlibBase64 :: Int
1169
rpcEncodingZlibBase64 = 1
1170

    
1171
-- * Timeout table
1172
--
1173
-- Various time constants for the timeout table
1174

    
1175
rpcTmoUrgent :: Int
1176
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1177

    
1178
rpcTmoFast :: Int
1179
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1180

    
1181
rpcTmoNormal :: Int
1182
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1183

    
1184
rpcTmoSlow :: Int
1185
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1186

    
1187
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1188
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1189
-- Python name.
1190
rpcTmo_4hrs :: Int
1191
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1192

    
1193
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1194
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1195
-- Python name.
1196
rpcTmo_1day :: Int
1197
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1198

    
1199
-- | Timeout for connecting to nodes (seconds)
1200
rpcConnectTimeout :: Int
1201
rpcConnectTimeout = 5
1202

    
1203
-- OS
1204

    
1205
osScriptCreate :: String
1206
osScriptCreate = "create"
1207

    
1208
osScriptExport :: String
1209
osScriptExport = "export"
1210

    
1211
osScriptImport :: String
1212
osScriptImport = "import"
1213

    
1214
osScriptRename :: String
1215
osScriptRename = "rename"
1216

    
1217
osScriptVerify :: String
1218
osScriptVerify = "verify"
1219

    
1220
osScripts :: [String]
1221
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1222
             osScriptVerify]
1223

    
1224
osApiFile :: String
1225
osApiFile = "ganeti_api_version"
1226

    
1227
osVariantsFile :: String
1228
osVariantsFile = "variants.list"
1229

    
1230
osParametersFile :: String
1231
osParametersFile = "parameters.list"
1232

    
1233
osValidateParameters :: String
1234
osValidateParameters = "parameters"
1235

    
1236
osValidateCalls :: FrozenSet String
1237
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1238

    
1239
-- | External Storage (ES) related constants
1240

    
1241
esActionAttach :: String
1242
esActionAttach = "attach"
1243

    
1244
esActionCreate :: String
1245
esActionCreate = "create"
1246

    
1247
esActionDetach :: String
1248
esActionDetach = "detach"
1249

    
1250
esActionGrow :: String
1251
esActionGrow = "grow"
1252

    
1253
esActionRemove :: String
1254
esActionRemove = "remove"
1255

    
1256
esActionSetinfo :: String
1257
esActionSetinfo = "setinfo"
1258

    
1259
esActionVerify :: String
1260
esActionVerify = "verify"
1261

    
1262
esScriptCreate :: String
1263
esScriptCreate = esActionCreate
1264

    
1265
esScriptRemove :: String
1266
esScriptRemove = esActionRemove
1267

    
1268
esScriptGrow :: String
1269
esScriptGrow = esActionGrow
1270

    
1271
esScriptAttach :: String
1272
esScriptAttach = esActionAttach
1273

    
1274
esScriptDetach :: String
1275
esScriptDetach = esActionDetach
1276

    
1277
esScriptSetinfo :: String
1278
esScriptSetinfo = esActionSetinfo
1279

    
1280
esScriptVerify :: String
1281
esScriptVerify = esActionVerify
1282

    
1283
esScripts :: FrozenSet String
1284
esScripts =
1285
  ConstantUtils.mkSet [esScriptAttach,
1286
                       esScriptCreate,
1287
                       esScriptDetach,
1288
                       esScriptGrow,
1289
                       esScriptRemove,
1290
                       esScriptSetinfo,
1291
                       esScriptVerify]
1292

    
1293
esParametersFile :: String
1294
esParametersFile = "parameters.list"
1295

    
1296
-- * Reboot types
1297

    
1298
instanceRebootSoft :: String
1299
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1300

    
1301
instanceRebootHard :: String
1302
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1303

    
1304
instanceRebootFull :: String
1305
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1306

    
1307
rebootTypes :: FrozenSet String
1308
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1309

    
1310
-- * Instance reboot behaviors
1311

    
1312
instanceRebootAllowed :: String
1313
instanceRebootAllowed = "reboot"
1314

    
1315
instanceRebootExit :: String
1316
instanceRebootExit = "exit"
1317

    
1318
rebootBehaviors :: [String]
1319
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1320

    
1321
-- * VTypes
1322

    
1323
vtypeBool :: VType
1324
vtypeBool = VTypeBool
1325

    
1326
vtypeInt :: VType
1327
vtypeInt = VTypeInt
1328

    
1329
vtypeMaybeString :: VType
1330
vtypeMaybeString = VTypeMaybeString
1331

    
1332
-- | Size in MiBs
1333
vtypeSize :: VType
1334
vtypeSize = VTypeSize
1335

    
1336
vtypeString :: VType
1337
vtypeString = VTypeString
1338

    
1339
enforceableTypes :: FrozenSet VType
1340
enforceableTypes = ConstantUtils.mkSet [minBound..]
1341

    
1342
-- | Instance specs
1343
--
1344
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1345

    
1346
ispecMemSize :: String
1347
ispecMemSize = ConstantUtils.ispecMemSize
1348

    
1349
ispecCpuCount :: String
1350
ispecCpuCount = ConstantUtils.ispecCpuCount
1351

    
1352
ispecDiskCount :: String
1353
ispecDiskCount = ConstantUtils.ispecDiskCount
1354

    
1355
ispecDiskSize :: String
1356
ispecDiskSize = ConstantUtils.ispecDiskSize
1357

    
1358
ispecNicCount :: String
1359
ispecNicCount = ConstantUtils.ispecNicCount
1360

    
1361
ispecSpindleUse :: String
1362
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1363

    
1364
ispecsParameterTypes :: Map String VType
1365
ispecsParameterTypes =
1366
  Map.fromList
1367
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1368
   (ConstantUtils.ispecCpuCount, VTypeInt),
1369
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1370
   (ConstantUtils.ispecMemSize, VTypeInt),
1371
   (ConstantUtils.ispecNicCount, VTypeInt),
1372
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1373

    
1374
ispecsParameters :: FrozenSet String
1375
ispecsParameters =
1376
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1377
                       ConstantUtils.ispecDiskCount,
1378
                       ConstantUtils.ispecDiskSize,
1379
                       ConstantUtils.ispecMemSize,
1380
                       ConstantUtils.ispecNicCount,
1381
                       ConstantUtils.ispecSpindleUse]
1382

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

    
1386
ispecsMax :: String
1387
ispecsMax = "max"
1388

    
1389
ispecsMin :: String
1390
ispecsMin = "min"
1391

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

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

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

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

    
1404
ispecsMinmaxKeys :: FrozenSet String
1405
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1406

    
1407
ipolicyParameters :: FrozenSet String
1408
ipolicyParameters =
1409
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1410
                       ConstantUtils.ipolicySpindleRatio]
1411

    
1412
ipolicyAllKeys :: FrozenSet String
1413
ipolicyAllKeys =
1414
  ConstantUtils.union ipolicyParameters $
1415
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1416
                       ConstantUtils.ispecsMinmax,
1417
                       ispecsStd]
1418

    
1419
-- | Node parameter names
1420

    
1421
ndExclusiveStorage :: String
1422
ndExclusiveStorage = "exclusive_storage"
1423

    
1424
ndOobProgram :: String
1425
ndOobProgram = "oob_program"
1426

    
1427
ndSpindleCount :: String
1428
ndSpindleCount = "spindle_count"
1429

    
1430
ndOvs :: String
1431
ndOvs = "ovs"
1432

    
1433
ndOvsLink :: String
1434
ndOvsLink = "ovs_link"
1435

    
1436
ndOvsName :: String
1437
ndOvsName = "ovs_name"
1438

    
1439
ndsParameterTypes :: Map String VType
1440
ndsParameterTypes =
1441
  Map.fromList
1442
  [(ndExclusiveStorage, VTypeBool),
1443
   (ndOobProgram, VTypeString),
1444
   (ndOvs, VTypeBool),
1445
   (ndOvsLink, VTypeMaybeString),
1446
   (ndOvsName, VTypeMaybeString),
1447
   (ndSpindleCount, VTypeInt)]
1448

    
1449
ndsParameters :: FrozenSet String
1450
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
1451

    
1452
ndsParameterTitles :: Map String String
1453
ndsParameterTitles =
1454
  Map.fromList
1455
  [(ndExclusiveStorage, "ExclusiveStorage"),
1456
   (ndOobProgram, "OutOfBandProgram"),
1457
   (ndOvs, "OpenvSwitch"),
1458
   (ndOvsLink, "OpenvSwitchLink"),
1459
   (ndOvsName, "OpenvSwitchName"),
1460
   (ndSpindleCount, "SpindleCount")]
1461

    
1462

    
1463

    
1464

    
1465

    
1466

    
1467

    
1468
-- * OOB supported commands
1469

    
1470
oobPowerOn :: String
1471
oobPowerOn = Types.oobCommandToRaw OobPowerOn
1472

    
1473
oobPowerOff :: String
1474
oobPowerOff = Types.oobCommandToRaw OobPowerOff
1475

    
1476
oobPowerCycle :: String
1477
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
1478

    
1479
oobPowerStatus :: String
1480
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
1481

    
1482
oobHealth :: String
1483
oobHealth = Types.oobCommandToRaw OobHealth
1484

    
1485
oobCommands :: FrozenSet String
1486
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
1487

    
1488
oobPowerStatusPowered :: String
1489
oobPowerStatusPowered = "powered"
1490

    
1491
-- | 60 seconds
1492
oobTimeout :: Int
1493
oobTimeout = 60
1494

    
1495
-- | 2 seconds
1496
oobPowerDelay :: Double
1497
oobPowerDelay = 2.0
1498

    
1499
oobStatusCritical :: String
1500
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
1501

    
1502
oobStatusOk :: String
1503
oobStatusOk = Types.oobStatusToRaw OobStatusOk
1504

    
1505
oobStatusUnknown :: String
1506
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
1507

    
1508
oobStatusWarning :: String
1509
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
1510

    
1511
oobStatuses :: FrozenSet String
1512
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
1513

    
1514
-- * NIC_* constants are used inside the ganeti config
1515

    
1516
nicLink :: String
1517
nicLink = "link"
1518

    
1519
nicMode :: String
1520
nicMode = "mode"
1521

    
1522
nicVlan :: String
1523
nicVlan = "vlan"
1524

    
1525
nicModeBridged :: String
1526
nicModeBridged = Types.nICModeToRaw NMBridged
1527

    
1528
nicModeRouted :: String
1529
nicModeRouted = Types.nICModeToRaw NMRouted
1530

    
1531
nicModeOvs :: String
1532
nicModeOvs = Types.nICModeToRaw NMOvs
1533

    
1534
nicIpPool :: String
1535
nicIpPool = Types.nICModeToRaw NMPool
1536

    
1537
nicValidModes :: FrozenSet String
1538
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
1539

    
1540
-- * Hypervisor constants
1541

    
1542
htXenPvm :: String
1543
htXenPvm = Types.hypervisorToRaw XenPvm
1544

    
1545
htFake :: String
1546
htFake = Types.hypervisorToRaw Fake
1547

    
1548
htXenHvm :: String
1549
htXenHvm = Types.hypervisorToRaw XenHvm
1550

    
1551
htKvm :: String
1552
htKvm = Types.hypervisorToRaw Kvm
1553

    
1554
htChroot :: String
1555
htChroot = Types.hypervisorToRaw Chroot
1556

    
1557
htLxc :: String
1558
htLxc = Types.hypervisorToRaw Lxc
1559

    
1560
hyperTypes :: FrozenSet String
1561
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
1562

    
1563
htsReqPort :: FrozenSet String
1564
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
1565

    
1566
-- * Migration type
1567

    
1568
htMigrationLive :: String
1569
htMigrationLive = Types.migrationModeToRaw MigrationLive
1570

    
1571
htMigrationNonlive :: String
1572
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
1573

    
1574
htMigrationModes :: FrozenSet String
1575
htMigrationModes =
1576
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
1577

    
1578
-- * Cluster verify steps
1579

    
1580
verifyNplusoneMem :: String
1581
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
1582

    
1583
verifyOptionalChecks :: FrozenSet String
1584
verifyOptionalChecks =
1585
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
1586

    
1587
-- * Cluster Verify error classes
1588

    
1589
cvTcluster :: String
1590
cvTcluster = "cluster"
1591

    
1592
cvTgroup :: String
1593
cvTgroup = "group"
1594

    
1595
cvTnode :: String
1596
cvTnode = "node"
1597

    
1598
cvTinstance :: String
1599
cvTinstance = "instance"
1600

    
1601
-- * Cluster Verify error codes and documentation
1602

    
1603
cvEclustercert :: (String, String, String)
1604
cvEclustercert =
1605
  ("cluster",
1606
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
1607
   "Cluster certificate files verification failure")
1608

    
1609
cvEclustercfg :: (String, String, String)
1610
cvEclustercfg =
1611
  ("cluster",
1612
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
1613
   "Cluster configuration verification failure")
1614

    
1615
cvEclusterdanglinginst :: (String, String, String)
1616
cvEclusterdanglinginst =
1617
  ("node",
1618
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
1619
   "Some instances have a non-existing primary node")
1620

    
1621
cvEclusterdanglingnodes :: (String, String, String)
1622
cvEclusterdanglingnodes =
1623
  ("node",
1624
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
1625
   "Some nodes belong to non-existing groups")
1626

    
1627
cvEclusterfilecheck :: (String, String, String)
1628
cvEclusterfilecheck =
1629
  ("cluster",
1630
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
1631
   "Cluster configuration verification failure")
1632

    
1633
cvEgroupdifferentpvsize :: (String, String, String)
1634
cvEgroupdifferentpvsize =
1635
  ("group",
1636
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
1637
   "PVs in the group have different sizes")
1638

    
1639
cvEinstancebadnode :: (String, String, String)
1640
cvEinstancebadnode =
1641
  ("instance",
1642
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
1643
   "Instance marked as running lives on an offline node")
1644

    
1645
cvEinstancedown :: (String, String, String)
1646
cvEinstancedown =
1647
  ("instance",
1648
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
1649
   "Instance not running on its primary node")
1650

    
1651
cvEinstancefaultydisk :: (String, String, String)
1652
cvEinstancefaultydisk =
1653
  ("instance",
1654
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
1655
   "Impossible to retrieve status for a disk")
1656

    
1657
cvEinstancelayout :: (String, String, String)
1658
cvEinstancelayout =
1659
  ("instance",
1660
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
1661
   "Instance has multiple secondary nodes")
1662

    
1663
cvEinstancemissingcfgparameter :: (String, String, String)
1664
cvEinstancemissingcfgparameter =
1665
  ("instance",
1666
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
1667
   "A configuration parameter for an instance is missing")
1668

    
1669
cvEinstancemissingdisk :: (String, String, String)
1670
cvEinstancemissingdisk =
1671
  ("instance",
1672
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
1673
   "Missing volume on an instance")
1674

    
1675
cvEinstancepolicy :: (String, String, String)
1676
cvEinstancepolicy =
1677
  ("instance",
1678
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
1679
   "Instance does not meet policy")
1680

    
1681
cvEinstancesplitgroups :: (String, String, String)
1682
cvEinstancesplitgroups =
1683
  ("instance",
1684
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
1685
   "Instance with primary and secondary nodes in different groups")
1686

    
1687
cvEinstanceunsuitablenode :: (String, String, String)
1688
cvEinstanceunsuitablenode =
1689
  ("instance",
1690
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
1691
   "Instance running on nodes that are not suitable for it")
1692

    
1693
cvEinstancewrongnode :: (String, String, String)
1694
cvEinstancewrongnode =
1695
  ("instance",
1696
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
1697
   "Instance running on the wrong node")
1698

    
1699
cvEnodedrbd :: (String, String, String)
1700
cvEnodedrbd =
1701
  ("node",
1702
   Types.cVErrorCodeToRaw CvENODEDRBD,
1703
   "Error parsing the DRBD status file")
1704

    
1705
cvEnodedrbdhelper :: (String, String, String)
1706
cvEnodedrbdhelper =
1707
  ("node",
1708
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
1709
   "Error caused by the DRBD helper")
1710

    
1711
cvEnodedrbdversion :: (String, String, String)
1712
cvEnodedrbdversion =
1713
  ("node",
1714
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
1715
   "DRBD version mismatch within a node group")
1716

    
1717
cvEnodefilecheck :: (String, String, String)
1718
cvEnodefilecheck =
1719
  ("node",
1720
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
1721
   "Error retrieving the checksum of the node files")
1722

    
1723
cvEnodefilestoragepaths :: (String, String, String)
1724
cvEnodefilestoragepaths =
1725
  ("node",
1726
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
1727
   "Detected bad file storage paths")
1728

    
1729
cvEnodefilestoragepathunusable :: (String, String, String)
1730
cvEnodefilestoragepathunusable =
1731
  ("node",
1732
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
1733
   "File storage path unusable")
1734

    
1735
cvEnodehooks :: (String, String, String)
1736
cvEnodehooks =
1737
  ("node",
1738
   Types.cVErrorCodeToRaw CvENODEHOOKS,
1739
   "Communication failure in hooks execution")
1740

    
1741
cvEnodehv :: (String, String, String)
1742
cvEnodehv =
1743
  ("node",
1744
   Types.cVErrorCodeToRaw CvENODEHV,
1745
   "Hypervisor parameters verification failure")
1746

    
1747
cvEnodelvm :: (String, String, String)
1748
cvEnodelvm =
1749
  ("node",
1750
   Types.cVErrorCodeToRaw CvENODELVM,
1751
   "LVM-related node error")
1752

    
1753
cvEnoden1 :: (String, String, String)
1754
cvEnoden1 =
1755
  ("node",
1756
   Types.cVErrorCodeToRaw CvENODEN1,
1757
   "Not enough memory to accommodate instance failovers")
1758

    
1759
cvEnodenet :: (String, String, String)
1760
cvEnodenet =
1761
  ("node",
1762
   Types.cVErrorCodeToRaw CvENODENET,
1763
   "Network-related node error")
1764

    
1765
cvEnodeoobpath :: (String, String, String)
1766
cvEnodeoobpath =
1767
  ("node",
1768
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
1769
   "Invalid Out Of Band path")
1770

    
1771
cvEnodeorphaninstance :: (String, String, String)
1772
cvEnodeorphaninstance =
1773
  ("node",
1774
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
1775
   "Unknown intance running on a node")
1776

    
1777
cvEnodeorphanlv :: (String, String, String)
1778
cvEnodeorphanlv =
1779
  ("node",
1780
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
1781
   "Unknown LVM logical volume")
1782

    
1783
cvEnodeos :: (String, String, String)
1784
cvEnodeos =
1785
  ("node",
1786
   Types.cVErrorCodeToRaw CvENODEOS,
1787
   "OS-related node error")
1788

    
1789
cvEnoderpc :: (String, String, String)
1790
cvEnoderpc =
1791
  ("node",
1792
   Types.cVErrorCodeToRaw CvENODERPC,
1793
   "Error during connection to the primary node of an instance")
1794

    
1795
cvEnodesetup :: (String, String, String)
1796
cvEnodesetup =
1797
  ("node",
1798
   Types.cVErrorCodeToRaw CvENODESETUP,
1799
   "Node setup error")
1800

    
1801
cvEnodesharedfilestoragepathunusable :: (String, String, String)
1802
cvEnodesharedfilestoragepathunusable =
1803
  ("node",
1804
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
1805
   "Shared file storage path unusable")
1806

    
1807
cvEnodessh :: (String, String, String)
1808
cvEnodessh =
1809
  ("node",
1810
   Types.cVErrorCodeToRaw CvENODESSH,
1811
   "SSH-related node error")
1812

    
1813
cvEnodetime :: (String, String, String)
1814
cvEnodetime =
1815
  ("node",
1816
   Types.cVErrorCodeToRaw CvENODETIME,
1817
   "Node returned invalid time")
1818

    
1819
cvEnodeuserscripts :: (String, String, String)
1820
cvEnodeuserscripts =
1821
  ("node",
1822
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
1823
   "User scripts not present or not executable")
1824

    
1825
cvEnodeversion :: (String, String, String)
1826
cvEnodeversion =
1827
  ("node",
1828
   Types.cVErrorCodeToRaw CvENODEVERSION,
1829
   "Protocol version mismatch or Ganeti version mismatch")
1830

    
1831
cvAllEcodes :: FrozenSet (String, String, String)
1832
cvAllEcodes =
1833
  ConstantUtils.mkSet
1834
  [cvEclustercert,
1835
   cvEclustercfg,
1836
   cvEclusterdanglinginst,
1837
   cvEclusterdanglingnodes,
1838
   cvEclusterfilecheck,
1839
   cvEgroupdifferentpvsize,
1840
   cvEinstancebadnode,
1841
   cvEinstancedown,
1842
   cvEinstancefaultydisk,
1843
   cvEinstancelayout,
1844
   cvEinstancemissingcfgparameter,
1845
   cvEinstancemissingdisk,
1846
   cvEinstancepolicy,
1847
   cvEinstancesplitgroups,
1848
   cvEinstanceunsuitablenode,
1849
   cvEinstancewrongnode,
1850
   cvEnodedrbd,
1851
   cvEnodedrbdhelper,
1852
   cvEnodedrbdversion,
1853
   cvEnodefilecheck,
1854
   cvEnodefilestoragepaths,
1855
   cvEnodefilestoragepathunusable,
1856
   cvEnodehooks,
1857
   cvEnodehv,
1858
   cvEnodelvm,
1859
   cvEnoden1,
1860
   cvEnodenet,
1861
   cvEnodeoobpath,
1862
   cvEnodeorphaninstance,
1863
   cvEnodeorphanlv,
1864
   cvEnodeos,
1865
   cvEnoderpc,
1866
   cvEnodesetup,
1867
   cvEnodesharedfilestoragepathunusable,
1868
   cvEnodessh,
1869
   cvEnodetime,
1870
   cvEnodeuserscripts,
1871
   cvEnodeversion]
1872

    
1873
cvAllEcodesStrings :: FrozenSet String
1874
cvAllEcodesStrings =
1875
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
1876

    
1877
-- * Instance status
1878

    
1879
inststAdmindown :: String
1880
inststAdmindown = Types.instanceStatusToRaw StatusDown
1881

    
1882
inststAdminoffline :: String
1883
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
1884

    
1885
inststErrordown :: String
1886
inststErrordown = Types.instanceStatusToRaw ErrorDown
1887

    
1888
inststErrorup :: String
1889
inststErrorup = Types.instanceStatusToRaw ErrorUp
1890

    
1891
inststNodedown :: String
1892
inststNodedown = Types.instanceStatusToRaw NodeDown
1893

    
1894
inststNodeoffline :: String
1895
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
1896

    
1897
inststRunning :: String
1898
inststRunning = Types.instanceStatusToRaw Running
1899

    
1900
inststWrongnode :: String
1901
inststWrongnode = Types.instanceStatusToRaw WrongNode
1902

    
1903
inststAll :: FrozenSet String
1904
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
1905

    
1906
-- * Admin states
1907

    
1908
adminstDown :: String
1909
adminstDown = Types.adminStateToRaw AdminDown
1910

    
1911
adminstOffline :: String
1912
adminstOffline = Types.adminStateToRaw AdminOffline
1913

    
1914
adminstUp :: String
1915
adminstUp = Types.adminStateToRaw AdminUp
1916

    
1917
adminstAll :: FrozenSet String
1918
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
1919

    
1920
-- * Node roles
1921

    
1922
nrDrained :: String
1923
nrDrained = Types.nodeRoleToRaw NRDrained
1924

    
1925
nrMaster :: String
1926
nrMaster = Types.nodeRoleToRaw NRMaster
1927

    
1928
nrMcandidate :: String
1929
nrMcandidate = Types.nodeRoleToRaw NRCandidate
1930

    
1931
nrOffline :: String
1932
nrOffline = Types.nodeRoleToRaw NROffline
1933

    
1934
nrRegular :: String
1935
nrRegular = Types.nodeRoleToRaw NRRegular
1936

    
1937
nrAll :: FrozenSet String
1938
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
1939

    
1940
-- * Allocator framework constants
1941

    
1942
iallocatorVersion :: Int
1943
iallocatorVersion = 2
1944

    
1945
iallocatorDirIn :: String
1946
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
1947

    
1948
iallocatorDirOut :: String
1949
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
1950

    
1951
validIallocatorDirections :: FrozenSet String
1952
validIallocatorDirections =
1953
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
1954

    
1955
iallocatorModeAlloc :: String
1956
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
1957

    
1958
iallocatorModeChgGroup :: String
1959
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
1960

    
1961
iallocatorModeMultiAlloc :: String
1962
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
1963

    
1964
iallocatorModeNodeEvac :: String
1965
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
1966

    
1967
iallocatorModeReloc :: String
1968
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
1969

    
1970
validIallocatorModes :: FrozenSet String
1971
validIallocatorModes =
1972
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
1973

    
1974
iallocatorSearchPath :: [String]
1975
iallocatorSearchPath = AutoConf.iallocatorSearchPath
1976

    
1977
defaultIallocatorShortcut :: String
1978
defaultIallocatorShortcut = "."
1979

    
1980
-- * Node evacuation
1981

    
1982
nodeEvacPri :: String
1983
nodeEvacPri = Types.evacModeToRaw ChangePrimary
1984

    
1985
nodeEvacSec :: String
1986
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
1987

    
1988
nodeEvacAll :: String
1989
nodeEvacAll = Types.evacModeToRaw ChangeAll
1990

    
1991
nodeEvacModes :: FrozenSet String
1992
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
1993

    
1994
-- * Job status
1995

    
1996
jobStatusQueued :: String
1997
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
1998

    
1999
jobStatusWaiting :: String
2000
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
2001

    
2002
jobStatusCanceling :: String
2003
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
2004

    
2005
jobStatusRunning :: String
2006
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
2007

    
2008
jobStatusCanceled :: String
2009
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
2010

    
2011
jobStatusSuccess :: String
2012
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
2013

    
2014
jobStatusError :: String
2015
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
2016

    
2017
jobsPending :: FrozenSet String
2018
jobsPending =
2019
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
2020

    
2021
jobsFinalized :: FrozenSet String
2022
jobsFinalized =
2023
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
2024

    
2025
jobStatusAll :: FrozenSet String
2026
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
2027

    
2028
-- * OpCode status
2029

    
2030
-- ** Not yet finalized opcodes
2031

    
2032
opStatusCanceling :: String
2033
opStatusCanceling = "canceling"
2034

    
2035
opStatusQueued :: String
2036
opStatusQueued = "queued"
2037

    
2038
opStatusRunning :: String
2039
opStatusRunning = "running"
2040

    
2041
opStatusWaiting :: String
2042
opStatusWaiting = "waiting"
2043

    
2044
-- ** Finalized opcodes
2045

    
2046
opStatusCanceled :: String
2047
opStatusCanceled = "canceled"
2048

    
2049
opStatusError :: String
2050
opStatusError = "error"
2051

    
2052
opStatusSuccess :: String
2053
opStatusSuccess = "success"
2054

    
2055
opsFinalized :: FrozenSet String
2056
opsFinalized =
2057
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
2058

    
2059
-- * OpCode priority
2060

    
2061
opPrioLowest :: Int
2062
opPrioLowest = 19
2063

    
2064
opPrioHighest :: Int
2065
opPrioHighest = -20
2066

    
2067
opPrioLow :: Int
2068
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
2069

    
2070
opPrioNormal :: Int
2071
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
2072

    
2073
opPrioHigh :: Int
2074
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
2075

    
2076
opPrioSubmitValid :: FrozenSet Int
2077
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
2078

    
2079
opPrioDefault :: Int
2080
opPrioDefault = opPrioNormal
2081

    
2082
-- * Execution log types
2083

    
2084
elogMessage :: String
2085
elogMessage = Types.eLogTypeToRaw ELogMessage
2086

    
2087
elogRemoteImport :: String
2088
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
2089

    
2090
elogJqueueTest :: String
2091
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
2092

    
2093
-- * Confd
2094

    
2095
confdProtocolVersion :: Int
2096
confdProtocolVersion = ConstantUtils.confdProtocolVersion
2097

    
2098
-- Confd request type
2099

    
2100
confdReqPing :: Int
2101
confdReqPing = Types.confdRequestTypeToRaw ReqPing
2102

    
2103
confdReqNodeRoleByname :: Int
2104
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
2105

    
2106
confdReqNodePipByInstanceIp :: Int
2107
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
2108

    
2109
confdReqClusterMaster :: Int
2110
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
2111

    
2112
confdReqNodePipList :: Int
2113
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
2114

    
2115
confdReqMcPipList :: Int
2116
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
2117

    
2118
confdReqInstancesIpsList :: Int
2119
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
2120

    
2121
confdReqNodeDrbd :: Int
2122
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
2123

    
2124
confdReqNodeInstances :: Int
2125
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
2126

    
2127
confdReqs :: FrozenSet Int
2128
confdReqs =
2129
  ConstantUtils.mkSet .
2130
  map Types.confdRequestTypeToRaw $
2131
  [minBound..] \\ [ReqNodeInstances]
2132

    
2133
-- * Confd request type
2134

    
2135
confdReqfieldName :: Int
2136
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
2137

    
2138
confdReqfieldIp :: Int
2139
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
2140

    
2141
confdReqfieldMnodePip :: Int
2142
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
2143

    
2144
-- * Confd repl status
2145

    
2146
confdReplStatusOk :: Int
2147
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
2148

    
2149
confdReplStatusError :: Int
2150
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
2151

    
2152
confdReplStatusNotimplemented :: Int
2153
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
2154

    
2155
confdReplStatuses :: FrozenSet Int
2156
confdReplStatuses =
2157
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
2158

    
2159
-- * Confd node role
2160

    
2161
confdNodeRoleMaster :: Int
2162
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
2163

    
2164
confdNodeRoleCandidate :: Int
2165
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
2166

    
2167
confdNodeRoleOffline :: Int
2168
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
2169

    
2170
confdNodeRoleDrained :: Int
2171
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
2172

    
2173
confdNodeRoleRegular :: Int
2174
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
2175

    
2176
-- * A few common errors for confd
2177

    
2178
confdErrorUnknownEntry :: Int
2179
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
2180

    
2181
confdErrorInternal :: Int
2182
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
2183

    
2184
confdErrorArgument :: Int
2185
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
2186

    
2187
-- * Confd request query fields
2188

    
2189
confdReqqLink :: String
2190
confdReqqLink = ConstantUtils.confdReqqLink
2191

    
2192
confdReqqIp :: String
2193
confdReqqIp = ConstantUtils.confdReqqIp
2194

    
2195
confdReqqIplist :: String
2196
confdReqqIplist = ConstantUtils.confdReqqIplist
2197

    
2198
confdReqqFields :: String
2199
confdReqqFields = ConstantUtils.confdReqqFields
2200

    
2201
-- | Each request is "salted" by the current timestamp.
2202
--
2203
-- This constant decides how many seconds of skew to accept.
2204
--
2205
-- TODO: make this a default and allow the value to be more
2206
-- configurable
2207
confdMaxClockSkew :: Int
2208
confdMaxClockSkew = 2 * nodeMaxClockSkew
2209

    
2210
-- | When we haven't reloaded the config for more than this amount of
2211
-- seconds, we force a test to see if inotify is betraying us. Using a
2212
-- prime number to ensure we get less chance of 'same wakeup' with
2213
-- other processes.
2214
confdConfigReloadTimeout :: Int
2215
confdConfigReloadTimeout = 17
2216

    
2217
-- | If we receive more than one update in this amount of
2218
-- microseconds, we move to polling every RATELIMIT seconds, rather
2219
-- than relying on inotify, to be able to serve more requests.
2220
confdConfigReloadRatelimit :: Int
2221
confdConfigReloadRatelimit = 250000
2222

    
2223
-- | Magic number prepended to all confd queries.
2224
--
2225
-- This allows us to distinguish different types of confd protocols
2226
-- and handle them. For example by changing this we can move the whole
2227
-- payload to be compressed, or move away from json.
2228
confdMagicFourcc :: String
2229
confdMagicFourcc = "plj0"
2230

    
2231
-- | By default a confd request is sent to the minimum between this
2232
-- number and all MCs. 6 was chosen because even in the case of a
2233
-- disastrous 50% response rate, we should have enough answers to be
2234
-- able to compare more than one.
2235
confdDefaultReqCoverage :: Int
2236
confdDefaultReqCoverage = 6
2237

    
2238
-- | Timeout in seconds to expire pending query request in the confd
2239
-- client library. We don't actually expect any answer more than 10
2240
-- seconds after we sent a request.
2241
confdClientExpireTimeout :: Int
2242
confdClientExpireTimeout = 10
2243

    
2244
-- * Possible values for NodeGroup.alloc_policy
2245

    
2246
allocPolicyLastResort :: String
2247
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
2248

    
2249
allocPolicyPreferred :: String
2250
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
2251

    
2252
allocPolicyUnallocable :: String
2253
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
2254

    
2255
validAllocPolicies :: [String]
2256
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
2257

    
2258
-- | Temporary external/shared storage parameters
2259
blockdevDriverManual :: String
2260
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
2261

    
2262
-- | 'qemu-img' path, required for 'ovfconverter'
2263
qemuimgPath :: String
2264
qemuimgPath = AutoConf.qemuimgPath
2265

    
2266
-- | Whether htools was enabled at compilation time
2267
--
2268
-- FIXME: this should be moved next to the other enable constants,
2269
-- such as, 'enableConfd', and renamed to 'enableHtools'.
2270
htools :: Bool
2271
htools = AutoConf.htools
2272

    
2273
-- * Key files for SSH daemon
2274

    
2275
sshHostDsaPriv :: String
2276
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
2277

    
2278
sshHostDsaPub :: String
2279
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
2280

    
2281
sshHostRsaPriv :: String
2282
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
2283

    
2284
sshHostRsaPub :: String
2285
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
2286

    
2287
-- | Path generating random UUID
2288
randomUuidFile :: String
2289
randomUuidFile = ConstantUtils.randomUuidFile
2290

    
2291
-- * Auto-repair tag prefixes
2292

    
2293
autoRepairTagPrefix :: String
2294
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
2295

    
2296
autoRepairTagEnabled :: String
2297
autoRepairTagEnabled = autoRepairTagPrefix
2298

    
2299
autoRepairTagPending :: String
2300
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
2301

    
2302
autoRepairTagResult :: String
2303
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
2304

    
2305
autoRepairTagSuspended :: String
2306
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
2307

    
2308
-- * Auto-repair levels
2309

    
2310
autoRepairFailover :: String
2311
autoRepairFailover = "failover"
2312

    
2313
autoRepairFixStorage :: String
2314
autoRepairFixStorage = "fix-storage"
2315

    
2316
autoRepairMigrate :: String
2317
autoRepairMigrate = "migrate"
2318

    
2319
autoRepairReinstall :: String
2320
autoRepairReinstall = "reinstall"
2321

    
2322
autoRepairAllTypes :: FrozenSet String
2323
autoRepairAllTypes =
2324
  ConstantUtils.mkSet [autoRepairFailover,
2325
                       autoRepairFixStorage,
2326
                       autoRepairMigrate,
2327
                       autoRepairReinstall]
2328

    
2329
-- * Auto-repair results
2330

    
2331
autoRepairEnoperm :: String
2332
autoRepairEnoperm = "enoperm"
2333

    
2334
autoRepairFailure :: String
2335
autoRepairFailure = "failure"
2336

    
2337
autoRepairSuccess :: String
2338
autoRepairSuccess = "success"
2339

    
2340
autoRepairAllResults :: FrozenSet String
2341
autoRepairAllResults =
2342
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
2343

    
2344
-- | The version identifier for builtin data collectors
2345
builtinDataCollectorVersion :: String
2346
builtinDataCollectorVersion = "B"
2347

    
2348
-- | The reason trail opcode parameter name
2349
opcodeReason :: String
2350
opcodeReason = "reason"
2351

    
2352
diskstatsFile :: String
2353
diskstatsFile = "/proc/diskstats"
2354

    
2355
-- *  CPU load collector
2356

    
2357
statFile :: String
2358
statFile = "/proc/stat"
2359

    
2360
cpuavgloadBufferSize :: Int
2361
cpuavgloadBufferSize = 150
2362

    
2363
cpuavgloadWindowSize :: Int
2364
cpuavgloadWindowSize = 600
2365

    
2366
-- | Mond's variable for periodical data collection
2367
mondTimeInterval :: Int
2368
mondTimeInterval = 5
2369

    
2370
-- * Disk access modes
2371

    
2372
diskUserspace :: String
2373
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
2374

    
2375
diskKernelspace :: String
2376
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
2377

    
2378
diskValidAccessModes :: FrozenSet String
2379
diskValidAccessModes =
2380
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
2381

    
2382
-- | Timeout for queue draining in upgrades
2383
upgradeQueueDrainTimeout :: Int
2384
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
2385

    
2386
-- | Intervall at which the queue is polled during upgrades
2387
upgradeQueuePollInterval :: Int
2388
upgradeQueuePollInterval  = 10