Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ f198cf91

History | View | Annotate | Download (94.2 kB)

1
{-# OPTIONS -fno-warn-type-defaults #-}
2
{-| HsConstants contains the Haskell constants
3

    
4
This is a transitional module complementary to 'Ganeti.Constants'.  It
5
is intended to contain the Haskell constants that are meant to be
6
generated in Python.
7

    
8
Do not write any definitions in this file other than constants.  Do
9
not even write helper functions.  The definitions in this module are
10
automatically stripped to build the Makefile.am target
11
'ListConstants.hs'.  If there are helper functions in this module,
12
they will also be dragged and it will cause compilation to fail.
13
Therefore, all helper functions should go to a separate module and
14
imported.
15

    
16
-}
17

    
18
{-
19

    
20
Copyright (C) 2013 Google Inc.
21

    
22
This program is free software; you can redistribute it and/or modify
23
it under the terms of the GNU General Public License as published by
24
the Free Software Foundation; either version 2 of the License, or
25
(at your option) any later version.
26

    
27
This program is distributed in the hope that it will be useful, but
28
WITHOUT ANY WARRANTY; without even the implied warranty of
29
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
30
General Public License for more details.
31

    
32
You should have received a copy of the GNU General Public License
33
along with this program; if not, write to the Free Software
34
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
35
02110-1301, USA.
36

    
37
-}
38
module Ganeti.HsConstants where
39

    
40
import Control.Arrow ((***))
41
import Data.List ((\\))
42
import Data.Map (Map)
43
import qualified Data.Map as Map (fromList, keys, insert)
44

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

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

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

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

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

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

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

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

    
81
hasGnuLn :: Bool
82
hasGnuLn = AutoConf.hasGnuLn
83

    
84
-- * 'autoconf' constants for Python only ('lib/pathutils.py')
85

    
86
-- ** Build-time constants
87

    
88
exportDir :: String
89
exportDir = AutoConf.exportDir
90

    
91
osSearchPath :: [String]
92
osSearchPath = AutoConf.osSearchPath
93

    
94
esSearchPath :: [String]
95
esSearchPath = AutoConf.esSearchPath
96

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

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

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

    
106
toolsdir :: String
107
toolsdir = AutoConf.toolsdir
108

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

    
112
-- ** Paths which don't change for a virtual cluster
113

    
114
pkglibdir :: String
115
pkglibdir = AutoConf.pkglibdir
116

    
117
sharedir :: String
118
sharedir = AutoConf.sharedir
119

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

    
122
manPages :: Map String Int
123
manPages = Map.fromList AutoConf.manPages
124

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

    
127
versionedsharedir :: String
128
versionedsharedir = AutoConf.versionedsharedir
129

    
130
-- * 'autoconf' constants for Python only ('tests/py/docs_unittest.py')
131

    
132
gntScripts :: [String]
133
gntScripts = AutoConf.gntScripts
134

    
135
-- * Various versions
136

    
137
releaseVersion :: String
138
releaseVersion = AutoConf.packageVersion
139

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

    
143
versionMinor :: Int
144
versionMinor = AutoConf.versionMinor
145

    
146
versionRevision :: Int
147
versionRevision = AutoConf.versionRevision
148

    
149
dirVersion :: String
150
dirVersion = AutoConf.dirVersion
151

    
152
osApiV10 :: Int
153
osApiV10 = 10
154

    
155
osApiV15 :: Int
156
osApiV15 = 15
157

    
158
osApiV20 :: Int
159
osApiV20 = 20
160

    
161
osApiVersions :: FrozenSet Int
162
osApiVersions = ConstantUtils.mkSet [osApiV10, osApiV15, osApiV20]
163

    
164
exportVersion :: Int
165
exportVersion = 0
166

    
167
rapiVersion :: Int
168
rapiVersion = 2
169

    
170
configMajor :: Int
171
configMajor = AutoConf.versionMajor
172

    
173
configMinor :: Int
174
configMinor = AutoConf.versionMinor
175

    
176
-- | The configuration is supposed to remain stable across
177
-- revisions. Therefore, the revision number is cleared to '0'.
178
configRevision :: Int
179
configRevision = 0
180

    
181
configVersion :: Int
182
configVersion = buildVersion configMajor configMinor configRevision
183

    
184
-- | Similarly to the configuration (see 'configRevision'), the
185
-- protocols are supposed to remain stable across revisions.
186
protocolVersion :: Int
187
protocolVersion = buildVersion configMajor configMinor configRevision
188

    
189
-- * User separation
190

    
191
daemonsGroup :: String
192
daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
193

    
194
adminGroup :: String
195
adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
196

    
197
masterdUser :: String
198
masterdUser = Runtime.daemonUser GanetiMasterd
199

    
200
masterdGroup :: String
201
masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
202

    
203
rapiUser :: String
204
rapiUser = Runtime.daemonUser GanetiRapi
205

    
206
rapiGroup :: String
207
rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
208

    
209
confdUser :: String
210
confdUser = Runtime.daemonUser GanetiConfd
211

    
212
confdGroup :: String
213
confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
214

    
215
luxidUser :: String
216
luxidUser = Runtime.daemonUser GanetiLuxid
217

    
218
luxidGroup :: String
219
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
220

    
221
nodedUser :: String
222
nodedUser = Runtime.daemonUser GanetiNoded
223

    
224
nodedGroup :: String
225
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
226

    
227
mondUser :: String
228
mondUser = Runtime.daemonUser GanetiMond
229

    
230
mondGroup :: String
231
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
232

    
233
sshLoginUser :: String
234
sshLoginUser = AutoConf.sshLoginUser
235

    
236
sshConsoleUser :: String
237
sshConsoleUser = AutoConf.sshConsoleUser
238

    
239
-- * Cpu pinning separators and constants
240

    
241
cpuPinningSep :: String
242
cpuPinningSep = ":"
243

    
244
cpuPinningAll :: String
245
cpuPinningAll = "all"
246

    
247
-- | Internal representation of "all"
248
cpuPinningAllVal :: Int
249
cpuPinningAllVal = -1
250

    
251
-- | One "all" entry in a CPU list means CPU pinning is off
252
cpuPinningOff :: [Int]
253
cpuPinningOff = [cpuPinningAllVal]
254

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

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

    
279
-- * Wipe
280

    
281
ddCmd :: String
282
ddCmd = "dd"
283

    
284
-- | 1GB
285
maxWipeChunk :: Int
286
maxWipeChunk = 1024
287

    
288
minWipeChunkPercent :: Int
289
minWipeChunkPercent = 10
290

    
291
-- * Directories
292

    
293
runDirsMode :: Int
294
runDirsMode = 0o775
295

    
296
secureDirMode :: Int
297
secureDirMode = 0o700
298

    
299
secureFileMode :: Int
300
secureFileMode = 0o600
301

    
302
adoptableBlockdevRoot :: String
303
adoptableBlockdevRoot = "/dev/disk/"
304

    
305
-- * 'autoconf' enable/disable
306

    
307
enableConfd :: Bool
308
enableConfd = AutoConf.enableConfd
309

    
310
enableMond :: Bool
311
enableMond = AutoConf.enableMond
312

    
313
enableRestrictedCommands :: Bool
314
enableRestrictedCommands = AutoConf.enableRestrictedCommands
315

    
316
enableSplitQuery :: Bool
317
enableSplitQuery = AutoConf.enableSplitQuery
318

    
319
-- * SSH constants
320

    
321
ssh :: String
322
ssh = "ssh"
323

    
324
scp :: String
325
scp = "scp"
326

    
327
-- * Daemons
328

    
329
confd :: String
330
confd = Runtime.daemonName GanetiConfd
331

    
332
masterd :: String
333
masterd = Runtime.daemonName GanetiMasterd
334

    
335
mond :: String
336
mond = Runtime.daemonName GanetiMond
337

    
338
noded :: String
339
noded = Runtime.daemonName GanetiNoded
340

    
341
luxid :: String
342
luxid = Runtime.daemonName GanetiLuxid
343

    
344
rapi :: String
345
rapi = Runtime.daemonName GanetiRapi
346

    
347
daemons :: FrozenSet String
348
daemons =
349
  ConstantUtils.mkSet [confd,
350
                       luxid,
351
                       masterd,
352
                       mond,
353
                       noded,
354
                       rapi]
355

    
356
defaultConfdPort :: Int
357
defaultConfdPort = 1814
358

    
359
defaultMondPort :: Int
360
defaultMondPort = 1815
361

    
362
defaultNodedPort :: Int
363
defaultNodedPort = 1811
364

    
365
defaultRapiPort :: Int
366
defaultRapiPort = 5080
367

    
368
daemonsPorts :: Map String (Protocol, Int)
369
daemonsPorts =
370
  Map.fromList [(confd, (Udp, defaultConfdPort)),
371
                (mond, (Tcp, defaultMondPort)),
372
                (noded, (Tcp, defaultNodedPort)),
373
                (rapi, (Tcp, defaultRapiPort)),
374
                (ssh, (Tcp, 22))]
375

    
376
firstDrbdPort :: Int
377
firstDrbdPort = 11000
378

    
379
lastDrbdPort :: Int
380
lastDrbdPort = 14999
381

    
382
daemonsLogbase :: Map String String
383
daemonsLogbase =
384
  Map.fromList
385
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
386

    
387
extraLogreasonAccess :: String
388
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
389

    
390
extraLogreasonError :: String
391
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
392

    
393
devConsole :: String
394
devConsole = ConstantUtils.devConsole
395

    
396
procMounts :: String
397
procMounts = "/proc/mounts"
398

    
399
-- * Luxi (Local UniX Interface) related constants
400

    
401
luxiEom :: PythonChar
402
luxiEom = PythonChar '\x03'
403

    
404
-- | Environment variable for the luxi override socket
405
luxiOverride :: String
406
luxiOverride = "FORCE_LUXI_SOCKET"
407

    
408
luxiOverrideMaster :: String
409
luxiOverrideMaster = "master"
410

    
411
luxiOverrideQuery :: String
412
luxiOverrideQuery = "query"
413

    
414
luxiVersion :: Int
415
luxiVersion = configVersion
416

    
417
-- * Syslog
418

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

    
422
syslogNo :: String
423
syslogNo = Logging.syslogUsageToRaw SyslogNo
424

    
425
syslogYes :: String
426
syslogYes = Logging.syslogUsageToRaw SyslogYes
427

    
428
syslogOnly :: String
429
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
430

    
431
syslogSocket :: String
432
syslogSocket = "/dev/log"
433

    
434
exportConfFile :: String
435
exportConfFile = "config.ini"
436

    
437
-- * Xen
438

    
439
xenBootloader :: String
440
xenBootloader = AutoConf.xenBootloader
441

    
442
xenCmdXl :: String
443
xenCmdXl = "xl"
444

    
445
xenCmdXm :: String
446
xenCmdXm = "xm"
447

    
448
xenInitrd :: String
449
xenInitrd = AutoConf.xenInitrd
450

    
451
xenKernel :: String
452
xenKernel = AutoConf.xenKernel
453

    
454
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
455
-- other constants
456
knownXenCommands :: FrozenSet String
457
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
458

    
459
-- * KVM and socat
460

    
461
kvmPath :: String
462
kvmPath = AutoConf.kvmPath
463

    
464
kvmKernel :: String
465
kvmKernel = AutoConf.kvmKernel
466

    
467
socatEscapeCode :: String
468
socatEscapeCode = "0x1d"
469

    
470
socatPath :: String
471
socatPath = AutoConf.socatPath
472

    
473
socatUseCompress :: Bool
474
socatUseCompress = AutoConf.socatUseCompress
475

    
476
socatUseEscape :: Bool
477
socatUseEscape = AutoConf.socatUseEscape
478

    
479
-- * Console types
480

    
481
-- | Display a message for console access
482
consMessage :: String
483
consMessage = "msg"
484

    
485
-- | Console as SPICE server
486
consSpice :: String
487
consSpice = "spice"
488

    
489
-- | Console as SSH command
490
consSsh :: String
491
consSsh = "ssh"
492

    
493
-- | Console as VNC server
494
consVnc :: String
495
consVnc = "vnc"
496

    
497
consAll :: FrozenSet String
498
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
499

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

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

    
519
-- * X509
520

    
521
-- | commonName (CN) used in certificates
522
x509CertCn :: String
523
x509CertCn = "ganeti.example.com"
524

    
525
-- | Default validity of certificates in days
526
x509CertDefaultValidity :: Int
527
x509CertDefaultValidity = 365 * 5
528

    
529
x509CertSignatureHeader :: String
530
x509CertSignatureHeader = "X-Ganeti-Signature"
531

    
532
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
533
x509CertSignDigest :: String
534
x509CertSignDigest = "SHA1"
535

    
536
-- * Import/export daemon mode
537

    
538
iemExport :: String
539
iemExport = "export"
540

    
541
iemImport :: String
542
iemImport = "import"
543

    
544
-- * Import/export transport compression
545

    
546
iecGzip :: String
547
iecGzip = Types.importExportCompressionToRaw GZip
548

    
549
iecNone :: String
550
iecNone = Types.importExportCompressionToRaw None
551

    
552
iecAll :: FrozenSet String
553
iecAll =
554
  ConstantUtils.mkSet $ map Types.importExportCompressionToRaw [minBound..]
555

    
556
ieCustomSize :: String
557
ieCustomSize = "fd"
558

    
559
-- * Import/export I/O
560

    
561
-- | Direct file I/O, equivalent to a shell's I/O redirection using
562
-- '<' or '>'
563
ieioFile :: String
564
ieioFile = "file"
565

    
566
-- | Raw block device I/O using "dd"
567
ieioRawDisk :: String
568
ieioRawDisk = "raw"
569

    
570
-- | OS definition import/export script
571
ieioScript :: String
572
ieioScript = "script"
573

    
574
-- * Hooks
575

    
576
hooksNameCfgupdate :: String
577
hooksNameCfgupdate = "config-update"
578

    
579
hooksNameWatcher :: String
580
hooksNameWatcher = "watcher"
581

    
582
hooksPath :: String
583
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
584

    
585
hooksPhasePost :: String
586
hooksPhasePost = "post"
587

    
588
hooksPhasePre :: String
589
hooksPhasePre = "pre"
590

    
591
hooksVersion :: Int
592
hooksVersion = 2
593

    
594
-- * Hooks subject type (what object type does the LU deal with)
595

    
596
htypeCluster :: String
597
htypeCluster = "CLUSTER"
598

    
599
htypeGroup :: String
600
htypeGroup = "GROUP"
601

    
602
htypeInstance :: String
603
htypeInstance = "INSTANCE"
604

    
605
htypeNetwork :: String
606
htypeNetwork = "NETWORK"
607

    
608
htypeNode :: String
609
htypeNode = "NODE"
610

    
611
-- * Hkr
612

    
613
hkrSkip :: Int
614
hkrSkip = 0
615

    
616
hkrFail :: Int
617
hkrFail = 1
618

    
619
hkrSuccess :: Int
620
hkrSuccess = 2
621

    
622
-- * Storage types
623

    
624
stBlock :: String
625
stBlock = Types.storageTypeToRaw StorageBlock
626

    
627
stDiskless :: String
628
stDiskless = Types.storageTypeToRaw StorageDiskless
629

    
630
stExt :: String
631
stExt = Types.storageTypeToRaw StorageExt
632

    
633
stFile :: String
634
stFile = Types.storageTypeToRaw StorageFile
635

    
636
stLvmPv :: String
637
stLvmPv = Types.storageTypeToRaw StorageLvmPv
638

    
639
stLvmVg :: String
640
stLvmVg = Types.storageTypeToRaw StorageLvmVg
641

    
642
stRados :: String
643
stRados = Types.storageTypeToRaw StorageRados
644

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

    
648
-- | The set of storage types for which storage reporting is available
649
--
650
-- FIXME: Remove this, once storage reporting is available for all
651
-- types.
652
stsReport :: FrozenSet String
653
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
654

    
655
-- * Storage fields
656
-- ** First two are valid in LU context only, not passed to backend
657

    
658
sfNode :: String
659
sfNode = "node"
660

    
661
sfType :: String
662
sfType = "type"
663

    
664
-- ** and the rest are valid in backend
665

    
666
sfAllocatable :: String
667
sfAllocatable = Types.storageFieldToRaw SFAllocatable
668

    
669
sfFree :: String
670
sfFree = Types.storageFieldToRaw SFFree
671

    
672
sfName :: String
673
sfName = Types.storageFieldToRaw SFName
674

    
675
sfSize :: String
676
sfSize = Types.storageFieldToRaw SFSize
677

    
678
sfUsed :: String
679
sfUsed = Types.storageFieldToRaw SFUsed
680

    
681
validStorageFields :: FrozenSet String
682
validStorageFields =
683
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
684
                        [sfNode, sfType]
685

    
686
modifiableStorageFields :: Map String (FrozenSet String)
687
modifiableStorageFields =
688
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
689
                 ConstantUtils.mkSet [sfAllocatable])]
690

    
691
-- * Storage operations
692

    
693
soFixConsistency :: String
694
soFixConsistency = "fix-consistency"
695

    
696
validStorageOperations :: Map String (FrozenSet String)
697
validStorageOperations =
698
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
699
                 ConstantUtils.mkSet [soFixConsistency])]
700

    
701
-- * Volume fields
702

    
703
vfDev :: String
704
vfDev = "dev"
705

    
706
vfInstance :: String
707
vfInstance = "instance"
708

    
709
vfName :: String
710
vfName = "name"
711

    
712
vfNode :: String
713
vfNode = "node"
714

    
715
vfPhys :: String
716
vfPhys = "phys"
717

    
718
vfSize :: String
719
vfSize = "size"
720

    
721
vfVg :: String
722
vfVg = "vg"
723

    
724
-- * Local disk status
725

    
726
ldsFaulty :: Int
727
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
728

    
729
ldsOkay :: Int
730
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
731

    
732
ldsUnknown :: Int
733
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
734

    
735
ldsNames :: Map Int String
736
ldsNames =
737
  Map.fromList [ (Types.localDiskStatusToRaw ds,
738
                  localDiskStatusName ds) | ds <- [minBound..] ]
739

    
740
-- * Disk template types
741

    
742
dtDiskless :: String
743
dtDiskless = Types.diskTemplateToRaw DTDiskless
744

    
745
dtFile :: String
746
dtFile = Types.diskTemplateToRaw DTFile
747

    
748
dtSharedFile :: String
749
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
750

    
751
dtPlain :: String
752
dtPlain = Types.diskTemplateToRaw DTPlain
753

    
754
dtBlock :: String
755
dtBlock = Types.diskTemplateToRaw DTBlock
756

    
757
dtDrbd8 :: String
758
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
759

    
760
dtRbd :: String
761
dtRbd = Types.diskTemplateToRaw DTRbd
762

    
763
dtExt :: String
764
dtExt = Types.diskTemplateToRaw DTExt
765

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

    
776
diskTemplates :: FrozenSet String
777
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
778

    
779
-- | Disk templates that are enabled by default
780
defaultEnabledDiskTemplates :: [String]
781
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
782

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

    
797
-- | The set of network-mirrored disk templates
798
dtsIntMirror :: FrozenSet String
799
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
800

    
801
-- | 'DTDiskless' is 'trivially' externally mirrored
802
dtsExtMirror :: FrozenSet String
803
dtsExtMirror =
804
  ConstantUtils.mkSet $
805
  map Types.diskTemplateToRaw [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd]
806

    
807
-- | The set of non-lvm-based disk templates
808
dtsNotLvm :: FrozenSet String
809
dtsNotLvm =
810
  ConstantUtils.mkSet $
811
  map Types.diskTemplateToRaw
812
  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd]
813

    
814
-- | The set of disk templates which can be grown
815
dtsGrowable :: FrozenSet String
816
dtsGrowable =
817
  ConstantUtils.mkSet $
818
  map Types.diskTemplateToRaw
819
  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd]
820

    
821
-- | The set of disk templates that allow adoption
822
dtsMayAdopt :: FrozenSet String
823
dtsMayAdopt =
824
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
825

    
826
-- | The set of disk templates that *must* use adoption
827
dtsMustAdopt :: FrozenSet String
828
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
829

    
830
-- | The set of disk templates that allow migrations
831
dtsMirrored :: FrozenSet String
832
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
833

    
834
-- | The set of file based disk templates
835
dtsFilebased :: FrozenSet String
836
dtsFilebased =
837
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTSharedFile, DTFile]
838

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

    
847
-- | The set of disk templates that are supported by exclusive_storage
848
dtsExclStorage :: FrozenSet String
849
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
850

    
851
-- | Templates for which we don't perform checks on free space
852
dtsNoFreeSpaceCheck :: FrozenSet String
853
dtsNoFreeSpaceCheck =
854
  ConstantUtils.mkSet $
855
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd]
856

    
857
dtsBlock :: FrozenSet String
858
dtsBlock =
859
  ConstantUtils.mkSet $
860
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
861

    
862
-- * Drbd
863

    
864
drbdHmacAlg :: String
865
drbdHmacAlg = "md5"
866

    
867
drbdDefaultNetProtocol :: String
868
drbdDefaultNetProtocol = "C"
869

    
870
drbdMigrationNetProtocol :: String
871
drbdMigrationNetProtocol = "C"
872

    
873
drbdStatusFile :: String
874
drbdStatusFile = "/proc/drbd"
875

    
876
-- | Size of DRBD meta block device
877
drbdMetaSize :: Int
878
drbdMetaSize = 128
879

    
880
-- * Drbd barrier types
881

    
882
drbdBDiskBarriers :: String
883
drbdBDiskBarriers = "b"
884

    
885
drbdBDiskDrain :: String
886
drbdBDiskDrain = "d"
887

    
888
drbdBDiskFlush :: String
889
drbdBDiskFlush = "f"
890

    
891
drbdBNone :: String
892
drbdBNone = "n"
893

    
894
-- | Rbd tool command
895
rbdCmd :: String
896
rbdCmd = "rbd"
897

    
898
-- * File backend driver
899

    
900
fdBlktap :: String
901
fdBlktap = Types.fileDriverToRaw FileBlktap
902

    
903
fdLoop :: String
904
fdLoop = Types.fileDriverToRaw FileLoop
905

    
906
fileDriver :: FrozenSet String
907
fileDriver =
908
  ConstantUtils.mkSet $
909
  map Types.fileDriverToRaw [minBound..]
910

    
911
-- | The set of drbd-like disk types
912
dtsDrbd :: FrozenSet String
913
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
914

    
915
-- * Disk access mode
916

    
917
diskRdonly :: String
918
diskRdonly = Types.diskModeToRaw DiskRdOnly
919

    
920
diskRdwr :: String
921
diskRdwr = Types.diskModeToRaw DiskRdWr
922

    
923
diskAccessSet :: FrozenSet String
924
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
925

    
926
-- * Disk replacement mode
927

    
928
replaceDiskAuto :: String
929
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
930

    
931
replaceDiskChg :: String
932
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
933

    
934
replaceDiskPri :: String
935
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
936

    
937
replaceDiskSec :: String
938
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
939

    
940
replaceModes :: FrozenSet String
941
replaceModes =
942
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
943

    
944
-- * Instance export mode
945

    
946
exportModeLocal :: String
947
exportModeLocal = Types.exportModeToRaw ExportModeLocal
948

    
949
exportModeRemote :: String
950
exportModeRemote = Types.exportModeToRaw ExportModeRemote
951

    
952
exportModes :: FrozenSet String
953
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
954

    
955
-- * Instance creation modes
956

    
957
instanceCreate :: String
958
instanceCreate = Types.instCreateModeToRaw InstCreate
959

    
960
instanceImport :: String
961
instanceImport = Types.instCreateModeToRaw InstImport
962

    
963
instanceRemoteImport :: String
964
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
965

    
966
instanceCreateModes :: FrozenSet String
967
instanceCreateModes =
968
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
969

    
970
-- * Remote import/export handshake message and version
971

    
972
rieHandshake :: String
973
rieHandshake = "Hi, I'm Ganeti"
974

    
975
rieVersion :: Int
976
rieVersion = 0
977

    
978
-- | Remote import/export certificate validity in seconds
979
rieCertValidity :: Int
980
rieCertValidity = 24 * 60 * 60
981

    
982
-- | Export only: how long to wait per connection attempt (seconds)
983
rieConnectAttemptTimeout :: Int
984
rieConnectAttemptTimeout = 20
985

    
986
-- | Export only: number of attempts to connect
987
rieConnectRetries :: Int
988
rieConnectRetries = 10
989

    
990
-- | Overall timeout for establishing connection
991
rieConnectTimeout :: Int
992
rieConnectTimeout = 180
993

    
994
-- | Give child process up to 5 seconds to exit after sending a signal
995
childLingerTimeout :: Double
996
childLingerTimeout = 5.0
997

    
998
-- * Import/export config options
999

    
1000
inisectBep :: String
1001
inisectBep = "backend"
1002

    
1003
inisectExp :: String
1004
inisectExp = "export"
1005

    
1006
inisectHyp :: String
1007
inisectHyp = "hypervisor"
1008

    
1009
inisectIns :: String
1010
inisectIns = "instance"
1011

    
1012
inisectOsp :: String
1013
inisectOsp = "os"
1014

    
1015
-- * Dynamic device modification
1016

    
1017
ddmAdd :: String
1018
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1019

    
1020
ddmModify :: String
1021
ddmModify = Types.ddmFullToRaw DdmFullModify
1022

    
1023
ddmRemove :: String
1024
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1025

    
1026
ddmsValues :: FrozenSet String
1027
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1028

    
1029
ddmsValuesWithModify :: FrozenSet String
1030
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1031

    
1032
-- * Common exit codes
1033

    
1034
exitSuccess :: Int
1035
exitSuccess = 0
1036

    
1037
exitFailure :: Int
1038
exitFailure = ConstantUtils.exitFailure
1039

    
1040
exitNotcluster :: Int
1041
exitNotcluster = 5
1042

    
1043
exitNotmaster :: Int
1044
exitNotmaster = 11
1045

    
1046
exitNodesetupError :: Int
1047
exitNodesetupError = 12
1048

    
1049
-- | Need user confirmation
1050
exitConfirmation :: Int
1051
exitConfirmation = 13
1052

    
1053
-- | Exit code for query operations with unknown fields
1054
exitUnknownField :: Int
1055
exitUnknownField = 14
1056

    
1057
-- * Tags
1058

    
1059
tagCluster :: String
1060
tagCluster = Types.tagKindToRaw TagKindCluster
1061

    
1062
tagInstance :: String
1063
tagInstance = Types.tagKindToRaw TagKindInstance
1064

    
1065
tagNetwork :: String
1066
tagNetwork = Types.tagKindToRaw TagKindNetwork
1067

    
1068
tagNode :: String
1069
tagNode = Types.tagKindToRaw TagKindNode
1070

    
1071
tagNodegroup :: String
1072
tagNodegroup = Types.tagKindToRaw TagKindGroup
1073

    
1074
validTagTypes :: FrozenSet String
1075
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1076

    
1077
maxTagLen :: Int
1078
maxTagLen = 128
1079

    
1080
maxTagsPerObj :: Int
1081
maxTagsPerObj = 4096
1082

    
1083
-- * Others
1084

    
1085
defaultBridge :: String
1086
defaultBridge = "xen-br0"
1087

    
1088
defaultOvs :: String
1089
defaultOvs = "switch1"
1090

    
1091
-- | 60 MiB, expressed in KiB
1092
classicDrbdSyncSpeed :: Int
1093
classicDrbdSyncSpeed = 60 * 1024
1094

    
1095
ip4AddressAny :: String
1096
ip4AddressAny = "0.0.0.0"
1097

    
1098
ip4AddressLocalhost :: String
1099
ip4AddressLocalhost = "127.0.0.1"
1100

    
1101
ip6AddressAny :: String
1102
ip6AddressAny = "::"
1103

    
1104
ip6AddressLocalhost :: String
1105
ip6AddressLocalhost = "::1"
1106

    
1107
ip4Version :: Int
1108
ip4Version = 4
1109

    
1110
ip6Version :: Int
1111
ip6Version = 6
1112

    
1113
validIpVersions :: FrozenSet Int
1114
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1115

    
1116
tcpPingTimeout :: Int
1117
tcpPingTimeout = 10
1118

    
1119
defaultVg :: String
1120
defaultVg = "xenvg"
1121

    
1122
defaultDrbdHelper :: String
1123
defaultDrbdHelper = "/bin/true"
1124

    
1125
minVgSize :: Int
1126
minVgSize = 20480
1127

    
1128
defaultMacPrefix :: String
1129
defaultMacPrefix = "aa:00:00"
1130

    
1131
-- | Default maximum instance wait time, in seconds.
1132
defaultShutdownTimeout :: Int
1133
defaultShutdownTimeout = 120
1134

    
1135
-- | Node clock skew in seconds
1136
nodeMaxClockSkew :: Int
1137
nodeMaxClockSkew = 150
1138

    
1139
-- | Time for an intra-cluster disk transfer to wait for a connection
1140
diskTransferConnectTimeout :: Int
1141
diskTransferConnectTimeout = 60
1142

    
1143
-- | Disk index separator
1144
diskSeparator :: String
1145
diskSeparator = AutoConf.diskSeparator
1146

    
1147
ipCommandPath :: String
1148
ipCommandPath = AutoConf.ipPath
1149

    
1150
-- | Key for job IDs in opcode result
1151
jobIdsKey :: String
1152
jobIdsKey = "jobs"
1153

    
1154
-- * Runparts results
1155

    
1156
runpartsErr :: Int
1157
runpartsErr = 2
1158

    
1159
runpartsRun :: Int
1160
runpartsRun = 1
1161

    
1162
runpartsSkip :: Int
1163
runpartsSkip = 0
1164

    
1165
runpartsStatus :: [Int]
1166
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1167

    
1168
-- * RPC
1169

    
1170
rpcEncodingNone :: Int
1171
rpcEncodingNone = 0
1172

    
1173
rpcEncodingZlibBase64 :: Int
1174
rpcEncodingZlibBase64 = 1
1175

    
1176
-- * Timeout table
1177
--
1178
-- Various time constants for the timeout table
1179

    
1180
rpcTmoUrgent :: Int
1181
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1182

    
1183
rpcTmoFast :: Int
1184
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1185

    
1186
rpcTmoNormal :: Int
1187
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1188

    
1189
rpcTmoSlow :: Int
1190
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1191

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

    
1198
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1199
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1200
-- Python name.
1201
rpcTmo_1day :: Int
1202
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1203

    
1204
-- | Timeout for connecting to nodes (seconds)
1205
rpcConnectTimeout :: Int
1206
rpcConnectTimeout = 5
1207

    
1208
-- OS
1209

    
1210
osScriptCreate :: String
1211
osScriptCreate = "create"
1212

    
1213
osScriptExport :: String
1214
osScriptExport = "export"
1215

    
1216
osScriptImport :: String
1217
osScriptImport = "import"
1218

    
1219
osScriptRename :: String
1220
osScriptRename = "rename"
1221

    
1222
osScriptVerify :: String
1223
osScriptVerify = "verify"
1224

    
1225
osScripts :: [String]
1226
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1227
             osScriptVerify]
1228

    
1229
osApiFile :: String
1230
osApiFile = "ganeti_api_version"
1231

    
1232
osVariantsFile :: String
1233
osVariantsFile = "variants.list"
1234

    
1235
osParametersFile :: String
1236
osParametersFile = "parameters.list"
1237

    
1238
osValidateParameters :: String
1239
osValidateParameters = "parameters"
1240

    
1241
osValidateCalls :: FrozenSet String
1242
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1243

    
1244
-- | External Storage (ES) related constants
1245

    
1246
esActionAttach :: String
1247
esActionAttach = "attach"
1248

    
1249
esActionCreate :: String
1250
esActionCreate = "create"
1251

    
1252
esActionDetach :: String
1253
esActionDetach = "detach"
1254

    
1255
esActionGrow :: String
1256
esActionGrow = "grow"
1257

    
1258
esActionRemove :: String
1259
esActionRemove = "remove"
1260

    
1261
esActionSetinfo :: String
1262
esActionSetinfo = "setinfo"
1263

    
1264
esActionVerify :: String
1265
esActionVerify = "verify"
1266

    
1267
esScriptCreate :: String
1268
esScriptCreate = esActionCreate
1269

    
1270
esScriptRemove :: String
1271
esScriptRemove = esActionRemove
1272

    
1273
esScriptGrow :: String
1274
esScriptGrow = esActionGrow
1275

    
1276
esScriptAttach :: String
1277
esScriptAttach = esActionAttach
1278

    
1279
esScriptDetach :: String
1280
esScriptDetach = esActionDetach
1281

    
1282
esScriptSetinfo :: String
1283
esScriptSetinfo = esActionSetinfo
1284

    
1285
esScriptVerify :: String
1286
esScriptVerify = esActionVerify
1287

    
1288
esScripts :: FrozenSet String
1289
esScripts =
1290
  ConstantUtils.mkSet [esScriptAttach,
1291
                       esScriptCreate,
1292
                       esScriptDetach,
1293
                       esScriptGrow,
1294
                       esScriptRemove,
1295
                       esScriptSetinfo,
1296
                       esScriptVerify]
1297

    
1298
esParametersFile :: String
1299
esParametersFile = "parameters.list"
1300

    
1301
-- * Reboot types
1302

    
1303
instanceRebootSoft :: String
1304
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1305

    
1306
instanceRebootHard :: String
1307
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1308

    
1309
instanceRebootFull :: String
1310
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1311

    
1312
rebootTypes :: FrozenSet String
1313
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1314

    
1315
-- * Instance reboot behaviors
1316

    
1317
instanceRebootAllowed :: String
1318
instanceRebootAllowed = "reboot"
1319

    
1320
instanceRebootExit :: String
1321
instanceRebootExit = "exit"
1322

    
1323
rebootBehaviors :: [String]
1324
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1325

    
1326
-- * VTypes
1327

    
1328
vtypeBool :: VType
1329
vtypeBool = VTypeBool
1330

    
1331
vtypeInt :: VType
1332
vtypeInt = VTypeInt
1333

    
1334
vtypeMaybeString :: VType
1335
vtypeMaybeString = VTypeMaybeString
1336

    
1337
-- | Size in MiBs
1338
vtypeSize :: VType
1339
vtypeSize = VTypeSize
1340

    
1341
vtypeString :: VType
1342
vtypeString = VTypeString
1343

    
1344
enforceableTypes :: FrozenSet VType
1345
enforceableTypes = ConstantUtils.mkSet [minBound..]
1346

    
1347
-- | Constant representing that the user does not specify any IP version
1348
ifaceNoIpVersionSpecified :: Int
1349
ifaceNoIpVersionSpecified = 0
1350

    
1351
validSerialSpeeds :: [Int]
1352
validSerialSpeeds =
1353
  [75,
1354
   110,
1355
   300,
1356
   600,
1357
   1200,
1358
   1800,
1359
   2400,
1360
   4800,
1361
   9600,
1362
   14400,
1363
   19200,
1364
   28800,
1365
   38400,
1366
   57600,
1367
   115200,
1368
   230400,
1369
   345600,
1370
   460800]
1371

    
1372
-- * HV parameter names (global namespace)
1373

    
1374
hvAcpi :: String
1375
hvAcpi = "acpi"
1376

    
1377
hvBlockdevPrefix :: String
1378
hvBlockdevPrefix = "blockdev_prefix"
1379

    
1380
hvBootloaderArgs :: String
1381
hvBootloaderArgs = "bootloader_args"
1382

    
1383
hvBootloaderPath :: String
1384
hvBootloaderPath = "bootloader_path"
1385

    
1386
hvBootOrder :: String
1387
hvBootOrder = "boot_order"
1388

    
1389
hvCdromImagePath :: String
1390
hvCdromImagePath = "cdrom_image_path"
1391

    
1392
hvCpuCap :: String
1393
hvCpuCap = "cpu_cap"
1394

    
1395
hvCpuCores :: String
1396
hvCpuCores = "cpu_cores"
1397

    
1398
hvCpuMask :: String
1399
hvCpuMask = "cpu_mask"
1400

    
1401
hvCpuSockets :: String
1402
hvCpuSockets = "cpu_sockets"
1403

    
1404
hvCpuThreads :: String
1405
hvCpuThreads = "cpu_threads"
1406

    
1407
hvCpuType :: String
1408
hvCpuType = "cpu_type"
1409

    
1410
hvCpuWeight :: String
1411
hvCpuWeight = "cpu_weight"
1412

    
1413
hvDeviceModel :: String
1414
hvDeviceModel = "device_model"
1415

    
1416
hvDiskCache :: String
1417
hvDiskCache = "disk_cache"
1418

    
1419
hvDiskType :: String
1420
hvDiskType = "disk_type"
1421

    
1422
hvInitrdPath :: String
1423
hvInitrdPath = "initrd_path"
1424

    
1425
hvInitScript :: String
1426
hvInitScript = "init_script"
1427

    
1428
hvKernelArgs :: String
1429
hvKernelArgs = "kernel_args"
1430

    
1431
hvKernelPath :: String
1432
hvKernelPath = "kernel_path"
1433

    
1434
hvKeymap :: String
1435
hvKeymap = "keymap"
1436

    
1437
hvKvmCdrom2ImagePath :: String
1438
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1439

    
1440
hvKvmCdromDiskType :: String
1441
hvKvmCdromDiskType = "cdrom_disk_type"
1442

    
1443
hvKvmExtra :: String
1444
hvKvmExtra = "kvm_extra"
1445

    
1446
hvKvmFlag :: String
1447
hvKvmFlag = "kvm_flag"
1448

    
1449
hvKvmFloppyImagePath :: String
1450
hvKvmFloppyImagePath = "floppy_image_path"
1451

    
1452
hvKvmMachineVersion :: String
1453
hvKvmMachineVersion = "machine_version"
1454

    
1455
hvKvmPath :: String
1456
hvKvmPath = "kvm_path"
1457

    
1458
hvKvmSpiceAudioCompr :: String
1459
hvKvmSpiceAudioCompr = "spice_playback_compression"
1460

    
1461
hvKvmSpiceBind :: String
1462
hvKvmSpiceBind = "spice_bind"
1463

    
1464
hvKvmSpiceIpVersion :: String
1465
hvKvmSpiceIpVersion = "spice_ip_version"
1466

    
1467
hvKvmSpiceJpegImgCompr :: String
1468
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1469

    
1470
hvKvmSpiceLosslessImgCompr :: String
1471
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1472

    
1473
hvKvmSpicePasswordFile :: String
1474
hvKvmSpicePasswordFile = "spice_password_file"
1475

    
1476
hvKvmSpiceStreamingVideoDetection :: String
1477
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1478

    
1479
hvKvmSpiceTlsCiphers :: String
1480
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1481

    
1482
hvKvmSpiceUseTls :: String
1483
hvKvmSpiceUseTls = "spice_use_tls"
1484

    
1485
hvKvmSpiceUseVdagent :: String
1486
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1487

    
1488
hvKvmSpiceZlibGlzImgCompr :: String
1489
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1490

    
1491
hvKvmUseChroot :: String
1492
hvKvmUseChroot = "use_chroot"
1493

    
1494
hvMemPath :: String
1495
hvMemPath = "mem_path"
1496

    
1497
hvMigrationBandwidth :: String
1498
hvMigrationBandwidth = "migration_bandwidth"
1499

    
1500
hvMigrationDowntime :: String
1501
hvMigrationDowntime = "migration_downtime"
1502

    
1503
hvMigrationMode :: String
1504
hvMigrationMode = "migration_mode"
1505

    
1506
hvMigrationPort :: String
1507
hvMigrationPort = "migration_port"
1508

    
1509
hvNicType :: String
1510
hvNicType = "nic_type"
1511

    
1512
hvPae :: String
1513
hvPae = "pae"
1514

    
1515
hvPassthrough :: String
1516
hvPassthrough = "pci_pass"
1517

    
1518
hvRebootBehavior :: String
1519
hvRebootBehavior = "reboot_behavior"
1520

    
1521
hvRootPath :: String
1522
hvRootPath = "root_path"
1523

    
1524
hvSecurityDomain :: String
1525
hvSecurityDomain = "security_domain"
1526

    
1527
hvSecurityModel :: String
1528
hvSecurityModel = "security_model"
1529

    
1530
hvSerialConsole :: String
1531
hvSerialConsole = "serial_console"
1532

    
1533
hvSerialSpeed :: String
1534
hvSerialSpeed = "serial_speed"
1535

    
1536
hvSoundhw :: String
1537
hvSoundhw = "soundhw"
1538

    
1539
hvUsbDevices :: String
1540
hvUsbDevices = "usb_devices"
1541

    
1542
hvUsbMouse :: String
1543
hvUsbMouse = "usb_mouse"
1544

    
1545
hvUseBootloader :: String
1546
hvUseBootloader = "use_bootloader"
1547

    
1548
hvUseLocaltime :: String
1549
hvUseLocaltime = "use_localtime"
1550

    
1551
hvVga :: String
1552
hvVga = "vga"
1553

    
1554
hvVhostNet :: String
1555
hvVhostNet = "vhost_net"
1556

    
1557
hvVifScript :: String
1558
hvVifScript = "vif_script"
1559

    
1560
hvVifType :: String
1561
hvVifType = "vif_type"
1562

    
1563
hvViridian :: String
1564
hvViridian = "viridian"
1565

    
1566
hvVncBindAddress :: String
1567
hvVncBindAddress = "vnc_bind_address"
1568

    
1569
hvVncPasswordFile :: String
1570
hvVncPasswordFile = "vnc_password_file"
1571

    
1572
hvVncTls :: String
1573
hvVncTls = "vnc_tls"
1574

    
1575
hvVncX509 :: String
1576
hvVncX509 = "vnc_x509_path"
1577

    
1578
hvVncX509Verify :: String
1579
hvVncX509Verify = "vnc_x509_verify"
1580

    
1581
hvVnetHdr :: String
1582
hvVnetHdr = "vnet_hdr"
1583

    
1584
hvXenCmd :: String
1585
hvXenCmd = "xen_cmd"
1586

    
1587
hvXenCpuid :: String
1588
hvXenCpuid = "cpuid"
1589

    
1590
hvsParameterTitles :: Map String String
1591
hvsParameterTitles =
1592
  Map.fromList
1593
  [(hvAcpi, "ACPI"),
1594
   (hvBootOrder, "Boot_order"),
1595
   (hvCdromImagePath, "CDROM_image_path"),
1596
   (hvCpuType, "cpu_type"),
1597
   (hvDiskType, "Disk_type"),
1598
   (hvInitrdPath, "Initrd_path"),
1599
   (hvKernelPath, "Kernel_path"),
1600
   (hvNicType, "NIC_type"),
1601
   (hvPae, "PAE"),
1602
   (hvPassthrough, "pci_pass"),
1603
   (hvVncBindAddress, "VNC_bind_address")]
1604

    
1605
hvsParameters :: FrozenSet String
1606
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1607

    
1608
hvsParameterTypes :: Map String VType
1609
hvsParameterTypes = Map.fromList
1610
  [ (hvAcpi,                            VTypeBool)
1611
  , (hvBlockdevPrefix,                  VTypeString)
1612
  , (hvBootloaderArgs,                  VTypeString)
1613
  , (hvBootloaderPath,                  VTypeString)
1614
  , (hvBootOrder,                       VTypeString)
1615
  , (hvCdromImagePath,                  VTypeString)
1616
  , (hvCpuCap,                          VTypeInt)
1617
  , (hvCpuCores,                        VTypeInt)
1618
  , (hvCpuMask,                         VTypeString)
1619
  , (hvCpuSockets,                      VTypeInt)
1620
  , (hvCpuThreads,                      VTypeInt)
1621
  , (hvCpuType,                         VTypeString)
1622
  , (hvCpuWeight,                       VTypeInt)
1623
  , (hvDeviceModel,                     VTypeString)
1624
  , (hvDiskCache,                       VTypeString)
1625
  , (hvDiskType,                        VTypeString)
1626
  , (hvInitrdPath,                      VTypeString)
1627
  , (hvInitScript,                      VTypeString)
1628
  , (hvKernelArgs,                      VTypeString)
1629
  , (hvKernelPath,                      VTypeString)
1630
  , (hvKeymap,                          VTypeString)
1631
  , (hvKvmCdrom2ImagePath,              VTypeString)
1632
  , (hvKvmCdromDiskType,                VTypeString)
1633
  , (hvKvmExtra,                        VTypeString)
1634
  , (hvKvmFlag,                         VTypeString)
1635
  , (hvKvmFloppyImagePath,              VTypeString)
1636
  , (hvKvmMachineVersion,               VTypeString)
1637
  , (hvKvmPath,                         VTypeString)
1638
  , (hvKvmSpiceAudioCompr,              VTypeBool)
1639
  , (hvKvmSpiceBind,                    VTypeString)
1640
  , (hvKvmSpiceIpVersion,               VTypeInt)
1641
  , (hvKvmSpiceJpegImgCompr,            VTypeString)
1642
  , (hvKvmSpiceLosslessImgCompr,        VTypeString)
1643
  , (hvKvmSpicePasswordFile,            VTypeString)
1644
  , (hvKvmSpiceStreamingVideoDetection, VTypeString)
1645
  , (hvKvmSpiceTlsCiphers,              VTypeString)
1646
  , (hvKvmSpiceUseTls,                  VTypeBool)
1647
  , (hvKvmSpiceUseVdagent,              VTypeBool)
1648
  , (hvKvmSpiceZlibGlzImgCompr,         VTypeString)
1649
  , (hvKvmUseChroot,                    VTypeBool)
1650
  , (hvMemPath,                         VTypeString)
1651
  , (hvMigrationBandwidth,              VTypeInt)
1652
  , (hvMigrationDowntime,               VTypeInt)
1653
  , (hvMigrationMode,                   VTypeString)
1654
  , (hvMigrationPort,                   VTypeInt)
1655
  , (hvNicType,                         VTypeString)
1656
  , (hvPae,                             VTypeBool)
1657
  , (hvPassthrough,                     VTypeString)
1658
  , (hvRebootBehavior,                  VTypeString)
1659
  , (hvRootPath,                        VTypeMaybeString)
1660
  , (hvSecurityDomain,                  VTypeString)
1661
  , (hvSecurityModel,                   VTypeString)
1662
  , (hvSerialConsole,                   VTypeBool)
1663
  , (hvSerialSpeed,                     VTypeInt)
1664
  , (hvSoundhw,                         VTypeString)
1665
  , (hvUsbDevices,                      VTypeString)
1666
  , (hvUsbMouse,                        VTypeString)
1667
  , (hvUseBootloader,                   VTypeBool)
1668
  , (hvUseLocaltime,                    VTypeBool)
1669
  , (hvVga,                             VTypeString)
1670
  , (hvVhostNet,                        VTypeBool)
1671
  , (hvVifScript,                       VTypeString)
1672
  , (hvVifType,                         VTypeString)
1673
  , (hvViridian,                        VTypeBool)
1674
  , (hvVncBindAddress,                  VTypeString)
1675
  , (hvVncPasswordFile,                 VTypeString)
1676
  , (hvVncTls,                          VTypeBool)
1677
  , (hvVncX509,                         VTypeString)
1678
  , (hvVncX509Verify,                   VTypeBool)
1679
  , (hvVnetHdr,                         VTypeBool)
1680
  , (hvXenCmd,                          VTypeString)
1681
  , (hvXenCpuid,                        VTypeString)
1682
  ]
1683

    
1684
-- * Migration statuses
1685

    
1686
hvMigrationActive :: String
1687
hvMigrationActive = "active"
1688

    
1689
hvMigrationCancelled :: String
1690
hvMigrationCancelled = "cancelled"
1691

    
1692
hvMigrationCompleted :: String
1693
hvMigrationCompleted = "completed"
1694

    
1695
hvMigrationFailed :: String
1696
hvMigrationFailed = "failed"
1697

    
1698
hvMigrationValidStatuses :: FrozenSet String
1699
hvMigrationValidStatuses =
1700
  ConstantUtils.mkSet [hvMigrationActive,
1701
                       hvMigrationCancelled,
1702
                       hvMigrationCompleted,
1703
                       hvMigrationFailed]
1704

    
1705
hvMigrationFailedStatuses :: FrozenSet String
1706
hvMigrationFailedStatuses =
1707
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1708

    
1709
-- | KVM-specific statuses
1710
--
1711
-- FIXME: this constant seems unnecessary
1712
hvKvmMigrationValidStatuses :: FrozenSet String
1713
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1714

    
1715
-- | Node info keys
1716
hvNodeinfoKeyVersion :: String
1717
hvNodeinfoKeyVersion = "hv_version"
1718

    
1719
-- * Hypervisor state
1720

    
1721
hvstCpuNode :: String
1722
hvstCpuNode = "cpu_node"
1723

    
1724
hvstCpuTotal :: String
1725
hvstCpuTotal = "cpu_total"
1726

    
1727
hvstMemoryHv :: String
1728
hvstMemoryHv = "mem_hv"
1729

    
1730
hvstMemoryNode :: String
1731
hvstMemoryNode = "mem_node"
1732

    
1733
hvstMemoryTotal :: String
1734
hvstMemoryTotal = "mem_total"
1735

    
1736
hvstsParameters :: FrozenSet String
1737
hvstsParameters =
1738
  ConstantUtils.mkSet [hvstCpuNode,
1739
                       hvstCpuTotal,
1740
                       hvstMemoryHv,
1741
                       hvstMemoryNode,
1742
                       hvstMemoryTotal]
1743

    
1744
hvstDefaults :: Map String Int
1745
hvstDefaults =
1746
  Map.fromList
1747
  [(hvstCpuNode, 1),
1748
   (hvstCpuTotal, 1),
1749
   (hvstMemoryHv, 0),
1750
   (hvstMemoryTotal, 0),
1751
   (hvstMemoryNode, 0)]
1752

    
1753
hvstsParameterTypes :: Map String VType
1754
hvstsParameterTypes =
1755
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1756
                (hvstMemoryNode, VTypeInt),
1757
                (hvstMemoryHv, VTypeInt),
1758
                (hvstCpuTotal, VTypeInt),
1759
                (hvstCpuNode, VTypeInt)]
1760

    
1761
-- * Disk state
1762

    
1763
dsDiskOverhead :: String
1764
dsDiskOverhead = "disk_overhead"
1765

    
1766
dsDiskReserved :: String
1767
dsDiskReserved = "disk_reserved"
1768

    
1769
dsDiskTotal :: String
1770
dsDiskTotal = "disk_total"
1771

    
1772
dsDefaults :: Map String Int
1773
dsDefaults =
1774
  Map.fromList
1775
  [(dsDiskTotal, 0),
1776
   (dsDiskReserved, 0),
1777
   (dsDiskOverhead, 0)]
1778

    
1779
dssParameterTypes :: Map String VType
1780
dssParameterTypes =
1781
  Map.fromList [(dsDiskTotal, VTypeInt),
1782
                (dsDiskReserved, VTypeInt),
1783
                (dsDiskOverhead, VTypeInt)]
1784

    
1785
dssParameters :: FrozenSet String
1786
dssParameters =
1787
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1788

    
1789
dsValidTypes :: FrozenSet String
1790
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1791

    
1792
-- Backend parameter names
1793

    
1794
beAlwaysFailover :: String
1795
beAlwaysFailover = "always_failover"
1796

    
1797
beAutoBalance :: String
1798
beAutoBalance = "auto_balance"
1799

    
1800
beMaxmem :: String
1801
beMaxmem = "maxmem"
1802

    
1803
-- | Deprecated and replaced by max and min mem
1804
beMemory :: String
1805
beMemory = "memory"
1806

    
1807
beMinmem :: String
1808
beMinmem = "minmem"
1809

    
1810
beSpindleUse :: String
1811
beSpindleUse = "spindle_use"
1812

    
1813
beVcpus :: String
1814
beVcpus = "vcpus"
1815

    
1816
besParameterTypes :: Map String VType
1817
besParameterTypes =
1818
  Map.fromList [(beAlwaysFailover, VTypeBool),
1819
                (beAutoBalance, VTypeBool),
1820
                (beMaxmem, VTypeSize),
1821
                (beMinmem, VTypeSize),
1822
                (beSpindleUse, VTypeInt),
1823
                (beVcpus, VTypeInt)]
1824

    
1825
besParameterTitles :: Map String String
1826
besParameterTitles =
1827
  Map.fromList [(beAutoBalance, "Auto_balance"),
1828
                (beMinmem, "ConfigMinMem"),
1829
                (beVcpus, "ConfigVCPUs"),
1830
                (beMaxmem, "ConfigMaxMem")]
1831

    
1832
besParameterCompat :: Map String VType
1833
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1834

    
1835
besParameters :: FrozenSet String
1836
besParameters =
1837
  ConstantUtils.mkSet [beAlwaysFailover,
1838
                       beAutoBalance,
1839
                       beMaxmem,
1840
                       beMinmem,
1841
                       beSpindleUse,
1842
                       beVcpus]
1843

    
1844
-- | Instance specs
1845
--
1846
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1847

    
1848
ispecMemSize :: String
1849
ispecMemSize = ConstantUtils.ispecMemSize
1850

    
1851
ispecCpuCount :: String
1852
ispecCpuCount = ConstantUtils.ispecCpuCount
1853

    
1854
ispecDiskCount :: String
1855
ispecDiskCount = ConstantUtils.ispecDiskCount
1856

    
1857
ispecDiskSize :: String
1858
ispecDiskSize = ConstantUtils.ispecDiskSize
1859

    
1860
ispecNicCount :: String
1861
ispecNicCount = ConstantUtils.ispecNicCount
1862

    
1863
ispecSpindleUse :: String
1864
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1865

    
1866
ispecsParameterTypes :: Map String VType
1867
ispecsParameterTypes =
1868
  Map.fromList
1869
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1870
   (ConstantUtils.ispecCpuCount, VTypeInt),
1871
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1872
   (ConstantUtils.ispecMemSize, VTypeInt),
1873
   (ConstantUtils.ispecNicCount, VTypeInt),
1874
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1875

    
1876
ispecsParameters :: FrozenSet String
1877
ispecsParameters =
1878
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1879
                       ConstantUtils.ispecDiskCount,
1880
                       ConstantUtils.ispecDiskSize,
1881
                       ConstantUtils.ispecMemSize,
1882
                       ConstantUtils.ispecNicCount,
1883
                       ConstantUtils.ispecSpindleUse]
1884

    
1885
ispecsMinmax :: String
1886
ispecsMinmax = ConstantUtils.ispecsMinmax
1887

    
1888
ispecsMax :: String
1889
ispecsMax = "max"
1890

    
1891
ispecsMin :: String
1892
ispecsMin = "min"
1893

    
1894
ispecsStd :: String
1895
ispecsStd = ConstantUtils.ispecsStd
1896

    
1897
ipolicyDts :: String
1898
ipolicyDts = ConstantUtils.ipolicyDts
1899

    
1900
ipolicyVcpuRatio :: String
1901
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1902

    
1903
ipolicySpindleRatio :: String
1904
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
1905

    
1906
ispecsMinmaxKeys :: FrozenSet String
1907
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1908

    
1909
ipolicyParameters :: FrozenSet String
1910
ipolicyParameters =
1911
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1912
                       ConstantUtils.ipolicySpindleRatio]
1913

    
1914
ipolicyAllKeys :: FrozenSet String
1915
ipolicyAllKeys =
1916
  ConstantUtils.union ipolicyParameters $
1917
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1918
                       ConstantUtils.ispecsMinmax,
1919
                       ispecsStd]
1920

    
1921
-- | Node parameter names
1922

    
1923
ndExclusiveStorage :: String
1924
ndExclusiveStorage = "exclusive_storage"
1925

    
1926
ndOobProgram :: String
1927
ndOobProgram = "oob_program"
1928

    
1929
ndSpindleCount :: String
1930
ndSpindleCount = "spindle_count"
1931

    
1932
ndOvs :: String
1933
ndOvs = "ovs"
1934

    
1935
ndOvsLink :: String
1936
ndOvsLink = "ovs_link"
1937

    
1938
ndOvsName :: String
1939
ndOvsName = "ovs_name"
1940

    
1941
ndsParameterTypes :: Map String VType
1942
ndsParameterTypes =
1943
  Map.fromList
1944
  [(ndExclusiveStorage, VTypeBool),
1945
   (ndOobProgram, VTypeString),
1946
   (ndOvs, VTypeBool),
1947
   (ndOvsLink, VTypeMaybeString),
1948
   (ndOvsName, VTypeMaybeString),
1949
   (ndSpindleCount, VTypeInt)]
1950

    
1951
ndsParameters :: FrozenSet String
1952
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
1953

    
1954
ndsParameterTitles :: Map String String
1955
ndsParameterTitles =
1956
  Map.fromList
1957
  [(ndExclusiveStorage, "ExclusiveStorage"),
1958
   (ndOobProgram, "OutOfBandProgram"),
1959
   (ndOvs, "OpenvSwitch"),
1960
   (ndOvsLink, "OpenvSwitchLink"),
1961
   (ndOvsName, "OpenvSwitchName"),
1962
   (ndSpindleCount, "SpindleCount")]
1963

    
1964
-- * Logical Disks parameters
1965

    
1966
ldpAccess :: String
1967
ldpAccess = "access"
1968

    
1969
ldpBarriers :: String
1970
ldpBarriers = "disabled-barriers"
1971

    
1972
ldpDefaultMetavg :: String
1973
ldpDefaultMetavg = "default-metavg"
1974

    
1975
ldpDelayTarget :: String
1976
ldpDelayTarget = "c-delay-target"
1977

    
1978
ldpDiskCustom :: String
1979
ldpDiskCustom = "disk-custom"
1980

    
1981
ldpDynamicResync :: String
1982
ldpDynamicResync = "dynamic-resync"
1983

    
1984
ldpFillTarget :: String
1985
ldpFillTarget = "c-fill-target"
1986

    
1987
ldpMaxRate :: String
1988
ldpMaxRate = "c-max-rate"
1989

    
1990
ldpMinRate :: String
1991
ldpMinRate = "c-min-rate"
1992

    
1993
ldpNetCustom :: String
1994
ldpNetCustom = "net-custom"
1995

    
1996
ldpNoMetaFlush :: String
1997
ldpNoMetaFlush = "disable-meta-flush"
1998

    
1999
ldpPlanAhead :: String
2000
ldpPlanAhead = "c-plan-ahead"
2001

    
2002
ldpPool :: String
2003
ldpPool = "pool"
2004

    
2005
ldpProtocol :: String
2006
ldpProtocol = "protocol"
2007

    
2008
ldpResyncRate :: String
2009
ldpResyncRate = "resync-rate"
2010

    
2011
ldpStripes :: String
2012
ldpStripes = "stripes"
2013

    
2014
diskLdTypes :: Map String VType
2015
diskLdTypes =
2016
  Map.fromList
2017
  [(ldpAccess, VTypeString),
2018
   (ldpResyncRate, VTypeInt),
2019
   (ldpStripes, VTypeInt),
2020
   (ldpBarriers, VTypeString),
2021
   (ldpNoMetaFlush, VTypeBool),
2022
   (ldpDefaultMetavg, VTypeString),
2023
   (ldpDiskCustom, VTypeString),
2024
   (ldpNetCustom, VTypeString),
2025
   (ldpProtocol, VTypeString),
2026
   (ldpDynamicResync, VTypeBool),
2027
   (ldpPlanAhead, VTypeInt),
2028
   (ldpFillTarget, VTypeInt),
2029
   (ldpDelayTarget, VTypeInt),
2030
   (ldpMaxRate, VTypeInt),
2031
   (ldpMinRate, VTypeInt),
2032
   (ldpPool, VTypeString)]
2033

    
2034
diskLdParameters :: FrozenSet String
2035
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2036

    
2037
-- * Disk template parameters
2038
--
2039
-- Disk template parameters can be set/changed by the user via
2040
-- gnt-cluster and gnt-group)
2041

    
2042
drbdResyncRate :: String
2043
drbdResyncRate = "resync-rate"
2044

    
2045
drbdDataStripes :: String
2046
drbdDataStripes = "data-stripes"
2047

    
2048
drbdMetaStripes :: String
2049
drbdMetaStripes = "meta-stripes"
2050

    
2051
drbdDiskBarriers :: String
2052
drbdDiskBarriers = "disk-barriers"
2053

    
2054
drbdMetaBarriers :: String
2055
drbdMetaBarriers = "meta-barriers"
2056

    
2057
drbdDefaultMetavg :: String
2058
drbdDefaultMetavg = "metavg"
2059

    
2060
drbdDiskCustom :: String
2061
drbdDiskCustom = "disk-custom"
2062

    
2063
drbdNetCustom :: String
2064
drbdNetCustom = "net-custom"
2065

    
2066
drbdProtocol :: String
2067
drbdProtocol = "protocol"
2068

    
2069
drbdDynamicResync :: String
2070
drbdDynamicResync = "dynamic-resync"
2071

    
2072
drbdPlanAhead :: String
2073
drbdPlanAhead = "c-plan-ahead"
2074

    
2075
drbdFillTarget :: String
2076
drbdFillTarget = "c-fill-target"
2077

    
2078
drbdDelayTarget :: String
2079
drbdDelayTarget = "c-delay-target"
2080

    
2081
drbdMaxRate :: String
2082
drbdMaxRate = "c-max-rate"
2083

    
2084
drbdMinRate :: String
2085
drbdMinRate = "c-min-rate"
2086

    
2087
lvStripes :: String
2088
lvStripes = "stripes"
2089

    
2090
rbdAccess :: String
2091
rbdAccess = "access"
2092

    
2093
rbdPool :: String
2094
rbdPool = "pool"
2095

    
2096
diskDtTypes :: Map String VType
2097
diskDtTypes =
2098
  Map.fromList [(drbdResyncRate, VTypeInt),
2099
                (drbdDataStripes, VTypeInt),
2100
                (drbdMetaStripes, VTypeInt),
2101
                (drbdDiskBarriers, VTypeString),
2102
                (drbdMetaBarriers, VTypeBool),
2103
                (drbdDefaultMetavg, VTypeString),
2104
                (drbdDiskCustom, VTypeString),
2105
                (drbdNetCustom, VTypeString),
2106
                (drbdProtocol, VTypeString),
2107
                (drbdDynamicResync, VTypeBool),
2108
                (drbdPlanAhead, VTypeInt),
2109
                (drbdFillTarget, VTypeInt),
2110
                (drbdDelayTarget, VTypeInt),
2111
                (drbdMaxRate, VTypeInt),
2112
                (drbdMinRate, VTypeInt),
2113
                (lvStripes, VTypeInt),
2114
                (rbdAccess, VTypeString),
2115
                (rbdPool, VTypeString)]
2116

    
2117
diskDtParameters :: FrozenSet String
2118
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2119

    
2120
-- * Dynamic disk parameters
2121

    
2122
ddpLocalIp :: String
2123
ddpLocalIp = "local-ip"
2124

    
2125
ddpRemoteIp :: String
2126
ddpRemoteIp = "remote-ip"
2127

    
2128
ddpPort :: String
2129
ddpPort = "port"
2130

    
2131
ddpLocalMinor :: String
2132
ddpLocalMinor = "local-minor"
2133

    
2134
ddpRemoteMinor :: String
2135
ddpRemoteMinor = "remote-minor"
2136

    
2137
-- * OOB supported commands
2138

    
2139
oobPowerOn :: String
2140
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2141

    
2142
oobPowerOff :: String
2143
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2144

    
2145
oobPowerCycle :: String
2146
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2147

    
2148
oobPowerStatus :: String
2149
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2150

    
2151
oobHealth :: String
2152
oobHealth = Types.oobCommandToRaw OobHealth
2153

    
2154
oobCommands :: FrozenSet String
2155
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2156

    
2157
oobPowerStatusPowered :: String
2158
oobPowerStatusPowered = "powered"
2159

    
2160
-- | 60 seconds
2161
oobTimeout :: Int
2162
oobTimeout = 60
2163

    
2164
-- | 2 seconds
2165
oobPowerDelay :: Double
2166
oobPowerDelay = 2.0
2167

    
2168
oobStatusCritical :: String
2169
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2170

    
2171
oobStatusOk :: String
2172
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2173

    
2174
oobStatusUnknown :: String
2175
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2176

    
2177
oobStatusWarning :: String
2178
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2179

    
2180
oobStatuses :: FrozenSet String
2181
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2182

    
2183
-- | Instance Parameters Profile
2184
ppDefault :: String
2185
ppDefault = "default"
2186

    
2187
-- * nic* constants are used inside the ganeti config
2188

    
2189
nicLink :: String
2190
nicLink = "link"
2191

    
2192
nicMode :: String
2193
nicMode = "mode"
2194

    
2195
nicVlan :: String
2196
nicVlan = "vlan"
2197

    
2198
nicsParameterTypes :: Map String VType
2199
nicsParameterTypes =
2200
  Map.fromList [(nicMode, vtypeString),
2201
                (nicLink, vtypeString),
2202
                (nicVlan, vtypeMaybeString)]
2203

    
2204
nicsParameters :: FrozenSet String
2205
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2206

    
2207
nicModeBridged :: String
2208
nicModeBridged = Types.nICModeToRaw NMBridged
2209

    
2210
nicModeRouted :: String
2211
nicModeRouted = Types.nICModeToRaw NMRouted
2212

    
2213
nicModeOvs :: String
2214
nicModeOvs = Types.nICModeToRaw NMOvs
2215

    
2216
nicIpPool :: String
2217
nicIpPool = Types.nICModeToRaw NMPool
2218

    
2219
nicValidModes :: FrozenSet String
2220
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2221

    
2222
releaseAction :: String
2223
releaseAction = "release"
2224

    
2225
reserveAction :: String
2226
reserveAction = "reserve"
2227

    
2228
-- * idisk* constants are used in opcodes, to create/change disks
2229

    
2230
idiskAdopt :: String
2231
idiskAdopt = "adopt"
2232

    
2233
idiskMetavg :: String
2234
idiskMetavg = "metavg"
2235

    
2236
idiskMode :: String
2237
idiskMode = "mode"
2238

    
2239
idiskName :: String
2240
idiskName = "name"
2241

    
2242
idiskSize :: String
2243
idiskSize = "size"
2244

    
2245
idiskSpindles :: String
2246
idiskSpindles = "spindles"
2247

    
2248
idiskVg :: String
2249
idiskVg = "vg"
2250

    
2251
idiskProvider :: String
2252
idiskProvider = "provider"
2253

    
2254
idiskParamsTypes :: Map String VType
2255
idiskParamsTypes =
2256
  Map.fromList [(idiskSize, VTypeSize),
2257
                (idiskSpindles, VTypeInt),
2258
                (idiskMode, VTypeString),
2259
                (idiskAdopt, VTypeString),
2260
                (idiskVg, VTypeString),
2261
                (idiskMetavg, VTypeString),
2262
                (idiskProvider, VTypeString),
2263
                (idiskName, VTypeMaybeString)]
2264

    
2265
idiskParams :: FrozenSet String
2266
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2267

    
2268
-- * inic* constants are used in opcodes, to create/change nics
2269

    
2270
inicBridge :: String
2271
inicBridge = "bridge"
2272

    
2273
inicIp :: String
2274
inicIp = "ip"
2275

    
2276
inicLink :: String
2277
inicLink = "link"
2278

    
2279
inicMac :: String
2280
inicMac = "mac"
2281

    
2282
inicMode :: String
2283
inicMode = "mode"
2284

    
2285
inicName :: String
2286
inicName = "name"
2287

    
2288
inicNetwork :: String
2289
inicNetwork = "network"
2290

    
2291
inicVlan :: String
2292
inicVlan = "vlan"
2293

    
2294
inicParamsTypes :: Map String VType
2295
inicParamsTypes =
2296
  Map.fromList [(inicBridge, VTypeMaybeString),
2297
                (inicIp, VTypeMaybeString),
2298
                (inicLink, VTypeString),
2299
                (inicMac, VTypeString),
2300
                (inicMode, VTypeString),
2301
                (inicName, VTypeMaybeString),
2302
                (inicNetwork, VTypeMaybeString),
2303
                (inicVlan, VTypeMaybeString)]
2304

    
2305
inicParams :: FrozenSet String
2306
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2307

    
2308
-- * Hypervisor constants
2309

    
2310
htXenPvm :: String
2311
htXenPvm = Types.hypervisorToRaw XenPvm
2312

    
2313
htFake :: String
2314
htFake = Types.hypervisorToRaw Fake
2315

    
2316
htXenHvm :: String
2317
htXenHvm = Types.hypervisorToRaw XenHvm
2318

    
2319
htKvm :: String
2320
htKvm = Types.hypervisorToRaw Kvm
2321

    
2322
htChroot :: String
2323
htChroot = Types.hypervisorToRaw Chroot
2324

    
2325
htLxc :: String
2326
htLxc = Types.hypervisorToRaw Lxc
2327

    
2328
hyperTypes :: FrozenSet String
2329
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2330

    
2331
htsReqPort :: FrozenSet String
2332
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2333

    
2334
vncBasePort :: Int
2335
vncBasePort = 5900
2336

    
2337
vncDefaultBindAddress :: String
2338
vncDefaultBindAddress = ip4AddressAny
2339

    
2340
-- * NIC types
2341

    
2342
htNicE1000 :: String
2343
htNicE1000 = "e1000"
2344

    
2345
htNicI82551 :: String
2346
htNicI82551 = "i82551"
2347

    
2348
htNicI8259er :: String
2349
htNicI8259er = "i82559er"
2350

    
2351
htNicI85557b :: String
2352
htNicI85557b = "i82557b"
2353

    
2354
htNicNe2kIsa :: String
2355
htNicNe2kIsa = "ne2k_isa"
2356

    
2357
htNicNe2kPci :: String
2358
htNicNe2kPci = "ne2k_pci"
2359

    
2360
htNicParavirtual :: String
2361
htNicParavirtual = "paravirtual"
2362

    
2363
htNicPcnet :: String
2364
htNicPcnet = "pcnet"
2365

    
2366
htNicRtl8139 :: String
2367
htNicRtl8139 = "rtl8139"
2368

    
2369
htHvmValidNicTypes :: FrozenSet String
2370
htHvmValidNicTypes =
2371
  ConstantUtils.mkSet [htNicE1000,
2372
                       htNicNe2kIsa,
2373
                       htNicNe2kPci,
2374
                       htNicParavirtual,
2375
                       htNicRtl8139]
2376

    
2377
htKvmValidNicTypes :: FrozenSet String
2378
htKvmValidNicTypes =
2379
  ConstantUtils.mkSet [htNicE1000,
2380
                       htNicI82551,
2381
                       htNicI8259er,
2382
                       htNicI85557b,
2383
                       htNicNe2kIsa,
2384
                       htNicNe2kPci,
2385
                       htNicParavirtual,
2386
                       htNicPcnet,
2387
                       htNicRtl8139]
2388

    
2389
-- * Vif types
2390

    
2391
-- | Default vif type in xen-hvm
2392
htHvmVifIoemu :: String
2393
htHvmVifIoemu = "ioemu"
2394

    
2395
htHvmVifVif :: String
2396
htHvmVifVif = "vif"
2397

    
2398
htHvmValidVifTypes :: FrozenSet String
2399
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2400

    
2401
-- * Disk types
2402

    
2403
htDiskIde :: String
2404
htDiskIde = "ide"
2405

    
2406
htDiskIoemu :: String
2407
htDiskIoemu = "ioemu"
2408

    
2409
htDiskMtd :: String
2410
htDiskMtd = "mtd"
2411

    
2412
htDiskParavirtual :: String
2413
htDiskParavirtual = "paravirtual"
2414

    
2415
htDiskPflash :: String
2416
htDiskPflash = "pflash"
2417

    
2418
htDiskScsi :: String
2419
htDiskScsi = "scsi"
2420

    
2421
htDiskSd :: String
2422
htDiskSd = "sd"
2423

    
2424
htHvmValidDiskTypes :: FrozenSet String
2425
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2426

    
2427
htKvmValidDiskTypes :: FrozenSet String
2428
htKvmValidDiskTypes =
2429
  ConstantUtils.mkSet [htDiskIde,
2430
                       htDiskMtd,
2431
                       htDiskParavirtual,
2432
                       htDiskPflash,
2433
                       htDiskScsi,
2434
                       htDiskSd]
2435

    
2436
htCacheDefault :: String
2437
htCacheDefault = "default"
2438

    
2439
htCacheNone :: String
2440
htCacheNone = "none"
2441

    
2442
htCacheWback :: String
2443
htCacheWback = "writeback"
2444

    
2445
htCacheWthrough :: String
2446
htCacheWthrough = "writethrough"
2447

    
2448
htValidCacheTypes :: FrozenSet String
2449
htValidCacheTypes =
2450
  ConstantUtils.mkSet [htCacheDefault,
2451
                       htCacheNone,
2452
                       htCacheWback,
2453
                       htCacheWthrough]
2454

    
2455
-- * Mouse types
2456

    
2457
htMouseMouse :: String
2458
htMouseMouse = "mouse"
2459

    
2460
htMouseTablet :: String
2461
htMouseTablet = "tablet"
2462

    
2463
htKvmValidMouseTypes :: FrozenSet String
2464
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2465

    
2466
-- * Boot order
2467

    
2468
htBoCdrom :: String
2469
htBoCdrom = "cdrom"
2470

    
2471
htBoDisk :: String
2472
htBoDisk = "disk"
2473

    
2474
htBoFloppy :: String
2475
htBoFloppy = "floppy"
2476

    
2477
htBoNetwork :: String
2478
htBoNetwork = "network"
2479

    
2480
htKvmValidBoTypes :: FrozenSet String
2481
htKvmValidBoTypes =
2482
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2483

    
2484
-- * SPICE lossless image compression options
2485

    
2486
htKvmSpiceLosslessImgComprAutoGlz :: String
2487
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2488

    
2489
htKvmSpiceLosslessImgComprAutoLz :: String
2490
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2491

    
2492
htKvmSpiceLosslessImgComprGlz :: String
2493
htKvmSpiceLosslessImgComprGlz = "glz"
2494

    
2495
htKvmSpiceLosslessImgComprLz :: String
2496
htKvmSpiceLosslessImgComprLz = "lz"
2497

    
2498
htKvmSpiceLosslessImgComprOff :: String
2499
htKvmSpiceLosslessImgComprOff = "off"
2500

    
2501
htKvmSpiceLosslessImgComprQuic :: String
2502
htKvmSpiceLosslessImgComprQuic = "quic"
2503

    
2504
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2505
htKvmSpiceValidLosslessImgComprOptions =
2506
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2507
                       htKvmSpiceLosslessImgComprAutoLz,
2508
                       htKvmSpiceLosslessImgComprGlz,
2509
                       htKvmSpiceLosslessImgComprLz,
2510
                       htKvmSpiceLosslessImgComprOff,
2511
                       htKvmSpiceLosslessImgComprQuic]
2512

    
2513
htKvmSpiceLossyImgComprAlways :: String
2514
htKvmSpiceLossyImgComprAlways = "always"
2515

    
2516
htKvmSpiceLossyImgComprAuto :: String
2517
htKvmSpiceLossyImgComprAuto = "auto"
2518

    
2519
htKvmSpiceLossyImgComprNever :: String
2520
htKvmSpiceLossyImgComprNever = "never"
2521

    
2522
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2523
htKvmSpiceValidLossyImgComprOptions =
2524
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2525
                       htKvmSpiceLossyImgComprAuto,
2526
                       htKvmSpiceLossyImgComprNever]
2527

    
2528
-- * SPICE video stream detection
2529

    
2530
htKvmSpiceVideoStreamDetectionAll :: String
2531
htKvmSpiceVideoStreamDetectionAll = "all"
2532

    
2533
htKvmSpiceVideoStreamDetectionFilter :: String
2534
htKvmSpiceVideoStreamDetectionFilter = "filter"
2535

    
2536
htKvmSpiceVideoStreamDetectionOff :: String
2537
htKvmSpiceVideoStreamDetectionOff = "off"
2538

    
2539
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2540
htKvmSpiceValidVideoStreamDetectionOptions =
2541
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2542
                       htKvmSpiceVideoStreamDetectionFilter,
2543
                       htKvmSpiceVideoStreamDetectionOff]
2544

    
2545
-- * Security models
2546

    
2547
htSmNone :: String
2548
htSmNone = "none"
2549

    
2550
htSmPool :: String
2551
htSmPool = "pool"
2552

    
2553
htSmUser :: String
2554
htSmUser = "user"
2555

    
2556
htKvmValidSmTypes :: FrozenSet String
2557
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2558

    
2559
-- * Kvm flag values
2560

    
2561
htKvmDisabled :: String
2562
htKvmDisabled = "disabled"
2563

    
2564
htKvmEnabled :: String
2565
htKvmEnabled = "enabled"
2566

    
2567
htKvmFlagValues :: FrozenSet String
2568
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2569

    
2570
-- * Migration type
2571

    
2572
htMigrationLive :: String
2573
htMigrationLive = Types.migrationModeToRaw MigrationLive
2574

    
2575
htMigrationNonlive :: String
2576
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2577

    
2578
htMigrationModes :: FrozenSet String
2579
htMigrationModes =
2580
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2581

    
2582
-- * Cluster verify steps
2583

    
2584
verifyNplusoneMem :: String
2585
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2586

    
2587
verifyOptionalChecks :: FrozenSet String
2588
verifyOptionalChecks =
2589
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2590

    
2591
-- * Cluster Verify error classes
2592

    
2593
cvTcluster :: String
2594
cvTcluster = "cluster"
2595

    
2596
cvTgroup :: String
2597
cvTgroup = "group"
2598

    
2599
cvTnode :: String
2600
cvTnode = "node"
2601

    
2602
cvTinstance :: String
2603
cvTinstance = "instance"
2604

    
2605
-- * Cluster Verify error codes and documentation
2606

    
2607
cvEclustercert :: (String, String, String)
2608
cvEclustercert =
2609
  ("cluster",
2610
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2611
   "Cluster certificate files verification failure")
2612

    
2613
cvEclustercfg :: (String, String, String)
2614
cvEclustercfg =
2615
  ("cluster",
2616
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2617
   "Cluster configuration verification failure")
2618

    
2619
cvEclusterdanglinginst :: (String, String, String)
2620
cvEclusterdanglinginst =
2621
  ("node",
2622
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2623
   "Some instances have a non-existing primary node")
2624

    
2625
cvEclusterdanglingnodes :: (String, String, String)
2626
cvEclusterdanglingnodes =
2627
  ("node",
2628
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2629
   "Some nodes belong to non-existing groups")
2630

    
2631
cvEclusterfilecheck :: (String, String, String)
2632
cvEclusterfilecheck =
2633
  ("cluster",
2634
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2635
   "Cluster configuration verification failure")
2636

    
2637
cvEgroupdifferentpvsize :: (String, String, String)
2638
cvEgroupdifferentpvsize =
2639
  ("group",
2640
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2641
   "PVs in the group have different sizes")
2642

    
2643
cvEinstancebadnode :: (String, String, String)
2644
cvEinstancebadnode =
2645
  ("instance",
2646
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2647
   "Instance marked as running lives on an offline node")
2648

    
2649
cvEinstancedown :: (String, String, String)
2650
cvEinstancedown =
2651
  ("instance",
2652
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2653
   "Instance not running on its primary node")
2654

    
2655
cvEinstancefaultydisk :: (String, String, String)
2656
cvEinstancefaultydisk =
2657
  ("instance",
2658
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2659
   "Impossible to retrieve status for a disk")
2660

    
2661
cvEinstancelayout :: (String, String, String)
2662
cvEinstancelayout =
2663
  ("instance",
2664
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2665
   "Instance has multiple secondary nodes")
2666

    
2667
cvEinstancemissingcfgparameter :: (String, String, String)
2668
cvEinstancemissingcfgparameter =
2669
  ("instance",
2670
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2671
   "A configuration parameter for an instance is missing")
2672

    
2673
cvEinstancemissingdisk :: (String, String, String)
2674
cvEinstancemissingdisk =
2675
  ("instance",
2676
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2677
   "Missing volume on an instance")
2678

    
2679
cvEinstancepolicy :: (String, String, String)
2680
cvEinstancepolicy =
2681
  ("instance",
2682
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2683
   "Instance does not meet policy")
2684

    
2685
cvEinstancesplitgroups :: (String, String, String)
2686
cvEinstancesplitgroups =
2687
  ("instance",
2688
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2689
   "Instance with primary and secondary nodes in different groups")
2690

    
2691
cvEinstanceunsuitablenode :: (String, String, String)
2692
cvEinstanceunsuitablenode =
2693
  ("instance",
2694
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2695
   "Instance running on nodes that are not suitable for it")
2696

    
2697
cvEinstancewrongnode :: (String, String, String)
2698
cvEinstancewrongnode =
2699
  ("instance",
2700
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2701
   "Instance running on the wrong node")
2702

    
2703
cvEnodedrbd :: (String, String, String)
2704
cvEnodedrbd =
2705
  ("node",
2706
   Types.cVErrorCodeToRaw CvENODEDRBD,
2707
   "Error parsing the DRBD status file")
2708

    
2709
cvEnodedrbdhelper :: (String, String, String)
2710
cvEnodedrbdhelper =
2711
  ("node",
2712
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2713
   "Error caused by the DRBD helper")
2714

    
2715
cvEnodedrbdversion :: (String, String, String)
2716
cvEnodedrbdversion =
2717
  ("node",
2718
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2719
   "DRBD version mismatch within a node group")
2720

    
2721
cvEnodefilecheck :: (String, String, String)
2722
cvEnodefilecheck =
2723
  ("node",
2724
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2725
   "Error retrieving the checksum of the node files")
2726

    
2727
cvEnodefilestoragepaths :: (String, String, String)
2728
cvEnodefilestoragepaths =
2729
  ("node",
2730
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2731
   "Detected bad file storage paths")
2732

    
2733
cvEnodefilestoragepathunusable :: (String, String, String)
2734
cvEnodefilestoragepathunusable =
2735
  ("node",
2736
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2737
   "File storage path unusable")
2738

    
2739
cvEnodehooks :: (String, String, String)
2740
cvEnodehooks =
2741
  ("node",
2742
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2743
   "Communication failure in hooks execution")
2744

    
2745
cvEnodehv :: (String, String, String)
2746
cvEnodehv =
2747
  ("node",
2748
   Types.cVErrorCodeToRaw CvENODEHV,
2749
   "Hypervisor parameters verification failure")
2750

    
2751
cvEnodelvm :: (String, String, String)
2752
cvEnodelvm =
2753
  ("node",
2754
   Types.cVErrorCodeToRaw CvENODELVM,
2755
   "LVM-related node error")
2756

    
2757
cvEnoden1 :: (String, String, String)
2758
cvEnoden1 =
2759
  ("node",
2760
   Types.cVErrorCodeToRaw CvENODEN1,
2761
   "Not enough memory to accommodate instance failovers")
2762

    
2763
cvEnodenet :: (String, String, String)
2764
cvEnodenet =
2765
  ("node",
2766
   Types.cVErrorCodeToRaw CvENODENET,
2767
   "Network-related node error")
2768

    
2769
cvEnodeoobpath :: (String, String, String)
2770
cvEnodeoobpath =
2771
  ("node",
2772
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2773
   "Invalid Out Of Band path")
2774

    
2775
cvEnodeorphaninstance :: (String, String, String)
2776
cvEnodeorphaninstance =
2777
  ("node",
2778
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2779
   "Unknown intance running on a node")
2780

    
2781
cvEnodeorphanlv :: (String, String, String)
2782
cvEnodeorphanlv =
2783
  ("node",
2784
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2785
   "Unknown LVM logical volume")
2786

    
2787
cvEnodeos :: (String, String, String)
2788
cvEnodeos =
2789
  ("node",
2790
   Types.cVErrorCodeToRaw CvENODEOS,
2791
   "OS-related node error")
2792

    
2793
cvEnoderpc :: (String, String, String)
2794
cvEnoderpc =
2795
  ("node",
2796
   Types.cVErrorCodeToRaw CvENODERPC,
2797
   "Error during connection to the primary node of an instance")
2798

    
2799
cvEnodesetup :: (String, String, String)
2800
cvEnodesetup =
2801
  ("node",
2802
   Types.cVErrorCodeToRaw CvENODESETUP,
2803
   "Node setup error")
2804

    
2805
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2806
cvEnodesharedfilestoragepathunusable =
2807
  ("node",
2808
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2809
   "Shared file storage path unusable")
2810

    
2811
cvEnodessh :: (String, String, String)
2812
cvEnodessh =
2813
  ("node",
2814
   Types.cVErrorCodeToRaw CvENODESSH,
2815
   "SSH-related node error")
2816

    
2817
cvEnodetime :: (String, String, String)
2818
cvEnodetime =
2819
  ("node",
2820
   Types.cVErrorCodeToRaw CvENODETIME,
2821
   "Node returned invalid time")
2822

    
2823
cvEnodeuserscripts :: (String, String, String)
2824
cvEnodeuserscripts =
2825
  ("node",
2826
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2827
   "User scripts not present or not executable")
2828

    
2829
cvEnodeversion :: (String, String, String)
2830
cvEnodeversion =
2831
  ("node",
2832
   Types.cVErrorCodeToRaw CvENODEVERSION,
2833
   "Protocol version mismatch or Ganeti version mismatch")
2834

    
2835
cvAllEcodes :: FrozenSet (String, String, String)
2836
cvAllEcodes =
2837
  ConstantUtils.mkSet
2838
  [cvEclustercert,
2839
   cvEclustercfg,
2840
   cvEclusterdanglinginst,
2841
   cvEclusterdanglingnodes,
2842
   cvEclusterfilecheck,
2843
   cvEgroupdifferentpvsize,
2844
   cvEinstancebadnode,
2845
   cvEinstancedown,
2846
   cvEinstancefaultydisk,
2847
   cvEinstancelayout,
2848
   cvEinstancemissingcfgparameter,
2849
   cvEinstancemissingdisk,
2850
   cvEinstancepolicy,
2851
   cvEinstancesplitgroups,
2852
   cvEinstanceunsuitablenode,
2853
   cvEinstancewrongnode,
2854
   cvEnodedrbd,
2855
   cvEnodedrbdhelper,
2856
   cvEnodedrbdversion,
2857
   cvEnodefilecheck,
2858
   cvEnodefilestoragepaths,
2859
   cvEnodefilestoragepathunusable,
2860
   cvEnodehooks,
2861
   cvEnodehv,
2862
   cvEnodelvm,
2863
   cvEnoden1,
2864
   cvEnodenet,
2865
   cvEnodeoobpath,
2866
   cvEnodeorphaninstance,
2867
   cvEnodeorphanlv,
2868
   cvEnodeos,
2869
   cvEnoderpc,
2870
   cvEnodesetup,
2871
   cvEnodesharedfilestoragepathunusable,
2872
   cvEnodessh,
2873
   cvEnodetime,
2874
   cvEnodeuserscripts,
2875
   cvEnodeversion]
2876

    
2877
cvAllEcodesStrings :: FrozenSet String
2878
cvAllEcodesStrings =
2879
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2880

    
2881
-- * Node verify constants
2882

    
2883
nvBridges :: String
2884
nvBridges = "bridges"
2885

    
2886
nvDrbdhelper :: String
2887
nvDrbdhelper = "drbd-helper"
2888

    
2889
nvDrbdversion :: String
2890
nvDrbdversion = "drbd-version"
2891

    
2892
nvDrbdlist :: String
2893
nvDrbdlist = "drbd-list"
2894

    
2895
nvExclusivepvs :: String
2896
nvExclusivepvs = "exclusive-pvs"
2897

    
2898
nvFilelist :: String
2899
nvFilelist = "filelist"
2900

    
2901
nvAcceptedStoragePaths :: String
2902
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2903

    
2904
nvFileStoragePath :: String
2905
nvFileStoragePath = "file-storage-path"
2906

    
2907
nvSharedFileStoragePath :: String
2908
nvSharedFileStoragePath = "shared-file-storage-path"
2909

    
2910
nvHvinfo :: String
2911
nvHvinfo = "hvinfo"
2912

    
2913
nvHvparams :: String
2914
nvHvparams = "hvparms"
2915

    
2916
nvHypervisor :: String
2917
nvHypervisor = "hypervisor"
2918

    
2919
nvInstancelist :: String
2920
nvInstancelist = "instancelist"
2921

    
2922
nvLvlist :: String
2923
nvLvlist = "lvlist"
2924

    
2925
nvMasterip :: String
2926
nvMasterip = "master-ip"
2927

    
2928
nvNodelist :: String
2929
nvNodelist = "nodelist"
2930

    
2931
nvNodenettest :: String
2932
nvNodenettest = "node-net-test"
2933

    
2934
nvNodesetup :: String
2935
nvNodesetup = "nodesetup"
2936

    
2937
nvOobPaths :: String
2938
nvOobPaths = "oob-paths"
2939

    
2940
nvOslist :: String
2941
nvOslist = "oslist"
2942

    
2943
nvPvlist :: String
2944
nvPvlist = "pvlist"
2945

    
2946
nvTime :: String
2947
nvTime = "time"
2948

    
2949
nvUserscripts :: String
2950
nvUserscripts = "user-scripts"
2951

    
2952
nvVersion :: String
2953
nvVersion = "version"
2954

    
2955
nvVglist :: String
2956
nvVglist = "vglist"
2957

    
2958
nvVmnodes :: String
2959
nvVmnodes = "vmnodes"
2960

    
2961
-- * Instance status
2962

    
2963
inststAdmindown :: String
2964
inststAdmindown = Types.instanceStatusToRaw StatusDown
2965

    
2966
inststAdminoffline :: String
2967
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
2968

    
2969
inststErrordown :: String
2970
inststErrordown = Types.instanceStatusToRaw ErrorDown
2971

    
2972
inststErrorup :: String
2973
inststErrorup = Types.instanceStatusToRaw ErrorUp
2974

    
2975
inststNodedown :: String
2976
inststNodedown = Types.instanceStatusToRaw NodeDown
2977

    
2978
inststNodeoffline :: String
2979
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
2980

    
2981
inststRunning :: String
2982
inststRunning = Types.instanceStatusToRaw Running
2983

    
2984
inststWrongnode :: String
2985
inststWrongnode = Types.instanceStatusToRaw WrongNode
2986

    
2987
inststAll :: FrozenSet String
2988
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
2989

    
2990
-- * Admin states
2991

    
2992
adminstDown :: String
2993
adminstDown = Types.adminStateToRaw AdminDown
2994

    
2995
adminstOffline :: String
2996
adminstOffline = Types.adminStateToRaw AdminOffline
2997

    
2998
adminstUp :: String
2999
adminstUp = Types.adminStateToRaw AdminUp
3000

    
3001
adminstAll :: FrozenSet String
3002
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3003

    
3004
-- * Node roles
3005

    
3006
nrDrained :: String
3007
nrDrained = Types.nodeRoleToRaw NRDrained
3008

    
3009
nrMaster :: String
3010
nrMaster = Types.nodeRoleToRaw NRMaster
3011

    
3012
nrMcandidate :: String
3013
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3014

    
3015
nrOffline :: String
3016
nrOffline = Types.nodeRoleToRaw NROffline
3017

    
3018
nrRegular :: String
3019
nrRegular = Types.nodeRoleToRaw NRRegular
3020

    
3021
nrAll :: FrozenSet String
3022
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3023

    
3024
-- * SSL certificate check constants (in days)
3025

    
3026
sslCertExpirationError :: Int
3027
sslCertExpirationError = 7
3028

    
3029
sslCertExpirationWarn :: Int
3030
sslCertExpirationWarn = 30
3031

    
3032
-- * Allocator framework constants
3033

    
3034
iallocatorVersion :: Int
3035
iallocatorVersion = 2
3036

    
3037
iallocatorDirIn :: String
3038
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3039

    
3040
iallocatorDirOut :: String
3041
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3042

    
3043
validIallocatorDirections :: FrozenSet String
3044
validIallocatorDirections =
3045
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3046

    
3047
iallocatorModeAlloc :: String
3048
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3049

    
3050
iallocatorModeChgGroup :: String
3051
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3052

    
3053
iallocatorModeMultiAlloc :: String
3054
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3055

    
3056
iallocatorModeNodeEvac :: String
3057
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3058

    
3059
iallocatorModeReloc :: String
3060
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3061

    
3062
validIallocatorModes :: FrozenSet String
3063
validIallocatorModes =
3064
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3065

    
3066
iallocatorSearchPath :: [String]
3067
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3068

    
3069
defaultIallocatorShortcut :: String
3070
defaultIallocatorShortcut = "."
3071

    
3072
-- * Node evacuation
3073

    
3074
nodeEvacPri :: String
3075
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3076

    
3077
nodeEvacSec :: String
3078
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3079

    
3080
nodeEvacAll :: String
3081
nodeEvacAll = Types.evacModeToRaw ChangeAll
3082

    
3083
nodeEvacModes :: FrozenSet String
3084
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3085

    
3086
-- * Job queue
3087

    
3088
jobQueueVersion :: Int
3089
jobQueueVersion = 1
3090

    
3091
jobQueueSizeHardLimit :: Int
3092
jobQueueSizeHardLimit = 5000
3093

    
3094
jobQueueFilesPerms :: Int
3095
jobQueueFilesPerms = 0o640
3096

    
3097
-- * Unchanged job return
3098

    
3099
jobNotchanged :: String
3100
jobNotchanged = "nochange"
3101

    
3102
-- * Job status
3103

    
3104
jobStatusQueued :: String
3105
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3106

    
3107
jobStatusWaiting :: String
3108
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3109

    
3110
jobStatusCanceling :: String
3111
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3112

    
3113
jobStatusRunning :: String
3114
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3115

    
3116
jobStatusCanceled :: String
3117
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3118

    
3119
jobStatusSuccess :: String
3120
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3121

    
3122
jobStatusError :: String
3123
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3124

    
3125
jobsPending :: FrozenSet String
3126
jobsPending =
3127
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3128

    
3129
jobsFinalized :: FrozenSet String
3130
jobsFinalized =
3131
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3132

    
3133
jobStatusAll :: FrozenSet String
3134
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3135

    
3136
-- * OpCode status
3137

    
3138
-- ** Not yet finalized opcodes
3139

    
3140
opStatusCanceling :: String
3141
opStatusCanceling = "canceling"
3142

    
3143
opStatusQueued :: String
3144
opStatusQueued = "queued"
3145

    
3146
opStatusRunning :: String
3147
opStatusRunning = "running"
3148

    
3149
opStatusWaiting :: String
3150
opStatusWaiting = "waiting"
3151

    
3152
-- ** Finalized opcodes
3153

    
3154
opStatusCanceled :: String
3155
opStatusCanceled = "canceled"
3156

    
3157
opStatusError :: String
3158
opStatusError = "error"
3159

    
3160
opStatusSuccess :: String
3161
opStatusSuccess = "success"
3162

    
3163
opsFinalized :: FrozenSet String
3164
opsFinalized =
3165
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3166

    
3167
-- * OpCode priority
3168

    
3169
opPrioLowest :: Int
3170
opPrioLowest = 19
3171

    
3172
opPrioHighest :: Int
3173
opPrioHighest = -20
3174

    
3175
opPrioLow :: Int
3176
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3177

    
3178
opPrioNormal :: Int
3179
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3180

    
3181
opPrioHigh :: Int
3182
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3183

    
3184
opPrioSubmitValid :: FrozenSet Int
3185
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3186

    
3187
opPrioDefault :: Int
3188
opPrioDefault = opPrioNormal
3189

    
3190
-- * Lock recalculate mode
3191

    
3192
locksAppend :: String
3193
locksAppend = "append"
3194

    
3195
locksReplace :: String
3196
locksReplace = "replace"
3197

    
3198
-- * Lock timeout
3199
--
3200
-- The lock timeout (sum) before we transition into blocking acquire
3201
-- (this can still be reset by priority change).  Computed as max time
3202
-- (10 hours) before we should actually go into blocking acquire,
3203
-- given that we start from the default priority level.
3204

    
3205
lockAttemptsMaxwait :: Double
3206
lockAttemptsMaxwait = 15.0
3207

    
3208
lockAttemptsMinwait :: Double
3209
lockAttemptsMinwait = 1.0
3210

    
3211
lockAttemptsTimeout :: Int
3212
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3213

    
3214
-- * Execution log types
3215

    
3216
elogMessage :: String
3217
elogMessage = Types.eLogTypeToRaw ELogMessage
3218

    
3219
elogRemoteImport :: String
3220
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3221

    
3222
elogJqueueTest :: String
3223
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3224

    
3225
-- * /etc/hosts modification
3226

    
3227
etcHostsAdd :: String
3228
etcHostsAdd = "add"
3229

    
3230
etcHostsRemove :: String
3231
etcHostsRemove = "remove"
3232

    
3233
-- * Job queue test
3234

    
3235
jqtMsgprefix :: String
3236
jqtMsgprefix = "TESTMSG="
3237

    
3238
jqtExec :: String
3239
jqtExec = "exec"
3240

    
3241
jqtExpandnames :: String
3242
jqtExpandnames = "expandnames"
3243

    
3244
jqtLogmsg :: String
3245
jqtLogmsg = "logmsg"
3246

    
3247
jqtStartmsg :: String
3248
jqtStartmsg = "startmsg"
3249

    
3250
jqtAll :: FrozenSet String
3251
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3252

    
3253
-- * Query resources
3254

    
3255
qrCluster :: String
3256
qrCluster = "cluster"
3257

    
3258
qrExport :: String
3259
qrExport = "export"
3260

    
3261
qrExtstorage :: String
3262
qrExtstorage = "extstorage"
3263

    
3264
qrGroup :: String
3265
qrGroup = "group"
3266

    
3267
qrInstance :: String
3268
qrInstance = "instance"
3269

    
3270
qrJob :: String
3271
qrJob = "job"
3272

    
3273
qrLock :: String
3274
qrLock = "lock"
3275

    
3276
qrNetwork :: String
3277
qrNetwork = "network"
3278

    
3279
qrNode :: String
3280
qrNode = "node"
3281

    
3282
qrOs :: String
3283
qrOs = "os"
3284

    
3285
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3286
qrViaOp :: FrozenSet String
3287
qrViaOp =
3288
  ConstantUtils.mkSet [qrCluster,
3289
                       qrInstance,
3290
                       qrNode,
3291
                       qrGroup,
3292
                       qrOs,
3293
                       qrExport,
3294
                       qrNetwork,
3295
                       qrExtstorage]
3296

    
3297
-- | List of resources which can be queried using Local UniX Interface
3298
qrViaLuxi :: FrozenSet String
3299
qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob]
3300

    
3301
-- | List of resources which can be queried using RAPI
3302
qrViaRapi :: FrozenSet String
3303
qrViaRapi = qrViaLuxi
3304

    
3305
-- * Query field types
3306

    
3307
qftBool :: String
3308
qftBool = "bool"
3309

    
3310
qftNumber :: String
3311
qftNumber = "number"
3312

    
3313
qftOther :: String
3314
qftOther = "other"
3315

    
3316
qftText :: String
3317
qftText = "text"
3318

    
3319
qftTimestamp :: String
3320
qftTimestamp = "timestamp"
3321

    
3322
qftUnit :: String
3323
qftUnit = "unit"
3324

    
3325
qftUnknown :: String
3326
qftUnknown = "unknown"
3327

    
3328
qftAll :: FrozenSet String
3329
qftAll =
3330
  ConstantUtils.mkSet [qftBool,
3331
                       qftNumber,
3332
                       qftOther,
3333
                       qftText,
3334
                       qftTimestamp,
3335
                       qftUnit,
3336
                       qftUnknown]
3337

    
3338
-- * Query result field status
3339
--
3340
-- Don't change or reuse values as they're used by clients.
3341
--
3342
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3343

    
3344
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3345
rsNodata :: Int
3346
rsNodata = 2
3347

    
3348
rsNormal :: Int
3349
rsNormal = 0
3350

    
3351
-- | Resource marked offline
3352
rsOffline :: Int
3353
rsOffline = 4
3354

    
3355
-- | Value unavailable/unsupported for item; if this field is
3356
-- supported but we cannot get the data for the moment, 'rsNodata' or
3357
-- 'rsOffline' should be used
3358
rsUnavail :: Int
3359
rsUnavail = 3
3360

    
3361
rsUnknown :: Int
3362
rsUnknown = 1
3363

    
3364
rsAll :: FrozenSet Int
3365
rsAll =
3366
  ConstantUtils.mkSet [rsNodata,
3367
                       rsNormal,
3368
                       rsOffline,
3369
                       rsUnavail,
3370
                       rsUnknown]
3371

    
3372
-- | Special field cases and their verbose/terse formatting
3373
rssDescription :: Map Int (String, String)
3374
rssDescription =
3375
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3376
                (rsNodata, ("(nodata)", "?")),
3377
                (rsOffline, ("(offline)", "*")),
3378
                (rsUnavail, ("(unavail)", "-"))]
3379

    
3380
-- * Max dynamic devices
3381

    
3382
maxDisks :: Int
3383
maxDisks = Types.maxDisks
3384

    
3385
maxNics :: Int
3386
maxNics = Types.maxNics
3387

    
3388
-- | SSCONF file prefix
3389
ssconfFileprefix :: String
3390
ssconfFileprefix = "ssconf_"
3391

    
3392
-- * SSCONF keys
3393

    
3394
ssClusterName :: String
3395
ssClusterName = "cluster_name"
3396

    
3397
ssClusterTags :: String
3398
ssClusterTags = "cluster_tags"
3399

    
3400
ssFileStorageDir :: String
3401
ssFileStorageDir = "file_storage_dir"
3402

    
3403
ssSharedFileStorageDir :: String
3404
ssSharedFileStorageDir = "shared_file_storage_dir"
3405

    
3406
ssMasterCandidates :: String
3407
ssMasterCandidates = "master_candidates"
3408

    
3409
ssMasterCandidatesIps :: String
3410
ssMasterCandidatesIps = "master_candidates_ips"
3411

    
3412
ssMasterIp :: String
3413
ssMasterIp = "master_ip"
3414

    
3415
ssMasterNetdev :: String
3416
ssMasterNetdev = "master_netdev"
3417

    
3418
ssMasterNetmask :: String
3419
ssMasterNetmask = "master_netmask"
3420

    
3421
ssMasterNode :: String
3422
ssMasterNode = "master_node"
3423

    
3424
ssNodeList :: String
3425
ssNodeList = "node_list"
3426

    
3427
ssNodePrimaryIps :: String
3428
ssNodePrimaryIps = "node_primary_ips"
3429

    
3430
ssNodeSecondaryIps :: String
3431
ssNodeSecondaryIps = "node_secondary_ips"
3432

    
3433
ssOfflineNodes :: String
3434
ssOfflineNodes = "offline_nodes"
3435

    
3436
ssOnlineNodes :: String
3437
ssOnlineNodes = "online_nodes"
3438

    
3439
ssPrimaryIpFamily :: String
3440
ssPrimaryIpFamily = "primary_ip_family"
3441

    
3442
ssInstanceList :: String
3443
ssInstanceList = "instance_list"
3444

    
3445
ssReleaseVersion :: String
3446
ssReleaseVersion = "release_version"
3447

    
3448
ssHypervisorList :: String
3449
ssHypervisorList = "hypervisor_list"
3450

    
3451
ssMaintainNodeHealth :: String
3452
ssMaintainNodeHealth = "maintain_node_health"
3453

    
3454
ssUidPool :: String
3455
ssUidPool = "uid_pool"
3456

    
3457
ssNodegroups :: String
3458
ssNodegroups = "nodegroups"
3459

    
3460
ssNetworks :: String
3461
ssNetworks = "networks"
3462

    
3463
-- | This is not a complete SSCONF key, but the prefix for the
3464
-- hypervisor keys
3465
ssHvparamsPref :: String
3466
ssHvparamsPref = "hvparams_"
3467

    
3468
-- * Hvparams keys
3469

    
3470
ssHvparamsXenChroot :: String
3471
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3472

    
3473
ssHvparamsXenFake :: String
3474
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3475

    
3476
ssHvparamsXenHvm :: String
3477
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3478

    
3479
ssHvparamsXenKvm :: String
3480
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3481

    
3482
ssHvparamsXenLxc :: String
3483
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3484

    
3485
ssHvparamsXenPvm :: String
3486
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3487

    
3488
validSsHvparamsKeys :: FrozenSet String
3489
validSsHvparamsKeys =
3490
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3491
                       ssHvparamsXenLxc,
3492
                       ssHvparamsXenFake,
3493
                       ssHvparamsXenHvm,
3494
                       ssHvparamsXenKvm,
3495
                       ssHvparamsXenPvm]
3496

    
3497
ssFilePerms :: Int
3498
ssFilePerms = 0o444
3499

    
3500
-- | Cluster wide default parameters
3501
defaultEnabledHypervisor :: String
3502
defaultEnabledHypervisor = htXenPvm
3503

    
3504
hvcGlobals :: FrozenSet String
3505
hvcGlobals =
3506
  ConstantUtils.mkSet [hvMigrationBandwidth,
3507
                       hvMigrationMode,
3508
                       hvMigrationPort,
3509
                       hvXenCmd]
3510

    
3511
ndcGlobals :: FrozenSet String
3512
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3513

    
3514
-- | All of the following values are quite arbitrary - there are no
3515
-- "good" defaults, these must be customised per-site
3516
ispecsMinmaxDefaults :: Map String (Map String Int)
3517
ispecsMinmaxDefaults =
3518
  Map.fromList
3519
  [(ispecsMin,
3520
    Map.fromList
3521
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3522
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3523
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3524
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3525
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3526
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3527
   (ispecsMax,
3528
    Map.fromList
3529
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3530
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3531
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3532
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3533
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3534
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3535

    
3536
masterPoolSizeDefault :: Int
3537
masterPoolSizeDefault = 10
3538

    
3539
-- * Exclusive storage
3540

    
3541
-- | Error margin used to compare physical disks
3542
partMargin :: Double
3543
partMargin = 0.01
3544

    
3545
-- | Space reserved when creating instance disks
3546
partReserved :: Double
3547
partReserved = 0.02
3548

    
3549
-- * Confd
3550

    
3551
confdProtocolVersion :: Int
3552
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3553

    
3554
-- Confd request type
3555

    
3556
confdReqPing :: Int
3557
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3558

    
3559
confdReqNodeRoleByname :: Int
3560
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3561

    
3562
confdReqNodePipByInstanceIp :: Int
3563
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3564

    
3565
confdReqClusterMaster :: Int
3566
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3567

    
3568
confdReqNodePipList :: Int
3569
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3570

    
3571
confdReqMcPipList :: Int
3572
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3573

    
3574
confdReqInstancesIpsList :: Int
3575
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3576

    
3577
confdReqNodeDrbd :: Int
3578
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3579

    
3580
confdReqNodeInstances :: Int
3581
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3582

    
3583
confdReqs :: FrozenSet Int
3584
confdReqs =
3585
  ConstantUtils.mkSet .
3586
  map Types.confdRequestTypeToRaw $
3587
  [minBound..] \\ [ReqNodeInstances]
3588

    
3589
-- * Confd request type
3590

    
3591
confdReqfieldName :: Int
3592
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3593

    
3594
confdReqfieldIp :: Int
3595
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3596

    
3597
confdReqfieldMnodePip :: Int
3598
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3599

    
3600
-- * Confd repl status
3601

    
3602
confdReplStatusOk :: Int
3603
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3604

    
3605
confdReplStatusError :: Int
3606
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3607

    
3608
confdReplStatusNotimplemented :: Int
3609
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3610

    
3611
confdReplStatuses :: FrozenSet Int
3612
confdReplStatuses =
3613
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3614

    
3615
-- * Confd node role
3616

    
3617
confdNodeRoleMaster :: Int
3618
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3619

    
3620
confdNodeRoleCandidate :: Int
3621
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3622

    
3623
confdNodeRoleOffline :: Int
3624
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3625

    
3626
confdNodeRoleDrained :: Int
3627
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3628

    
3629
confdNodeRoleRegular :: Int
3630
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3631

    
3632
-- * A few common errors for confd
3633

    
3634
confdErrorUnknownEntry :: Int
3635
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3636

    
3637
confdErrorInternal :: Int
3638
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3639

    
3640
confdErrorArgument :: Int
3641
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3642

    
3643
-- * Confd request query fields
3644

    
3645
confdReqqLink :: String
3646
confdReqqLink = ConstantUtils.confdReqqLink
3647

    
3648
confdReqqIp :: String
3649
confdReqqIp = ConstantUtils.confdReqqIp
3650

    
3651
confdReqqIplist :: String
3652
confdReqqIplist = ConstantUtils.confdReqqIplist
3653

    
3654
confdReqqFields :: String
3655
confdReqqFields = ConstantUtils.confdReqqFields
3656

    
3657
-- | Each request is "salted" by the current timestamp.
3658
--
3659
-- This constant decides how many seconds of skew to accept.
3660
--
3661
-- TODO: make this a default and allow the value to be more
3662
-- configurable
3663
confdMaxClockSkew :: Int
3664
confdMaxClockSkew = 2 * nodeMaxClockSkew
3665

    
3666
-- | When we haven't reloaded the config for more than this amount of
3667
-- seconds, we force a test to see if inotify is betraying us. Using a
3668
-- prime number to ensure we get less chance of 'same wakeup' with
3669
-- other processes.
3670
confdConfigReloadTimeout :: Int
3671
confdConfigReloadTimeout = 17
3672

    
3673
-- | If we receive more than one update in this amount of
3674
-- microseconds, we move to polling every RATELIMIT seconds, rather
3675
-- than relying on inotify, to be able to serve more requests.
3676
confdConfigReloadRatelimit :: Int
3677
confdConfigReloadRatelimit = 250000
3678

    
3679
-- | Magic number prepended to all confd queries.
3680
--
3681
-- This allows us to distinguish different types of confd protocols
3682
-- and handle them. For example by changing this we can move the whole
3683
-- payload to be compressed, or move away from json.
3684
confdMagicFourcc :: String
3685
confdMagicFourcc = "plj0"
3686

    
3687
-- | By default a confd request is sent to the minimum between this
3688
-- number and all MCs. 6 was chosen because even in the case of a
3689
-- disastrous 50% response rate, we should have enough answers to be
3690
-- able to compare more than one.
3691
confdDefaultReqCoverage :: Int
3692
confdDefaultReqCoverage = 6
3693

    
3694
-- | Timeout in seconds to expire pending query request in the confd
3695
-- client library. We don't actually expect any answer more than 10
3696
-- seconds after we sent a request.
3697
confdClientExpireTimeout :: Int
3698
confdClientExpireTimeout = 10
3699

    
3700
-- | Maximum UDP datagram size.
3701
--
3702
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
3703
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
3704
--   (assuming we can't use jumbo frames)
3705
-- We just set this to 60K, which should be enough
3706
maxUdpDataSize :: Int
3707
maxUdpDataSize = 61440
3708

    
3709
-- * User-id pool minimum/maximum acceptable user-ids
3710

    
3711
uidpoolUidMin :: Int
3712
uidpoolUidMin = 0
3713

    
3714
-- | Assuming 32 bit user-ids
3715
uidpoolUidMax :: Integer
3716
uidpoolUidMax = 2 ^ 32 - 1
3717

    
3718
-- | Name or path of the pgrep command
3719
pgrep :: String
3720
pgrep = "pgrep"
3721

    
3722
-- | Name of the node group that gets created at cluster init or
3723
-- upgrade
3724
initialNodeGroupName :: String
3725
initialNodeGroupName = "default"
3726

    
3727
-- * Possible values for NodeGroup.alloc_policy
3728

    
3729
allocPolicyLastResort :: String
3730
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
3731

    
3732
allocPolicyPreferred :: String
3733
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
3734

    
3735
allocPolicyUnallocable :: String
3736
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
3737

    
3738
validAllocPolicies :: [String]
3739
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
3740

    
3741
-- | Temporary external/shared storage parameters
3742
blockdevDriverManual :: String
3743
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
3744

    
3745
-- | 'qemu-img' path, required for 'ovfconverter'
3746
qemuimgPath :: String
3747
qemuimgPath = AutoConf.qemuimgPath
3748

    
3749
-- | Whether htools was enabled at compilation time
3750
--
3751
-- FIXME: this should be moved next to the other enable constants,
3752
-- such as, 'enableConfd', and renamed to 'enableHtools'.
3753
htools :: Bool
3754
htools = AutoConf.htools
3755

    
3756
-- | The hail iallocator
3757
iallocHail :: String
3758
iallocHail = "hail"
3759

    
3760
-- * Fake opcodes for functions that have hooks attached to them via
3761
-- backend.RunLocalHooks
3762

    
3763
fakeOpMasterTurndown :: String
3764
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
3765

    
3766
fakeOpMasterTurnup :: String
3767
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
3768

    
3769
-- * SSH key types
3770

    
3771
sshkDsa :: String
3772
sshkDsa = "dsa"
3773

    
3774
sshkRsa :: String
3775
sshkRsa = "rsa"
3776

    
3777
sshkAll :: FrozenSet String
3778
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
3779

    
3780
-- * SSH authorized key types
3781

    
3782
sshakDss :: String
3783
sshakDss = "ssh-dss"
3784

    
3785
sshakRsa :: String
3786
sshakRsa = "ssh-rsa"
3787

    
3788
sshakAll :: FrozenSet String
3789
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
3790

    
3791
-- * SSH setup
3792

    
3793
sshsClusterName :: String
3794
sshsClusterName = "cluster_name"
3795

    
3796
sshsSshHostKey :: String
3797
sshsSshHostKey = "ssh_host_key"
3798

    
3799
sshsSshRootKey :: String
3800
sshsSshRootKey = "ssh_root_key"
3801

    
3802
sshsNodeDaemonCertificate :: String
3803
sshsNodeDaemonCertificate = "node_daemon_certificate"
3804

    
3805
-- * Key files for SSH daemon
3806

    
3807
sshHostDsaPriv :: String
3808
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
3809

    
3810
sshHostDsaPub :: String
3811
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
3812

    
3813
sshHostRsaPriv :: String
3814
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
3815

    
3816
sshHostRsaPub :: String
3817
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
3818

    
3819
-- * Node daemon setup
3820

    
3821
ndsClusterName :: String
3822
ndsClusterName = "cluster_name"
3823

    
3824
ndsNodeDaemonCertificate :: String
3825
ndsNodeDaemonCertificate = "node_daemon_certificate"
3826

    
3827
ndsSsconf :: String
3828
ndsSsconf = "ssconf"
3829

    
3830
ndsStartNodeDaemon :: String
3831
ndsStartNodeDaemon = "start_node_daemon"
3832

    
3833
-- * The source reasons for the execution of an OpCode
3834

    
3835
opcodeReasonSrcClient :: String
3836
opcodeReasonSrcClient = "gnt:client"
3837

    
3838
opcodeReasonSrcNoded :: String
3839
opcodeReasonSrcNoded = "gnt:daemon:noded"
3840

    
3841
opcodeReasonSrcOpcode :: String
3842
opcodeReasonSrcOpcode = "gnt:opcode"
3843

    
3844
opcodeReasonSrcRlib2 :: String
3845
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
3846

    
3847
opcodeReasonSrcUser :: String
3848
opcodeReasonSrcUser = "gnt:user"
3849

    
3850
opcodeReasonSources :: FrozenSet String
3851
opcodeReasonSources =
3852
  ConstantUtils.mkSet [opcodeReasonSrcClient,
3853
                       opcodeReasonSrcNoded,
3854
                       opcodeReasonSrcOpcode,
3855
                       opcodeReasonSrcRlib2,
3856
                       opcodeReasonSrcUser]
3857

    
3858
-- | Path generating random UUID
3859
randomUuidFile :: String
3860
randomUuidFile = ConstantUtils.randomUuidFile
3861

    
3862
-- * Auto-repair tag prefixes
3863

    
3864
autoRepairTagPrefix :: String
3865
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
3866

    
3867
autoRepairTagEnabled :: String
3868
autoRepairTagEnabled = autoRepairTagPrefix
3869

    
3870
autoRepairTagPending :: String
3871
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
3872

    
3873
autoRepairTagResult :: String
3874
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
3875

    
3876
autoRepairTagSuspended :: String
3877
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
3878

    
3879
-- * Auto-repair levels
3880

    
3881
autoRepairFailover :: String
3882
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
3883

    
3884
autoRepairFixStorage :: String
3885
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
3886

    
3887
autoRepairMigrate :: String
3888
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
3889

    
3890
autoRepairReinstall :: String
3891
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
3892

    
3893
autoRepairAllTypes :: FrozenSet String
3894
autoRepairAllTypes =
3895
  ConstantUtils.mkSet [autoRepairFailover,
3896
                       autoRepairFixStorage,
3897
                       autoRepairMigrate,
3898
                       autoRepairReinstall]
3899

    
3900
-- * Auto-repair results
3901

    
3902
autoRepairEnoperm :: String
3903
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
3904

    
3905
autoRepairFailure :: String
3906
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
3907

    
3908
autoRepairSuccess :: String
3909
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
3910

    
3911
autoRepairAllResults :: FrozenSet String
3912
autoRepairAllResults =
3913
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
3914

    
3915
-- | The version identifier for builtin data collectors
3916
builtinDataCollectorVersion :: String
3917
builtinDataCollectorVersion = "B"
3918

    
3919
-- | The reason trail opcode parameter name
3920
opcodeReason :: String
3921
opcodeReason = "reason"
3922

    
3923
diskstatsFile :: String
3924
diskstatsFile = "/proc/diskstats"
3925

    
3926
-- *  CPU load collector
3927

    
3928
statFile :: String
3929
statFile = "/proc/stat"
3930

    
3931
cpuavgloadBufferSize :: Int
3932
cpuavgloadBufferSize = 150
3933

    
3934
cpuavgloadWindowSize :: Int
3935
cpuavgloadWindowSize = 600
3936

    
3937
-- | Mond's variable for periodical data collection
3938
mondTimeInterval :: Int
3939
mondTimeInterval = 5
3940

    
3941
-- * Disk access modes
3942

    
3943
diskUserspace :: String
3944
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
3945

    
3946
diskKernelspace :: String
3947
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
3948

    
3949
diskValidAccessModes :: FrozenSet String
3950
diskValidAccessModes =
3951
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
3952

    
3953
-- | Timeout for queue draining in upgrades
3954
upgradeQueueDrainTimeout :: Int
3955
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
3956

    
3957
-- | Intervall at which the queue is polled during upgrades
3958
upgradeQueuePollInterval :: Int
3959
upgradeQueuePollInterval  = 10