Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ c92b4671

History | View | Annotate | Download (118.8 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
fdLoop :: String
975
fdLoop = Types.fileDriverToRaw FileLoop
976

    
977
fdDefault :: String
978
fdDefault = fdLoop
979

    
980
fileDriver :: FrozenSet String
981
fileDriver =
982
  ConstantUtils.mkSet $
983
  map Types.fileDriverToRaw [minBound..]
984

    
985
-- | The set of drbd-like disk types
986
dtsDrbd :: FrozenSet String
987
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
988

    
989
-- * Disk access mode
990

    
991
diskRdonly :: String
992
diskRdonly = Types.diskModeToRaw DiskRdOnly
993

    
994
diskRdwr :: String
995
diskRdwr = Types.diskModeToRaw DiskRdWr
996

    
997
diskAccessSet :: FrozenSet String
998
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
999

    
1000
-- * Disk replacement mode
1001

    
1002
replaceDiskAuto :: String
1003
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
1004

    
1005
replaceDiskChg :: String
1006
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
1007

    
1008
replaceDiskPri :: String
1009
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
1010

    
1011
replaceDiskSec :: String
1012
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
1013

    
1014
replaceModes :: FrozenSet String
1015
replaceModes =
1016
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
1017

    
1018
-- * Instance export mode
1019

    
1020
exportModeLocal :: String
1021
exportModeLocal = Types.exportModeToRaw ExportModeLocal
1022

    
1023
exportModeRemote :: String
1024
exportModeRemote = Types.exportModeToRaw ExportModeRemote
1025

    
1026
exportModes :: FrozenSet String
1027
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
1028

    
1029
-- * Instance creation modes
1030

    
1031
instanceCreate :: String
1032
instanceCreate = Types.instCreateModeToRaw InstCreate
1033

    
1034
instanceImport :: String
1035
instanceImport = Types.instCreateModeToRaw InstImport
1036

    
1037
instanceRemoteImport :: String
1038
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1039

    
1040
instanceCreateModes :: FrozenSet String
1041
instanceCreateModes =
1042
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1043

    
1044
-- * Remote import/export handshake message and version
1045

    
1046
rieHandshake :: String
1047
rieHandshake = "Hi, I'm Ganeti"
1048

    
1049
rieVersion :: Int
1050
rieVersion = 0
1051

    
1052
-- | Remote import/export certificate validity (seconds)
1053
rieCertValidity :: Int
1054
rieCertValidity = 24 * 60 * 60
1055

    
1056
-- | Export only: how long to wait per connection attempt (seconds)
1057
rieConnectAttemptTimeout :: Int
1058
rieConnectAttemptTimeout = 20
1059

    
1060
-- | Export only: number of attempts to connect
1061
rieConnectRetries :: Int
1062
rieConnectRetries = 10
1063

    
1064
-- | Overall timeout for establishing connection
1065
rieConnectTimeout :: Int
1066
rieConnectTimeout = 180
1067

    
1068
-- | Give child process up to 5 seconds to exit after sending a signal
1069
childLingerTimeout :: Double
1070
childLingerTimeout = 5.0
1071

    
1072
-- * Import/export config options
1073

    
1074
inisectBep :: String
1075
inisectBep = "backend"
1076

    
1077
inisectExp :: String
1078
inisectExp = "export"
1079

    
1080
inisectHyp :: String
1081
inisectHyp = "hypervisor"
1082

    
1083
inisectIns :: String
1084
inisectIns = "instance"
1085

    
1086
inisectOsp :: String
1087
inisectOsp = "os"
1088

    
1089
-- * Dynamic device modification
1090

    
1091
ddmAdd :: String
1092
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1093

    
1094
ddmModify :: String
1095
ddmModify = Types.ddmFullToRaw DdmFullModify
1096

    
1097
ddmRemove :: String
1098
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1099

    
1100
ddmsValues :: FrozenSet String
1101
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1102

    
1103
ddmsValuesWithModify :: FrozenSet String
1104
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1105

    
1106
-- * Common exit codes
1107

    
1108
exitSuccess :: Int
1109
exitSuccess = 0
1110

    
1111
exitFailure :: Int
1112
exitFailure = ConstantUtils.exitFailure
1113

    
1114
exitNotcluster :: Int
1115
exitNotcluster = 5
1116

    
1117
exitNotmaster :: Int
1118
exitNotmaster = 11
1119

    
1120
exitNodesetupError :: Int
1121
exitNodesetupError = 12
1122

    
1123
-- | Need user confirmation
1124
exitConfirmation :: Int
1125
exitConfirmation = 13
1126

    
1127
-- | Exit code for query operations with unknown fields
1128
exitUnknownField :: Int
1129
exitUnknownField = 14
1130

    
1131
-- * Tags
1132

    
1133
tagCluster :: String
1134
tagCluster = Types.tagKindToRaw TagKindCluster
1135

    
1136
tagInstance :: String
1137
tagInstance = Types.tagKindToRaw TagKindInstance
1138

    
1139
tagNetwork :: String
1140
tagNetwork = Types.tagKindToRaw TagKindNetwork
1141

    
1142
tagNode :: String
1143
tagNode = Types.tagKindToRaw TagKindNode
1144

    
1145
tagNodegroup :: String
1146
tagNodegroup = Types.tagKindToRaw TagKindGroup
1147

    
1148
validTagTypes :: FrozenSet String
1149
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1150

    
1151
maxTagLen :: Int
1152
maxTagLen = 128
1153

    
1154
maxTagsPerObj :: Int
1155
maxTagsPerObj = 4096
1156

    
1157
-- * Others
1158

    
1159
defaultBridge :: String
1160
defaultBridge = "xen-br0"
1161

    
1162
defaultOvs :: String
1163
defaultOvs = "switch1"
1164

    
1165
-- | 60 MiB/s, expressed in KiB/s
1166
classicDrbdSyncSpeed :: Int
1167
classicDrbdSyncSpeed = 60 * 1024
1168

    
1169
ip4AddressAny :: String
1170
ip4AddressAny = "0.0.0.0"
1171

    
1172
ip4AddressLocalhost :: String
1173
ip4AddressLocalhost = "127.0.0.1"
1174

    
1175
ip6AddressAny :: String
1176
ip6AddressAny = "::"
1177

    
1178
ip6AddressLocalhost :: String
1179
ip6AddressLocalhost = "::1"
1180

    
1181
ip4Version :: Int
1182
ip4Version = 4
1183

    
1184
ip6Version :: Int
1185
ip6Version = 6
1186

    
1187
validIpVersions :: FrozenSet Int
1188
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1189

    
1190
tcpPingTimeout :: Int
1191
tcpPingTimeout = 10
1192

    
1193
defaultVg :: String
1194
defaultVg = "xenvg"
1195

    
1196
defaultDrbdHelper :: String
1197
defaultDrbdHelper = "/bin/true"
1198

    
1199
minVgSize :: Int
1200
minVgSize = 20480
1201

    
1202
defaultMacPrefix :: String
1203
defaultMacPrefix = "aa:00:00"
1204

    
1205
-- | Default maximum instance wait time (seconds)
1206
defaultShutdownTimeout :: Int
1207
defaultShutdownTimeout = 120
1208

    
1209
-- | Node clock skew (seconds)
1210
nodeMaxClockSkew :: Int
1211
nodeMaxClockSkew = 150
1212

    
1213
-- | Time for an intra-cluster disk transfer to wait for a connection
1214
diskTransferConnectTimeout :: Int
1215
diskTransferConnectTimeout = 60
1216

    
1217
-- | Disk index separator
1218
diskSeparator :: String
1219
diskSeparator = AutoConf.diskSeparator
1220

    
1221
ipCommandPath :: String
1222
ipCommandPath = AutoConf.ipPath
1223

    
1224
-- | Key for job IDs in opcode result
1225
jobIdsKey :: String
1226
jobIdsKey = "jobs"
1227

    
1228
-- * Runparts results
1229

    
1230
runpartsErr :: Int
1231
runpartsErr = 2
1232

    
1233
runpartsRun :: Int
1234
runpartsRun = 1
1235

    
1236
runpartsSkip :: Int
1237
runpartsSkip = 0
1238

    
1239
runpartsStatus :: [Int]
1240
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1241

    
1242
-- * RPC
1243

    
1244
rpcEncodingNone :: Int
1245
rpcEncodingNone = 0
1246

    
1247
rpcEncodingZlibBase64 :: Int
1248
rpcEncodingZlibBase64 = 1
1249

    
1250
-- * Timeout table
1251
--
1252
-- Various time constants for the timeout table
1253

    
1254
rpcTmoUrgent :: Int
1255
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1256

    
1257
rpcTmoFast :: Int
1258
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1259

    
1260
rpcTmoNormal :: Int
1261
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1262

    
1263
rpcTmoSlow :: Int
1264
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1265

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

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

    
1278
-- | Timeout for connecting to nodes (seconds)
1279
rpcConnectTimeout :: Int
1280
rpcConnectTimeout = 5
1281

    
1282
-- OS
1283

    
1284
osScriptCreate :: String
1285
osScriptCreate = "create"
1286

    
1287
osScriptExport :: String
1288
osScriptExport = "export"
1289

    
1290
osScriptImport :: String
1291
osScriptImport = "import"
1292

    
1293
osScriptRename :: String
1294
osScriptRename = "rename"
1295

    
1296
osScriptVerify :: String
1297
osScriptVerify = "verify"
1298

    
1299
osScripts :: [String]
1300
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1301
             osScriptVerify]
1302

    
1303
osApiFile :: String
1304
osApiFile = "ganeti_api_version"
1305

    
1306
osVariantsFile :: String
1307
osVariantsFile = "variants.list"
1308

    
1309
osParametersFile :: String
1310
osParametersFile = "parameters.list"
1311

    
1312
osValidateParameters :: String
1313
osValidateParameters = "parameters"
1314

    
1315
osValidateCalls :: FrozenSet String
1316
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1317

    
1318
-- | External Storage (ES) related constants
1319

    
1320
esActionAttach :: String
1321
esActionAttach = "attach"
1322

    
1323
esActionCreate :: String
1324
esActionCreate = "create"
1325

    
1326
esActionDetach :: String
1327
esActionDetach = "detach"
1328

    
1329
esActionGrow :: String
1330
esActionGrow = "grow"
1331

    
1332
esActionRemove :: String
1333
esActionRemove = "remove"
1334

    
1335
esActionSetinfo :: String
1336
esActionSetinfo = "setinfo"
1337

    
1338
esActionVerify :: String
1339
esActionVerify = "verify"
1340

    
1341
esScriptCreate :: String
1342
esScriptCreate = esActionCreate
1343

    
1344
esScriptRemove :: String
1345
esScriptRemove = esActionRemove
1346

    
1347
esScriptGrow :: String
1348
esScriptGrow = esActionGrow
1349

    
1350
esScriptAttach :: String
1351
esScriptAttach = esActionAttach
1352

    
1353
esScriptDetach :: String
1354
esScriptDetach = esActionDetach
1355

    
1356
esScriptSetinfo :: String
1357
esScriptSetinfo = esActionSetinfo
1358

    
1359
esScriptVerify :: String
1360
esScriptVerify = esActionVerify
1361

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

    
1372
esParametersFile :: String
1373
esParametersFile = "parameters.list"
1374

    
1375
-- * Reboot types
1376

    
1377
instanceRebootSoft :: String
1378
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1379

    
1380
instanceRebootHard :: String
1381
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1382

    
1383
instanceRebootFull :: String
1384
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1385

    
1386
rebootTypes :: FrozenSet String
1387
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1388

    
1389
-- * Instance reboot behaviors
1390

    
1391
instanceRebootAllowed :: String
1392
instanceRebootAllowed = "reboot"
1393

    
1394
instanceRebootExit :: String
1395
instanceRebootExit = "exit"
1396

    
1397
rebootBehaviors :: [String]
1398
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1399

    
1400
-- * VTypes
1401

    
1402
vtypeBool :: VType
1403
vtypeBool = VTypeBool
1404

    
1405
vtypeInt :: VType
1406
vtypeInt = VTypeInt
1407

    
1408
vtypeMaybeString :: VType
1409
vtypeMaybeString = VTypeMaybeString
1410

    
1411
-- | Size in MiBs
1412
vtypeSize :: VType
1413
vtypeSize = VTypeSize
1414

    
1415
vtypeString :: VType
1416
vtypeString = VTypeString
1417

    
1418
enforceableTypes :: FrozenSet VType
1419
enforceableTypes = ConstantUtils.mkSet [minBound..]
1420

    
1421
-- | Constant representing that the user does not specify any IP version
1422
ifaceNoIpVersionSpecified :: Int
1423
ifaceNoIpVersionSpecified = 0
1424

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

    
1446
-- * HV parameter names (global namespace)
1447

    
1448
hvAcpi :: String
1449
hvAcpi = "acpi"
1450

    
1451
hvBlockdevPrefix :: String
1452
hvBlockdevPrefix = "blockdev_prefix"
1453

    
1454
hvBootloaderArgs :: String
1455
hvBootloaderArgs = "bootloader_args"
1456

    
1457
hvBootloaderPath :: String
1458
hvBootloaderPath = "bootloader_path"
1459

    
1460
hvBootOrder :: String
1461
hvBootOrder = "boot_order"
1462

    
1463
hvCdromImagePath :: String
1464
hvCdromImagePath = "cdrom_image_path"
1465

    
1466
hvCpuCap :: String
1467
hvCpuCap = "cpu_cap"
1468

    
1469
hvCpuCores :: String
1470
hvCpuCores = "cpu_cores"
1471

    
1472
hvCpuMask :: String
1473
hvCpuMask = "cpu_mask"
1474

    
1475
hvCpuSockets :: String
1476
hvCpuSockets = "cpu_sockets"
1477

    
1478
hvCpuThreads :: String
1479
hvCpuThreads = "cpu_threads"
1480

    
1481
hvCpuType :: String
1482
hvCpuType = "cpu_type"
1483

    
1484
hvCpuWeight :: String
1485
hvCpuWeight = "cpu_weight"
1486

    
1487
hvDeviceModel :: String
1488
hvDeviceModel = "device_model"
1489

    
1490
hvDiskCache :: String
1491
hvDiskCache = "disk_cache"
1492

    
1493
hvDiskType :: String
1494
hvDiskType = "disk_type"
1495

    
1496
hvInitrdPath :: String
1497
hvInitrdPath = "initrd_path"
1498

    
1499
hvInitScript :: String
1500
hvInitScript = "init_script"
1501

    
1502
hvKernelArgs :: String
1503
hvKernelArgs = "kernel_args"
1504

    
1505
hvKernelPath :: String
1506
hvKernelPath = "kernel_path"
1507

    
1508
hvKeymap :: String
1509
hvKeymap = "keymap"
1510

    
1511
hvKvmCdrom2ImagePath :: String
1512
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1513

    
1514
hvKvmCdromDiskType :: String
1515
hvKvmCdromDiskType = "cdrom_disk_type"
1516

    
1517
hvKvmExtra :: String
1518
hvKvmExtra = "kvm_extra"
1519

    
1520
hvKvmFlag :: String
1521
hvKvmFlag = "kvm_flag"
1522

    
1523
hvKvmFloppyImagePath :: String
1524
hvKvmFloppyImagePath = "floppy_image_path"
1525

    
1526
hvKvmMachineVersion :: String
1527
hvKvmMachineVersion = "machine_version"
1528

    
1529
hvKvmPath :: String
1530
hvKvmPath = "kvm_path"
1531

    
1532
hvKvmSpiceAudioCompr :: String
1533
hvKvmSpiceAudioCompr = "spice_playback_compression"
1534

    
1535
hvKvmSpiceBind :: String
1536
hvKvmSpiceBind = "spice_bind"
1537

    
1538
hvKvmSpiceIpVersion :: String
1539
hvKvmSpiceIpVersion = "spice_ip_version"
1540

    
1541
hvKvmSpiceJpegImgCompr :: String
1542
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1543

    
1544
hvKvmSpiceLosslessImgCompr :: String
1545
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1546

    
1547
hvKvmSpicePasswordFile :: String
1548
hvKvmSpicePasswordFile = "spice_password_file"
1549

    
1550
hvKvmSpiceStreamingVideoDetection :: String
1551
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1552

    
1553
hvKvmSpiceTlsCiphers :: String
1554
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1555

    
1556
hvKvmSpiceUseTls :: String
1557
hvKvmSpiceUseTls = "spice_use_tls"
1558

    
1559
hvKvmSpiceUseVdagent :: String
1560
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1561

    
1562
hvKvmSpiceZlibGlzImgCompr :: String
1563
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1564

    
1565
hvKvmUseChroot :: String
1566
hvKvmUseChroot = "use_chroot"
1567

    
1568
hvKvmUserShutdown :: String
1569
hvKvmUserShutdown = "user_shutdown"
1570

    
1571
hvMemPath :: String
1572
hvMemPath = "mem_path"
1573

    
1574
hvMigrationBandwidth :: String
1575
hvMigrationBandwidth = "migration_bandwidth"
1576

    
1577
hvMigrationDowntime :: String
1578
hvMigrationDowntime = "migration_downtime"
1579

    
1580
hvMigrationMode :: String
1581
hvMigrationMode = "migration_mode"
1582

    
1583
hvMigrationPort :: String
1584
hvMigrationPort = "migration_port"
1585

    
1586
hvNicType :: String
1587
hvNicType = "nic_type"
1588

    
1589
hvPae :: String
1590
hvPae = "pae"
1591

    
1592
hvPassthrough :: String
1593
hvPassthrough = "pci_pass"
1594

    
1595
hvRebootBehavior :: String
1596
hvRebootBehavior = "reboot_behavior"
1597

    
1598
hvRootPath :: String
1599
hvRootPath = "root_path"
1600

    
1601
hvSecurityDomain :: String
1602
hvSecurityDomain = "security_domain"
1603

    
1604
hvSecurityModel :: String
1605
hvSecurityModel = "security_model"
1606

    
1607
hvSerialConsole :: String
1608
hvSerialConsole = "serial_console"
1609

    
1610
hvSerialSpeed :: String
1611
hvSerialSpeed = "serial_speed"
1612

    
1613
hvSoundhw :: String
1614
hvSoundhw = "soundhw"
1615

    
1616
hvUsbDevices :: String
1617
hvUsbDevices = "usb_devices"
1618

    
1619
hvUsbMouse :: String
1620
hvUsbMouse = "usb_mouse"
1621

    
1622
hvUseBootloader :: String
1623
hvUseBootloader = "use_bootloader"
1624

    
1625
hvUseLocaltime :: String
1626
hvUseLocaltime = "use_localtime"
1627

    
1628
hvVga :: String
1629
hvVga = "vga"
1630

    
1631
hvVhostNet :: String
1632
hvVhostNet = "vhost_net"
1633

    
1634
hvVifScript :: String
1635
hvVifScript = "vif_script"
1636

    
1637
hvVifType :: String
1638
hvVifType = "vif_type"
1639

    
1640
hvViridian :: String
1641
hvViridian = "viridian"
1642

    
1643
hvVncBindAddress :: String
1644
hvVncBindAddress = "vnc_bind_address"
1645

    
1646
hvVncPasswordFile :: String
1647
hvVncPasswordFile = "vnc_password_file"
1648

    
1649
hvVncTls :: String
1650
hvVncTls = "vnc_tls"
1651

    
1652
hvVncX509 :: String
1653
hvVncX509 = "vnc_x509_path"
1654

    
1655
hvVncX509Verify :: String
1656
hvVncX509Verify = "vnc_x509_verify"
1657

    
1658
hvVnetHdr :: String
1659
hvVnetHdr = "vnet_hdr"
1660

    
1661
hvXenCmd :: String
1662
hvXenCmd = "xen_cmd"
1663

    
1664
hvXenCpuid :: String
1665
hvXenCpuid = "cpuid"
1666

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

    
1682
hvsParameters :: FrozenSet String
1683
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1684

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

    
1762
-- * Migration statuses
1763

    
1764
hvMigrationActive :: String
1765
hvMigrationActive = "active"
1766

    
1767
hvMigrationCancelled :: String
1768
hvMigrationCancelled = "cancelled"
1769

    
1770
hvMigrationCompleted :: String
1771
hvMigrationCompleted = "completed"
1772

    
1773
hvMigrationFailed :: String
1774
hvMigrationFailed = "failed"
1775

    
1776
hvMigrationValidStatuses :: FrozenSet String
1777
hvMigrationValidStatuses =
1778
  ConstantUtils.mkSet [hvMigrationActive,
1779
                       hvMigrationCancelled,
1780
                       hvMigrationCompleted,
1781
                       hvMigrationFailed]
1782

    
1783
hvMigrationFailedStatuses :: FrozenSet String
1784
hvMigrationFailedStatuses =
1785
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1786

    
1787
-- | KVM-specific statuses
1788
--
1789
-- FIXME: this constant seems unnecessary
1790
hvKvmMigrationValidStatuses :: FrozenSet String
1791
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1792

    
1793
-- | Node info keys
1794
hvNodeinfoKeyVersion :: String
1795
hvNodeinfoKeyVersion = "hv_version"
1796

    
1797
-- * Hypervisor state
1798

    
1799
hvstCpuNode :: String
1800
hvstCpuNode = "cpu_node"
1801

    
1802
hvstCpuTotal :: String
1803
hvstCpuTotal = "cpu_total"
1804

    
1805
hvstMemoryHv :: String
1806
hvstMemoryHv = "mem_hv"
1807

    
1808
hvstMemoryNode :: String
1809
hvstMemoryNode = "mem_node"
1810

    
1811
hvstMemoryTotal :: String
1812
hvstMemoryTotal = "mem_total"
1813

    
1814
hvstsParameters :: FrozenSet String
1815
hvstsParameters =
1816
  ConstantUtils.mkSet [hvstCpuNode,
1817
                       hvstCpuTotal,
1818
                       hvstMemoryHv,
1819
                       hvstMemoryNode,
1820
                       hvstMemoryTotal]
1821

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

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

    
1839
-- * Disk state
1840

    
1841
dsDiskOverhead :: String
1842
dsDiskOverhead = "disk_overhead"
1843

    
1844
dsDiskReserved :: String
1845
dsDiskReserved = "disk_reserved"
1846

    
1847
dsDiskTotal :: String
1848
dsDiskTotal = "disk_total"
1849

    
1850
dsDefaults :: Map String Int
1851
dsDefaults =
1852
  Map.fromList
1853
  [(dsDiskTotal, 0),
1854
   (dsDiskReserved, 0),
1855
   (dsDiskOverhead, 0)]
1856

    
1857
dssParameterTypes :: Map String VType
1858
dssParameterTypes =
1859
  Map.fromList [(dsDiskTotal, VTypeInt),
1860
                (dsDiskReserved, VTypeInt),
1861
                (dsDiskOverhead, VTypeInt)]
1862

    
1863
dssParameters :: FrozenSet String
1864
dssParameters =
1865
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1866

    
1867
dsValidTypes :: FrozenSet String
1868
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1869

    
1870
-- Backend parameter names
1871

    
1872
beAlwaysFailover :: String
1873
beAlwaysFailover = "always_failover"
1874

    
1875
beAutoBalance :: String
1876
beAutoBalance = "auto_balance"
1877

    
1878
beMaxmem :: String
1879
beMaxmem = "maxmem"
1880

    
1881
-- | Deprecated and replaced by max and min mem
1882
beMemory :: String
1883
beMemory = "memory"
1884

    
1885
beMinmem :: String
1886
beMinmem = "minmem"
1887

    
1888
beSpindleUse :: String
1889
beSpindleUse = "spindle_use"
1890

    
1891
beVcpus :: String
1892
beVcpus = "vcpus"
1893

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

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

    
1910
besParameterCompat :: Map String VType
1911
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1912

    
1913
besParameters :: FrozenSet String
1914
besParameters =
1915
  ConstantUtils.mkSet [beAlwaysFailover,
1916
                       beAutoBalance,
1917
                       beMaxmem,
1918
                       beMinmem,
1919
                       beSpindleUse,
1920
                       beVcpus]
1921

    
1922
-- | Instance specs
1923
--
1924
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1925

    
1926
ispecMemSize :: String
1927
ispecMemSize = ConstantUtils.ispecMemSize
1928

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

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

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

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

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

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

    
1954
ispecsParameters :: FrozenSet String
1955
ispecsParameters =
1956
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1957
                       ConstantUtils.ispecDiskCount,
1958
                       ConstantUtils.ispecDiskSize,
1959
                       ConstantUtils.ispecMemSize,
1960
                       ConstantUtils.ispecNicCount,
1961
                       ConstantUtils.ispecSpindleUse]
1962

    
1963
ispecsMinmax :: String
1964
ispecsMinmax = ConstantUtils.ispecsMinmax
1965

    
1966
ispecsMax :: String
1967
ispecsMax = "max"
1968

    
1969
ispecsMin :: String
1970
ispecsMin = "min"
1971

    
1972
ispecsStd :: String
1973
ispecsStd = ConstantUtils.ispecsStd
1974

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

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

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

    
1984
ispecsMinmaxKeys :: FrozenSet String
1985
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1986

    
1987
ipolicyParameters :: FrozenSet String
1988
ipolicyParameters =
1989
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1990
                       ConstantUtils.ipolicySpindleRatio]
1991

    
1992
ipolicyAllKeys :: FrozenSet String
1993
ipolicyAllKeys =
1994
  ConstantUtils.union ipolicyParameters $
1995
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1996
                       ConstantUtils.ispecsMinmax,
1997
                       ispecsStd]
1998

    
1999
-- | Node parameter names
2000

    
2001
ndExclusiveStorage :: String
2002
ndExclusiveStorage = "exclusive_storage"
2003

    
2004
ndOobProgram :: String
2005
ndOobProgram = "oob_program"
2006

    
2007
ndSpindleCount :: String
2008
ndSpindleCount = "spindle_count"
2009

    
2010
ndOvs :: String
2011
ndOvs = "ovs"
2012

    
2013
ndOvsLink :: String
2014
ndOvsLink = "ovs_link"
2015

    
2016
ndOvsName :: String
2017
ndOvsName = "ovs_name"
2018

    
2019
ndSshPort :: String
2020
ndSshPort = "ssh_port"
2021

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

    
2033
ndsParameters :: FrozenSet String
2034
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
2035

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

    
2046
-- * Logical Disks parameters
2047

    
2048
ldpAccess :: String
2049
ldpAccess = "access"
2050

    
2051
ldpBarriers :: String
2052
ldpBarriers = "disabled-barriers"
2053

    
2054
ldpDefaultMetavg :: String
2055
ldpDefaultMetavg = "default-metavg"
2056

    
2057
ldpDelayTarget :: String
2058
ldpDelayTarget = "c-delay-target"
2059

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

    
2063
ldpDynamicResync :: String
2064
ldpDynamicResync = "dynamic-resync"
2065

    
2066
ldpFillTarget :: String
2067
ldpFillTarget = "c-fill-target"
2068

    
2069
ldpMaxRate :: String
2070
ldpMaxRate = "c-max-rate"
2071

    
2072
ldpMinRate :: String
2073
ldpMinRate = "c-min-rate"
2074

    
2075
ldpNetCustom :: String
2076
ldpNetCustom = "net-custom"
2077

    
2078
ldpNoMetaFlush :: String
2079
ldpNoMetaFlush = "disable-meta-flush"
2080

    
2081
ldpPlanAhead :: String
2082
ldpPlanAhead = "c-plan-ahead"
2083

    
2084
ldpPool :: String
2085
ldpPool = "pool"
2086

    
2087
ldpProtocol :: String
2088
ldpProtocol = "protocol"
2089

    
2090
ldpResyncRate :: String
2091
ldpResyncRate = "resync-rate"
2092

    
2093
ldpStripes :: String
2094
ldpStripes = "stripes"
2095

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

    
2116
diskLdParameters :: FrozenSet String
2117
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2118

    
2119
-- * Disk template parameters
2120
--
2121
-- Disk template parameters can be set/changed by the user via
2122
-- gnt-cluster and gnt-group)
2123

    
2124
drbdResyncRate :: String
2125
drbdResyncRate = "resync-rate"
2126

    
2127
drbdDataStripes :: String
2128
drbdDataStripes = "data-stripes"
2129

    
2130
drbdMetaStripes :: String
2131
drbdMetaStripes = "meta-stripes"
2132

    
2133
drbdDiskBarriers :: String
2134
drbdDiskBarriers = "disk-barriers"
2135

    
2136
drbdMetaBarriers :: String
2137
drbdMetaBarriers = "meta-barriers"
2138

    
2139
drbdDefaultMetavg :: String
2140
drbdDefaultMetavg = "metavg"
2141

    
2142
drbdDiskCustom :: String
2143
drbdDiskCustom = "disk-custom"
2144

    
2145
drbdNetCustom :: String
2146
drbdNetCustom = "net-custom"
2147

    
2148
drbdProtocol :: String
2149
drbdProtocol = "protocol"
2150

    
2151
drbdDynamicResync :: String
2152
drbdDynamicResync = "dynamic-resync"
2153

    
2154
drbdPlanAhead :: String
2155
drbdPlanAhead = "c-plan-ahead"
2156

    
2157
drbdFillTarget :: String
2158
drbdFillTarget = "c-fill-target"
2159

    
2160
drbdDelayTarget :: String
2161
drbdDelayTarget = "c-delay-target"
2162

    
2163
drbdMaxRate :: String
2164
drbdMaxRate = "c-max-rate"
2165

    
2166
drbdMinRate :: String
2167
drbdMinRate = "c-min-rate"
2168

    
2169
lvStripes :: String
2170
lvStripes = "stripes"
2171

    
2172
rbdAccess :: String
2173
rbdAccess = "access"
2174

    
2175
rbdPool :: String
2176
rbdPool = "pool"
2177

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

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

    
2206
-- * Dynamic disk parameters
2207

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

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

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

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

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

    
2223
-- * OOB supported commands
2224

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2351
idiskParams :: FrozenSet String
2352
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2353

    
2354
modifiableIdiskParamsTypes :: Map String VType
2355
modifiableIdiskParamsTypes =
2356
  Map.fromList [(idiskMode, VTypeString),
2357
                (idiskName, VTypeString)]
2358

    
2359
modifiableIdiskParams :: FrozenSet String
2360
modifiableIdiskParams =
2361
  ConstantUtils.mkSet (Map.keys modifiableIdiskParamsTypes)
2362

    
2363
-- * inic* constants are used in opcodes, to create/change nics
2364

    
2365
inicBridge :: String
2366
inicBridge = "bridge"
2367

    
2368
inicIp :: String
2369
inicIp = "ip"
2370

    
2371
inicLink :: String
2372
inicLink = "link"
2373

    
2374
inicMac :: String
2375
inicMac = "mac"
2376

    
2377
inicMode :: String
2378
inicMode = "mode"
2379

    
2380
inicName :: String
2381
inicName = "name"
2382

    
2383
inicNetwork :: String
2384
inicNetwork = "network"
2385

    
2386
inicVlan :: String
2387
inicVlan = "vlan"
2388

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

    
2400
inicParams :: FrozenSet String
2401
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2402

    
2403
-- * Hypervisor constants
2404

    
2405
htXenPvm :: String
2406
htXenPvm = Types.hypervisorToRaw XenPvm
2407

    
2408
htFake :: String
2409
htFake = Types.hypervisorToRaw Fake
2410

    
2411
htXenHvm :: String
2412
htXenHvm = Types.hypervisorToRaw XenHvm
2413

    
2414
htKvm :: String
2415
htKvm = Types.hypervisorToRaw Kvm
2416

    
2417
htChroot :: String
2418
htChroot = Types.hypervisorToRaw Chroot
2419

    
2420
htLxc :: String
2421
htLxc = Types.hypervisorToRaw Lxc
2422

    
2423
hyperTypes :: FrozenSet String
2424
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2425

    
2426
htsReqPort :: FrozenSet String
2427
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2428

    
2429
vncBasePort :: Int
2430
vncBasePort = 5900
2431

    
2432
vncDefaultBindAddress :: String
2433
vncDefaultBindAddress = ip4AddressAny
2434

    
2435
-- * NIC types
2436

    
2437
htNicE1000 :: String
2438
htNicE1000 = "e1000"
2439

    
2440
htNicI82551 :: String
2441
htNicI82551 = "i82551"
2442

    
2443
htNicI8259er :: String
2444
htNicI8259er = "i82559er"
2445

    
2446
htNicI85557b :: String
2447
htNicI85557b = "i82557b"
2448

    
2449
htNicNe2kIsa :: String
2450
htNicNe2kIsa = "ne2k_isa"
2451

    
2452
htNicNe2kPci :: String
2453
htNicNe2kPci = "ne2k_pci"
2454

    
2455
htNicParavirtual :: String
2456
htNicParavirtual = "paravirtual"
2457

    
2458
htNicPcnet :: String
2459
htNicPcnet = "pcnet"
2460

    
2461
htNicRtl8139 :: String
2462
htNicRtl8139 = "rtl8139"
2463

    
2464
htHvmValidNicTypes :: FrozenSet String
2465
htHvmValidNicTypes =
2466
  ConstantUtils.mkSet [htNicE1000,
2467
                       htNicNe2kIsa,
2468
                       htNicNe2kPci,
2469
                       htNicParavirtual,
2470
                       htNicRtl8139]
2471

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

    
2484
-- * Vif types
2485

    
2486
-- | Default vif type in xen-hvm
2487
htHvmVifIoemu :: String
2488
htHvmVifIoemu = "ioemu"
2489

    
2490
htHvmVifVif :: String
2491
htHvmVifVif = "vif"
2492

    
2493
htHvmValidVifTypes :: FrozenSet String
2494
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2495

    
2496
-- * Disk types
2497

    
2498
htDiskIde :: String
2499
htDiskIde = "ide"
2500

    
2501
htDiskIoemu :: String
2502
htDiskIoemu = "ioemu"
2503

    
2504
htDiskMtd :: String
2505
htDiskMtd = "mtd"
2506

    
2507
htDiskParavirtual :: String
2508
htDiskParavirtual = "paravirtual"
2509

    
2510
htDiskPflash :: String
2511
htDiskPflash = "pflash"
2512

    
2513
htDiskScsi :: String
2514
htDiskScsi = "scsi"
2515

    
2516
htDiskSd :: String
2517
htDiskSd = "sd"
2518

    
2519
htHvmValidDiskTypes :: FrozenSet String
2520
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2521

    
2522
htKvmValidDiskTypes :: FrozenSet String
2523
htKvmValidDiskTypes =
2524
  ConstantUtils.mkSet [htDiskIde,
2525
                       htDiskMtd,
2526
                       htDiskParavirtual,
2527
                       htDiskPflash,
2528
                       htDiskScsi,
2529
                       htDiskSd]
2530

    
2531
htCacheDefault :: String
2532
htCacheDefault = "default"
2533

    
2534
htCacheNone :: String
2535
htCacheNone = "none"
2536

    
2537
htCacheWback :: String
2538
htCacheWback = "writeback"
2539

    
2540
htCacheWthrough :: String
2541
htCacheWthrough = "writethrough"
2542

    
2543
htValidCacheTypes :: FrozenSet String
2544
htValidCacheTypes =
2545
  ConstantUtils.mkSet [htCacheDefault,
2546
                       htCacheNone,
2547
                       htCacheWback,
2548
                       htCacheWthrough]
2549

    
2550
-- * Mouse types
2551

    
2552
htMouseMouse :: String
2553
htMouseMouse = "mouse"
2554

    
2555
htMouseTablet :: String
2556
htMouseTablet = "tablet"
2557

    
2558
htKvmValidMouseTypes :: FrozenSet String
2559
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2560

    
2561
-- * Boot order
2562

    
2563
htBoCdrom :: String
2564
htBoCdrom = "cdrom"
2565

    
2566
htBoDisk :: String
2567
htBoDisk = "disk"
2568

    
2569
htBoFloppy :: String
2570
htBoFloppy = "floppy"
2571

    
2572
htBoNetwork :: String
2573
htBoNetwork = "network"
2574

    
2575
htKvmValidBoTypes :: FrozenSet String
2576
htKvmValidBoTypes =
2577
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2578

    
2579
-- * SPICE lossless image compression options
2580

    
2581
htKvmSpiceLosslessImgComprAutoGlz :: String
2582
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2583

    
2584
htKvmSpiceLosslessImgComprAutoLz :: String
2585
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2586

    
2587
htKvmSpiceLosslessImgComprGlz :: String
2588
htKvmSpiceLosslessImgComprGlz = "glz"
2589

    
2590
htKvmSpiceLosslessImgComprLz :: String
2591
htKvmSpiceLosslessImgComprLz = "lz"
2592

    
2593
htKvmSpiceLosslessImgComprOff :: String
2594
htKvmSpiceLosslessImgComprOff = "off"
2595

    
2596
htKvmSpiceLosslessImgComprQuic :: String
2597
htKvmSpiceLosslessImgComprQuic = "quic"
2598

    
2599
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2600
htKvmSpiceValidLosslessImgComprOptions =
2601
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2602
                       htKvmSpiceLosslessImgComprAutoLz,
2603
                       htKvmSpiceLosslessImgComprGlz,
2604
                       htKvmSpiceLosslessImgComprLz,
2605
                       htKvmSpiceLosslessImgComprOff,
2606
                       htKvmSpiceLosslessImgComprQuic]
2607

    
2608
htKvmSpiceLossyImgComprAlways :: String
2609
htKvmSpiceLossyImgComprAlways = "always"
2610

    
2611
htKvmSpiceLossyImgComprAuto :: String
2612
htKvmSpiceLossyImgComprAuto = "auto"
2613

    
2614
htKvmSpiceLossyImgComprNever :: String
2615
htKvmSpiceLossyImgComprNever = "never"
2616

    
2617
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2618
htKvmSpiceValidLossyImgComprOptions =
2619
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2620
                       htKvmSpiceLossyImgComprAuto,
2621
                       htKvmSpiceLossyImgComprNever]
2622

    
2623
-- * SPICE video stream detection
2624

    
2625
htKvmSpiceVideoStreamDetectionAll :: String
2626
htKvmSpiceVideoStreamDetectionAll = "all"
2627

    
2628
htKvmSpiceVideoStreamDetectionFilter :: String
2629
htKvmSpiceVideoStreamDetectionFilter = "filter"
2630

    
2631
htKvmSpiceVideoStreamDetectionOff :: String
2632
htKvmSpiceVideoStreamDetectionOff = "off"
2633

    
2634
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2635
htKvmSpiceValidVideoStreamDetectionOptions =
2636
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2637
                       htKvmSpiceVideoStreamDetectionFilter,
2638
                       htKvmSpiceVideoStreamDetectionOff]
2639

    
2640
-- * Security models
2641

    
2642
htSmNone :: String
2643
htSmNone = "none"
2644

    
2645
htSmPool :: String
2646
htSmPool = "pool"
2647

    
2648
htSmUser :: String
2649
htSmUser = "user"
2650

    
2651
htKvmValidSmTypes :: FrozenSet String
2652
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2653

    
2654
-- * Kvm flag values
2655

    
2656
htKvmDisabled :: String
2657
htKvmDisabled = "disabled"
2658

    
2659
htKvmEnabled :: String
2660
htKvmEnabled = "enabled"
2661

    
2662
htKvmFlagValues :: FrozenSet String
2663
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2664

    
2665
-- * Migration type
2666

    
2667
htMigrationLive :: String
2668
htMigrationLive = Types.migrationModeToRaw MigrationLive
2669

    
2670
htMigrationNonlive :: String
2671
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2672

    
2673
htMigrationModes :: FrozenSet String
2674
htMigrationModes =
2675
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2676

    
2677
-- * Cluster verify steps
2678

    
2679
verifyNplusoneMem :: String
2680
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2681

    
2682
verifyOptionalChecks :: FrozenSet String
2683
verifyOptionalChecks =
2684
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2685

    
2686
-- * Cluster Verify error classes
2687

    
2688
cvTcluster :: String
2689
cvTcluster = "cluster"
2690

    
2691
cvTgroup :: String
2692
cvTgroup = "group"
2693

    
2694
cvTnode :: String
2695
cvTnode = "node"
2696

    
2697
cvTinstance :: String
2698
cvTinstance = "instance"
2699

    
2700
-- * Cluster Verify error levels
2701

    
2702
cvWarning :: String
2703
cvWarning = "WARNING"
2704

    
2705
cvError :: String
2706
cvError = "ERROR"
2707

    
2708
-- * Cluster Verify error codes and documentation
2709

    
2710
cvEclustercert :: (String, String, String)
2711
cvEclustercert =
2712
  ("cluster",
2713
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2714
   "Cluster certificate files verification failure")
2715

    
2716
cvEclusterclientcert :: (String, String, String)
2717
cvEclusterclientcert =
2718
  ("cluster",
2719
   Types.cVErrorCodeToRaw CvECLUSTERCLIENTCERT,
2720
   "Cluster client certificate files verification failure")
2721

    
2722
cvEclustercfg :: (String, String, String)
2723
cvEclustercfg =
2724
  ("cluster",
2725
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2726
   "Cluster configuration verification failure")
2727

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

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

    
2740
cvEclusterfilecheck :: (String, String, String)
2741
cvEclusterfilecheck =
2742
  ("cluster",
2743
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2744
   "Cluster configuration verification failure")
2745

    
2746
cvEgroupdifferentpvsize :: (String, String, String)
2747
cvEgroupdifferentpvsize =
2748
  ("group",
2749
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2750
   "PVs in the group have different sizes")
2751

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

    
2758
cvEinstancedown :: (String, String, String)
2759
cvEinstancedown =
2760
  ("instance",
2761
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2762
   "Instance not running on its primary node")
2763

    
2764
cvEinstancefaultydisk :: (String, String, String)
2765
cvEinstancefaultydisk =
2766
  ("instance",
2767
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2768
   "Impossible to retrieve status for a disk")
2769

    
2770
cvEinstancelayout :: (String, String, String)
2771
cvEinstancelayout =
2772
  ("instance",
2773
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2774
   "Instance has multiple secondary nodes")
2775

    
2776
cvEinstancemissingcfgparameter :: (String, String, String)
2777
cvEinstancemissingcfgparameter =
2778
  ("instance",
2779
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2780
   "A configuration parameter for an instance is missing")
2781

    
2782
cvEinstancemissingdisk :: (String, String, String)
2783
cvEinstancemissingdisk =
2784
  ("instance",
2785
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2786
   "Missing volume on an instance")
2787

    
2788
cvEinstancepolicy :: (String, String, String)
2789
cvEinstancepolicy =
2790
  ("instance",
2791
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2792
   "Instance does not meet policy")
2793

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

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

    
2806
cvEinstancewrongnode :: (String, String, String)
2807
cvEinstancewrongnode =
2808
  ("instance",
2809
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2810
   "Instance running on the wrong node")
2811

    
2812
cvEnodedrbd :: (String, String, String)
2813
cvEnodedrbd =
2814
  ("node",
2815
   Types.cVErrorCodeToRaw CvENODEDRBD,
2816
   "Error parsing the DRBD status file")
2817

    
2818
cvEnodedrbdhelper :: (String, String, String)
2819
cvEnodedrbdhelper =
2820
  ("node",
2821
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2822
   "Error caused by the DRBD helper")
2823

    
2824
cvEnodedrbdversion :: (String, String, String)
2825
cvEnodedrbdversion =
2826
  ("node",
2827
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2828
   "DRBD version mismatch within a node group")
2829

    
2830
cvEnodefilecheck :: (String, String, String)
2831
cvEnodefilecheck =
2832
  ("node",
2833
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2834
   "Error retrieving the checksum of the node files")
2835

    
2836
cvEnodefilestoragepaths :: (String, String, String)
2837
cvEnodefilestoragepaths =
2838
  ("node",
2839
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2840
   "Detected bad file storage paths")
2841

    
2842
cvEnodefilestoragepathunusable :: (String, String, String)
2843
cvEnodefilestoragepathunusable =
2844
  ("node",
2845
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2846
   "File storage path unusable")
2847

    
2848
cvEnodehooks :: (String, String, String)
2849
cvEnodehooks =
2850
  ("node",
2851
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2852
   "Communication failure in hooks execution")
2853

    
2854
cvEnodehv :: (String, String, String)
2855
cvEnodehv =
2856
  ("node",
2857
   Types.cVErrorCodeToRaw CvENODEHV,
2858
   "Hypervisor parameters verification failure")
2859

    
2860
cvEnodelvm :: (String, String, String)
2861
cvEnodelvm =
2862
  ("node",
2863
   Types.cVErrorCodeToRaw CvENODELVM,
2864
   "LVM-related node error")
2865

    
2866
cvEnoden1 :: (String, String, String)
2867
cvEnoden1 =
2868
  ("node",
2869
   Types.cVErrorCodeToRaw CvENODEN1,
2870
   "Not enough memory to accommodate instance failovers")
2871

    
2872
cvEnodenet :: (String, String, String)
2873
cvEnodenet =
2874
  ("node",
2875
   Types.cVErrorCodeToRaw CvENODENET,
2876
   "Network-related node error")
2877

    
2878
cvEnodeoobpath :: (String, String, String)
2879
cvEnodeoobpath =
2880
  ("node",
2881
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2882
   "Invalid Out Of Band path")
2883

    
2884
cvEnodeorphaninstance :: (String, String, String)
2885
cvEnodeorphaninstance =
2886
  ("node",
2887
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2888
   "Unknown intance running on a node")
2889

    
2890
cvEnodeorphanlv :: (String, String, String)
2891
cvEnodeorphanlv =
2892
  ("node",
2893
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2894
   "Unknown LVM logical volume")
2895

    
2896
cvEnodeos :: (String, String, String)
2897
cvEnodeos =
2898
  ("node",
2899
   Types.cVErrorCodeToRaw CvENODEOS,
2900
   "OS-related node error")
2901

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

    
2908
cvEnodesetup :: (String, String, String)
2909
cvEnodesetup =
2910
  ("node",
2911
   Types.cVErrorCodeToRaw CvENODESETUP,
2912
   "Node setup error")
2913

    
2914
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2915
cvEnodesharedfilestoragepathunusable =
2916
  ("node",
2917
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2918
   "Shared file storage path unusable")
2919

    
2920
cvEnodessh :: (String, String, String)
2921
cvEnodessh =
2922
  ("node",
2923
   Types.cVErrorCodeToRaw CvENODESSH,
2924
   "SSH-related node error")
2925

    
2926
cvEnodetime :: (String, String, String)
2927
cvEnodetime =
2928
  ("node",
2929
   Types.cVErrorCodeToRaw CvENODETIME,
2930
   "Node returned invalid time")
2931

    
2932
cvEnodeuserscripts :: (String, String, String)
2933
cvEnodeuserscripts =
2934
  ("node",
2935
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2936
   "User scripts not present or not executable")
2937

    
2938
cvEnodeversion :: (String, String, String)
2939
cvEnodeversion =
2940
  ("node",
2941
   Types.cVErrorCodeToRaw CvENODEVERSION,
2942
   "Protocol version mismatch or Ganeti version mismatch")
2943

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

    
2986
cvAllEcodesStrings :: FrozenSet String
2987
cvAllEcodesStrings =
2988
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2989

    
2990
-- * Node verify constants
2991

    
2992
nvBridges :: String
2993
nvBridges = "bridges"
2994

    
2995
nvClientCert :: String
2996
nvClientCert = "client-cert"
2997

    
2998
nvDrbdhelper :: String
2999
nvDrbdhelper = "drbd-helper"
3000

    
3001
nvDrbdversion :: String
3002
nvDrbdversion = "drbd-version"
3003

    
3004
nvDrbdlist :: String
3005
nvDrbdlist = "drbd-list"
3006

    
3007
nvExclusivepvs :: String
3008
nvExclusivepvs = "exclusive-pvs"
3009

    
3010
nvFilelist :: String
3011
nvFilelist = "filelist"
3012

    
3013
nvAcceptedStoragePaths :: String
3014
nvAcceptedStoragePaths = "allowed-file-storage-paths"
3015

    
3016
nvFileStoragePath :: String
3017
nvFileStoragePath = "file-storage-path"
3018

    
3019
nvSharedFileStoragePath :: String
3020
nvSharedFileStoragePath = "shared-file-storage-path"
3021

    
3022
nvHvinfo :: String
3023
nvHvinfo = "hvinfo"
3024

    
3025
nvHvparams :: String
3026
nvHvparams = "hvparms"
3027

    
3028
nvHypervisor :: String
3029
nvHypervisor = "hypervisor"
3030

    
3031
nvInstancelist :: String
3032
nvInstancelist = "instancelist"
3033

    
3034
nvLvlist :: String
3035
nvLvlist = "lvlist"
3036

    
3037
nvMasterip :: String
3038
nvMasterip = "master-ip"
3039

    
3040
nvNodelist :: String
3041
nvNodelist = "nodelist"
3042

    
3043
nvNodenettest :: String
3044
nvNodenettest = "node-net-test"
3045

    
3046
nvNodesetup :: String
3047
nvNodesetup = "nodesetup"
3048

    
3049
nvOobPaths :: String
3050
nvOobPaths = "oob-paths"
3051

    
3052
nvOslist :: String
3053
nvOslist = "oslist"
3054

    
3055
nvPvlist :: String
3056
nvPvlist = "pvlist"
3057

    
3058
nvTime :: String
3059
nvTime = "time"
3060

    
3061
nvUserscripts :: String
3062
nvUserscripts = "user-scripts"
3063

    
3064
nvVersion :: String
3065
nvVersion = "version"
3066

    
3067
nvVglist :: String
3068
nvVglist = "vglist"
3069

    
3070
nvVmnodes :: String
3071
nvVmnodes = "vmnodes"
3072

    
3073
-- * Instance status
3074

    
3075
inststAdmindown :: String
3076
inststAdmindown = Types.instanceStatusToRaw StatusDown
3077

    
3078
inststAdminoffline :: String
3079
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3080

    
3081
inststErrordown :: String
3082
inststErrordown = Types.instanceStatusToRaw ErrorDown
3083

    
3084
inststErrorup :: String
3085
inststErrorup = Types.instanceStatusToRaw ErrorUp
3086

    
3087
inststNodedown :: String
3088
inststNodedown = Types.instanceStatusToRaw NodeDown
3089

    
3090
inststNodeoffline :: String
3091
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3092

    
3093
inststRunning :: String
3094
inststRunning = Types.instanceStatusToRaw Running
3095

    
3096
inststUserdown :: String
3097
inststUserdown = Types.instanceStatusToRaw UserDown
3098

    
3099
inststWrongnode :: String
3100
inststWrongnode = Types.instanceStatusToRaw WrongNode
3101

    
3102
inststAll :: FrozenSet String
3103
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3104

    
3105
-- * Admin states
3106

    
3107
adminstDown :: String
3108
adminstDown = Types.adminStateToRaw AdminDown
3109

    
3110
adminstOffline :: String
3111
adminstOffline = Types.adminStateToRaw AdminOffline
3112

    
3113
adminstUp :: String
3114
adminstUp = Types.adminStateToRaw AdminUp
3115

    
3116
adminstAll :: FrozenSet String
3117
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3118

    
3119
-- * Node roles
3120

    
3121
nrDrained :: String
3122
nrDrained = Types.nodeRoleToRaw NRDrained
3123

    
3124
nrMaster :: String
3125
nrMaster = Types.nodeRoleToRaw NRMaster
3126

    
3127
nrMcandidate :: String
3128
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3129

    
3130
nrOffline :: String
3131
nrOffline = Types.nodeRoleToRaw NROffline
3132

    
3133
nrRegular :: String
3134
nrRegular = Types.nodeRoleToRaw NRRegular
3135

    
3136
nrAll :: FrozenSet String
3137
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3138

    
3139
-- * SSL certificate check constants (in days)
3140

    
3141
sslCertExpirationError :: Int
3142
sslCertExpirationError = 7
3143

    
3144
sslCertExpirationWarn :: Int
3145
sslCertExpirationWarn = 30
3146

    
3147
-- * Allocator framework constants
3148

    
3149
iallocatorVersion :: Int
3150
iallocatorVersion = 2
3151

    
3152
iallocatorDirIn :: String
3153
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3154

    
3155
iallocatorDirOut :: String
3156
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3157

    
3158
validIallocatorDirections :: FrozenSet String
3159
validIallocatorDirections =
3160
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3161

    
3162
iallocatorModeAlloc :: String
3163
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3164

    
3165
iallocatorModeChgGroup :: String
3166
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3167

    
3168
iallocatorModeMultiAlloc :: String
3169
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3170

    
3171
iallocatorModeNodeEvac :: String
3172
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3173

    
3174
iallocatorModeReloc :: String
3175
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3176

    
3177
validIallocatorModes :: FrozenSet String
3178
validIallocatorModes =
3179
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3180

    
3181
iallocatorSearchPath :: [String]
3182
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3183

    
3184
defaultIallocatorShortcut :: String
3185
defaultIallocatorShortcut = "."
3186

    
3187
-- * Node evacuation
3188

    
3189
nodeEvacPri :: String
3190
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3191

    
3192
nodeEvacSec :: String
3193
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3194

    
3195
nodeEvacAll :: String
3196
nodeEvacAll = Types.evacModeToRaw ChangeAll
3197

    
3198
nodeEvacModes :: FrozenSet String
3199
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3200

    
3201
-- * Job queue
3202

    
3203
jobQueueVersion :: Int
3204
jobQueueVersion = 1
3205

    
3206
jobQueueSizeHardLimit :: Int
3207
jobQueueSizeHardLimit = 5000
3208

    
3209
jobQueueFilesPerms :: Int
3210
jobQueueFilesPerms = 0o640
3211

    
3212
-- * Unchanged job return
3213

    
3214
jobNotchanged :: String
3215
jobNotchanged = "nochange"
3216

    
3217
-- * Job status
3218

    
3219
jobStatusQueued :: String
3220
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3221

    
3222
jobStatusWaiting :: String
3223
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3224

    
3225
jobStatusCanceling :: String
3226
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3227

    
3228
jobStatusRunning :: String
3229
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3230

    
3231
jobStatusCanceled :: String
3232
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3233

    
3234
jobStatusSuccess :: String
3235
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3236

    
3237
jobStatusError :: String
3238
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3239

    
3240
jobsPending :: FrozenSet String
3241
jobsPending =
3242
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3243

    
3244
jobsFinalized :: FrozenSet String
3245
jobsFinalized =
3246
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3247

    
3248
jobStatusAll :: FrozenSet String
3249
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3250

    
3251
-- * OpCode status
3252

    
3253
-- ** Not yet finalized opcodes
3254

    
3255
opStatusCanceling :: String
3256
opStatusCanceling = "canceling"
3257

    
3258
opStatusQueued :: String
3259
opStatusQueued = "queued"
3260

    
3261
opStatusRunning :: String
3262
opStatusRunning = "running"
3263

    
3264
opStatusWaiting :: String
3265
opStatusWaiting = "waiting"
3266

    
3267
-- ** Finalized opcodes
3268

    
3269
opStatusCanceled :: String
3270
opStatusCanceled = "canceled"
3271

    
3272
opStatusError :: String
3273
opStatusError = "error"
3274

    
3275
opStatusSuccess :: String
3276
opStatusSuccess = "success"
3277

    
3278
opsFinalized :: FrozenSet String
3279
opsFinalized =
3280
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3281

    
3282
-- * OpCode priority
3283

    
3284
opPrioLowest :: Int
3285
opPrioLowest = 19
3286

    
3287
opPrioHighest :: Int
3288
opPrioHighest = -20
3289

    
3290
opPrioLow :: Int
3291
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3292

    
3293
opPrioNormal :: Int
3294
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3295

    
3296
opPrioHigh :: Int
3297
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3298

    
3299
opPrioSubmitValid :: FrozenSet Int
3300
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3301

    
3302
opPrioDefault :: Int
3303
opPrioDefault = opPrioNormal
3304

    
3305
-- * Lock recalculate mode
3306

    
3307
locksAppend :: String
3308
locksAppend = "append"
3309

    
3310
locksReplace :: String
3311
locksReplace = "replace"
3312

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

    
3320
lockAttemptsMaxwait :: Double
3321
lockAttemptsMaxwait = 15.0
3322

    
3323
lockAttemptsMinwait :: Double
3324
lockAttemptsMinwait = 1.0
3325

    
3326
lockAttemptsTimeout :: Int
3327
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3328

    
3329
-- * Execution log types
3330

    
3331
elogMessage :: String
3332
elogMessage = Types.eLogTypeToRaw ELogMessage
3333

    
3334
elogRemoteImport :: String
3335
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3336

    
3337
elogJqueueTest :: String
3338
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3339

    
3340
-- * /etc/hosts modification
3341

    
3342
etcHostsAdd :: String
3343
etcHostsAdd = "add"
3344

    
3345
etcHostsRemove :: String
3346
etcHostsRemove = "remove"
3347

    
3348
-- * Job queue test
3349

    
3350
jqtMsgprefix :: String
3351
jqtMsgprefix = "TESTMSG="
3352

    
3353
jqtExec :: String
3354
jqtExec = "exec"
3355

    
3356
jqtExpandnames :: String
3357
jqtExpandnames = "expandnames"
3358

    
3359
jqtLogmsg :: String
3360
jqtLogmsg = "logmsg"
3361

    
3362
jqtStartmsg :: String
3363
jqtStartmsg = "startmsg"
3364

    
3365
jqtAll :: FrozenSet String
3366
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3367

    
3368
-- * Query resources
3369

    
3370
qrCluster :: String
3371
qrCluster = "cluster"
3372

    
3373
qrExport :: String
3374
qrExport = "export"
3375

    
3376
qrExtstorage :: String
3377
qrExtstorage = "extstorage"
3378

    
3379
qrGroup :: String
3380
qrGroup = "group"
3381

    
3382
qrInstance :: String
3383
qrInstance = "instance"
3384

    
3385
qrJob :: String
3386
qrJob = "job"
3387

    
3388
qrLock :: String
3389
qrLock = "lock"
3390

    
3391
qrNetwork :: String
3392
qrNetwork = "network"
3393

    
3394
qrNode :: String
3395
qrNode = "node"
3396

    
3397
qrOs :: String
3398
qrOs = "os"
3399

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

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

    
3417
-- | List of resources which can be queried using RAPI
3418
qrViaRapi :: FrozenSet String
3419
qrViaRapi = qrViaLuxi
3420

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

    
3425
-- * Query field types
3426

    
3427
qftBool :: String
3428
qftBool = "bool"
3429

    
3430
qftNumber :: String
3431
qftNumber = "number"
3432

    
3433
qftOther :: String
3434
qftOther = "other"
3435

    
3436
qftText :: String
3437
qftText = "text"
3438

    
3439
qftTimestamp :: String
3440
qftTimestamp = "timestamp"
3441

    
3442
qftUnit :: String
3443
qftUnit = "unit"
3444

    
3445
qftUnknown :: String
3446
qftUnknown = "unknown"
3447

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

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

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

    
3468
rsNormal :: Int
3469
rsNormal = 0
3470

    
3471
-- | Resource marked offline
3472
rsOffline :: Int
3473
rsOffline = 4
3474

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

    
3481
rsUnknown :: Int
3482
rsUnknown = 1
3483

    
3484
rsAll :: FrozenSet Int
3485
rsAll =
3486
  ConstantUtils.mkSet [rsNodata,
3487
                       rsNormal,
3488
                       rsOffline,
3489
                       rsUnavail,
3490
                       rsUnknown]
3491

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

    
3500
-- * Max dynamic devices
3501

    
3502
maxDisks :: Int
3503
maxDisks = Types.maxDisks
3504

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

    
3508
-- | SSCONF file prefix
3509
ssconfFileprefix :: String
3510
ssconfFileprefix = "ssconf_"
3511

    
3512
-- * SSCONF keys
3513

    
3514
ssClusterName :: String
3515
ssClusterName = "cluster_name"
3516

    
3517
ssClusterTags :: String
3518
ssClusterTags = "cluster_tags"
3519

    
3520
ssFileStorageDir :: String
3521
ssFileStorageDir = "file_storage_dir"
3522

    
3523
ssSharedFileStorageDir :: String
3524
ssSharedFileStorageDir = "shared_file_storage_dir"
3525

    
3526
ssGlusterStorageDir :: String
3527
ssGlusterStorageDir = "gluster_storage_dir"
3528

    
3529
ssMasterCandidates :: String
3530
ssMasterCandidates = "master_candidates"
3531

    
3532
ssMasterCandidatesIps :: String
3533
ssMasterCandidatesIps = "master_candidates_ips"
3534

    
3535
ssMasterCandidatesCerts :: String
3536
ssMasterCandidatesCerts = "master_candidates_certs"
3537

    
3538
ssMasterIp :: String
3539
ssMasterIp = "master_ip"
3540

    
3541
ssMasterNetdev :: String
3542
ssMasterNetdev = "master_netdev"
3543

    
3544
ssMasterNetmask :: String
3545
ssMasterNetmask = "master_netmask"
3546

    
3547
ssMasterNode :: String
3548
ssMasterNode = "master_node"
3549

    
3550
ssNodeList :: String
3551
ssNodeList = "node_list"
3552

    
3553
ssNodePrimaryIps :: String
3554
ssNodePrimaryIps = "node_primary_ips"
3555

    
3556
ssNodeSecondaryIps :: String
3557
ssNodeSecondaryIps = "node_secondary_ips"
3558

    
3559
ssOfflineNodes :: String
3560
ssOfflineNodes = "offline_nodes"
3561

    
3562
ssOnlineNodes :: String
3563
ssOnlineNodes = "online_nodes"
3564

    
3565
ssPrimaryIpFamily :: String
3566
ssPrimaryIpFamily = "primary_ip_family"
3567

    
3568
ssInstanceList :: String
3569
ssInstanceList = "instance_list"
3570

    
3571
ssReleaseVersion :: String
3572
ssReleaseVersion = "release_version"
3573

    
3574
ssHypervisorList :: String
3575
ssHypervisorList = "hypervisor_list"
3576

    
3577
ssMaintainNodeHealth :: String
3578
ssMaintainNodeHealth = "maintain_node_health"
3579

    
3580
ssUidPool :: String
3581
ssUidPool = "uid_pool"
3582

    
3583
ssNodegroups :: String
3584
ssNodegroups = "nodegroups"
3585

    
3586
ssNetworks :: String
3587
ssNetworks = "networks"
3588

    
3589
-- | This is not a complete SSCONF key, but the prefix for the
3590
-- hypervisor keys
3591
ssHvparamsPref :: String
3592
ssHvparamsPref = "hvparams_"
3593

    
3594
-- * Hvparams keys
3595

    
3596
ssHvparamsXenChroot :: String
3597
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3598

    
3599
ssHvparamsXenFake :: String
3600
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3601

    
3602
ssHvparamsXenHvm :: String
3603
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3604

    
3605
ssHvparamsXenKvm :: String
3606
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3607

    
3608
ssHvparamsXenLxc :: String
3609
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3610

    
3611
ssHvparamsXenPvm :: String
3612
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3613

    
3614
validSsHvparamsKeys :: FrozenSet String
3615
validSsHvparamsKeys =
3616
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3617
                       ssHvparamsXenLxc,
3618
                       ssHvparamsXenFake,
3619
                       ssHvparamsXenHvm,
3620
                       ssHvparamsXenKvm,
3621
                       ssHvparamsXenPvm]
3622

    
3623
ssFilePerms :: Int
3624
ssFilePerms = 0o444
3625

    
3626
-- | Cluster wide default parameters
3627
defaultEnabledHypervisor :: String
3628
defaultEnabledHypervisor = htXenPvm
3629

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

    
3743
hvcGlobals :: FrozenSet String
3744
hvcGlobals =
3745
  ConstantUtils.mkSet [hvMigrationBandwidth,
3746
                       hvMigrationMode,
3747
                       hvMigrationPort,
3748
                       hvXenCmd]
3749

    
3750
becDefaults :: Map String PyValueEx
3751
becDefaults =
3752
  Map.fromList
3753
  [ (beMinmem, PyValueEx (128 :: Int))
3754
  , (beMaxmem, PyValueEx (128 :: Int))
3755
  , (beVcpus, PyValueEx (1 :: Int))
3756
  , (beAutoBalance, PyValueEx True)
3757
  , (beAlwaysFailover, PyValueEx False)
3758
  , (beSpindleUse, PyValueEx (1 :: Int))
3759
  ]
3760

    
3761
ndcDefaults :: Map String PyValueEx
3762
ndcDefaults =
3763
  Map.fromList
3764
  [ (ndOobProgram,       PyValueEx "")
3765
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3766
  , (ndExclusiveStorage, PyValueEx False)
3767
  , (ndOvs,              PyValueEx False)
3768
  , (ndOvsName,          PyValueEx defaultOvs)
3769
  , (ndOvsLink,          PyValueEx "")
3770
  , (ndSshPort,          PyValueEx (22 :: Int))
3771
  ]
3772

    
3773
ndcGlobals :: FrozenSet String
3774
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3775

    
3776
-- | Default delay target measured in sectors
3777
defaultDelayTarget :: Int
3778
defaultDelayTarget = 1
3779

    
3780
defaultDiskCustom :: String
3781
defaultDiskCustom = ""
3782

    
3783
defaultDiskResync :: Bool
3784
defaultDiskResync = False
3785

    
3786
-- | Default fill target measured in sectors
3787
defaultFillTarget :: Int
3788
defaultFillTarget = 0
3789

    
3790
-- | Default mininum rate measured in KiB/s
3791
defaultMinRate :: Int
3792
defaultMinRate = 4 * 1024
3793

    
3794
defaultNetCustom :: String
3795
defaultNetCustom = ""
3796

    
3797
-- | Default plan ahead measured in sectors
3798
--
3799
-- The default values for the DRBD dynamic resync speed algorithm are
3800
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3801
-- (that we don't need to set to 0, because we have a separate option
3802
-- to enable it) and for c-max-rate, that we cap to the default value
3803
-- for the static resync rate.
3804
defaultPlanAhead :: Int
3805
defaultPlanAhead = 20
3806

    
3807
defaultRbdPool :: String
3808
defaultRbdPool = "rbd"
3809

    
3810
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3811
diskLdDefaults =
3812
  Map.fromList
3813
  [ (DTBlock, Map.empty)
3814
  , (DTDrbd8, Map.fromList
3815
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3816
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3817
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3818
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3819
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3820
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3821
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3822
              , (ldpMinRate,       PyValueEx defaultMinRate)
3823
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3824
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3825
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3826
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3827
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3828
              ])
3829
  , (DTExt, Map.empty)
3830
  , (DTFile, Map.empty)
3831
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3832
  , (DTRbd, Map.fromList
3833
            [ (ldpPool, PyValueEx defaultRbdPool)
3834
            , (ldpAccess, PyValueEx diskKernelspace)
3835
            ])
3836
  , (DTSharedFile, Map.empty)
3837
  , (DTGluster, Map.fromList
3838
                [ (rbdAccess, PyValueEx diskKernelspace)
3839
                , (glusterHost, PyValueEx glusterHostDefault)
3840
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3841
                , (glusterPort, PyValueEx glusterPortDefault)
3842
                ])
3843
  ]
3844

    
3845
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3846
diskDtDefaults =
3847
  Map.fromList
3848
  [ (DTBlock,      Map.empty)
3849
  , (DTDiskless,   Map.empty)
3850
  , (DTDrbd8,      Map.fromList
3851
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3852
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3853
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3854
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3855
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3856
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3857
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3858
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3859
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3860
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3861
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3862
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3863
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3864
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3865
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3866
                   ])
3867
  , (DTExt,        Map.empty)
3868
  , (DTFile,       Map.empty)
3869
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3870
  , (DTRbd,        Map.fromList
3871
                   [ (rbdPool, PyValueEx defaultRbdPool)
3872
                   , (rbdAccess, PyValueEx diskKernelspace)
3873
                   ])
3874
  , (DTSharedFile, Map.empty)
3875
  , (DTGluster, Map.fromList
3876
                [ (rbdAccess, PyValueEx diskKernelspace)
3877
                , (glusterHost, PyValueEx glusterHostDefault)
3878
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3879
                , (glusterPort, PyValueEx glusterPortDefault)
3880
                ])
3881
  ]
3882

    
3883
niccDefaults :: Map String PyValueEx
3884
niccDefaults =
3885
  Map.fromList
3886
  [ (nicMode, PyValueEx nicModeBridged)
3887
  , (nicLink, PyValueEx defaultBridge)
3888
  , (nicVlan, PyValueEx "")
3889
  ]
3890

    
3891
-- | All of the following values are quite arbitrary - there are no
3892
-- "good" defaults, these must be customised per-site
3893
ispecsMinmaxDefaults :: Map String (Map String Int)
3894
ispecsMinmaxDefaults =
3895
  Map.fromList
3896
  [(ispecsMin,
3897
    Map.fromList
3898
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3899
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3900
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3901
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3902
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3903
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3904
   (ispecsMax,
3905
    Map.fromList
3906
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3907
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3908
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3909
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3910
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3911
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3912

    
3913
ipolicyDefaults :: Map String PyValueEx
3914
ipolicyDefaults =
3915
  Map.fromList
3916
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3917
  , (ispecsStd,           PyValueEx (Map.fromList
3918
                                     [ (ispecMemSize,    128)
3919
                                     , (ispecCpuCount,   1)
3920
                                     , (ispecDiskCount,  1)
3921
                                     , (ispecDiskSize,   1024)
3922
                                     , (ispecNicCount,   1)
3923
                                     , (ispecSpindleUse, 1)
3924
                                     ] :: Map String Int))
3925
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3926
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3927
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3928
  ]
3929

    
3930
masterPoolSizeDefault :: Int
3931
masterPoolSizeDefault = 10
3932

    
3933
-- * Exclusive storage
3934

    
3935
-- | Error margin used to compare physical disks
3936
partMargin :: Double
3937
partMargin = 0.01
3938

    
3939
-- | Space reserved when creating instance disks
3940
partReserved :: Double
3941
partReserved = 0.02
3942

    
3943
-- * Luxid job scheduling
3944

    
3945
-- | Time intervall in seconds for polling updates on the job queue. This
3946
-- intervall is only relevant if the number of running jobs reaches the maximal
3947
-- allowed number, as otherwise new jobs will be started immediately anyway.
3948
-- Also, as jobs are watched via inotify, scheduling usually works independent
3949
-- of polling. Therefore we chose a sufficiently large interval, in the order of
3950
-- 5 minutes. As with the interval for reloading the configuration, we chose a
3951
-- prime number to avoid accidental 'same wakeup' with other processes.
3952
luxidJobqueuePollInterval :: Int
3953
luxidJobqueuePollInterval = 307
3954

    
3955
-- | The default value for the maximal number of jobs to be running at the same
3956
-- time. Once the maximal number is reached, new jobs will just be queued and
3957
-- only started, once some of the other jobs have finished.
3958
luxidMaximalRunningJobsDefault :: Int
3959
luxidMaximalRunningJobsDefault = 20
3960

    
3961
-- * Confd
3962

    
3963
confdProtocolVersion :: Int
3964
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3965

    
3966
-- Confd request type
3967

    
3968
confdReqPing :: Int
3969
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3970

    
3971
confdReqNodeRoleByname :: Int
3972
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3973

    
3974
confdReqNodePipByInstanceIp :: Int
3975
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3976

    
3977
confdReqClusterMaster :: Int
3978
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3979

    
3980
confdReqNodePipList :: Int
3981
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3982

    
3983
confdReqMcPipList :: Int
3984
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3985

    
3986
confdReqInstancesIpsList :: Int
3987
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3988

    
3989
confdReqNodeDrbd :: Int
3990
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3991

    
3992
confdReqNodeInstances :: Int
3993
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3994

    
3995
confdReqs :: FrozenSet Int
3996
confdReqs =
3997
  ConstantUtils.mkSet .
3998
  map Types.confdRequestTypeToRaw $
3999
  [minBound..] \\ [ReqNodeInstances]
4000

    
4001
-- * Confd request type
4002

    
4003
confdReqfieldName :: Int
4004
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
4005

    
4006
confdReqfieldIp :: Int
4007
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
4008

    
4009
confdReqfieldMnodePip :: Int
4010
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
4011

    
4012
-- * Confd repl status
4013

    
4014
confdReplStatusOk :: Int
4015
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
4016

    
4017
confdReplStatusError :: Int
4018
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
4019

    
4020
confdReplStatusNotimplemented :: Int
4021
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
4022

    
4023
confdReplStatuses :: FrozenSet Int
4024
confdReplStatuses =
4025
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
4026

    
4027
-- * Confd node role
4028

    
4029
confdNodeRoleMaster :: Int
4030
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
4031

    
4032
confdNodeRoleCandidate :: Int
4033
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
4034

    
4035
confdNodeRoleOffline :: Int
4036
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
4037

    
4038
confdNodeRoleDrained :: Int
4039
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
4040

    
4041
confdNodeRoleRegular :: Int
4042
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
4043

    
4044
-- * A few common errors for confd
4045

    
4046
confdErrorUnknownEntry :: Int
4047
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
4048

    
4049
confdErrorInternal :: Int
4050
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
4051

    
4052
confdErrorArgument :: Int
4053
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
4054

    
4055
-- * Confd request query fields
4056

    
4057
confdReqqLink :: String
4058
confdReqqLink = ConstantUtils.confdReqqLink
4059

    
4060
confdReqqIp :: String
4061
confdReqqIp = ConstantUtils.confdReqqIp
4062

    
4063
confdReqqIplist :: String
4064
confdReqqIplist = ConstantUtils.confdReqqIplist
4065

    
4066
confdReqqFields :: String
4067
confdReqqFields = ConstantUtils.confdReqqFields
4068

    
4069
-- | Each request is "salted" by the current timestamp.
4070
--
4071
-- This constant decides how many seconds of skew to accept.
4072
--
4073
-- TODO: make this a default and allow the value to be more
4074
-- configurable
4075
confdMaxClockSkew :: Int
4076
confdMaxClockSkew = 2 * nodeMaxClockSkew
4077

    
4078
-- | When we haven't reloaded the config for more than this amount of
4079
-- seconds, we force a test to see if inotify is betraying us. Using a
4080
-- prime number to ensure we get less chance of 'same wakeup' with
4081
-- other processes.
4082
confdConfigReloadTimeout :: Int
4083
confdConfigReloadTimeout = 17
4084

    
4085
-- | If we receive more than one update in this amount of
4086
-- microseconds, we move to polling every RATELIMIT seconds, rather
4087
-- than relying on inotify, to be able to serve more requests.
4088
confdConfigReloadRatelimit :: Int
4089
confdConfigReloadRatelimit = 250000
4090

    
4091
-- | Magic number prepended to all confd queries.
4092
--
4093
-- This allows us to distinguish different types of confd protocols
4094
-- and handle them. For example by changing this we can move the whole
4095
-- payload to be compressed, or move away from json.
4096
confdMagicFourcc :: String
4097
confdMagicFourcc = "plj0"
4098

    
4099
-- | By default a confd request is sent to the minimum between this
4100
-- number and all MCs. 6 was chosen because even in the case of a
4101
-- disastrous 50% response rate, we should have enough answers to be
4102
-- able to compare more than one.
4103
confdDefaultReqCoverage :: Int
4104
confdDefaultReqCoverage = 6
4105

    
4106
-- | Timeout in seconds to expire pending query request in the confd
4107
-- client library. We don't actually expect any answer more than 10
4108
-- seconds after we sent a request.
4109
confdClientExpireTimeout :: Int
4110
confdClientExpireTimeout = 10
4111

    
4112
-- | Maximum UDP datagram size.
4113
--
4114
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4115
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4116
--   (assuming we can't use jumbo frames)
4117
-- We just set this to 60K, which should be enough
4118
maxUdpDataSize :: Int
4119
maxUdpDataSize = 61440
4120

    
4121
-- * User-id pool minimum/maximum acceptable user-ids
4122

    
4123
uidpoolUidMin :: Int
4124
uidpoolUidMin = 0
4125

    
4126
-- | Assuming 32 bit user-ids
4127
uidpoolUidMax :: Integer
4128
uidpoolUidMax = 2 ^ 32 - 1
4129

    
4130
-- | Name or path of the pgrep command
4131
pgrep :: String
4132
pgrep = "pgrep"
4133

    
4134
-- | Name of the node group that gets created at cluster init or
4135
-- upgrade
4136
initialNodeGroupName :: String
4137
initialNodeGroupName = "default"
4138

    
4139
-- * Possible values for NodeGroup.alloc_policy
4140

    
4141
allocPolicyLastResort :: String
4142
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4143

    
4144
allocPolicyPreferred :: String
4145
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4146

    
4147
allocPolicyUnallocable :: String
4148
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4149

    
4150
validAllocPolicies :: [String]
4151
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4152

    
4153
-- | Temporary external/shared storage parameters
4154
blockdevDriverManual :: String
4155
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4156

    
4157
-- | 'qemu-img' path, required for 'ovfconverter'
4158
qemuimgPath :: String
4159
qemuimgPath = AutoConf.qemuimgPath
4160

    
4161
-- | Whether htools was enabled at compilation time
4162
--
4163
-- FIXME: this should be moved next to the other enable constants,
4164
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4165
htools :: Bool
4166
htools = AutoConf.htools
4167

    
4168
-- | The hail iallocator
4169
iallocHail :: String
4170
iallocHail = "hail"
4171

    
4172
-- * Fake opcodes for functions that have hooks attached to them via
4173
-- backend.RunLocalHooks
4174

    
4175
fakeOpMasterTurndown :: String
4176
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4177

    
4178
fakeOpMasterTurnup :: String
4179
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4180

    
4181

    
4182
-- * Crypto Types
4183
-- Types of cryptographic tokens used in node communication
4184

    
4185
cryptoTypeSslDigest :: String
4186
cryptoTypeSslDigest = "ssl"
4187

    
4188
cryptoTypeSsh :: String
4189
cryptoTypeSsh = "ssh"
4190

    
4191
-- So far only ssl keys are used in the context of this constant
4192
cryptoTypes :: FrozenSet String
4193
cryptoTypes = ConstantUtils.mkSet [cryptoTypeSslDigest]
4194

    
4195
-- * Crypto Actions
4196
-- Actions that can be performed on crypto tokens
4197

    
4198
cryptoActionGet :: String
4199
cryptoActionGet = "get"
4200

    
4201
-- This is 'create and get'
4202
cryptoActionCreate :: String
4203
cryptoActionCreate = "create"
4204

    
4205
cryptoActions :: FrozenSet String
4206
cryptoActions = ConstantUtils.mkSet [cryptoActionGet, cryptoActionCreate]
4207

    
4208
-- * Options for CryptoActions
4209

    
4210
-- Filename of the certificate
4211
cryptoOptionCertFile :: String
4212
cryptoOptionCertFile = "cert_file"
4213

    
4214
-- * SSH key types
4215

    
4216
sshkDsa :: String
4217
sshkDsa = "dsa"
4218

    
4219
sshkRsa :: String
4220
sshkRsa = "rsa"
4221

    
4222
sshkAll :: FrozenSet String
4223
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4224

    
4225
-- * SSH authorized key types
4226

    
4227
sshakDss :: String
4228
sshakDss = "ssh-dss"
4229

    
4230
sshakRsa :: String
4231
sshakRsa = "ssh-rsa"
4232

    
4233
sshakAll :: FrozenSet String
4234
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4235

    
4236
-- * SSH setup
4237

    
4238
sshsClusterName :: String
4239
sshsClusterName = "cluster_name"
4240

    
4241
sshsSshHostKey :: String
4242
sshsSshHostKey = "ssh_host_key"
4243

    
4244
sshsSshRootKey :: String
4245
sshsSshRootKey = "ssh_root_key"
4246

    
4247
sshsNodeDaemonCertificate :: String
4248
sshsNodeDaemonCertificate = "node_daemon_certificate"
4249

    
4250
-- * Key files for SSH daemon
4251

    
4252
sshHostDsaPriv :: String
4253
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4254

    
4255
sshHostDsaPub :: String
4256
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4257

    
4258
sshHostRsaPriv :: String
4259
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4260

    
4261
sshHostRsaPub :: String
4262
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4263

    
4264
sshDaemonKeyfiles :: Map String (String, String)
4265
sshDaemonKeyfiles =
4266
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4267
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4268
               ]
4269

    
4270
-- * Node daemon setup
4271

    
4272
ndsClusterName :: String
4273
ndsClusterName = "cluster_name"
4274

    
4275
ndsNodeDaemonCertificate :: String
4276
ndsNodeDaemonCertificate = "node_daemon_certificate"
4277

    
4278
ndsSsconf :: String
4279
ndsSsconf = "ssconf"
4280

    
4281
ndsStartNodeDaemon :: String
4282
ndsStartNodeDaemon = "start_node_daemon"
4283

    
4284
-- * The source reasons for the execution of an OpCode
4285

    
4286
opcodeReasonSrcClient :: String
4287
opcodeReasonSrcClient = "gnt:client"
4288

    
4289
opcodeReasonSrcNoded :: String
4290
opcodeReasonSrcNoded = "gnt:daemon:noded"
4291

    
4292
opcodeReasonSrcOpcode :: String
4293
opcodeReasonSrcOpcode = "gnt:opcode"
4294

    
4295
opcodeReasonSrcRlib2 :: String
4296
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4297

    
4298
opcodeReasonSrcUser :: String
4299
opcodeReasonSrcUser = "gnt:user"
4300

    
4301
opcodeReasonSources :: FrozenSet String
4302
opcodeReasonSources =
4303
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4304
                       opcodeReasonSrcNoded,
4305
                       opcodeReasonSrcOpcode,
4306
                       opcodeReasonSrcRlib2,
4307
                       opcodeReasonSrcUser]
4308

    
4309
-- | Path generating random UUID
4310
randomUuidFile :: String
4311
randomUuidFile = ConstantUtils.randomUuidFile
4312

    
4313
-- * Auto-repair tag prefixes
4314

    
4315
autoRepairTagPrefix :: String
4316
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4317

    
4318
autoRepairTagEnabled :: String
4319
autoRepairTagEnabled = autoRepairTagPrefix
4320

    
4321
autoRepairTagPending :: String
4322
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4323

    
4324
autoRepairTagResult :: String
4325
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4326

    
4327
autoRepairTagSuspended :: String
4328
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4329

    
4330
-- * Auto-repair levels
4331

    
4332
autoRepairFailover :: String
4333
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4334

    
4335
autoRepairFixStorage :: String
4336
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4337

    
4338
autoRepairMigrate :: String
4339
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4340

    
4341
autoRepairReinstall :: String
4342
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4343

    
4344
autoRepairAllTypes :: FrozenSet String
4345
autoRepairAllTypes =
4346
  ConstantUtils.mkSet [autoRepairFailover,
4347
                       autoRepairFixStorage,
4348
                       autoRepairMigrate,
4349
                       autoRepairReinstall]
4350

    
4351
-- * Auto-repair results
4352

    
4353
autoRepairEnoperm :: String
4354
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4355

    
4356
autoRepairFailure :: String
4357
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4358

    
4359
autoRepairSuccess :: String
4360
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4361

    
4362
autoRepairAllResults :: FrozenSet String
4363
autoRepairAllResults =
4364
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4365

    
4366
-- | The version identifier for builtin data collectors
4367
builtinDataCollectorVersion :: String
4368
builtinDataCollectorVersion = "B"
4369

    
4370
-- | The reason trail opcode parameter name
4371
opcodeReason :: String
4372
opcodeReason = "reason"
4373

    
4374
diskstatsFile :: String
4375
diskstatsFile = "/proc/diskstats"
4376

    
4377
-- *  CPU load collector
4378

    
4379
statFile :: String
4380
statFile = "/proc/stat"
4381

    
4382
cpuavgloadBufferSize :: Int
4383
cpuavgloadBufferSize = 150
4384

    
4385
cpuavgloadWindowSize :: Int
4386
cpuavgloadWindowSize = 600
4387

    
4388
-- * Monitoring daemon
4389

    
4390
-- | Mond's variable for periodical data collection
4391
mondTimeInterval :: Int
4392
mondTimeInterval = 5
4393

    
4394
-- | Mond's latest API version
4395
mondLatestApiVersion :: Int
4396
mondLatestApiVersion = 1
4397

    
4398
-- * Disk access modes
4399

    
4400
diskUserspace :: String
4401
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4402

    
4403
diskKernelspace :: String
4404
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4405

    
4406
diskValidAccessModes :: FrozenSet String
4407
diskValidAccessModes =
4408
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4409

    
4410
-- | Timeout for queue draining in upgrades
4411
upgradeQueueDrainTimeout :: Int
4412
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4413

    
4414
-- | Intervall at which the queue is polled during upgrades
4415
upgradeQueuePollInterval :: Int
4416
upgradeQueuePollInterval  = 10
4417

    
4418
-- * Hotplug Actions
4419

    
4420
hotplugActionAdd :: String
4421
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4422

    
4423
hotplugActionRemove :: String
4424
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4425

    
4426
hotplugActionModify :: String
4427
hotplugActionModify = Types.hotplugActionToRaw HAMod
4428

    
4429
hotplugAllActions :: FrozenSet String
4430
hotplugAllActions =
4431
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4432

    
4433
-- * Hotplug Device Targets
4434

    
4435
hotplugTargetNic :: String
4436
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4437

    
4438
hotplugTargetDisk :: String
4439
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4440

    
4441
hotplugAllTargets :: FrozenSet String
4442
hotplugAllTargets =
4443
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4444

    
4445
-- | Timeout for disk removal (seconds)
4446
diskRemoveRetryTimeout :: Int
4447
diskRemoveRetryTimeout = 30
4448

    
4449
-- | Interval between disk removal retries (seconds)
4450
diskRemoveRetryInterval :: Int
4451
diskRemoveRetryInterval  = 3
4452

    
4453
-- * UUID regex
4454

    
4455
uuidRegex :: String
4456
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4457

    
4458
-- * Luxi constants
4459

    
4460
luxiSocketPerms :: Int
4461
luxiSocketPerms = 0o660
4462

    
4463
luxiKeyMethod :: String
4464
luxiKeyMethod = "method"
4465

    
4466
luxiKeyArgs :: String
4467
luxiKeyArgs = "args"
4468

    
4469
luxiKeySuccess :: String
4470
luxiKeySuccess = "success"
4471

    
4472
luxiKeyResult :: String
4473
luxiKeyResult = "result"
4474

    
4475
luxiKeyVersion :: String
4476
luxiKeyVersion = "version"
4477

    
4478
luxiReqSubmitJob :: String
4479
luxiReqSubmitJob = "SubmitJob"
4480

    
4481
luxiReqSubmitJobToDrainedQueue :: String
4482
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4483

    
4484
luxiReqSubmitManyJobs :: String
4485
luxiReqSubmitManyJobs = "SubmitManyJobs"
4486

    
4487
luxiReqWaitForJobChange :: String
4488
luxiReqWaitForJobChange = "WaitForJobChange"
4489

    
4490
luxiReqPickupJob :: String
4491
luxiReqPickupJob = "PickupJob"
4492

    
4493
luxiReqCancelJob :: String
4494
luxiReqCancelJob = "CancelJob"
4495

    
4496
luxiReqArchiveJob :: String
4497
luxiReqArchiveJob = "ArchiveJob"
4498

    
4499
luxiReqChangeJobPriority :: String
4500
luxiReqChangeJobPriority = "ChangeJobPriority"
4501

    
4502
luxiReqAutoArchiveJobs :: String
4503
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4504

    
4505
luxiReqQuery :: String
4506
luxiReqQuery = "Query"
4507

    
4508
luxiReqQueryFields :: String
4509
luxiReqQueryFields = "QueryFields"
4510

    
4511
luxiReqQueryJobs :: String
4512
luxiReqQueryJobs = "QueryJobs"
4513

    
4514
luxiReqQueryInstances :: String
4515
luxiReqQueryInstances = "QueryInstances"
4516

    
4517
luxiReqQueryNodes :: String
4518
luxiReqQueryNodes = "QueryNodes"
4519

    
4520
luxiReqQueryGroups :: String
4521
luxiReqQueryGroups = "QueryGroups"
4522

    
4523
luxiReqQueryNetworks :: String
4524
luxiReqQueryNetworks = "QueryNetworks"
4525

    
4526
luxiReqQueryExports :: String
4527
luxiReqQueryExports = "QueryExports"
4528

    
4529
luxiReqQueryConfigValues :: String
4530
luxiReqQueryConfigValues = "QueryConfigValues"
4531

    
4532
luxiReqQueryClusterInfo :: String
4533
luxiReqQueryClusterInfo = "QueryClusterInfo"
4534

    
4535
luxiReqQueryTags :: String
4536
luxiReqQueryTags = "QueryTags"
4537

    
4538
luxiReqSetDrainFlag :: String
4539
luxiReqSetDrainFlag = "SetDrainFlag"
4540

    
4541
luxiReqSetWatcherPause :: String
4542
luxiReqSetWatcherPause = "SetWatcherPause"
4543

    
4544
luxiReqAll :: FrozenSet String
4545
luxiReqAll =
4546
  ConstantUtils.mkSet
4547
  [ luxiReqArchiveJob
4548
  , luxiReqAutoArchiveJobs
4549
  , luxiReqCancelJob
4550
  , luxiReqChangeJobPriority
4551
  , luxiReqQuery
4552
  , luxiReqQueryClusterInfo
4553
  , luxiReqQueryConfigValues
4554
  , luxiReqQueryExports
4555
  , luxiReqQueryFields
4556
  , luxiReqQueryGroups
4557
  , luxiReqQueryInstances
4558
  , luxiReqQueryJobs
4559
  , luxiReqQueryNodes
4560
  , luxiReqQueryNetworks
4561
  , luxiReqQueryTags
4562
  , luxiReqSetDrainFlag
4563
  , luxiReqSetWatcherPause
4564
  , luxiReqSubmitJob
4565
  , luxiReqSubmitJobToDrainedQueue
4566
  , luxiReqSubmitManyJobs
4567
  , luxiReqWaitForJobChange
4568
  , luxiReqPickupJob
4569
  ]
4570

    
4571
luxiDefCtmo :: Int
4572
luxiDefCtmo = 10
4573

    
4574
luxiDefRwto :: Int
4575
luxiDefRwto = 60
4576

    
4577
-- | 'WaitForJobChange' timeout
4578
luxiWfjcTimeout :: Int
4579
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4580

    
4581
-- * Query language constants
4582

    
4583
-- ** Logic operators with one or more operands, each of which is a
4584
-- filter on its own
4585

    
4586
qlangOpAnd :: String
4587
qlangOpAnd = "&"
4588

    
4589
qlangOpOr :: String
4590
qlangOpOr = "|"
4591

    
4592
-- ** Unary operators with exactly one operand
4593

    
4594
qlangOpNot :: String
4595
qlangOpNot = "!"
4596

    
4597
qlangOpTrue :: String
4598
qlangOpTrue = "?"
4599

    
4600
-- ** Binary operators with exactly two operands, the field name and
4601
-- an operator-specific value
4602

    
4603
qlangOpContains :: String
4604
qlangOpContains = "=[]"
4605

    
4606
qlangOpEqual :: String
4607
qlangOpEqual = "="
4608

    
4609
qlangOpGe :: String
4610
qlangOpGe = ">="
4611

    
4612
qlangOpGt :: String
4613
qlangOpGt = ">"
4614

    
4615
qlangOpLe :: String
4616
qlangOpLe = "<="
4617

    
4618
qlangOpLt :: String
4619
qlangOpLt = "<"
4620

    
4621
qlangOpNotEqual :: String
4622
qlangOpNotEqual = "!="
4623

    
4624
qlangOpRegexp :: String
4625
qlangOpRegexp = "=~"
4626

    
4627
-- | Characters used for detecting user-written filters (see
4628
-- L{_CheckFilter})
4629

    
4630
qlangFilterDetectionChars :: FrozenSet String
4631
qlangFilterDetectionChars =
4632
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4633
                       ")", "(", "\x0b", "\n",
4634
                       "\r", "\x0c", "/", "<",
4635
                       "\t", ">", "=", "\\", "~"]
4636

    
4637
-- | Characters used to detect globbing filters
4638
qlangGlobDetectionChars :: FrozenSet String
4639
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4640

    
4641
-- * Error related constants
4642
--
4643
-- 'OpPrereqError' failure types
4644

    
4645
-- | Environment error (e.g. node disk error)
4646
errorsEcodeEnviron :: String
4647
errorsEcodeEnviron = "environment_error"
4648

    
4649
-- | Entity already exists
4650
errorsEcodeExists :: String
4651
errorsEcodeExists = "already_exists"
4652

    
4653
-- | Internal cluster error
4654
errorsEcodeFault :: String
4655
errorsEcodeFault = "internal_error"
4656

    
4657
-- | Wrong arguments (at syntax level)
4658
errorsEcodeInval :: String
4659
errorsEcodeInval = "wrong_input"
4660

    
4661
-- | Entity not found
4662
errorsEcodeNoent :: String
4663
errorsEcodeNoent = "unknown_entity"
4664

    
4665
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4666
errorsEcodeNores :: String
4667
errorsEcodeNores = "insufficient_resources"
4668

    
4669
-- | Resource not unique (e.g. MAC or IP duplication)
4670
errorsEcodeNotunique :: String
4671
errorsEcodeNotunique = "resource_not_unique"
4672

    
4673
-- | Resolver errors
4674
errorsEcodeResolver :: String
4675
errorsEcodeResolver = "resolver_error"
4676

    
4677
-- | Wrong entity state
4678
errorsEcodeState :: String
4679
errorsEcodeState = "wrong_state"
4680

    
4681
-- | Temporarily out of resources; operation can be tried again
4682
errorsEcodeTempNores :: String
4683
errorsEcodeTempNores = "temp_insufficient_resources"
4684

    
4685
errorsEcodeAll :: FrozenSet String
4686
errorsEcodeAll =
4687
  ConstantUtils.mkSet [ errorsEcodeNores
4688
                      , errorsEcodeExists
4689
                      , errorsEcodeState
4690
                      , errorsEcodeNotunique
4691
                      , errorsEcodeTempNores
4692
                      , errorsEcodeNoent
4693
                      , errorsEcodeFault
4694
                      , errorsEcodeResolver
4695
                      , errorsEcodeInval
4696
                      , errorsEcodeEnviron
4697
                      ]
4698

    
4699
-- * Jstore related constants
4700

    
4701
jstoreJobsPerArchiveDirectory :: Int
4702
jstoreJobsPerArchiveDirectory = 10000
4703

    
4704
-- * Gluster settings
4705

    
4706
-- | Name of the Gluster host setting
4707
glusterHost :: String
4708
glusterHost = "host"
4709

    
4710
-- | Default value of the Gluster host setting
4711
glusterHostDefault :: String
4712
glusterHostDefault = "127.0.0.1"
4713

    
4714
-- | Name of the Gluster volume setting
4715
glusterVolume :: String
4716
glusterVolume = "volume"
4717

    
4718
-- | Default value of the Gluster volume setting
4719
glusterVolumeDefault :: String
4720
glusterVolumeDefault = "gv0"
4721

    
4722
-- | Name of the Gluster port setting
4723
glusterPort :: String
4724
glusterPort = "port"
4725

    
4726
-- | Default value of the Gluster port setting
4727
glusterPortDefault :: Int
4728
glusterPortDefault = 24007