Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ aad2d389

History | View | Annotate | Download (119.9 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
-- * Admin state sources
3123

    
3124
adminSource :: AdminStateSource
3125
adminSource = AdminSource
3126

    
3127
userSource :: AdminStateSource
3128
userSource = UserSource
3129

    
3130
adminStateSources :: FrozenSet AdminStateSource
3131
adminStateSources = ConstantUtils.mkSet [minBound..]
3132

    
3133
-- * Node roles
3134

    
3135
nrDrained :: String
3136
nrDrained = Types.nodeRoleToRaw NRDrained
3137

    
3138
nrMaster :: String
3139
nrMaster = Types.nodeRoleToRaw NRMaster
3140

    
3141
nrMcandidate :: String
3142
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3143

    
3144
nrOffline :: String
3145
nrOffline = Types.nodeRoleToRaw NROffline
3146

    
3147
nrRegular :: String
3148
nrRegular = Types.nodeRoleToRaw NRRegular
3149

    
3150
nrAll :: FrozenSet String
3151
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3152

    
3153
-- * SSL certificate check constants (in days)
3154

    
3155
sslCertExpirationError :: Int
3156
sslCertExpirationError = 7
3157

    
3158
sslCertExpirationWarn :: Int
3159
sslCertExpirationWarn = 30
3160

    
3161
-- * Allocator framework constants
3162

    
3163
iallocatorVersion :: Int
3164
iallocatorVersion = 2
3165

    
3166
iallocatorDirIn :: String
3167
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3168

    
3169
iallocatorDirOut :: String
3170
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3171

    
3172
validIallocatorDirections :: FrozenSet String
3173
validIallocatorDirections =
3174
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3175

    
3176
iallocatorModeAlloc :: String
3177
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3178

    
3179
iallocatorModeChgGroup :: String
3180
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3181

    
3182
iallocatorModeMultiAlloc :: String
3183
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3184

    
3185
iallocatorModeNodeEvac :: String
3186
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3187

    
3188
iallocatorModeReloc :: String
3189
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3190

    
3191
validIallocatorModes :: FrozenSet String
3192
validIallocatorModes =
3193
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3194

    
3195
iallocatorSearchPath :: [String]
3196
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3197

    
3198
defaultIallocatorShortcut :: String
3199
defaultIallocatorShortcut = "."
3200

    
3201
-- * Node evacuation
3202

    
3203
nodeEvacPri :: String
3204
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3205

    
3206
nodeEvacSec :: String
3207
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3208

    
3209
nodeEvacAll :: String
3210
nodeEvacAll = Types.evacModeToRaw ChangeAll
3211

    
3212
nodeEvacModes :: FrozenSet String
3213
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3214

    
3215
-- * Job queue
3216

    
3217
jobQueueVersion :: Int
3218
jobQueueVersion = 1
3219

    
3220
jobQueueSizeHardLimit :: Int
3221
jobQueueSizeHardLimit = 5000
3222

    
3223
jobQueueFilesPerms :: Int
3224
jobQueueFilesPerms = 0o640
3225

    
3226
-- * Unchanged job return
3227

    
3228
jobNotchanged :: String
3229
jobNotchanged = "nochange"
3230

    
3231
-- * Job status
3232

    
3233
jobStatusQueued :: String
3234
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3235

    
3236
jobStatusWaiting :: String
3237
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3238

    
3239
jobStatusCanceling :: String
3240
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3241

    
3242
jobStatusRunning :: String
3243
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3244

    
3245
jobStatusCanceled :: String
3246
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3247

    
3248
jobStatusSuccess :: String
3249
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3250

    
3251
jobStatusError :: String
3252
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3253

    
3254
jobsPending :: FrozenSet String
3255
jobsPending =
3256
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3257

    
3258
jobsFinalized :: FrozenSet String
3259
jobsFinalized =
3260
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3261

    
3262
jobStatusAll :: FrozenSet String
3263
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3264

    
3265
-- * OpCode status
3266

    
3267
-- ** Not yet finalized opcodes
3268

    
3269
opStatusCanceling :: String
3270
opStatusCanceling = "canceling"
3271

    
3272
opStatusQueued :: String
3273
opStatusQueued = "queued"
3274

    
3275
opStatusRunning :: String
3276
opStatusRunning = "running"
3277

    
3278
opStatusWaiting :: String
3279
opStatusWaiting = "waiting"
3280

    
3281
-- ** Finalized opcodes
3282

    
3283
opStatusCanceled :: String
3284
opStatusCanceled = "canceled"
3285

    
3286
opStatusError :: String
3287
opStatusError = "error"
3288

    
3289
opStatusSuccess :: String
3290
opStatusSuccess = "success"
3291

    
3292
opsFinalized :: FrozenSet String
3293
opsFinalized =
3294
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3295

    
3296
-- * OpCode priority
3297

    
3298
opPrioLowest :: Int
3299
opPrioLowest = 19
3300

    
3301
opPrioHighest :: Int
3302
opPrioHighest = -20
3303

    
3304
opPrioLow :: Int
3305
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3306

    
3307
opPrioNormal :: Int
3308
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3309

    
3310
opPrioHigh :: Int
3311
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3312

    
3313
opPrioSubmitValid :: FrozenSet Int
3314
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3315

    
3316
opPrioDefault :: Int
3317
opPrioDefault = opPrioNormal
3318

    
3319
-- * Lock recalculate mode
3320

    
3321
locksAppend :: String
3322
locksAppend = "append"
3323

    
3324
locksReplace :: String
3325
locksReplace = "replace"
3326

    
3327
-- * Lock timeout
3328
--
3329
-- The lock timeout (sum) before we transition into blocking acquire
3330
-- (this can still be reset by priority change).  Computed as max time
3331
-- (10 hours) before we should actually go into blocking acquire,
3332
-- given that we start from the default priority level.
3333

    
3334
lockAttemptsMaxwait :: Double
3335
lockAttemptsMaxwait = 15.0
3336

    
3337
lockAttemptsMinwait :: Double
3338
lockAttemptsMinwait = 1.0
3339

    
3340
lockAttemptsTimeout :: Int
3341
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3342

    
3343
-- * Execution log types
3344

    
3345
elogMessage :: String
3346
elogMessage = Types.eLogTypeToRaw ELogMessage
3347

    
3348
elogRemoteImport :: String
3349
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3350

    
3351
elogJqueueTest :: String
3352
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3353

    
3354
-- * /etc/hosts modification
3355

    
3356
etcHostsAdd :: String
3357
etcHostsAdd = "add"
3358

    
3359
etcHostsRemove :: String
3360
etcHostsRemove = "remove"
3361

    
3362
-- * Job queue test
3363

    
3364
jqtMsgprefix :: String
3365
jqtMsgprefix = "TESTMSG="
3366

    
3367
jqtExec :: String
3368
jqtExec = "exec"
3369

    
3370
jqtExpandnames :: String
3371
jqtExpandnames = "expandnames"
3372

    
3373
jqtLogmsg :: String
3374
jqtLogmsg = "logmsg"
3375

    
3376
jqtStartmsg :: String
3377
jqtStartmsg = "startmsg"
3378

    
3379
jqtAll :: FrozenSet String
3380
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3381

    
3382
-- * Query resources
3383

    
3384
qrCluster :: String
3385
qrCluster = "cluster"
3386

    
3387
qrExport :: String
3388
qrExport = "export"
3389

    
3390
qrExtstorage :: String
3391
qrExtstorage = "extstorage"
3392

    
3393
qrGroup :: String
3394
qrGroup = "group"
3395

    
3396
qrInstance :: String
3397
qrInstance = "instance"
3398

    
3399
qrJob :: String
3400
qrJob = "job"
3401

    
3402
qrLock :: String
3403
qrLock = "lock"
3404

    
3405
qrNetwork :: String
3406
qrNetwork = "network"
3407

    
3408
qrNode :: String
3409
qrNode = "node"
3410

    
3411
qrOs :: String
3412
qrOs = "os"
3413

    
3414
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3415
qrViaOp :: FrozenSet String
3416
qrViaOp =
3417
  ConstantUtils.mkSet [qrCluster,
3418
                       qrOs,
3419
                       qrExtstorage]
3420

    
3421
-- | List of resources which can be queried using Local UniX Interface
3422
qrViaLuxi :: FrozenSet String
3423
qrViaLuxi = ConstantUtils.mkSet [qrGroup,
3424
                                 qrExport,
3425
                                 qrInstance,
3426
                                 qrJob,
3427
                                 qrLock,
3428
                                 qrNetwork,
3429
                                 qrNode]
3430

    
3431
-- | List of resources which can be queried using RAPI
3432
qrViaRapi :: FrozenSet String
3433
qrViaRapi = qrViaLuxi
3434

    
3435
-- | List of resources which can be queried via RAPI including PUT requests
3436
qrViaRapiPut :: FrozenSet String
3437
qrViaRapiPut = ConstantUtils.mkSet [qrLock, qrJob]
3438

    
3439
-- * Query field types
3440

    
3441
qftBool :: String
3442
qftBool = "bool"
3443

    
3444
qftNumber :: String
3445
qftNumber = "number"
3446

    
3447
qftOther :: String
3448
qftOther = "other"
3449

    
3450
qftText :: String
3451
qftText = "text"
3452

    
3453
qftTimestamp :: String
3454
qftTimestamp = "timestamp"
3455

    
3456
qftUnit :: String
3457
qftUnit = "unit"
3458

    
3459
qftUnknown :: String
3460
qftUnknown = "unknown"
3461

    
3462
qftAll :: FrozenSet String
3463
qftAll =
3464
  ConstantUtils.mkSet [qftBool,
3465
                       qftNumber,
3466
                       qftOther,
3467
                       qftText,
3468
                       qftTimestamp,
3469
                       qftUnit,
3470
                       qftUnknown]
3471

    
3472
-- * Query result field status
3473
--
3474
-- Don't change or reuse values as they're used by clients.
3475
--
3476
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3477

    
3478
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3479
rsNodata :: Int
3480
rsNodata = 2
3481

    
3482
rsNormal :: Int
3483
rsNormal = 0
3484

    
3485
-- | Resource marked offline
3486
rsOffline :: Int
3487
rsOffline = 4
3488

    
3489
-- | Value unavailable/unsupported for item; if this field is
3490
-- supported but we cannot get the data for the moment, 'rsNodata' or
3491
-- 'rsOffline' should be used
3492
rsUnavail :: Int
3493
rsUnavail = 3
3494

    
3495
rsUnknown :: Int
3496
rsUnknown = 1
3497

    
3498
rsAll :: FrozenSet Int
3499
rsAll =
3500
  ConstantUtils.mkSet [rsNodata,
3501
                       rsNormal,
3502
                       rsOffline,
3503
                       rsUnavail,
3504
                       rsUnknown]
3505

    
3506
-- | Special field cases and their verbose/terse formatting
3507
rssDescription :: Map Int (String, String)
3508
rssDescription =
3509
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3510
                (rsNodata, ("(nodata)", "?")),
3511
                (rsOffline, ("(offline)", "*")),
3512
                (rsUnavail, ("(unavail)", "-"))]
3513

    
3514
-- * Max dynamic devices
3515

    
3516
maxDisks :: Int
3517
maxDisks = Types.maxDisks
3518

    
3519
maxNics :: Int
3520
maxNics = Types.maxNics
3521

    
3522
-- | SSCONF file prefix
3523
ssconfFileprefix :: String
3524
ssconfFileprefix = "ssconf_"
3525

    
3526
-- * SSCONF keys
3527

    
3528
ssClusterName :: String
3529
ssClusterName = "cluster_name"
3530

    
3531
ssClusterTags :: String
3532
ssClusterTags = "cluster_tags"
3533

    
3534
ssFileStorageDir :: String
3535
ssFileStorageDir = "file_storage_dir"
3536

    
3537
ssSharedFileStorageDir :: String
3538
ssSharedFileStorageDir = "shared_file_storage_dir"
3539

    
3540
ssGlusterStorageDir :: String
3541
ssGlusterStorageDir = "gluster_storage_dir"
3542

    
3543
ssMasterCandidates :: String
3544
ssMasterCandidates = "master_candidates"
3545

    
3546
ssMasterCandidatesIps :: String
3547
ssMasterCandidatesIps = "master_candidates_ips"
3548

    
3549
ssMasterCandidatesCerts :: String
3550
ssMasterCandidatesCerts = "master_candidates_certs"
3551

    
3552
ssMasterIp :: String
3553
ssMasterIp = "master_ip"
3554

    
3555
ssMasterNetdev :: String
3556
ssMasterNetdev = "master_netdev"
3557

    
3558
ssMasterNetmask :: String
3559
ssMasterNetmask = "master_netmask"
3560

    
3561
ssMasterNode :: String
3562
ssMasterNode = "master_node"
3563

    
3564
ssNodeList :: String
3565
ssNodeList = "node_list"
3566

    
3567
ssNodePrimaryIps :: String
3568
ssNodePrimaryIps = "node_primary_ips"
3569

    
3570
ssNodeSecondaryIps :: String
3571
ssNodeSecondaryIps = "node_secondary_ips"
3572

    
3573
ssOfflineNodes :: String
3574
ssOfflineNodes = "offline_nodes"
3575

    
3576
ssOnlineNodes :: String
3577
ssOnlineNodes = "online_nodes"
3578

    
3579
ssPrimaryIpFamily :: String
3580
ssPrimaryIpFamily = "primary_ip_family"
3581

    
3582
ssInstanceList :: String
3583
ssInstanceList = "instance_list"
3584

    
3585
ssReleaseVersion :: String
3586
ssReleaseVersion = "release_version"
3587

    
3588
ssHypervisorList :: String
3589
ssHypervisorList = "hypervisor_list"
3590

    
3591
ssMaintainNodeHealth :: String
3592
ssMaintainNodeHealth = "maintain_node_health"
3593

    
3594
ssUidPool :: String
3595
ssUidPool = "uid_pool"
3596

    
3597
ssNodegroups :: String
3598
ssNodegroups = "nodegroups"
3599

    
3600
ssNetworks :: String
3601
ssNetworks = "networks"
3602

    
3603
-- | This is not a complete SSCONF key, but the prefix for the
3604
-- hypervisor keys
3605
ssHvparamsPref :: String
3606
ssHvparamsPref = "hvparams_"
3607

    
3608
-- * Hvparams keys
3609

    
3610
ssHvparamsXenChroot :: String
3611
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3612

    
3613
ssHvparamsXenFake :: String
3614
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3615

    
3616
ssHvparamsXenHvm :: String
3617
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3618

    
3619
ssHvparamsXenKvm :: String
3620
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3621

    
3622
ssHvparamsXenLxc :: String
3623
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3624

    
3625
ssHvparamsXenPvm :: String
3626
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3627

    
3628
validSsHvparamsKeys :: FrozenSet String
3629
validSsHvparamsKeys =
3630
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3631
                       ssHvparamsXenLxc,
3632
                       ssHvparamsXenFake,
3633
                       ssHvparamsXenHvm,
3634
                       ssHvparamsXenKvm,
3635
                       ssHvparamsXenPvm]
3636

    
3637
ssFilePerms :: Int
3638
ssFilePerms = 0o444
3639

    
3640
-- | Cluster wide default parameters
3641
defaultEnabledHypervisor :: String
3642
defaultEnabledHypervisor = htXenPvm
3643

    
3644
hvcDefaults :: Map Hypervisor (Map String PyValueEx)
3645
hvcDefaults =
3646
  Map.fromList
3647
  [ (XenPvm, Map.fromList
3648
             [ (hvUseBootloader,  PyValueEx False)
3649
             , (hvBootloaderPath, PyValueEx xenBootloader)
3650
             , (hvBootloaderArgs, PyValueEx "")
3651
             , (hvKernelPath,     PyValueEx xenKernel)
3652
             , (hvInitrdPath,     PyValueEx "")
3653
             , (hvRootPath,       PyValueEx "/dev/xvda1")
3654
             , (hvKernelArgs,     PyValueEx "ro")
3655
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3656
             , (hvMigrationMode,  PyValueEx htMigrationLive)
3657
             , (hvBlockdevPrefix, PyValueEx "sd")
3658
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3659
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3660
             , (hvCpuCap,         PyValueEx (0 :: Int))
3661
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3662
             , (hvVifScript,      PyValueEx "")
3663
             , (hvXenCmd,         PyValueEx xenCmdXm)
3664
             , (hvXenCpuid,       PyValueEx "")
3665
             , (hvSoundhw,        PyValueEx "")
3666
             ])
3667
  , (XenHvm, Map.fromList
3668
             [ (hvBootOrder,      PyValueEx "cd")
3669
             , (hvCdromImagePath, PyValueEx "")
3670
             , (hvNicType,        PyValueEx htNicRtl8139)
3671
             , (hvDiskType,       PyValueEx htDiskParavirtual)
3672
             , (hvVncBindAddress, PyValueEx ip4AddressAny)
3673
             , (hvAcpi,           PyValueEx True)
3674
             , (hvPae,            PyValueEx True)
3675
             , (hvKernelPath,     PyValueEx "/usr/lib/xen/boot/hvmloader")
3676
             , (hvDeviceModel,    PyValueEx "/usr/lib/xen/bin/qemu-dm")
3677
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3678
             , (hvMigrationMode,  PyValueEx htMigrationNonlive)
3679
             , (hvUseLocaltime,   PyValueEx False)
3680
             , (hvBlockdevPrefix, PyValueEx "hd")
3681
             , (hvPassthrough,    PyValueEx "")
3682
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3683
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3684
             , (hvCpuCap,         PyValueEx (0 :: Int))
3685
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3686
             , (hvVifType,        PyValueEx htHvmVifIoemu)
3687
             , (hvVifScript,      PyValueEx "")
3688
             , (hvViridian,       PyValueEx False)
3689
             , (hvXenCmd,         PyValueEx xenCmdXm)
3690
             , (hvXenCpuid,       PyValueEx "")
3691
             , (hvSoundhw,        PyValueEx "")
3692
             ])
3693
  , (Kvm, Map.fromList
3694
          [ (hvKvmPath,                         PyValueEx kvmPath)
3695
          , (hvKernelPath,                      PyValueEx kvmKernel)
3696
          , (hvInitrdPath,                      PyValueEx "")
3697
          , (hvKernelArgs,                      PyValueEx "ro")
3698
          , (hvRootPath,                        PyValueEx "/dev/vda1")
3699
          , (hvAcpi,                            PyValueEx True)
3700
          , (hvSerialConsole,                   PyValueEx True)
3701
          , (hvSerialSpeed,                     PyValueEx (38400 :: Int))
3702
          , (hvVncBindAddress,                  PyValueEx "")
3703
          , (hvVncTls,                          PyValueEx False)
3704
          , (hvVncX509,                         PyValueEx "")
3705
          , (hvVncX509Verify,                   PyValueEx False)
3706
          , (hvVncPasswordFile,                 PyValueEx "")
3707
          , (hvKvmSpiceBind,                    PyValueEx "")
3708
          , (hvKvmSpiceIpVersion,           PyValueEx ifaceNoIpVersionSpecified)
3709
          , (hvKvmSpicePasswordFile,            PyValueEx "")
3710
          , (hvKvmSpiceLosslessImgCompr,        PyValueEx "")
3711
          , (hvKvmSpiceJpegImgCompr,            PyValueEx "")
3712
          , (hvKvmSpiceZlibGlzImgCompr,         PyValueEx "")
3713
          , (hvKvmSpiceStreamingVideoDetection, PyValueEx "")
3714
          , (hvKvmSpiceAudioCompr,              PyValueEx True)
3715
          , (hvKvmSpiceUseTls,                  PyValueEx False)
3716
          , (hvKvmSpiceTlsCiphers,              PyValueEx opensslCiphers)
3717
          , (hvKvmSpiceUseVdagent,              PyValueEx True)
3718
          , (hvKvmFloppyImagePath,              PyValueEx "")
3719
          , (hvCdromImagePath,                  PyValueEx "")
3720
          , (hvKvmCdrom2ImagePath,              PyValueEx "")
3721
          , (hvBootOrder,                       PyValueEx htBoDisk)
3722
          , (hvNicType,                         PyValueEx htNicParavirtual)
3723
          , (hvDiskType,                        PyValueEx htDiskParavirtual)
3724
          , (hvKvmCdromDiskType,                PyValueEx "")
3725
          , (hvUsbMouse,                        PyValueEx "")
3726
          , (hvKeymap,                          PyValueEx "")
3727
          , (hvMigrationPort,                   PyValueEx (8102 :: Int))
3728
          , (hvMigrationBandwidth,              PyValueEx (32 :: Int))
3729
          , (hvMigrationDowntime,               PyValueEx (30 :: Int))
3730
          , (hvMigrationMode,                   PyValueEx htMigrationLive)
3731
          , (hvUseLocaltime,                    PyValueEx False)
3732
          , (hvDiskCache,                       PyValueEx htCacheDefault)
3733
          , (hvSecurityModel,                   PyValueEx htSmNone)
3734
          , (hvSecurityDomain,                  PyValueEx "")
3735
          , (hvKvmFlag,                         PyValueEx "")
3736
          , (hvVhostNet,                        PyValueEx False)
3737
          , (hvKvmUseChroot,                    PyValueEx False)
3738
          , (hvKvmUserShutdown,                 PyValueEx False)
3739
          , (hvMemPath,                         PyValueEx "")
3740
          , (hvRebootBehavior,                  PyValueEx instanceRebootAllowed)
3741
          , (hvCpuMask,                         PyValueEx cpuPinningAll)
3742
          , (hvCpuType,                         PyValueEx "")
3743
          , (hvCpuCores,                        PyValueEx (0 :: Int))
3744
          , (hvCpuThreads,                      PyValueEx (0 :: Int))
3745
          , (hvCpuSockets,                      PyValueEx (0 :: Int))
3746
          , (hvSoundhw,                         PyValueEx "")
3747
          , (hvUsbDevices,                      PyValueEx "")
3748
          , (hvVga,                             PyValueEx "")
3749
          , (hvKvmExtra,                        PyValueEx "")
3750
          , (hvKvmMachineVersion,               PyValueEx "")
3751
          , (hvVnetHdr,                         PyValueEx True)])
3752
  , (Fake, Map.fromList [(hvMigrationMode, PyValueEx htMigrationLive)])
3753
  , (Chroot, Map.fromList [(hvInitScript, PyValueEx "/ganeti-chroot")])
3754
  , (Lxc, Map.fromList [(hvCpuMask, PyValueEx "")])
3755
  ]
3756

    
3757
hvcGlobals :: FrozenSet String
3758
hvcGlobals =
3759
  ConstantUtils.mkSet [hvMigrationBandwidth,
3760
                       hvMigrationMode,
3761
                       hvMigrationPort,
3762
                       hvXenCmd]
3763

    
3764
becDefaults :: Map String PyValueEx
3765
becDefaults =
3766
  Map.fromList
3767
  [ (beMinmem, PyValueEx (128 :: Int))
3768
  , (beMaxmem, PyValueEx (128 :: Int))
3769
  , (beVcpus, PyValueEx (1 :: Int))
3770
  , (beAutoBalance, PyValueEx True)
3771
  , (beAlwaysFailover, PyValueEx False)
3772
  , (beSpindleUse, PyValueEx (1 :: Int))
3773
  ]
3774

    
3775
ndcDefaults :: Map String PyValueEx
3776
ndcDefaults =
3777
  Map.fromList
3778
  [ (ndOobProgram,       PyValueEx "")
3779
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3780
  , (ndExclusiveStorage, PyValueEx False)
3781
  , (ndOvs,              PyValueEx False)
3782
  , (ndOvsName,          PyValueEx defaultOvs)
3783
  , (ndOvsLink,          PyValueEx "")
3784
  , (ndSshPort,          PyValueEx (22 :: Int))
3785
  ]
3786

    
3787
ndcGlobals :: FrozenSet String
3788
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3789

    
3790
-- | Default delay target measured in sectors
3791
defaultDelayTarget :: Int
3792
defaultDelayTarget = 1
3793

    
3794
defaultDiskCustom :: String
3795
defaultDiskCustom = ""
3796

    
3797
defaultDiskResync :: Bool
3798
defaultDiskResync = False
3799

    
3800
-- | Default fill target measured in sectors
3801
defaultFillTarget :: Int
3802
defaultFillTarget = 0
3803

    
3804
-- | Default mininum rate measured in KiB/s
3805
defaultMinRate :: Int
3806
defaultMinRate = 4 * 1024
3807

    
3808
defaultNetCustom :: String
3809
defaultNetCustom = ""
3810

    
3811
-- | Default plan ahead measured in sectors
3812
--
3813
-- The default values for the DRBD dynamic resync speed algorithm are
3814
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3815
-- (that we don't need to set to 0, because we have a separate option
3816
-- to enable it) and for c-max-rate, that we cap to the default value
3817
-- for the static resync rate.
3818
defaultPlanAhead :: Int
3819
defaultPlanAhead = 20
3820

    
3821
defaultRbdPool :: String
3822
defaultRbdPool = "rbd"
3823

    
3824
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3825
diskLdDefaults =
3826
  Map.fromList
3827
  [ (DTBlock, Map.empty)
3828
  , (DTDrbd8, Map.fromList
3829
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3830
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3831
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3832
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3833
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3834
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3835
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3836
              , (ldpMinRate,       PyValueEx defaultMinRate)
3837
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3838
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3839
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3840
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3841
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3842
              ])
3843
  , (DTExt, Map.empty)
3844
  , (DTFile, Map.empty)
3845
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3846
  , (DTRbd, Map.fromList
3847
            [ (ldpPool, PyValueEx defaultRbdPool)
3848
            , (ldpAccess, PyValueEx diskKernelspace)
3849
            ])
3850
  , (DTSharedFile, Map.empty)
3851
  , (DTGluster, Map.fromList
3852
                [ (rbdAccess, PyValueEx diskKernelspace)
3853
                , (glusterHost, PyValueEx glusterHostDefault)
3854
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3855
                , (glusterPort, PyValueEx glusterPortDefault)
3856
                ])
3857
  ]
3858

    
3859
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3860
diskDtDefaults =
3861
  Map.fromList
3862
  [ (DTBlock,      Map.empty)
3863
  , (DTDiskless,   Map.empty)
3864
  , (DTDrbd8,      Map.fromList
3865
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3866
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3867
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3868
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3869
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3870
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3871
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3872
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3873
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3874
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3875
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3876
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3877
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3878
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3879
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3880
                   ])
3881
  , (DTExt,        Map.empty)
3882
  , (DTFile,       Map.empty)
3883
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3884
  , (DTRbd,        Map.fromList
3885
                   [ (rbdPool, PyValueEx defaultRbdPool)
3886
                   , (rbdAccess, PyValueEx diskKernelspace)
3887
                   ])
3888
  , (DTSharedFile, Map.empty)
3889
  , (DTGluster, Map.fromList
3890
                [ (rbdAccess, PyValueEx diskKernelspace)
3891
                , (glusterHost, PyValueEx glusterHostDefault)
3892
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3893
                , (glusterPort, PyValueEx glusterPortDefault)
3894
                ])
3895
  ]
3896

    
3897
niccDefaults :: Map String PyValueEx
3898
niccDefaults =
3899
  Map.fromList
3900
  [ (nicMode, PyValueEx nicModeBridged)
3901
  , (nicLink, PyValueEx defaultBridge)
3902
  , (nicVlan, PyValueEx "")
3903
  ]
3904

    
3905
-- | All of the following values are quite arbitrary - there are no
3906
-- "good" defaults, these must be customised per-site
3907
ispecsMinmaxDefaults :: Map String (Map String Int)
3908
ispecsMinmaxDefaults =
3909
  Map.fromList
3910
  [(ispecsMin,
3911
    Map.fromList
3912
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3913
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3914
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3915
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3916
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3917
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3918
   (ispecsMax,
3919
    Map.fromList
3920
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3921
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3922
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3923
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3924
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3925
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3926

    
3927
ipolicyDefaults :: Map String PyValueEx
3928
ipolicyDefaults =
3929
  Map.fromList
3930
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3931
  , (ispecsStd,           PyValueEx (Map.fromList
3932
                                     [ (ispecMemSize,    128)
3933
                                     , (ispecCpuCount,   1)
3934
                                     , (ispecDiskCount,  1)
3935
                                     , (ispecDiskSize,   1024)
3936
                                     , (ispecNicCount,   1)
3937
                                     , (ispecSpindleUse, 1)
3938
                                     ] :: Map String Int))
3939
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3940
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3941
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3942
  ]
3943

    
3944
masterPoolSizeDefault :: Int
3945
masterPoolSizeDefault = 10
3946

    
3947
-- * Exclusive storage
3948

    
3949
-- | Error margin used to compare physical disks
3950
partMargin :: Double
3951
partMargin = 0.01
3952

    
3953
-- | Space reserved when creating instance disks
3954
partReserved :: Double
3955
partReserved = 0.02
3956

    
3957
-- * Luxid job scheduling
3958

    
3959
-- | Time intervall in seconds for polling updates on the job queue. This
3960
-- intervall is only relevant if the number of running jobs reaches the maximal
3961
-- allowed number, as otherwise new jobs will be started immediately anyway.
3962
-- Also, as jobs are watched via inotify, scheduling usually works independent
3963
-- of polling. Therefore we chose a sufficiently large interval, in the order of
3964
-- 5 minutes. As with the interval for reloading the configuration, we chose a
3965
-- prime number to avoid accidental 'same wakeup' with other processes.
3966
luxidJobqueuePollInterval :: Int
3967
luxidJobqueuePollInterval = 307
3968

    
3969
-- | The default value for the maximal number of jobs to be running at the same
3970
-- time. Once the maximal number is reached, new jobs will just be queued and
3971
-- only started, once some of the other jobs have finished.
3972
luxidMaximalRunningJobsDefault :: Int
3973
luxidMaximalRunningJobsDefault = 20
3974

    
3975
-- * Confd
3976

    
3977
confdProtocolVersion :: Int
3978
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3979

    
3980
-- Confd request type
3981

    
3982
confdReqPing :: Int
3983
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3984

    
3985
confdReqNodeRoleByname :: Int
3986
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3987

    
3988
confdReqNodePipByInstanceIp :: Int
3989
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3990

    
3991
confdReqClusterMaster :: Int
3992
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3993

    
3994
confdReqNodePipList :: Int
3995
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3996

    
3997
confdReqMcPipList :: Int
3998
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3999

    
4000
confdReqInstancesIpsList :: Int
4001
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
4002

    
4003
confdReqNodeDrbd :: Int
4004
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
4005

    
4006
confdReqNodeInstances :: Int
4007
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
4008

    
4009
confdReqs :: FrozenSet Int
4010
confdReqs =
4011
  ConstantUtils.mkSet .
4012
  map Types.confdRequestTypeToRaw $
4013
  [minBound..] \\ [ReqNodeInstances]
4014

    
4015
-- * Confd request type
4016

    
4017
confdReqfieldName :: Int
4018
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
4019

    
4020
confdReqfieldIp :: Int
4021
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
4022

    
4023
confdReqfieldMnodePip :: Int
4024
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
4025

    
4026
-- * Confd repl status
4027

    
4028
confdReplStatusOk :: Int
4029
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
4030

    
4031
confdReplStatusError :: Int
4032
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
4033

    
4034
confdReplStatusNotimplemented :: Int
4035
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
4036

    
4037
confdReplStatuses :: FrozenSet Int
4038
confdReplStatuses =
4039
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
4040

    
4041
-- * Confd node role
4042

    
4043
confdNodeRoleMaster :: Int
4044
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
4045

    
4046
confdNodeRoleCandidate :: Int
4047
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
4048

    
4049
confdNodeRoleOffline :: Int
4050
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
4051

    
4052
confdNodeRoleDrained :: Int
4053
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
4054

    
4055
confdNodeRoleRegular :: Int
4056
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
4057

    
4058
-- * A few common errors for confd
4059

    
4060
confdErrorUnknownEntry :: Int
4061
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
4062

    
4063
confdErrorInternal :: Int
4064
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
4065

    
4066
confdErrorArgument :: Int
4067
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
4068

    
4069
-- * Confd request query fields
4070

    
4071
confdReqqLink :: String
4072
confdReqqLink = ConstantUtils.confdReqqLink
4073

    
4074
confdReqqIp :: String
4075
confdReqqIp = ConstantUtils.confdReqqIp
4076

    
4077
confdReqqIplist :: String
4078
confdReqqIplist = ConstantUtils.confdReqqIplist
4079

    
4080
confdReqqFields :: String
4081
confdReqqFields = ConstantUtils.confdReqqFields
4082

    
4083
-- | Each request is "salted" by the current timestamp.
4084
--
4085
-- This constant decides how many seconds of skew to accept.
4086
--
4087
-- TODO: make this a default and allow the value to be more
4088
-- configurable
4089
confdMaxClockSkew :: Int
4090
confdMaxClockSkew = 2 * nodeMaxClockSkew
4091

    
4092
-- | When we haven't reloaded the config for more than this amount of
4093
-- seconds, we force a test to see if inotify is betraying us. Using a
4094
-- prime number to ensure we get less chance of 'same wakeup' with
4095
-- other processes.
4096
confdConfigReloadTimeout :: Int
4097
confdConfigReloadTimeout = 17
4098

    
4099
-- | If we receive more than one update in this amount of
4100
-- microseconds, we move to polling every RATELIMIT seconds, rather
4101
-- than relying on inotify, to be able to serve more requests.
4102
confdConfigReloadRatelimit :: Int
4103
confdConfigReloadRatelimit = 250000
4104

    
4105
-- | Magic number prepended to all confd queries.
4106
--
4107
-- This allows us to distinguish different types of confd protocols
4108
-- and handle them. For example by changing this we can move the whole
4109
-- payload to be compressed, or move away from json.
4110
confdMagicFourcc :: String
4111
confdMagicFourcc = "plj0"
4112

    
4113
-- | By default a confd request is sent to the minimum between this
4114
-- number and all MCs. 6 was chosen because even in the case of a
4115
-- disastrous 50% response rate, we should have enough answers to be
4116
-- able to compare more than one.
4117
confdDefaultReqCoverage :: Int
4118
confdDefaultReqCoverage = 6
4119

    
4120
-- | Timeout in seconds to expire pending query request in the confd
4121
-- client library. We don't actually expect any answer more than 10
4122
-- seconds after we sent a request.
4123
confdClientExpireTimeout :: Int
4124
confdClientExpireTimeout = 10
4125

    
4126
-- | Maximum UDP datagram size.
4127
--
4128
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4129
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4130
--   (assuming we can't use jumbo frames)
4131
-- We just set this to 60K, which should be enough
4132
maxUdpDataSize :: Int
4133
maxUdpDataSize = 61440
4134

    
4135
-- * User-id pool minimum/maximum acceptable user-ids
4136

    
4137
uidpoolUidMin :: Int
4138
uidpoolUidMin = 0
4139

    
4140
-- | Assuming 32 bit user-ids
4141
uidpoolUidMax :: Integer
4142
uidpoolUidMax = 2 ^ 32 - 1
4143

    
4144
-- | Name or path of the pgrep command
4145
pgrep :: String
4146
pgrep = "pgrep"
4147

    
4148
-- | Name of the node group that gets created at cluster init or
4149
-- upgrade
4150
initialNodeGroupName :: String
4151
initialNodeGroupName = "default"
4152

    
4153
-- * Possible values for NodeGroup.alloc_policy
4154

    
4155
allocPolicyLastResort :: String
4156
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4157

    
4158
allocPolicyPreferred :: String
4159
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4160

    
4161
allocPolicyUnallocable :: String
4162
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4163

    
4164
validAllocPolicies :: [String]
4165
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4166

    
4167
-- | Temporary external/shared storage parameters
4168
blockdevDriverManual :: String
4169
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4170

    
4171
-- | 'qemu-img' path, required for 'ovfconverter'
4172
qemuimgPath :: String
4173
qemuimgPath = AutoConf.qemuimgPath
4174

    
4175
-- | The hail iallocator
4176
iallocHail :: String
4177
iallocHail = "hail"
4178

    
4179
-- * Fake opcodes for functions that have hooks attached to them via
4180
-- backend.RunLocalHooks
4181

    
4182
fakeOpMasterTurndown :: String
4183
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4184

    
4185
fakeOpMasterTurnup :: String
4186
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4187

    
4188

    
4189
-- * Crypto Types
4190
-- Types of cryptographic tokens used in node communication
4191

    
4192
cryptoTypeSslDigest :: String
4193
cryptoTypeSslDigest = "ssl"
4194

    
4195
cryptoTypeSsh :: String
4196
cryptoTypeSsh = "ssh"
4197

    
4198
-- So far only ssl keys are used in the context of this constant
4199
cryptoTypes :: FrozenSet String
4200
cryptoTypes = ConstantUtils.mkSet [cryptoTypeSslDigest]
4201

    
4202
-- * Crypto Actions
4203
-- Actions that can be performed on crypto tokens
4204

    
4205
cryptoActionGet :: String
4206
cryptoActionGet = "get"
4207

    
4208
-- This is 'create and get'
4209
cryptoActionCreate :: String
4210
cryptoActionCreate = "create"
4211

    
4212
cryptoActions :: FrozenSet String
4213
cryptoActions = ConstantUtils.mkSet [cryptoActionGet, cryptoActionCreate]
4214

    
4215
-- * Options for CryptoActions
4216

    
4217
-- Filename of the certificate
4218
cryptoOptionCertFile :: String
4219
cryptoOptionCertFile = "cert_file"
4220

    
4221
-- Serial number of the certificate
4222
cryptoOptionSerialNo :: String
4223
cryptoOptionSerialNo = "serial_no"
4224

    
4225
-- * SSH key types
4226

    
4227
sshkDsa :: String
4228
sshkDsa = "dsa"
4229

    
4230
sshkRsa :: String
4231
sshkRsa = "rsa"
4232

    
4233
sshkAll :: FrozenSet String
4234
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4235

    
4236
-- * SSH authorized key types
4237

    
4238
sshakDss :: String
4239
sshakDss = "ssh-dss"
4240

    
4241
sshakRsa :: String
4242
sshakRsa = "ssh-rsa"
4243

    
4244
sshakAll :: FrozenSet String
4245
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4246

    
4247
-- * SSH setup
4248

    
4249
sshsClusterName :: String
4250
sshsClusterName = "cluster_name"
4251

    
4252
sshsSshHostKey :: String
4253
sshsSshHostKey = "ssh_host_key"
4254

    
4255
sshsSshRootKey :: String
4256
sshsSshRootKey = "ssh_root_key"
4257

    
4258
sshsNodeDaemonCertificate :: String
4259
sshsNodeDaemonCertificate = "node_daemon_certificate"
4260

    
4261
-- * Key files for SSH daemon
4262

    
4263
sshHostDsaPriv :: String
4264
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4265

    
4266
sshHostDsaPub :: String
4267
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4268

    
4269
sshHostRsaPriv :: String
4270
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4271

    
4272
sshHostRsaPub :: String
4273
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4274

    
4275
sshDaemonKeyfiles :: Map String (String, String)
4276
sshDaemonKeyfiles =
4277
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4278
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4279
               ]
4280

    
4281
-- * Node daemon setup
4282

    
4283
ndsClusterName :: String
4284
ndsClusterName = "cluster_name"
4285

    
4286
ndsNodeDaemonCertificate :: String
4287
ndsNodeDaemonCertificate = "node_daemon_certificate"
4288

    
4289
ndsSsconf :: String
4290
ndsSsconf = "ssconf"
4291

    
4292
ndsStartNodeDaemon :: String
4293
ndsStartNodeDaemon = "start_node_daemon"
4294

    
4295
-- * VCluster related constants
4296

    
4297
vClusterEtcHosts :: String
4298
vClusterEtcHosts = "/etc/hosts"
4299

    
4300
vClusterVirtPathPrefix :: String
4301
vClusterVirtPathPrefix = "/###-VIRTUAL-PATH-###,"
4302

    
4303
vClusterRootdirEnvname :: String
4304
vClusterRootdirEnvname = "GANETI_ROOTDIR"
4305

    
4306
vClusterHostnameEnvname :: String
4307
vClusterHostnameEnvname = "GANETI_HOSTNAME"
4308

    
4309
vClusterVpathWhitelist :: FrozenSet String
4310
vClusterVpathWhitelist = ConstantUtils.mkSet [ vClusterEtcHosts ]
4311

    
4312
-- * The source reasons for the execution of an OpCode
4313

    
4314
opcodeReasonSrcClient :: String
4315
opcodeReasonSrcClient = "gnt:client"
4316

    
4317
_opcodeReasonSrcDaemon :: String
4318
_opcodeReasonSrcDaemon = "gnt:daemon"
4319

    
4320
_opcodeReasonSrcMasterd :: String
4321
_opcodeReasonSrcMasterd = _opcodeReasonSrcDaemon ++ ":masterd"
4322

    
4323
opcodeReasonSrcNoded :: String
4324
opcodeReasonSrcNoded = _opcodeReasonSrcDaemon ++ ":noded"
4325

    
4326
opcodeReasonSrcOpcode :: String
4327
opcodeReasonSrcOpcode = "gnt:opcode"
4328

    
4329
opcodeReasonSrcPickup :: String
4330
opcodeReasonSrcPickup = _opcodeReasonSrcMasterd ++ ":pickup"
4331

    
4332
opcodeReasonSrcRlib2 :: String
4333
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4334

    
4335
opcodeReasonSrcUser :: String
4336
opcodeReasonSrcUser = "gnt:user"
4337

    
4338
opcodeReasonSources :: FrozenSet String
4339
opcodeReasonSources =
4340
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4341
                       opcodeReasonSrcNoded,
4342
                       opcodeReasonSrcOpcode,
4343
                       opcodeReasonSrcPickup,
4344
                       opcodeReasonSrcRlib2,
4345
                       opcodeReasonSrcUser]
4346

    
4347
-- | Path generating random UUID
4348
randomUuidFile :: String
4349
randomUuidFile = ConstantUtils.randomUuidFile
4350

    
4351
-- * Auto-repair tag prefixes
4352

    
4353
autoRepairTagPrefix :: String
4354
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4355

    
4356
autoRepairTagEnabled :: String
4357
autoRepairTagEnabled = autoRepairTagPrefix
4358

    
4359
autoRepairTagPending :: String
4360
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4361

    
4362
autoRepairTagResult :: String
4363
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4364

    
4365
autoRepairTagSuspended :: String
4366
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4367

    
4368
-- * Auto-repair levels
4369

    
4370
autoRepairFailover :: String
4371
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4372

    
4373
autoRepairFixStorage :: String
4374
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4375

    
4376
autoRepairMigrate :: String
4377
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4378

    
4379
autoRepairReinstall :: String
4380
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4381

    
4382
autoRepairAllTypes :: FrozenSet String
4383
autoRepairAllTypes =
4384
  ConstantUtils.mkSet [autoRepairFailover,
4385
                       autoRepairFixStorage,
4386
                       autoRepairMigrate,
4387
                       autoRepairReinstall]
4388

    
4389
-- * Auto-repair results
4390

    
4391
autoRepairEnoperm :: String
4392
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4393

    
4394
autoRepairFailure :: String
4395
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4396

    
4397
autoRepairSuccess :: String
4398
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4399

    
4400
autoRepairAllResults :: FrozenSet String
4401
autoRepairAllResults =
4402
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4403

    
4404
-- | The version identifier for builtin data collectors
4405
builtinDataCollectorVersion :: String
4406
builtinDataCollectorVersion = "B"
4407

    
4408
-- | The reason trail opcode parameter name
4409
opcodeReason :: String
4410
opcodeReason = "reason"
4411

    
4412
-- | The reason trail opcode parameter name
4413
opcodeSequential :: String
4414
opcodeSequential = "sequential"
4415

    
4416
diskstatsFile :: String
4417
diskstatsFile = "/proc/diskstats"
4418

    
4419
-- *  CPU load collector
4420

    
4421
statFile :: String
4422
statFile = "/proc/stat"
4423

    
4424
cpuavgloadBufferSize :: Int
4425
cpuavgloadBufferSize = 150
4426

    
4427
cpuavgloadWindowSize :: Int
4428
cpuavgloadWindowSize = 600
4429

    
4430
-- * Monitoring daemon
4431

    
4432
-- | Mond's variable for periodical data collection
4433
mondTimeInterval :: Int
4434
mondTimeInterval = 5
4435

    
4436
-- | Mond's latest API version
4437
mondLatestApiVersion :: Int
4438
mondLatestApiVersion = 1
4439

    
4440
-- * Disk access modes
4441

    
4442
diskUserspace :: String
4443
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4444

    
4445
diskKernelspace :: String
4446
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4447

    
4448
diskValidAccessModes :: FrozenSet String
4449
diskValidAccessModes =
4450
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4451

    
4452
-- | Timeout for queue draining in upgrades
4453
upgradeQueueDrainTimeout :: Int
4454
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4455

    
4456
-- | Intervall at which the queue is polled during upgrades
4457
upgradeQueuePollInterval :: Int
4458
upgradeQueuePollInterval  = 10
4459

    
4460
-- * Hotplug Actions
4461

    
4462
hotplugActionAdd :: String
4463
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4464

    
4465
hotplugActionRemove :: String
4466
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4467

    
4468
hotplugActionModify :: String
4469
hotplugActionModify = Types.hotplugActionToRaw HAMod
4470

    
4471
hotplugAllActions :: FrozenSet String
4472
hotplugAllActions =
4473
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4474

    
4475
-- * Hotplug Device Targets
4476

    
4477
hotplugTargetNic :: String
4478
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4479

    
4480
hotplugTargetDisk :: String
4481
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4482

    
4483
hotplugAllTargets :: FrozenSet String
4484
hotplugAllTargets =
4485
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4486

    
4487
-- | Timeout for disk removal (seconds)
4488
diskRemoveRetryTimeout :: Int
4489
diskRemoveRetryTimeout = 30
4490

    
4491
-- | Interval between disk removal retries (seconds)
4492
diskRemoveRetryInterval :: Int
4493
diskRemoveRetryInterval  = 3
4494

    
4495
-- * UUID regex
4496

    
4497
uuidRegex :: String
4498
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4499

    
4500
-- * Luxi constants
4501

    
4502
luxiSocketPerms :: Int
4503
luxiSocketPerms = 0o660
4504

    
4505
luxiKeyMethod :: String
4506
luxiKeyMethod = "method"
4507

    
4508
luxiKeyArgs :: String
4509
luxiKeyArgs = "args"
4510

    
4511
luxiKeySuccess :: String
4512
luxiKeySuccess = "success"
4513

    
4514
luxiKeyResult :: String
4515
luxiKeyResult = "result"
4516

    
4517
luxiKeyVersion :: String
4518
luxiKeyVersion = "version"
4519

    
4520
luxiReqSubmitJob :: String
4521
luxiReqSubmitJob = "SubmitJob"
4522

    
4523
luxiReqSubmitJobToDrainedQueue :: String
4524
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4525

    
4526
luxiReqSubmitManyJobs :: String
4527
luxiReqSubmitManyJobs = "SubmitManyJobs"
4528

    
4529
luxiReqWaitForJobChange :: String
4530
luxiReqWaitForJobChange = "WaitForJobChange"
4531

    
4532
luxiReqPickupJob :: String
4533
luxiReqPickupJob = "PickupJob"
4534

    
4535
luxiReqCancelJob :: String
4536
luxiReqCancelJob = "CancelJob"
4537

    
4538
luxiReqArchiveJob :: String
4539
luxiReqArchiveJob = "ArchiveJob"
4540

    
4541
luxiReqChangeJobPriority :: String
4542
luxiReqChangeJobPriority = "ChangeJobPriority"
4543

    
4544
luxiReqAutoArchiveJobs :: String
4545
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4546

    
4547
luxiReqQuery :: String
4548
luxiReqQuery = "Query"
4549

    
4550
luxiReqQueryFields :: String
4551
luxiReqQueryFields = "QueryFields"
4552

    
4553
luxiReqQueryJobs :: String
4554
luxiReqQueryJobs = "QueryJobs"
4555

    
4556
luxiReqQueryInstances :: String
4557
luxiReqQueryInstances = "QueryInstances"
4558

    
4559
luxiReqQueryNodes :: String
4560
luxiReqQueryNodes = "QueryNodes"
4561

    
4562
luxiReqQueryGroups :: String
4563
luxiReqQueryGroups = "QueryGroups"
4564

    
4565
luxiReqQueryNetworks :: String
4566
luxiReqQueryNetworks = "QueryNetworks"
4567

    
4568
luxiReqQueryExports :: String
4569
luxiReqQueryExports = "QueryExports"
4570

    
4571
luxiReqQueryConfigValues :: String
4572
luxiReqQueryConfigValues = "QueryConfigValues"
4573

    
4574
luxiReqQueryClusterInfo :: String
4575
luxiReqQueryClusterInfo = "QueryClusterInfo"
4576

    
4577
luxiReqQueryTags :: String
4578
luxiReqQueryTags = "QueryTags"
4579

    
4580
luxiReqSetDrainFlag :: String
4581
luxiReqSetDrainFlag = "SetDrainFlag"
4582

    
4583
luxiReqSetWatcherPause :: String
4584
luxiReqSetWatcherPause = "SetWatcherPause"
4585

    
4586
luxiReqAll :: FrozenSet String
4587
luxiReqAll =
4588
  ConstantUtils.mkSet
4589
  [ luxiReqArchiveJob
4590
  , luxiReqAutoArchiveJobs
4591
  , luxiReqCancelJob
4592
  , luxiReqChangeJobPriority
4593
  , luxiReqQuery
4594
  , luxiReqQueryClusterInfo
4595
  , luxiReqQueryConfigValues
4596
  , luxiReqQueryExports
4597
  , luxiReqQueryFields
4598
  , luxiReqQueryGroups
4599
  , luxiReqQueryInstances
4600
  , luxiReqQueryJobs
4601
  , luxiReqQueryNodes
4602
  , luxiReqQueryNetworks
4603
  , luxiReqQueryTags
4604
  , luxiReqSetDrainFlag
4605
  , luxiReqSetWatcherPause
4606
  , luxiReqSubmitJob
4607
  , luxiReqSubmitJobToDrainedQueue
4608
  , luxiReqSubmitManyJobs
4609
  , luxiReqWaitForJobChange
4610
  , luxiReqPickupJob
4611
  ]
4612

    
4613
luxiDefCtmo :: Int
4614
luxiDefCtmo = 10
4615

    
4616
luxiDefRwto :: Int
4617
luxiDefRwto = 60
4618

    
4619
-- | 'WaitForJobChange' timeout
4620
luxiWfjcTimeout :: Int
4621
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4622

    
4623
-- * Query language constants
4624

    
4625
-- ** Logic operators with one or more operands, each of which is a
4626
-- filter on its own
4627

    
4628
qlangOpAnd :: String
4629
qlangOpAnd = "&"
4630

    
4631
qlangOpOr :: String
4632
qlangOpOr = "|"
4633

    
4634
-- ** Unary operators with exactly one operand
4635

    
4636
qlangOpNot :: String
4637
qlangOpNot = "!"
4638

    
4639
qlangOpTrue :: String
4640
qlangOpTrue = "?"
4641

    
4642
-- ** Binary operators with exactly two operands, the field name and
4643
-- an operator-specific value
4644

    
4645
qlangOpContains :: String
4646
qlangOpContains = "=[]"
4647

    
4648
qlangOpEqual :: String
4649
qlangOpEqual = "="
4650

    
4651
qlangOpGe :: String
4652
qlangOpGe = ">="
4653

    
4654
qlangOpGt :: String
4655
qlangOpGt = ">"
4656

    
4657
qlangOpLe :: String
4658
qlangOpLe = "<="
4659

    
4660
qlangOpLt :: String
4661
qlangOpLt = "<"
4662

    
4663
qlangOpNotEqual :: String
4664
qlangOpNotEqual = "!="
4665

    
4666
qlangOpRegexp :: String
4667
qlangOpRegexp = "=~"
4668

    
4669
-- | Characters used for detecting user-written filters (see
4670
-- L{_CheckFilter})
4671

    
4672
qlangFilterDetectionChars :: FrozenSet String
4673
qlangFilterDetectionChars =
4674
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4675
                       ")", "(", "\x0b", "\n",
4676
                       "\r", "\x0c", "/", "<",
4677
                       "\t", ">", "=", "\\", "~"]
4678

    
4679
-- | Characters used to detect globbing filters
4680
qlangGlobDetectionChars :: FrozenSet String
4681
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4682

    
4683
-- * Error related constants
4684
--
4685
-- 'OpPrereqError' failure types
4686

    
4687
-- | Environment error (e.g. node disk error)
4688
errorsEcodeEnviron :: String
4689
errorsEcodeEnviron = "environment_error"
4690

    
4691
-- | Entity already exists
4692
errorsEcodeExists :: String
4693
errorsEcodeExists = "already_exists"
4694

    
4695
-- | Internal cluster error
4696
errorsEcodeFault :: String
4697
errorsEcodeFault = "internal_error"
4698

    
4699
-- | Wrong arguments (at syntax level)
4700
errorsEcodeInval :: String
4701
errorsEcodeInval = "wrong_input"
4702

    
4703
-- | Entity not found
4704
errorsEcodeNoent :: String
4705
errorsEcodeNoent = "unknown_entity"
4706

    
4707
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4708
errorsEcodeNores :: String
4709
errorsEcodeNores = "insufficient_resources"
4710

    
4711
-- | Resource not unique (e.g. MAC or IP duplication)
4712
errorsEcodeNotunique :: String
4713
errorsEcodeNotunique = "resource_not_unique"
4714

    
4715
-- | Resolver errors
4716
errorsEcodeResolver :: String
4717
errorsEcodeResolver = "resolver_error"
4718

    
4719
-- | Wrong entity state
4720
errorsEcodeState :: String
4721
errorsEcodeState = "wrong_state"
4722

    
4723
-- | Temporarily out of resources; operation can be tried again
4724
errorsEcodeTempNores :: String
4725
errorsEcodeTempNores = "temp_insufficient_resources"
4726

    
4727
errorsEcodeAll :: FrozenSet String
4728
errorsEcodeAll =
4729
  ConstantUtils.mkSet [ errorsEcodeNores
4730
                      , errorsEcodeExists
4731
                      , errorsEcodeState
4732
                      , errorsEcodeNotunique
4733
                      , errorsEcodeTempNores
4734
                      , errorsEcodeNoent
4735
                      , errorsEcodeFault
4736
                      , errorsEcodeResolver
4737
                      , errorsEcodeInval
4738
                      , errorsEcodeEnviron
4739
                      ]
4740

    
4741
-- * Jstore related constants
4742

    
4743
jstoreJobsPerArchiveDirectory :: Int
4744
jstoreJobsPerArchiveDirectory = 10000
4745

    
4746
-- * Gluster settings
4747

    
4748
-- | Name of the Gluster host setting
4749
glusterHost :: String
4750
glusterHost = "host"
4751

    
4752
-- | Default value of the Gluster host setting
4753
glusterHostDefault :: String
4754
glusterHostDefault = "127.0.0.1"
4755

    
4756
-- | Name of the Gluster volume setting
4757
glusterVolume :: String
4758
glusterVolume = "volume"
4759

    
4760
-- | Default value of the Gluster volume setting
4761
glusterVolumeDefault :: String
4762
glusterVolumeDefault = "gv0"
4763

    
4764
-- | Name of the Gluster port setting
4765
glusterPort :: String
4766
glusterPort = "port"
4767

    
4768
-- | Default value of the Gluster port setting
4769
glusterPortDefault :: Int
4770
glusterPortDefault = 24007