Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 1ecc03c1

History | View | Annotate | Download (115.6 kB)

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

    
4
The constants in this module are used in Haskell and are also
5
converted to Python.
6

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

    
15
-}
16

    
17
{-
18

    
19
Copyright (C) 2013 Google Inc.
20
All rights reserved.
21

    
22
Redistribution and use in source and binary forms, with or without
23
modification, are permitted provided that the following conditions are
24
met:
25

    
26
1. Redistributions of source code must retain the above copyright notice,
27
this list of conditions and the following disclaimer.
28

    
29
2. Redistributions in binary form must reproduce the above copyright
30
notice, this list of conditions and the following disclaimer in the
31
documentation and/or other materials provided with the distribution.
32

    
33
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
34
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
35
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
36
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
37
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
38
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
39
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
40
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
41
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
42
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
43
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44

    
45
-}
46
module Ganeti.Constants where
47

    
48
import Control.Arrow ((***))
49
import Data.List ((\\))
50
import Data.Map (Map)
51
import qualified Data.Map as Map (empty, fromList, keys, insert)
52

    
53
import qualified AutoConf
54
import Ganeti.ConstantUtils (PythonChar(..), FrozenSet, Protocol(..),
55
                             buildVersion)
56
import qualified Ganeti.ConstantUtils as ConstantUtils
57
import Ganeti.HTools.Types (AutoRepairResult(..), AutoRepairType(..))
58
import qualified Ganeti.HTools.Types as Types
59
import Ganeti.Logging (SyslogUsage(..))
60
import qualified Ganeti.Logging as Logging (syslogUsageToRaw)
61
import qualified Ganeti.Runtime as Runtime
62
import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..),
63
                       ExtraLogReason(..))
64
import Ganeti.THH (PyValueEx(..))
65
import Ganeti.Types
66
import qualified Ganeti.Types as Types
67
import Ganeti.Confd.Types (ConfdRequestType(..), ConfdReqField(..),
68
                           ConfdReplyStatus(..), ConfdNodeRole(..),
69
                           ConfdErrorType(..))
70
import qualified Ganeti.Confd.Types as Types
71

    
72
{-# ANN module "HLint: ignore Use camelCase" #-}
73

    
74
-- * 'autoconf' constants for Python only ('autotools/build-bash-completion')
75

    
76
htoolsProgs :: [String]
77
htoolsProgs = AutoConf.htoolsProgs
78

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

    
81
drbdBarriers :: String
82
drbdBarriers = AutoConf.drbdBarriers
83

    
84
drbdNoMetaFlush :: Bool
85
drbdNoMetaFlush = AutoConf.drbdNoMetaFlush
86

    
87
lvmStripecount :: Int
88
lvmStripecount = AutoConf.lvmStripecount
89

    
90
hasGnuLn :: Bool
91
hasGnuLn = AutoConf.hasGnuLn
92

    
93
-- * 'autoconf' constants for Python only ('lib/pathutils.py')
94

    
95
-- ** Build-time constants
96

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

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

    
103
osSearchPath :: [String]
104
osSearchPath = AutoConf.osSearchPath
105

    
106
esSearchPath :: [String]
107
esSearchPath = AutoConf.esSearchPath
108

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

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

    
115
sysconfdir :: String
116
sysconfdir = AutoConf.sysconfdir
117

    
118
toolsdir :: String
119
toolsdir = AutoConf.toolsdir
120

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

    
124
-- ** Paths which don't change for a virtual cluster
125

    
126
pkglibdir :: String
127
pkglibdir = AutoConf.pkglibdir
128

    
129
sharedir :: String
130
sharedir = AutoConf.sharedir
131

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

    
134
manPages :: Map String Int
135
manPages = Map.fromList AutoConf.manPages
136

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

    
139
versionedsharedir :: String
140
versionedsharedir = AutoConf.versionedsharedir
141

    
142
-- * 'autoconf' constants for Python only ('tests/py/docs_unittest.py')
143

    
144
gntScripts :: [String]
145
gntScripts = AutoConf.gntScripts
146

    
147
-- * Various versions
148

    
149
releaseVersion :: String
150
releaseVersion = AutoConf.packageVersion
151

    
152
versionMajor :: Int
153
versionMajor = AutoConf.versionMajor
154

    
155
versionMinor :: Int
156
versionMinor = AutoConf.versionMinor
157

    
158
versionRevision :: Int
159
versionRevision = AutoConf.versionRevision
160

    
161
dirVersion :: String
162
dirVersion = AutoConf.dirVersion
163

    
164
osApiV10 :: Int
165
osApiV10 = 10
166

    
167
osApiV15 :: Int
168
osApiV15 = 15
169

    
170
osApiV20 :: Int
171
osApiV20 = 20
172

    
173
osApiVersions :: FrozenSet Int
174
osApiVersions = ConstantUtils.mkSet [osApiV10, osApiV15, osApiV20]
175

    
176
exportVersion :: Int
177
exportVersion = 0
178

    
179
rapiVersion :: Int
180
rapiVersion = 2
181

    
182
configMajor :: Int
183
configMajor = AutoConf.versionMajor
184

    
185
configMinor :: Int
186
configMinor = AutoConf.versionMinor
187

    
188
-- | The configuration is supposed to remain stable across
189
-- revisions. Therefore, the revision number is cleared to '0'.
190
configRevision :: Int
191
configRevision = 0
192

    
193
configVersion :: Int
194
configVersion = buildVersion configMajor configMinor configRevision
195

    
196
-- | Similarly to the configuration (see 'configRevision'), the
197
-- protocols are supposed to remain stable across revisions.
198
protocolVersion :: Int
199
protocolVersion = buildVersion configMajor configMinor configRevision
200

    
201
-- * User separation
202

    
203
daemonsGroup :: String
204
daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
205

    
206
adminGroup :: String
207
adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
208

    
209
masterdUser :: String
210
masterdUser = Runtime.daemonUser GanetiMasterd
211

    
212
masterdGroup :: String
213
masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
214

    
215
rapiUser :: String
216
rapiUser = Runtime.daemonUser GanetiRapi
217

    
218
rapiGroup :: String
219
rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
220

    
221
confdUser :: String
222
confdUser = Runtime.daemonUser GanetiConfd
223

    
224
confdGroup :: String
225
confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
226

    
227
luxidUser :: String
228
luxidUser = Runtime.daemonUser GanetiLuxid
229

    
230
luxidGroup :: String
231
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
232

    
233
nodedUser :: String
234
nodedUser = Runtime.daemonUser GanetiNoded
235

    
236
nodedGroup :: String
237
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
238

    
239
mondUser :: String
240
mondUser = Runtime.daemonUser GanetiMond
241

    
242
mondGroup :: String
243
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
244

    
245
sshLoginUser :: String
246
sshLoginUser = AutoConf.sshLoginUser
247

    
248
sshConsoleUser :: String
249
sshConsoleUser = AutoConf.sshConsoleUser
250

    
251
-- * Cpu pinning separators and constants
252

    
253
cpuPinningSep :: String
254
cpuPinningSep = ":"
255

    
256
cpuPinningAll :: String
257
cpuPinningAll = "all"
258

    
259
-- | Internal representation of "all"
260
cpuPinningAllVal :: Int
261
cpuPinningAllVal = -1
262

    
263
-- | One "all" entry in a CPU list means CPU pinning is off
264
cpuPinningOff :: [Int]
265
cpuPinningOff = [cpuPinningAllVal]
266

    
267
-- | A Xen-specific implementation detail is that there is no way to
268
-- actually say "use any cpu for pinning" in a Xen configuration file,
269
-- as opposed to the command line, where you can say
270
-- @
271
-- xm vcpu-pin <domain> <vcpu> all
272
-- @
273
--
274
-- The workaround used in Xen is "0-63" (see source code function
275
-- "xm_vcpu_pin" in @<xen-source>/tools/python/xen/xm/main.py@).
276
--
277
-- To support future changes, the following constant is treated as a
278
-- blackbox string that simply means "use any cpu for pinning under
279
-- xen".
280
cpuPinningAllXen :: String
281
cpuPinningAllXen = "0-63"
282

    
283
-- | A KVM-specific implementation detail - the following value is
284
-- used to set CPU affinity to all processors (--0 through --31), per
285
-- taskset man page.
286
--
287
-- FIXME: This only works for machines with up to 32 CPU cores
288
cpuPinningAllKvm :: Int
289
cpuPinningAllKvm = 0xFFFFFFFF
290

    
291
-- * Wipe
292

    
293
ddCmd :: String
294
ddCmd = "dd"
295

    
296
-- | 1GB
297
maxWipeChunk :: Int
298
maxWipeChunk = 1024
299

    
300
minWipeChunkPercent :: Int
301
minWipeChunkPercent = 10
302

    
303
-- * Directories
304

    
305
runDirsMode :: Int
306
runDirsMode = 0o775
307

    
308
secureDirMode :: Int
309
secureDirMode = 0o700
310

    
311
secureFileMode :: Int
312
secureFileMode = 0o600
313

    
314
adoptableBlockdevRoot :: String
315
adoptableBlockdevRoot = "/dev/disk/"
316

    
317
-- * 'autoconf' enable/disable
318

    
319
enableConfd :: Bool
320
enableConfd = AutoConf.enableConfd
321

    
322
enableMond :: Bool
323
enableMond = AutoConf.enableMond
324

    
325
enableRestrictedCommands :: Bool
326
enableRestrictedCommands = AutoConf.enableRestrictedCommands
327

    
328
enableSplitQuery :: Bool
329
enableSplitQuery = AutoConf.enableSplitQuery
330

    
331
-- * SSH constants
332

    
333
ssh :: String
334
ssh = "ssh"
335

    
336
scp :: String
337
scp = "scp"
338

    
339
-- * Daemons
340

    
341
confd :: String
342
confd = Runtime.daemonName GanetiConfd
343

    
344
masterd :: String
345
masterd = Runtime.daemonName GanetiMasterd
346

    
347
mond :: String
348
mond = Runtime.daemonName GanetiMond
349

    
350
noded :: String
351
noded = Runtime.daemonName GanetiNoded
352

    
353
luxid :: String
354
luxid = Runtime.daemonName GanetiLuxid
355

    
356
rapi :: String
357
rapi = Runtime.daemonName GanetiRapi
358

    
359
daemons :: FrozenSet String
360
daemons =
361
  ConstantUtils.mkSet [confd,
362
                       luxid,
363
                       masterd,
364
                       mond,
365
                       noded,
366
                       rapi]
367

    
368
defaultConfdPort :: Int
369
defaultConfdPort = 1814
370

    
371
defaultMondPort :: Int
372
defaultMondPort = 1815
373

    
374
defaultNodedPort :: Int
375
defaultNodedPort = 1811
376

    
377
defaultRapiPort :: Int
378
defaultRapiPort = 5080
379

    
380
daemonsPorts :: Map String (Protocol, Int)
381
daemonsPorts =
382
  Map.fromList [(confd, (Udp, defaultConfdPort)),
383
                (mond, (Tcp, defaultMondPort)),
384
                (noded, (Tcp, defaultNodedPort)),
385
                (rapi, (Tcp, defaultRapiPort)),
386
                (ssh, (Tcp, 22))]
387

    
388
firstDrbdPort :: Int
389
firstDrbdPort = 11000
390

    
391
lastDrbdPort :: Int
392
lastDrbdPort = 14999
393

    
394
daemonsLogbase :: Map String String
395
daemonsLogbase =
396
  Map.fromList
397
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
398

    
399
daemonsExtraLogbase :: Map String (Map String String)
400
daemonsExtraLogbase =
401
  Map.fromList $
402
  map (Runtime.daemonName *** id)
403
  [ (GanetiMond, Map.fromList
404
                 [ ("access", Runtime.daemonsExtraLogbase GanetiMond AccessLog)
405
                 , ("error", Runtime.daemonsExtraLogbase GanetiMond ErrorLog)
406
                 ])
407
  ]
408

    
409
extraLogreasonAccess :: String
410
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
411

    
412
extraLogreasonError :: String
413
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
414

    
415
devConsole :: String
416
devConsole = ConstantUtils.devConsole
417

    
418
procMounts :: String
419
procMounts = "/proc/mounts"
420

    
421
-- * Luxi (Local UniX Interface) related constants
422

    
423
luxiEom :: PythonChar
424
luxiEom = PythonChar '\x03'
425

    
426
-- | Environment variable for the luxi override socket
427
luxiOverride :: String
428
luxiOverride = "FORCE_LUXI_SOCKET"
429

    
430
luxiOverrideMaster :: String
431
luxiOverrideMaster = "master"
432

    
433
luxiOverrideQuery :: String
434
luxiOverrideQuery = "query"
435

    
436
luxiVersion :: Int
437
luxiVersion = configVersion
438

    
439
-- * Syslog
440

    
441
syslogUsage :: String
442
syslogUsage = AutoConf.syslogUsage
443

    
444
syslogNo :: String
445
syslogNo = Logging.syslogUsageToRaw SyslogNo
446

    
447
syslogYes :: String
448
syslogYes = Logging.syslogUsageToRaw SyslogYes
449

    
450
syslogOnly :: String
451
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
452

    
453
syslogSocket :: String
454
syslogSocket = "/dev/log"
455

    
456
exportConfFile :: String
457
exportConfFile = "config.ini"
458

    
459
-- * Xen
460

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

    
464
xenCmdXl :: String
465
xenCmdXl = "xl"
466

    
467
xenCmdXm :: String
468
xenCmdXm = "xm"
469

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

    
473
xenKernel :: String
474
xenKernel = AutoConf.xenKernel
475

    
476
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
477
-- other constants
478
knownXenCommands :: FrozenSet String
479
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
480

    
481
-- * KVM and socat
482

    
483
kvmPath :: String
484
kvmPath = AutoConf.kvmPath
485

    
486
kvmKernel :: String
487
kvmKernel = AutoConf.kvmKernel
488

    
489
socatEscapeCode :: String
490
socatEscapeCode = "0x1d"
491

    
492
socatPath :: String
493
socatPath = AutoConf.socatPath
494

    
495
socatUseCompress :: Bool
496
socatUseCompress = AutoConf.socatUseCompress
497

    
498
socatUseEscape :: Bool
499
socatUseEscape = AutoConf.socatUseEscape
500

    
501
-- * Console types
502

    
503
-- | Display a message for console access
504
consMessage :: String
505
consMessage = "msg"
506

    
507
-- | Console as SPICE server
508
consSpice :: String
509
consSpice = "spice"
510

    
511
-- | Console as SSH command
512
consSsh :: String
513
consSsh = "ssh"
514

    
515
-- | Console as VNC server
516
consVnc :: String
517
consVnc = "vnc"
518

    
519
consAll :: FrozenSet String
520
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
521

    
522
-- | RSA key bit length
523
--
524
-- For RSA keys more bits are better, but they also make operations
525
-- more expensive. NIST SP 800-131 recommends a minimum of 2048 bits
526
-- from the year 2010 on.
527
rsaKeyBits :: Int
528
rsaKeyBits = 2048
529

    
530
-- | Ciphers allowed for SSL connections.
531
--
532
-- For the format, see ciphers(1). A better way to disable ciphers
533
-- would be to use the exclamation mark (!), but socat versions below
534
-- 1.5 can't parse exclamation marks in options properly. When
535
-- modifying the ciphers, ensure not to accidentially add something
536
-- after it's been removed. Use the "openssl" utility to check the
537
-- allowed ciphers, e.g.  "openssl ciphers -v HIGH:-DES".
538
opensslCiphers :: String
539
opensslCiphers = "HIGH:-DES:-3DES:-EXPORT:-ADH"
540

    
541
-- * X509
542

    
543
-- | commonName (CN) used in certificates
544
x509CertCn :: String
545
x509CertCn = "ganeti.example.com"
546

    
547
-- | Default validity of certificates in days
548
x509CertDefaultValidity :: Int
549
x509CertDefaultValidity = 365 * 5
550

    
551
x509CertSignatureHeader :: String
552
x509CertSignatureHeader = "X-Ganeti-Signature"
553

    
554
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
555
x509CertSignDigest :: String
556
x509CertSignDigest = "SHA1"
557

    
558
-- * Import/export daemon mode
559

    
560
iemExport :: String
561
iemExport = "export"
562

    
563
iemImport :: String
564
iemImport = "import"
565

    
566
-- * Import/export transport compression
567

    
568
iecGzip :: String
569
iecGzip = "gzip"
570

    
571
iecNone :: String
572
iecNone = "none"
573

    
574
iecAll :: [String]
575
iecAll = [iecGzip, iecNone]
576

    
577
ieCustomSize :: String
578
ieCustomSize = "fd"
579

    
580
-- * Import/export I/O
581

    
582
-- | Direct file I/O, equivalent to a shell's I/O redirection using
583
-- '<' or '>'
584
ieioFile :: String
585
ieioFile = "file"
586

    
587
-- | Raw block device I/O using "dd"
588
ieioRawDisk :: String
589
ieioRawDisk = "raw"
590

    
591
-- | OS definition import/export script
592
ieioScript :: String
593
ieioScript = "script"
594

    
595
-- * Values
596

    
597
valueDefault :: String
598
valueDefault = "default"
599

    
600
valueAuto :: String
601
valueAuto = "auto"
602

    
603
valueGenerate :: String
604
valueGenerate = "generate"
605

    
606
valueNone :: String
607
valueNone = "none"
608

    
609
valueTrue :: String
610
valueTrue = "true"
611

    
612
valueFalse :: String
613
valueFalse = "false"
614

    
615
-- * Hooks
616

    
617
hooksNameCfgupdate :: String
618
hooksNameCfgupdate = "config-update"
619

    
620
hooksNameWatcher :: String
621
hooksNameWatcher = "watcher"
622

    
623
hooksPath :: String
624
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
625

    
626
hooksPhasePost :: String
627
hooksPhasePost = "post"
628

    
629
hooksPhasePre :: String
630
hooksPhasePre = "pre"
631

    
632
hooksVersion :: Int
633
hooksVersion = 2
634

    
635
-- * Hooks subject type (what object type does the LU deal with)
636

    
637
htypeCluster :: String
638
htypeCluster = "CLUSTER"
639

    
640
htypeGroup :: String
641
htypeGroup = "GROUP"
642

    
643
htypeInstance :: String
644
htypeInstance = "INSTANCE"
645

    
646
htypeNetwork :: String
647
htypeNetwork = "NETWORK"
648

    
649
htypeNode :: String
650
htypeNode = "NODE"
651

    
652
-- * Hkr
653

    
654
hkrSkip :: Int
655
hkrSkip = 0
656

    
657
hkrFail :: Int
658
hkrFail = 1
659

    
660
hkrSuccess :: Int
661
hkrSuccess = 2
662

    
663
-- * Storage types
664

    
665
stBlock :: String
666
stBlock = Types.storageTypeToRaw StorageBlock
667

    
668
stDiskless :: String
669
stDiskless = Types.storageTypeToRaw StorageDiskless
670

    
671
stExt :: String
672
stExt = Types.storageTypeToRaw StorageExt
673

    
674
stFile :: String
675
stFile = Types.storageTypeToRaw StorageFile
676

    
677
stLvmPv :: String
678
stLvmPv = Types.storageTypeToRaw StorageLvmPv
679

    
680
stLvmVg :: String
681
stLvmVg = Types.storageTypeToRaw StorageLvmVg
682

    
683
stRados :: String
684
stRados = Types.storageTypeToRaw StorageRados
685

    
686
storageTypes :: FrozenSet String
687
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
688

    
689
-- | The set of storage types for which storage reporting is available
690
--
691
-- FIXME: Remove this, once storage reporting is available for all
692
-- types.
693
stsReport :: FrozenSet String
694
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
695

    
696
-- * Storage fields
697
-- ** First two are valid in LU context only, not passed to backend
698

    
699
sfNode :: String
700
sfNode = "node"
701

    
702
sfType :: String
703
sfType = "type"
704

    
705
-- ** and the rest are valid in backend
706

    
707
sfAllocatable :: String
708
sfAllocatable = Types.storageFieldToRaw SFAllocatable
709

    
710
sfFree :: String
711
sfFree = Types.storageFieldToRaw SFFree
712

    
713
sfName :: String
714
sfName = Types.storageFieldToRaw SFName
715

    
716
sfSize :: String
717
sfSize = Types.storageFieldToRaw SFSize
718

    
719
sfUsed :: String
720
sfUsed = Types.storageFieldToRaw SFUsed
721

    
722
validStorageFields :: FrozenSet String
723
validStorageFields =
724
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
725
                        [sfNode, sfType]
726

    
727
modifiableStorageFields :: Map String (FrozenSet String)
728
modifiableStorageFields =
729
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
730
                 ConstantUtils.mkSet [sfAllocatable])]
731

    
732
-- * Storage operations
733

    
734
soFixConsistency :: String
735
soFixConsistency = "fix-consistency"
736

    
737
validStorageOperations :: Map String (FrozenSet String)
738
validStorageOperations =
739
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
740
                 ConstantUtils.mkSet [soFixConsistency])]
741

    
742
-- * Volume fields
743

    
744
vfDev :: String
745
vfDev = "dev"
746

    
747
vfInstance :: String
748
vfInstance = "instance"
749

    
750
vfName :: String
751
vfName = "name"
752

    
753
vfNode :: String
754
vfNode = "node"
755

    
756
vfPhys :: String
757
vfPhys = "phys"
758

    
759
vfSize :: String
760
vfSize = "size"
761

    
762
vfVg :: String
763
vfVg = "vg"
764

    
765
-- * Local disk status
766

    
767
ldsFaulty :: Int
768
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
769

    
770
ldsOkay :: Int
771
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
772

    
773
ldsUnknown :: Int
774
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
775

    
776
ldsNames :: Map Int String
777
ldsNames =
778
  Map.fromList [ (Types.localDiskStatusToRaw ds,
779
                  localDiskStatusName ds) | ds <- [minBound..] ]
780

    
781
-- * Disk template types
782

    
783
dtDiskless :: String
784
dtDiskless = Types.diskTemplateToRaw DTDiskless
785

    
786
dtFile :: String
787
dtFile = Types.diskTemplateToRaw DTFile
788

    
789
dtSharedFile :: String
790
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
791

    
792
dtPlain :: String
793
dtPlain = Types.diskTemplateToRaw DTPlain
794

    
795
dtBlock :: String
796
dtBlock = Types.diskTemplateToRaw DTBlock
797

    
798
dtDrbd8 :: String
799
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
800

    
801
dtRbd :: String
802
dtRbd = Types.diskTemplateToRaw DTRbd
803

    
804
dtExt :: String
805
dtExt = Types.diskTemplateToRaw DTExt
806

    
807
-- | This is used to order determine the default disk template when
808
-- the list of enabled disk templates is inferred from the current
809
-- state of the cluster.  This only happens on an upgrade from a
810
-- version of Ganeti that did not support the 'enabled_disk_templates'
811
-- so far.
812
diskTemplatePreference :: [String]
813
diskTemplatePreference =
814
  map Types.diskTemplateToRaw
815
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile, DTPlain, DTRbd, DTSharedFile]
816

    
817
diskTemplates :: FrozenSet String
818
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
819

    
820
-- | Disk templates that are enabled by default
821
defaultEnabledDiskTemplates :: [String]
822
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
823

    
824
-- | Mapping of disk templates to storage types
825
mapDiskTemplateStorageType :: Map String String
826
mapDiskTemplateStorageType =
827
  Map.fromList $
828
  map (Types.diskTemplateToRaw *** Types.storageTypeToRaw)
829
  [(DTBlock, StorageBlock),
830
   (DTDrbd8, StorageLvmVg),
831
   (DTExt, StorageExt),
832
   (DTSharedFile, StorageFile),
833
   (DTFile, StorageFile),
834
   (DTDiskless, StorageDiskless),
835
   (DTPlain, StorageLvmVg),
836
   (DTRbd, StorageRados)]
837

    
838
-- | The set of network-mirrored disk templates
839
dtsIntMirror :: FrozenSet String
840
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
841

    
842
-- | 'DTDiskless' is 'trivially' externally mirrored
843
dtsExtMirror :: FrozenSet String
844
dtsExtMirror =
845
  ConstantUtils.mkSet $
846
  map Types.diskTemplateToRaw [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd]
847

    
848
-- | The set of non-lvm-based disk templates
849
dtsNotLvm :: FrozenSet String
850
dtsNotLvm =
851
  ConstantUtils.mkSet $
852
  map Types.diskTemplateToRaw
853
  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd]
854

    
855
-- | The set of disk templates which can be grown
856
dtsGrowable :: FrozenSet String
857
dtsGrowable =
858
  ConstantUtils.mkSet $
859
  map Types.diskTemplateToRaw
860
  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd]
861

    
862
-- | The set of disk templates that allow adoption
863
dtsMayAdopt :: FrozenSet String
864
dtsMayAdopt =
865
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
866

    
867
-- | The set of disk templates that *must* use adoption
868
dtsMustAdopt :: FrozenSet String
869
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
870

    
871
-- | The set of disk templates that allow migrations
872
dtsMirrored :: FrozenSet String
873
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
874

    
875
-- | The set of file based disk templates
876
dtsFilebased :: FrozenSet String
877
dtsFilebased =
878
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTSharedFile, DTFile]
879

    
880
-- | The set of disk templates that can be moved by copying
881
--
882
-- Note: a requirement is that they're not accessed externally or
883
-- shared between nodes; in particular, sharedfile is not suitable.
884
dtsCopyable :: FrozenSet String
885
dtsCopyable =
886
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
887

    
888
-- | The set of disk templates that are supported by exclusive_storage
889
dtsExclStorage :: FrozenSet String
890
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
891

    
892
-- | Templates for which we don't perform checks on free space
893
dtsNoFreeSpaceCheck :: FrozenSet String
894
dtsNoFreeSpaceCheck =
895
  ConstantUtils.mkSet $
896
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd]
897

    
898
dtsBlock :: FrozenSet String
899
dtsBlock =
900
  ConstantUtils.mkSet $
901
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
902

    
903
-- | The set of lvm-based disk templates
904
dtsLvm :: FrozenSet String
905
dtsLvm = diskTemplates `ConstantUtils.difference` dtsNotLvm
906

    
907
-- | The set of lvm-based disk templates
908
dtsHaveAccess :: FrozenSet String
909
dtsHaveAccess = ConstantUtils.mkSet $
910
  map Types.diskTemplateToRaw [DTRbd, DTExt]
911

    
912
-- * Drbd
913

    
914
drbdHmacAlg :: String
915
drbdHmacAlg = "md5"
916

    
917
drbdDefaultNetProtocol :: String
918
drbdDefaultNetProtocol = "C"
919

    
920
drbdMigrationNetProtocol :: String
921
drbdMigrationNetProtocol = "C"
922

    
923
drbdStatusFile :: String
924
drbdStatusFile = "/proc/drbd"
925

    
926
-- | Size of DRBD meta block device
927
drbdMetaSize :: Int
928
drbdMetaSize = 128
929

    
930
-- * Drbd barrier types
931

    
932
drbdBDiskBarriers :: String
933
drbdBDiskBarriers = "b"
934

    
935
drbdBDiskDrain :: String
936
drbdBDiskDrain = "d"
937

    
938
drbdBDiskFlush :: String
939
drbdBDiskFlush = "f"
940

    
941
drbdBNone :: String
942
drbdBNone = "n"
943

    
944
-- | Valid barrier combinations: "n" or any non-null subset of "bfd"
945
drbdValidBarrierOpt :: FrozenSet (FrozenSet String)
946
drbdValidBarrierOpt =
947
  ConstantUtils.mkSet
948
  [ ConstantUtils.mkSet [drbdBNone]
949
  , ConstantUtils.mkSet [drbdBDiskBarriers]
950
  , ConstantUtils.mkSet [drbdBDiskDrain]
951
  , ConstantUtils.mkSet [drbdBDiskFlush]
952
  , ConstantUtils.mkSet [drbdBDiskDrain, drbdBDiskFlush]
953
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskDrain]
954
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush]
955
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush, drbdBDiskDrain]
956
  ]
957

    
958
-- | Rbd tool command
959
rbdCmd :: String
960
rbdCmd = "rbd"
961

    
962
-- * File backend driver
963

    
964
fdBlktap :: String
965
fdBlktap = Types.fileDriverToRaw FileBlktap
966

    
967
fdBlktap2 :: String
968
fdBlktap2 = Types.fileDriverToRaw FileBlktap2
969

    
970
fdLoop :: String
971
fdLoop = Types.fileDriverToRaw FileLoop
972

    
973
fdDefault :: String
974
fdDefault = fdLoop
975

    
976
fileDriver :: FrozenSet String
977
fileDriver =
978
  ConstantUtils.mkSet $
979
  map Types.fileDriverToRaw [minBound..]
980

    
981
-- | The set of drbd-like disk types
982
dtsDrbd :: FrozenSet String
983
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
984

    
985
-- * Disk access mode
986

    
987
diskRdonly :: String
988
diskRdonly = Types.diskModeToRaw DiskRdOnly
989

    
990
diskRdwr :: String
991
diskRdwr = Types.diskModeToRaw DiskRdWr
992

    
993
diskAccessSet :: FrozenSet String
994
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
995

    
996
-- * Disk replacement mode
997

    
998
replaceDiskAuto :: String
999
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
1000

    
1001
replaceDiskChg :: String
1002
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
1003

    
1004
replaceDiskPri :: String
1005
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
1006

    
1007
replaceDiskSec :: String
1008
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
1009

    
1010
replaceModes :: FrozenSet String
1011
replaceModes =
1012
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
1013

    
1014
-- * Instance export mode
1015

    
1016
exportModeLocal :: String
1017
exportModeLocal = Types.exportModeToRaw ExportModeLocal
1018

    
1019
exportModeRemote :: String
1020
exportModeRemote = Types.exportModeToRaw ExportModeRemote
1021

    
1022
exportModes :: FrozenSet String
1023
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
1024

    
1025
-- * Instance creation modes
1026

    
1027
instanceCreate :: String
1028
instanceCreate = Types.instCreateModeToRaw InstCreate
1029

    
1030
instanceImport :: String
1031
instanceImport = Types.instCreateModeToRaw InstImport
1032

    
1033
instanceRemoteImport :: String
1034
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1035

    
1036
instanceCreateModes :: FrozenSet String
1037
instanceCreateModes =
1038
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1039

    
1040
-- * Remote import/export handshake message and version
1041

    
1042
rieHandshake :: String
1043
rieHandshake = "Hi, I'm Ganeti"
1044

    
1045
rieVersion :: Int
1046
rieVersion = 0
1047

    
1048
-- | Remote import/export certificate validity (seconds)
1049
rieCertValidity :: Int
1050
rieCertValidity = 24 * 60 * 60
1051

    
1052
-- | Export only: how long to wait per connection attempt (seconds)
1053
rieConnectAttemptTimeout :: Int
1054
rieConnectAttemptTimeout = 20
1055

    
1056
-- | Export only: number of attempts to connect
1057
rieConnectRetries :: Int
1058
rieConnectRetries = 10
1059

    
1060
-- | Overall timeout for establishing connection
1061
rieConnectTimeout :: Int
1062
rieConnectTimeout = 180
1063

    
1064
-- | Give child process up to 5 seconds to exit after sending a signal
1065
childLingerTimeout :: Double
1066
childLingerTimeout = 5.0
1067

    
1068
-- * Import/export config options
1069

    
1070
inisectBep :: String
1071
inisectBep = "backend"
1072

    
1073
inisectExp :: String
1074
inisectExp = "export"
1075

    
1076
inisectHyp :: String
1077
inisectHyp = "hypervisor"
1078

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

    
1082
inisectOsp :: String
1083
inisectOsp = "os"
1084

    
1085
-- * Dynamic device modification
1086

    
1087
ddmAdd :: String
1088
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1089

    
1090
ddmModify :: String
1091
ddmModify = Types.ddmFullToRaw DdmFullModify
1092

    
1093
ddmRemove :: String
1094
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1095

    
1096
ddmsValues :: FrozenSet String
1097
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1098

    
1099
ddmsValuesWithModify :: FrozenSet String
1100
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1101

    
1102
-- * Common exit codes
1103

    
1104
exitSuccess :: Int
1105
exitSuccess = 0
1106

    
1107
exitFailure :: Int
1108
exitFailure = ConstantUtils.exitFailure
1109

    
1110
exitNotcluster :: Int
1111
exitNotcluster = 5
1112

    
1113
exitNotmaster :: Int
1114
exitNotmaster = 11
1115

    
1116
exitNodesetupError :: Int
1117
exitNodesetupError = 12
1118

    
1119
-- | Need user confirmation
1120
exitConfirmation :: Int
1121
exitConfirmation = 13
1122

    
1123
-- | Exit code for query operations with unknown fields
1124
exitUnknownField :: Int
1125
exitUnknownField = 14
1126

    
1127
-- * Tags
1128

    
1129
tagCluster :: String
1130
tagCluster = Types.tagKindToRaw TagKindCluster
1131

    
1132
tagInstance :: String
1133
tagInstance = Types.tagKindToRaw TagKindInstance
1134

    
1135
tagNetwork :: String
1136
tagNetwork = Types.tagKindToRaw TagKindNetwork
1137

    
1138
tagNode :: String
1139
tagNode = Types.tagKindToRaw TagKindNode
1140

    
1141
tagNodegroup :: String
1142
tagNodegroup = Types.tagKindToRaw TagKindGroup
1143

    
1144
validTagTypes :: FrozenSet String
1145
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1146

    
1147
maxTagLen :: Int
1148
maxTagLen = 128
1149

    
1150
maxTagsPerObj :: Int
1151
maxTagsPerObj = 4096
1152

    
1153
-- * Others
1154

    
1155
defaultBridge :: String
1156
defaultBridge = "xen-br0"
1157

    
1158
defaultOvs :: String
1159
defaultOvs = "switch1"
1160

    
1161
-- | 60 MiB/s, expressed in KiB/s
1162
classicDrbdSyncSpeed :: Int
1163
classicDrbdSyncSpeed = 60 * 1024
1164

    
1165
ip4AddressAny :: String
1166
ip4AddressAny = "0.0.0.0"
1167

    
1168
ip4AddressLocalhost :: String
1169
ip4AddressLocalhost = "127.0.0.1"
1170

    
1171
ip6AddressAny :: String
1172
ip6AddressAny = "::"
1173

    
1174
ip6AddressLocalhost :: String
1175
ip6AddressLocalhost = "::1"
1176

    
1177
ip4Version :: Int
1178
ip4Version = 4
1179

    
1180
ip6Version :: Int
1181
ip6Version = 6
1182

    
1183
validIpVersions :: FrozenSet Int
1184
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1185

    
1186
tcpPingTimeout :: Int
1187
tcpPingTimeout = 10
1188

    
1189
defaultVg :: String
1190
defaultVg = "xenvg"
1191

    
1192
defaultDrbdHelper :: String
1193
defaultDrbdHelper = "/bin/true"
1194

    
1195
minVgSize :: Int
1196
minVgSize = 20480
1197

    
1198
defaultMacPrefix :: String
1199
defaultMacPrefix = "aa:00:00"
1200

    
1201
-- | Default maximum instance wait time (seconds)
1202
defaultShutdownTimeout :: Int
1203
defaultShutdownTimeout = 120
1204

    
1205
-- | Node clock skew (seconds)
1206
nodeMaxClockSkew :: Int
1207
nodeMaxClockSkew = 150
1208

    
1209
-- | Time for an intra-cluster disk transfer to wait for a connection
1210
diskTransferConnectTimeout :: Int
1211
diskTransferConnectTimeout = 60
1212

    
1213
-- | Disk index separator
1214
diskSeparator :: String
1215
diskSeparator = AutoConf.diskSeparator
1216

    
1217
ipCommandPath :: String
1218
ipCommandPath = AutoConf.ipPath
1219

    
1220
-- | Key for job IDs in opcode result
1221
jobIdsKey :: String
1222
jobIdsKey = "jobs"
1223

    
1224
-- * Runparts results
1225

    
1226
runpartsErr :: Int
1227
runpartsErr = 2
1228

    
1229
runpartsRun :: Int
1230
runpartsRun = 1
1231

    
1232
runpartsSkip :: Int
1233
runpartsSkip = 0
1234

    
1235
runpartsStatus :: [Int]
1236
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1237

    
1238
-- * RPC
1239

    
1240
rpcEncodingNone :: Int
1241
rpcEncodingNone = 0
1242

    
1243
rpcEncodingZlibBase64 :: Int
1244
rpcEncodingZlibBase64 = 1
1245

    
1246
-- * Timeout table
1247
--
1248
-- Various time constants for the timeout table
1249

    
1250
rpcTmoUrgent :: Int
1251
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1252

    
1253
rpcTmoFast :: Int
1254
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1255

    
1256
rpcTmoNormal :: Int
1257
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1258

    
1259
rpcTmoSlow :: Int
1260
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1261

    
1262
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1263
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1264
-- Python name.
1265
rpcTmo_4hrs :: Int
1266
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1267

    
1268
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1269
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1270
-- Python name.
1271
rpcTmo_1day :: Int
1272
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1273

    
1274
-- | Timeout for connecting to nodes (seconds)
1275
rpcConnectTimeout :: Int
1276
rpcConnectTimeout = 5
1277

    
1278
-- OS
1279

    
1280
osScriptCreate :: String
1281
osScriptCreate = "create"
1282

    
1283
osScriptExport :: String
1284
osScriptExport = "export"
1285

    
1286
osScriptImport :: String
1287
osScriptImport = "import"
1288

    
1289
osScriptRename :: String
1290
osScriptRename = "rename"
1291

    
1292
osScriptVerify :: String
1293
osScriptVerify = "verify"
1294

    
1295
osScripts :: [String]
1296
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1297
             osScriptVerify]
1298

    
1299
osApiFile :: String
1300
osApiFile = "ganeti_api_version"
1301

    
1302
osVariantsFile :: String
1303
osVariantsFile = "variants.list"
1304

    
1305
osParametersFile :: String
1306
osParametersFile = "parameters.list"
1307

    
1308
osValidateParameters :: String
1309
osValidateParameters = "parameters"
1310

    
1311
osValidateCalls :: FrozenSet String
1312
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1313

    
1314
-- | External Storage (ES) related constants
1315

    
1316
esActionAttach :: String
1317
esActionAttach = "attach"
1318

    
1319
esActionCreate :: String
1320
esActionCreate = "create"
1321

    
1322
esActionDetach :: String
1323
esActionDetach = "detach"
1324

    
1325
esActionGrow :: String
1326
esActionGrow = "grow"
1327

    
1328
esActionRemove :: String
1329
esActionRemove = "remove"
1330

    
1331
esActionSetinfo :: String
1332
esActionSetinfo = "setinfo"
1333

    
1334
esActionVerify :: String
1335
esActionVerify = "verify"
1336

    
1337
esActionSnapshot :: String
1338
esActionSnapshot = "snapshot"
1339

    
1340
esScriptCreate :: String
1341
esScriptCreate = esActionCreate
1342

    
1343
esScriptRemove :: String
1344
esScriptRemove = esActionRemove
1345

    
1346
esScriptGrow :: String
1347
esScriptGrow = esActionGrow
1348

    
1349
esScriptAttach :: String
1350
esScriptAttach = esActionAttach
1351

    
1352
esScriptDetach :: String
1353
esScriptDetach = esActionDetach
1354

    
1355
esScriptSetinfo :: String
1356
esScriptSetinfo = esActionSetinfo
1357

    
1358
esScriptVerify :: String
1359
esScriptVerify = esActionVerify
1360

    
1361
esScriptSnapshot :: String
1362
esScriptSnapshot = esActionSnapshot
1363

    
1364
esScripts :: FrozenSet String
1365
esScripts =
1366
  ConstantUtils.mkSet [esScriptAttach,
1367
                       esScriptCreate,
1368
                       esScriptDetach,
1369
                       esScriptGrow,
1370
                       esScriptRemove,
1371
                       esScriptSetinfo,
1372
                       esScriptVerify,
1373
                       esScriptSnapshot]
1374

    
1375
esParametersFile :: String
1376
esParametersFile = "parameters.list"
1377

    
1378
-- * Reboot types
1379

    
1380
instanceRebootSoft :: String
1381
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1382

    
1383
instanceRebootHard :: String
1384
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1385

    
1386
instanceRebootFull :: String
1387
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1388

    
1389
rebootTypes :: FrozenSet String
1390
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1391

    
1392
-- * Instance reboot behaviors
1393

    
1394
instanceRebootAllowed :: String
1395
instanceRebootAllowed = "reboot"
1396

    
1397
instanceRebootExit :: String
1398
instanceRebootExit = "exit"
1399

    
1400
rebootBehaviors :: [String]
1401
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1402

    
1403
-- * VTypes
1404

    
1405
vtypeBool :: VType
1406
vtypeBool = VTypeBool
1407

    
1408
vtypeInt :: VType
1409
vtypeInt = VTypeInt
1410

    
1411
vtypeMaybeString :: VType
1412
vtypeMaybeString = VTypeMaybeString
1413

    
1414
-- | Size in MiBs
1415
vtypeSize :: VType
1416
vtypeSize = VTypeSize
1417

    
1418
vtypeString :: VType
1419
vtypeString = VTypeString
1420

    
1421
enforceableTypes :: FrozenSet VType
1422
enforceableTypes = ConstantUtils.mkSet [minBound..]
1423

    
1424
-- | Constant representing that the user does not specify any IP version
1425
ifaceNoIpVersionSpecified :: Int
1426
ifaceNoIpVersionSpecified = 0
1427

    
1428
validSerialSpeeds :: [Int]
1429
validSerialSpeeds =
1430
  [75,
1431
   110,
1432
   300,
1433
   600,
1434
   1200,
1435
   1800,
1436
   2400,
1437
   4800,
1438
   9600,
1439
   14400,
1440
   19200,
1441
   28800,
1442
   38400,
1443
   57600,
1444
   115200,
1445
   230400,
1446
   345600,
1447
   460800]
1448

    
1449
-- * HV parameter names (global namespace)
1450

    
1451
hvAcpi :: String
1452
hvAcpi = "acpi"
1453

    
1454
hvBlockdevPrefix :: String
1455
hvBlockdevPrefix = "blockdev_prefix"
1456

    
1457
hvBootloaderArgs :: String
1458
hvBootloaderArgs = "bootloader_args"
1459

    
1460
hvBootloaderPath :: String
1461
hvBootloaderPath = "bootloader_path"
1462

    
1463
hvBootOrder :: String
1464
hvBootOrder = "boot_order"
1465

    
1466
hvCdromImagePath :: String
1467
hvCdromImagePath = "cdrom_image_path"
1468

    
1469
hvCpuCap :: String
1470
hvCpuCap = "cpu_cap"
1471

    
1472
hvCpuCores :: String
1473
hvCpuCores = "cpu_cores"
1474

    
1475
hvCpuMask :: String
1476
hvCpuMask = "cpu_mask"
1477

    
1478
hvCpuSockets :: String
1479
hvCpuSockets = "cpu_sockets"
1480

    
1481
hvCpuThreads :: String
1482
hvCpuThreads = "cpu_threads"
1483

    
1484
hvCpuType :: String
1485
hvCpuType = "cpu_type"
1486

    
1487
hvCpuWeight :: String
1488
hvCpuWeight = "cpu_weight"
1489

    
1490
hvDeviceModel :: String
1491
hvDeviceModel = "device_model"
1492

    
1493
hvDiskCache :: String
1494
hvDiskCache = "disk_cache"
1495

    
1496
hvDiskType :: String
1497
hvDiskType = "disk_type"
1498

    
1499
hvInitrdPath :: String
1500
hvInitrdPath = "initrd_path"
1501

    
1502
hvInitScript :: String
1503
hvInitScript = "init_script"
1504

    
1505
hvKernelArgs :: String
1506
hvKernelArgs = "kernel_args"
1507

    
1508
hvKernelPath :: String
1509
hvKernelPath = "kernel_path"
1510

    
1511
hvKeymap :: String
1512
hvKeymap = "keymap"
1513

    
1514
hvKvmCdrom2ImagePath :: String
1515
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1516

    
1517
hvKvmCdromDiskType :: String
1518
hvKvmCdromDiskType = "cdrom_disk_type"
1519

    
1520
hvKvmExtra :: String
1521
hvKvmExtra = "kvm_extra"
1522

    
1523
hvKvmFlag :: String
1524
hvKvmFlag = "kvm_flag"
1525

    
1526
hvKvmFloppyImagePath :: String
1527
hvKvmFloppyImagePath = "floppy_image_path"
1528

    
1529
hvKvmMachineVersion :: String
1530
hvKvmMachineVersion = "machine_version"
1531

    
1532
hvKvmMigrationCaps :: String
1533
hvKvmMigrationCaps = "migration_caps"
1534

    
1535
hvKvmPath :: String
1536
hvKvmPath = "kvm_path"
1537

    
1538
hvKvmSpiceAudioCompr :: String
1539
hvKvmSpiceAudioCompr = "spice_playback_compression"
1540

    
1541
hvKvmSpiceBind :: String
1542
hvKvmSpiceBind = "spice_bind"
1543

    
1544
hvKvmSpiceIpVersion :: String
1545
hvKvmSpiceIpVersion = "spice_ip_version"
1546

    
1547
hvKvmSpiceJpegImgCompr :: String
1548
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1549

    
1550
hvKvmSpiceLosslessImgCompr :: String
1551
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1552

    
1553
hvKvmSpicePasswordFile :: String
1554
hvKvmSpicePasswordFile = "spice_password_file"
1555

    
1556
hvKvmSpiceStreamingVideoDetection :: String
1557
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1558

    
1559
hvKvmSpiceTlsCiphers :: String
1560
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1561

    
1562
hvKvmSpiceUseTls :: String
1563
hvKvmSpiceUseTls = "spice_use_tls"
1564

    
1565
hvKvmSpiceUseVdagent :: String
1566
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1567

    
1568
hvKvmSpiceZlibGlzImgCompr :: String
1569
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1570

    
1571
hvKvmUseChroot :: String
1572
hvKvmUseChroot = "use_chroot"
1573

    
1574
hvMemPath :: String
1575
hvMemPath = "mem_path"
1576

    
1577
hvMigrationBandwidth :: String
1578
hvMigrationBandwidth = "migration_bandwidth"
1579

    
1580
hvMigrationDowntime :: String
1581
hvMigrationDowntime = "migration_downtime"
1582

    
1583
hvMigrationMode :: String
1584
hvMigrationMode = "migration_mode"
1585

    
1586
hvMigrationPort :: String
1587
hvMigrationPort = "migration_port"
1588

    
1589
hvNicType :: String
1590
hvNicType = "nic_type"
1591

    
1592
hvPae :: String
1593
hvPae = "pae"
1594

    
1595
hvPassthrough :: String
1596
hvPassthrough = "pci_pass"
1597

    
1598
hvRebootBehavior :: String
1599
hvRebootBehavior = "reboot_behavior"
1600

    
1601
hvRootPath :: String
1602
hvRootPath = "root_path"
1603

    
1604
hvSecurityDomain :: String
1605
hvSecurityDomain = "security_domain"
1606

    
1607
hvSecurityModel :: String
1608
hvSecurityModel = "security_model"
1609

    
1610
hvSerialConsole :: String
1611
hvSerialConsole = "serial_console"
1612

    
1613
hvSerialSpeed :: String
1614
hvSerialSpeed = "serial_speed"
1615

    
1616
hvSoundhw :: String
1617
hvSoundhw = "soundhw"
1618

    
1619
hvUsbDevices :: String
1620
hvUsbDevices = "usb_devices"
1621

    
1622
hvUsbMouse :: String
1623
hvUsbMouse = "usb_mouse"
1624

    
1625
hvUseBootloader :: String
1626
hvUseBootloader = "use_bootloader"
1627

    
1628
hvUseLocaltime :: String
1629
hvUseLocaltime = "use_localtime"
1630

    
1631
hvVga :: String
1632
hvVga = "vga"
1633

    
1634
hvVhostNet :: String
1635
hvVhostNet = "vhost_net"
1636

    
1637
hvVirtioNetQueues :: String
1638
hvVirtioNetQueues = "virtio_net_queues"
1639

    
1640
hvVifScript :: String
1641
hvVifScript = "vif_script"
1642

    
1643
hvVifType :: String
1644
hvVifType = "vif_type"
1645

    
1646
hvViridian :: String
1647
hvViridian = "viridian"
1648

    
1649
hvVncBindAddress :: String
1650
hvVncBindAddress = "vnc_bind_address"
1651

    
1652
hvVncPasswordFile :: String
1653
hvVncPasswordFile = "vnc_password_file"
1654

    
1655
hvVncTls :: String
1656
hvVncTls = "vnc_tls"
1657

    
1658
hvVncX509 :: String
1659
hvVncX509 = "vnc_x509_path"
1660

    
1661
hvVncX509Verify :: String
1662
hvVncX509Verify = "vnc_x509_verify"
1663

    
1664
hvVnetHdr :: String
1665
hvVnetHdr = "vnet_hdr"
1666

    
1667
hvXenCmd :: String
1668
hvXenCmd = "xen_cmd"
1669

    
1670
hvXenCpuid :: String
1671
hvXenCpuid = "cpuid"
1672

    
1673
hvsParameterTitles :: Map String String
1674
hvsParameterTitles =
1675
  Map.fromList
1676
  [(hvAcpi, "ACPI"),
1677
   (hvBootOrder, "Boot_order"),
1678
   (hvCdromImagePath, "CDROM_image_path"),
1679
   (hvCpuType, "cpu_type"),
1680
   (hvDiskType, "Disk_type"),
1681
   (hvInitrdPath, "Initrd_path"),
1682
   (hvKernelPath, "Kernel_path"),
1683
   (hvNicType, "NIC_type"),
1684
   (hvPae, "PAE"),
1685
   (hvPassthrough, "pci_pass"),
1686
   (hvVncBindAddress, "VNC_bind_address")]
1687

    
1688
hvsParameters :: FrozenSet String
1689
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1690

    
1691
hvsParameterTypes :: Map String VType
1692
hvsParameterTypes = Map.fromList
1693
  [ (hvAcpi,                            VTypeBool)
1694
  , (hvBlockdevPrefix,                  VTypeString)
1695
  , (hvBootloaderArgs,                  VTypeString)
1696
  , (hvBootloaderPath,                  VTypeString)
1697
  , (hvBootOrder,                       VTypeString)
1698
  , (hvCdromImagePath,                  VTypeString)
1699
  , (hvCpuCap,                          VTypeInt)
1700
  , (hvCpuCores,                        VTypeInt)
1701
  , (hvCpuMask,                         VTypeString)
1702
  , (hvCpuSockets,                      VTypeInt)
1703
  , (hvCpuThreads,                      VTypeInt)
1704
  , (hvCpuType,                         VTypeString)
1705
  , (hvCpuWeight,                       VTypeInt)
1706
  , (hvDeviceModel,                     VTypeString)
1707
  , (hvDiskCache,                       VTypeString)
1708
  , (hvDiskType,                        VTypeString)
1709
  , (hvInitrdPath,                      VTypeString)
1710
  , (hvInitScript,                      VTypeString)
1711
  , (hvKernelArgs,                      VTypeString)
1712
  , (hvKernelPath,                      VTypeString)
1713
  , (hvKeymap,                          VTypeString)
1714
  , (hvKvmCdrom2ImagePath,              VTypeString)
1715
  , (hvKvmCdromDiskType,                VTypeString)
1716
  , (hvKvmExtra,                        VTypeString)
1717
  , (hvKvmFlag,                         VTypeString)
1718
  , (hvKvmFloppyImagePath,              VTypeString)
1719
  , (hvKvmMachineVersion,               VTypeString)
1720
  , (hvKvmMigrationCaps,                VTypeString)
1721
  , (hvKvmPath,                         VTypeString)
1722
  , (hvKvmSpiceAudioCompr,              VTypeBool)
1723
  , (hvKvmSpiceBind,                    VTypeString)
1724
  , (hvKvmSpiceIpVersion,               VTypeInt)
1725
  , (hvKvmSpiceJpegImgCompr,            VTypeString)
1726
  , (hvKvmSpiceLosslessImgCompr,        VTypeString)
1727
  , (hvKvmSpicePasswordFile,            VTypeString)
1728
  , (hvKvmSpiceStreamingVideoDetection, VTypeString)
1729
  , (hvKvmSpiceTlsCiphers,              VTypeString)
1730
  , (hvKvmSpiceUseTls,                  VTypeBool)
1731
  , (hvKvmSpiceUseVdagent,              VTypeBool)
1732
  , (hvKvmSpiceZlibGlzImgCompr,         VTypeString)
1733
  , (hvKvmUseChroot,                    VTypeBool)
1734
  , (hvMemPath,                         VTypeString)
1735
  , (hvMigrationBandwidth,              VTypeInt)
1736
  , (hvMigrationDowntime,               VTypeInt)
1737
  , (hvMigrationMode,                   VTypeString)
1738
  , (hvMigrationPort,                   VTypeInt)
1739
  , (hvNicType,                         VTypeString)
1740
  , (hvPae,                             VTypeBool)
1741
  , (hvPassthrough,                     VTypeString)
1742
  , (hvRebootBehavior,                  VTypeString)
1743
  , (hvRootPath,                        VTypeMaybeString)
1744
  , (hvSecurityDomain,                  VTypeString)
1745
  , (hvSecurityModel,                   VTypeString)
1746
  , (hvSerialConsole,                   VTypeBool)
1747
  , (hvSerialSpeed,                     VTypeInt)
1748
  , (hvSoundhw,                         VTypeString)
1749
  , (hvUsbDevices,                      VTypeString)
1750
  , (hvUsbMouse,                        VTypeString)
1751
  , (hvUseBootloader,                   VTypeBool)
1752
  , (hvUseLocaltime,                    VTypeBool)
1753
  , (hvVga,                             VTypeString)
1754
  , (hvVhostNet,                        VTypeBool)
1755
  , (hvVirtioNetQueues,                 VTypeInt)
1756
  , (hvVifScript,                       VTypeString)
1757
  , (hvVifType,                         VTypeString)
1758
  , (hvViridian,                        VTypeBool)
1759
  , (hvVncBindAddress,                  VTypeString)
1760
  , (hvVncPasswordFile,                 VTypeString)
1761
  , (hvVncTls,                          VTypeBool)
1762
  , (hvVncX509,                         VTypeString)
1763
  , (hvVncX509Verify,                   VTypeBool)
1764
  , (hvVnetHdr,                         VTypeBool)
1765
  , (hvXenCmd,                          VTypeString)
1766
  , (hvXenCpuid,                        VTypeString)
1767
  ]
1768

    
1769
-- * Migration statuses
1770

    
1771
hvMigrationActive :: String
1772
hvMigrationActive = "active"
1773

    
1774
hvMigrationCancelled :: String
1775
hvMigrationCancelled = "cancelled"
1776

    
1777
hvMigrationCompleted :: String
1778
hvMigrationCompleted = "completed"
1779

    
1780
hvMigrationFailed :: String
1781
hvMigrationFailed = "failed"
1782

    
1783
hvMigrationValidStatuses :: FrozenSet String
1784
hvMigrationValidStatuses =
1785
  ConstantUtils.mkSet [hvMigrationActive,
1786
                       hvMigrationCancelled,
1787
                       hvMigrationCompleted,
1788
                       hvMigrationFailed]
1789

    
1790
hvMigrationFailedStatuses :: FrozenSet String
1791
hvMigrationFailedStatuses =
1792
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1793

    
1794
-- | KVM-specific statuses
1795
--
1796
-- FIXME: this constant seems unnecessary
1797
hvKvmMigrationValidStatuses :: FrozenSet String
1798
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1799

    
1800
-- | Node info keys
1801
hvNodeinfoKeyVersion :: String
1802
hvNodeinfoKeyVersion = "hv_version"
1803

    
1804
-- * Hypervisor state
1805

    
1806
hvstCpuNode :: String
1807
hvstCpuNode = "cpu_node"
1808

    
1809
hvstCpuTotal :: String
1810
hvstCpuTotal = "cpu_total"
1811

    
1812
hvstMemoryHv :: String
1813
hvstMemoryHv = "mem_hv"
1814

    
1815
hvstMemoryNode :: String
1816
hvstMemoryNode = "mem_node"
1817

    
1818
hvstMemoryTotal :: String
1819
hvstMemoryTotal = "mem_total"
1820

    
1821
hvstsParameters :: FrozenSet String
1822
hvstsParameters =
1823
  ConstantUtils.mkSet [hvstCpuNode,
1824
                       hvstCpuTotal,
1825
                       hvstMemoryHv,
1826
                       hvstMemoryNode,
1827
                       hvstMemoryTotal]
1828

    
1829
hvstDefaults :: Map String Int
1830
hvstDefaults =
1831
  Map.fromList
1832
  [(hvstCpuNode, 1),
1833
   (hvstCpuTotal, 1),
1834
   (hvstMemoryHv, 0),
1835
   (hvstMemoryTotal, 0),
1836
   (hvstMemoryNode, 0)]
1837

    
1838
hvstsParameterTypes :: Map String VType
1839
hvstsParameterTypes =
1840
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1841
                (hvstMemoryNode, VTypeInt),
1842
                (hvstMemoryHv, VTypeInt),
1843
                (hvstCpuTotal, VTypeInt),
1844
                (hvstCpuNode, VTypeInt)]
1845

    
1846
-- * Disk state
1847

    
1848
dsDiskOverhead :: String
1849
dsDiskOverhead = "disk_overhead"
1850

    
1851
dsDiskReserved :: String
1852
dsDiskReserved = "disk_reserved"
1853

    
1854
dsDiskTotal :: String
1855
dsDiskTotal = "disk_total"
1856

    
1857
dsDefaults :: Map String Int
1858
dsDefaults =
1859
  Map.fromList
1860
  [(dsDiskTotal, 0),
1861
   (dsDiskReserved, 0),
1862
   (dsDiskOverhead, 0)]
1863

    
1864
dssParameterTypes :: Map String VType
1865
dssParameterTypes =
1866
  Map.fromList [(dsDiskTotal, VTypeInt),
1867
                (dsDiskReserved, VTypeInt),
1868
                (dsDiskOverhead, VTypeInt)]
1869

    
1870
dssParameters :: FrozenSet String
1871
dssParameters =
1872
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1873

    
1874
dsValidTypes :: FrozenSet String
1875
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1876

    
1877
-- Backend parameter names
1878

    
1879
beAlwaysFailover :: String
1880
beAlwaysFailover = "always_failover"
1881

    
1882
beAutoBalance :: String
1883
beAutoBalance = "auto_balance"
1884

    
1885
beMaxmem :: String
1886
beMaxmem = "maxmem"
1887

    
1888
-- | Deprecated and replaced by max and min mem
1889
beMemory :: String
1890
beMemory = "memory"
1891

    
1892
beMinmem :: String
1893
beMinmem = "minmem"
1894

    
1895
beSpindleUse :: String
1896
beSpindleUse = "spindle_use"
1897

    
1898
beVcpus :: String
1899
beVcpus = "vcpus"
1900

    
1901
besParameterTypes :: Map String VType
1902
besParameterTypes =
1903
  Map.fromList [(beAlwaysFailover, VTypeBool),
1904
                (beAutoBalance, VTypeBool),
1905
                (beMaxmem, VTypeSize),
1906
                (beMinmem, VTypeSize),
1907
                (beSpindleUse, VTypeInt),
1908
                (beVcpus, VTypeInt)]
1909

    
1910
besParameterTitles :: Map String String
1911
besParameterTitles =
1912
  Map.fromList [(beAutoBalance, "Auto_balance"),
1913
                (beMinmem, "ConfigMinMem"),
1914
                (beVcpus, "ConfigVCPUs"),
1915
                (beMaxmem, "ConfigMaxMem")]
1916

    
1917
besParameterCompat :: Map String VType
1918
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1919

    
1920
besParameters :: FrozenSet String
1921
besParameters =
1922
  ConstantUtils.mkSet [beAlwaysFailover,
1923
                       beAutoBalance,
1924
                       beMaxmem,
1925
                       beMinmem,
1926
                       beSpindleUse,
1927
                       beVcpus]
1928

    
1929
-- | Instance specs
1930
--
1931
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1932

    
1933
ispecMemSize :: String
1934
ispecMemSize = ConstantUtils.ispecMemSize
1935

    
1936
ispecCpuCount :: String
1937
ispecCpuCount = ConstantUtils.ispecCpuCount
1938

    
1939
ispecDiskCount :: String
1940
ispecDiskCount = ConstantUtils.ispecDiskCount
1941

    
1942
ispecDiskSize :: String
1943
ispecDiskSize = ConstantUtils.ispecDiskSize
1944

    
1945
ispecNicCount :: String
1946
ispecNicCount = ConstantUtils.ispecNicCount
1947

    
1948
ispecSpindleUse :: String
1949
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1950

    
1951
ispecsParameterTypes :: Map String VType
1952
ispecsParameterTypes =
1953
  Map.fromList
1954
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1955
   (ConstantUtils.ispecCpuCount, VTypeInt),
1956
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1957
   (ConstantUtils.ispecMemSize, VTypeInt),
1958
   (ConstantUtils.ispecNicCount, VTypeInt),
1959
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1960

    
1961
ispecsParameters :: FrozenSet String
1962
ispecsParameters =
1963
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1964
                       ConstantUtils.ispecDiskCount,
1965
                       ConstantUtils.ispecDiskSize,
1966
                       ConstantUtils.ispecMemSize,
1967
                       ConstantUtils.ispecNicCount,
1968
                       ConstantUtils.ispecSpindleUse]
1969

    
1970
ispecsMinmax :: String
1971
ispecsMinmax = ConstantUtils.ispecsMinmax
1972

    
1973
ispecsMax :: String
1974
ispecsMax = "max"
1975

    
1976
ispecsMin :: String
1977
ispecsMin = "min"
1978

    
1979
ispecsStd :: String
1980
ispecsStd = ConstantUtils.ispecsStd
1981

    
1982
ipolicyDts :: String
1983
ipolicyDts = ConstantUtils.ipolicyDts
1984

    
1985
ipolicyVcpuRatio :: String
1986
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1987

    
1988
ipolicySpindleRatio :: String
1989
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
1990

    
1991
ispecsMinmaxKeys :: FrozenSet String
1992
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1993

    
1994
ipolicyParameters :: FrozenSet String
1995
ipolicyParameters =
1996
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1997
                       ConstantUtils.ipolicySpindleRatio]
1998

    
1999
ipolicyAllKeys :: FrozenSet String
2000
ipolicyAllKeys =
2001
  ConstantUtils.union ipolicyParameters $
2002
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
2003
                       ConstantUtils.ispecsMinmax,
2004
                       ispecsStd]
2005

    
2006
-- | Node parameter names
2007

    
2008
ndExclusiveStorage :: String
2009
ndExclusiveStorage = "exclusive_storage"
2010

    
2011
ndOobProgram :: String
2012
ndOobProgram = "oob_program"
2013

    
2014
ndSpindleCount :: String
2015
ndSpindleCount = "spindle_count"
2016

    
2017
ndOvs :: String
2018
ndOvs = "ovs"
2019

    
2020
ndOvsLink :: String
2021
ndOvsLink = "ovs_link"
2022

    
2023
ndOvsName :: String
2024
ndOvsName = "ovs_name"
2025

    
2026
ndsParameterTypes :: Map String VType
2027
ndsParameterTypes =
2028
  Map.fromList
2029
  [(ndExclusiveStorage, VTypeBool),
2030
   (ndOobProgram, VTypeString),
2031
   (ndOvs, VTypeBool),
2032
   (ndOvsLink, VTypeMaybeString),
2033
   (ndOvsName, VTypeMaybeString),
2034
   (ndSpindleCount, VTypeInt)]
2035

    
2036
ndsParameters :: FrozenSet String
2037
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
2038

    
2039
ndsParameterTitles :: Map String String
2040
ndsParameterTitles =
2041
  Map.fromList
2042
  [(ndExclusiveStorage, "ExclusiveStorage"),
2043
   (ndOobProgram, "OutOfBandProgram"),
2044
   (ndOvs, "OpenvSwitch"),
2045
   (ndOvsLink, "OpenvSwitchLink"),
2046
   (ndOvsName, "OpenvSwitchName"),
2047
   (ndSpindleCount, "SpindleCount")]
2048

    
2049
-- * Logical Disks parameters
2050

    
2051
ldpAccess :: String
2052
ldpAccess = "access"
2053

    
2054
ldpBarriers :: String
2055
ldpBarriers = "disabled-barriers"
2056

    
2057
ldpDefaultMetavg :: String
2058
ldpDefaultMetavg = "default-metavg"
2059

    
2060
ldpDelayTarget :: String
2061
ldpDelayTarget = "c-delay-target"
2062

    
2063
ldpDiskCustom :: String
2064
ldpDiskCustom = "disk-custom"
2065

    
2066
ldpDynamicResync :: String
2067
ldpDynamicResync = "dynamic-resync"
2068

    
2069
ldpFillTarget :: String
2070
ldpFillTarget = "c-fill-target"
2071

    
2072
ldpMaxRate :: String
2073
ldpMaxRate = "c-max-rate"
2074

    
2075
ldpMinRate :: String
2076
ldpMinRate = "c-min-rate"
2077

    
2078
ldpNetCustom :: String
2079
ldpNetCustom = "net-custom"
2080

    
2081
ldpNoMetaFlush :: String
2082
ldpNoMetaFlush = "disable-meta-flush"
2083

    
2084
ldpPlanAhead :: String
2085
ldpPlanAhead = "c-plan-ahead"
2086

    
2087
ldpPool :: String
2088
ldpPool = "pool"
2089

    
2090
ldpProtocol :: String
2091
ldpProtocol = "protocol"
2092

    
2093
ldpResyncRate :: String
2094
ldpResyncRate = "resync-rate"
2095

    
2096
ldpStripes :: String
2097
ldpStripes = "stripes"
2098

    
2099
diskLdTypes :: Map String VType
2100
diskLdTypes =
2101
  Map.fromList
2102
  [(ldpAccess, VTypeString),
2103
   (ldpResyncRate, VTypeInt),
2104
   (ldpStripes, VTypeInt),
2105
   (ldpBarriers, VTypeString),
2106
   (ldpNoMetaFlush, VTypeBool),
2107
   (ldpDefaultMetavg, VTypeString),
2108
   (ldpDiskCustom, VTypeString),
2109
   (ldpNetCustom, VTypeString),
2110
   (ldpProtocol, VTypeString),
2111
   (ldpDynamicResync, VTypeBool),
2112
   (ldpPlanAhead, VTypeInt),
2113
   (ldpFillTarget, VTypeInt),
2114
   (ldpDelayTarget, VTypeInt),
2115
   (ldpMaxRate, VTypeInt),
2116
   (ldpMinRate, VTypeInt),
2117
   (ldpPool, VTypeString)]
2118

    
2119
diskLdParameters :: FrozenSet String
2120
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2121

    
2122
-- * Disk template parameters
2123
--
2124
-- Disk template parameters can be set/changed by the user via
2125
-- gnt-cluster and gnt-group)
2126

    
2127
drbdResyncRate :: String
2128
drbdResyncRate = "resync-rate"
2129

    
2130
drbdDataStripes :: String
2131
drbdDataStripes = "data-stripes"
2132

    
2133
drbdMetaStripes :: String
2134
drbdMetaStripes = "meta-stripes"
2135

    
2136
drbdDiskBarriers :: String
2137
drbdDiskBarriers = "disk-barriers"
2138

    
2139
drbdMetaBarriers :: String
2140
drbdMetaBarriers = "meta-barriers"
2141

    
2142
drbdDefaultMetavg :: String
2143
drbdDefaultMetavg = "metavg"
2144

    
2145
drbdDiskCustom :: String
2146
drbdDiskCustom = "disk-custom"
2147

    
2148
drbdNetCustom :: String
2149
drbdNetCustom = "net-custom"
2150

    
2151
drbdProtocol :: String
2152
drbdProtocol = "protocol"
2153

    
2154
drbdDynamicResync :: String
2155
drbdDynamicResync = "dynamic-resync"
2156

    
2157
drbdPlanAhead :: String
2158
drbdPlanAhead = "c-plan-ahead"
2159

    
2160
drbdFillTarget :: String
2161
drbdFillTarget = "c-fill-target"
2162

    
2163
drbdDelayTarget :: String
2164
drbdDelayTarget = "c-delay-target"
2165

    
2166
drbdMaxRate :: String
2167
drbdMaxRate = "c-max-rate"
2168

    
2169
drbdMinRate :: String
2170
drbdMinRate = "c-min-rate"
2171

    
2172
lvStripes :: String
2173
lvStripes = "stripes"
2174

    
2175
rbdAccess :: String
2176
rbdAccess = "access"
2177

    
2178
rbdPool :: String
2179
rbdPool = "pool"
2180

    
2181
diskDtTypes :: Map String VType
2182
diskDtTypes =
2183
  Map.fromList [(drbdResyncRate, VTypeInt),
2184
                (drbdDataStripes, VTypeInt),
2185
                (drbdMetaStripes, VTypeInt),
2186
                (drbdDiskBarriers, VTypeString),
2187
                (drbdMetaBarriers, VTypeBool),
2188
                (drbdDefaultMetavg, VTypeString),
2189
                (drbdDiskCustom, VTypeString),
2190
                (drbdNetCustom, VTypeString),
2191
                (drbdProtocol, VTypeString),
2192
                (drbdDynamicResync, VTypeBool),
2193
                (drbdPlanAhead, VTypeInt),
2194
                (drbdFillTarget, VTypeInt),
2195
                (drbdDelayTarget, VTypeInt),
2196
                (drbdMaxRate, VTypeInt),
2197
                (drbdMinRate, VTypeInt),
2198
                (lvStripes, VTypeInt),
2199
                (rbdAccess, VTypeString),
2200
                (rbdPool, VTypeString)]
2201

    
2202
diskDtParameters :: FrozenSet String
2203
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2204

    
2205
-- * Dynamic disk parameters
2206

    
2207
ddpLocalIp :: String
2208
ddpLocalIp = "local-ip"
2209

    
2210
ddpRemoteIp :: String
2211
ddpRemoteIp = "remote-ip"
2212

    
2213
ddpPort :: String
2214
ddpPort = "port"
2215

    
2216
ddpLocalMinor :: String
2217
ddpLocalMinor = "local-minor"
2218

    
2219
ddpRemoteMinor :: String
2220
ddpRemoteMinor = "remote-minor"
2221

    
2222
-- * OOB supported commands
2223

    
2224
oobPowerOn :: String
2225
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2226

    
2227
oobPowerOff :: String
2228
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2229

    
2230
oobPowerCycle :: String
2231
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2232

    
2233
oobPowerStatus :: String
2234
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2235

    
2236
oobHealth :: String
2237
oobHealth = Types.oobCommandToRaw OobHealth
2238

    
2239
oobCommands :: FrozenSet String
2240
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2241

    
2242
oobPowerStatusPowered :: String
2243
oobPowerStatusPowered = "powered"
2244

    
2245
-- | 60 seconds
2246
oobTimeout :: Int
2247
oobTimeout = 60
2248

    
2249
-- | 2 seconds
2250
oobPowerDelay :: Double
2251
oobPowerDelay = 2.0
2252

    
2253
oobStatusCritical :: String
2254
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2255

    
2256
oobStatusOk :: String
2257
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2258

    
2259
oobStatusUnknown :: String
2260
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2261

    
2262
oobStatusWarning :: String
2263
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2264

    
2265
oobStatuses :: FrozenSet String
2266
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2267

    
2268
-- | Instance Parameters Profile
2269
ppDefault :: String
2270
ppDefault = "default"
2271

    
2272
-- * nic* constants are used inside the ganeti config
2273

    
2274
nicLink :: String
2275
nicLink = "link"
2276

    
2277
nicMode :: String
2278
nicMode = "mode"
2279

    
2280
nicVlan :: String
2281
nicVlan = "vlan"
2282

    
2283
nicsParameterTypes :: Map String VType
2284
nicsParameterTypes =
2285
  Map.fromList [(nicMode, vtypeString),
2286
                (nicLink, vtypeString),
2287
                (nicVlan, vtypeString)]
2288

    
2289
nicsParameters :: FrozenSet String
2290
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2291

    
2292
nicModeBridged :: String
2293
nicModeBridged = Types.nICModeToRaw NMBridged
2294

    
2295
nicModeRouted :: String
2296
nicModeRouted = Types.nICModeToRaw NMRouted
2297

    
2298
nicModeOvs :: String
2299
nicModeOvs = Types.nICModeToRaw NMOvs
2300

    
2301
nicIpPool :: String
2302
nicIpPool = Types.nICModeToRaw NMPool
2303

    
2304
nicValidModes :: FrozenSet String
2305
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2306

    
2307
releaseAction :: String
2308
releaseAction = "release"
2309

    
2310
reserveAction :: String
2311
reserveAction = "reserve"
2312

    
2313
-- * idisk* constants are used in opcodes, to create/change disks
2314

    
2315
idiskAdopt :: String
2316
idiskAdopt = "adopt"
2317

    
2318
idiskMetavg :: String
2319
idiskMetavg = "metavg"
2320

    
2321
idiskMode :: String
2322
idiskMode = "mode"
2323

    
2324
idiskName :: String
2325
idiskName = "name"
2326

    
2327
idiskSize :: String
2328
idiskSize = "size"
2329

    
2330
idiskSpindles :: String
2331
idiskSpindles = "spindles"
2332

    
2333
idiskVg :: String
2334
idiskVg = "vg"
2335

    
2336
idiskProvider :: String
2337
idiskProvider = "provider"
2338

    
2339
idiskAccess :: String
2340
idiskAccess = "access"
2341

    
2342
idiskParamsTypes :: Map String VType
2343
idiskParamsTypes =
2344
  Map.fromList [(idiskSize, VTypeSize),
2345
                (idiskSpindles, VTypeInt),
2346
                (idiskMode, VTypeString),
2347
                (idiskAdopt, VTypeString),
2348
                (idiskVg, VTypeString),
2349
                (idiskMetavg, VTypeString),
2350
                (idiskProvider, VTypeString),
2351
                (idiskAccess, VTypeString),
2352
                (idiskName, VTypeMaybeString)]
2353

    
2354
idiskParams :: FrozenSet String
2355
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2356

    
2357
modifiableIdiskParamsTypes :: Map String VType
2358
modifiableIdiskParamsTypes =
2359
  Map.fromList [(idiskMode, VTypeString),
2360
                (idiskName, VTypeString)]
2361

    
2362
modifiableIdiskParams :: FrozenSet String
2363
modifiableIdiskParams =
2364
  ConstantUtils.mkSet (Map.keys modifiableIdiskParamsTypes)
2365

    
2366
-- * inic* constants are used in opcodes, to create/change nics
2367

    
2368
inicBridge :: String
2369
inicBridge = "bridge"
2370

    
2371
inicIp :: String
2372
inicIp = "ip"
2373

    
2374
inicLink :: String
2375
inicLink = "link"
2376

    
2377
inicMac :: String
2378
inicMac = "mac"
2379

    
2380
inicMode :: String
2381
inicMode = "mode"
2382

    
2383
inicName :: String
2384
inicName = "name"
2385

    
2386
inicNetwork :: String
2387
inicNetwork = "network"
2388

    
2389
inicVlan :: String
2390
inicVlan = "vlan"
2391

    
2392
inicParamsTypes :: Map String VType
2393
inicParamsTypes =
2394
  Map.fromList [(inicBridge, VTypeMaybeString),
2395
                (inicIp, VTypeMaybeString),
2396
                (inicLink, VTypeString),
2397
                (inicMac, VTypeString),
2398
                (inicMode, VTypeString),
2399
                (inicName, VTypeMaybeString),
2400
                (inicNetwork, VTypeMaybeString),
2401
                (inicVlan, VTypeMaybeString)]
2402

    
2403
inicParams :: FrozenSet String
2404
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2405

    
2406
-- * Hypervisor constants
2407

    
2408
htXenPvm :: String
2409
htXenPvm = Types.hypervisorToRaw XenPvm
2410

    
2411
htFake :: String
2412
htFake = Types.hypervisorToRaw Fake
2413

    
2414
htXenHvm :: String
2415
htXenHvm = Types.hypervisorToRaw XenHvm
2416

    
2417
htKvm :: String
2418
htKvm = Types.hypervisorToRaw Kvm
2419

    
2420
htChroot :: String
2421
htChroot = Types.hypervisorToRaw Chroot
2422

    
2423
htLxc :: String
2424
htLxc = Types.hypervisorToRaw Lxc
2425

    
2426
hyperTypes :: FrozenSet String
2427
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2428

    
2429
htsReqPort :: FrozenSet String
2430
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2431

    
2432
vncBasePort :: Int
2433
vncBasePort = 5900
2434

    
2435
vncDefaultBindAddress :: String
2436
vncDefaultBindAddress = ip4AddressAny
2437

    
2438
-- * NIC types
2439

    
2440
htNicE1000 :: String
2441
htNicE1000 = "e1000"
2442

    
2443
htNicI82551 :: String
2444
htNicI82551 = "i82551"
2445

    
2446
htNicI8259er :: String
2447
htNicI8259er = "i82559er"
2448

    
2449
htNicI85557b :: String
2450
htNicI85557b = "i82557b"
2451

    
2452
htNicNe2kIsa :: String
2453
htNicNe2kIsa = "ne2k_isa"
2454

    
2455
htNicNe2kPci :: String
2456
htNicNe2kPci = "ne2k_pci"
2457

    
2458
htNicParavirtual :: String
2459
htNicParavirtual = "paravirtual"
2460

    
2461
htNicPcnet :: String
2462
htNicPcnet = "pcnet"
2463

    
2464
htNicRtl8139 :: String
2465
htNicRtl8139 = "rtl8139"
2466

    
2467
htHvmValidNicTypes :: FrozenSet String
2468
htHvmValidNicTypes =
2469
  ConstantUtils.mkSet [htNicE1000,
2470
                       htNicNe2kIsa,
2471
                       htNicNe2kPci,
2472
                       htNicParavirtual,
2473
                       htNicRtl8139]
2474

    
2475
htKvmValidNicTypes :: FrozenSet String
2476
htKvmValidNicTypes =
2477
  ConstantUtils.mkSet [htNicE1000,
2478
                       htNicI82551,
2479
                       htNicI8259er,
2480
                       htNicI85557b,
2481
                       htNicNe2kIsa,
2482
                       htNicNe2kPci,
2483
                       htNicParavirtual,
2484
                       htNicPcnet,
2485
                       htNicRtl8139]
2486

    
2487
-- * Vif types
2488

    
2489
-- | Default vif type in xen-hvm
2490
htHvmVifIoemu :: String
2491
htHvmVifIoemu = "ioemu"
2492

    
2493
htHvmVifVif :: String
2494
htHvmVifVif = "vif"
2495

    
2496
htHvmValidVifTypes :: FrozenSet String
2497
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2498

    
2499
-- * Disk types
2500

    
2501
htDiskIde :: String
2502
htDiskIde = "ide"
2503

    
2504
htDiskIoemu :: String
2505
htDiskIoemu = "ioemu"
2506

    
2507
htDiskMtd :: String
2508
htDiskMtd = "mtd"
2509

    
2510
htDiskParavirtual :: String
2511
htDiskParavirtual = "paravirtual"
2512

    
2513
htDiskPflash :: String
2514
htDiskPflash = "pflash"
2515

    
2516
htDiskScsi :: String
2517
htDiskScsi = "scsi"
2518

    
2519
htDiskSd :: String
2520
htDiskSd = "sd"
2521

    
2522
htHvmValidDiskTypes :: FrozenSet String
2523
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2524

    
2525
htKvmValidDiskTypes :: FrozenSet String
2526
htKvmValidDiskTypes =
2527
  ConstantUtils.mkSet [htDiskIde,
2528
                       htDiskMtd,
2529
                       htDiskParavirtual,
2530
                       htDiskPflash,
2531
                       htDiskScsi,
2532
                       htDiskSd]
2533

    
2534
htCacheDefault :: String
2535
htCacheDefault = "default"
2536

    
2537
htCacheNone :: String
2538
htCacheNone = "none"
2539

    
2540
htCacheWback :: String
2541
htCacheWback = "writeback"
2542

    
2543
htCacheWthrough :: String
2544
htCacheWthrough = "writethrough"
2545

    
2546
htValidCacheTypes :: FrozenSet String
2547
htValidCacheTypes =
2548
  ConstantUtils.mkSet [htCacheDefault,
2549
                       htCacheNone,
2550
                       htCacheWback,
2551
                       htCacheWthrough]
2552

    
2553
-- * Mouse types
2554

    
2555
htMouseMouse :: String
2556
htMouseMouse = "mouse"
2557

    
2558
htMouseTablet :: String
2559
htMouseTablet = "tablet"
2560

    
2561
htKvmValidMouseTypes :: FrozenSet String
2562
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2563

    
2564
-- * Boot order
2565

    
2566
htBoCdrom :: String
2567
htBoCdrom = "cdrom"
2568

    
2569
htBoDisk :: String
2570
htBoDisk = "disk"
2571

    
2572
htBoFloppy :: String
2573
htBoFloppy = "floppy"
2574

    
2575
htBoNetwork :: String
2576
htBoNetwork = "network"
2577

    
2578
htKvmValidBoTypes :: FrozenSet String
2579
htKvmValidBoTypes =
2580
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2581

    
2582
-- * SPICE lossless image compression options
2583

    
2584
htKvmSpiceLosslessImgComprAutoGlz :: String
2585
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2586

    
2587
htKvmSpiceLosslessImgComprAutoLz :: String
2588
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2589

    
2590
htKvmSpiceLosslessImgComprGlz :: String
2591
htKvmSpiceLosslessImgComprGlz = "glz"
2592

    
2593
htKvmSpiceLosslessImgComprLz :: String
2594
htKvmSpiceLosslessImgComprLz = "lz"
2595

    
2596
htKvmSpiceLosslessImgComprOff :: String
2597
htKvmSpiceLosslessImgComprOff = "off"
2598

    
2599
htKvmSpiceLosslessImgComprQuic :: String
2600
htKvmSpiceLosslessImgComprQuic = "quic"
2601

    
2602
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2603
htKvmSpiceValidLosslessImgComprOptions =
2604
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2605
                       htKvmSpiceLosslessImgComprAutoLz,
2606
                       htKvmSpiceLosslessImgComprGlz,
2607
                       htKvmSpiceLosslessImgComprLz,
2608
                       htKvmSpiceLosslessImgComprOff,
2609
                       htKvmSpiceLosslessImgComprQuic]
2610

    
2611
htKvmSpiceLossyImgComprAlways :: String
2612
htKvmSpiceLossyImgComprAlways = "always"
2613

    
2614
htKvmSpiceLossyImgComprAuto :: String
2615
htKvmSpiceLossyImgComprAuto = "auto"
2616

    
2617
htKvmSpiceLossyImgComprNever :: String
2618
htKvmSpiceLossyImgComprNever = "never"
2619

    
2620
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2621
htKvmSpiceValidLossyImgComprOptions =
2622
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2623
                       htKvmSpiceLossyImgComprAuto,
2624
                       htKvmSpiceLossyImgComprNever]
2625

    
2626
-- * SPICE video stream detection
2627

    
2628
htKvmSpiceVideoStreamDetectionAll :: String
2629
htKvmSpiceVideoStreamDetectionAll = "all"
2630

    
2631
htKvmSpiceVideoStreamDetectionFilter :: String
2632
htKvmSpiceVideoStreamDetectionFilter = "filter"
2633

    
2634
htKvmSpiceVideoStreamDetectionOff :: String
2635
htKvmSpiceVideoStreamDetectionOff = "off"
2636

    
2637
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2638
htKvmSpiceValidVideoStreamDetectionOptions =
2639
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2640
                       htKvmSpiceVideoStreamDetectionFilter,
2641
                       htKvmSpiceVideoStreamDetectionOff]
2642

    
2643
-- * Security models
2644

    
2645
htSmNone :: String
2646
htSmNone = "none"
2647

    
2648
htSmPool :: String
2649
htSmPool = "pool"
2650

    
2651
htSmUser :: String
2652
htSmUser = "user"
2653

    
2654
htKvmValidSmTypes :: FrozenSet String
2655
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2656

    
2657
-- * Kvm flag values
2658

    
2659
htKvmDisabled :: String
2660
htKvmDisabled = "disabled"
2661

    
2662
htKvmEnabled :: String
2663
htKvmEnabled = "enabled"
2664

    
2665
htKvmFlagValues :: FrozenSet String
2666
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2667

    
2668
-- * Migration type
2669

    
2670
htMigrationLive :: String
2671
htMigrationLive = Types.migrationModeToRaw MigrationLive
2672

    
2673
htMigrationNonlive :: String
2674
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2675

    
2676
htMigrationModes :: FrozenSet String
2677
htMigrationModes =
2678
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2679

    
2680
-- * Cluster verify steps
2681

    
2682
verifyNplusoneMem :: String
2683
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2684

    
2685
verifyOptionalChecks :: FrozenSet String
2686
verifyOptionalChecks =
2687
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2688

    
2689
-- * Cluster Verify error classes
2690

    
2691
cvTcluster :: String
2692
cvTcluster = "cluster"
2693

    
2694
cvTgroup :: String
2695
cvTgroup = "group"
2696

    
2697
cvTnode :: String
2698
cvTnode = "node"
2699

    
2700
cvTinstance :: String
2701
cvTinstance = "instance"
2702

    
2703
-- * Cluster Verify error codes and documentation
2704

    
2705
cvEclustercert :: (String, String, String)
2706
cvEclustercert =
2707
  ("cluster",
2708
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2709
   "Cluster certificate files verification failure")
2710

    
2711
cvEclustercfg :: (String, String, String)
2712
cvEclustercfg =
2713
  ("cluster",
2714
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2715
   "Cluster configuration verification failure")
2716

    
2717
cvEclusterdanglinginst :: (String, String, String)
2718
cvEclusterdanglinginst =
2719
  ("node",
2720
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2721
   "Some instances have a non-existing primary node")
2722

    
2723
cvEclusterdanglingnodes :: (String, String, String)
2724
cvEclusterdanglingnodes =
2725
  ("node",
2726
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2727
   "Some nodes belong to non-existing groups")
2728

    
2729
cvEclusterfilecheck :: (String, String, String)
2730
cvEclusterfilecheck =
2731
  ("cluster",
2732
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2733
   "Cluster configuration verification failure")
2734

    
2735
cvEgroupdifferentpvsize :: (String, String, String)
2736
cvEgroupdifferentpvsize =
2737
  ("group",
2738
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2739
   "PVs in the group have different sizes")
2740

    
2741
cvEinstancebadnode :: (String, String, String)
2742
cvEinstancebadnode =
2743
  ("instance",
2744
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2745
   "Instance marked as running lives on an offline node")
2746

    
2747
cvEinstancedown :: (String, String, String)
2748
cvEinstancedown =
2749
  ("instance",
2750
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2751
   "Instance not running on its primary node")
2752

    
2753
cvEinstancefaultydisk :: (String, String, String)
2754
cvEinstancefaultydisk =
2755
  ("instance",
2756
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2757
   "Impossible to retrieve status for a disk")
2758

    
2759
cvEinstancelayout :: (String, String, String)
2760
cvEinstancelayout =
2761
  ("instance",
2762
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2763
   "Instance has multiple secondary nodes")
2764

    
2765
cvEinstancemissingcfgparameter :: (String, String, String)
2766
cvEinstancemissingcfgparameter =
2767
  ("instance",
2768
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2769
   "A configuration parameter for an instance is missing")
2770

    
2771
cvEinstancemissingdisk :: (String, String, String)
2772
cvEinstancemissingdisk =
2773
  ("instance",
2774
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2775
   "Missing volume on an instance")
2776

    
2777
cvEinstancepolicy :: (String, String, String)
2778
cvEinstancepolicy =
2779
  ("instance",
2780
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2781
   "Instance does not meet policy")
2782

    
2783
cvEinstancesplitgroups :: (String, String, String)
2784
cvEinstancesplitgroups =
2785
  ("instance",
2786
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2787
   "Instance with primary and secondary nodes in different groups")
2788

    
2789
cvEinstanceunsuitablenode :: (String, String, String)
2790
cvEinstanceunsuitablenode =
2791
  ("instance",
2792
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2793
   "Instance running on nodes that are not suitable for it")
2794

    
2795
cvEinstancewrongnode :: (String, String, String)
2796
cvEinstancewrongnode =
2797
  ("instance",
2798
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2799
   "Instance running on the wrong node")
2800

    
2801
cvEnodedrbd :: (String, String, String)
2802
cvEnodedrbd =
2803
  ("node",
2804
   Types.cVErrorCodeToRaw CvENODEDRBD,
2805
   "Error parsing the DRBD status file")
2806

    
2807
cvEnodedrbdhelper :: (String, String, String)
2808
cvEnodedrbdhelper =
2809
  ("node",
2810
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2811
   "Error caused by the DRBD helper")
2812

    
2813
cvEnodedrbdversion :: (String, String, String)
2814
cvEnodedrbdversion =
2815
  ("node",
2816
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2817
   "DRBD version mismatch within a node group")
2818

    
2819
cvEnodefilecheck :: (String, String, String)
2820
cvEnodefilecheck =
2821
  ("node",
2822
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2823
   "Error retrieving the checksum of the node files")
2824

    
2825
cvEnodefilestoragepaths :: (String, String, String)
2826
cvEnodefilestoragepaths =
2827
  ("node",
2828
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2829
   "Detected bad file storage paths")
2830

    
2831
cvEnodefilestoragepathunusable :: (String, String, String)
2832
cvEnodefilestoragepathunusable =
2833
  ("node",
2834
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2835
   "File storage path unusable")
2836

    
2837
cvEnodehooks :: (String, String, String)
2838
cvEnodehooks =
2839
  ("node",
2840
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2841
   "Communication failure in hooks execution")
2842

    
2843
cvEnodehv :: (String, String, String)
2844
cvEnodehv =
2845
  ("node",
2846
   Types.cVErrorCodeToRaw CvENODEHV,
2847
   "Hypervisor parameters verification failure")
2848

    
2849
cvEnodelvm :: (String, String, String)
2850
cvEnodelvm =
2851
  ("node",
2852
   Types.cVErrorCodeToRaw CvENODELVM,
2853
   "LVM-related node error")
2854

    
2855
cvEnoden1 :: (String, String, String)
2856
cvEnoden1 =
2857
  ("node",
2858
   Types.cVErrorCodeToRaw CvENODEN1,
2859
   "Not enough memory to accommodate instance failovers")
2860

    
2861
cvEnodenet :: (String, String, String)
2862
cvEnodenet =
2863
  ("node",
2864
   Types.cVErrorCodeToRaw CvENODENET,
2865
   "Network-related node error")
2866

    
2867
cvEnodeoobpath :: (String, String, String)
2868
cvEnodeoobpath =
2869
  ("node",
2870
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2871
   "Invalid Out Of Band path")
2872

    
2873
cvEnodeorphaninstance :: (String, String, String)
2874
cvEnodeorphaninstance =
2875
  ("node",
2876
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2877
   "Unknown intance running on a node")
2878

    
2879
cvEnodeorphanlv :: (String, String, String)
2880
cvEnodeorphanlv =
2881
  ("node",
2882
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2883
   "Unknown LVM logical volume")
2884

    
2885
cvEnodeos :: (String, String, String)
2886
cvEnodeos =
2887
  ("node",
2888
   Types.cVErrorCodeToRaw CvENODEOS,
2889
   "OS-related node error")
2890

    
2891
cvEnoderpc :: (String, String, String)
2892
cvEnoderpc =
2893
  ("node",
2894
   Types.cVErrorCodeToRaw CvENODERPC,
2895
   "Error during connection to the primary node of an instance")
2896

    
2897
cvEnodesetup :: (String, String, String)
2898
cvEnodesetup =
2899
  ("node",
2900
   Types.cVErrorCodeToRaw CvENODESETUP,
2901
   "Node setup error")
2902

    
2903
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2904
cvEnodesharedfilestoragepathunusable =
2905
  ("node",
2906
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2907
   "Shared file storage path unusable")
2908

    
2909
cvEnodessh :: (String, String, String)
2910
cvEnodessh =
2911
  ("node",
2912
   Types.cVErrorCodeToRaw CvENODESSH,
2913
   "SSH-related node error")
2914

    
2915
cvEnodetime :: (String, String, String)
2916
cvEnodetime =
2917
  ("node",
2918
   Types.cVErrorCodeToRaw CvENODETIME,
2919
   "Node returned invalid time")
2920

    
2921
cvEnodeuserscripts :: (String, String, String)
2922
cvEnodeuserscripts =
2923
  ("node",
2924
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2925
   "User scripts not present or not executable")
2926

    
2927
cvEnodeversion :: (String, String, String)
2928
cvEnodeversion =
2929
  ("node",
2930
   Types.cVErrorCodeToRaw CvENODEVERSION,
2931
   "Protocol version mismatch or Ganeti version mismatch")
2932

    
2933
cvAllEcodes :: FrozenSet (String, String, String)
2934
cvAllEcodes =
2935
  ConstantUtils.mkSet
2936
  [cvEclustercert,
2937
   cvEclustercfg,
2938
   cvEclusterdanglinginst,
2939
   cvEclusterdanglingnodes,
2940
   cvEclusterfilecheck,
2941
   cvEgroupdifferentpvsize,
2942
   cvEinstancebadnode,
2943
   cvEinstancedown,
2944
   cvEinstancefaultydisk,
2945
   cvEinstancelayout,
2946
   cvEinstancemissingcfgparameter,
2947
   cvEinstancemissingdisk,
2948
   cvEinstancepolicy,
2949
   cvEinstancesplitgroups,
2950
   cvEinstanceunsuitablenode,
2951
   cvEinstancewrongnode,
2952
   cvEnodedrbd,
2953
   cvEnodedrbdhelper,
2954
   cvEnodedrbdversion,
2955
   cvEnodefilecheck,
2956
   cvEnodefilestoragepaths,
2957
   cvEnodefilestoragepathunusable,
2958
   cvEnodehooks,
2959
   cvEnodehv,
2960
   cvEnodelvm,
2961
   cvEnoden1,
2962
   cvEnodenet,
2963
   cvEnodeoobpath,
2964
   cvEnodeorphaninstance,
2965
   cvEnodeorphanlv,
2966
   cvEnodeos,
2967
   cvEnoderpc,
2968
   cvEnodesetup,
2969
   cvEnodesharedfilestoragepathunusable,
2970
   cvEnodessh,
2971
   cvEnodetime,
2972
   cvEnodeuserscripts,
2973
   cvEnodeversion]
2974

    
2975
cvAllEcodesStrings :: FrozenSet String
2976
cvAllEcodesStrings =
2977
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2978

    
2979
-- * Node verify constants
2980

    
2981
nvBridges :: String
2982
nvBridges = "bridges"
2983

    
2984
nvDrbdhelper :: String
2985
nvDrbdhelper = "drbd-helper"
2986

    
2987
nvDrbdversion :: String
2988
nvDrbdversion = "drbd-version"
2989

    
2990
nvDrbdlist :: String
2991
nvDrbdlist = "drbd-list"
2992

    
2993
nvExclusivepvs :: String
2994
nvExclusivepvs = "exclusive-pvs"
2995

    
2996
nvFilelist :: String
2997
nvFilelist = "filelist"
2998

    
2999
nvAcceptedStoragePaths :: String
3000
nvAcceptedStoragePaths = "allowed-file-storage-paths"
3001

    
3002
nvFileStoragePath :: String
3003
nvFileStoragePath = "file-storage-path"
3004

    
3005
nvSharedFileStoragePath :: String
3006
nvSharedFileStoragePath = "shared-file-storage-path"
3007

    
3008
nvHvinfo :: String
3009
nvHvinfo = "hvinfo"
3010

    
3011
nvHvparams :: String
3012
nvHvparams = "hvparms"
3013

    
3014
nvHypervisor :: String
3015
nvHypervisor = "hypervisor"
3016

    
3017
nvInstancelist :: String
3018
nvInstancelist = "instancelist"
3019

    
3020
nvLvlist :: String
3021
nvLvlist = "lvlist"
3022

    
3023
nvMasterip :: String
3024
nvMasterip = "master-ip"
3025

    
3026
nvNodelist :: String
3027
nvNodelist = "nodelist"
3028

    
3029
nvNodenettest :: String
3030
nvNodenettest = "node-net-test"
3031

    
3032
nvNodesetup :: String
3033
nvNodesetup = "nodesetup"
3034

    
3035
nvOobPaths :: String
3036
nvOobPaths = "oob-paths"
3037

    
3038
nvOslist :: String
3039
nvOslist = "oslist"
3040

    
3041
nvPvlist :: String
3042
nvPvlist = "pvlist"
3043

    
3044
nvTime :: String
3045
nvTime = "time"
3046

    
3047
nvUserscripts :: String
3048
nvUserscripts = "user-scripts"
3049

    
3050
nvVersion :: String
3051
nvVersion = "version"
3052

    
3053
nvVglist :: String
3054
nvVglist = "vglist"
3055

    
3056
nvNonvmnodes :: String
3057
nvNonvmnodes = "nonvmnodes"
3058

    
3059
-- * Instance status
3060

    
3061
inststAdmindown :: String
3062
inststAdmindown = Types.instanceStatusToRaw StatusDown
3063

    
3064
inststAdminoffline :: String
3065
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3066

    
3067
inststErrordown :: String
3068
inststErrordown = Types.instanceStatusToRaw ErrorDown
3069

    
3070
inststErrorup :: String
3071
inststErrorup = Types.instanceStatusToRaw ErrorUp
3072

    
3073
inststNodedown :: String
3074
inststNodedown = Types.instanceStatusToRaw NodeDown
3075

    
3076
inststNodeoffline :: String
3077
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3078

    
3079
inststRunning :: String
3080
inststRunning = Types.instanceStatusToRaw Running
3081

    
3082
inststWrongnode :: String
3083
inststWrongnode = Types.instanceStatusToRaw WrongNode
3084

    
3085
inststAll :: FrozenSet String
3086
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3087

    
3088
-- * Admin states
3089

    
3090
adminstDown :: String
3091
adminstDown = Types.adminStateToRaw AdminDown
3092

    
3093
adminstOffline :: String
3094
adminstOffline = Types.adminStateToRaw AdminOffline
3095

    
3096
adminstUp :: String
3097
adminstUp = Types.adminStateToRaw AdminUp
3098

    
3099
adminstAll :: FrozenSet String
3100
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3101

    
3102
-- * Node roles
3103

    
3104
nrDrained :: String
3105
nrDrained = Types.nodeRoleToRaw NRDrained
3106

    
3107
nrMaster :: String
3108
nrMaster = Types.nodeRoleToRaw NRMaster
3109

    
3110
nrMcandidate :: String
3111
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3112

    
3113
nrOffline :: String
3114
nrOffline = Types.nodeRoleToRaw NROffline
3115

    
3116
nrRegular :: String
3117
nrRegular = Types.nodeRoleToRaw NRRegular
3118

    
3119
nrAll :: FrozenSet String
3120
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3121

    
3122
-- * SSL certificate check constants (in days)
3123

    
3124
sslCertExpirationError :: Int
3125
sslCertExpirationError = 7
3126

    
3127
sslCertExpirationWarn :: Int
3128
sslCertExpirationWarn = 30
3129

    
3130
-- * Allocator framework constants
3131

    
3132
iallocatorVersion :: Int
3133
iallocatorVersion = 2
3134

    
3135
iallocatorDirIn :: String
3136
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3137

    
3138
iallocatorDirOut :: String
3139
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3140

    
3141
validIallocatorDirections :: FrozenSet String
3142
validIallocatorDirections =
3143
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3144

    
3145
iallocatorModeAlloc :: String
3146
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3147

    
3148
iallocatorModeChgGroup :: String
3149
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3150

    
3151
iallocatorModeMultiAlloc :: String
3152
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3153

    
3154
iallocatorModeNodeEvac :: String
3155
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3156

    
3157
iallocatorModeReloc :: String
3158
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3159

    
3160
validIallocatorModes :: FrozenSet String
3161
validIallocatorModes =
3162
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3163

    
3164
iallocatorSearchPath :: [String]
3165
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3166

    
3167
defaultIallocatorShortcut :: String
3168
defaultIallocatorShortcut = "."
3169

    
3170
-- * Node evacuation
3171

    
3172
nodeEvacPri :: String
3173
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3174

    
3175
nodeEvacSec :: String
3176
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3177

    
3178
nodeEvacAll :: String
3179
nodeEvacAll = Types.evacModeToRaw ChangeAll
3180

    
3181
nodeEvacModes :: FrozenSet String
3182
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3183

    
3184
-- * Job queue
3185

    
3186
jobQueueVersion :: Int
3187
jobQueueVersion = 1
3188

    
3189
jobQueueSizeHardLimit :: Int
3190
jobQueueSizeHardLimit = 5000
3191

    
3192
jobQueueFilesPerms :: Int
3193
jobQueueFilesPerms = 0o640
3194

    
3195
-- * Unchanged job return
3196

    
3197
jobNotchanged :: String
3198
jobNotchanged = "nochange"
3199

    
3200
-- * Job status
3201

    
3202
jobStatusQueued :: String
3203
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3204

    
3205
jobStatusWaiting :: String
3206
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3207

    
3208
jobStatusCanceling :: String
3209
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3210

    
3211
jobStatusRunning :: String
3212
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3213

    
3214
jobStatusCanceled :: String
3215
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3216

    
3217
jobStatusSuccess :: String
3218
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3219

    
3220
jobStatusError :: String
3221
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3222

    
3223
jobsPending :: FrozenSet String
3224
jobsPending =
3225
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3226

    
3227
jobsFinalized :: FrozenSet String
3228
jobsFinalized =
3229
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3230

    
3231
jobStatusAll :: FrozenSet String
3232
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3233

    
3234
-- * OpCode status
3235

    
3236
-- ** Not yet finalized opcodes
3237

    
3238
opStatusCanceling :: String
3239
opStatusCanceling = "canceling"
3240

    
3241
opStatusQueued :: String
3242
opStatusQueued = "queued"
3243

    
3244
opStatusRunning :: String
3245
opStatusRunning = "running"
3246

    
3247
opStatusWaiting :: String
3248
opStatusWaiting = "waiting"
3249

    
3250
-- ** Finalized opcodes
3251

    
3252
opStatusCanceled :: String
3253
opStatusCanceled = "canceled"
3254

    
3255
opStatusError :: String
3256
opStatusError = "error"
3257

    
3258
opStatusSuccess :: String
3259
opStatusSuccess = "success"
3260

    
3261
opsFinalized :: FrozenSet String
3262
opsFinalized =
3263
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3264

    
3265
-- * OpCode priority
3266

    
3267
opPrioLowest :: Int
3268
opPrioLowest = 19
3269

    
3270
opPrioHighest :: Int
3271
opPrioHighest = -20
3272

    
3273
opPrioLow :: Int
3274
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3275

    
3276
opPrioNormal :: Int
3277
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3278

    
3279
opPrioHigh :: Int
3280
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3281

    
3282
opPrioSubmitValid :: FrozenSet Int
3283
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3284

    
3285
opPrioDefault :: Int
3286
opPrioDefault = opPrioNormal
3287

    
3288
-- * Lock recalculate mode
3289

    
3290
locksAppend :: String
3291
locksAppend = "append"
3292

    
3293
locksReplace :: String
3294
locksReplace = "replace"
3295

    
3296
-- * Lock timeout
3297
--
3298
-- The lock timeout (sum) before we transition into blocking acquire
3299
-- (this can still be reset by priority change).  Computed as max time
3300
-- (10 hours) before we should actually go into blocking acquire,
3301
-- given that we start from the default priority level.
3302

    
3303
lockAttemptsMaxwait :: Double
3304
lockAttemptsMaxwait = 15.0
3305

    
3306
lockAttemptsMinwait :: Double
3307
lockAttemptsMinwait = 1.0
3308

    
3309
lockAttemptsTimeout :: Int
3310
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3311

    
3312
-- * Execution log types
3313

    
3314
elogMessage :: String
3315
elogMessage = Types.eLogTypeToRaw ELogMessage
3316

    
3317
elogRemoteImport :: String
3318
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3319

    
3320
elogJqueueTest :: String
3321
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3322

    
3323
-- * /etc/hosts modification
3324

    
3325
etcHostsAdd :: String
3326
etcHostsAdd = "add"
3327

    
3328
etcHostsRemove :: String
3329
etcHostsRemove = "remove"
3330

    
3331
-- * Job queue test
3332

    
3333
jqtMsgprefix :: String
3334
jqtMsgprefix = "TESTMSG="
3335

    
3336
jqtExec :: String
3337
jqtExec = "exec"
3338

    
3339
jqtExpandnames :: String
3340
jqtExpandnames = "expandnames"
3341

    
3342
jqtLogmsg :: String
3343
jqtLogmsg = "logmsg"
3344

    
3345
jqtStartmsg :: String
3346
jqtStartmsg = "startmsg"
3347

    
3348
jqtAll :: FrozenSet String
3349
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3350

    
3351
-- * Query resources
3352

    
3353
qrCluster :: String
3354
qrCluster = "cluster"
3355

    
3356
qrExport :: String
3357
qrExport = "export"
3358

    
3359
qrExtstorage :: String
3360
qrExtstorage = "extstorage"
3361

    
3362
qrGroup :: String
3363
qrGroup = "group"
3364

    
3365
qrInstance :: String
3366
qrInstance = "instance"
3367

    
3368
qrJob :: String
3369
qrJob = "job"
3370

    
3371
qrLock :: String
3372
qrLock = "lock"
3373

    
3374
qrNetwork :: String
3375
qrNetwork = "network"
3376

    
3377
qrNode :: String
3378
qrNode = "node"
3379

    
3380
qrOs :: String
3381
qrOs = "os"
3382

    
3383
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3384
qrViaOp :: FrozenSet String
3385
qrViaOp =
3386
  ConstantUtils.mkSet [qrCluster,
3387
                       qrInstance,
3388
                       qrNode,
3389
                       qrGroup,
3390
                       qrOs,
3391
                       qrExport,
3392
                       qrNetwork,
3393
                       qrExtstorage]
3394

    
3395
-- | List of resources which can be queried using Local UniX Interface
3396
qrViaLuxi :: FrozenSet String
3397
qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob]
3398

    
3399
-- | List of resources which can be queried using RAPI
3400
qrViaRapi :: FrozenSet String
3401
qrViaRapi = qrViaLuxi
3402

    
3403
-- * Query field types
3404

    
3405
qftBool :: String
3406
qftBool = "bool"
3407

    
3408
qftNumber :: String
3409
qftNumber = "number"
3410

    
3411
qftOther :: String
3412
qftOther = "other"
3413

    
3414
qftText :: String
3415
qftText = "text"
3416

    
3417
qftTimestamp :: String
3418
qftTimestamp = "timestamp"
3419

    
3420
qftUnit :: String
3421
qftUnit = "unit"
3422

    
3423
qftUnknown :: String
3424
qftUnknown = "unknown"
3425

    
3426
qftAll :: FrozenSet String
3427
qftAll =
3428
  ConstantUtils.mkSet [qftBool,
3429
                       qftNumber,
3430
                       qftOther,
3431
                       qftText,
3432
                       qftTimestamp,
3433
                       qftUnit,
3434
                       qftUnknown]
3435

    
3436
-- * Query result field status
3437
--
3438
-- Don't change or reuse values as they're used by clients.
3439
--
3440
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3441

    
3442
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3443
rsNodata :: Int
3444
rsNodata = 2
3445

    
3446
rsNormal :: Int
3447
rsNormal = 0
3448

    
3449
-- | Resource marked offline
3450
rsOffline :: Int
3451
rsOffline = 4
3452

    
3453
-- | Value unavailable/unsupported for item; if this field is
3454
-- supported but we cannot get the data for the moment, 'rsNodata' or
3455
-- 'rsOffline' should be used
3456
rsUnavail :: Int
3457
rsUnavail = 3
3458

    
3459
rsUnknown :: Int
3460
rsUnknown = 1
3461

    
3462
rsAll :: FrozenSet Int
3463
rsAll =
3464
  ConstantUtils.mkSet [rsNodata,
3465
                       rsNormal,
3466
                       rsOffline,
3467
                       rsUnavail,
3468
                       rsUnknown]
3469

    
3470
-- | Special field cases and their verbose/terse formatting
3471
rssDescription :: Map Int (String, String)
3472
rssDescription =
3473
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3474
                (rsNodata, ("(nodata)", "?")),
3475
                (rsOffline, ("(offline)", "*")),
3476
                (rsUnavail, ("(unavail)", "-"))]
3477

    
3478
-- * Max dynamic devices
3479

    
3480
maxDisks :: Int
3481
maxDisks = Types.maxDisks
3482

    
3483
maxNics :: Int
3484
maxNics = Types.maxNics
3485

    
3486
-- | SSCONF file prefix
3487
ssconfFileprefix :: String
3488
ssconfFileprefix = "ssconf_"
3489

    
3490
-- * SSCONF keys
3491

    
3492
ssClusterName :: String
3493
ssClusterName = "cluster_name"
3494

    
3495
ssClusterTags :: String
3496
ssClusterTags = "cluster_tags"
3497

    
3498
ssFileStorageDir :: String
3499
ssFileStorageDir = "file_storage_dir"
3500

    
3501
ssSharedFileStorageDir :: String
3502
ssSharedFileStorageDir = "shared_file_storage_dir"
3503

    
3504
ssMasterCandidates :: String
3505
ssMasterCandidates = "master_candidates"
3506

    
3507
ssMasterCandidatesIps :: String
3508
ssMasterCandidatesIps = "master_candidates_ips"
3509

    
3510
ssMasterIp :: String
3511
ssMasterIp = "master_ip"
3512

    
3513
ssMasterNetdev :: String
3514
ssMasterNetdev = "master_netdev"
3515

    
3516
ssMasterNetmask :: String
3517
ssMasterNetmask = "master_netmask"
3518

    
3519
ssMasterNode :: String
3520
ssMasterNode = "master_node"
3521

    
3522
ssNodeList :: String
3523
ssNodeList = "node_list"
3524

    
3525
ssNodePrimaryIps :: String
3526
ssNodePrimaryIps = "node_primary_ips"
3527

    
3528
ssNodeSecondaryIps :: String
3529
ssNodeSecondaryIps = "node_secondary_ips"
3530

    
3531
ssOfflineNodes :: String
3532
ssOfflineNodes = "offline_nodes"
3533

    
3534
ssOnlineNodes :: String
3535
ssOnlineNodes = "online_nodes"
3536

    
3537
ssPrimaryIpFamily :: String
3538
ssPrimaryIpFamily = "primary_ip_family"
3539

    
3540
ssInstanceList :: String
3541
ssInstanceList = "instance_list"
3542

    
3543
ssReleaseVersion :: String
3544
ssReleaseVersion = "release_version"
3545

    
3546
ssHypervisorList :: String
3547
ssHypervisorList = "hypervisor_list"
3548

    
3549
ssMaintainNodeHealth :: String
3550
ssMaintainNodeHealth = "maintain_node_health"
3551

    
3552
ssUidPool :: String
3553
ssUidPool = "uid_pool"
3554

    
3555
ssNodegroups :: String
3556
ssNodegroups = "nodegroups"
3557

    
3558
ssNetworks :: String
3559
ssNetworks = "networks"
3560

    
3561
-- | This is not a complete SSCONF key, but the prefix for the
3562
-- hypervisor keys
3563
ssHvparamsPref :: String
3564
ssHvparamsPref = "hvparams_"
3565

    
3566
-- * Hvparams keys
3567

    
3568
ssHvparamsXenChroot :: String
3569
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3570

    
3571
ssHvparamsXenFake :: String
3572
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3573

    
3574
ssHvparamsXenHvm :: String
3575
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3576

    
3577
ssHvparamsXenKvm :: String
3578
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3579

    
3580
ssHvparamsXenLxc :: String
3581
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3582

    
3583
ssHvparamsXenPvm :: String
3584
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3585

    
3586
validSsHvparamsKeys :: FrozenSet String
3587
validSsHvparamsKeys =
3588
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3589
                       ssHvparamsXenLxc,
3590
                       ssHvparamsXenFake,
3591
                       ssHvparamsXenHvm,
3592
                       ssHvparamsXenKvm,
3593
                       ssHvparamsXenPvm]
3594

    
3595
ssFilePerms :: Int
3596
ssFilePerms = 0o444
3597

    
3598
-- | Cluster wide default parameters
3599
defaultEnabledHypervisor :: String
3600
defaultEnabledHypervisor = htXenPvm
3601

    
3602
hvcDefaults :: Map Hypervisor (Map String PyValueEx)
3603
hvcDefaults =
3604
  Map.fromList
3605
  [ (XenPvm, Map.fromList
3606
             [ (hvUseBootloader,  PyValueEx False)
3607
             , (hvBootloaderPath, PyValueEx xenBootloader)
3608
             , (hvBootloaderArgs, PyValueEx "")
3609
             , (hvKernelPath,     PyValueEx xenKernel)
3610
             , (hvInitrdPath,     PyValueEx "")
3611
             , (hvRootPath,       PyValueEx "/dev/xvda1")
3612
             , (hvKernelArgs,     PyValueEx "ro")
3613
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3614
             , (hvMigrationMode,  PyValueEx htMigrationLive)
3615
             , (hvBlockdevPrefix, PyValueEx "sd")
3616
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3617
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3618
             , (hvCpuCap,         PyValueEx (0 :: Int))
3619
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3620
             , (hvVifScript,      PyValueEx "")
3621
             , (hvXenCmd,         PyValueEx xenCmdXm)
3622
             , (hvXenCpuid,       PyValueEx "")
3623
             , (hvSoundhw,        PyValueEx "")
3624
             ])
3625
  , (XenHvm, Map.fromList
3626
             [ (hvBootOrder,      PyValueEx "cd")
3627
             , (hvCdromImagePath, PyValueEx "")
3628
             , (hvNicType,        PyValueEx htNicRtl8139)
3629
             , (hvDiskType,       PyValueEx htDiskParavirtual)
3630
             , (hvVncBindAddress, PyValueEx ip4AddressAny)
3631
             , (hvAcpi,           PyValueEx True)
3632
             , (hvPae,            PyValueEx True)
3633
             , (hvKernelPath,     PyValueEx "/usr/lib/xen/boot/hvmloader")
3634
             , (hvDeviceModel,    PyValueEx "/usr/lib/xen/bin/qemu-dm")
3635
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3636
             , (hvMigrationMode,  PyValueEx htMigrationNonlive)
3637
             , (hvUseLocaltime,   PyValueEx False)
3638
             , (hvBlockdevPrefix, PyValueEx "hd")
3639
             , (hvPassthrough,    PyValueEx "")
3640
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3641
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3642
             , (hvCpuCap,         PyValueEx (0 :: Int))
3643
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3644
             , (hvVifType,        PyValueEx htHvmVifIoemu)
3645
             , (hvVifScript,      PyValueEx "")
3646
             , (hvViridian,       PyValueEx False)
3647
             , (hvXenCmd,         PyValueEx xenCmdXm)
3648
             , (hvXenCpuid,       PyValueEx "")
3649
             , (hvSoundhw,        PyValueEx "")
3650
             ])
3651
  , (Kvm, Map.fromList
3652
          [ (hvKvmPath,                         PyValueEx kvmPath)
3653
          , (hvKernelPath,                      PyValueEx kvmKernel)
3654
          , (hvInitrdPath,                      PyValueEx "")
3655
          , (hvKernelArgs,                      PyValueEx "ro")
3656
          , (hvRootPath,                        PyValueEx "/dev/vda1")
3657
          , (hvAcpi,                            PyValueEx True)
3658
          , (hvSerialConsole,                   PyValueEx True)
3659
          , (hvSerialSpeed,                     PyValueEx (38400 :: Int))
3660
          , (hvVncBindAddress,                  PyValueEx "")
3661
          , (hvVncTls,                          PyValueEx False)
3662
          , (hvVncX509,                         PyValueEx "")
3663
          , (hvVncX509Verify,                   PyValueEx False)
3664
          , (hvVncPasswordFile,                 PyValueEx "")
3665
          , (hvKvmSpiceBind,                    PyValueEx "")
3666
          , (hvKvmSpiceIpVersion,           PyValueEx ifaceNoIpVersionSpecified)
3667
          , (hvKvmSpicePasswordFile,            PyValueEx "")
3668
          , (hvKvmSpiceLosslessImgCompr,        PyValueEx "")
3669
          , (hvKvmSpiceJpegImgCompr,            PyValueEx "")
3670
          , (hvKvmSpiceZlibGlzImgCompr,         PyValueEx "")
3671
          , (hvKvmSpiceStreamingVideoDetection, PyValueEx "")
3672
          , (hvKvmSpiceAudioCompr,              PyValueEx True)
3673
          , (hvKvmSpiceUseTls,                  PyValueEx False)
3674
          , (hvKvmSpiceTlsCiphers,              PyValueEx opensslCiphers)
3675
          , (hvKvmSpiceUseVdagent,              PyValueEx True)
3676
          , (hvKvmFloppyImagePath,              PyValueEx "")
3677
          , (hvCdromImagePath,                  PyValueEx "")
3678
          , (hvKvmCdrom2ImagePath,              PyValueEx "")
3679
          , (hvBootOrder,                       PyValueEx htBoDisk)
3680
          , (hvNicType,                         PyValueEx htNicParavirtual)
3681
          , (hvDiskType,                        PyValueEx htDiskParavirtual)
3682
          , (hvKvmCdromDiskType,                PyValueEx "")
3683
          , (hvUsbMouse,                        PyValueEx "")
3684
          , (hvKeymap,                          PyValueEx "")
3685
          , (hvMigrationPort,                   PyValueEx (8102 :: Int))
3686
          , (hvMigrationBandwidth,              PyValueEx (32 :: Int))
3687
          , (hvMigrationDowntime,               PyValueEx (30 :: Int))
3688
          , (hvMigrationMode,                   PyValueEx htMigrationLive)
3689
          , (hvUseLocaltime,                    PyValueEx False)
3690
          , (hvDiskCache,                       PyValueEx htCacheDefault)
3691
          , (hvSecurityModel,                   PyValueEx htSmNone)
3692
          , (hvSecurityDomain,                  PyValueEx "")
3693
          , (hvKvmFlag,                         PyValueEx "")
3694
          , (hvVhostNet,                        PyValueEx False)
3695
          , (hvVirtioNetQueues,                 PyValueEx (1 :: Int))
3696
          , (hvKvmUseChroot,                    PyValueEx False)
3697
          , (hvMemPath,                         PyValueEx "")
3698
          , (hvRebootBehavior,                  PyValueEx instanceRebootAllowed)
3699
          , (hvCpuMask,                         PyValueEx cpuPinningAll)
3700
          , (hvCpuType,                         PyValueEx "")
3701
          , (hvCpuCores,                        PyValueEx (0 :: Int))
3702
          , (hvCpuThreads,                      PyValueEx (0 :: Int))
3703
          , (hvCpuSockets,                      PyValueEx (0 :: Int))
3704
          , (hvSoundhw,                         PyValueEx "")
3705
          , (hvUsbDevices,                      PyValueEx "")
3706
          , (hvVga,                             PyValueEx "")
3707
          , (hvKvmExtra,                        PyValueEx "")
3708
          , (hvKvmMachineVersion,               PyValueEx "")
3709
          , (hvKvmMigrationCaps,                PyValueEx "")
3710
          , (hvVnetHdr,                         PyValueEx True)])
3711
  , (Fake, Map.fromList [(hvMigrationMode, PyValueEx htMigrationLive)])
3712
  , (Chroot, Map.fromList [(hvInitScript, PyValueEx "/ganeti-chroot")])
3713
  , (Lxc, Map.fromList [(hvCpuMask, PyValueEx "")])
3714
  ]
3715

    
3716
hvcGlobals :: FrozenSet String
3717
hvcGlobals =
3718
  ConstantUtils.mkSet [hvMigrationBandwidth,
3719
                       hvMigrationMode,
3720
                       hvMigrationPort,
3721
                       hvXenCmd]
3722

    
3723
becDefaults :: Map String PyValueEx
3724
becDefaults =
3725
  Map.fromList
3726
  [ (beMinmem, PyValueEx (128 :: Int))
3727
  , (beMaxmem, PyValueEx (128 :: Int))
3728
  , (beVcpus, PyValueEx (1 :: Int))
3729
  , (beAutoBalance, PyValueEx True)
3730
  , (beAlwaysFailover, PyValueEx False)
3731
  , (beSpindleUse, PyValueEx (1 :: Int))
3732
  ]
3733

    
3734
ndcDefaults :: Map String PyValueEx
3735
ndcDefaults =
3736
  Map.fromList
3737
  [ (ndOobProgram,       PyValueEx "")
3738
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3739
  , (ndExclusiveStorage, PyValueEx False)
3740
  , (ndOvs,              PyValueEx False)
3741
  , (ndOvsName,          PyValueEx defaultOvs)
3742
  , (ndOvsLink,          PyValueEx "")
3743
  ]
3744

    
3745
ndcGlobals :: FrozenSet String
3746
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3747

    
3748
-- | Default delay target measured in sectors
3749
defaultDelayTarget :: Int
3750
defaultDelayTarget = 1
3751

    
3752
defaultDiskCustom :: String
3753
defaultDiskCustom = ""
3754

    
3755
defaultDiskResync :: Bool
3756
defaultDiskResync = False
3757

    
3758
-- | Default fill target measured in sectors
3759
defaultFillTarget :: Int
3760
defaultFillTarget = 0
3761

    
3762
-- | Default mininum rate measured in KiB/s
3763
defaultMinRate :: Int
3764
defaultMinRate = 4 * 1024
3765

    
3766
defaultNetCustom :: String
3767
defaultNetCustom = ""
3768

    
3769
-- | Default plan ahead measured in sectors
3770
--
3771
-- The default values for the DRBD dynamic resync speed algorithm are
3772
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3773
-- (that we don't need to set to 0, because we have a separate option
3774
-- to enable it) and for c-max-rate, that we cap to the default value
3775
-- for the static resync rate.
3776
defaultPlanAhead :: Int
3777
defaultPlanAhead = 20
3778

    
3779
defaultRbdPool :: String
3780
defaultRbdPool = "rbd"
3781

    
3782
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3783
diskLdDefaults =
3784
  Map.fromList
3785
  [ (DTBlock, Map.empty)
3786
  , (DTDrbd8, Map.fromList
3787
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3788
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3789
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3790
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3791
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3792
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3793
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3794
              , (ldpMinRate,       PyValueEx defaultMinRate)
3795
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3796
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3797
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3798
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3799
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3800
              ])
3801
  , (DTExt, Map.fromList
3802
            [ (ldpAccess, PyValueEx diskKernelspace)
3803
            ])
3804
  , (DTFile, Map.empty)
3805
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3806
  , (DTRbd, Map.fromList
3807
            [ (ldpPool, PyValueEx defaultRbdPool)
3808
            , (ldpAccess, PyValueEx diskKernelspace)
3809
            ])
3810
  , (DTSharedFile, Map.empty)
3811
  ]
3812

    
3813
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3814
diskDtDefaults =
3815
  Map.fromList
3816
  [ (DTBlock,      Map.empty)
3817
  , (DTDiskless,   Map.empty)
3818
  , (DTDrbd8,      Map.fromList
3819
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3820
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3821
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3822
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3823
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3824
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3825
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3826
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3827
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3828
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3829
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3830
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3831
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3832
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3833
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3834
                   ])
3835
  , (DTExt,        Map.fromList
3836
                   [ (rbdAccess, PyValueEx diskKernelspace)
3837
                   ])
3838
  , (DTFile,       Map.empty)
3839
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3840
  , (DTRbd,        Map.fromList
3841
                   [ (rbdPool, PyValueEx defaultRbdPool)
3842
                   , (rbdAccess, PyValueEx diskKernelspace)
3843
                   ])
3844
  , (DTSharedFile, Map.empty)
3845
  ]
3846

    
3847
niccDefaults :: Map String PyValueEx
3848
niccDefaults =
3849
  Map.fromList
3850
  [ (nicMode, PyValueEx nicModeBridged)
3851
  , (nicLink, PyValueEx defaultBridge)
3852
  , (nicVlan, PyValueEx "")
3853
  ]
3854

    
3855
-- | All of the following values are quite arbitrary - there are no
3856
-- "good" defaults, these must be customised per-site
3857
ispecsMinmaxDefaults :: Map String (Map String Int)
3858
ispecsMinmaxDefaults =
3859
  Map.fromList
3860
  [(ispecsMin,
3861
    Map.fromList
3862
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3863
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3864
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3865
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3866
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3867
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3868
   (ispecsMax,
3869
    Map.fromList
3870
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3871
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3872
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3873
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3874
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3875
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3876

    
3877
ipolicyDefaults :: Map String PyValueEx
3878
ipolicyDefaults =
3879
  Map.fromList
3880
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3881
  , (ispecsStd,           PyValueEx (Map.fromList
3882
                                     [ (ispecMemSize,    128)
3883
                                     , (ispecCpuCount,   1)
3884
                                     , (ispecDiskCount,  1)
3885
                                     , (ispecDiskSize,   1024)
3886
                                     , (ispecNicCount,   1)
3887
                                     , (ispecSpindleUse, 1)
3888
                                     ] :: Map String Int))
3889
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3890
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3891
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3892
  ]
3893

    
3894
masterPoolSizeDefault :: Int
3895
masterPoolSizeDefault = 10
3896

    
3897
-- * Exclusive storage
3898

    
3899
-- | Error margin used to compare physical disks
3900
partMargin :: Double
3901
partMargin = 0.01
3902

    
3903
-- | Space reserved when creating instance disks
3904
partReserved :: Double
3905
partReserved = 0.02
3906

    
3907
-- * Confd
3908

    
3909
confdProtocolVersion :: Int
3910
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3911

    
3912
-- Confd request type
3913

    
3914
confdReqPing :: Int
3915
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3916

    
3917
confdReqNodeRoleByname :: Int
3918
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3919

    
3920
confdReqNodePipByInstanceIp :: Int
3921
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3922

    
3923
confdReqClusterMaster :: Int
3924
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3925

    
3926
confdReqNodePipList :: Int
3927
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3928

    
3929
confdReqMcPipList :: Int
3930
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3931

    
3932
confdReqInstancesIpsList :: Int
3933
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3934

    
3935
confdReqNodeDrbd :: Int
3936
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3937

    
3938
confdReqNodeInstances :: Int
3939
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3940

    
3941
confdReqs :: FrozenSet Int
3942
confdReqs =
3943
  ConstantUtils.mkSet .
3944
  map Types.confdRequestTypeToRaw $
3945
  [minBound..] \\ [ReqNodeInstances]
3946

    
3947
-- * Confd request type
3948

    
3949
confdReqfieldName :: Int
3950
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3951

    
3952
confdReqfieldIp :: Int
3953
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3954

    
3955
confdReqfieldMnodePip :: Int
3956
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3957

    
3958
-- * Confd repl status
3959

    
3960
confdReplStatusOk :: Int
3961
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3962

    
3963
confdReplStatusError :: Int
3964
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3965

    
3966
confdReplStatusNotimplemented :: Int
3967
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3968

    
3969
confdReplStatuses :: FrozenSet Int
3970
confdReplStatuses =
3971
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3972

    
3973
-- * Confd node role
3974

    
3975
confdNodeRoleMaster :: Int
3976
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3977

    
3978
confdNodeRoleCandidate :: Int
3979
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3980

    
3981
confdNodeRoleOffline :: Int
3982
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3983

    
3984
confdNodeRoleDrained :: Int
3985
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3986

    
3987
confdNodeRoleRegular :: Int
3988
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3989

    
3990
-- * A few common errors for confd
3991

    
3992
confdErrorUnknownEntry :: Int
3993
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3994

    
3995
confdErrorInternal :: Int
3996
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3997

    
3998
confdErrorArgument :: Int
3999
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
4000

    
4001
-- * Confd request query fields
4002

    
4003
confdReqqLink :: String
4004
confdReqqLink = ConstantUtils.confdReqqLink
4005

    
4006
confdReqqIp :: String
4007
confdReqqIp = ConstantUtils.confdReqqIp
4008

    
4009
confdReqqIplist :: String
4010
confdReqqIplist = ConstantUtils.confdReqqIplist
4011

    
4012
confdReqqFields :: String
4013
confdReqqFields = ConstantUtils.confdReqqFields
4014

    
4015
-- | Each request is "salted" by the current timestamp.
4016
--
4017
-- This constant decides how many seconds of skew to accept.
4018
--
4019
-- TODO: make this a default and allow the value to be more
4020
-- configurable
4021
confdMaxClockSkew :: Int
4022
confdMaxClockSkew = 2 * nodeMaxClockSkew
4023

    
4024
-- | When we haven't reloaded the config for more than this amount of
4025
-- seconds, we force a test to see if inotify is betraying us. Using a
4026
-- prime number to ensure we get less chance of 'same wakeup' with
4027
-- other processes.
4028
confdConfigReloadTimeout :: Int
4029
confdConfigReloadTimeout = 17
4030

    
4031
-- | If we receive more than one update in this amount of
4032
-- microseconds, we move to polling every RATELIMIT seconds, rather
4033
-- than relying on inotify, to be able to serve more requests.
4034
confdConfigReloadRatelimit :: Int
4035
confdConfigReloadRatelimit = 250000
4036

    
4037
-- | Magic number prepended to all confd queries.
4038
--
4039
-- This allows us to distinguish different types of confd protocols
4040
-- and handle them. For example by changing this we can move the whole
4041
-- payload to be compressed, or move away from json.
4042
confdMagicFourcc :: String
4043
confdMagicFourcc = "plj0"
4044

    
4045
-- | By default a confd request is sent to the minimum between this
4046
-- number and all MCs. 6 was chosen because even in the case of a
4047
-- disastrous 50% response rate, we should have enough answers to be
4048
-- able to compare more than one.
4049
confdDefaultReqCoverage :: Int
4050
confdDefaultReqCoverage = 6
4051

    
4052
-- | Timeout in seconds to expire pending query request in the confd
4053
-- client library. We don't actually expect any answer more than 10
4054
-- seconds after we sent a request.
4055
confdClientExpireTimeout :: Int
4056
confdClientExpireTimeout = 10
4057

    
4058
-- | Maximum UDP datagram size.
4059
--
4060
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4061
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4062
--   (assuming we can't use jumbo frames)
4063
-- We just set this to 60K, which should be enough
4064
maxUdpDataSize :: Int
4065
maxUdpDataSize = 61440
4066

    
4067
-- * User-id pool minimum/maximum acceptable user-ids
4068

    
4069
uidpoolUidMin :: Int
4070
uidpoolUidMin = 0
4071

    
4072
-- | Assuming 32 bit user-ids
4073
uidpoolUidMax :: Integer
4074
uidpoolUidMax = 2 ^ 32 - 1
4075

    
4076
-- | Name or path of the pgrep command
4077
pgrep :: String
4078
pgrep = "pgrep"
4079

    
4080
-- | Name of the node group that gets created at cluster init or
4081
-- upgrade
4082
initialNodeGroupName :: String
4083
initialNodeGroupName = "default"
4084

    
4085
-- * Possible values for NodeGroup.alloc_policy
4086

    
4087
allocPolicyLastResort :: String
4088
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4089

    
4090
allocPolicyPreferred :: String
4091
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4092

    
4093
allocPolicyUnallocable :: String
4094
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4095

    
4096
validAllocPolicies :: [String]
4097
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4098

    
4099
-- | Temporary external/shared storage parameters
4100
blockdevDriverManual :: String
4101
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4102

    
4103
-- | 'qemu-img' path, required for 'ovfconverter'
4104
qemuimgPath :: String
4105
qemuimgPath = AutoConf.qemuimgPath
4106

    
4107
-- | Whether htools was enabled at compilation time
4108
--
4109
-- FIXME: this should be moved next to the other enable constants,
4110
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4111
htools :: Bool
4112
htools = AutoConf.htools
4113

    
4114
-- | The hail iallocator
4115
iallocHail :: String
4116
iallocHail = "hail"
4117

    
4118
-- * Fake opcodes for functions that have hooks attached to them via
4119
-- backend.RunLocalHooks
4120

    
4121
fakeOpMasterTurndown :: String
4122
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4123

    
4124
fakeOpMasterTurnup :: String
4125
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4126

    
4127
-- * SSH key types
4128

    
4129
sshkDsa :: String
4130
sshkDsa = "dsa"
4131

    
4132
sshkRsa :: String
4133
sshkRsa = "rsa"
4134

    
4135
sshkAll :: FrozenSet String
4136
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4137

    
4138
-- * SSH authorized key types
4139

    
4140
sshakDss :: String
4141
sshakDss = "ssh-dss"
4142

    
4143
sshakRsa :: String
4144
sshakRsa = "ssh-rsa"
4145

    
4146
sshakAll :: FrozenSet String
4147
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4148

    
4149
-- * SSH setup
4150

    
4151
sshsClusterName :: String
4152
sshsClusterName = "cluster_name"
4153

    
4154
sshsSshHostKey :: String
4155
sshsSshHostKey = "ssh_host_key"
4156

    
4157
sshsSshRootKey :: String
4158
sshsSshRootKey = "ssh_root_key"
4159

    
4160
sshsNodeDaemonCertificate :: String
4161
sshsNodeDaemonCertificate = "node_daemon_certificate"
4162

    
4163
-- * Key files for SSH daemon
4164

    
4165
sshHostDsaPriv :: String
4166
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4167

    
4168
sshHostDsaPub :: String
4169
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4170

    
4171
sshHostRsaPriv :: String
4172
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4173

    
4174
sshHostRsaPub :: String
4175
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4176

    
4177
sshDaemonKeyfiles :: Map String (String, String)
4178
sshDaemonKeyfiles =
4179
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4180
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4181
               ]
4182

    
4183
-- * Node daemon setup
4184

    
4185
ndsClusterName :: String
4186
ndsClusterName = "cluster_name"
4187

    
4188
ndsNodeDaemonCertificate :: String
4189
ndsNodeDaemonCertificate = "node_daemon_certificate"
4190

    
4191
ndsSsconf :: String
4192
ndsSsconf = "ssconf"
4193

    
4194
ndsStartNodeDaemon :: String
4195
ndsStartNodeDaemon = "start_node_daemon"
4196

    
4197
-- * The source reasons for the execution of an OpCode
4198

    
4199
opcodeReasonSrcClient :: String
4200
opcodeReasonSrcClient = "gnt:client"
4201

    
4202
opcodeReasonSrcNoded :: String
4203
opcodeReasonSrcNoded = "gnt:daemon:noded"
4204

    
4205
opcodeReasonSrcOpcode :: String
4206
opcodeReasonSrcOpcode = "gnt:opcode"
4207

    
4208
opcodeReasonSrcRlib2 :: String
4209
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4210

    
4211
opcodeReasonSrcUser :: String
4212
opcodeReasonSrcUser = "gnt:user"
4213

    
4214
opcodeReasonSources :: FrozenSet String
4215
opcodeReasonSources =
4216
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4217
                       opcodeReasonSrcNoded,
4218
                       opcodeReasonSrcOpcode,
4219
                       opcodeReasonSrcRlib2,
4220
                       opcodeReasonSrcUser]
4221

    
4222
-- | Path generating random UUID
4223
randomUuidFile :: String
4224
randomUuidFile = ConstantUtils.randomUuidFile
4225

    
4226
-- * Auto-repair tag prefixes
4227

    
4228
autoRepairTagPrefix :: String
4229
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4230

    
4231
autoRepairTagEnabled :: String
4232
autoRepairTagEnabled = autoRepairTagPrefix
4233

    
4234
autoRepairTagPending :: String
4235
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4236

    
4237
autoRepairTagResult :: String
4238
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4239

    
4240
autoRepairTagSuspended :: String
4241
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4242

    
4243
-- * Auto-repair levels
4244

    
4245
autoRepairFailover :: String
4246
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4247

    
4248
autoRepairFixStorage :: String
4249
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4250

    
4251
autoRepairMigrate :: String
4252
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4253

    
4254
autoRepairReinstall :: String
4255
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4256

    
4257
autoRepairAllTypes :: FrozenSet String
4258
autoRepairAllTypes =
4259
  ConstantUtils.mkSet [autoRepairFailover,
4260
                       autoRepairFixStorage,
4261
                       autoRepairMigrate,
4262
                       autoRepairReinstall]
4263

    
4264
-- * Auto-repair results
4265

    
4266
autoRepairEnoperm :: String
4267
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4268

    
4269
autoRepairFailure :: String
4270
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4271

    
4272
autoRepairSuccess :: String
4273
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4274

    
4275
autoRepairAllResults :: FrozenSet String
4276
autoRepairAllResults =
4277
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4278

    
4279
-- | The version identifier for builtin data collectors
4280
builtinDataCollectorVersion :: String
4281
builtinDataCollectorVersion = "B"
4282

    
4283
-- | The reason trail opcode parameter name
4284
opcodeReason :: String
4285
opcodeReason = "reason"
4286

    
4287
-- | The reason trail opcode parameter name
4288
opcodeSequential :: String
4289
opcodeSequential = "sequential"
4290

    
4291
diskstatsFile :: String
4292
diskstatsFile = "/proc/diskstats"
4293

    
4294
-- *  CPU load collector
4295

    
4296
statFile :: String
4297
statFile = "/proc/stat"
4298

    
4299
cpuavgloadBufferSize :: Int
4300
cpuavgloadBufferSize = 150
4301

    
4302
cpuavgloadWindowSize :: Int
4303
cpuavgloadWindowSize = 600
4304

    
4305
-- * Monitoring daemon
4306

    
4307
-- | Mond's variable for periodical data collection
4308
mondTimeInterval :: Int
4309
mondTimeInterval = 5
4310

    
4311
-- | Mond's latest API version
4312
mondLatestApiVersion :: Int
4313
mondLatestApiVersion = 1
4314

    
4315
-- * Disk access modes
4316

    
4317
diskUserspace :: String
4318
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4319

    
4320
diskKernelspace :: String
4321
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4322

    
4323
diskValidAccessModes :: FrozenSet String
4324
diskValidAccessModes =
4325
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4326

    
4327
-- | Timeout for queue draining in upgrades
4328
upgradeQueueDrainTimeout :: Int
4329
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4330

    
4331
-- | Intervall at which the queue is polled during upgrades
4332
upgradeQueuePollInterval :: Int
4333
upgradeQueuePollInterval  = 10
4334

    
4335
-- * Hotplug Actions
4336

    
4337
hotplugActionAdd :: String
4338
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4339

    
4340
hotplugActionRemove :: String
4341
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4342

    
4343
hotplugActionModify :: String
4344
hotplugActionModify = Types.hotplugActionToRaw HAMod
4345

    
4346
hotplugAllActions :: FrozenSet String
4347
hotplugAllActions =
4348
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4349

    
4350
-- * Hotplug Device Targets
4351

    
4352
hotplugTargetNic :: String
4353
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4354

    
4355
hotplugTargetDisk :: String
4356
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4357

    
4358
hotplugAllTargets :: FrozenSet String
4359
hotplugAllTargets =
4360
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4361

    
4362
-- | Timeout for disk removal (seconds)
4363
diskRemoveRetryTimeout :: Int
4364
diskRemoveRetryTimeout = 30
4365

    
4366
-- | Interval between disk removal retries (seconds)
4367
diskRemoveRetryInterval :: Int
4368
diskRemoveRetryInterval  = 3
4369

    
4370
-- * UUID regex
4371

    
4372
uuidRegex :: String
4373
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4374

    
4375
-- * Luxi constants
4376

    
4377
luxiSocketPerms :: Int
4378
luxiSocketPerms = 0o660
4379

    
4380
luxiKeyMethod :: String
4381
luxiKeyMethod = "method"
4382

    
4383
luxiKeyArgs :: String
4384
luxiKeyArgs = "args"
4385

    
4386
luxiKeySuccess :: String
4387
luxiKeySuccess = "success"
4388

    
4389
luxiKeyResult :: String
4390
luxiKeyResult = "result"
4391

    
4392
luxiKeyVersion :: String
4393
luxiKeyVersion = "version"
4394

    
4395
luxiReqSubmitJob :: String
4396
luxiReqSubmitJob = "SubmitJob"
4397

    
4398
luxiReqSubmitJobToDrainedQueue :: String
4399
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4400

    
4401
luxiReqSubmitManyJobs :: String
4402
luxiReqSubmitManyJobs = "SubmitManyJobs"
4403

    
4404
luxiReqWaitForJobChange :: String
4405
luxiReqWaitForJobChange = "WaitForJobChange"
4406

    
4407
luxiReqCancelJob :: String
4408
luxiReqCancelJob = "CancelJob"
4409

    
4410
luxiReqArchiveJob :: String
4411
luxiReqArchiveJob = "ArchiveJob"
4412

    
4413
luxiReqChangeJobPriority :: String
4414
luxiReqChangeJobPriority = "ChangeJobPriority"
4415

    
4416
luxiReqAutoArchiveJobs :: String
4417
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4418

    
4419
luxiReqQuery :: String
4420
luxiReqQuery = "Query"
4421

    
4422
luxiReqQueryFields :: String
4423
luxiReqQueryFields = "QueryFields"
4424

    
4425
luxiReqQueryJobs :: String
4426
luxiReqQueryJobs = "QueryJobs"
4427

    
4428
luxiReqQueryInstances :: String
4429
luxiReqQueryInstances = "QueryInstances"
4430

    
4431
luxiReqQueryNodes :: String
4432
luxiReqQueryNodes = "QueryNodes"
4433

    
4434
luxiReqQueryGroups :: String
4435
luxiReqQueryGroups = "QueryGroups"
4436

    
4437
luxiReqQueryNetworks :: String
4438
luxiReqQueryNetworks = "QueryNetworks"
4439

    
4440
luxiReqQueryExports :: String
4441
luxiReqQueryExports = "QueryExports"
4442

    
4443
luxiReqQueryConfigValues :: String
4444
luxiReqQueryConfigValues = "QueryConfigValues"
4445

    
4446
luxiReqQueryClusterInfo :: String
4447
luxiReqQueryClusterInfo = "QueryClusterInfo"
4448

    
4449
luxiReqQueryTags :: String
4450
luxiReqQueryTags = "QueryTags"
4451

    
4452
luxiReqSetDrainFlag :: String
4453
luxiReqSetDrainFlag = "SetDrainFlag"
4454

    
4455
luxiReqSetWatcherPause :: String
4456
luxiReqSetWatcherPause = "SetWatcherPause"
4457

    
4458
luxiReqAll :: FrozenSet String
4459
luxiReqAll =
4460
  ConstantUtils.mkSet
4461
  [ luxiReqArchiveJob
4462
  , luxiReqAutoArchiveJobs
4463
  , luxiReqCancelJob
4464
  , luxiReqChangeJobPriority
4465
  , luxiReqQuery
4466
  , luxiReqQueryClusterInfo
4467
  , luxiReqQueryConfigValues
4468
  , luxiReqQueryExports
4469
  , luxiReqQueryFields
4470
  , luxiReqQueryGroups
4471
  , luxiReqQueryInstances
4472
  , luxiReqQueryJobs
4473
  , luxiReqQueryNodes
4474
  , luxiReqQueryNetworks
4475
  , luxiReqQueryTags
4476
  , luxiReqSetDrainFlag
4477
  , luxiReqSetWatcherPause
4478
  , luxiReqSubmitJob
4479
  , luxiReqSubmitJobToDrainedQueue
4480
  , luxiReqSubmitManyJobs
4481
  , luxiReqWaitForJobChange
4482
  ]
4483

    
4484
luxiDefCtmo :: Int
4485
luxiDefCtmo = 10
4486

    
4487
luxiDefRwto :: Int
4488
luxiDefRwto = 60
4489

    
4490
-- | 'WaitForJobChange' timeout
4491
luxiWfjcTimeout :: Int
4492
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4493

    
4494
-- * Query language constants
4495

    
4496
-- ** Logic operators with one or more operands, each of which is a
4497
-- filter on its own
4498

    
4499
qlangOpAnd :: String
4500
qlangOpAnd = "&"
4501

    
4502
qlangOpOr :: String
4503
qlangOpOr = "|"
4504

    
4505
-- ** Unary operators with exactly one operand
4506

    
4507
qlangOpNot :: String
4508
qlangOpNot = "!"
4509

    
4510
qlangOpTrue :: String
4511
qlangOpTrue = "?"
4512

    
4513
-- ** Binary operators with exactly two operands, the field name and
4514
-- an operator-specific value
4515

    
4516
qlangOpContains :: String
4517
qlangOpContains = "=[]"
4518

    
4519
qlangOpEqual :: String
4520
qlangOpEqual = "="
4521

    
4522
qlangOpGe :: String
4523
qlangOpGe = ">="
4524

    
4525
qlangOpGt :: String
4526
qlangOpGt = ">"
4527

    
4528
qlangOpLe :: String
4529
qlangOpLe = "<="
4530

    
4531
qlangOpLt :: String
4532
qlangOpLt = "<"
4533

    
4534
qlangOpNotEqual :: String
4535
qlangOpNotEqual = "!="
4536

    
4537
qlangOpRegexp :: String
4538
qlangOpRegexp = "=~"
4539

    
4540
-- | Characters used for detecting user-written filters (see
4541
-- L{_CheckFilter})
4542

    
4543
qlangFilterDetectionChars :: FrozenSet String
4544
qlangFilterDetectionChars =
4545
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4546
                       ")", "(", "\x0b", "\n",
4547
                       "\r", "\x0c", "/", "<",
4548
                       "\t", ">", "=", "\\", "~"]
4549

    
4550
-- | Characters used to detect globbing filters
4551
qlangGlobDetectionChars :: FrozenSet String
4552
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4553

    
4554
-- * Error related constants
4555
--
4556
-- 'OpPrereqError' failure types
4557

    
4558
-- | Environment error (e.g. node disk error)
4559
errorsEcodeEnviron :: String
4560
errorsEcodeEnviron = "environment_error"
4561

    
4562
-- | Entity already exists
4563
errorsEcodeExists :: String
4564
errorsEcodeExists = "already_exists"
4565

    
4566
-- | Internal cluster error
4567
errorsEcodeFault :: String
4568
errorsEcodeFault = "internal_error"
4569

    
4570
-- | Wrong arguments (at syntax level)
4571
errorsEcodeInval :: String
4572
errorsEcodeInval = "wrong_input"
4573

    
4574
-- | Entity not found
4575
errorsEcodeNoent :: String
4576
errorsEcodeNoent = "unknown_entity"
4577

    
4578
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4579
errorsEcodeNores :: String
4580
errorsEcodeNores = "insufficient_resources"
4581

    
4582
-- | Resource not unique (e.g. MAC or IP duplication)
4583
errorsEcodeNotunique :: String
4584
errorsEcodeNotunique = "resource_not_unique"
4585

    
4586
-- | Resolver errors
4587
errorsEcodeResolver :: String
4588
errorsEcodeResolver = "resolver_error"
4589

    
4590
-- | Wrong entity state
4591
errorsEcodeState :: String
4592
errorsEcodeState = "wrong_state"
4593

    
4594
-- | Temporarily out of resources; operation can be tried again
4595
errorsEcodeTempNores :: String
4596
errorsEcodeTempNores = "temp_insufficient_resources"
4597

    
4598
errorsEcodeAll :: FrozenSet String
4599
errorsEcodeAll =
4600
  ConstantUtils.mkSet [ errorsEcodeNores
4601
                      , errorsEcodeExists
4602
                      , errorsEcodeState
4603
                      , errorsEcodeNotunique
4604
                      , errorsEcodeTempNores
4605
                      , errorsEcodeNoent
4606
                      , errorsEcodeFault
4607
                      , errorsEcodeResolver
4608
                      , errorsEcodeInval
4609
                      , errorsEcodeEnviron
4610
                      ]
4611

    
4612
-- * Jstore related constants
4613

    
4614
jstoreJobsPerArchiveDirectory :: Int
4615
jstoreJobsPerArchiveDirectory = 10000