Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 0cd5ab45

History | View | Annotate | Download (119.1 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

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

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

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

    
36
-}
37
module Ganeti.Constants where
38

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

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

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

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

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

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

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

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

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

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

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

    
86
-- ** Build-time constants
87

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
135
-- * Various versions
136

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

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

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

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

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

    
152
osApiV10 :: Int
153
osApiV10 = 10
154

    
155
osApiV15 :: Int
156
osApiV15 = 15
157

    
158
osApiV20 :: Int
159
osApiV20 = 20
160

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

    
164
exportVersion :: Int
165
exportVersion = 0
166

    
167
rapiVersion :: Int
168
rapiVersion = 2
169

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

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

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

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

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

    
189
-- * User separation
190

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

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

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

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

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

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

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

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

    
215
kvmdUser :: String
216
kvmdUser = Runtime.daemonUser GanetiKvmd
217

    
218
kvmdGroup :: String
219
kvmdGroup = Runtime.daemonGroup (DaemonGroup GanetiKvmd)
220

    
221
luxidUser :: String
222
luxidUser = Runtime.daemonUser GanetiLuxid
223

    
224
luxidGroup :: String
225
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
226

    
227
nodedUser :: String
228
nodedUser = Runtime.daemonUser GanetiNoded
229

    
230
nodedGroup :: String
231
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
232

    
233
mondUser :: String
234
mondUser = Runtime.daemonUser GanetiMond
235

    
236
mondGroup :: String
237
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
238

    
239
sshLoginUser :: String
240
sshLoginUser = AutoConf.sshLoginUser
241

    
242
sshConsoleUser :: String
243
sshConsoleUser = AutoConf.sshConsoleUser
244

    
245
-- * Cpu pinning separators and constants
246

    
247
cpuPinningSep :: String
248
cpuPinningSep = ":"
249

    
250
cpuPinningAll :: String
251
cpuPinningAll = "all"
252

    
253
-- | Internal representation of "all"
254
cpuPinningAllVal :: Int
255
cpuPinningAllVal = -1
256

    
257
-- | One "all" entry in a CPU list means CPU pinning is off
258
cpuPinningOff :: [Int]
259
cpuPinningOff = [cpuPinningAllVal]
260

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

    
277
-- | A KVM-specific implementation detail - the following value is
278
-- used to set CPU affinity to all processors (--0 through --31), per
279
-- taskset man page.
280
--
281
-- FIXME: This only works for machines with up to 32 CPU cores
282
cpuPinningAllKvm :: Int
283
cpuPinningAllKvm = 0xFFFFFFFF
284

    
285
-- * Wipe
286

    
287
ddCmd :: String
288
ddCmd = "dd"
289

    
290
-- | 1GB
291
maxWipeChunk :: Int
292
maxWipeChunk = 1024
293

    
294
minWipeChunkPercent :: Int
295
minWipeChunkPercent = 10
296

    
297
-- * Directories
298

    
299
runDirsMode :: Int
300
runDirsMode = 0o775
301

    
302
secureDirMode :: Int
303
secureDirMode = 0o700
304

    
305
secureFileMode :: Int
306
secureFileMode = 0o600
307

    
308
adoptableBlockdevRoot :: String
309
adoptableBlockdevRoot = "/dev/disk/"
310

    
311
-- * 'autoconf' enable/disable
312

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

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

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

    
322
-- * SSH constants
323

    
324
ssh :: String
325
ssh = "ssh"
326

    
327
scp :: String
328
scp = "scp"
329

    
330
-- * Daemons
331

    
332
confd :: String
333
confd = Runtime.daemonName GanetiConfd
334

    
335
masterd :: String
336
masterd = Runtime.daemonName GanetiMasterd
337

    
338
mond :: String
339
mond = Runtime.daemonName GanetiMond
340

    
341
noded :: String
342
noded = Runtime.daemonName GanetiNoded
343

    
344
luxid :: String
345
luxid = Runtime.daemonName GanetiLuxid
346

    
347
rapi :: String
348
rapi = Runtime.daemonName GanetiRapi
349

    
350
kvmd :: String
351
kvmd = Runtime.daemonName GanetiKvmd
352

    
353
daemons :: FrozenSet String
354
daemons =
355
  ConstantUtils.mkSet [confd,
356
                       luxid,
357
                       masterd,
358
                       mond,
359
                       noded,
360
                       rapi]
361

    
362
defaultConfdPort :: Int
363
defaultConfdPort = 1814
364

    
365
defaultMondPort :: Int
366
defaultMondPort = 1815
367

    
368
defaultNodedPort :: Int
369
defaultNodedPort = 1811
370

    
371
defaultRapiPort :: Int
372
defaultRapiPort = 5080
373

    
374
daemonsPorts :: Map String (Protocol, Int)
375
daemonsPorts =
376
  Map.fromList [(confd, (Udp, defaultConfdPort)),
377
                (mond, (Tcp, defaultMondPort)),
378
                (noded, (Tcp, defaultNodedPort)),
379
                (rapi, (Tcp, defaultRapiPort)),
380
                (ssh, (Tcp, 22))]
381

    
382
firstDrbdPort :: Int
383
firstDrbdPort = 11000
384

    
385
lastDrbdPort :: Int
386
lastDrbdPort = 14999
387

    
388
daemonsLogbase :: Map String String
389
daemonsLogbase =
390
  Map.fromList
391
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
392

    
393
daemonsExtraLogbase :: Map String (Map String String)
394
daemonsExtraLogbase =
395
  Map.fromList $
396
  map (Runtime.daemonName *** id)
397
  [ (GanetiMond, Map.fromList
398
                 [ ("access", Runtime.daemonsExtraLogbase GanetiMond AccessLog)
399
                 , ("error", Runtime.daemonsExtraLogbase GanetiMond ErrorLog)
400
                 ])
401
  ]
402

    
403
extraLogreasonAccess :: String
404
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
405

    
406
extraLogreasonError :: String
407
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
408

    
409
devConsole :: String
410
devConsole = ConstantUtils.devConsole
411

    
412
procMounts :: String
413
procMounts = "/proc/mounts"
414

    
415
-- * Luxi (Local UniX Interface) related constants
416

    
417
luxiEom :: PythonChar
418
luxiEom = PythonChar '\x03'
419

    
420
-- | Environment variable for the luxi override socket
421
luxiOverride :: String
422
luxiOverride = "FORCE_LUXI_SOCKET"
423

    
424
luxiOverrideMaster :: String
425
luxiOverrideMaster = "master"
426

    
427
luxiOverrideQuery :: String
428
luxiOverrideQuery = "query"
429

    
430
luxiVersion :: Int
431
luxiVersion = configVersion
432

    
433
-- * Syslog
434

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

    
438
syslogNo :: String
439
syslogNo = Logging.syslogUsageToRaw SyslogNo
440

    
441
syslogYes :: String
442
syslogYes = Logging.syslogUsageToRaw SyslogYes
443

    
444
syslogOnly :: String
445
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
446

    
447
syslogSocket :: String
448
syslogSocket = "/dev/log"
449

    
450
exportConfFile :: String
451
exportConfFile = "config.ini"
452

    
453
-- * Xen
454

    
455
xenBootloader :: String
456
xenBootloader = AutoConf.xenBootloader
457

    
458
xenCmdXl :: String
459
xenCmdXl = "xl"
460

    
461
xenCmdXm :: String
462
xenCmdXm = "xm"
463

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

    
467
xenKernel :: String
468
xenKernel = AutoConf.xenKernel
469

    
470
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
471
-- other constants
472
knownXenCommands :: FrozenSet String
473
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
474

    
475
-- * KVM and socat
476

    
477
kvmPath :: String
478
kvmPath = AutoConf.kvmPath
479

    
480
kvmKernel :: String
481
kvmKernel = AutoConf.kvmKernel
482

    
483
socatEscapeCode :: String
484
socatEscapeCode = "0x1d"
485

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

    
489
socatUseCompress :: Bool
490
socatUseCompress = AutoConf.socatUseCompress
491

    
492
socatUseEscape :: Bool
493
socatUseEscape = AutoConf.socatUseEscape
494

    
495
-- * Console types
496

    
497
-- | Display a message for console access
498
consMessage :: String
499
consMessage = "msg"
500

    
501
-- | Console as SPICE server
502
consSpice :: String
503
consSpice = "spice"
504

    
505
-- | Console as SSH command
506
consSsh :: String
507
consSsh = "ssh"
508

    
509
-- | Console as VNC server
510
consVnc :: String
511
consVnc = "vnc"
512

    
513
consAll :: FrozenSet String
514
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
515

    
516
-- | RSA key bit length
517
--
518
-- For RSA keys more bits are better, but they also make operations
519
-- more expensive. NIST SP 800-131 recommends a minimum of 2048 bits
520
-- from the year 2010 on.
521
rsaKeyBits :: Int
522
rsaKeyBits = 2048
523

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

    
535
-- * X509
536

    
537
-- | commonName (CN) used in certificates
538
x509CertCn :: String
539
x509CertCn = "ganeti.example.com"
540

    
541
-- | Default validity of certificates in days
542
x509CertDefaultValidity :: Int
543
x509CertDefaultValidity = 365 * 5
544

    
545
x509CertSignatureHeader :: String
546
x509CertSignatureHeader = "X-Ganeti-Signature"
547

    
548
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
549
x509CertSignDigest :: String
550
x509CertSignDigest = "SHA1"
551

    
552
-- * Import/export daemon mode
553

    
554
iemExport :: String
555
iemExport = "export"
556

    
557
iemImport :: String
558
iemImport = "import"
559

    
560
-- * Import/export transport compression
561

    
562
iecGzip :: String
563
iecGzip = "gzip"
564

    
565
iecNone :: String
566
iecNone = "none"
567

    
568
iecAll :: [String]
569
iecAll = [iecGzip, iecNone]
570

    
571
ieCustomSize :: String
572
ieCustomSize = "fd"
573

    
574
-- * Import/export I/O
575

    
576
-- | Direct file I/O, equivalent to a shell's I/O redirection using
577
-- '<' or '>'
578
ieioFile :: String
579
ieioFile = "file"
580

    
581
-- | Raw block device I/O using "dd"
582
ieioRawDisk :: String
583
ieioRawDisk = "raw"
584

    
585
-- | OS definition import/export script
586
ieioScript :: String
587
ieioScript = "script"
588

    
589
-- * Values
590

    
591
valueDefault :: String
592
valueDefault = "default"
593

    
594
valueAuto :: String
595
valueAuto = "auto"
596

    
597
valueGenerate :: String
598
valueGenerate = "generate"
599

    
600
valueNone :: String
601
valueNone = "none"
602

    
603
valueTrue :: String
604
valueTrue = "true"
605

    
606
valueFalse :: String
607
valueFalse = "false"
608

    
609
-- * Hooks
610

    
611
hooksNameCfgupdate :: String
612
hooksNameCfgupdate = "config-update"
613

    
614
hooksNameWatcher :: String
615
hooksNameWatcher = "watcher"
616

    
617
hooksPath :: String
618
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
619

    
620
hooksPhasePost :: String
621
hooksPhasePost = "post"
622

    
623
hooksPhasePre :: String
624
hooksPhasePre = "pre"
625

    
626
hooksVersion :: Int
627
hooksVersion = 2
628

    
629
-- * Hooks subject type (what object type does the LU deal with)
630

    
631
htypeCluster :: String
632
htypeCluster = "CLUSTER"
633

    
634
htypeGroup :: String
635
htypeGroup = "GROUP"
636

    
637
htypeInstance :: String
638
htypeInstance = "INSTANCE"
639

    
640
htypeNetwork :: String
641
htypeNetwork = "NETWORK"
642

    
643
htypeNode :: String
644
htypeNode = "NODE"
645

    
646
-- * Hkr
647

    
648
hkrSkip :: Int
649
hkrSkip = 0
650

    
651
hkrFail :: Int
652
hkrFail = 1
653

    
654
hkrSuccess :: Int
655
hkrSuccess = 2
656

    
657
-- * Storage types
658

    
659
stBlock :: String
660
stBlock = Types.storageTypeToRaw StorageBlock
661

    
662
stDiskless :: String
663
stDiskless = Types.storageTypeToRaw StorageDiskless
664

    
665
stExt :: String
666
stExt = Types.storageTypeToRaw StorageExt
667

    
668
stFile :: String
669
stFile = Types.storageTypeToRaw StorageFile
670

    
671
stSharedFile :: String
672
stSharedFile = Types.storageTypeToRaw StorageSharedFile
673

    
674
stLvmPv :: String
675
stLvmPv = Types.storageTypeToRaw StorageLvmPv
676

    
677
stLvmVg :: String
678
stLvmVg = Types.storageTypeToRaw StorageLvmVg
679

    
680
stRados :: String
681
stRados = Types.storageTypeToRaw StorageRados
682

    
683
storageTypes :: FrozenSet String
684
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
685

    
686
-- | The set of storage types for which full storage reporting is available
687
stsReport :: FrozenSet String
688
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
689

    
690
-- | The set of storage types for which node storage reporting is available
691
-- | (as used by LUQueryNodeStorage)
692
stsReportNodeStorage :: FrozenSet String
693
stsReportNodeStorage = ConstantUtils.union stsReport $
694
                                           ConstantUtils.mkSet [stSharedFile]
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
dtGluster :: String
808
dtGluster = Types.diskTemplateToRaw DTGluster
809

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

    
821
diskTemplates :: FrozenSet String
822
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
823

    
824
-- | Disk templates that are enabled by default
825
defaultEnabledDiskTemplates :: [String]
826
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
827

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

    
843
-- | The set of network-mirrored disk templates
844
dtsIntMirror :: FrozenSet String
845
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
846

    
847
-- | 'DTDiskless' is 'trivially' externally mirrored
848
dtsExtMirror :: FrozenSet String
849
dtsExtMirror =
850
  ConstantUtils.mkSet $
851
  map Types.diskTemplateToRaw
852
  [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd, DTGluster]
853

    
854
-- | The set of non-lvm-based disk templates
855
dtsNotLvm :: FrozenSet String
856
dtsNotLvm =
857
  ConstantUtils.mkSet $
858
  map Types.diskTemplateToRaw
859
  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd, DTGluster]
860

    
861
-- | The set of disk templates which can be grown
862
dtsGrowable :: FrozenSet String
863
dtsGrowable =
864
  ConstantUtils.mkSet $
865
  map Types.diskTemplateToRaw
866
  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd, DTGluster]
867

    
868
-- | The set of disk templates that allow adoption
869
dtsMayAdopt :: FrozenSet String
870
dtsMayAdopt =
871
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
872

    
873
-- | The set of disk templates that *must* use adoption
874
dtsMustAdopt :: FrozenSet String
875
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
876

    
877
-- | The set of disk templates that allow migrations
878
dtsMirrored :: FrozenSet String
879
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
880

    
881
-- | The set of file based disk templates
882
dtsFilebased :: FrozenSet String
883
dtsFilebased =
884
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw
885
  [DTSharedFile, DTFile, DTGluster]
886

    
887
-- | The set of disk templates that can be moved by copying
888
--
889
-- Note: a requirement is that they're not accessed externally or
890
-- shared between nodes; in particular, sharedfile is not suitable.
891
dtsCopyable :: FrozenSet String
892
dtsCopyable =
893
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
894

    
895
-- | The set of disk templates that are supported by exclusive_storage
896
dtsExclStorage :: FrozenSet String
897
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
898

    
899
-- | Templates for which we don't perform checks on free space
900
dtsNoFreeSpaceCheck :: FrozenSet String
901
dtsNoFreeSpaceCheck =
902
  ConstantUtils.mkSet $
903
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd, DTGluster]
904

    
905
dtsBlock :: FrozenSet String
906
dtsBlock =
907
  ConstantUtils.mkSet $
908
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
909

    
910
-- | The set of lvm-based disk templates
911
dtsLvm :: FrozenSet String
912
dtsLvm = diskTemplates `ConstantUtils.difference` dtsNotLvm
913

    
914
-- | The set of lvm-based disk templates
915
dtsHaveAccess :: FrozenSet String
916
dtsHaveAccess = ConstantUtils.mkSet $
917
  map Types.diskTemplateToRaw [DTRbd, DTGluster]
918

    
919
-- * Drbd
920

    
921
drbdHmacAlg :: String
922
drbdHmacAlg = "md5"
923

    
924
drbdDefaultNetProtocol :: String
925
drbdDefaultNetProtocol = "C"
926

    
927
drbdMigrationNetProtocol :: String
928
drbdMigrationNetProtocol = "C"
929

    
930
drbdStatusFile :: String
931
drbdStatusFile = "/proc/drbd"
932

    
933
-- | Size of DRBD meta block device
934
drbdMetaSize :: Int
935
drbdMetaSize = 128
936

    
937
-- * Drbd barrier types
938

    
939
drbdBDiskBarriers :: String
940
drbdBDiskBarriers = "b"
941

    
942
drbdBDiskDrain :: String
943
drbdBDiskDrain = "d"
944

    
945
drbdBDiskFlush :: String
946
drbdBDiskFlush = "f"
947

    
948
drbdBNone :: String
949
drbdBNone = "n"
950

    
951
-- | Valid barrier combinations: "n" or any non-null subset of "bfd"
952
drbdValidBarrierOpt :: FrozenSet (FrozenSet String)
953
drbdValidBarrierOpt =
954
  ConstantUtils.mkSet
955
  [ ConstantUtils.mkSet [drbdBNone]
956
  , ConstantUtils.mkSet [drbdBDiskBarriers]
957
  , ConstantUtils.mkSet [drbdBDiskDrain]
958
  , ConstantUtils.mkSet [drbdBDiskFlush]
959
  , ConstantUtils.mkSet [drbdBDiskDrain, drbdBDiskFlush]
960
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskDrain]
961
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush]
962
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush, drbdBDiskDrain]
963
  ]
964

    
965
-- | Rbd tool command
966
rbdCmd :: String
967
rbdCmd = "rbd"
968

    
969
-- * File backend driver
970

    
971
fdBlktap :: String
972
fdBlktap = Types.fileDriverToRaw FileBlktap
973

    
974
fdBlktap2 :: String
975
fdBlktap2 = Types.fileDriverToRaw FileBlktap2
976

    
977
fdLoop :: String
978
fdLoop = Types.fileDriverToRaw FileLoop
979

    
980
fdDefault :: String
981
fdDefault = fdLoop
982

    
983
fileDriver :: FrozenSet String
984
fileDriver =
985
  ConstantUtils.mkSet $
986
  map Types.fileDriverToRaw [minBound..]
987

    
988
-- | The set of drbd-like disk types
989
dtsDrbd :: FrozenSet String
990
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
991

    
992
-- * Disk access mode
993

    
994
diskRdonly :: String
995
diskRdonly = Types.diskModeToRaw DiskRdOnly
996

    
997
diskRdwr :: String
998
diskRdwr = Types.diskModeToRaw DiskRdWr
999

    
1000
diskAccessSet :: FrozenSet String
1001
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
1002

    
1003
-- * Disk replacement mode
1004

    
1005
replaceDiskAuto :: String
1006
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
1007

    
1008
replaceDiskChg :: String
1009
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
1010

    
1011
replaceDiskPri :: String
1012
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
1013

    
1014
replaceDiskSec :: String
1015
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
1016

    
1017
replaceModes :: FrozenSet String
1018
replaceModes =
1019
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
1020

    
1021
-- * Instance export mode
1022

    
1023
exportModeLocal :: String
1024
exportModeLocal = Types.exportModeToRaw ExportModeLocal
1025

    
1026
exportModeRemote :: String
1027
exportModeRemote = Types.exportModeToRaw ExportModeRemote
1028

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

    
1032
-- * Instance creation modes
1033

    
1034
instanceCreate :: String
1035
instanceCreate = Types.instCreateModeToRaw InstCreate
1036

    
1037
instanceImport :: String
1038
instanceImport = Types.instCreateModeToRaw InstImport
1039

    
1040
instanceRemoteImport :: String
1041
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1042

    
1043
instanceCreateModes :: FrozenSet String
1044
instanceCreateModes =
1045
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1046

    
1047
-- * Remote import/export handshake message and version
1048

    
1049
rieHandshake :: String
1050
rieHandshake = "Hi, I'm Ganeti"
1051

    
1052
rieVersion :: Int
1053
rieVersion = 0
1054

    
1055
-- | Remote import/export certificate validity (seconds)
1056
rieCertValidity :: Int
1057
rieCertValidity = 24 * 60 * 60
1058

    
1059
-- | Export only: how long to wait per connection attempt (seconds)
1060
rieConnectAttemptTimeout :: Int
1061
rieConnectAttemptTimeout = 20
1062

    
1063
-- | Export only: number of attempts to connect
1064
rieConnectRetries :: Int
1065
rieConnectRetries = 10
1066

    
1067
-- | Overall timeout for establishing connection
1068
rieConnectTimeout :: Int
1069
rieConnectTimeout = 180
1070

    
1071
-- | Give child process up to 5 seconds to exit after sending a signal
1072
childLingerTimeout :: Double
1073
childLingerTimeout = 5.0
1074

    
1075
-- * Import/export config options
1076

    
1077
inisectBep :: String
1078
inisectBep = "backend"
1079

    
1080
inisectExp :: String
1081
inisectExp = "export"
1082

    
1083
inisectHyp :: String
1084
inisectHyp = "hypervisor"
1085

    
1086
inisectIns :: String
1087
inisectIns = "instance"
1088

    
1089
inisectOsp :: String
1090
inisectOsp = "os"
1091

    
1092
-- * Dynamic device modification
1093

    
1094
ddmAdd :: String
1095
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1096

    
1097
ddmModify :: String
1098
ddmModify = Types.ddmFullToRaw DdmFullModify
1099

    
1100
ddmRemove :: String
1101
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1102

    
1103
ddmsValues :: FrozenSet String
1104
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1105

    
1106
ddmsValuesWithModify :: FrozenSet String
1107
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1108

    
1109
-- * Common exit codes
1110

    
1111
exitSuccess :: Int
1112
exitSuccess = 0
1113

    
1114
exitFailure :: Int
1115
exitFailure = ConstantUtils.exitFailure
1116

    
1117
exitNotcluster :: Int
1118
exitNotcluster = 5
1119

    
1120
exitNotmaster :: Int
1121
exitNotmaster = 11
1122

    
1123
exitNodesetupError :: Int
1124
exitNodesetupError = 12
1125

    
1126
-- | Need user confirmation
1127
exitConfirmation :: Int
1128
exitConfirmation = 13
1129

    
1130
-- | Exit code for query operations with unknown fields
1131
exitUnknownField :: Int
1132
exitUnknownField = 14
1133

    
1134
-- * Tags
1135

    
1136
tagCluster :: String
1137
tagCluster = Types.tagKindToRaw TagKindCluster
1138

    
1139
tagInstance :: String
1140
tagInstance = Types.tagKindToRaw TagKindInstance
1141

    
1142
tagNetwork :: String
1143
tagNetwork = Types.tagKindToRaw TagKindNetwork
1144

    
1145
tagNode :: String
1146
tagNode = Types.tagKindToRaw TagKindNode
1147

    
1148
tagNodegroup :: String
1149
tagNodegroup = Types.tagKindToRaw TagKindGroup
1150

    
1151
validTagTypes :: FrozenSet String
1152
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1153

    
1154
maxTagLen :: Int
1155
maxTagLen = 128
1156

    
1157
maxTagsPerObj :: Int
1158
maxTagsPerObj = 4096
1159

    
1160
-- * Others
1161

    
1162
defaultBridge :: String
1163
defaultBridge = "xen-br0"
1164

    
1165
defaultOvs :: String
1166
defaultOvs = "switch1"
1167

    
1168
-- | 60 MiB/s, expressed in KiB/s
1169
classicDrbdSyncSpeed :: Int
1170
classicDrbdSyncSpeed = 60 * 1024
1171

    
1172
ip4AddressAny :: String
1173
ip4AddressAny = "0.0.0.0"
1174

    
1175
ip4AddressLocalhost :: String
1176
ip4AddressLocalhost = "127.0.0.1"
1177

    
1178
ip6AddressAny :: String
1179
ip6AddressAny = "::"
1180

    
1181
ip6AddressLocalhost :: String
1182
ip6AddressLocalhost = "::1"
1183

    
1184
ip4Version :: Int
1185
ip4Version = 4
1186

    
1187
ip6Version :: Int
1188
ip6Version = 6
1189

    
1190
validIpVersions :: FrozenSet Int
1191
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1192

    
1193
tcpPingTimeout :: Int
1194
tcpPingTimeout = 10
1195

    
1196
defaultVg :: String
1197
defaultVg = "xenvg"
1198

    
1199
defaultDrbdHelper :: String
1200
defaultDrbdHelper = "/bin/true"
1201

    
1202
minVgSize :: Int
1203
minVgSize = 20480
1204

    
1205
defaultMacPrefix :: String
1206
defaultMacPrefix = "aa:00:00"
1207

    
1208
-- | Default maximum instance wait time (seconds)
1209
defaultShutdownTimeout :: Int
1210
defaultShutdownTimeout = 120
1211

    
1212
-- | Node clock skew (seconds)
1213
nodeMaxClockSkew :: Int
1214
nodeMaxClockSkew = 150
1215

    
1216
-- | Time for an intra-cluster disk transfer to wait for a connection
1217
diskTransferConnectTimeout :: Int
1218
diskTransferConnectTimeout = 60
1219

    
1220
-- | Disk index separator
1221
diskSeparator :: String
1222
diskSeparator = AutoConf.diskSeparator
1223

    
1224
ipCommandPath :: String
1225
ipCommandPath = AutoConf.ipPath
1226

    
1227
-- | Key for job IDs in opcode result
1228
jobIdsKey :: String
1229
jobIdsKey = "jobs"
1230

    
1231
-- * Runparts results
1232

    
1233
runpartsErr :: Int
1234
runpartsErr = 2
1235

    
1236
runpartsRun :: Int
1237
runpartsRun = 1
1238

    
1239
runpartsSkip :: Int
1240
runpartsSkip = 0
1241

    
1242
runpartsStatus :: [Int]
1243
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1244

    
1245
-- * RPC
1246

    
1247
rpcEncodingNone :: Int
1248
rpcEncodingNone = 0
1249

    
1250
rpcEncodingZlibBase64 :: Int
1251
rpcEncodingZlibBase64 = 1
1252

    
1253
-- * Timeout table
1254
--
1255
-- Various time constants for the timeout table
1256

    
1257
rpcTmoUrgent :: Int
1258
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1259

    
1260
rpcTmoFast :: Int
1261
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1262

    
1263
rpcTmoNormal :: Int
1264
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1265

    
1266
rpcTmoSlow :: Int
1267
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1268

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

    
1275
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1276
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1277
-- Python name.
1278
rpcTmo_1day :: Int
1279
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1280

    
1281
-- | Timeout for connecting to nodes (seconds)
1282
rpcConnectTimeout :: Int
1283
rpcConnectTimeout = 5
1284

    
1285
-- OS
1286

    
1287
osScriptCreate :: String
1288
osScriptCreate = "create"
1289

    
1290
osScriptExport :: String
1291
osScriptExport = "export"
1292

    
1293
osScriptImport :: String
1294
osScriptImport = "import"
1295

    
1296
osScriptRename :: String
1297
osScriptRename = "rename"
1298

    
1299
osScriptVerify :: String
1300
osScriptVerify = "verify"
1301

    
1302
osScripts :: [String]
1303
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1304
             osScriptVerify]
1305

    
1306
osApiFile :: String
1307
osApiFile = "ganeti_api_version"
1308

    
1309
osVariantsFile :: String
1310
osVariantsFile = "variants.list"
1311

    
1312
osParametersFile :: String
1313
osParametersFile = "parameters.list"
1314

    
1315
osValidateParameters :: String
1316
osValidateParameters = "parameters"
1317

    
1318
osValidateCalls :: FrozenSet String
1319
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1320

    
1321
-- | External Storage (ES) related constants
1322

    
1323
esActionAttach :: String
1324
esActionAttach = "attach"
1325

    
1326
esActionCreate :: String
1327
esActionCreate = "create"
1328

    
1329
esActionDetach :: String
1330
esActionDetach = "detach"
1331

    
1332
esActionGrow :: String
1333
esActionGrow = "grow"
1334

    
1335
esActionRemove :: String
1336
esActionRemove = "remove"
1337

    
1338
esActionSetinfo :: String
1339
esActionSetinfo = "setinfo"
1340

    
1341
esActionVerify :: String
1342
esActionVerify = "verify"
1343

    
1344
esScriptCreate :: String
1345
esScriptCreate = esActionCreate
1346

    
1347
esScriptRemove :: String
1348
esScriptRemove = esActionRemove
1349

    
1350
esScriptGrow :: String
1351
esScriptGrow = esActionGrow
1352

    
1353
esScriptAttach :: String
1354
esScriptAttach = esActionAttach
1355

    
1356
esScriptDetach :: String
1357
esScriptDetach = esActionDetach
1358

    
1359
esScriptSetinfo :: String
1360
esScriptSetinfo = esActionSetinfo
1361

    
1362
esScriptVerify :: String
1363
esScriptVerify = esActionVerify
1364

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

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

    
1378
-- * Reboot types
1379

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

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

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

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

    
1392
-- * Instance reboot behaviors
1393

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

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

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

    
1403
-- * VTypes
1404

    
1405
vtypeBool :: VType
1406
vtypeBool = VTypeBool
1407

    
1408
vtypeInt :: VType
1409
vtypeInt = VTypeInt
1410

    
1411
vtypeMaybeString :: VType
1412
vtypeMaybeString = VTypeMaybeString
1413

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

    
1418
vtypeString :: VType
1419
vtypeString = VTypeString
1420

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1532
hvKvmPath :: String
1533
hvKvmPath = "kvm_path"
1534

    
1535
hvKvmSpiceAudioCompr :: String
1536
hvKvmSpiceAudioCompr = "spice_playback_compression"
1537

    
1538
hvKvmSpiceBind :: String
1539
hvKvmSpiceBind = "spice_bind"
1540

    
1541
hvKvmSpiceIpVersion :: String
1542
hvKvmSpiceIpVersion = "spice_ip_version"
1543

    
1544
hvKvmSpiceJpegImgCompr :: String
1545
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1546

    
1547
hvKvmSpiceLosslessImgCompr :: String
1548
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1549

    
1550
hvKvmSpicePasswordFile :: String
1551
hvKvmSpicePasswordFile = "spice_password_file"
1552

    
1553
hvKvmSpiceStreamingVideoDetection :: String
1554
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1555

    
1556
hvKvmSpiceTlsCiphers :: String
1557
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1558

    
1559
hvKvmSpiceUseTls :: String
1560
hvKvmSpiceUseTls = "spice_use_tls"
1561

    
1562
hvKvmSpiceUseVdagent :: String
1563
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1564

    
1565
hvKvmSpiceZlibGlzImgCompr :: String
1566
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1567

    
1568
hvKvmUseChroot :: String
1569
hvKvmUseChroot = "use_chroot"
1570

    
1571
hvKvmUserShutdown :: String
1572
hvKvmUserShutdown = "user_shutdown"
1573

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1637
hvVifScript :: String
1638
hvVifScript = "vif_script"
1639

    
1640
hvVifType :: String
1641
hvVifType = "vif_type"
1642

    
1643
hvViridian :: String
1644
hvViridian = "viridian"
1645

    
1646
hvVncBindAddress :: String
1647
hvVncBindAddress = "vnc_bind_address"
1648

    
1649
hvVncPasswordFile :: String
1650
hvVncPasswordFile = "vnc_password_file"
1651

    
1652
hvVncTls :: String
1653
hvVncTls = "vnc_tls"
1654

    
1655
hvVncX509 :: String
1656
hvVncX509 = "vnc_x509_path"
1657

    
1658
hvVncX509Verify :: String
1659
hvVncX509Verify = "vnc_x509_verify"
1660

    
1661
hvVnetHdr :: String
1662
hvVnetHdr = "vnet_hdr"
1663

    
1664
hvXenCmd :: String
1665
hvXenCmd = "xen_cmd"
1666

    
1667
hvXenCpuid :: String
1668
hvXenCpuid = "cpuid"
1669

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

    
1685
hvsParameters :: FrozenSet String
1686
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1687

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

    
1765
-- * Migration statuses
1766

    
1767
hvMigrationActive :: String
1768
hvMigrationActive = "active"
1769

    
1770
hvMigrationCancelled :: String
1771
hvMigrationCancelled = "cancelled"
1772

    
1773
hvMigrationCompleted :: String
1774
hvMigrationCompleted = "completed"
1775

    
1776
hvMigrationFailed :: String
1777
hvMigrationFailed = "failed"
1778

    
1779
hvMigrationValidStatuses :: FrozenSet String
1780
hvMigrationValidStatuses =
1781
  ConstantUtils.mkSet [hvMigrationActive,
1782
                       hvMigrationCancelled,
1783
                       hvMigrationCompleted,
1784
                       hvMigrationFailed]
1785

    
1786
hvMigrationFailedStatuses :: FrozenSet String
1787
hvMigrationFailedStatuses =
1788
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1789

    
1790
-- | KVM-specific statuses
1791
--
1792
-- FIXME: this constant seems unnecessary
1793
hvKvmMigrationValidStatuses :: FrozenSet String
1794
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1795

    
1796
-- | Node info keys
1797
hvNodeinfoKeyVersion :: String
1798
hvNodeinfoKeyVersion = "hv_version"
1799

    
1800
-- * Hypervisor state
1801

    
1802
hvstCpuNode :: String
1803
hvstCpuNode = "cpu_node"
1804

    
1805
hvstCpuTotal :: String
1806
hvstCpuTotal = "cpu_total"
1807

    
1808
hvstMemoryHv :: String
1809
hvstMemoryHv = "mem_hv"
1810

    
1811
hvstMemoryNode :: String
1812
hvstMemoryNode = "mem_node"
1813

    
1814
hvstMemoryTotal :: String
1815
hvstMemoryTotal = "mem_total"
1816

    
1817
hvstsParameters :: FrozenSet String
1818
hvstsParameters =
1819
  ConstantUtils.mkSet [hvstCpuNode,
1820
                       hvstCpuTotal,
1821
                       hvstMemoryHv,
1822
                       hvstMemoryNode,
1823
                       hvstMemoryTotal]
1824

    
1825
hvstDefaults :: Map String Int
1826
hvstDefaults =
1827
  Map.fromList
1828
  [(hvstCpuNode, 1),
1829
   (hvstCpuTotal, 1),
1830
   (hvstMemoryHv, 0),
1831
   (hvstMemoryTotal, 0),
1832
   (hvstMemoryNode, 0)]
1833

    
1834
hvstsParameterTypes :: Map String VType
1835
hvstsParameterTypes =
1836
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1837
                (hvstMemoryNode, VTypeInt),
1838
                (hvstMemoryHv, VTypeInt),
1839
                (hvstCpuTotal, VTypeInt),
1840
                (hvstCpuNode, VTypeInt)]
1841

    
1842
-- * Disk state
1843

    
1844
dsDiskOverhead :: String
1845
dsDiskOverhead = "disk_overhead"
1846

    
1847
dsDiskReserved :: String
1848
dsDiskReserved = "disk_reserved"
1849

    
1850
dsDiskTotal :: String
1851
dsDiskTotal = "disk_total"
1852

    
1853
dsDefaults :: Map String Int
1854
dsDefaults =
1855
  Map.fromList
1856
  [(dsDiskTotal, 0),
1857
   (dsDiskReserved, 0),
1858
   (dsDiskOverhead, 0)]
1859

    
1860
dssParameterTypes :: Map String VType
1861
dssParameterTypes =
1862
  Map.fromList [(dsDiskTotal, VTypeInt),
1863
                (dsDiskReserved, VTypeInt),
1864
                (dsDiskOverhead, VTypeInt)]
1865

    
1866
dssParameters :: FrozenSet String
1867
dssParameters =
1868
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1869

    
1870
dsValidTypes :: FrozenSet String
1871
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1872

    
1873
-- Backend parameter names
1874

    
1875
beAlwaysFailover :: String
1876
beAlwaysFailover = "always_failover"
1877

    
1878
beAutoBalance :: String
1879
beAutoBalance = "auto_balance"
1880

    
1881
beMaxmem :: String
1882
beMaxmem = "maxmem"
1883

    
1884
-- | Deprecated and replaced by max and min mem
1885
beMemory :: String
1886
beMemory = "memory"
1887

    
1888
beMinmem :: String
1889
beMinmem = "minmem"
1890

    
1891
beSpindleUse :: String
1892
beSpindleUse = "spindle_use"
1893

    
1894
beVcpus :: String
1895
beVcpus = "vcpus"
1896

    
1897
besParameterTypes :: Map String VType
1898
besParameterTypes =
1899
  Map.fromList [(beAlwaysFailover, VTypeBool),
1900
                (beAutoBalance, VTypeBool),
1901
                (beMaxmem, VTypeSize),
1902
                (beMinmem, VTypeSize),
1903
                (beSpindleUse, VTypeInt),
1904
                (beVcpus, VTypeInt)]
1905

    
1906
besParameterTitles :: Map String String
1907
besParameterTitles =
1908
  Map.fromList [(beAutoBalance, "Auto_balance"),
1909
                (beMinmem, "ConfigMinMem"),
1910
                (beVcpus, "ConfigVCPUs"),
1911
                (beMaxmem, "ConfigMaxMem")]
1912

    
1913
besParameterCompat :: Map String VType
1914
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1915

    
1916
besParameters :: FrozenSet String
1917
besParameters =
1918
  ConstantUtils.mkSet [beAlwaysFailover,
1919
                       beAutoBalance,
1920
                       beMaxmem,
1921
                       beMinmem,
1922
                       beSpindleUse,
1923
                       beVcpus]
1924

    
1925
-- | Instance specs
1926
--
1927
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1928

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

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

    
1935
ispecDiskCount :: String
1936
ispecDiskCount = ConstantUtils.ispecDiskCount
1937

    
1938
ispecDiskSize :: String
1939
ispecDiskSize = ConstantUtils.ispecDiskSize
1940

    
1941
ispecNicCount :: String
1942
ispecNicCount = ConstantUtils.ispecNicCount
1943

    
1944
ispecSpindleUse :: String
1945
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1946

    
1947
ispecsParameterTypes :: Map String VType
1948
ispecsParameterTypes =
1949
  Map.fromList
1950
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1951
   (ConstantUtils.ispecCpuCount, VTypeInt),
1952
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1953
   (ConstantUtils.ispecMemSize, VTypeInt),
1954
   (ConstantUtils.ispecNicCount, VTypeInt),
1955
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1956

    
1957
ispecsParameters :: FrozenSet String
1958
ispecsParameters =
1959
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1960
                       ConstantUtils.ispecDiskCount,
1961
                       ConstantUtils.ispecDiskSize,
1962
                       ConstantUtils.ispecMemSize,
1963
                       ConstantUtils.ispecNicCount,
1964
                       ConstantUtils.ispecSpindleUse]
1965

    
1966
ispecsMinmax :: String
1967
ispecsMinmax = ConstantUtils.ispecsMinmax
1968

    
1969
ispecsMax :: String
1970
ispecsMax = "max"
1971

    
1972
ispecsMin :: String
1973
ispecsMin = "min"
1974

    
1975
ispecsStd :: String
1976
ispecsStd = ConstantUtils.ispecsStd
1977

    
1978
ipolicyDts :: String
1979
ipolicyDts = ConstantUtils.ipolicyDts
1980

    
1981
ipolicyVcpuRatio :: String
1982
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1983

    
1984
ipolicySpindleRatio :: String
1985
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
1986

    
1987
ispecsMinmaxKeys :: FrozenSet String
1988
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1989

    
1990
ipolicyParameters :: FrozenSet String
1991
ipolicyParameters =
1992
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1993
                       ConstantUtils.ipolicySpindleRatio]
1994

    
1995
ipolicyAllKeys :: FrozenSet String
1996
ipolicyAllKeys =
1997
  ConstantUtils.union ipolicyParameters $
1998
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1999
                       ConstantUtils.ispecsMinmax,
2000
                       ispecsStd]
2001

    
2002
-- | Node parameter names
2003

    
2004
ndExclusiveStorage :: String
2005
ndExclusiveStorage = "exclusive_storage"
2006

    
2007
ndOobProgram :: String
2008
ndOobProgram = "oob_program"
2009

    
2010
ndSpindleCount :: String
2011
ndSpindleCount = "spindle_count"
2012

    
2013
ndOvs :: String
2014
ndOvs = "ovs"
2015

    
2016
ndOvsLink :: String
2017
ndOvsLink = "ovs_link"
2018

    
2019
ndOvsName :: String
2020
ndOvsName = "ovs_name"
2021

    
2022
ndSshPort :: String
2023
ndSshPort = "ssh_port"
2024

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

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

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

    
2049
-- * Logical Disks parameters
2050

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2206
diskDtParameters :: FrozenSet String
2207
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2208

    
2209
-- * Dynamic disk parameters
2210

    
2211
ddpLocalIp :: String
2212
ddpLocalIp = "local-ip"
2213

    
2214
ddpRemoteIp :: String
2215
ddpRemoteIp = "remote-ip"
2216

    
2217
ddpPort :: String
2218
ddpPort = "port"
2219

    
2220
ddpLocalMinor :: String
2221
ddpLocalMinor = "local-minor"
2222

    
2223
ddpRemoteMinor :: String
2224
ddpRemoteMinor = "remote-minor"
2225

    
2226
-- * OOB supported commands
2227

    
2228
oobPowerOn :: String
2229
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2230

    
2231
oobPowerOff :: String
2232
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2233

    
2234
oobPowerCycle :: String
2235
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2236

    
2237
oobPowerStatus :: String
2238
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2239

    
2240
oobHealth :: String
2241
oobHealth = Types.oobCommandToRaw OobHealth
2242

    
2243
oobCommands :: FrozenSet String
2244
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2245

    
2246
oobPowerStatusPowered :: String
2247
oobPowerStatusPowered = "powered"
2248

    
2249
-- | 60 seconds
2250
oobTimeout :: Int
2251
oobTimeout = 60
2252

    
2253
-- | 2 seconds
2254
oobPowerDelay :: Double
2255
oobPowerDelay = 2.0
2256

    
2257
oobStatusCritical :: String
2258
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2259

    
2260
oobStatusOk :: String
2261
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2262

    
2263
oobStatusUnknown :: String
2264
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2265

    
2266
oobStatusWarning :: String
2267
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2268

    
2269
oobStatuses :: FrozenSet String
2270
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2271

    
2272
-- | Instance Parameters Profile
2273
ppDefault :: String
2274
ppDefault = "default"
2275

    
2276
-- * nic* constants are used inside the ganeti config
2277

    
2278
nicLink :: String
2279
nicLink = "link"
2280

    
2281
nicMode :: String
2282
nicMode = "mode"
2283

    
2284
nicVlan :: String
2285
nicVlan = "vlan"
2286

    
2287
nicsParameterTypes :: Map String VType
2288
nicsParameterTypes =
2289
  Map.fromList [(nicMode, vtypeString),
2290
                (nicLink, vtypeString),
2291
                (nicVlan, vtypeString)]
2292

    
2293
nicsParameters :: FrozenSet String
2294
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2295

    
2296
nicModeBridged :: String
2297
nicModeBridged = Types.nICModeToRaw NMBridged
2298

    
2299
nicModeRouted :: String
2300
nicModeRouted = Types.nICModeToRaw NMRouted
2301

    
2302
nicModeOvs :: String
2303
nicModeOvs = Types.nICModeToRaw NMOvs
2304

    
2305
nicIpPool :: String
2306
nicIpPool = Types.nICModeToRaw NMPool
2307

    
2308
nicValidModes :: FrozenSet String
2309
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2310

    
2311
releaseAction :: String
2312
releaseAction = "release"
2313

    
2314
reserveAction :: String
2315
reserveAction = "reserve"
2316

    
2317
-- * idisk* constants are used in opcodes, to create/change disks
2318

    
2319
idiskAdopt :: String
2320
idiskAdopt = "adopt"
2321

    
2322
idiskMetavg :: String
2323
idiskMetavg = "metavg"
2324

    
2325
idiskMode :: String
2326
idiskMode = "mode"
2327

    
2328
idiskName :: String
2329
idiskName = "name"
2330

    
2331
idiskSize :: String
2332
idiskSize = "size"
2333

    
2334
idiskSpindles :: String
2335
idiskSpindles = "spindles"
2336

    
2337
idiskVg :: String
2338
idiskVg = "vg"
2339

    
2340
idiskProvider :: String
2341
idiskProvider = "provider"
2342

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2406
-- * Hypervisor constants
2407

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

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

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

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

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

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

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

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

    
2432
vncBasePort :: Int
2433
vncBasePort = 5900
2434

    
2435
vncDefaultBindAddress :: String
2436
vncDefaultBindAddress = ip4AddressAny
2437

    
2438
-- * NIC types
2439

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

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

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

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

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

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

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

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

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

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

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

    
2487
-- * Vif types
2488

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

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

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

    
2499
-- * Disk types
2500

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2553
-- * Mouse types
2554

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

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

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

    
2564
-- * Boot order
2565

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

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

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

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

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

    
2582
-- * SPICE lossless image compression options
2583

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

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

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

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

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

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

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

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

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

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

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

    
2626
-- * SPICE video stream detection
2627

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

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

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

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

    
2643
-- * Security models
2644

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

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

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

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

    
2657
-- * Kvm flag values
2658

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

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

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

    
2668
-- * Migration type
2669

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

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

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

    
2680
-- * Cluster verify steps
2681

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

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

    
2689
-- * Cluster Verify error classes
2690

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

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

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

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

    
2703
-- * Cluster Verify error levels
2704

    
2705
cvWarning :: String
2706
cvWarning = "WARNING"
2707

    
2708
cvError :: String
2709
cvError = "ERROR"
2710

    
2711
-- * Cluster Verify error codes and documentation
2712

    
2713
cvEclustercert :: (String, String, String)
2714
cvEclustercert =
2715
  ("cluster",
2716
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2717
   "Cluster certificate files verification failure")
2718

    
2719
cvEclusterclientcert :: (String, String, String)
2720
cvEclusterclientcert =
2721
  ("cluster",
2722
   Types.cVErrorCodeToRaw CvECLUSTERCLIENTCERT,
2723
   "Cluster client certificate files verification failure")
2724

    
2725
cvEclustercfg :: (String, String, String)
2726
cvEclustercfg =
2727
  ("cluster",
2728
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2729
   "Cluster configuration verification failure")
2730

    
2731
cvEclusterdanglinginst :: (String, String, String)
2732
cvEclusterdanglinginst =
2733
  ("node",
2734
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2735
   "Some instances have a non-existing primary node")
2736

    
2737
cvEclusterdanglingnodes :: (String, String, String)
2738
cvEclusterdanglingnodes =
2739
  ("node",
2740
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2741
   "Some nodes belong to non-existing groups")
2742

    
2743
cvEclusterfilecheck :: (String, String, String)
2744
cvEclusterfilecheck =
2745
  ("cluster",
2746
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2747
   "Cluster configuration verification failure")
2748

    
2749
cvEgroupdifferentpvsize :: (String, String, String)
2750
cvEgroupdifferentpvsize =
2751
  ("group",
2752
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2753
   "PVs in the group have different sizes")
2754

    
2755
cvEinstancebadnode :: (String, String, String)
2756
cvEinstancebadnode =
2757
  ("instance",
2758
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2759
   "Instance marked as running lives on an offline node")
2760

    
2761
cvEinstancedown :: (String, String, String)
2762
cvEinstancedown =
2763
  ("instance",
2764
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2765
   "Instance not running on its primary node")
2766

    
2767
cvEinstancefaultydisk :: (String, String, String)
2768
cvEinstancefaultydisk =
2769
  ("instance",
2770
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2771
   "Impossible to retrieve status for a disk")
2772

    
2773
cvEinstancelayout :: (String, String, String)
2774
cvEinstancelayout =
2775
  ("instance",
2776
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2777
   "Instance has multiple secondary nodes")
2778

    
2779
cvEinstancemissingcfgparameter :: (String, String, String)
2780
cvEinstancemissingcfgparameter =
2781
  ("instance",
2782
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2783
   "A configuration parameter for an instance is missing")
2784

    
2785
cvEinstancemissingdisk :: (String, String, String)
2786
cvEinstancemissingdisk =
2787
  ("instance",
2788
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2789
   "Missing volume on an instance")
2790

    
2791
cvEinstancepolicy :: (String, String, String)
2792
cvEinstancepolicy =
2793
  ("instance",
2794
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2795
   "Instance does not meet policy")
2796

    
2797
cvEinstancesplitgroups :: (String, String, String)
2798
cvEinstancesplitgroups =
2799
  ("instance",
2800
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2801
   "Instance with primary and secondary nodes in different groups")
2802

    
2803
cvEinstanceunsuitablenode :: (String, String, String)
2804
cvEinstanceunsuitablenode =
2805
  ("instance",
2806
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2807
   "Instance running on nodes that are not suitable for it")
2808

    
2809
cvEinstancewrongnode :: (String, String, String)
2810
cvEinstancewrongnode =
2811
  ("instance",
2812
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2813
   "Instance running on the wrong node")
2814

    
2815
cvEnodedrbd :: (String, String, String)
2816
cvEnodedrbd =
2817
  ("node",
2818
   Types.cVErrorCodeToRaw CvENODEDRBD,
2819
   "Error parsing the DRBD status file")
2820

    
2821
cvEnodedrbdhelper :: (String, String, String)
2822
cvEnodedrbdhelper =
2823
  ("node",
2824
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2825
   "Error caused by the DRBD helper")
2826

    
2827
cvEnodedrbdversion :: (String, String, String)
2828
cvEnodedrbdversion =
2829
  ("node",
2830
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2831
   "DRBD version mismatch within a node group")
2832

    
2833
cvEnodefilecheck :: (String, String, String)
2834
cvEnodefilecheck =
2835
  ("node",
2836
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2837
   "Error retrieving the checksum of the node files")
2838

    
2839
cvEnodefilestoragepaths :: (String, String, String)
2840
cvEnodefilestoragepaths =
2841
  ("node",
2842
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2843
   "Detected bad file storage paths")
2844

    
2845
cvEnodefilestoragepathunusable :: (String, String, String)
2846
cvEnodefilestoragepathunusable =
2847
  ("node",
2848
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2849
   "File storage path unusable")
2850

    
2851
cvEnodehooks :: (String, String, String)
2852
cvEnodehooks =
2853
  ("node",
2854
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2855
   "Communication failure in hooks execution")
2856

    
2857
cvEnodehv :: (String, String, String)
2858
cvEnodehv =
2859
  ("node",
2860
   Types.cVErrorCodeToRaw CvENODEHV,
2861
   "Hypervisor parameters verification failure")
2862

    
2863
cvEnodelvm :: (String, String, String)
2864
cvEnodelvm =
2865
  ("node",
2866
   Types.cVErrorCodeToRaw CvENODELVM,
2867
   "LVM-related node error")
2868

    
2869
cvEnoden1 :: (String, String, String)
2870
cvEnoden1 =
2871
  ("node",
2872
   Types.cVErrorCodeToRaw CvENODEN1,
2873
   "Not enough memory to accommodate instance failovers")
2874

    
2875
cvEnodenet :: (String, String, String)
2876
cvEnodenet =
2877
  ("node",
2878
   Types.cVErrorCodeToRaw CvENODENET,
2879
   "Network-related node error")
2880

    
2881
cvEnodeoobpath :: (String, String, String)
2882
cvEnodeoobpath =
2883
  ("node",
2884
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2885
   "Invalid Out Of Band path")
2886

    
2887
cvEnodeorphaninstance :: (String, String, String)
2888
cvEnodeorphaninstance =
2889
  ("node",
2890
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2891
   "Unknown intance running on a node")
2892

    
2893
cvEnodeorphanlv :: (String, String, String)
2894
cvEnodeorphanlv =
2895
  ("node",
2896
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2897
   "Unknown LVM logical volume")
2898

    
2899
cvEnodeos :: (String, String, String)
2900
cvEnodeos =
2901
  ("node",
2902
   Types.cVErrorCodeToRaw CvENODEOS,
2903
   "OS-related node error")
2904

    
2905
cvEnoderpc :: (String, String, String)
2906
cvEnoderpc =
2907
  ("node",
2908
   Types.cVErrorCodeToRaw CvENODERPC,
2909
   "Error during connection to the primary node of an instance")
2910

    
2911
cvEnodesetup :: (String, String, String)
2912
cvEnodesetup =
2913
  ("node",
2914
   Types.cVErrorCodeToRaw CvENODESETUP,
2915
   "Node setup error")
2916

    
2917
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2918
cvEnodesharedfilestoragepathunusable =
2919
  ("node",
2920
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2921
   "Shared file storage path unusable")
2922

    
2923
cvEnodessh :: (String, String, String)
2924
cvEnodessh =
2925
  ("node",
2926
   Types.cVErrorCodeToRaw CvENODESSH,
2927
   "SSH-related node error")
2928

    
2929
cvEnodetime :: (String, String, String)
2930
cvEnodetime =
2931
  ("node",
2932
   Types.cVErrorCodeToRaw CvENODETIME,
2933
   "Node returned invalid time")
2934

    
2935
cvEnodeuserscripts :: (String, String, String)
2936
cvEnodeuserscripts =
2937
  ("node",
2938
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2939
   "User scripts not present or not executable")
2940

    
2941
cvEnodeversion :: (String, String, String)
2942
cvEnodeversion =
2943
  ("node",
2944
   Types.cVErrorCodeToRaw CvENODEVERSION,
2945
   "Protocol version mismatch or Ganeti version mismatch")
2946

    
2947
cvAllEcodes :: FrozenSet (String, String, String)
2948
cvAllEcodes =
2949
  ConstantUtils.mkSet
2950
  [cvEclustercert,
2951
   cvEclustercfg,
2952
   cvEclusterdanglinginst,
2953
   cvEclusterdanglingnodes,
2954
   cvEclusterfilecheck,
2955
   cvEgroupdifferentpvsize,
2956
   cvEinstancebadnode,
2957
   cvEinstancedown,
2958
   cvEinstancefaultydisk,
2959
   cvEinstancelayout,
2960
   cvEinstancemissingcfgparameter,
2961
   cvEinstancemissingdisk,
2962
   cvEinstancepolicy,
2963
   cvEinstancesplitgroups,
2964
   cvEinstanceunsuitablenode,
2965
   cvEinstancewrongnode,
2966
   cvEnodedrbd,
2967
   cvEnodedrbdhelper,
2968
   cvEnodedrbdversion,
2969
   cvEnodefilecheck,
2970
   cvEnodefilestoragepaths,
2971
   cvEnodefilestoragepathunusable,
2972
   cvEnodehooks,
2973
   cvEnodehv,
2974
   cvEnodelvm,
2975
   cvEnoden1,
2976
   cvEnodenet,
2977
   cvEnodeoobpath,
2978
   cvEnodeorphaninstance,
2979
   cvEnodeorphanlv,
2980
   cvEnodeos,
2981
   cvEnoderpc,
2982
   cvEnodesetup,
2983
   cvEnodesharedfilestoragepathunusable,
2984
   cvEnodessh,
2985
   cvEnodetime,
2986
   cvEnodeuserscripts,
2987
   cvEnodeversion]
2988

    
2989
cvAllEcodesStrings :: FrozenSet String
2990
cvAllEcodesStrings =
2991
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2992

    
2993
-- * Node verify constants
2994

    
2995
nvBridges :: String
2996
nvBridges = "bridges"
2997

    
2998
nvClientCert :: String
2999
nvClientCert = "client-cert"
3000

    
3001
nvDrbdhelper :: String
3002
nvDrbdhelper = "drbd-helper"
3003

    
3004
nvDrbdversion :: String
3005
nvDrbdversion = "drbd-version"
3006

    
3007
nvDrbdlist :: String
3008
nvDrbdlist = "drbd-list"
3009

    
3010
nvExclusivepvs :: String
3011
nvExclusivepvs = "exclusive-pvs"
3012

    
3013
nvFilelist :: String
3014
nvFilelist = "filelist"
3015

    
3016
nvAcceptedStoragePaths :: String
3017
nvAcceptedStoragePaths = "allowed-file-storage-paths"
3018

    
3019
nvFileStoragePath :: String
3020
nvFileStoragePath = "file-storage-path"
3021

    
3022
nvSharedFileStoragePath :: String
3023
nvSharedFileStoragePath = "shared-file-storage-path"
3024

    
3025
nvHvinfo :: String
3026
nvHvinfo = "hvinfo"
3027

    
3028
nvHvparams :: String
3029
nvHvparams = "hvparms"
3030

    
3031
nvHypervisor :: String
3032
nvHypervisor = "hypervisor"
3033

    
3034
nvInstancelist :: String
3035
nvInstancelist = "instancelist"
3036

    
3037
nvLvlist :: String
3038
nvLvlist = "lvlist"
3039

    
3040
nvMasterip :: String
3041
nvMasterip = "master-ip"
3042

    
3043
nvNodelist :: String
3044
nvNodelist = "nodelist"
3045

    
3046
nvNodenettest :: String
3047
nvNodenettest = "node-net-test"
3048

    
3049
nvNodesetup :: String
3050
nvNodesetup = "nodesetup"
3051

    
3052
nvOobPaths :: String
3053
nvOobPaths = "oob-paths"
3054

    
3055
nvOslist :: String
3056
nvOslist = "oslist"
3057

    
3058
nvPvlist :: String
3059
nvPvlist = "pvlist"
3060

    
3061
nvTime :: String
3062
nvTime = "time"
3063

    
3064
nvUserscripts :: String
3065
nvUserscripts = "user-scripts"
3066

    
3067
nvVersion :: String
3068
nvVersion = "version"
3069

    
3070
nvVglist :: String
3071
nvVglist = "vglist"
3072

    
3073
nvVmnodes :: String
3074
nvVmnodes = "vmnodes"
3075

    
3076
-- * Instance status
3077

    
3078
inststAdmindown :: String
3079
inststAdmindown = Types.instanceStatusToRaw StatusDown
3080

    
3081
inststAdminoffline :: String
3082
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3083

    
3084
inststErrordown :: String
3085
inststErrordown = Types.instanceStatusToRaw ErrorDown
3086

    
3087
inststErrorup :: String
3088
inststErrorup = Types.instanceStatusToRaw ErrorUp
3089

    
3090
inststNodedown :: String
3091
inststNodedown = Types.instanceStatusToRaw NodeDown
3092

    
3093
inststNodeoffline :: String
3094
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3095

    
3096
inststRunning :: String
3097
inststRunning = Types.instanceStatusToRaw Running
3098

    
3099
inststUserdown :: String
3100
inststUserdown = Types.instanceStatusToRaw UserDown
3101

    
3102
inststWrongnode :: String
3103
inststWrongnode = Types.instanceStatusToRaw WrongNode
3104

    
3105
inststAll :: FrozenSet String
3106
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3107

    
3108
-- * Admin states
3109

    
3110
adminstDown :: String
3111
adminstDown = Types.adminStateToRaw AdminDown
3112

    
3113
adminstOffline :: String
3114
adminstOffline = Types.adminStateToRaw AdminOffline
3115

    
3116
adminstUp :: String
3117
adminstUp = Types.adminStateToRaw AdminUp
3118

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

    
3122
-- * Node roles
3123

    
3124
nrDrained :: String
3125
nrDrained = Types.nodeRoleToRaw NRDrained
3126

    
3127
nrMaster :: String
3128
nrMaster = Types.nodeRoleToRaw NRMaster
3129

    
3130
nrMcandidate :: String
3131
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3132

    
3133
nrOffline :: String
3134
nrOffline = Types.nodeRoleToRaw NROffline
3135

    
3136
nrRegular :: String
3137
nrRegular = Types.nodeRoleToRaw NRRegular
3138

    
3139
nrAll :: FrozenSet String
3140
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3141

    
3142
-- * SSL certificate check constants (in days)
3143

    
3144
sslCertExpirationError :: Int
3145
sslCertExpirationError = 7
3146

    
3147
sslCertExpirationWarn :: Int
3148
sslCertExpirationWarn = 30
3149

    
3150
-- * Allocator framework constants
3151

    
3152
iallocatorVersion :: Int
3153
iallocatorVersion = 2
3154

    
3155
iallocatorDirIn :: String
3156
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3157

    
3158
iallocatorDirOut :: String
3159
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3160

    
3161
validIallocatorDirections :: FrozenSet String
3162
validIallocatorDirections =
3163
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3164

    
3165
iallocatorModeAlloc :: String
3166
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3167

    
3168
iallocatorModeChgGroup :: String
3169
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3170

    
3171
iallocatorModeMultiAlloc :: String
3172
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3173

    
3174
iallocatorModeNodeEvac :: String
3175
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3176

    
3177
iallocatorModeReloc :: String
3178
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3179

    
3180
validIallocatorModes :: FrozenSet String
3181
validIallocatorModes =
3182
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3183

    
3184
iallocatorSearchPath :: [String]
3185
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3186

    
3187
defaultIallocatorShortcut :: String
3188
defaultIallocatorShortcut = "."
3189

    
3190
-- * Node evacuation
3191

    
3192
nodeEvacPri :: String
3193
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3194

    
3195
nodeEvacSec :: String
3196
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3197

    
3198
nodeEvacAll :: String
3199
nodeEvacAll = Types.evacModeToRaw ChangeAll
3200

    
3201
nodeEvacModes :: FrozenSet String
3202
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3203

    
3204
-- * Job queue
3205

    
3206
jobQueueVersion :: Int
3207
jobQueueVersion = 1
3208

    
3209
jobQueueSizeHardLimit :: Int
3210
jobQueueSizeHardLimit = 5000
3211

    
3212
jobQueueFilesPerms :: Int
3213
jobQueueFilesPerms = 0o640
3214

    
3215
-- * Unchanged job return
3216

    
3217
jobNotchanged :: String
3218
jobNotchanged = "nochange"
3219

    
3220
-- * Job status
3221

    
3222
jobStatusQueued :: String
3223
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3224

    
3225
jobStatusWaiting :: String
3226
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3227

    
3228
jobStatusCanceling :: String
3229
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3230

    
3231
jobStatusRunning :: String
3232
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3233

    
3234
jobStatusCanceled :: String
3235
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3236

    
3237
jobStatusSuccess :: String
3238
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3239

    
3240
jobStatusError :: String
3241
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3242

    
3243
jobsPending :: FrozenSet String
3244
jobsPending =
3245
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3246

    
3247
jobsFinalized :: FrozenSet String
3248
jobsFinalized =
3249
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3250

    
3251
jobStatusAll :: FrozenSet String
3252
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3253

    
3254
-- * OpCode status
3255

    
3256
-- ** Not yet finalized opcodes
3257

    
3258
opStatusCanceling :: String
3259
opStatusCanceling = "canceling"
3260

    
3261
opStatusQueued :: String
3262
opStatusQueued = "queued"
3263

    
3264
opStatusRunning :: String
3265
opStatusRunning = "running"
3266

    
3267
opStatusWaiting :: String
3268
opStatusWaiting = "waiting"
3269

    
3270
-- ** Finalized opcodes
3271

    
3272
opStatusCanceled :: String
3273
opStatusCanceled = "canceled"
3274

    
3275
opStatusError :: String
3276
opStatusError = "error"
3277

    
3278
opStatusSuccess :: String
3279
opStatusSuccess = "success"
3280

    
3281
opsFinalized :: FrozenSet String
3282
opsFinalized =
3283
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3284

    
3285
-- * OpCode priority
3286

    
3287
opPrioLowest :: Int
3288
opPrioLowest = 19
3289

    
3290
opPrioHighest :: Int
3291
opPrioHighest = -20
3292

    
3293
opPrioLow :: Int
3294
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3295

    
3296
opPrioNormal :: Int
3297
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3298

    
3299
opPrioHigh :: Int
3300
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3301

    
3302
opPrioSubmitValid :: FrozenSet Int
3303
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3304

    
3305
opPrioDefault :: Int
3306
opPrioDefault = opPrioNormal
3307

    
3308
-- * Lock recalculate mode
3309

    
3310
locksAppend :: String
3311
locksAppend = "append"
3312

    
3313
locksReplace :: String
3314
locksReplace = "replace"
3315

    
3316
-- * Lock timeout
3317
--
3318
-- The lock timeout (sum) before we transition into blocking acquire
3319
-- (this can still be reset by priority change).  Computed as max time
3320
-- (10 hours) before we should actually go into blocking acquire,
3321
-- given that we start from the default priority level.
3322

    
3323
lockAttemptsMaxwait :: Double
3324
lockAttemptsMaxwait = 15.0
3325

    
3326
lockAttemptsMinwait :: Double
3327
lockAttemptsMinwait = 1.0
3328

    
3329
lockAttemptsTimeout :: Int
3330
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3331

    
3332
-- * Execution log types
3333

    
3334
elogMessage :: String
3335
elogMessage = Types.eLogTypeToRaw ELogMessage
3336

    
3337
elogRemoteImport :: String
3338
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3339

    
3340
elogJqueueTest :: String
3341
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3342

    
3343
-- * /etc/hosts modification
3344

    
3345
etcHostsAdd :: String
3346
etcHostsAdd = "add"
3347

    
3348
etcHostsRemove :: String
3349
etcHostsRemove = "remove"
3350

    
3351
-- * Job queue test
3352

    
3353
jqtMsgprefix :: String
3354
jqtMsgprefix = "TESTMSG="
3355

    
3356
jqtExec :: String
3357
jqtExec = "exec"
3358

    
3359
jqtExpandnames :: String
3360
jqtExpandnames = "expandnames"
3361

    
3362
jqtLogmsg :: String
3363
jqtLogmsg = "logmsg"
3364

    
3365
jqtStartmsg :: String
3366
jqtStartmsg = "startmsg"
3367

    
3368
jqtAll :: FrozenSet String
3369
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3370

    
3371
-- * Query resources
3372

    
3373
qrCluster :: String
3374
qrCluster = "cluster"
3375

    
3376
qrExport :: String
3377
qrExport = "export"
3378

    
3379
qrExtstorage :: String
3380
qrExtstorage = "extstorage"
3381

    
3382
qrGroup :: String
3383
qrGroup = "group"
3384

    
3385
qrInstance :: String
3386
qrInstance = "instance"
3387

    
3388
qrJob :: String
3389
qrJob = "job"
3390

    
3391
qrLock :: String
3392
qrLock = "lock"
3393

    
3394
qrNetwork :: String
3395
qrNetwork = "network"
3396

    
3397
qrNode :: String
3398
qrNode = "node"
3399

    
3400
qrOs :: String
3401
qrOs = "os"
3402

    
3403
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3404
qrViaOp :: FrozenSet String
3405
qrViaOp =
3406
  ConstantUtils.mkSet [qrCluster,
3407
                       qrOs,
3408
                       qrExtstorage]
3409

    
3410
-- | List of resources which can be queried using Local UniX Interface
3411
qrViaLuxi :: FrozenSet String
3412
qrViaLuxi = ConstantUtils.mkSet [qrGroup,
3413
                                 qrExport,
3414
                                 qrInstance,
3415
                                 qrJob,
3416
                                 qrLock,
3417
                                 qrNetwork,
3418
                                 qrNode]
3419

    
3420
-- | List of resources which can be queried using RAPI
3421
qrViaRapi :: FrozenSet String
3422
qrViaRapi = qrViaLuxi
3423

    
3424
-- | List of resources which can be queried via RAPI including PUT requests
3425
qrViaRapiPut :: FrozenSet String
3426
qrViaRapiPut = ConstantUtils.mkSet [qrLock, qrJob]
3427

    
3428
-- * Query field types
3429

    
3430
qftBool :: String
3431
qftBool = "bool"
3432

    
3433
qftNumber :: String
3434
qftNumber = "number"
3435

    
3436
qftOther :: String
3437
qftOther = "other"
3438

    
3439
qftText :: String
3440
qftText = "text"
3441

    
3442
qftTimestamp :: String
3443
qftTimestamp = "timestamp"
3444

    
3445
qftUnit :: String
3446
qftUnit = "unit"
3447

    
3448
qftUnknown :: String
3449
qftUnknown = "unknown"
3450

    
3451
qftAll :: FrozenSet String
3452
qftAll =
3453
  ConstantUtils.mkSet [qftBool,
3454
                       qftNumber,
3455
                       qftOther,
3456
                       qftText,
3457
                       qftTimestamp,
3458
                       qftUnit,
3459
                       qftUnknown]
3460

    
3461
-- * Query result field status
3462
--
3463
-- Don't change or reuse values as they're used by clients.
3464
--
3465
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3466

    
3467
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3468
rsNodata :: Int
3469
rsNodata = 2
3470

    
3471
rsNormal :: Int
3472
rsNormal = 0
3473

    
3474
-- | Resource marked offline
3475
rsOffline :: Int
3476
rsOffline = 4
3477

    
3478
-- | Value unavailable/unsupported for item; if this field is
3479
-- supported but we cannot get the data for the moment, 'rsNodata' or
3480
-- 'rsOffline' should be used
3481
rsUnavail :: Int
3482
rsUnavail = 3
3483

    
3484
rsUnknown :: Int
3485
rsUnknown = 1
3486

    
3487
rsAll :: FrozenSet Int
3488
rsAll =
3489
  ConstantUtils.mkSet [rsNodata,
3490
                       rsNormal,
3491
                       rsOffline,
3492
                       rsUnavail,
3493
                       rsUnknown]
3494

    
3495
-- | Special field cases and their verbose/terse formatting
3496
rssDescription :: Map Int (String, String)
3497
rssDescription =
3498
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3499
                (rsNodata, ("(nodata)", "?")),
3500
                (rsOffline, ("(offline)", "*")),
3501
                (rsUnavail, ("(unavail)", "-"))]
3502

    
3503
-- * Max dynamic devices
3504

    
3505
maxDisks :: Int
3506
maxDisks = Types.maxDisks
3507

    
3508
maxNics :: Int
3509
maxNics = Types.maxNics
3510

    
3511
-- | SSCONF file prefix
3512
ssconfFileprefix :: String
3513
ssconfFileprefix = "ssconf_"
3514

    
3515
-- * SSCONF keys
3516

    
3517
ssClusterName :: String
3518
ssClusterName = "cluster_name"
3519

    
3520
ssClusterTags :: String
3521
ssClusterTags = "cluster_tags"
3522

    
3523
ssFileStorageDir :: String
3524
ssFileStorageDir = "file_storage_dir"
3525

    
3526
ssSharedFileStorageDir :: String
3527
ssSharedFileStorageDir = "shared_file_storage_dir"
3528

    
3529
ssGlusterStorageDir :: String
3530
ssGlusterStorageDir = "gluster_storage_dir"
3531

    
3532
ssMasterCandidates :: String
3533
ssMasterCandidates = "master_candidates"
3534

    
3535
ssMasterCandidatesIps :: String
3536
ssMasterCandidatesIps = "master_candidates_ips"
3537

    
3538
ssMasterCandidatesCerts :: String
3539
ssMasterCandidatesCerts = "master_candidates_certs"
3540

    
3541
ssMasterIp :: String
3542
ssMasterIp = "master_ip"
3543

    
3544
ssMasterNetdev :: String
3545
ssMasterNetdev = "master_netdev"
3546

    
3547
ssMasterNetmask :: String
3548
ssMasterNetmask = "master_netmask"
3549

    
3550
ssMasterNode :: String
3551
ssMasterNode = "master_node"
3552

    
3553
ssNodeList :: String
3554
ssNodeList = "node_list"
3555

    
3556
ssNodePrimaryIps :: String
3557
ssNodePrimaryIps = "node_primary_ips"
3558

    
3559
ssNodeSecondaryIps :: String
3560
ssNodeSecondaryIps = "node_secondary_ips"
3561

    
3562
ssOfflineNodes :: String
3563
ssOfflineNodes = "offline_nodes"
3564

    
3565
ssOnlineNodes :: String
3566
ssOnlineNodes = "online_nodes"
3567

    
3568
ssPrimaryIpFamily :: String
3569
ssPrimaryIpFamily = "primary_ip_family"
3570

    
3571
ssInstanceList :: String
3572
ssInstanceList = "instance_list"
3573

    
3574
ssReleaseVersion :: String
3575
ssReleaseVersion = "release_version"
3576

    
3577
ssHypervisorList :: String
3578
ssHypervisorList = "hypervisor_list"
3579

    
3580
ssMaintainNodeHealth :: String
3581
ssMaintainNodeHealth = "maintain_node_health"
3582

    
3583
ssUidPool :: String
3584
ssUidPool = "uid_pool"
3585

    
3586
ssNodegroups :: String
3587
ssNodegroups = "nodegroups"
3588

    
3589
ssNetworks :: String
3590
ssNetworks = "networks"
3591

    
3592
-- | This is not a complete SSCONF key, but the prefix for the
3593
-- hypervisor keys
3594
ssHvparamsPref :: String
3595
ssHvparamsPref = "hvparams_"
3596

    
3597
-- * Hvparams keys
3598

    
3599
ssHvparamsXenChroot :: String
3600
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3601

    
3602
ssHvparamsXenFake :: String
3603
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3604

    
3605
ssHvparamsXenHvm :: String
3606
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3607

    
3608
ssHvparamsXenKvm :: String
3609
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3610

    
3611
ssHvparamsXenLxc :: String
3612
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3613

    
3614
ssHvparamsXenPvm :: String
3615
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3616

    
3617
validSsHvparamsKeys :: FrozenSet String
3618
validSsHvparamsKeys =
3619
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3620
                       ssHvparamsXenLxc,
3621
                       ssHvparamsXenFake,
3622
                       ssHvparamsXenHvm,
3623
                       ssHvparamsXenKvm,
3624
                       ssHvparamsXenPvm]
3625

    
3626
ssFilePerms :: Int
3627
ssFilePerms = 0o444
3628

    
3629
-- | Cluster wide default parameters
3630
defaultEnabledHypervisor :: String
3631
defaultEnabledHypervisor = htXenPvm
3632

    
3633
hvcDefaults :: Map Hypervisor (Map String PyValueEx)
3634
hvcDefaults =
3635
  Map.fromList
3636
  [ (XenPvm, Map.fromList
3637
             [ (hvUseBootloader,  PyValueEx False)
3638
             , (hvBootloaderPath, PyValueEx xenBootloader)
3639
             , (hvBootloaderArgs, PyValueEx "")
3640
             , (hvKernelPath,     PyValueEx xenKernel)
3641
             , (hvInitrdPath,     PyValueEx "")
3642
             , (hvRootPath,       PyValueEx "/dev/xvda1")
3643
             , (hvKernelArgs,     PyValueEx "ro")
3644
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3645
             , (hvMigrationMode,  PyValueEx htMigrationLive)
3646
             , (hvBlockdevPrefix, PyValueEx "sd")
3647
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3648
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3649
             , (hvCpuCap,         PyValueEx (0 :: Int))
3650
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3651
             , (hvVifScript,      PyValueEx "")
3652
             , (hvXenCmd,         PyValueEx xenCmdXm)
3653
             , (hvXenCpuid,       PyValueEx "")
3654
             , (hvSoundhw,        PyValueEx "")
3655
             ])
3656
  , (XenHvm, Map.fromList
3657
             [ (hvBootOrder,      PyValueEx "cd")
3658
             , (hvCdromImagePath, PyValueEx "")
3659
             , (hvNicType,        PyValueEx htNicRtl8139)
3660
             , (hvDiskType,       PyValueEx htDiskParavirtual)
3661
             , (hvVncBindAddress, PyValueEx ip4AddressAny)
3662
             , (hvAcpi,           PyValueEx True)
3663
             , (hvPae,            PyValueEx True)
3664
             , (hvKernelPath,     PyValueEx "/usr/lib/xen/boot/hvmloader")
3665
             , (hvDeviceModel,    PyValueEx "/usr/lib/xen/bin/qemu-dm")
3666
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3667
             , (hvMigrationMode,  PyValueEx htMigrationNonlive)
3668
             , (hvUseLocaltime,   PyValueEx False)
3669
             , (hvBlockdevPrefix, PyValueEx "hd")
3670
             , (hvPassthrough,    PyValueEx "")
3671
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3672
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3673
             , (hvCpuCap,         PyValueEx (0 :: Int))
3674
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3675
             , (hvVifType,        PyValueEx htHvmVifIoemu)
3676
             , (hvVifScript,      PyValueEx "")
3677
             , (hvViridian,       PyValueEx False)
3678
             , (hvXenCmd,         PyValueEx xenCmdXm)
3679
             , (hvXenCpuid,       PyValueEx "")
3680
             , (hvSoundhw,        PyValueEx "")
3681
             ])
3682
  , (Kvm, Map.fromList
3683
          [ (hvKvmPath,                         PyValueEx kvmPath)
3684
          , (hvKernelPath,                      PyValueEx kvmKernel)
3685
          , (hvInitrdPath,                      PyValueEx "")
3686
          , (hvKernelArgs,                      PyValueEx "ro")
3687
          , (hvRootPath,                        PyValueEx "/dev/vda1")
3688
          , (hvAcpi,                            PyValueEx True)
3689
          , (hvSerialConsole,                   PyValueEx True)
3690
          , (hvSerialSpeed,                     PyValueEx (38400 :: Int))
3691
          , (hvVncBindAddress,                  PyValueEx "")
3692
          , (hvVncTls,                          PyValueEx False)
3693
          , (hvVncX509,                         PyValueEx "")
3694
          , (hvVncX509Verify,                   PyValueEx False)
3695
          , (hvVncPasswordFile,                 PyValueEx "")
3696
          , (hvKvmSpiceBind,                    PyValueEx "")
3697
          , (hvKvmSpiceIpVersion,           PyValueEx ifaceNoIpVersionSpecified)
3698
          , (hvKvmSpicePasswordFile,            PyValueEx "")
3699
          , (hvKvmSpiceLosslessImgCompr,        PyValueEx "")
3700
          , (hvKvmSpiceJpegImgCompr,            PyValueEx "")
3701
          , (hvKvmSpiceZlibGlzImgCompr,         PyValueEx "")
3702
          , (hvKvmSpiceStreamingVideoDetection, PyValueEx "")
3703
          , (hvKvmSpiceAudioCompr,              PyValueEx True)
3704
          , (hvKvmSpiceUseTls,                  PyValueEx False)
3705
          , (hvKvmSpiceTlsCiphers,              PyValueEx opensslCiphers)
3706
          , (hvKvmSpiceUseVdagent,              PyValueEx True)
3707
          , (hvKvmFloppyImagePath,              PyValueEx "")
3708
          , (hvCdromImagePath,                  PyValueEx "")
3709
          , (hvKvmCdrom2ImagePath,              PyValueEx "")
3710
          , (hvBootOrder,                       PyValueEx htBoDisk)
3711
          , (hvNicType,                         PyValueEx htNicParavirtual)
3712
          , (hvDiskType,                        PyValueEx htDiskParavirtual)
3713
          , (hvKvmCdromDiskType,                PyValueEx "")
3714
          , (hvUsbMouse,                        PyValueEx "")
3715
          , (hvKeymap,                          PyValueEx "")
3716
          , (hvMigrationPort,                   PyValueEx (8102 :: Int))
3717
          , (hvMigrationBandwidth,              PyValueEx (32 :: Int))
3718
          , (hvMigrationDowntime,               PyValueEx (30 :: Int))
3719
          , (hvMigrationMode,                   PyValueEx htMigrationLive)
3720
          , (hvUseLocaltime,                    PyValueEx False)
3721
          , (hvDiskCache,                       PyValueEx htCacheDefault)
3722
          , (hvSecurityModel,                   PyValueEx htSmNone)
3723
          , (hvSecurityDomain,                  PyValueEx "")
3724
          , (hvKvmFlag,                         PyValueEx "")
3725
          , (hvVhostNet,                        PyValueEx False)
3726
          , (hvKvmUseChroot,                    PyValueEx False)
3727
          , (hvKvmUserShutdown,                 PyValueEx False)
3728
          , (hvMemPath,                         PyValueEx "")
3729
          , (hvRebootBehavior,                  PyValueEx instanceRebootAllowed)
3730
          , (hvCpuMask,                         PyValueEx cpuPinningAll)
3731
          , (hvCpuType,                         PyValueEx "")
3732
          , (hvCpuCores,                        PyValueEx (0 :: Int))
3733
          , (hvCpuThreads,                      PyValueEx (0 :: Int))
3734
          , (hvCpuSockets,                      PyValueEx (0 :: Int))
3735
          , (hvSoundhw,                         PyValueEx "")
3736
          , (hvUsbDevices,                      PyValueEx "")
3737
          , (hvVga,                             PyValueEx "")
3738
          , (hvKvmExtra,                        PyValueEx "")
3739
          , (hvKvmMachineVersion,               PyValueEx "")
3740
          , (hvVnetHdr,                         PyValueEx True)])
3741
  , (Fake, Map.fromList [(hvMigrationMode, PyValueEx htMigrationLive)])
3742
  , (Chroot, Map.fromList [(hvInitScript, PyValueEx "/ganeti-chroot")])
3743
  , (Lxc, Map.fromList [(hvCpuMask, PyValueEx "")])
3744
  ]
3745

    
3746
hvcGlobals :: FrozenSet String
3747
hvcGlobals =
3748
  ConstantUtils.mkSet [hvMigrationBandwidth,
3749
                       hvMigrationMode,
3750
                       hvMigrationPort,
3751
                       hvXenCmd]
3752

    
3753
becDefaults :: Map String PyValueEx
3754
becDefaults =
3755
  Map.fromList
3756
  [ (beMinmem, PyValueEx (128 :: Int))
3757
  , (beMaxmem, PyValueEx (128 :: Int))
3758
  , (beVcpus, PyValueEx (1 :: Int))
3759
  , (beAutoBalance, PyValueEx True)
3760
  , (beAlwaysFailover, PyValueEx False)
3761
  , (beSpindleUse, PyValueEx (1 :: Int))
3762
  ]
3763

    
3764
ndcDefaults :: Map String PyValueEx
3765
ndcDefaults =
3766
  Map.fromList
3767
  [ (ndOobProgram,       PyValueEx "")
3768
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3769
  , (ndExclusiveStorage, PyValueEx False)
3770
  , (ndOvs,              PyValueEx False)
3771
  , (ndOvsName,          PyValueEx defaultOvs)
3772
  , (ndOvsLink,          PyValueEx "")
3773
  , (ndSshPort,          PyValueEx (22 :: Int))
3774
  ]
3775

    
3776
ndcGlobals :: FrozenSet String
3777
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3778

    
3779
-- | Default delay target measured in sectors
3780
defaultDelayTarget :: Int
3781
defaultDelayTarget = 1
3782

    
3783
defaultDiskCustom :: String
3784
defaultDiskCustom = ""
3785

    
3786
defaultDiskResync :: Bool
3787
defaultDiskResync = False
3788

    
3789
-- | Default fill target measured in sectors
3790
defaultFillTarget :: Int
3791
defaultFillTarget = 0
3792

    
3793
-- | Default mininum rate measured in KiB/s
3794
defaultMinRate :: Int
3795
defaultMinRate = 4 * 1024
3796

    
3797
defaultNetCustom :: String
3798
defaultNetCustom = ""
3799

    
3800
-- | Default plan ahead measured in sectors
3801
--
3802
-- The default values for the DRBD dynamic resync speed algorithm are
3803
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3804
-- (that we don't need to set to 0, because we have a separate option
3805
-- to enable it) and for c-max-rate, that we cap to the default value
3806
-- for the static resync rate.
3807
defaultPlanAhead :: Int
3808
defaultPlanAhead = 20
3809

    
3810
defaultRbdPool :: String
3811
defaultRbdPool = "rbd"
3812

    
3813
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3814
diskLdDefaults =
3815
  Map.fromList
3816
  [ (DTBlock, Map.empty)
3817
  , (DTDrbd8, Map.fromList
3818
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3819
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3820
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3821
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3822
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3823
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3824
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3825
              , (ldpMinRate,       PyValueEx defaultMinRate)
3826
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3827
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3828
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3829
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3830
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3831
              ])
3832
  , (DTExt, Map.empty)
3833
  , (DTFile, Map.empty)
3834
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3835
  , (DTRbd, Map.fromList
3836
            [ (ldpPool, PyValueEx defaultRbdPool)
3837
            , (ldpAccess, PyValueEx diskKernelspace)
3838
            ])
3839
  , (DTSharedFile, Map.empty)
3840
  , (DTGluster, Map.fromList
3841
                [ (rbdAccess, PyValueEx diskKernelspace)
3842
                , (glusterHost, PyValueEx glusterHostDefault)
3843
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3844
                , (glusterPort, PyValueEx glusterPortDefault)
3845
                ])
3846
  ]
3847

    
3848
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3849
diskDtDefaults =
3850
  Map.fromList
3851
  [ (DTBlock,      Map.empty)
3852
  , (DTDiskless,   Map.empty)
3853
  , (DTDrbd8,      Map.fromList
3854
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3855
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3856
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3857
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3858
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3859
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3860
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3861
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3862
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3863
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3864
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3865
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3866
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3867
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3868
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3869
                   ])
3870
  , (DTExt,        Map.empty)
3871
  , (DTFile,       Map.empty)
3872
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3873
  , (DTRbd,        Map.fromList
3874
                   [ (rbdPool, PyValueEx defaultRbdPool)
3875
                   , (rbdAccess, PyValueEx diskKernelspace)
3876
                   ])
3877
  , (DTSharedFile, Map.empty)
3878
  , (DTGluster, Map.fromList
3879
                [ (rbdAccess, PyValueEx diskKernelspace)
3880
                , (glusterHost, PyValueEx glusterHostDefault)
3881
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3882
                , (glusterPort, PyValueEx glusterPortDefault)
3883
                ])
3884
  ]
3885

    
3886
niccDefaults :: Map String PyValueEx
3887
niccDefaults =
3888
  Map.fromList
3889
  [ (nicMode, PyValueEx nicModeBridged)
3890
  , (nicLink, PyValueEx defaultBridge)
3891
  , (nicVlan, PyValueEx "")
3892
  ]
3893

    
3894
-- | All of the following values are quite arbitrary - there are no
3895
-- "good" defaults, these must be customised per-site
3896
ispecsMinmaxDefaults :: Map String (Map String Int)
3897
ispecsMinmaxDefaults =
3898
  Map.fromList
3899
  [(ispecsMin,
3900
    Map.fromList
3901
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3902
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3903
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3904
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3905
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3906
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3907
   (ispecsMax,
3908
    Map.fromList
3909
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3910
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3911
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3912
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3913
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3914
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3915

    
3916
ipolicyDefaults :: Map String PyValueEx
3917
ipolicyDefaults =
3918
  Map.fromList
3919
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3920
  , (ispecsStd,           PyValueEx (Map.fromList
3921
                                     [ (ispecMemSize,    128)
3922
                                     , (ispecCpuCount,   1)
3923
                                     , (ispecDiskCount,  1)
3924
                                     , (ispecDiskSize,   1024)
3925
                                     , (ispecNicCount,   1)
3926
                                     , (ispecSpindleUse, 1)
3927
                                     ] :: Map String Int))
3928
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3929
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3930
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3931
  ]
3932

    
3933
masterPoolSizeDefault :: Int
3934
masterPoolSizeDefault = 10
3935

    
3936
-- * Exclusive storage
3937

    
3938
-- | Error margin used to compare physical disks
3939
partMargin :: Double
3940
partMargin = 0.01
3941

    
3942
-- | Space reserved when creating instance disks
3943
partReserved :: Double
3944
partReserved = 0.02
3945

    
3946
-- * Luxid job scheduling
3947

    
3948
-- | Time intervall in seconds for polling updates on the job queue. This
3949
-- intervall is only relevant if the number of running jobs reaches the maximal
3950
-- allowed number, as otherwise new jobs will be started immediately anyway.
3951
-- Also, as jobs are watched via inotify, scheduling usually works independent
3952
-- of polling. Therefore we chose a sufficiently large interval, in the order of
3953
-- 5 minutes. As with the interval for reloading the configuration, we chose a
3954
-- prime number to avoid accidental 'same wakeup' with other processes.
3955
luxidJobqueuePollInterval :: Int
3956
luxidJobqueuePollInterval = 307
3957

    
3958
-- | The default value for the maximal number of jobs to be running at the same
3959
-- time. Once the maximal number is reached, new jobs will just be queued and
3960
-- only started, once some of the other jobs have finished.
3961
luxidMaximalRunningJobsDefault :: Int
3962
luxidMaximalRunningJobsDefault = 20
3963

    
3964
-- * Confd
3965

    
3966
confdProtocolVersion :: Int
3967
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3968

    
3969
-- Confd request type
3970

    
3971
confdReqPing :: Int
3972
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3973

    
3974
confdReqNodeRoleByname :: Int
3975
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3976

    
3977
confdReqNodePipByInstanceIp :: Int
3978
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3979

    
3980
confdReqClusterMaster :: Int
3981
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3982

    
3983
confdReqNodePipList :: Int
3984
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3985

    
3986
confdReqMcPipList :: Int
3987
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3988

    
3989
confdReqInstancesIpsList :: Int
3990
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3991

    
3992
confdReqNodeDrbd :: Int
3993
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3994

    
3995
confdReqNodeInstances :: Int
3996
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3997

    
3998
confdReqs :: FrozenSet Int
3999
confdReqs =
4000
  ConstantUtils.mkSet .
4001
  map Types.confdRequestTypeToRaw $
4002
  [minBound..] \\ [ReqNodeInstances]
4003

    
4004
-- * Confd request type
4005

    
4006
confdReqfieldName :: Int
4007
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
4008

    
4009
confdReqfieldIp :: Int
4010
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
4011

    
4012
confdReqfieldMnodePip :: Int
4013
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
4014

    
4015
-- * Confd repl status
4016

    
4017
confdReplStatusOk :: Int
4018
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
4019

    
4020
confdReplStatusError :: Int
4021
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
4022

    
4023
confdReplStatusNotimplemented :: Int
4024
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
4025

    
4026
confdReplStatuses :: FrozenSet Int
4027
confdReplStatuses =
4028
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
4029

    
4030
-- * Confd node role
4031

    
4032
confdNodeRoleMaster :: Int
4033
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
4034

    
4035
confdNodeRoleCandidate :: Int
4036
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
4037

    
4038
confdNodeRoleOffline :: Int
4039
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
4040

    
4041
confdNodeRoleDrained :: Int
4042
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
4043

    
4044
confdNodeRoleRegular :: Int
4045
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
4046

    
4047
-- * A few common errors for confd
4048

    
4049
confdErrorUnknownEntry :: Int
4050
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
4051

    
4052
confdErrorInternal :: Int
4053
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
4054

    
4055
confdErrorArgument :: Int
4056
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
4057

    
4058
-- * Confd request query fields
4059

    
4060
confdReqqLink :: String
4061
confdReqqLink = ConstantUtils.confdReqqLink
4062

    
4063
confdReqqIp :: String
4064
confdReqqIp = ConstantUtils.confdReqqIp
4065

    
4066
confdReqqIplist :: String
4067
confdReqqIplist = ConstantUtils.confdReqqIplist
4068

    
4069
confdReqqFields :: String
4070
confdReqqFields = ConstantUtils.confdReqqFields
4071

    
4072
-- | Each request is "salted" by the current timestamp.
4073
--
4074
-- This constant decides how many seconds of skew to accept.
4075
--
4076
-- TODO: make this a default and allow the value to be more
4077
-- configurable
4078
confdMaxClockSkew :: Int
4079
confdMaxClockSkew = 2 * nodeMaxClockSkew
4080

    
4081
-- | When we haven't reloaded the config for more than this amount of
4082
-- seconds, we force a test to see if inotify is betraying us. Using a
4083
-- prime number to ensure we get less chance of 'same wakeup' with
4084
-- other processes.
4085
confdConfigReloadTimeout :: Int
4086
confdConfigReloadTimeout = 17
4087

    
4088
-- | If we receive more than one update in this amount of
4089
-- microseconds, we move to polling every RATELIMIT seconds, rather
4090
-- than relying on inotify, to be able to serve more requests.
4091
confdConfigReloadRatelimit :: Int
4092
confdConfigReloadRatelimit = 250000
4093

    
4094
-- | Magic number prepended to all confd queries.
4095
--
4096
-- This allows us to distinguish different types of confd protocols
4097
-- and handle them. For example by changing this we can move the whole
4098
-- payload to be compressed, or move away from json.
4099
confdMagicFourcc :: String
4100
confdMagicFourcc = "plj0"
4101

    
4102
-- | By default a confd request is sent to the minimum between this
4103
-- number and all MCs. 6 was chosen because even in the case of a
4104
-- disastrous 50% response rate, we should have enough answers to be
4105
-- able to compare more than one.
4106
confdDefaultReqCoverage :: Int
4107
confdDefaultReqCoverage = 6
4108

    
4109
-- | Timeout in seconds to expire pending query request in the confd
4110
-- client library. We don't actually expect any answer more than 10
4111
-- seconds after we sent a request.
4112
confdClientExpireTimeout :: Int
4113
confdClientExpireTimeout = 10
4114

    
4115
-- | Maximum UDP datagram size.
4116
--
4117
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4118
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4119
--   (assuming we can't use jumbo frames)
4120
-- We just set this to 60K, which should be enough
4121
maxUdpDataSize :: Int
4122
maxUdpDataSize = 61440
4123

    
4124
-- * User-id pool minimum/maximum acceptable user-ids
4125

    
4126
uidpoolUidMin :: Int
4127
uidpoolUidMin = 0
4128

    
4129
-- | Assuming 32 bit user-ids
4130
uidpoolUidMax :: Integer
4131
uidpoolUidMax = 2 ^ 32 - 1
4132

    
4133
-- | Name or path of the pgrep command
4134
pgrep :: String
4135
pgrep = "pgrep"
4136

    
4137
-- | Name of the node group that gets created at cluster init or
4138
-- upgrade
4139
initialNodeGroupName :: String
4140
initialNodeGroupName = "default"
4141

    
4142
-- * Possible values for NodeGroup.alloc_policy
4143

    
4144
allocPolicyLastResort :: String
4145
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4146

    
4147
allocPolicyPreferred :: String
4148
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4149

    
4150
allocPolicyUnallocable :: String
4151
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4152

    
4153
validAllocPolicies :: [String]
4154
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4155

    
4156
-- | Temporary external/shared storage parameters
4157
blockdevDriverManual :: String
4158
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4159

    
4160
-- | 'qemu-img' path, required for 'ovfconverter'
4161
qemuimgPath :: String
4162
qemuimgPath = AutoConf.qemuimgPath
4163

    
4164
-- | The hail iallocator
4165
iallocHail :: String
4166
iallocHail = "hail"
4167

    
4168
-- * Fake opcodes for functions that have hooks attached to them via
4169
-- backend.RunLocalHooks
4170

    
4171
fakeOpMasterTurndown :: String
4172
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4173

    
4174
fakeOpMasterTurnup :: String
4175
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4176

    
4177

    
4178
-- * Crypto Types
4179
-- Types of cryptographic tokens used in node communication
4180

    
4181
cryptoTypeSslDigest :: String
4182
cryptoTypeSslDigest = "ssl"
4183

    
4184
cryptoTypeSsh :: String
4185
cryptoTypeSsh = "ssh"
4186

    
4187
-- So far only ssl keys are used in the context of this constant
4188
cryptoTypes :: FrozenSet String
4189
cryptoTypes = ConstantUtils.mkSet [cryptoTypeSslDigest]
4190

    
4191
-- * Crypto Actions
4192
-- Actions that can be performed on crypto tokens
4193

    
4194
cryptoActionGet :: String
4195
cryptoActionGet = "get"
4196

    
4197
-- This is 'create and get'
4198
cryptoActionCreate :: String
4199
cryptoActionCreate = "create"
4200

    
4201
cryptoActions :: FrozenSet String
4202
cryptoActions = ConstantUtils.mkSet [cryptoActionGet, cryptoActionCreate]
4203

    
4204
-- * Options for CryptoActions
4205

    
4206
-- Filename of the certificate
4207
cryptoOptionCertFile :: String
4208
cryptoOptionCertFile = "cert_file"
4209

    
4210
-- * SSH key types
4211

    
4212
sshkDsa :: String
4213
sshkDsa = "dsa"
4214

    
4215
sshkRsa :: String
4216
sshkRsa = "rsa"
4217

    
4218
sshkAll :: FrozenSet String
4219
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4220

    
4221
-- * SSH authorized key types
4222

    
4223
sshakDss :: String
4224
sshakDss = "ssh-dss"
4225

    
4226
sshakRsa :: String
4227
sshakRsa = "ssh-rsa"
4228

    
4229
sshakAll :: FrozenSet String
4230
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4231

    
4232
-- * SSH setup
4233

    
4234
sshsClusterName :: String
4235
sshsClusterName = "cluster_name"
4236

    
4237
sshsSshHostKey :: String
4238
sshsSshHostKey = "ssh_host_key"
4239

    
4240
sshsSshRootKey :: String
4241
sshsSshRootKey = "ssh_root_key"
4242

    
4243
sshsNodeDaemonCertificate :: String
4244
sshsNodeDaemonCertificate = "node_daemon_certificate"
4245

    
4246
-- * Key files for SSH daemon
4247

    
4248
sshHostDsaPriv :: String
4249
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4250

    
4251
sshHostDsaPub :: String
4252
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4253

    
4254
sshHostRsaPriv :: String
4255
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4256

    
4257
sshHostRsaPub :: String
4258
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4259

    
4260
sshDaemonKeyfiles :: Map String (String, String)
4261
sshDaemonKeyfiles =
4262
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4263
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4264
               ]
4265

    
4266
-- * Node daemon setup
4267

    
4268
ndsClusterName :: String
4269
ndsClusterName = "cluster_name"
4270

    
4271
ndsNodeDaemonCertificate :: String
4272
ndsNodeDaemonCertificate = "node_daemon_certificate"
4273

    
4274
ndsSsconf :: String
4275
ndsSsconf = "ssconf"
4276

    
4277
ndsStartNodeDaemon :: String
4278
ndsStartNodeDaemon = "start_node_daemon"
4279

    
4280
-- * VCluster related constants
4281

    
4282
vClusterEtcHosts :: String
4283
vClusterEtcHosts = "/etc/hosts"
4284

    
4285
vClusterVirtPathPrefix :: String
4286
vClusterVirtPathPrefix = "/###-VIRTUAL-PATH-###,"
4287

    
4288
vClusterRootdirEnvname :: String
4289
vClusterRootdirEnvname = "GANETI_ROOTDIR"
4290

    
4291
vClusterHostnameEnvname :: String
4292
vClusterHostnameEnvname = "GANETI_HOSTNAME"
4293

    
4294
vClusterVpathWhitelist :: FrozenSet String
4295
vClusterVpathWhitelist = ConstantUtils.mkSet [ vClusterEtcHosts ]
4296

    
4297
-- * The source reasons for the execution of an OpCode
4298

    
4299
opcodeReasonSrcClient :: String
4300
opcodeReasonSrcClient = "gnt:client"
4301

    
4302
opcodeReasonSrcNoded :: String
4303
opcodeReasonSrcNoded = "gnt:daemon:noded"
4304

    
4305
opcodeReasonSrcOpcode :: String
4306
opcodeReasonSrcOpcode = "gnt:opcode"
4307

    
4308
opcodeReasonSrcRlib2 :: String
4309
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4310

    
4311
opcodeReasonSrcUser :: String
4312
opcodeReasonSrcUser = "gnt:user"
4313

    
4314
opcodeReasonSources :: FrozenSet String
4315
opcodeReasonSources =
4316
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4317
                       opcodeReasonSrcNoded,
4318
                       opcodeReasonSrcOpcode,
4319
                       opcodeReasonSrcRlib2,
4320
                       opcodeReasonSrcUser]
4321

    
4322
-- | Path generating random UUID
4323
randomUuidFile :: String
4324
randomUuidFile = ConstantUtils.randomUuidFile
4325

    
4326
-- * Auto-repair tag prefixes
4327

    
4328
autoRepairTagPrefix :: String
4329
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4330

    
4331
autoRepairTagEnabled :: String
4332
autoRepairTagEnabled = autoRepairTagPrefix
4333

    
4334
autoRepairTagPending :: String
4335
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4336

    
4337
autoRepairTagResult :: String
4338
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4339

    
4340
autoRepairTagSuspended :: String
4341
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4342

    
4343
-- * Auto-repair levels
4344

    
4345
autoRepairFailover :: String
4346
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4347

    
4348
autoRepairFixStorage :: String
4349
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4350

    
4351
autoRepairMigrate :: String
4352
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4353

    
4354
autoRepairReinstall :: String
4355
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4356

    
4357
autoRepairAllTypes :: FrozenSet String
4358
autoRepairAllTypes =
4359
  ConstantUtils.mkSet [autoRepairFailover,
4360
                       autoRepairFixStorage,
4361
                       autoRepairMigrate,
4362
                       autoRepairReinstall]
4363

    
4364
-- * Auto-repair results
4365

    
4366
autoRepairEnoperm :: String
4367
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4368

    
4369
autoRepairFailure :: String
4370
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4371

    
4372
autoRepairSuccess :: String
4373
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4374

    
4375
autoRepairAllResults :: FrozenSet String
4376
autoRepairAllResults =
4377
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4378

    
4379
-- | The version identifier for builtin data collectors
4380
builtinDataCollectorVersion :: String
4381
builtinDataCollectorVersion = "B"
4382

    
4383
-- | The reason trail opcode parameter name
4384
opcodeReason :: String
4385
opcodeReason = "reason"
4386

    
4387
diskstatsFile :: String
4388
diskstatsFile = "/proc/diskstats"
4389

    
4390
-- *  CPU load collector
4391

    
4392
statFile :: String
4393
statFile = "/proc/stat"
4394

    
4395
cpuavgloadBufferSize :: Int
4396
cpuavgloadBufferSize = 150
4397

    
4398
cpuavgloadWindowSize :: Int
4399
cpuavgloadWindowSize = 600
4400

    
4401
-- * Monitoring daemon
4402

    
4403
-- | Mond's variable for periodical data collection
4404
mondTimeInterval :: Int
4405
mondTimeInterval = 5
4406

    
4407
-- | Mond's latest API version
4408
mondLatestApiVersion :: Int
4409
mondLatestApiVersion = 1
4410

    
4411
-- * Disk access modes
4412

    
4413
diskUserspace :: String
4414
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4415

    
4416
diskKernelspace :: String
4417
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4418

    
4419
diskValidAccessModes :: FrozenSet String
4420
diskValidAccessModes =
4421
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4422

    
4423
-- | Timeout for queue draining in upgrades
4424
upgradeQueueDrainTimeout :: Int
4425
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4426

    
4427
-- | Intervall at which the queue is polled during upgrades
4428
upgradeQueuePollInterval :: Int
4429
upgradeQueuePollInterval  = 10
4430

    
4431
-- * Hotplug Actions
4432

    
4433
hotplugActionAdd :: String
4434
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4435

    
4436
hotplugActionRemove :: String
4437
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4438

    
4439
hotplugActionModify :: String
4440
hotplugActionModify = Types.hotplugActionToRaw HAMod
4441

    
4442
hotplugAllActions :: FrozenSet String
4443
hotplugAllActions =
4444
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4445

    
4446
-- * Hotplug Device Targets
4447

    
4448
hotplugTargetNic :: String
4449
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4450

    
4451
hotplugTargetDisk :: String
4452
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4453

    
4454
hotplugAllTargets :: FrozenSet String
4455
hotplugAllTargets =
4456
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4457

    
4458
-- | Timeout for disk removal (seconds)
4459
diskRemoveRetryTimeout :: Int
4460
diskRemoveRetryTimeout = 30
4461

    
4462
-- | Interval between disk removal retries (seconds)
4463
diskRemoveRetryInterval :: Int
4464
diskRemoveRetryInterval  = 3
4465

    
4466
-- * UUID regex
4467

    
4468
uuidRegex :: String
4469
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4470

    
4471
-- * Luxi constants
4472

    
4473
luxiSocketPerms :: Int
4474
luxiSocketPerms = 0o660
4475

    
4476
luxiKeyMethod :: String
4477
luxiKeyMethod = "method"
4478

    
4479
luxiKeyArgs :: String
4480
luxiKeyArgs = "args"
4481

    
4482
luxiKeySuccess :: String
4483
luxiKeySuccess = "success"
4484

    
4485
luxiKeyResult :: String
4486
luxiKeyResult = "result"
4487

    
4488
luxiKeyVersion :: String
4489
luxiKeyVersion = "version"
4490

    
4491
luxiReqSubmitJob :: String
4492
luxiReqSubmitJob = "SubmitJob"
4493

    
4494
luxiReqSubmitJobToDrainedQueue :: String
4495
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4496

    
4497
luxiReqSubmitManyJobs :: String
4498
luxiReqSubmitManyJobs = "SubmitManyJobs"
4499

    
4500
luxiReqWaitForJobChange :: String
4501
luxiReqWaitForJobChange = "WaitForJobChange"
4502

    
4503
luxiReqPickupJob :: String
4504
luxiReqPickupJob = "PickupJob"
4505

    
4506
luxiReqCancelJob :: String
4507
luxiReqCancelJob = "CancelJob"
4508

    
4509
luxiReqArchiveJob :: String
4510
luxiReqArchiveJob = "ArchiveJob"
4511

    
4512
luxiReqChangeJobPriority :: String
4513
luxiReqChangeJobPriority = "ChangeJobPriority"
4514

    
4515
luxiReqAutoArchiveJobs :: String
4516
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4517

    
4518
luxiReqQuery :: String
4519
luxiReqQuery = "Query"
4520

    
4521
luxiReqQueryFields :: String
4522
luxiReqQueryFields = "QueryFields"
4523

    
4524
luxiReqQueryJobs :: String
4525
luxiReqQueryJobs = "QueryJobs"
4526

    
4527
luxiReqQueryInstances :: String
4528
luxiReqQueryInstances = "QueryInstances"
4529

    
4530
luxiReqQueryNodes :: String
4531
luxiReqQueryNodes = "QueryNodes"
4532

    
4533
luxiReqQueryGroups :: String
4534
luxiReqQueryGroups = "QueryGroups"
4535

    
4536
luxiReqQueryNetworks :: String
4537
luxiReqQueryNetworks = "QueryNetworks"
4538

    
4539
luxiReqQueryExports :: String
4540
luxiReqQueryExports = "QueryExports"
4541

    
4542
luxiReqQueryConfigValues :: String
4543
luxiReqQueryConfigValues = "QueryConfigValues"
4544

    
4545
luxiReqQueryClusterInfo :: String
4546
luxiReqQueryClusterInfo = "QueryClusterInfo"
4547

    
4548
luxiReqQueryTags :: String
4549
luxiReqQueryTags = "QueryTags"
4550

    
4551
luxiReqSetDrainFlag :: String
4552
luxiReqSetDrainFlag = "SetDrainFlag"
4553

    
4554
luxiReqSetWatcherPause :: String
4555
luxiReqSetWatcherPause = "SetWatcherPause"
4556

    
4557
luxiReqAll :: FrozenSet String
4558
luxiReqAll =
4559
  ConstantUtils.mkSet
4560
  [ luxiReqArchiveJob
4561
  , luxiReqAutoArchiveJobs
4562
  , luxiReqCancelJob
4563
  , luxiReqChangeJobPriority
4564
  , luxiReqQuery
4565
  , luxiReqQueryClusterInfo
4566
  , luxiReqQueryConfigValues
4567
  , luxiReqQueryExports
4568
  , luxiReqQueryFields
4569
  , luxiReqQueryGroups
4570
  , luxiReqQueryInstances
4571
  , luxiReqQueryJobs
4572
  , luxiReqQueryNodes
4573
  , luxiReqQueryNetworks
4574
  , luxiReqQueryTags
4575
  , luxiReqSetDrainFlag
4576
  , luxiReqSetWatcherPause
4577
  , luxiReqSubmitJob
4578
  , luxiReqSubmitJobToDrainedQueue
4579
  , luxiReqSubmitManyJobs
4580
  , luxiReqWaitForJobChange
4581
  , luxiReqPickupJob
4582
  ]
4583

    
4584
luxiDefCtmo :: Int
4585
luxiDefCtmo = 10
4586

    
4587
luxiDefRwto :: Int
4588
luxiDefRwto = 60
4589

    
4590
-- | 'WaitForJobChange' timeout
4591
luxiWfjcTimeout :: Int
4592
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4593

    
4594
-- * Query language constants
4595

    
4596
-- ** Logic operators with one or more operands, each of which is a
4597
-- filter on its own
4598

    
4599
qlangOpAnd :: String
4600
qlangOpAnd = "&"
4601

    
4602
qlangOpOr :: String
4603
qlangOpOr = "|"
4604

    
4605
-- ** Unary operators with exactly one operand
4606

    
4607
qlangOpNot :: String
4608
qlangOpNot = "!"
4609

    
4610
qlangOpTrue :: String
4611
qlangOpTrue = "?"
4612

    
4613
-- ** Binary operators with exactly two operands, the field name and
4614
-- an operator-specific value
4615

    
4616
qlangOpContains :: String
4617
qlangOpContains = "=[]"
4618

    
4619
qlangOpEqual :: String
4620
qlangOpEqual = "="
4621

    
4622
qlangOpGe :: String
4623
qlangOpGe = ">="
4624

    
4625
qlangOpGt :: String
4626
qlangOpGt = ">"
4627

    
4628
qlangOpLe :: String
4629
qlangOpLe = "<="
4630

    
4631
qlangOpLt :: String
4632
qlangOpLt = "<"
4633

    
4634
qlangOpNotEqual :: String
4635
qlangOpNotEqual = "!="
4636

    
4637
qlangOpRegexp :: String
4638
qlangOpRegexp = "=~"
4639

    
4640
-- | Characters used for detecting user-written filters (see
4641
-- L{_CheckFilter})
4642

    
4643
qlangFilterDetectionChars :: FrozenSet String
4644
qlangFilterDetectionChars =
4645
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4646
                       ")", "(", "\x0b", "\n",
4647
                       "\r", "\x0c", "/", "<",
4648
                       "\t", ">", "=", "\\", "~"]
4649

    
4650
-- | Characters used to detect globbing filters
4651
qlangGlobDetectionChars :: FrozenSet String
4652
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4653

    
4654
-- * Error related constants
4655
--
4656
-- 'OpPrereqError' failure types
4657

    
4658
-- | Environment error (e.g. node disk error)
4659
errorsEcodeEnviron :: String
4660
errorsEcodeEnviron = "environment_error"
4661

    
4662
-- | Entity already exists
4663
errorsEcodeExists :: String
4664
errorsEcodeExists = "already_exists"
4665

    
4666
-- | Internal cluster error
4667
errorsEcodeFault :: String
4668
errorsEcodeFault = "internal_error"
4669

    
4670
-- | Wrong arguments (at syntax level)
4671
errorsEcodeInval :: String
4672
errorsEcodeInval = "wrong_input"
4673

    
4674
-- | Entity not found
4675
errorsEcodeNoent :: String
4676
errorsEcodeNoent = "unknown_entity"
4677

    
4678
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4679
errorsEcodeNores :: String
4680
errorsEcodeNores = "insufficient_resources"
4681

    
4682
-- | Resource not unique (e.g. MAC or IP duplication)
4683
errorsEcodeNotunique :: String
4684
errorsEcodeNotunique = "resource_not_unique"
4685

    
4686
-- | Resolver errors
4687
errorsEcodeResolver :: String
4688
errorsEcodeResolver = "resolver_error"
4689

    
4690
-- | Wrong entity state
4691
errorsEcodeState :: String
4692
errorsEcodeState = "wrong_state"
4693

    
4694
-- | Temporarily out of resources; operation can be tried again
4695
errorsEcodeTempNores :: String
4696
errorsEcodeTempNores = "temp_insufficient_resources"
4697

    
4698
errorsEcodeAll :: FrozenSet String
4699
errorsEcodeAll =
4700
  ConstantUtils.mkSet [ errorsEcodeNores
4701
                      , errorsEcodeExists
4702
                      , errorsEcodeState
4703
                      , errorsEcodeNotunique
4704
                      , errorsEcodeTempNores
4705
                      , errorsEcodeNoent
4706
                      , errorsEcodeFault
4707
                      , errorsEcodeResolver
4708
                      , errorsEcodeInval
4709
                      , errorsEcodeEnviron
4710
                      ]
4711

    
4712
-- * Jstore related constants
4713

    
4714
jstoreJobsPerArchiveDirectory :: Int
4715
jstoreJobsPerArchiveDirectory = 10000
4716

    
4717
-- * Gluster settings
4718

    
4719
-- | Name of the Gluster host setting
4720
glusterHost :: String
4721
glusterHost = "host"
4722

    
4723
-- | Default value of the Gluster host setting
4724
glusterHostDefault :: String
4725
glusterHostDefault = "127.0.0.1"
4726

    
4727
-- | Name of the Gluster volume setting
4728
glusterVolume :: String
4729
glusterVolume = "volume"
4730

    
4731
-- | Default value of the Gluster volume setting
4732
glusterVolumeDefault :: String
4733
glusterVolumeDefault = "gv0"
4734

    
4735
-- | Name of the Gluster port setting
4736
glusterPort :: String
4737
glusterPort = "port"
4738

    
4739
-- | Default value of the Gluster port setting
4740
glusterPortDefault :: Int
4741
glusterPortDefault = 24007