Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 29625e5a

History | View | Annotate | Download (114.7 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
-- * Drbd
908

    
909
drbdHmacAlg :: String
910
drbdHmacAlg = "md5"
911

    
912
drbdDefaultNetProtocol :: String
913
drbdDefaultNetProtocol = "C"
914

    
915
drbdMigrationNetProtocol :: String
916
drbdMigrationNetProtocol = "C"
917

    
918
drbdStatusFile :: String
919
drbdStatusFile = "/proc/drbd"
920

    
921
-- | Size of DRBD meta block device
922
drbdMetaSize :: Int
923
drbdMetaSize = 128
924

    
925
-- * Drbd barrier types
926

    
927
drbdBDiskBarriers :: String
928
drbdBDiskBarriers = "b"
929

    
930
drbdBDiskDrain :: String
931
drbdBDiskDrain = "d"
932

    
933
drbdBDiskFlush :: String
934
drbdBDiskFlush = "f"
935

    
936
drbdBNone :: String
937
drbdBNone = "n"
938

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

    
953
-- | Rbd tool command
954
rbdCmd :: String
955
rbdCmd = "rbd"
956

    
957
-- * File backend driver
958

    
959
fdBlktap :: String
960
fdBlktap = Types.fileDriverToRaw FileBlktap
961

    
962
fdBlktap2 :: String
963
fdBlktap2 = Types.fileDriverToRaw FileBlktap2
964

    
965
fdLoop :: String
966
fdLoop = Types.fileDriverToRaw FileLoop
967

    
968
fdDefault :: String
969
fdDefault = fdLoop
970

    
971
fileDriver :: FrozenSet String
972
fileDriver =
973
  ConstantUtils.mkSet $
974
  map Types.fileDriverToRaw [minBound..]
975

    
976
-- | The set of drbd-like disk types
977
dtsDrbd :: FrozenSet String
978
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
979

    
980
-- * Disk access mode
981

    
982
diskRdonly :: String
983
diskRdonly = Types.diskModeToRaw DiskRdOnly
984

    
985
diskRdwr :: String
986
diskRdwr = Types.diskModeToRaw DiskRdWr
987

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

    
991
-- * Disk replacement mode
992

    
993
replaceDiskAuto :: String
994
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
995

    
996
replaceDiskChg :: String
997
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
998

    
999
replaceDiskPri :: String
1000
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
1001

    
1002
replaceDiskSec :: String
1003
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
1004

    
1005
replaceModes :: FrozenSet String
1006
replaceModes =
1007
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
1008

    
1009
-- * Instance export mode
1010

    
1011
exportModeLocal :: String
1012
exportModeLocal = Types.exportModeToRaw ExportModeLocal
1013

    
1014
exportModeRemote :: String
1015
exportModeRemote = Types.exportModeToRaw ExportModeRemote
1016

    
1017
exportModes :: FrozenSet String
1018
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
1019

    
1020
-- * Instance creation modes
1021

    
1022
instanceCreate :: String
1023
instanceCreate = Types.instCreateModeToRaw InstCreate
1024

    
1025
instanceImport :: String
1026
instanceImport = Types.instCreateModeToRaw InstImport
1027

    
1028
instanceRemoteImport :: String
1029
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1030

    
1031
instanceCreateModes :: FrozenSet String
1032
instanceCreateModes =
1033
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1034

    
1035
-- * Remote import/export handshake message and version
1036

    
1037
rieHandshake :: String
1038
rieHandshake = "Hi, I'm Ganeti"
1039

    
1040
rieVersion :: Int
1041
rieVersion = 0
1042

    
1043
-- | Remote import/export certificate validity (seconds)
1044
rieCertValidity :: Int
1045
rieCertValidity = 24 * 60 * 60
1046

    
1047
-- | Export only: how long to wait per connection attempt (seconds)
1048
rieConnectAttemptTimeout :: Int
1049
rieConnectAttemptTimeout = 20
1050

    
1051
-- | Export only: number of attempts to connect
1052
rieConnectRetries :: Int
1053
rieConnectRetries = 10
1054

    
1055
-- | Overall timeout for establishing connection
1056
rieConnectTimeout :: Int
1057
rieConnectTimeout = 180
1058

    
1059
-- | Give child process up to 5 seconds to exit after sending a signal
1060
childLingerTimeout :: Double
1061
childLingerTimeout = 5.0
1062

    
1063
-- * Import/export config options
1064

    
1065
inisectBep :: String
1066
inisectBep = "backend"
1067

    
1068
inisectExp :: String
1069
inisectExp = "export"
1070

    
1071
inisectHyp :: String
1072
inisectHyp = "hypervisor"
1073

    
1074
inisectIns :: String
1075
inisectIns = "instance"
1076

    
1077
inisectOsp :: String
1078
inisectOsp = "os"
1079

    
1080
-- * Dynamic device modification
1081

    
1082
ddmAdd :: String
1083
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1084

    
1085
ddmModify :: String
1086
ddmModify = Types.ddmFullToRaw DdmFullModify
1087

    
1088
ddmRemove :: String
1089
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1090

    
1091
ddmsValues :: FrozenSet String
1092
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1093

    
1094
ddmsValuesWithModify :: FrozenSet String
1095
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1096

    
1097
-- * Common exit codes
1098

    
1099
exitSuccess :: Int
1100
exitSuccess = 0
1101

    
1102
exitFailure :: Int
1103
exitFailure = ConstantUtils.exitFailure
1104

    
1105
exitNotcluster :: Int
1106
exitNotcluster = 5
1107

    
1108
exitNotmaster :: Int
1109
exitNotmaster = 11
1110

    
1111
exitNodesetupError :: Int
1112
exitNodesetupError = 12
1113

    
1114
-- | Need user confirmation
1115
exitConfirmation :: Int
1116
exitConfirmation = 13
1117

    
1118
-- | Exit code for query operations with unknown fields
1119
exitUnknownField :: Int
1120
exitUnknownField = 14
1121

    
1122
-- * Tags
1123

    
1124
tagCluster :: String
1125
tagCluster = Types.tagKindToRaw TagKindCluster
1126

    
1127
tagInstance :: String
1128
tagInstance = Types.tagKindToRaw TagKindInstance
1129

    
1130
tagNetwork :: String
1131
tagNetwork = Types.tagKindToRaw TagKindNetwork
1132

    
1133
tagNode :: String
1134
tagNode = Types.tagKindToRaw TagKindNode
1135

    
1136
tagNodegroup :: String
1137
tagNodegroup = Types.tagKindToRaw TagKindGroup
1138

    
1139
validTagTypes :: FrozenSet String
1140
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1141

    
1142
maxTagLen :: Int
1143
maxTagLen = 128
1144

    
1145
maxTagsPerObj :: Int
1146
maxTagsPerObj = 4096
1147

    
1148
-- * Others
1149

    
1150
defaultBridge :: String
1151
defaultBridge = "xen-br0"
1152

    
1153
defaultOvs :: String
1154
defaultOvs = "switch1"
1155

    
1156
-- | 60 MiB/s, expressed in KiB/s
1157
classicDrbdSyncSpeed :: Int
1158
classicDrbdSyncSpeed = 60 * 1024
1159

    
1160
ip4AddressAny :: String
1161
ip4AddressAny = "0.0.0.0"
1162

    
1163
ip4AddressLocalhost :: String
1164
ip4AddressLocalhost = "127.0.0.1"
1165

    
1166
ip6AddressAny :: String
1167
ip6AddressAny = "::"
1168

    
1169
ip6AddressLocalhost :: String
1170
ip6AddressLocalhost = "::1"
1171

    
1172
ip4Version :: Int
1173
ip4Version = 4
1174

    
1175
ip6Version :: Int
1176
ip6Version = 6
1177

    
1178
validIpVersions :: FrozenSet Int
1179
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1180

    
1181
tcpPingTimeout :: Int
1182
tcpPingTimeout = 10
1183

    
1184
defaultVg :: String
1185
defaultVg = "xenvg"
1186

    
1187
defaultDrbdHelper :: String
1188
defaultDrbdHelper = "/bin/true"
1189

    
1190
minVgSize :: Int
1191
minVgSize = 20480
1192

    
1193
defaultMacPrefix :: String
1194
defaultMacPrefix = "aa:00:00"
1195

    
1196
-- | Default maximum instance wait time (seconds)
1197
defaultShutdownTimeout :: Int
1198
defaultShutdownTimeout = 120
1199

    
1200
-- | Node clock skew (seconds)
1201
nodeMaxClockSkew :: Int
1202
nodeMaxClockSkew = 150
1203

    
1204
-- | Time for an intra-cluster disk transfer to wait for a connection
1205
diskTransferConnectTimeout :: Int
1206
diskTransferConnectTimeout = 60
1207

    
1208
-- | Disk index separator
1209
diskSeparator :: String
1210
diskSeparator = AutoConf.diskSeparator
1211

    
1212
ipCommandPath :: String
1213
ipCommandPath = AutoConf.ipPath
1214

    
1215
-- | Key for job IDs in opcode result
1216
jobIdsKey :: String
1217
jobIdsKey = "jobs"
1218

    
1219
-- * Runparts results
1220

    
1221
runpartsErr :: Int
1222
runpartsErr = 2
1223

    
1224
runpartsRun :: Int
1225
runpartsRun = 1
1226

    
1227
runpartsSkip :: Int
1228
runpartsSkip = 0
1229

    
1230
runpartsStatus :: [Int]
1231
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1232

    
1233
-- * RPC
1234

    
1235
rpcEncodingNone :: Int
1236
rpcEncodingNone = 0
1237

    
1238
rpcEncodingZlibBase64 :: Int
1239
rpcEncodingZlibBase64 = 1
1240

    
1241
-- * Timeout table
1242
--
1243
-- Various time constants for the timeout table
1244

    
1245
rpcTmoUrgent :: Int
1246
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1247

    
1248
rpcTmoFast :: Int
1249
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1250

    
1251
rpcTmoNormal :: Int
1252
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1253

    
1254
rpcTmoSlow :: Int
1255
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1256

    
1257
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1258
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1259
-- Python name.
1260
rpcTmo_4hrs :: Int
1261
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1262

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

    
1269
-- | Timeout for connecting to nodes (seconds)
1270
rpcConnectTimeout :: Int
1271
rpcConnectTimeout = 5
1272

    
1273
-- OS
1274

    
1275
osScriptCreate :: String
1276
osScriptCreate = "create"
1277

    
1278
osScriptExport :: String
1279
osScriptExport = "export"
1280

    
1281
osScriptImport :: String
1282
osScriptImport = "import"
1283

    
1284
osScriptRename :: String
1285
osScriptRename = "rename"
1286

    
1287
osScriptVerify :: String
1288
osScriptVerify = "verify"
1289

    
1290
osScripts :: [String]
1291
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1292
             osScriptVerify]
1293

    
1294
osApiFile :: String
1295
osApiFile = "ganeti_api_version"
1296

    
1297
osVariantsFile :: String
1298
osVariantsFile = "variants.list"
1299

    
1300
osParametersFile :: String
1301
osParametersFile = "parameters.list"
1302

    
1303
osValidateParameters :: String
1304
osValidateParameters = "parameters"
1305

    
1306
osValidateCalls :: FrozenSet String
1307
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1308

    
1309
-- | External Storage (ES) related constants
1310

    
1311
esActionAttach :: String
1312
esActionAttach = "attach"
1313

    
1314
esActionCreate :: String
1315
esActionCreate = "create"
1316

    
1317
esActionDetach :: String
1318
esActionDetach = "detach"
1319

    
1320
esActionGrow :: String
1321
esActionGrow = "grow"
1322

    
1323
esActionRemove :: String
1324
esActionRemove = "remove"
1325

    
1326
esActionSetinfo :: String
1327
esActionSetinfo = "setinfo"
1328

    
1329
esActionVerify :: String
1330
esActionVerify = "verify"
1331

    
1332
esScriptCreate :: String
1333
esScriptCreate = esActionCreate
1334

    
1335
esScriptRemove :: String
1336
esScriptRemove = esActionRemove
1337

    
1338
esScriptGrow :: String
1339
esScriptGrow = esActionGrow
1340

    
1341
esScriptAttach :: String
1342
esScriptAttach = esActionAttach
1343

    
1344
esScriptDetach :: String
1345
esScriptDetach = esActionDetach
1346

    
1347
esScriptSetinfo :: String
1348
esScriptSetinfo = esActionSetinfo
1349

    
1350
esScriptVerify :: String
1351
esScriptVerify = esActionVerify
1352

    
1353
esScripts :: FrozenSet String
1354
esScripts =
1355
  ConstantUtils.mkSet [esScriptAttach,
1356
                       esScriptCreate,
1357
                       esScriptDetach,
1358
                       esScriptGrow,
1359
                       esScriptRemove,
1360
                       esScriptSetinfo,
1361
                       esScriptVerify]
1362

    
1363
esParametersFile :: String
1364
esParametersFile = "parameters.list"
1365

    
1366
-- * Reboot types
1367

    
1368
instanceRebootSoft :: String
1369
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1370

    
1371
instanceRebootHard :: String
1372
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1373

    
1374
instanceRebootFull :: String
1375
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1376

    
1377
rebootTypes :: FrozenSet String
1378
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1379

    
1380
-- * Instance reboot behaviors
1381

    
1382
instanceRebootAllowed :: String
1383
instanceRebootAllowed = "reboot"
1384

    
1385
instanceRebootExit :: String
1386
instanceRebootExit = "exit"
1387

    
1388
rebootBehaviors :: [String]
1389
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1390

    
1391
-- * VTypes
1392

    
1393
vtypeBool :: VType
1394
vtypeBool = VTypeBool
1395

    
1396
vtypeInt :: VType
1397
vtypeInt = VTypeInt
1398

    
1399
vtypeMaybeString :: VType
1400
vtypeMaybeString = VTypeMaybeString
1401

    
1402
-- | Size in MiBs
1403
vtypeSize :: VType
1404
vtypeSize = VTypeSize
1405

    
1406
vtypeString :: VType
1407
vtypeString = VTypeString
1408

    
1409
enforceableTypes :: FrozenSet VType
1410
enforceableTypes = ConstantUtils.mkSet [minBound..]
1411

    
1412
-- | Constant representing that the user does not specify any IP version
1413
ifaceNoIpVersionSpecified :: Int
1414
ifaceNoIpVersionSpecified = 0
1415

    
1416
validSerialSpeeds :: [Int]
1417
validSerialSpeeds =
1418
  [75,
1419
   110,
1420
   300,
1421
   600,
1422
   1200,
1423
   1800,
1424
   2400,
1425
   4800,
1426
   9600,
1427
   14400,
1428
   19200,
1429
   28800,
1430
   38400,
1431
   57600,
1432
   115200,
1433
   230400,
1434
   345600,
1435
   460800]
1436

    
1437
-- * HV parameter names (global namespace)
1438

    
1439
hvAcpi :: String
1440
hvAcpi = "acpi"
1441

    
1442
hvBlockdevPrefix :: String
1443
hvBlockdevPrefix = "blockdev_prefix"
1444

    
1445
hvBootloaderArgs :: String
1446
hvBootloaderArgs = "bootloader_args"
1447

    
1448
hvBootloaderPath :: String
1449
hvBootloaderPath = "bootloader_path"
1450

    
1451
hvBootOrder :: String
1452
hvBootOrder = "boot_order"
1453

    
1454
hvCdromImagePath :: String
1455
hvCdromImagePath = "cdrom_image_path"
1456

    
1457
hvCpuCap :: String
1458
hvCpuCap = "cpu_cap"
1459

    
1460
hvCpuCores :: String
1461
hvCpuCores = "cpu_cores"
1462

    
1463
hvCpuMask :: String
1464
hvCpuMask = "cpu_mask"
1465

    
1466
hvCpuSockets :: String
1467
hvCpuSockets = "cpu_sockets"
1468

    
1469
hvCpuThreads :: String
1470
hvCpuThreads = "cpu_threads"
1471

    
1472
hvCpuType :: String
1473
hvCpuType = "cpu_type"
1474

    
1475
hvCpuWeight :: String
1476
hvCpuWeight = "cpu_weight"
1477

    
1478
hvDeviceModel :: String
1479
hvDeviceModel = "device_model"
1480

    
1481
hvDiskCache :: String
1482
hvDiskCache = "disk_cache"
1483

    
1484
hvDiskType :: String
1485
hvDiskType = "disk_type"
1486

    
1487
hvInitrdPath :: String
1488
hvInitrdPath = "initrd_path"
1489

    
1490
hvInitScript :: String
1491
hvInitScript = "init_script"
1492

    
1493
hvKernelArgs :: String
1494
hvKernelArgs = "kernel_args"
1495

    
1496
hvKernelPath :: String
1497
hvKernelPath = "kernel_path"
1498

    
1499
hvKeymap :: String
1500
hvKeymap = "keymap"
1501

    
1502
hvKvmCdrom2ImagePath :: String
1503
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1504

    
1505
hvKvmCdromDiskType :: String
1506
hvKvmCdromDiskType = "cdrom_disk_type"
1507

    
1508
hvKvmExtra :: String
1509
hvKvmExtra = "kvm_extra"
1510

    
1511
hvKvmFlag :: String
1512
hvKvmFlag = "kvm_flag"
1513

    
1514
hvKvmFloppyImagePath :: String
1515
hvKvmFloppyImagePath = "floppy_image_path"
1516

    
1517
hvKvmMachineVersion :: String
1518
hvKvmMachineVersion = "machine_version"
1519

    
1520
hvKvmPath :: String
1521
hvKvmPath = "kvm_path"
1522

    
1523
hvKvmSpiceAudioCompr :: String
1524
hvKvmSpiceAudioCompr = "spice_playback_compression"
1525

    
1526
hvKvmSpiceBind :: String
1527
hvKvmSpiceBind = "spice_bind"
1528

    
1529
hvKvmSpiceIpVersion :: String
1530
hvKvmSpiceIpVersion = "spice_ip_version"
1531

    
1532
hvKvmSpiceJpegImgCompr :: String
1533
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1534

    
1535
hvKvmSpiceLosslessImgCompr :: String
1536
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1537

    
1538
hvKvmSpicePasswordFile :: String
1539
hvKvmSpicePasswordFile = "spice_password_file"
1540

    
1541
hvKvmSpiceStreamingVideoDetection :: String
1542
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1543

    
1544
hvKvmSpiceTlsCiphers :: String
1545
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1546

    
1547
hvKvmSpiceUseTls :: String
1548
hvKvmSpiceUseTls = "spice_use_tls"
1549

    
1550
hvKvmSpiceUseVdagent :: String
1551
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1552

    
1553
hvKvmSpiceZlibGlzImgCompr :: String
1554
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1555

    
1556
hvKvmUseChroot :: String
1557
hvKvmUseChroot = "use_chroot"
1558

    
1559
hvMemPath :: String
1560
hvMemPath = "mem_path"
1561

    
1562
hvMigrationBandwidth :: String
1563
hvMigrationBandwidth = "migration_bandwidth"
1564

    
1565
hvMigrationDowntime :: String
1566
hvMigrationDowntime = "migration_downtime"
1567

    
1568
hvMigrationMode :: String
1569
hvMigrationMode = "migration_mode"
1570

    
1571
hvMigrationPort :: String
1572
hvMigrationPort = "migration_port"
1573

    
1574
hvNicType :: String
1575
hvNicType = "nic_type"
1576

    
1577
hvPae :: String
1578
hvPae = "pae"
1579

    
1580
hvPassthrough :: String
1581
hvPassthrough = "pci_pass"
1582

    
1583
hvRebootBehavior :: String
1584
hvRebootBehavior = "reboot_behavior"
1585

    
1586
hvRootPath :: String
1587
hvRootPath = "root_path"
1588

    
1589
hvSecurityDomain :: String
1590
hvSecurityDomain = "security_domain"
1591

    
1592
hvSecurityModel :: String
1593
hvSecurityModel = "security_model"
1594

    
1595
hvSerialConsole :: String
1596
hvSerialConsole = "serial_console"
1597

    
1598
hvSerialSpeed :: String
1599
hvSerialSpeed = "serial_speed"
1600

    
1601
hvSoundhw :: String
1602
hvSoundhw = "soundhw"
1603

    
1604
hvUsbDevices :: String
1605
hvUsbDevices = "usb_devices"
1606

    
1607
hvUsbMouse :: String
1608
hvUsbMouse = "usb_mouse"
1609

    
1610
hvUseBootloader :: String
1611
hvUseBootloader = "use_bootloader"
1612

    
1613
hvUseLocaltime :: String
1614
hvUseLocaltime = "use_localtime"
1615

    
1616
hvVga :: String
1617
hvVga = "vga"
1618

    
1619
hvVhostNet :: String
1620
hvVhostNet = "vhost_net"
1621

    
1622
hvVifScript :: String
1623
hvVifScript = "vif_script"
1624

    
1625
hvVifType :: String
1626
hvVifType = "vif_type"
1627

    
1628
hvViridian :: String
1629
hvViridian = "viridian"
1630

    
1631
hvVncBindAddress :: String
1632
hvVncBindAddress = "vnc_bind_address"
1633

    
1634
hvVncPasswordFile :: String
1635
hvVncPasswordFile = "vnc_password_file"
1636

    
1637
hvVncTls :: String
1638
hvVncTls = "vnc_tls"
1639

    
1640
hvVncX509 :: String
1641
hvVncX509 = "vnc_x509_path"
1642

    
1643
hvVncX509Verify :: String
1644
hvVncX509Verify = "vnc_x509_verify"
1645

    
1646
hvVnetHdr :: String
1647
hvVnetHdr = "vnet_hdr"
1648

    
1649
hvXenCmd :: String
1650
hvXenCmd = "xen_cmd"
1651

    
1652
hvXenCpuid :: String
1653
hvXenCpuid = "cpuid"
1654

    
1655
hvsParameterTitles :: Map String String
1656
hvsParameterTitles =
1657
  Map.fromList
1658
  [(hvAcpi, "ACPI"),
1659
   (hvBootOrder, "Boot_order"),
1660
   (hvCdromImagePath, "CDROM_image_path"),
1661
   (hvCpuType, "cpu_type"),
1662
   (hvDiskType, "Disk_type"),
1663
   (hvInitrdPath, "Initrd_path"),
1664
   (hvKernelPath, "Kernel_path"),
1665
   (hvNicType, "NIC_type"),
1666
   (hvPae, "PAE"),
1667
   (hvPassthrough, "pci_pass"),
1668
   (hvVncBindAddress, "VNC_bind_address")]
1669

    
1670
hvsParameters :: FrozenSet String
1671
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1672

    
1673
hvsParameterTypes :: Map String VType
1674
hvsParameterTypes = Map.fromList
1675
  [ (hvAcpi,                            VTypeBool)
1676
  , (hvBlockdevPrefix,                  VTypeString)
1677
  , (hvBootloaderArgs,                  VTypeString)
1678
  , (hvBootloaderPath,                  VTypeString)
1679
  , (hvBootOrder,                       VTypeString)
1680
  , (hvCdromImagePath,                  VTypeString)
1681
  , (hvCpuCap,                          VTypeInt)
1682
  , (hvCpuCores,                        VTypeInt)
1683
  , (hvCpuMask,                         VTypeString)
1684
  , (hvCpuSockets,                      VTypeInt)
1685
  , (hvCpuThreads,                      VTypeInt)
1686
  , (hvCpuType,                         VTypeString)
1687
  , (hvCpuWeight,                       VTypeInt)
1688
  , (hvDeviceModel,                     VTypeString)
1689
  , (hvDiskCache,                       VTypeString)
1690
  , (hvDiskType,                        VTypeString)
1691
  , (hvInitrdPath,                      VTypeString)
1692
  , (hvInitScript,                      VTypeString)
1693
  , (hvKernelArgs,                      VTypeString)
1694
  , (hvKernelPath,                      VTypeString)
1695
  , (hvKeymap,                          VTypeString)
1696
  , (hvKvmCdrom2ImagePath,              VTypeString)
1697
  , (hvKvmCdromDiskType,                VTypeString)
1698
  , (hvKvmExtra,                        VTypeString)
1699
  , (hvKvmFlag,                         VTypeString)
1700
  , (hvKvmFloppyImagePath,              VTypeString)
1701
  , (hvKvmMachineVersion,               VTypeString)
1702
  , (hvKvmPath,                         VTypeString)
1703
  , (hvKvmSpiceAudioCompr,              VTypeBool)
1704
  , (hvKvmSpiceBind,                    VTypeString)
1705
  , (hvKvmSpiceIpVersion,               VTypeInt)
1706
  , (hvKvmSpiceJpegImgCompr,            VTypeString)
1707
  , (hvKvmSpiceLosslessImgCompr,        VTypeString)
1708
  , (hvKvmSpicePasswordFile,            VTypeString)
1709
  , (hvKvmSpiceStreamingVideoDetection, VTypeString)
1710
  , (hvKvmSpiceTlsCiphers,              VTypeString)
1711
  , (hvKvmSpiceUseTls,                  VTypeBool)
1712
  , (hvKvmSpiceUseVdagent,              VTypeBool)
1713
  , (hvKvmSpiceZlibGlzImgCompr,         VTypeString)
1714
  , (hvKvmUseChroot,                    VTypeBool)
1715
  , (hvMemPath,                         VTypeString)
1716
  , (hvMigrationBandwidth,              VTypeInt)
1717
  , (hvMigrationDowntime,               VTypeInt)
1718
  , (hvMigrationMode,                   VTypeString)
1719
  , (hvMigrationPort,                   VTypeInt)
1720
  , (hvNicType,                         VTypeString)
1721
  , (hvPae,                             VTypeBool)
1722
  , (hvPassthrough,                     VTypeString)
1723
  , (hvRebootBehavior,                  VTypeString)
1724
  , (hvRootPath,                        VTypeMaybeString)
1725
  , (hvSecurityDomain,                  VTypeString)
1726
  , (hvSecurityModel,                   VTypeString)
1727
  , (hvSerialConsole,                   VTypeBool)
1728
  , (hvSerialSpeed,                     VTypeInt)
1729
  , (hvSoundhw,                         VTypeString)
1730
  , (hvUsbDevices,                      VTypeString)
1731
  , (hvUsbMouse,                        VTypeString)
1732
  , (hvUseBootloader,                   VTypeBool)
1733
  , (hvUseLocaltime,                    VTypeBool)
1734
  , (hvVga,                             VTypeString)
1735
  , (hvVhostNet,                        VTypeBool)
1736
  , (hvVifScript,                       VTypeString)
1737
  , (hvVifType,                         VTypeString)
1738
  , (hvViridian,                        VTypeBool)
1739
  , (hvVncBindAddress,                  VTypeString)
1740
  , (hvVncPasswordFile,                 VTypeString)
1741
  , (hvVncTls,                          VTypeBool)
1742
  , (hvVncX509,                         VTypeString)
1743
  , (hvVncX509Verify,                   VTypeBool)
1744
  , (hvVnetHdr,                         VTypeBool)
1745
  , (hvXenCmd,                          VTypeString)
1746
  , (hvXenCpuid,                        VTypeString)
1747
  ]
1748

    
1749
-- * Migration statuses
1750

    
1751
hvMigrationActive :: String
1752
hvMigrationActive = "active"
1753

    
1754
hvMigrationCancelled :: String
1755
hvMigrationCancelled = "cancelled"
1756

    
1757
hvMigrationCompleted :: String
1758
hvMigrationCompleted = "completed"
1759

    
1760
hvMigrationFailed :: String
1761
hvMigrationFailed = "failed"
1762

    
1763
hvMigrationValidStatuses :: FrozenSet String
1764
hvMigrationValidStatuses =
1765
  ConstantUtils.mkSet [hvMigrationActive,
1766
                       hvMigrationCancelled,
1767
                       hvMigrationCompleted,
1768
                       hvMigrationFailed]
1769

    
1770
hvMigrationFailedStatuses :: FrozenSet String
1771
hvMigrationFailedStatuses =
1772
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1773

    
1774
-- | KVM-specific statuses
1775
--
1776
-- FIXME: this constant seems unnecessary
1777
hvKvmMigrationValidStatuses :: FrozenSet String
1778
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1779

    
1780
-- | Node info keys
1781
hvNodeinfoKeyVersion :: String
1782
hvNodeinfoKeyVersion = "hv_version"
1783

    
1784
-- * Hypervisor state
1785

    
1786
hvstCpuNode :: String
1787
hvstCpuNode = "cpu_node"
1788

    
1789
hvstCpuTotal :: String
1790
hvstCpuTotal = "cpu_total"
1791

    
1792
hvstMemoryHv :: String
1793
hvstMemoryHv = "mem_hv"
1794

    
1795
hvstMemoryNode :: String
1796
hvstMemoryNode = "mem_node"
1797

    
1798
hvstMemoryTotal :: String
1799
hvstMemoryTotal = "mem_total"
1800

    
1801
hvstsParameters :: FrozenSet String
1802
hvstsParameters =
1803
  ConstantUtils.mkSet [hvstCpuNode,
1804
                       hvstCpuTotal,
1805
                       hvstMemoryHv,
1806
                       hvstMemoryNode,
1807
                       hvstMemoryTotal]
1808

    
1809
hvstDefaults :: Map String Int
1810
hvstDefaults =
1811
  Map.fromList
1812
  [(hvstCpuNode, 1),
1813
   (hvstCpuTotal, 1),
1814
   (hvstMemoryHv, 0),
1815
   (hvstMemoryTotal, 0),
1816
   (hvstMemoryNode, 0)]
1817

    
1818
hvstsParameterTypes :: Map String VType
1819
hvstsParameterTypes =
1820
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1821
                (hvstMemoryNode, VTypeInt),
1822
                (hvstMemoryHv, VTypeInt),
1823
                (hvstCpuTotal, VTypeInt),
1824
                (hvstCpuNode, VTypeInt)]
1825

    
1826
-- * Disk state
1827

    
1828
dsDiskOverhead :: String
1829
dsDiskOverhead = "disk_overhead"
1830

    
1831
dsDiskReserved :: String
1832
dsDiskReserved = "disk_reserved"
1833

    
1834
dsDiskTotal :: String
1835
dsDiskTotal = "disk_total"
1836

    
1837
dsDefaults :: Map String Int
1838
dsDefaults =
1839
  Map.fromList
1840
  [(dsDiskTotal, 0),
1841
   (dsDiskReserved, 0),
1842
   (dsDiskOverhead, 0)]
1843

    
1844
dssParameterTypes :: Map String VType
1845
dssParameterTypes =
1846
  Map.fromList [(dsDiskTotal, VTypeInt),
1847
                (dsDiskReserved, VTypeInt),
1848
                (dsDiskOverhead, VTypeInt)]
1849

    
1850
dssParameters :: FrozenSet String
1851
dssParameters =
1852
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1853

    
1854
dsValidTypes :: FrozenSet String
1855
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1856

    
1857
-- Backend parameter names
1858

    
1859
beAlwaysFailover :: String
1860
beAlwaysFailover = "always_failover"
1861

    
1862
beAutoBalance :: String
1863
beAutoBalance = "auto_balance"
1864

    
1865
beMaxmem :: String
1866
beMaxmem = "maxmem"
1867

    
1868
-- | Deprecated and replaced by max and min mem
1869
beMemory :: String
1870
beMemory = "memory"
1871

    
1872
beMinmem :: String
1873
beMinmem = "minmem"
1874

    
1875
beSpindleUse :: String
1876
beSpindleUse = "spindle_use"
1877

    
1878
beVcpus :: String
1879
beVcpus = "vcpus"
1880

    
1881
besParameterTypes :: Map String VType
1882
besParameterTypes =
1883
  Map.fromList [(beAlwaysFailover, VTypeBool),
1884
                (beAutoBalance, VTypeBool),
1885
                (beMaxmem, VTypeSize),
1886
                (beMinmem, VTypeSize),
1887
                (beSpindleUse, VTypeInt),
1888
                (beVcpus, VTypeInt)]
1889

    
1890
besParameterTitles :: Map String String
1891
besParameterTitles =
1892
  Map.fromList [(beAutoBalance, "Auto_balance"),
1893
                (beMinmem, "ConfigMinMem"),
1894
                (beVcpus, "ConfigVCPUs"),
1895
                (beMaxmem, "ConfigMaxMem")]
1896

    
1897
besParameterCompat :: Map String VType
1898
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1899

    
1900
besParameters :: FrozenSet String
1901
besParameters =
1902
  ConstantUtils.mkSet [beAlwaysFailover,
1903
                       beAutoBalance,
1904
                       beMaxmem,
1905
                       beMinmem,
1906
                       beSpindleUse,
1907
                       beVcpus]
1908

    
1909
-- | Instance specs
1910
--
1911
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1912

    
1913
ispecMemSize :: String
1914
ispecMemSize = ConstantUtils.ispecMemSize
1915

    
1916
ispecCpuCount :: String
1917
ispecCpuCount = ConstantUtils.ispecCpuCount
1918

    
1919
ispecDiskCount :: String
1920
ispecDiskCount = ConstantUtils.ispecDiskCount
1921

    
1922
ispecDiskSize :: String
1923
ispecDiskSize = ConstantUtils.ispecDiskSize
1924

    
1925
ispecNicCount :: String
1926
ispecNicCount = ConstantUtils.ispecNicCount
1927

    
1928
ispecSpindleUse :: String
1929
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1930

    
1931
ispecsParameterTypes :: Map String VType
1932
ispecsParameterTypes =
1933
  Map.fromList
1934
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1935
   (ConstantUtils.ispecCpuCount, VTypeInt),
1936
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1937
   (ConstantUtils.ispecMemSize, VTypeInt),
1938
   (ConstantUtils.ispecNicCount, VTypeInt),
1939
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1940

    
1941
ispecsParameters :: FrozenSet String
1942
ispecsParameters =
1943
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1944
                       ConstantUtils.ispecDiskCount,
1945
                       ConstantUtils.ispecDiskSize,
1946
                       ConstantUtils.ispecMemSize,
1947
                       ConstantUtils.ispecNicCount,
1948
                       ConstantUtils.ispecSpindleUse]
1949

    
1950
ispecsMinmax :: String
1951
ispecsMinmax = ConstantUtils.ispecsMinmax
1952

    
1953
ispecsMax :: String
1954
ispecsMax = "max"
1955

    
1956
ispecsMin :: String
1957
ispecsMin = "min"
1958

    
1959
ispecsStd :: String
1960
ispecsStd = ConstantUtils.ispecsStd
1961

    
1962
ipolicyDts :: String
1963
ipolicyDts = ConstantUtils.ipolicyDts
1964

    
1965
ipolicyVcpuRatio :: String
1966
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1967

    
1968
ipolicySpindleRatio :: String
1969
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
1970

    
1971
ispecsMinmaxKeys :: FrozenSet String
1972
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1973

    
1974
ipolicyParameters :: FrozenSet String
1975
ipolicyParameters =
1976
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1977
                       ConstantUtils.ipolicySpindleRatio]
1978

    
1979
ipolicyAllKeys :: FrozenSet String
1980
ipolicyAllKeys =
1981
  ConstantUtils.union ipolicyParameters $
1982
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1983
                       ConstantUtils.ispecsMinmax,
1984
                       ispecsStd]
1985

    
1986
-- | Node parameter names
1987

    
1988
ndExclusiveStorage :: String
1989
ndExclusiveStorage = "exclusive_storage"
1990

    
1991
ndOobProgram :: String
1992
ndOobProgram = "oob_program"
1993

    
1994
ndSpindleCount :: String
1995
ndSpindleCount = "spindle_count"
1996

    
1997
ndOvs :: String
1998
ndOvs = "ovs"
1999

    
2000
ndOvsLink :: String
2001
ndOvsLink = "ovs_link"
2002

    
2003
ndOvsName :: String
2004
ndOvsName = "ovs_name"
2005

    
2006
ndsParameterTypes :: Map String VType
2007
ndsParameterTypes =
2008
  Map.fromList
2009
  [(ndExclusiveStorage, VTypeBool),
2010
   (ndOobProgram, VTypeString),
2011
   (ndOvs, VTypeBool),
2012
   (ndOvsLink, VTypeMaybeString),
2013
   (ndOvsName, VTypeMaybeString),
2014
   (ndSpindleCount, VTypeInt)]
2015

    
2016
ndsParameters :: FrozenSet String
2017
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
2018

    
2019
ndsParameterTitles :: Map String String
2020
ndsParameterTitles =
2021
  Map.fromList
2022
  [(ndExclusiveStorage, "ExclusiveStorage"),
2023
   (ndOobProgram, "OutOfBandProgram"),
2024
   (ndOvs, "OpenvSwitch"),
2025
   (ndOvsLink, "OpenvSwitchLink"),
2026
   (ndOvsName, "OpenvSwitchName"),
2027
   (ndSpindleCount, "SpindleCount")]
2028

    
2029
-- * Logical Disks parameters
2030

    
2031
ldpAccess :: String
2032
ldpAccess = "access"
2033

    
2034
ldpBarriers :: String
2035
ldpBarriers = "disabled-barriers"
2036

    
2037
ldpDefaultMetavg :: String
2038
ldpDefaultMetavg = "default-metavg"
2039

    
2040
ldpDelayTarget :: String
2041
ldpDelayTarget = "c-delay-target"
2042

    
2043
ldpDiskCustom :: String
2044
ldpDiskCustom = "disk-custom"
2045

    
2046
ldpDynamicResync :: String
2047
ldpDynamicResync = "dynamic-resync"
2048

    
2049
ldpFillTarget :: String
2050
ldpFillTarget = "c-fill-target"
2051

    
2052
ldpMaxRate :: String
2053
ldpMaxRate = "c-max-rate"
2054

    
2055
ldpMinRate :: String
2056
ldpMinRate = "c-min-rate"
2057

    
2058
ldpNetCustom :: String
2059
ldpNetCustom = "net-custom"
2060

    
2061
ldpNoMetaFlush :: String
2062
ldpNoMetaFlush = "disable-meta-flush"
2063

    
2064
ldpPlanAhead :: String
2065
ldpPlanAhead = "c-plan-ahead"
2066

    
2067
ldpPool :: String
2068
ldpPool = "pool"
2069

    
2070
ldpProtocol :: String
2071
ldpProtocol = "protocol"
2072

    
2073
ldpResyncRate :: String
2074
ldpResyncRate = "resync-rate"
2075

    
2076
ldpStripes :: String
2077
ldpStripes = "stripes"
2078

    
2079
diskLdTypes :: Map String VType
2080
diskLdTypes =
2081
  Map.fromList
2082
  [(ldpAccess, VTypeString),
2083
   (ldpResyncRate, VTypeInt),
2084
   (ldpStripes, VTypeInt),
2085
   (ldpBarriers, VTypeString),
2086
   (ldpNoMetaFlush, VTypeBool),
2087
   (ldpDefaultMetavg, VTypeString),
2088
   (ldpDiskCustom, VTypeString),
2089
   (ldpNetCustom, VTypeString),
2090
   (ldpProtocol, VTypeString),
2091
   (ldpDynamicResync, VTypeBool),
2092
   (ldpPlanAhead, VTypeInt),
2093
   (ldpFillTarget, VTypeInt),
2094
   (ldpDelayTarget, VTypeInt),
2095
   (ldpMaxRate, VTypeInt),
2096
   (ldpMinRate, VTypeInt),
2097
   (ldpPool, VTypeString)]
2098

    
2099
diskLdParameters :: FrozenSet String
2100
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2101

    
2102
-- * Disk template parameters
2103
--
2104
-- Disk template parameters can be set/changed by the user via
2105
-- gnt-cluster and gnt-group)
2106

    
2107
drbdResyncRate :: String
2108
drbdResyncRate = "resync-rate"
2109

    
2110
drbdDataStripes :: String
2111
drbdDataStripes = "data-stripes"
2112

    
2113
drbdMetaStripes :: String
2114
drbdMetaStripes = "meta-stripes"
2115

    
2116
drbdDiskBarriers :: String
2117
drbdDiskBarriers = "disk-barriers"
2118

    
2119
drbdMetaBarriers :: String
2120
drbdMetaBarriers = "meta-barriers"
2121

    
2122
drbdDefaultMetavg :: String
2123
drbdDefaultMetavg = "metavg"
2124

    
2125
drbdDiskCustom :: String
2126
drbdDiskCustom = "disk-custom"
2127

    
2128
drbdNetCustom :: String
2129
drbdNetCustom = "net-custom"
2130

    
2131
drbdProtocol :: String
2132
drbdProtocol = "protocol"
2133

    
2134
drbdDynamicResync :: String
2135
drbdDynamicResync = "dynamic-resync"
2136

    
2137
drbdPlanAhead :: String
2138
drbdPlanAhead = "c-plan-ahead"
2139

    
2140
drbdFillTarget :: String
2141
drbdFillTarget = "c-fill-target"
2142

    
2143
drbdDelayTarget :: String
2144
drbdDelayTarget = "c-delay-target"
2145

    
2146
drbdMaxRate :: String
2147
drbdMaxRate = "c-max-rate"
2148

    
2149
drbdMinRate :: String
2150
drbdMinRate = "c-min-rate"
2151

    
2152
lvStripes :: String
2153
lvStripes = "stripes"
2154

    
2155
rbdAccess :: String
2156
rbdAccess = "access"
2157

    
2158
rbdPool :: String
2159
rbdPool = "pool"
2160

    
2161
diskDtTypes :: Map String VType
2162
diskDtTypes =
2163
  Map.fromList [(drbdResyncRate, VTypeInt),
2164
                (drbdDataStripes, VTypeInt),
2165
                (drbdMetaStripes, VTypeInt),
2166
                (drbdDiskBarriers, VTypeString),
2167
                (drbdMetaBarriers, VTypeBool),
2168
                (drbdDefaultMetavg, VTypeString),
2169
                (drbdDiskCustom, VTypeString),
2170
                (drbdNetCustom, VTypeString),
2171
                (drbdProtocol, VTypeString),
2172
                (drbdDynamicResync, VTypeBool),
2173
                (drbdPlanAhead, VTypeInt),
2174
                (drbdFillTarget, VTypeInt),
2175
                (drbdDelayTarget, VTypeInt),
2176
                (drbdMaxRate, VTypeInt),
2177
                (drbdMinRate, VTypeInt),
2178
                (lvStripes, VTypeInt),
2179
                (rbdAccess, VTypeString),
2180
                (rbdPool, VTypeString)]
2181

    
2182
diskDtParameters :: FrozenSet String
2183
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2184

    
2185
-- * Dynamic disk parameters
2186

    
2187
ddpLocalIp :: String
2188
ddpLocalIp = "local-ip"
2189

    
2190
ddpRemoteIp :: String
2191
ddpRemoteIp = "remote-ip"
2192

    
2193
ddpPort :: String
2194
ddpPort = "port"
2195

    
2196
ddpLocalMinor :: String
2197
ddpLocalMinor = "local-minor"
2198

    
2199
ddpRemoteMinor :: String
2200
ddpRemoteMinor = "remote-minor"
2201

    
2202
-- * OOB supported commands
2203

    
2204
oobPowerOn :: String
2205
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2206

    
2207
oobPowerOff :: String
2208
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2209

    
2210
oobPowerCycle :: String
2211
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2212

    
2213
oobPowerStatus :: String
2214
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2215

    
2216
oobHealth :: String
2217
oobHealth = Types.oobCommandToRaw OobHealth
2218

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

    
2222
oobPowerStatusPowered :: String
2223
oobPowerStatusPowered = "powered"
2224

    
2225
-- | 60 seconds
2226
oobTimeout :: Int
2227
oobTimeout = 60
2228

    
2229
-- | 2 seconds
2230
oobPowerDelay :: Double
2231
oobPowerDelay = 2.0
2232

    
2233
oobStatusCritical :: String
2234
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2235

    
2236
oobStatusOk :: String
2237
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2238

    
2239
oobStatusUnknown :: String
2240
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2241

    
2242
oobStatusWarning :: String
2243
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2244

    
2245
oobStatuses :: FrozenSet String
2246
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2247

    
2248
-- | Instance Parameters Profile
2249
ppDefault :: String
2250
ppDefault = "default"
2251

    
2252
-- * nic* constants are used inside the ganeti config
2253

    
2254
nicLink :: String
2255
nicLink = "link"
2256

    
2257
nicMode :: String
2258
nicMode = "mode"
2259

    
2260
nicVlan :: String
2261
nicVlan = "vlan"
2262

    
2263
nicsParameterTypes :: Map String VType
2264
nicsParameterTypes =
2265
  Map.fromList [(nicMode, vtypeString),
2266
                (nicLink, vtypeString),
2267
                (nicVlan, vtypeString)]
2268

    
2269
nicsParameters :: FrozenSet String
2270
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2271

    
2272
nicModeBridged :: String
2273
nicModeBridged = Types.nICModeToRaw NMBridged
2274

    
2275
nicModeRouted :: String
2276
nicModeRouted = Types.nICModeToRaw NMRouted
2277

    
2278
nicModeOvs :: String
2279
nicModeOvs = Types.nICModeToRaw NMOvs
2280

    
2281
nicIpPool :: String
2282
nicIpPool = Types.nICModeToRaw NMPool
2283

    
2284
nicValidModes :: FrozenSet String
2285
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2286

    
2287
releaseAction :: String
2288
releaseAction = "release"
2289

    
2290
reserveAction :: String
2291
reserveAction = "reserve"
2292

    
2293
-- * idisk* constants are used in opcodes, to create/change disks
2294

    
2295
idiskAdopt :: String
2296
idiskAdopt = "adopt"
2297

    
2298
idiskMetavg :: String
2299
idiskMetavg = "metavg"
2300

    
2301
idiskMode :: String
2302
idiskMode = "mode"
2303

    
2304
idiskName :: String
2305
idiskName = "name"
2306

    
2307
idiskSize :: String
2308
idiskSize = "size"
2309

    
2310
idiskSpindles :: String
2311
idiskSpindles = "spindles"
2312

    
2313
idiskVg :: String
2314
idiskVg = "vg"
2315

    
2316
idiskProvider :: String
2317
idiskProvider = "provider"
2318

    
2319
idiskParamsTypes :: Map String VType
2320
idiskParamsTypes =
2321
  Map.fromList [(idiskSize, VTypeSize),
2322
                (idiskSpindles, VTypeInt),
2323
                (idiskMode, VTypeString),
2324
                (idiskAdopt, VTypeString),
2325
                (idiskVg, VTypeString),
2326
                (idiskMetavg, VTypeString),
2327
                (idiskProvider, VTypeString),
2328
                (idiskName, VTypeMaybeString)]
2329

    
2330
idiskParams :: FrozenSet String
2331
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2332

    
2333
modifiableIdiskParamsTypes :: Map String VType
2334
modifiableIdiskParamsTypes =
2335
  Map.fromList [(idiskMode, VTypeString),
2336
                (idiskName, VTypeString)]
2337

    
2338
modifiableIdiskParams :: FrozenSet String
2339
modifiableIdiskParams =
2340
  ConstantUtils.mkSet (Map.keys modifiableIdiskParamsTypes)
2341

    
2342
-- * inic* constants are used in opcodes, to create/change nics
2343

    
2344
inicBridge :: String
2345
inicBridge = "bridge"
2346

    
2347
inicIp :: String
2348
inicIp = "ip"
2349

    
2350
inicLink :: String
2351
inicLink = "link"
2352

    
2353
inicMac :: String
2354
inicMac = "mac"
2355

    
2356
inicMode :: String
2357
inicMode = "mode"
2358

    
2359
inicName :: String
2360
inicName = "name"
2361

    
2362
inicNetwork :: String
2363
inicNetwork = "network"
2364

    
2365
inicVlan :: String
2366
inicVlan = "vlan"
2367

    
2368
inicParamsTypes :: Map String VType
2369
inicParamsTypes =
2370
  Map.fromList [(inicBridge, VTypeMaybeString),
2371
                (inicIp, VTypeMaybeString),
2372
                (inicLink, VTypeString),
2373
                (inicMac, VTypeString),
2374
                (inicMode, VTypeString),
2375
                (inicName, VTypeMaybeString),
2376
                (inicNetwork, VTypeMaybeString),
2377
                (inicVlan, VTypeMaybeString)]
2378

    
2379
inicParams :: FrozenSet String
2380
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2381

    
2382
-- * Hypervisor constants
2383

    
2384
htXenPvm :: String
2385
htXenPvm = Types.hypervisorToRaw XenPvm
2386

    
2387
htFake :: String
2388
htFake = Types.hypervisorToRaw Fake
2389

    
2390
htXenHvm :: String
2391
htXenHvm = Types.hypervisorToRaw XenHvm
2392

    
2393
htKvm :: String
2394
htKvm = Types.hypervisorToRaw Kvm
2395

    
2396
htChroot :: String
2397
htChroot = Types.hypervisorToRaw Chroot
2398

    
2399
htLxc :: String
2400
htLxc = Types.hypervisorToRaw Lxc
2401

    
2402
hyperTypes :: FrozenSet String
2403
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2404

    
2405
htsReqPort :: FrozenSet String
2406
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2407

    
2408
vncBasePort :: Int
2409
vncBasePort = 5900
2410

    
2411
vncDefaultBindAddress :: String
2412
vncDefaultBindAddress = ip4AddressAny
2413

    
2414
-- * NIC types
2415

    
2416
htNicE1000 :: String
2417
htNicE1000 = "e1000"
2418

    
2419
htNicI82551 :: String
2420
htNicI82551 = "i82551"
2421

    
2422
htNicI8259er :: String
2423
htNicI8259er = "i82559er"
2424

    
2425
htNicI85557b :: String
2426
htNicI85557b = "i82557b"
2427

    
2428
htNicNe2kIsa :: String
2429
htNicNe2kIsa = "ne2k_isa"
2430

    
2431
htNicNe2kPci :: String
2432
htNicNe2kPci = "ne2k_pci"
2433

    
2434
htNicParavirtual :: String
2435
htNicParavirtual = "paravirtual"
2436

    
2437
htNicPcnet :: String
2438
htNicPcnet = "pcnet"
2439

    
2440
htNicRtl8139 :: String
2441
htNicRtl8139 = "rtl8139"
2442

    
2443
htHvmValidNicTypes :: FrozenSet String
2444
htHvmValidNicTypes =
2445
  ConstantUtils.mkSet [htNicE1000,
2446
                       htNicNe2kIsa,
2447
                       htNicNe2kPci,
2448
                       htNicParavirtual,
2449
                       htNicRtl8139]
2450

    
2451
htKvmValidNicTypes :: FrozenSet String
2452
htKvmValidNicTypes =
2453
  ConstantUtils.mkSet [htNicE1000,
2454
                       htNicI82551,
2455
                       htNicI8259er,
2456
                       htNicI85557b,
2457
                       htNicNe2kIsa,
2458
                       htNicNe2kPci,
2459
                       htNicParavirtual,
2460
                       htNicPcnet,
2461
                       htNicRtl8139]
2462

    
2463
-- * Vif types
2464

    
2465
-- | Default vif type in xen-hvm
2466
htHvmVifIoemu :: String
2467
htHvmVifIoemu = "ioemu"
2468

    
2469
htHvmVifVif :: String
2470
htHvmVifVif = "vif"
2471

    
2472
htHvmValidVifTypes :: FrozenSet String
2473
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2474

    
2475
-- * Disk types
2476

    
2477
htDiskIde :: String
2478
htDiskIde = "ide"
2479

    
2480
htDiskIoemu :: String
2481
htDiskIoemu = "ioemu"
2482

    
2483
htDiskMtd :: String
2484
htDiskMtd = "mtd"
2485

    
2486
htDiskParavirtual :: String
2487
htDiskParavirtual = "paravirtual"
2488

    
2489
htDiskPflash :: String
2490
htDiskPflash = "pflash"
2491

    
2492
htDiskScsi :: String
2493
htDiskScsi = "scsi"
2494

    
2495
htDiskSd :: String
2496
htDiskSd = "sd"
2497

    
2498
htHvmValidDiskTypes :: FrozenSet String
2499
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2500

    
2501
htKvmValidDiskTypes :: FrozenSet String
2502
htKvmValidDiskTypes =
2503
  ConstantUtils.mkSet [htDiskIde,
2504
                       htDiskMtd,
2505
                       htDiskParavirtual,
2506
                       htDiskPflash,
2507
                       htDiskScsi,
2508
                       htDiskSd]
2509

    
2510
htCacheDefault :: String
2511
htCacheDefault = "default"
2512

    
2513
htCacheNone :: String
2514
htCacheNone = "none"
2515

    
2516
htCacheWback :: String
2517
htCacheWback = "writeback"
2518

    
2519
htCacheWthrough :: String
2520
htCacheWthrough = "writethrough"
2521

    
2522
htValidCacheTypes :: FrozenSet String
2523
htValidCacheTypes =
2524
  ConstantUtils.mkSet [htCacheDefault,
2525
                       htCacheNone,
2526
                       htCacheWback,
2527
                       htCacheWthrough]
2528

    
2529
-- * Mouse types
2530

    
2531
htMouseMouse :: String
2532
htMouseMouse = "mouse"
2533

    
2534
htMouseTablet :: String
2535
htMouseTablet = "tablet"
2536

    
2537
htKvmValidMouseTypes :: FrozenSet String
2538
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2539

    
2540
-- * Boot order
2541

    
2542
htBoCdrom :: String
2543
htBoCdrom = "cdrom"
2544

    
2545
htBoDisk :: String
2546
htBoDisk = "disk"
2547

    
2548
htBoFloppy :: String
2549
htBoFloppy = "floppy"
2550

    
2551
htBoNetwork :: String
2552
htBoNetwork = "network"
2553

    
2554
htKvmValidBoTypes :: FrozenSet String
2555
htKvmValidBoTypes =
2556
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2557

    
2558
-- * SPICE lossless image compression options
2559

    
2560
htKvmSpiceLosslessImgComprAutoGlz :: String
2561
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2562

    
2563
htKvmSpiceLosslessImgComprAutoLz :: String
2564
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2565

    
2566
htKvmSpiceLosslessImgComprGlz :: String
2567
htKvmSpiceLosslessImgComprGlz = "glz"
2568

    
2569
htKvmSpiceLosslessImgComprLz :: String
2570
htKvmSpiceLosslessImgComprLz = "lz"
2571

    
2572
htKvmSpiceLosslessImgComprOff :: String
2573
htKvmSpiceLosslessImgComprOff = "off"
2574

    
2575
htKvmSpiceLosslessImgComprQuic :: String
2576
htKvmSpiceLosslessImgComprQuic = "quic"
2577

    
2578
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2579
htKvmSpiceValidLosslessImgComprOptions =
2580
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2581
                       htKvmSpiceLosslessImgComprAutoLz,
2582
                       htKvmSpiceLosslessImgComprGlz,
2583
                       htKvmSpiceLosslessImgComprLz,
2584
                       htKvmSpiceLosslessImgComprOff,
2585
                       htKvmSpiceLosslessImgComprQuic]
2586

    
2587
htKvmSpiceLossyImgComprAlways :: String
2588
htKvmSpiceLossyImgComprAlways = "always"
2589

    
2590
htKvmSpiceLossyImgComprAuto :: String
2591
htKvmSpiceLossyImgComprAuto = "auto"
2592

    
2593
htKvmSpiceLossyImgComprNever :: String
2594
htKvmSpiceLossyImgComprNever = "never"
2595

    
2596
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2597
htKvmSpiceValidLossyImgComprOptions =
2598
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2599
                       htKvmSpiceLossyImgComprAuto,
2600
                       htKvmSpiceLossyImgComprNever]
2601

    
2602
-- * SPICE video stream detection
2603

    
2604
htKvmSpiceVideoStreamDetectionAll :: String
2605
htKvmSpiceVideoStreamDetectionAll = "all"
2606

    
2607
htKvmSpiceVideoStreamDetectionFilter :: String
2608
htKvmSpiceVideoStreamDetectionFilter = "filter"
2609

    
2610
htKvmSpiceVideoStreamDetectionOff :: String
2611
htKvmSpiceVideoStreamDetectionOff = "off"
2612

    
2613
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2614
htKvmSpiceValidVideoStreamDetectionOptions =
2615
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2616
                       htKvmSpiceVideoStreamDetectionFilter,
2617
                       htKvmSpiceVideoStreamDetectionOff]
2618

    
2619
-- * Security models
2620

    
2621
htSmNone :: String
2622
htSmNone = "none"
2623

    
2624
htSmPool :: String
2625
htSmPool = "pool"
2626

    
2627
htSmUser :: String
2628
htSmUser = "user"
2629

    
2630
htKvmValidSmTypes :: FrozenSet String
2631
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2632

    
2633
-- * Kvm flag values
2634

    
2635
htKvmDisabled :: String
2636
htKvmDisabled = "disabled"
2637

    
2638
htKvmEnabled :: String
2639
htKvmEnabled = "enabled"
2640

    
2641
htKvmFlagValues :: FrozenSet String
2642
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2643

    
2644
-- * Migration type
2645

    
2646
htMigrationLive :: String
2647
htMigrationLive = Types.migrationModeToRaw MigrationLive
2648

    
2649
htMigrationNonlive :: String
2650
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2651

    
2652
htMigrationModes :: FrozenSet String
2653
htMigrationModes =
2654
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2655

    
2656
-- * Cluster verify steps
2657

    
2658
verifyNplusoneMem :: String
2659
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2660

    
2661
verifyOptionalChecks :: FrozenSet String
2662
verifyOptionalChecks =
2663
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2664

    
2665
-- * Cluster Verify error classes
2666

    
2667
cvTcluster :: String
2668
cvTcluster = "cluster"
2669

    
2670
cvTgroup :: String
2671
cvTgroup = "group"
2672

    
2673
cvTnode :: String
2674
cvTnode = "node"
2675

    
2676
cvTinstance :: String
2677
cvTinstance = "instance"
2678

    
2679
-- * Cluster Verify error codes and documentation
2680

    
2681
cvEclustercert :: (String, String, String)
2682
cvEclustercert =
2683
  ("cluster",
2684
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2685
   "Cluster certificate files verification failure")
2686

    
2687
cvEclustercfg :: (String, String, String)
2688
cvEclustercfg =
2689
  ("cluster",
2690
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2691
   "Cluster configuration verification failure")
2692

    
2693
cvEclusterdanglinginst :: (String, String, String)
2694
cvEclusterdanglinginst =
2695
  ("node",
2696
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2697
   "Some instances have a non-existing primary node")
2698

    
2699
cvEclusterdanglingnodes :: (String, String, String)
2700
cvEclusterdanglingnodes =
2701
  ("node",
2702
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2703
   "Some nodes belong to non-existing groups")
2704

    
2705
cvEclusterfilecheck :: (String, String, String)
2706
cvEclusterfilecheck =
2707
  ("cluster",
2708
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2709
   "Cluster configuration verification failure")
2710

    
2711
cvEgroupdifferentpvsize :: (String, String, String)
2712
cvEgroupdifferentpvsize =
2713
  ("group",
2714
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2715
   "PVs in the group have different sizes")
2716

    
2717
cvEinstancebadnode :: (String, String, String)
2718
cvEinstancebadnode =
2719
  ("instance",
2720
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2721
   "Instance marked as running lives on an offline node")
2722

    
2723
cvEinstancedown :: (String, String, String)
2724
cvEinstancedown =
2725
  ("instance",
2726
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2727
   "Instance not running on its primary node")
2728

    
2729
cvEinstancefaultydisk :: (String, String, String)
2730
cvEinstancefaultydisk =
2731
  ("instance",
2732
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2733
   "Impossible to retrieve status for a disk")
2734

    
2735
cvEinstancelayout :: (String, String, String)
2736
cvEinstancelayout =
2737
  ("instance",
2738
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2739
   "Instance has multiple secondary nodes")
2740

    
2741
cvEinstancemissingcfgparameter :: (String, String, String)
2742
cvEinstancemissingcfgparameter =
2743
  ("instance",
2744
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2745
   "A configuration parameter for an instance is missing")
2746

    
2747
cvEinstancemissingdisk :: (String, String, String)
2748
cvEinstancemissingdisk =
2749
  ("instance",
2750
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2751
   "Missing volume on an instance")
2752

    
2753
cvEinstancepolicy :: (String, String, String)
2754
cvEinstancepolicy =
2755
  ("instance",
2756
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2757
   "Instance does not meet policy")
2758

    
2759
cvEinstancesplitgroups :: (String, String, String)
2760
cvEinstancesplitgroups =
2761
  ("instance",
2762
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2763
   "Instance with primary and secondary nodes in different groups")
2764

    
2765
cvEinstanceunsuitablenode :: (String, String, String)
2766
cvEinstanceunsuitablenode =
2767
  ("instance",
2768
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2769
   "Instance running on nodes that are not suitable for it")
2770

    
2771
cvEinstancewrongnode :: (String, String, String)
2772
cvEinstancewrongnode =
2773
  ("instance",
2774
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2775
   "Instance running on the wrong node")
2776

    
2777
cvEnodedrbd :: (String, String, String)
2778
cvEnodedrbd =
2779
  ("node",
2780
   Types.cVErrorCodeToRaw CvENODEDRBD,
2781
   "Error parsing the DRBD status file")
2782

    
2783
cvEnodedrbdhelper :: (String, String, String)
2784
cvEnodedrbdhelper =
2785
  ("node",
2786
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2787
   "Error caused by the DRBD helper")
2788

    
2789
cvEnodedrbdversion :: (String, String, String)
2790
cvEnodedrbdversion =
2791
  ("node",
2792
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2793
   "DRBD version mismatch within a node group")
2794

    
2795
cvEnodefilecheck :: (String, String, String)
2796
cvEnodefilecheck =
2797
  ("node",
2798
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2799
   "Error retrieving the checksum of the node files")
2800

    
2801
cvEnodefilestoragepaths :: (String, String, String)
2802
cvEnodefilestoragepaths =
2803
  ("node",
2804
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2805
   "Detected bad file storage paths")
2806

    
2807
cvEnodefilestoragepathunusable :: (String, String, String)
2808
cvEnodefilestoragepathunusable =
2809
  ("node",
2810
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2811
   "File storage path unusable")
2812

    
2813
cvEnodehooks :: (String, String, String)
2814
cvEnodehooks =
2815
  ("node",
2816
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2817
   "Communication failure in hooks execution")
2818

    
2819
cvEnodehv :: (String, String, String)
2820
cvEnodehv =
2821
  ("node",
2822
   Types.cVErrorCodeToRaw CvENODEHV,
2823
   "Hypervisor parameters verification failure")
2824

    
2825
cvEnodelvm :: (String, String, String)
2826
cvEnodelvm =
2827
  ("node",
2828
   Types.cVErrorCodeToRaw CvENODELVM,
2829
   "LVM-related node error")
2830

    
2831
cvEnoden1 :: (String, String, String)
2832
cvEnoden1 =
2833
  ("node",
2834
   Types.cVErrorCodeToRaw CvENODEN1,
2835
   "Not enough memory to accommodate instance failovers")
2836

    
2837
cvEnodenet :: (String, String, String)
2838
cvEnodenet =
2839
  ("node",
2840
   Types.cVErrorCodeToRaw CvENODENET,
2841
   "Network-related node error")
2842

    
2843
cvEnodeoobpath :: (String, String, String)
2844
cvEnodeoobpath =
2845
  ("node",
2846
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2847
   "Invalid Out Of Band path")
2848

    
2849
cvEnodeorphaninstance :: (String, String, String)
2850
cvEnodeorphaninstance =
2851
  ("node",
2852
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2853
   "Unknown intance running on a node")
2854

    
2855
cvEnodeorphanlv :: (String, String, String)
2856
cvEnodeorphanlv =
2857
  ("node",
2858
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2859
   "Unknown LVM logical volume")
2860

    
2861
cvEnodeos :: (String, String, String)
2862
cvEnodeos =
2863
  ("node",
2864
   Types.cVErrorCodeToRaw CvENODEOS,
2865
   "OS-related node error")
2866

    
2867
cvEnoderpc :: (String, String, String)
2868
cvEnoderpc =
2869
  ("node",
2870
   Types.cVErrorCodeToRaw CvENODERPC,
2871
   "Error during connection to the primary node of an instance")
2872

    
2873
cvEnodesetup :: (String, String, String)
2874
cvEnodesetup =
2875
  ("node",
2876
   Types.cVErrorCodeToRaw CvENODESETUP,
2877
   "Node setup error")
2878

    
2879
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2880
cvEnodesharedfilestoragepathunusable =
2881
  ("node",
2882
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2883
   "Shared file storage path unusable")
2884

    
2885
cvEnodessh :: (String, String, String)
2886
cvEnodessh =
2887
  ("node",
2888
   Types.cVErrorCodeToRaw CvENODESSH,
2889
   "SSH-related node error")
2890

    
2891
cvEnodetime :: (String, String, String)
2892
cvEnodetime =
2893
  ("node",
2894
   Types.cVErrorCodeToRaw CvENODETIME,
2895
   "Node returned invalid time")
2896

    
2897
cvEnodeuserscripts :: (String, String, String)
2898
cvEnodeuserscripts =
2899
  ("node",
2900
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2901
   "User scripts not present or not executable")
2902

    
2903
cvEnodeversion :: (String, String, String)
2904
cvEnodeversion =
2905
  ("node",
2906
   Types.cVErrorCodeToRaw CvENODEVERSION,
2907
   "Protocol version mismatch or Ganeti version mismatch")
2908

    
2909
cvAllEcodes :: FrozenSet (String, String, String)
2910
cvAllEcodes =
2911
  ConstantUtils.mkSet
2912
  [cvEclustercert,
2913
   cvEclustercfg,
2914
   cvEclusterdanglinginst,
2915
   cvEclusterdanglingnodes,
2916
   cvEclusterfilecheck,
2917
   cvEgroupdifferentpvsize,
2918
   cvEinstancebadnode,
2919
   cvEinstancedown,
2920
   cvEinstancefaultydisk,
2921
   cvEinstancelayout,
2922
   cvEinstancemissingcfgparameter,
2923
   cvEinstancemissingdisk,
2924
   cvEinstancepolicy,
2925
   cvEinstancesplitgroups,
2926
   cvEinstanceunsuitablenode,
2927
   cvEinstancewrongnode,
2928
   cvEnodedrbd,
2929
   cvEnodedrbdhelper,
2930
   cvEnodedrbdversion,
2931
   cvEnodefilecheck,
2932
   cvEnodefilestoragepaths,
2933
   cvEnodefilestoragepathunusable,
2934
   cvEnodehooks,
2935
   cvEnodehv,
2936
   cvEnodelvm,
2937
   cvEnoden1,
2938
   cvEnodenet,
2939
   cvEnodeoobpath,
2940
   cvEnodeorphaninstance,
2941
   cvEnodeorphanlv,
2942
   cvEnodeos,
2943
   cvEnoderpc,
2944
   cvEnodesetup,
2945
   cvEnodesharedfilestoragepathunusable,
2946
   cvEnodessh,
2947
   cvEnodetime,
2948
   cvEnodeuserscripts,
2949
   cvEnodeversion]
2950

    
2951
cvAllEcodesStrings :: FrozenSet String
2952
cvAllEcodesStrings =
2953
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2954

    
2955
-- * Node verify constants
2956

    
2957
nvBridges :: String
2958
nvBridges = "bridges"
2959

    
2960
nvDrbdhelper :: String
2961
nvDrbdhelper = "drbd-helper"
2962

    
2963
nvDrbdversion :: String
2964
nvDrbdversion = "drbd-version"
2965

    
2966
nvDrbdlist :: String
2967
nvDrbdlist = "drbd-list"
2968

    
2969
nvExclusivepvs :: String
2970
nvExclusivepvs = "exclusive-pvs"
2971

    
2972
nvFilelist :: String
2973
nvFilelist = "filelist"
2974

    
2975
nvAcceptedStoragePaths :: String
2976
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2977

    
2978
nvFileStoragePath :: String
2979
nvFileStoragePath = "file-storage-path"
2980

    
2981
nvSharedFileStoragePath :: String
2982
nvSharedFileStoragePath = "shared-file-storage-path"
2983

    
2984
nvHvinfo :: String
2985
nvHvinfo = "hvinfo"
2986

    
2987
nvHvparams :: String
2988
nvHvparams = "hvparms"
2989

    
2990
nvHypervisor :: String
2991
nvHypervisor = "hypervisor"
2992

    
2993
nvInstancelist :: String
2994
nvInstancelist = "instancelist"
2995

    
2996
nvLvlist :: String
2997
nvLvlist = "lvlist"
2998

    
2999
nvMasterip :: String
3000
nvMasterip = "master-ip"
3001

    
3002
nvNodelist :: String
3003
nvNodelist = "nodelist"
3004

    
3005
nvNodenettest :: String
3006
nvNodenettest = "node-net-test"
3007

    
3008
nvNodesetup :: String
3009
nvNodesetup = "nodesetup"
3010

    
3011
nvOobPaths :: String
3012
nvOobPaths = "oob-paths"
3013

    
3014
nvOslist :: String
3015
nvOslist = "oslist"
3016

    
3017
nvPvlist :: String
3018
nvPvlist = "pvlist"
3019

    
3020
nvTime :: String
3021
nvTime = "time"
3022

    
3023
nvUserscripts :: String
3024
nvUserscripts = "user-scripts"
3025

    
3026
nvVersion :: String
3027
nvVersion = "version"
3028

    
3029
nvVglist :: String
3030
nvVglist = "vglist"
3031

    
3032
nvNonvmnodes :: String
3033
nvNonvmnodes = "nonvmnodes"
3034

    
3035
-- * Instance status
3036

    
3037
inststAdmindown :: String
3038
inststAdmindown = Types.instanceStatusToRaw StatusDown
3039

    
3040
inststAdminoffline :: String
3041
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3042

    
3043
inststErrordown :: String
3044
inststErrordown = Types.instanceStatusToRaw ErrorDown
3045

    
3046
inststErrorup :: String
3047
inststErrorup = Types.instanceStatusToRaw ErrorUp
3048

    
3049
inststNodedown :: String
3050
inststNodedown = Types.instanceStatusToRaw NodeDown
3051

    
3052
inststNodeoffline :: String
3053
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3054

    
3055
inststRunning :: String
3056
inststRunning = Types.instanceStatusToRaw Running
3057

    
3058
inststWrongnode :: String
3059
inststWrongnode = Types.instanceStatusToRaw WrongNode
3060

    
3061
inststAll :: FrozenSet String
3062
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3063

    
3064
-- * Admin states
3065

    
3066
adminstDown :: String
3067
adminstDown = Types.adminStateToRaw AdminDown
3068

    
3069
adminstOffline :: String
3070
adminstOffline = Types.adminStateToRaw AdminOffline
3071

    
3072
adminstUp :: String
3073
adminstUp = Types.adminStateToRaw AdminUp
3074

    
3075
adminstAll :: FrozenSet String
3076
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3077

    
3078
-- * Node roles
3079

    
3080
nrDrained :: String
3081
nrDrained = Types.nodeRoleToRaw NRDrained
3082

    
3083
nrMaster :: String
3084
nrMaster = Types.nodeRoleToRaw NRMaster
3085

    
3086
nrMcandidate :: String
3087
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3088

    
3089
nrOffline :: String
3090
nrOffline = Types.nodeRoleToRaw NROffline
3091

    
3092
nrRegular :: String
3093
nrRegular = Types.nodeRoleToRaw NRRegular
3094

    
3095
nrAll :: FrozenSet String
3096
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3097

    
3098
-- * SSL certificate check constants (in days)
3099

    
3100
sslCertExpirationError :: Int
3101
sslCertExpirationError = 7
3102

    
3103
sslCertExpirationWarn :: Int
3104
sslCertExpirationWarn = 30
3105

    
3106
-- * Allocator framework constants
3107

    
3108
iallocatorVersion :: Int
3109
iallocatorVersion = 2
3110

    
3111
iallocatorDirIn :: String
3112
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3113

    
3114
iallocatorDirOut :: String
3115
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3116

    
3117
validIallocatorDirections :: FrozenSet String
3118
validIallocatorDirections =
3119
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3120

    
3121
iallocatorModeAlloc :: String
3122
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3123

    
3124
iallocatorModeChgGroup :: String
3125
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3126

    
3127
iallocatorModeMultiAlloc :: String
3128
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3129

    
3130
iallocatorModeNodeEvac :: String
3131
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3132

    
3133
iallocatorModeReloc :: String
3134
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3135

    
3136
validIallocatorModes :: FrozenSet String
3137
validIallocatorModes =
3138
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3139

    
3140
iallocatorSearchPath :: [String]
3141
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3142

    
3143
defaultIallocatorShortcut :: String
3144
defaultIallocatorShortcut = "."
3145

    
3146
-- * Node evacuation
3147

    
3148
nodeEvacPri :: String
3149
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3150

    
3151
nodeEvacSec :: String
3152
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3153

    
3154
nodeEvacAll :: String
3155
nodeEvacAll = Types.evacModeToRaw ChangeAll
3156

    
3157
nodeEvacModes :: FrozenSet String
3158
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3159

    
3160
-- * Job queue
3161

    
3162
jobQueueVersion :: Int
3163
jobQueueVersion = 1
3164

    
3165
jobQueueSizeHardLimit :: Int
3166
jobQueueSizeHardLimit = 5000
3167

    
3168
jobQueueFilesPerms :: Int
3169
jobQueueFilesPerms = 0o640
3170

    
3171
-- * Unchanged job return
3172

    
3173
jobNotchanged :: String
3174
jobNotchanged = "nochange"
3175

    
3176
-- * Job status
3177

    
3178
jobStatusQueued :: String
3179
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3180

    
3181
jobStatusWaiting :: String
3182
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3183

    
3184
jobStatusCanceling :: String
3185
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3186

    
3187
jobStatusRunning :: String
3188
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3189

    
3190
jobStatusCanceled :: String
3191
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3192

    
3193
jobStatusSuccess :: String
3194
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3195

    
3196
jobStatusError :: String
3197
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3198

    
3199
jobsPending :: FrozenSet String
3200
jobsPending =
3201
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3202

    
3203
jobsFinalized :: FrozenSet String
3204
jobsFinalized =
3205
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3206

    
3207
jobStatusAll :: FrozenSet String
3208
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3209

    
3210
-- * OpCode status
3211

    
3212
-- ** Not yet finalized opcodes
3213

    
3214
opStatusCanceling :: String
3215
opStatusCanceling = "canceling"
3216

    
3217
opStatusQueued :: String
3218
opStatusQueued = "queued"
3219

    
3220
opStatusRunning :: String
3221
opStatusRunning = "running"
3222

    
3223
opStatusWaiting :: String
3224
opStatusWaiting = "waiting"
3225

    
3226
-- ** Finalized opcodes
3227

    
3228
opStatusCanceled :: String
3229
opStatusCanceled = "canceled"
3230

    
3231
opStatusError :: String
3232
opStatusError = "error"
3233

    
3234
opStatusSuccess :: String
3235
opStatusSuccess = "success"
3236

    
3237
opsFinalized :: FrozenSet String
3238
opsFinalized =
3239
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3240

    
3241
-- * OpCode priority
3242

    
3243
opPrioLowest :: Int
3244
opPrioLowest = 19
3245

    
3246
opPrioHighest :: Int
3247
opPrioHighest = -20
3248

    
3249
opPrioLow :: Int
3250
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3251

    
3252
opPrioNormal :: Int
3253
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3254

    
3255
opPrioHigh :: Int
3256
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3257

    
3258
opPrioSubmitValid :: FrozenSet Int
3259
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3260

    
3261
opPrioDefault :: Int
3262
opPrioDefault = opPrioNormal
3263

    
3264
-- * Lock recalculate mode
3265

    
3266
locksAppend :: String
3267
locksAppend = "append"
3268

    
3269
locksReplace :: String
3270
locksReplace = "replace"
3271

    
3272
-- * Lock timeout
3273
--
3274
-- The lock timeout (sum) before we transition into blocking acquire
3275
-- (this can still be reset by priority change).  Computed as max time
3276
-- (10 hours) before we should actually go into blocking acquire,
3277
-- given that we start from the default priority level.
3278

    
3279
lockAttemptsMaxwait :: Double
3280
lockAttemptsMaxwait = 15.0
3281

    
3282
lockAttemptsMinwait :: Double
3283
lockAttemptsMinwait = 1.0
3284

    
3285
lockAttemptsTimeout :: Int
3286
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3287

    
3288
-- * Execution log types
3289

    
3290
elogMessage :: String
3291
elogMessage = Types.eLogTypeToRaw ELogMessage
3292

    
3293
elogRemoteImport :: String
3294
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3295

    
3296
elogJqueueTest :: String
3297
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3298

    
3299
-- * /etc/hosts modification
3300

    
3301
etcHostsAdd :: String
3302
etcHostsAdd = "add"
3303

    
3304
etcHostsRemove :: String
3305
etcHostsRemove = "remove"
3306

    
3307
-- * Job queue test
3308

    
3309
jqtMsgprefix :: String
3310
jqtMsgprefix = "TESTMSG="
3311

    
3312
jqtExec :: String
3313
jqtExec = "exec"
3314

    
3315
jqtExpandnames :: String
3316
jqtExpandnames = "expandnames"
3317

    
3318
jqtLogmsg :: String
3319
jqtLogmsg = "logmsg"
3320

    
3321
jqtStartmsg :: String
3322
jqtStartmsg = "startmsg"
3323

    
3324
jqtAll :: FrozenSet String
3325
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3326

    
3327
-- * Query resources
3328

    
3329
qrCluster :: String
3330
qrCluster = "cluster"
3331

    
3332
qrExport :: String
3333
qrExport = "export"
3334

    
3335
qrExtstorage :: String
3336
qrExtstorage = "extstorage"
3337

    
3338
qrGroup :: String
3339
qrGroup = "group"
3340

    
3341
qrInstance :: String
3342
qrInstance = "instance"
3343

    
3344
qrJob :: String
3345
qrJob = "job"
3346

    
3347
qrLock :: String
3348
qrLock = "lock"
3349

    
3350
qrNetwork :: String
3351
qrNetwork = "network"
3352

    
3353
qrNode :: String
3354
qrNode = "node"
3355

    
3356
qrOs :: String
3357
qrOs = "os"
3358

    
3359
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3360
qrViaOp :: FrozenSet String
3361
qrViaOp =
3362
  ConstantUtils.mkSet [qrCluster,
3363
                       qrInstance,
3364
                       qrNode,
3365
                       qrGroup,
3366
                       qrOs,
3367
                       qrExport,
3368
                       qrNetwork,
3369
                       qrExtstorage]
3370

    
3371
-- | List of resources which can be queried using Local UniX Interface
3372
qrViaLuxi :: FrozenSet String
3373
qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob]
3374

    
3375
-- | List of resources which can be queried using RAPI
3376
qrViaRapi :: FrozenSet String
3377
qrViaRapi = qrViaLuxi
3378

    
3379
-- * Query field types
3380

    
3381
qftBool :: String
3382
qftBool = "bool"
3383

    
3384
qftNumber :: String
3385
qftNumber = "number"
3386

    
3387
qftOther :: String
3388
qftOther = "other"
3389

    
3390
qftText :: String
3391
qftText = "text"
3392

    
3393
qftTimestamp :: String
3394
qftTimestamp = "timestamp"
3395

    
3396
qftUnit :: String
3397
qftUnit = "unit"
3398

    
3399
qftUnknown :: String
3400
qftUnknown = "unknown"
3401

    
3402
qftAll :: FrozenSet String
3403
qftAll =
3404
  ConstantUtils.mkSet [qftBool,
3405
                       qftNumber,
3406
                       qftOther,
3407
                       qftText,
3408
                       qftTimestamp,
3409
                       qftUnit,
3410
                       qftUnknown]
3411

    
3412
-- * Query result field status
3413
--
3414
-- Don't change or reuse values as they're used by clients.
3415
--
3416
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3417

    
3418
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3419
rsNodata :: Int
3420
rsNodata = 2
3421

    
3422
rsNormal :: Int
3423
rsNormal = 0
3424

    
3425
-- | Resource marked offline
3426
rsOffline :: Int
3427
rsOffline = 4
3428

    
3429
-- | Value unavailable/unsupported for item; if this field is
3430
-- supported but we cannot get the data for the moment, 'rsNodata' or
3431
-- 'rsOffline' should be used
3432
rsUnavail :: Int
3433
rsUnavail = 3
3434

    
3435
rsUnknown :: Int
3436
rsUnknown = 1
3437

    
3438
rsAll :: FrozenSet Int
3439
rsAll =
3440
  ConstantUtils.mkSet [rsNodata,
3441
                       rsNormal,
3442
                       rsOffline,
3443
                       rsUnavail,
3444
                       rsUnknown]
3445

    
3446
-- | Special field cases and their verbose/terse formatting
3447
rssDescription :: Map Int (String, String)
3448
rssDescription =
3449
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3450
                (rsNodata, ("(nodata)", "?")),
3451
                (rsOffline, ("(offline)", "*")),
3452
                (rsUnavail, ("(unavail)", "-"))]
3453

    
3454
-- * Max dynamic devices
3455

    
3456
maxDisks :: Int
3457
maxDisks = Types.maxDisks
3458

    
3459
maxNics :: Int
3460
maxNics = Types.maxNics
3461

    
3462
-- | SSCONF file prefix
3463
ssconfFileprefix :: String
3464
ssconfFileprefix = "ssconf_"
3465

    
3466
-- * SSCONF keys
3467

    
3468
ssClusterName :: String
3469
ssClusterName = "cluster_name"
3470

    
3471
ssClusterTags :: String
3472
ssClusterTags = "cluster_tags"
3473

    
3474
ssFileStorageDir :: String
3475
ssFileStorageDir = "file_storage_dir"
3476

    
3477
ssSharedFileStorageDir :: String
3478
ssSharedFileStorageDir = "shared_file_storage_dir"
3479

    
3480
ssMasterCandidates :: String
3481
ssMasterCandidates = "master_candidates"
3482

    
3483
ssMasterCandidatesIps :: String
3484
ssMasterCandidatesIps = "master_candidates_ips"
3485

    
3486
ssMasterIp :: String
3487
ssMasterIp = "master_ip"
3488

    
3489
ssMasterNetdev :: String
3490
ssMasterNetdev = "master_netdev"
3491

    
3492
ssMasterNetmask :: String
3493
ssMasterNetmask = "master_netmask"
3494

    
3495
ssMasterNode :: String
3496
ssMasterNode = "master_node"
3497

    
3498
ssNodeList :: String
3499
ssNodeList = "node_list"
3500

    
3501
ssNodePrimaryIps :: String
3502
ssNodePrimaryIps = "node_primary_ips"
3503

    
3504
ssNodeSecondaryIps :: String
3505
ssNodeSecondaryIps = "node_secondary_ips"
3506

    
3507
ssOfflineNodes :: String
3508
ssOfflineNodes = "offline_nodes"
3509

    
3510
ssOnlineNodes :: String
3511
ssOnlineNodes = "online_nodes"
3512

    
3513
ssPrimaryIpFamily :: String
3514
ssPrimaryIpFamily = "primary_ip_family"
3515

    
3516
ssInstanceList :: String
3517
ssInstanceList = "instance_list"
3518

    
3519
ssReleaseVersion :: String
3520
ssReleaseVersion = "release_version"
3521

    
3522
ssHypervisorList :: String
3523
ssHypervisorList = "hypervisor_list"
3524

    
3525
ssMaintainNodeHealth :: String
3526
ssMaintainNodeHealth = "maintain_node_health"
3527

    
3528
ssUidPool :: String
3529
ssUidPool = "uid_pool"
3530

    
3531
ssNodegroups :: String
3532
ssNodegroups = "nodegroups"
3533

    
3534
ssNetworks :: String
3535
ssNetworks = "networks"
3536

    
3537
-- | This is not a complete SSCONF key, but the prefix for the
3538
-- hypervisor keys
3539
ssHvparamsPref :: String
3540
ssHvparamsPref = "hvparams_"
3541

    
3542
-- * Hvparams keys
3543

    
3544
ssHvparamsXenChroot :: String
3545
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3546

    
3547
ssHvparamsXenFake :: String
3548
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3549

    
3550
ssHvparamsXenHvm :: String
3551
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3552

    
3553
ssHvparamsXenKvm :: String
3554
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3555

    
3556
ssHvparamsXenLxc :: String
3557
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3558

    
3559
ssHvparamsXenPvm :: String
3560
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3561

    
3562
validSsHvparamsKeys :: FrozenSet String
3563
validSsHvparamsKeys =
3564
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3565
                       ssHvparamsXenLxc,
3566
                       ssHvparamsXenFake,
3567
                       ssHvparamsXenHvm,
3568
                       ssHvparamsXenKvm,
3569
                       ssHvparamsXenPvm]
3570

    
3571
ssFilePerms :: Int
3572
ssFilePerms = 0o444
3573

    
3574
-- | Cluster wide default parameters
3575
defaultEnabledHypervisor :: String
3576
defaultEnabledHypervisor = htXenPvm
3577

    
3578
hvcDefaults :: Map Hypervisor (Map String PyValueEx)
3579
hvcDefaults =
3580
  Map.fromList
3581
  [ (XenPvm, Map.fromList
3582
             [ (hvUseBootloader,  PyValueEx False)
3583
             , (hvBootloaderPath, PyValueEx xenBootloader)
3584
             , (hvBootloaderArgs, PyValueEx "")
3585
             , (hvKernelPath,     PyValueEx xenKernel)
3586
             , (hvInitrdPath,     PyValueEx "")
3587
             , (hvRootPath,       PyValueEx "/dev/xvda1")
3588
             , (hvKernelArgs,     PyValueEx "ro")
3589
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3590
             , (hvMigrationMode,  PyValueEx htMigrationLive)
3591
             , (hvBlockdevPrefix, PyValueEx "sd")
3592
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3593
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3594
             , (hvCpuCap,         PyValueEx (0 :: Int))
3595
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3596
             , (hvVifScript,      PyValueEx "")
3597
             , (hvXenCmd,         PyValueEx xenCmdXm)
3598
             , (hvXenCpuid,       PyValueEx "")
3599
             , (hvSoundhw,        PyValueEx "")
3600
             ])
3601
  , (XenHvm, Map.fromList
3602
             [ (hvBootOrder,      PyValueEx "cd")
3603
             , (hvCdromImagePath, PyValueEx "")
3604
             , (hvNicType,        PyValueEx htNicRtl8139)
3605
             , (hvDiskType,       PyValueEx htDiskParavirtual)
3606
             , (hvVncBindAddress, PyValueEx ip4AddressAny)
3607
             , (hvAcpi,           PyValueEx True)
3608
             , (hvPae,            PyValueEx True)
3609
             , (hvKernelPath,     PyValueEx "/usr/lib/xen/boot/hvmloader")
3610
             , (hvDeviceModel,    PyValueEx "/usr/lib/xen/bin/qemu-dm")
3611
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3612
             , (hvMigrationMode,  PyValueEx htMigrationNonlive)
3613
             , (hvUseLocaltime,   PyValueEx False)
3614
             , (hvBlockdevPrefix, PyValueEx "hd")
3615
             , (hvPassthrough,    PyValueEx "")
3616
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3617
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3618
             , (hvCpuCap,         PyValueEx (0 :: Int))
3619
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3620
             , (hvVifType,        PyValueEx htHvmVifIoemu)
3621
             , (hvVifScript,      PyValueEx "")
3622
             , (hvViridian,       PyValueEx False)
3623
             , (hvXenCmd,         PyValueEx xenCmdXm)
3624
             , (hvXenCpuid,       PyValueEx "")
3625
             , (hvSoundhw,        PyValueEx "")
3626
             ])
3627
  , (Kvm, Map.fromList
3628
          [ (hvKvmPath,                         PyValueEx kvmPath)
3629
          , (hvKernelPath,                      PyValueEx kvmKernel)
3630
          , (hvInitrdPath,                      PyValueEx "")
3631
          , (hvKernelArgs,                      PyValueEx "ro")
3632
          , (hvRootPath,                        PyValueEx "/dev/vda1")
3633
          , (hvAcpi,                            PyValueEx True)
3634
          , (hvSerialConsole,                   PyValueEx True)
3635
          , (hvSerialSpeed,                     PyValueEx (38400 :: Int))
3636
          , (hvVncBindAddress,                  PyValueEx "")
3637
          , (hvVncTls,                          PyValueEx False)
3638
          , (hvVncX509,                         PyValueEx "")
3639
          , (hvVncX509Verify,                   PyValueEx False)
3640
          , (hvVncPasswordFile,                 PyValueEx "")
3641
          , (hvKvmSpiceBind,                    PyValueEx "")
3642
          , (hvKvmSpiceIpVersion,           PyValueEx ifaceNoIpVersionSpecified)
3643
          , (hvKvmSpicePasswordFile,            PyValueEx "")
3644
          , (hvKvmSpiceLosslessImgCompr,        PyValueEx "")
3645
          , (hvKvmSpiceJpegImgCompr,            PyValueEx "")
3646
          , (hvKvmSpiceZlibGlzImgCompr,         PyValueEx "")
3647
          , (hvKvmSpiceStreamingVideoDetection, PyValueEx "")
3648
          , (hvKvmSpiceAudioCompr,              PyValueEx True)
3649
          , (hvKvmSpiceUseTls,                  PyValueEx False)
3650
          , (hvKvmSpiceTlsCiphers,              PyValueEx opensslCiphers)
3651
          , (hvKvmSpiceUseVdagent,              PyValueEx True)
3652
          , (hvKvmFloppyImagePath,              PyValueEx "")
3653
          , (hvCdromImagePath,                  PyValueEx "")
3654
          , (hvKvmCdrom2ImagePath,              PyValueEx "")
3655
          , (hvBootOrder,                       PyValueEx htBoDisk)
3656
          , (hvNicType,                         PyValueEx htNicParavirtual)
3657
          , (hvDiskType,                        PyValueEx htDiskParavirtual)
3658
          , (hvKvmCdromDiskType,                PyValueEx "")
3659
          , (hvUsbMouse,                        PyValueEx "")
3660
          , (hvKeymap,                          PyValueEx "")
3661
          , (hvMigrationPort,                   PyValueEx (8102 :: Int))
3662
          , (hvMigrationBandwidth,              PyValueEx (32 :: Int))
3663
          , (hvMigrationDowntime,               PyValueEx (30 :: Int))
3664
          , (hvMigrationMode,                   PyValueEx htMigrationLive)
3665
          , (hvUseLocaltime,                    PyValueEx False)
3666
          , (hvDiskCache,                       PyValueEx htCacheDefault)
3667
          , (hvSecurityModel,                   PyValueEx htSmNone)
3668
          , (hvSecurityDomain,                  PyValueEx "")
3669
          , (hvKvmFlag,                         PyValueEx "")
3670
          , (hvVhostNet,                        PyValueEx False)
3671
          , (hvKvmUseChroot,                    PyValueEx False)
3672
          , (hvMemPath,                         PyValueEx "")
3673
          , (hvRebootBehavior,                  PyValueEx instanceRebootAllowed)
3674
          , (hvCpuMask,                         PyValueEx cpuPinningAll)
3675
          , (hvCpuType,                         PyValueEx "")
3676
          , (hvCpuCores,                        PyValueEx (0 :: Int))
3677
          , (hvCpuThreads,                      PyValueEx (0 :: Int))
3678
          , (hvCpuSockets,                      PyValueEx (0 :: Int))
3679
          , (hvSoundhw,                         PyValueEx "")
3680
          , (hvUsbDevices,                      PyValueEx "")
3681
          , (hvVga,                             PyValueEx "")
3682
          , (hvKvmExtra,                        PyValueEx "")
3683
          , (hvKvmMachineVersion,               PyValueEx "")
3684
          , (hvVnetHdr,                         PyValueEx True)])
3685
  , (Fake, Map.fromList [(hvMigrationMode, PyValueEx htMigrationLive)])
3686
  , (Chroot, Map.fromList [(hvInitScript, PyValueEx "/ganeti-chroot")])
3687
  , (Lxc, Map.fromList [(hvCpuMask, PyValueEx "")])
3688
  ]
3689

    
3690
hvcGlobals :: FrozenSet String
3691
hvcGlobals =
3692
  ConstantUtils.mkSet [hvMigrationBandwidth,
3693
                       hvMigrationMode,
3694
                       hvMigrationPort,
3695
                       hvXenCmd]
3696

    
3697
becDefaults :: Map String PyValueEx
3698
becDefaults =
3699
  Map.fromList
3700
  [ (beMinmem, PyValueEx (128 :: Int))
3701
  , (beMaxmem, PyValueEx (128 :: Int))
3702
  , (beVcpus, PyValueEx (1 :: Int))
3703
  , (beAutoBalance, PyValueEx True)
3704
  , (beAlwaysFailover, PyValueEx False)
3705
  , (beSpindleUse, PyValueEx (1 :: Int))
3706
  ]
3707

    
3708
ndcDefaults :: Map String PyValueEx
3709
ndcDefaults =
3710
  Map.fromList
3711
  [ (ndOobProgram,       PyValueEx "")
3712
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3713
  , (ndExclusiveStorage, PyValueEx False)
3714
  , (ndOvs,              PyValueEx False)
3715
  , (ndOvsName,          PyValueEx defaultOvs)
3716
  , (ndOvsLink,          PyValueEx "")
3717
  ]
3718

    
3719
ndcGlobals :: FrozenSet String
3720
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3721

    
3722
-- | Default delay target measured in sectors
3723
defaultDelayTarget :: Int
3724
defaultDelayTarget = 1
3725

    
3726
defaultDiskCustom :: String
3727
defaultDiskCustom = ""
3728

    
3729
defaultDiskResync :: Bool
3730
defaultDiskResync = False
3731

    
3732
-- | Default fill target measured in sectors
3733
defaultFillTarget :: Int
3734
defaultFillTarget = 0
3735

    
3736
-- | Default mininum rate measured in KiB/s
3737
defaultMinRate :: Int
3738
defaultMinRate = 4 * 1024
3739

    
3740
defaultNetCustom :: String
3741
defaultNetCustom = ""
3742

    
3743
-- | Default plan ahead measured in sectors
3744
--
3745
-- The default values for the DRBD dynamic resync speed algorithm are
3746
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3747
-- (that we don't need to set to 0, because we have a separate option
3748
-- to enable it) and for c-max-rate, that we cap to the default value
3749
-- for the static resync rate.
3750
defaultPlanAhead :: Int
3751
defaultPlanAhead = 20
3752

    
3753
defaultRbdPool :: String
3754
defaultRbdPool = "rbd"
3755

    
3756
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3757
diskLdDefaults =
3758
  Map.fromList
3759
  [ (DTBlock, Map.empty)
3760
  , (DTDrbd8, Map.fromList
3761
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3762
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3763
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3764
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3765
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3766
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3767
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3768
              , (ldpMinRate,       PyValueEx defaultMinRate)
3769
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3770
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3771
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3772
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3773
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3774
              ])
3775
  , (DTExt, Map.empty)
3776
  , (DTFile, Map.empty)
3777
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3778
  , (DTRbd, Map.fromList
3779
            [ (ldpPool, PyValueEx defaultRbdPool)
3780
            , (ldpAccess, PyValueEx diskKernelspace)
3781
            ])
3782
  , (DTSharedFile, Map.empty)
3783
  ]
3784

    
3785
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3786
diskDtDefaults =
3787
  Map.fromList
3788
  [ (DTBlock,      Map.empty)
3789
  , (DTDiskless,   Map.empty)
3790
  , (DTDrbd8,      Map.fromList
3791
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3792
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3793
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3794
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3795
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3796
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3797
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3798
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3799
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3800
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3801
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3802
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3803
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3804
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3805
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3806
                   ])
3807
  , (DTExt,        Map.empty)
3808
  , (DTFile,       Map.empty)
3809
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3810
  , (DTRbd,        Map.fromList
3811
                   [ (rbdPool, PyValueEx defaultRbdPool)
3812
                   , (rbdAccess, PyValueEx diskKernelspace)
3813
                   ])
3814
  , (DTSharedFile, Map.empty)
3815
  ]
3816

    
3817
niccDefaults :: Map String PyValueEx
3818
niccDefaults =
3819
  Map.fromList
3820
  [ (nicMode, PyValueEx nicModeBridged)
3821
  , (nicLink, PyValueEx defaultBridge)
3822
  , (nicVlan, PyValueEx "")
3823
  ]
3824

    
3825
-- | All of the following values are quite arbitrary - there are no
3826
-- "good" defaults, these must be customised per-site
3827
ispecsMinmaxDefaults :: Map String (Map String Int)
3828
ispecsMinmaxDefaults =
3829
  Map.fromList
3830
  [(ispecsMin,
3831
    Map.fromList
3832
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3833
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3834
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3835
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3836
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3837
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3838
   (ispecsMax,
3839
    Map.fromList
3840
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3841
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3842
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3843
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3844
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3845
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3846

    
3847
ipolicyDefaults :: Map String PyValueEx
3848
ipolicyDefaults =
3849
  Map.fromList
3850
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3851
  , (ispecsStd,           PyValueEx (Map.fromList
3852
                                     [ (ispecMemSize,    128)
3853
                                     , (ispecCpuCount,   1)
3854
                                     , (ispecDiskCount,  1)
3855
                                     , (ispecDiskSize,   1024)
3856
                                     , (ispecNicCount,   1)
3857
                                     , (ispecSpindleUse, 1)
3858
                                     ] :: Map String Int))
3859
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3860
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3861
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3862
  ]
3863

    
3864
masterPoolSizeDefault :: Int
3865
masterPoolSizeDefault = 10
3866

    
3867
-- * Exclusive storage
3868

    
3869
-- | Error margin used to compare physical disks
3870
partMargin :: Double
3871
partMargin = 0.01
3872

    
3873
-- | Space reserved when creating instance disks
3874
partReserved :: Double
3875
partReserved = 0.02
3876

    
3877
-- * Confd
3878

    
3879
confdProtocolVersion :: Int
3880
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3881

    
3882
-- Confd request type
3883

    
3884
confdReqPing :: Int
3885
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3886

    
3887
confdReqNodeRoleByname :: Int
3888
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3889

    
3890
confdReqNodePipByInstanceIp :: Int
3891
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3892

    
3893
confdReqClusterMaster :: Int
3894
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3895

    
3896
confdReqNodePipList :: Int
3897
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3898

    
3899
confdReqMcPipList :: Int
3900
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3901

    
3902
confdReqInstancesIpsList :: Int
3903
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3904

    
3905
confdReqNodeDrbd :: Int
3906
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3907

    
3908
confdReqNodeInstances :: Int
3909
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3910

    
3911
confdReqs :: FrozenSet Int
3912
confdReqs =
3913
  ConstantUtils.mkSet .
3914
  map Types.confdRequestTypeToRaw $
3915
  [minBound..] \\ [ReqNodeInstances]
3916

    
3917
-- * Confd request type
3918

    
3919
confdReqfieldName :: Int
3920
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3921

    
3922
confdReqfieldIp :: Int
3923
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3924

    
3925
confdReqfieldMnodePip :: Int
3926
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3927

    
3928
-- * Confd repl status
3929

    
3930
confdReplStatusOk :: Int
3931
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3932

    
3933
confdReplStatusError :: Int
3934
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3935

    
3936
confdReplStatusNotimplemented :: Int
3937
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3938

    
3939
confdReplStatuses :: FrozenSet Int
3940
confdReplStatuses =
3941
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3942

    
3943
-- * Confd node role
3944

    
3945
confdNodeRoleMaster :: Int
3946
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3947

    
3948
confdNodeRoleCandidate :: Int
3949
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3950

    
3951
confdNodeRoleOffline :: Int
3952
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3953

    
3954
confdNodeRoleDrained :: Int
3955
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3956

    
3957
confdNodeRoleRegular :: Int
3958
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3959

    
3960
-- * A few common errors for confd
3961

    
3962
confdErrorUnknownEntry :: Int
3963
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3964

    
3965
confdErrorInternal :: Int
3966
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3967

    
3968
confdErrorArgument :: Int
3969
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3970

    
3971
-- * Confd request query fields
3972

    
3973
confdReqqLink :: String
3974
confdReqqLink = ConstantUtils.confdReqqLink
3975

    
3976
confdReqqIp :: String
3977
confdReqqIp = ConstantUtils.confdReqqIp
3978

    
3979
confdReqqIplist :: String
3980
confdReqqIplist = ConstantUtils.confdReqqIplist
3981

    
3982
confdReqqFields :: String
3983
confdReqqFields = ConstantUtils.confdReqqFields
3984

    
3985
-- | Each request is "salted" by the current timestamp.
3986
--
3987
-- This constant decides how many seconds of skew to accept.
3988
--
3989
-- TODO: make this a default and allow the value to be more
3990
-- configurable
3991
confdMaxClockSkew :: Int
3992
confdMaxClockSkew = 2 * nodeMaxClockSkew
3993

    
3994
-- | When we haven't reloaded the config for more than this amount of
3995
-- seconds, we force a test to see if inotify is betraying us. Using a
3996
-- prime number to ensure we get less chance of 'same wakeup' with
3997
-- other processes.
3998
confdConfigReloadTimeout :: Int
3999
confdConfigReloadTimeout = 17
4000

    
4001
-- | If we receive more than one update in this amount of
4002
-- microseconds, we move to polling every RATELIMIT seconds, rather
4003
-- than relying on inotify, to be able to serve more requests.
4004
confdConfigReloadRatelimit :: Int
4005
confdConfigReloadRatelimit = 250000
4006

    
4007
-- | Magic number prepended to all confd queries.
4008
--
4009
-- This allows us to distinguish different types of confd protocols
4010
-- and handle them. For example by changing this we can move the whole
4011
-- payload to be compressed, or move away from json.
4012
confdMagicFourcc :: String
4013
confdMagicFourcc = "plj0"
4014

    
4015
-- | By default a confd request is sent to the minimum between this
4016
-- number and all MCs. 6 was chosen because even in the case of a
4017
-- disastrous 50% response rate, we should have enough answers to be
4018
-- able to compare more than one.
4019
confdDefaultReqCoverage :: Int
4020
confdDefaultReqCoverage = 6
4021

    
4022
-- | Timeout in seconds to expire pending query request in the confd
4023
-- client library. We don't actually expect any answer more than 10
4024
-- seconds after we sent a request.
4025
confdClientExpireTimeout :: Int
4026
confdClientExpireTimeout = 10
4027

    
4028
-- | Maximum UDP datagram size.
4029
--
4030
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4031
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4032
--   (assuming we can't use jumbo frames)
4033
-- We just set this to 60K, which should be enough
4034
maxUdpDataSize :: Int
4035
maxUdpDataSize = 61440
4036

    
4037
-- * User-id pool minimum/maximum acceptable user-ids
4038

    
4039
uidpoolUidMin :: Int
4040
uidpoolUidMin = 0
4041

    
4042
-- | Assuming 32 bit user-ids
4043
uidpoolUidMax :: Integer
4044
uidpoolUidMax = 2 ^ 32 - 1
4045

    
4046
-- | Name or path of the pgrep command
4047
pgrep :: String
4048
pgrep = "pgrep"
4049

    
4050
-- | Name of the node group that gets created at cluster init or
4051
-- upgrade
4052
initialNodeGroupName :: String
4053
initialNodeGroupName = "default"
4054

    
4055
-- * Possible values for NodeGroup.alloc_policy
4056

    
4057
allocPolicyLastResort :: String
4058
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4059

    
4060
allocPolicyPreferred :: String
4061
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4062

    
4063
allocPolicyUnallocable :: String
4064
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4065

    
4066
validAllocPolicies :: [String]
4067
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4068

    
4069
-- | Temporary external/shared storage parameters
4070
blockdevDriverManual :: String
4071
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4072

    
4073
-- | 'qemu-img' path, required for 'ovfconverter'
4074
qemuimgPath :: String
4075
qemuimgPath = AutoConf.qemuimgPath
4076

    
4077
-- | Whether htools was enabled at compilation time
4078
--
4079
-- FIXME: this should be moved next to the other enable constants,
4080
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4081
htools :: Bool
4082
htools = AutoConf.htools
4083

    
4084
-- | The hail iallocator
4085
iallocHail :: String
4086
iallocHail = "hail"
4087

    
4088
-- * Fake opcodes for functions that have hooks attached to them via
4089
-- backend.RunLocalHooks
4090

    
4091
fakeOpMasterTurndown :: String
4092
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4093

    
4094
fakeOpMasterTurnup :: String
4095
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4096

    
4097
-- * SSH key types
4098

    
4099
sshkDsa :: String
4100
sshkDsa = "dsa"
4101

    
4102
sshkRsa :: String
4103
sshkRsa = "rsa"
4104

    
4105
sshkAll :: FrozenSet String
4106
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4107

    
4108
-- * SSH authorized key types
4109

    
4110
sshakDss :: String
4111
sshakDss = "ssh-dss"
4112

    
4113
sshakRsa :: String
4114
sshakRsa = "ssh-rsa"
4115

    
4116
sshakAll :: FrozenSet String
4117
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4118

    
4119
-- * SSH setup
4120

    
4121
sshsClusterName :: String
4122
sshsClusterName = "cluster_name"
4123

    
4124
sshsSshHostKey :: String
4125
sshsSshHostKey = "ssh_host_key"
4126

    
4127
sshsSshRootKey :: String
4128
sshsSshRootKey = "ssh_root_key"
4129

    
4130
sshsNodeDaemonCertificate :: String
4131
sshsNodeDaemonCertificate = "node_daemon_certificate"
4132

    
4133
-- * Key files for SSH daemon
4134

    
4135
sshHostDsaPriv :: String
4136
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4137

    
4138
sshHostDsaPub :: String
4139
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4140

    
4141
sshHostRsaPriv :: String
4142
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4143

    
4144
sshHostRsaPub :: String
4145
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4146

    
4147
sshDaemonKeyfiles :: Map String (String, String)
4148
sshDaemonKeyfiles =
4149
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4150
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4151
               ]
4152

    
4153
-- * Node daemon setup
4154

    
4155
ndsClusterName :: String
4156
ndsClusterName = "cluster_name"
4157

    
4158
ndsNodeDaemonCertificate :: String
4159
ndsNodeDaemonCertificate = "node_daemon_certificate"
4160

    
4161
ndsSsconf :: String
4162
ndsSsconf = "ssconf"
4163

    
4164
ndsStartNodeDaemon :: String
4165
ndsStartNodeDaemon = "start_node_daemon"
4166

    
4167
-- * The source reasons for the execution of an OpCode
4168

    
4169
opcodeReasonSrcClient :: String
4170
opcodeReasonSrcClient = "gnt:client"
4171

    
4172
opcodeReasonSrcNoded :: String
4173
opcodeReasonSrcNoded = "gnt:daemon:noded"
4174

    
4175
opcodeReasonSrcOpcode :: String
4176
opcodeReasonSrcOpcode = "gnt:opcode"
4177

    
4178
opcodeReasonSrcRlib2 :: String
4179
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4180

    
4181
opcodeReasonSrcUser :: String
4182
opcodeReasonSrcUser = "gnt:user"
4183

    
4184
opcodeReasonSources :: FrozenSet String
4185
opcodeReasonSources =
4186
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4187
                       opcodeReasonSrcNoded,
4188
                       opcodeReasonSrcOpcode,
4189
                       opcodeReasonSrcRlib2,
4190
                       opcodeReasonSrcUser]
4191

    
4192
-- | Path generating random UUID
4193
randomUuidFile :: String
4194
randomUuidFile = ConstantUtils.randomUuidFile
4195

    
4196
-- * Auto-repair tag prefixes
4197

    
4198
autoRepairTagPrefix :: String
4199
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4200

    
4201
autoRepairTagEnabled :: String
4202
autoRepairTagEnabled = autoRepairTagPrefix
4203

    
4204
autoRepairTagPending :: String
4205
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4206

    
4207
autoRepairTagResult :: String
4208
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4209

    
4210
autoRepairTagSuspended :: String
4211
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4212

    
4213
-- * Auto-repair levels
4214

    
4215
autoRepairFailover :: String
4216
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4217

    
4218
autoRepairFixStorage :: String
4219
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4220

    
4221
autoRepairMigrate :: String
4222
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4223

    
4224
autoRepairReinstall :: String
4225
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4226

    
4227
autoRepairAllTypes :: FrozenSet String
4228
autoRepairAllTypes =
4229
  ConstantUtils.mkSet [autoRepairFailover,
4230
                       autoRepairFixStorage,
4231
                       autoRepairMigrate,
4232
                       autoRepairReinstall]
4233

    
4234
-- * Auto-repair results
4235

    
4236
autoRepairEnoperm :: String
4237
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4238

    
4239
autoRepairFailure :: String
4240
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4241

    
4242
autoRepairSuccess :: String
4243
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4244

    
4245
autoRepairAllResults :: FrozenSet String
4246
autoRepairAllResults =
4247
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4248

    
4249
-- | The version identifier for builtin data collectors
4250
builtinDataCollectorVersion :: String
4251
builtinDataCollectorVersion = "B"
4252

    
4253
-- | The reason trail opcode parameter name
4254
opcodeReason :: String
4255
opcodeReason = "reason"
4256

    
4257
-- | The reason trail opcode parameter name
4258
opcodeSequential :: String
4259
opcodeSequential = "sequential"
4260

    
4261
diskstatsFile :: String
4262
diskstatsFile = "/proc/diskstats"
4263

    
4264
-- *  CPU load collector
4265

    
4266
statFile :: String
4267
statFile = "/proc/stat"
4268

    
4269
cpuavgloadBufferSize :: Int
4270
cpuavgloadBufferSize = 150
4271

    
4272
cpuavgloadWindowSize :: Int
4273
cpuavgloadWindowSize = 600
4274

    
4275
-- * Monitoring daemon
4276

    
4277
-- | Mond's variable for periodical data collection
4278
mondTimeInterval :: Int
4279
mondTimeInterval = 5
4280

    
4281
-- | Mond's latest API version
4282
mondLatestApiVersion :: Int
4283
mondLatestApiVersion = 1
4284

    
4285
-- * Disk access modes
4286

    
4287
diskUserspace :: String
4288
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4289

    
4290
diskKernelspace :: String
4291
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4292

    
4293
diskValidAccessModes :: FrozenSet String
4294
diskValidAccessModes =
4295
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4296

    
4297
-- | Timeout for queue draining in upgrades
4298
upgradeQueueDrainTimeout :: Int
4299
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4300

    
4301
-- | Intervall at which the queue is polled during upgrades
4302
upgradeQueuePollInterval :: Int
4303
upgradeQueuePollInterval  = 10
4304

    
4305
-- * Hotplug Actions
4306

    
4307
hotplugActionAdd :: String
4308
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4309

    
4310
hotplugActionRemove :: String
4311
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4312

    
4313
hotplugActionModify :: String
4314
hotplugActionModify = Types.hotplugActionToRaw HAMod
4315

    
4316
hotplugAllActions :: FrozenSet String
4317
hotplugAllActions =
4318
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4319

    
4320
-- * Hotplug Device Targets
4321

    
4322
hotplugTargetNic :: String
4323
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4324

    
4325
hotplugTargetDisk :: String
4326
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4327

    
4328
hotplugAllTargets :: FrozenSet String
4329
hotplugAllTargets =
4330
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4331

    
4332
-- | Timeout for disk removal (seconds)
4333
diskRemoveRetryTimeout :: Int
4334
diskRemoveRetryTimeout = 30
4335

    
4336
-- | Interval between disk removal retries (seconds)
4337
diskRemoveRetryInterval :: Int
4338
diskRemoveRetryInterval  = 3
4339

    
4340
-- * UUID regex
4341

    
4342
uuidRegex :: String
4343
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4344

    
4345
-- * Luxi constants
4346

    
4347
luxiSocketPerms :: Int
4348
luxiSocketPerms = 0o660
4349

    
4350
luxiKeyMethod :: String
4351
luxiKeyMethod = "method"
4352

    
4353
luxiKeyArgs :: String
4354
luxiKeyArgs = "args"
4355

    
4356
luxiKeySuccess :: String
4357
luxiKeySuccess = "success"
4358

    
4359
luxiKeyResult :: String
4360
luxiKeyResult = "result"
4361

    
4362
luxiKeyVersion :: String
4363
luxiKeyVersion = "version"
4364

    
4365
luxiReqSubmitJob :: String
4366
luxiReqSubmitJob = "SubmitJob"
4367

    
4368
luxiReqSubmitJobToDrainedQueue :: String
4369
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4370

    
4371
luxiReqSubmitManyJobs :: String
4372
luxiReqSubmitManyJobs = "SubmitManyJobs"
4373

    
4374
luxiReqWaitForJobChange :: String
4375
luxiReqWaitForJobChange = "WaitForJobChange"
4376

    
4377
luxiReqCancelJob :: String
4378
luxiReqCancelJob = "CancelJob"
4379

    
4380
luxiReqArchiveJob :: String
4381
luxiReqArchiveJob = "ArchiveJob"
4382

    
4383
luxiReqChangeJobPriority :: String
4384
luxiReqChangeJobPriority = "ChangeJobPriority"
4385

    
4386
luxiReqAutoArchiveJobs :: String
4387
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4388

    
4389
luxiReqQuery :: String
4390
luxiReqQuery = "Query"
4391

    
4392
luxiReqQueryFields :: String
4393
luxiReqQueryFields = "QueryFields"
4394

    
4395
luxiReqQueryJobs :: String
4396
luxiReqQueryJobs = "QueryJobs"
4397

    
4398
luxiReqQueryInstances :: String
4399
luxiReqQueryInstances = "QueryInstances"
4400

    
4401
luxiReqQueryNodes :: String
4402
luxiReqQueryNodes = "QueryNodes"
4403

    
4404
luxiReqQueryGroups :: String
4405
luxiReqQueryGroups = "QueryGroups"
4406

    
4407
luxiReqQueryNetworks :: String
4408
luxiReqQueryNetworks = "QueryNetworks"
4409

    
4410
luxiReqQueryExports :: String
4411
luxiReqQueryExports = "QueryExports"
4412

    
4413
luxiReqQueryConfigValues :: String
4414
luxiReqQueryConfigValues = "QueryConfigValues"
4415

    
4416
luxiReqQueryClusterInfo :: String
4417
luxiReqQueryClusterInfo = "QueryClusterInfo"
4418

    
4419
luxiReqQueryTags :: String
4420
luxiReqQueryTags = "QueryTags"
4421

    
4422
luxiReqSetDrainFlag :: String
4423
luxiReqSetDrainFlag = "SetDrainFlag"
4424

    
4425
luxiReqSetWatcherPause :: String
4426
luxiReqSetWatcherPause = "SetWatcherPause"
4427

    
4428
luxiReqAll :: FrozenSet String
4429
luxiReqAll =
4430
  ConstantUtils.mkSet
4431
  [ luxiReqArchiveJob
4432
  , luxiReqAutoArchiveJobs
4433
  , luxiReqCancelJob
4434
  , luxiReqChangeJobPriority
4435
  , luxiReqQuery
4436
  , luxiReqQueryClusterInfo
4437
  , luxiReqQueryConfigValues
4438
  , luxiReqQueryExports
4439
  , luxiReqQueryFields
4440
  , luxiReqQueryGroups
4441
  , luxiReqQueryInstances
4442
  , luxiReqQueryJobs
4443
  , luxiReqQueryNodes
4444
  , luxiReqQueryNetworks
4445
  , luxiReqQueryTags
4446
  , luxiReqSetDrainFlag
4447
  , luxiReqSetWatcherPause
4448
  , luxiReqSubmitJob
4449
  , luxiReqSubmitJobToDrainedQueue
4450
  , luxiReqSubmitManyJobs
4451
  , luxiReqWaitForJobChange
4452
  ]
4453

    
4454
luxiDefCtmo :: Int
4455
luxiDefCtmo = 10
4456

    
4457
luxiDefRwto :: Int
4458
luxiDefRwto = 60
4459

    
4460
-- | 'WaitForJobChange' timeout
4461
luxiWfjcTimeout :: Int
4462
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4463

    
4464
-- * Query language constants
4465

    
4466
-- ** Logic operators with one or more operands, each of which is a
4467
-- filter on its own
4468

    
4469
qlangOpAnd :: String
4470
qlangOpAnd = "&"
4471

    
4472
qlangOpOr :: String
4473
qlangOpOr = "|"
4474

    
4475
-- ** Unary operators with exactly one operand
4476

    
4477
qlangOpNot :: String
4478
qlangOpNot = "!"
4479

    
4480
qlangOpTrue :: String
4481
qlangOpTrue = "?"
4482

    
4483
-- ** Binary operators with exactly two operands, the field name and
4484
-- an operator-specific value
4485

    
4486
qlangOpContains :: String
4487
qlangOpContains = "=[]"
4488

    
4489
qlangOpEqual :: String
4490
qlangOpEqual = "="
4491

    
4492
qlangOpGe :: String
4493
qlangOpGe = ">="
4494

    
4495
qlangOpGt :: String
4496
qlangOpGt = ">"
4497

    
4498
qlangOpLe :: String
4499
qlangOpLe = "<="
4500

    
4501
qlangOpLt :: String
4502
qlangOpLt = "<"
4503

    
4504
qlangOpNotEqual :: String
4505
qlangOpNotEqual = "!="
4506

    
4507
qlangOpRegexp :: String
4508
qlangOpRegexp = "=~"
4509

    
4510
-- | Characters used for detecting user-written filters (see
4511
-- L{_CheckFilter})
4512

    
4513
qlangFilterDetectionChars :: FrozenSet String
4514
qlangFilterDetectionChars =
4515
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4516
                       ")", "(", "\x0b", "\n",
4517
                       "\r", "\x0c", "/", "<",
4518
                       "\t", ">", "=", "\\", "~"]
4519

    
4520
-- | Characters used to detect globbing filters
4521
qlangGlobDetectionChars :: FrozenSet String
4522
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4523

    
4524
-- * Error related constants
4525
--
4526
-- 'OpPrereqError' failure types
4527

    
4528
-- | Environment error (e.g. node disk error)
4529
errorsEcodeEnviron :: String
4530
errorsEcodeEnviron = "environment_error"
4531

    
4532
-- | Entity already exists
4533
errorsEcodeExists :: String
4534
errorsEcodeExists = "already_exists"
4535

    
4536
-- | Internal cluster error
4537
errorsEcodeFault :: String
4538
errorsEcodeFault = "internal_error"
4539

    
4540
-- | Wrong arguments (at syntax level)
4541
errorsEcodeInval :: String
4542
errorsEcodeInval = "wrong_input"
4543

    
4544
-- | Entity not found
4545
errorsEcodeNoent :: String
4546
errorsEcodeNoent = "unknown_entity"
4547

    
4548
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4549
errorsEcodeNores :: String
4550
errorsEcodeNores = "insufficient_resources"
4551

    
4552
-- | Resource not unique (e.g. MAC or IP duplication)
4553
errorsEcodeNotunique :: String
4554
errorsEcodeNotunique = "resource_not_unique"
4555

    
4556
-- | Resolver errors
4557
errorsEcodeResolver :: String
4558
errorsEcodeResolver = "resolver_error"
4559

    
4560
-- | Wrong entity state
4561
errorsEcodeState :: String
4562
errorsEcodeState = "wrong_state"
4563

    
4564
-- | Temporarily out of resources; operation can be tried again
4565
errorsEcodeTempNores :: String
4566
errorsEcodeTempNores = "temp_insufficient_resources"
4567

    
4568
errorsEcodeAll :: FrozenSet String
4569
errorsEcodeAll =
4570
  ConstantUtils.mkSet [ errorsEcodeNores
4571
                      , errorsEcodeExists
4572
                      , errorsEcodeState
4573
                      , errorsEcodeNotunique
4574
                      , errorsEcodeTempNores
4575
                      , errorsEcodeNoent
4576
                      , errorsEcodeFault
4577
                      , errorsEcodeResolver
4578
                      , errorsEcodeInval
4579
                      , errorsEcodeEnviron
4580
                      ]
4581

    
4582
-- * Jstore related constants
4583

    
4584
jstoreJobsPerArchiveDirectory :: Int
4585
jstoreJobsPerArchiveDirectory = 10000