Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ d722af8b

History | View | Annotate | Download (117.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
luxidUser :: String
216
luxidUser = Runtime.daemonUser GanetiLuxid
217

    
218
luxidGroup :: String
219
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
220

    
221
nodedUser :: String
222
nodedUser = Runtime.daemonUser GanetiNoded
223

    
224
nodedGroup :: String
225
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
226

    
227
mondUser :: String
228
mondUser = Runtime.daemonUser GanetiMond
229

    
230
mondGroup :: String
231
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
232

    
233
sshLoginUser :: String
234
sshLoginUser = AutoConf.sshLoginUser
235

    
236
sshConsoleUser :: String
237
sshConsoleUser = AutoConf.sshConsoleUser
238

    
239
-- * Cpu pinning separators and constants
240

    
241
cpuPinningSep :: String
242
cpuPinningSep = ":"
243

    
244
cpuPinningAll :: String
245
cpuPinningAll = "all"
246

    
247
-- | Internal representation of "all"
248
cpuPinningAllVal :: Int
249
cpuPinningAllVal = -1
250

    
251
-- | One "all" entry in a CPU list means CPU pinning is off
252
cpuPinningOff :: [Int]
253
cpuPinningOff = [cpuPinningAllVal]
254

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

    
271
-- | A KVM-specific implementation detail - the following value is
272
-- used to set CPU affinity to all processors (--0 through --31), per
273
-- taskset man page.
274
--
275
-- FIXME: This only works for machines with up to 32 CPU cores
276
cpuPinningAllKvm :: Int
277
cpuPinningAllKvm = 0xFFFFFFFF
278

    
279
-- * Wipe
280

    
281
ddCmd :: String
282
ddCmd = "dd"
283

    
284
-- | 1GB
285
maxWipeChunk :: Int
286
maxWipeChunk = 1024
287

    
288
minWipeChunkPercent :: Int
289
minWipeChunkPercent = 10
290

    
291
-- * Directories
292

    
293
runDirsMode :: Int
294
runDirsMode = 0o775
295

    
296
secureDirMode :: Int
297
secureDirMode = 0o700
298

    
299
secureFileMode :: Int
300
secureFileMode = 0o600
301

    
302
adoptableBlockdevRoot :: String
303
adoptableBlockdevRoot = "/dev/disk/"
304

    
305
-- * 'autoconf' enable/disable
306

    
307
enableConfd :: Bool
308
enableConfd = AutoConf.enableConfd
309

    
310
enableMond :: Bool
311
enableMond = AutoConf.enableMond
312

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

    
316
-- * SSH constants
317

    
318
ssh :: String
319
ssh = "ssh"
320

    
321
scp :: String
322
scp = "scp"
323

    
324
-- * Daemons
325

    
326
confd :: String
327
confd = Runtime.daemonName GanetiConfd
328

    
329
masterd :: String
330
masterd = Runtime.daemonName GanetiMasterd
331

    
332
mond :: String
333
mond = Runtime.daemonName GanetiMond
334

    
335
noded :: String
336
noded = Runtime.daemonName GanetiNoded
337

    
338
luxid :: String
339
luxid = Runtime.daemonName GanetiLuxid
340

    
341
rapi :: String
342
rapi = Runtime.daemonName GanetiRapi
343

    
344
daemons :: FrozenSet String
345
daemons =
346
  ConstantUtils.mkSet [confd,
347
                       luxid,
348
                       masterd,
349
                       mond,
350
                       noded,
351
                       rapi]
352

    
353
defaultConfdPort :: Int
354
defaultConfdPort = 1814
355

    
356
defaultMondPort :: Int
357
defaultMondPort = 1815
358

    
359
defaultNodedPort :: Int
360
defaultNodedPort = 1811
361

    
362
defaultRapiPort :: Int
363
defaultRapiPort = 5080
364

    
365
daemonsPorts :: Map String (Protocol, Int)
366
daemonsPorts =
367
  Map.fromList [(confd, (Udp, defaultConfdPort)),
368
                (mond, (Tcp, defaultMondPort)),
369
                (noded, (Tcp, defaultNodedPort)),
370
                (rapi, (Tcp, defaultRapiPort)),
371
                (ssh, (Tcp, 22))]
372

    
373
firstDrbdPort :: Int
374
firstDrbdPort = 11000
375

    
376
lastDrbdPort :: Int
377
lastDrbdPort = 14999
378

    
379
daemonsLogbase :: Map String String
380
daemonsLogbase =
381
  Map.fromList
382
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
383

    
384
daemonsExtraLogbase :: Map String (Map String String)
385
daemonsExtraLogbase =
386
  Map.fromList $
387
  map (Runtime.daemonName *** id)
388
  [ (GanetiMond, Map.fromList
389
                 [ ("access", Runtime.daemonsExtraLogbase GanetiMond AccessLog)
390
                 , ("error", Runtime.daemonsExtraLogbase GanetiMond ErrorLog)
391
                 ])
392
  ]
393

    
394
extraLogreasonAccess :: String
395
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
396

    
397
extraLogreasonError :: String
398
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
399

    
400
devConsole :: String
401
devConsole = ConstantUtils.devConsole
402

    
403
procMounts :: String
404
procMounts = "/proc/mounts"
405

    
406
-- * Luxi (Local UniX Interface) related constants
407

    
408
luxiEom :: PythonChar
409
luxiEom = PythonChar '\x03'
410

    
411
-- | Environment variable for the luxi override socket
412
luxiOverride :: String
413
luxiOverride = "FORCE_LUXI_SOCKET"
414

    
415
luxiOverrideMaster :: String
416
luxiOverrideMaster = "master"
417

    
418
luxiOverrideQuery :: String
419
luxiOverrideQuery = "query"
420

    
421
luxiVersion :: Int
422
luxiVersion = configVersion
423

    
424
-- * Syslog
425

    
426
syslogUsage :: String
427
syslogUsage = AutoConf.syslogUsage
428

    
429
syslogNo :: String
430
syslogNo = Logging.syslogUsageToRaw SyslogNo
431

    
432
syslogYes :: String
433
syslogYes = Logging.syslogUsageToRaw SyslogYes
434

    
435
syslogOnly :: String
436
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
437

    
438
syslogSocket :: String
439
syslogSocket = "/dev/log"
440

    
441
exportConfFile :: String
442
exportConfFile = "config.ini"
443

    
444
-- * Xen
445

    
446
xenBootloader :: String
447
xenBootloader = AutoConf.xenBootloader
448

    
449
xenCmdXl :: String
450
xenCmdXl = "xl"
451

    
452
xenCmdXm :: String
453
xenCmdXm = "xm"
454

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

    
458
xenKernel :: String
459
xenKernel = AutoConf.xenKernel
460

    
461
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
462
-- other constants
463
knownXenCommands :: FrozenSet String
464
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
465

    
466
-- * KVM and socat
467

    
468
kvmPath :: String
469
kvmPath = AutoConf.kvmPath
470

    
471
kvmKernel :: String
472
kvmKernel = AutoConf.kvmKernel
473

    
474
socatEscapeCode :: String
475
socatEscapeCode = "0x1d"
476

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

    
480
socatUseCompress :: Bool
481
socatUseCompress = AutoConf.socatUseCompress
482

    
483
socatUseEscape :: Bool
484
socatUseEscape = AutoConf.socatUseEscape
485

    
486
-- * Console types
487

    
488
-- | Display a message for console access
489
consMessage :: String
490
consMessage = "msg"
491

    
492
-- | Console as SPICE server
493
consSpice :: String
494
consSpice = "spice"
495

    
496
-- | Console as SSH command
497
consSsh :: String
498
consSsh = "ssh"
499

    
500
-- | Console as VNC server
501
consVnc :: String
502
consVnc = "vnc"
503

    
504
consAll :: FrozenSet String
505
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
506

    
507
-- | RSA key bit length
508
--
509
-- For RSA keys more bits are better, but they also make operations
510
-- more expensive. NIST SP 800-131 recommends a minimum of 2048 bits
511
-- from the year 2010 on.
512
rsaKeyBits :: Int
513
rsaKeyBits = 2048
514

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

    
526
-- * X509
527

    
528
-- | commonName (CN) used in certificates
529
x509CertCn :: String
530
x509CertCn = "ganeti.example.com"
531

    
532
-- | Default validity of certificates in days
533
x509CertDefaultValidity :: Int
534
x509CertDefaultValidity = 365 * 5
535

    
536
x509CertSignatureHeader :: String
537
x509CertSignatureHeader = "X-Ganeti-Signature"
538

    
539
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
540
x509CertSignDigest :: String
541
x509CertSignDigest = "SHA1"
542

    
543
-- * Import/export daemon mode
544

    
545
iemExport :: String
546
iemExport = "export"
547

    
548
iemImport :: String
549
iemImport = "import"
550

    
551
-- * Import/export transport compression
552

    
553
iecGzip :: String
554
iecGzip = "gzip"
555

    
556
iecNone :: String
557
iecNone = "none"
558

    
559
iecAll :: [String]
560
iecAll = [iecGzip, iecNone]
561

    
562
ieCustomSize :: String
563
ieCustomSize = "fd"
564

    
565
-- * Import/export I/O
566

    
567
-- | Direct file I/O, equivalent to a shell's I/O redirection using
568
-- '<' or '>'
569
ieioFile :: String
570
ieioFile = "file"
571

    
572
-- | Raw block device I/O using "dd"
573
ieioRawDisk :: String
574
ieioRawDisk = "raw"
575

    
576
-- | OS definition import/export script
577
ieioScript :: String
578
ieioScript = "script"
579

    
580
-- * Values
581

    
582
valueDefault :: String
583
valueDefault = "default"
584

    
585
valueAuto :: String
586
valueAuto = "auto"
587

    
588
valueGenerate :: String
589
valueGenerate = "generate"
590

    
591
valueNone :: String
592
valueNone = "none"
593

    
594
valueTrue :: String
595
valueTrue = "true"
596

    
597
valueFalse :: String
598
valueFalse = "false"
599

    
600
-- * Hooks
601

    
602
hooksNameCfgupdate :: String
603
hooksNameCfgupdate = "config-update"
604

    
605
hooksNameWatcher :: String
606
hooksNameWatcher = "watcher"
607

    
608
hooksPath :: String
609
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
610

    
611
hooksPhasePost :: String
612
hooksPhasePost = "post"
613

    
614
hooksPhasePre :: String
615
hooksPhasePre = "pre"
616

    
617
hooksVersion :: Int
618
hooksVersion = 2
619

    
620
-- * Hooks subject type (what object type does the LU deal with)
621

    
622
htypeCluster :: String
623
htypeCluster = "CLUSTER"
624

    
625
htypeGroup :: String
626
htypeGroup = "GROUP"
627

    
628
htypeInstance :: String
629
htypeInstance = "INSTANCE"
630

    
631
htypeNetwork :: String
632
htypeNetwork = "NETWORK"
633

    
634
htypeNode :: String
635
htypeNode = "NODE"
636

    
637
-- * Hkr
638

    
639
hkrSkip :: Int
640
hkrSkip = 0
641

    
642
hkrFail :: Int
643
hkrFail = 1
644

    
645
hkrSuccess :: Int
646
hkrSuccess = 2
647

    
648
-- * Storage types
649

    
650
stBlock :: String
651
stBlock = Types.storageTypeToRaw StorageBlock
652

    
653
stDiskless :: String
654
stDiskless = Types.storageTypeToRaw StorageDiskless
655

    
656
stExt :: String
657
stExt = Types.storageTypeToRaw StorageExt
658

    
659
stFile :: String
660
stFile = Types.storageTypeToRaw StorageFile
661

    
662
stSharedFile :: String
663
stSharedFile = Types.storageTypeToRaw StorageSharedFile
664

    
665
stLvmPv :: String
666
stLvmPv = Types.storageTypeToRaw StorageLvmPv
667

    
668
stLvmVg :: String
669
stLvmVg = Types.storageTypeToRaw StorageLvmVg
670

    
671
stRados :: String
672
stRados = Types.storageTypeToRaw StorageRados
673

    
674
storageTypes :: FrozenSet String
675
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
676

    
677
-- | The set of storage types for which full storage reporting is available
678
stsReport :: FrozenSet String
679
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
680

    
681
-- | The set of storage types for which node storage reporting is available
682
-- | (as used by LUQueryNodeStorage)
683
stsReportNodeStorage :: FrozenSet String
684
stsReportNodeStorage = ConstantUtils.union stsReport $
685
                                           ConstantUtils.mkSet [stSharedFile]
686

    
687
-- * Storage fields
688
-- ** First two are valid in LU context only, not passed to backend
689

    
690
sfNode :: String
691
sfNode = "node"
692

    
693
sfType :: String
694
sfType = "type"
695

    
696
-- ** and the rest are valid in backend
697

    
698
sfAllocatable :: String
699
sfAllocatable = Types.storageFieldToRaw SFAllocatable
700

    
701
sfFree :: String
702
sfFree = Types.storageFieldToRaw SFFree
703

    
704
sfName :: String
705
sfName = Types.storageFieldToRaw SFName
706

    
707
sfSize :: String
708
sfSize = Types.storageFieldToRaw SFSize
709

    
710
sfUsed :: String
711
sfUsed = Types.storageFieldToRaw SFUsed
712

    
713
validStorageFields :: FrozenSet String
714
validStorageFields =
715
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
716
                        [sfNode, sfType]
717

    
718
modifiableStorageFields :: Map String (FrozenSet String)
719
modifiableStorageFields =
720
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
721
                 ConstantUtils.mkSet [sfAllocatable])]
722

    
723
-- * Storage operations
724

    
725
soFixConsistency :: String
726
soFixConsistency = "fix-consistency"
727

    
728
validStorageOperations :: Map String (FrozenSet String)
729
validStorageOperations =
730
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
731
                 ConstantUtils.mkSet [soFixConsistency])]
732

    
733
-- * Volume fields
734

    
735
vfDev :: String
736
vfDev = "dev"
737

    
738
vfInstance :: String
739
vfInstance = "instance"
740

    
741
vfName :: String
742
vfName = "name"
743

    
744
vfNode :: String
745
vfNode = "node"
746

    
747
vfPhys :: String
748
vfPhys = "phys"
749

    
750
vfSize :: String
751
vfSize = "size"
752

    
753
vfVg :: String
754
vfVg = "vg"
755

    
756
-- * Local disk status
757

    
758
ldsFaulty :: Int
759
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
760

    
761
ldsOkay :: Int
762
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
763

    
764
ldsUnknown :: Int
765
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
766

    
767
ldsNames :: Map Int String
768
ldsNames =
769
  Map.fromList [ (Types.localDiskStatusToRaw ds,
770
                  localDiskStatusName ds) | ds <- [minBound..] ]
771

    
772
-- * Disk template types
773

    
774
dtDiskless :: String
775
dtDiskless = Types.diskTemplateToRaw DTDiskless
776

    
777
dtFile :: String
778
dtFile = Types.diskTemplateToRaw DTFile
779

    
780
dtSharedFile :: String
781
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
782

    
783
dtPlain :: String
784
dtPlain = Types.diskTemplateToRaw DTPlain
785

    
786
dtBlock :: String
787
dtBlock = Types.diskTemplateToRaw DTBlock
788

    
789
dtDrbd8 :: String
790
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
791

    
792
dtRbd :: String
793
dtRbd = Types.diskTemplateToRaw DTRbd
794

    
795
dtExt :: String
796
dtExt = Types.diskTemplateToRaw DTExt
797

    
798
dtGluster :: String
799
dtGluster = Types.diskTemplateToRaw DTGluster
800

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

    
812
diskTemplates :: FrozenSet String
813
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
814

    
815
-- | Disk templates that are enabled by default
816
defaultEnabledDiskTemplates :: [String]
817
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
818

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

    
834
-- | The set of network-mirrored disk templates
835
dtsIntMirror :: FrozenSet String
836
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
837

    
838
-- | 'DTDiskless' is 'trivially' externally mirrored
839
dtsExtMirror :: FrozenSet String
840
dtsExtMirror =
841
  ConstantUtils.mkSet $
842
  map Types.diskTemplateToRaw
843
  [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd, DTGluster]
844

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

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

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

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

    
868
-- | The set of disk templates that allow migrations
869
dtsMirrored :: FrozenSet String
870
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
871

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

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

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

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

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

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

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

    
910
-- * Drbd
911

    
912
drbdHmacAlg :: String
913
drbdHmacAlg = "md5"
914

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

    
918
drbdMigrationNetProtocol :: String
919
drbdMigrationNetProtocol = "C"
920

    
921
drbdStatusFile :: String
922
drbdStatusFile = "/proc/drbd"
923

    
924
-- | Size of DRBD meta block device
925
drbdMetaSize :: Int
926
drbdMetaSize = 128
927

    
928
-- * Drbd barrier types
929

    
930
drbdBDiskBarriers :: String
931
drbdBDiskBarriers = "b"
932

    
933
drbdBDiskDrain :: String
934
drbdBDiskDrain = "d"
935

    
936
drbdBDiskFlush :: String
937
drbdBDiskFlush = "f"
938

    
939
drbdBNone :: String
940
drbdBNone = "n"
941

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

    
956
-- | Rbd tool command
957
rbdCmd :: String
958
rbdCmd = "rbd"
959

    
960
-- * File backend driver
961

    
962
fdBlktap :: String
963
fdBlktap = Types.fileDriverToRaw FileBlktap
964

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

    
968
fdDefault :: String
969
fdDefault = fdLoop
970

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

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

    
980
-- * Disk access mode
981

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

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

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

    
991
-- * Disk replacement mode
992

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

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

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

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

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

    
1009
-- * Instance export mode
1010

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

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

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

    
1020
-- * Instance creation modes
1021

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

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

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

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

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

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

    
1040
rieVersion :: Int
1041
rieVersion = 0
1042

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

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

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

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

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

    
1063
-- * Import/export config options
1064

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

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

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

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

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

    
1080
-- * Dynamic device modification
1081

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

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

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

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

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

    
1097
-- * Common exit codes
1098

    
1099
exitSuccess :: Int
1100
exitSuccess = 0
1101

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

    
1105
exitNotcluster :: Int
1106
exitNotcluster = 5
1107

    
1108
exitNotmaster :: Int
1109
exitNotmaster = 11
1110

    
1111
exitNodesetupError :: Int
1112
exitNodesetupError = 12
1113

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

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

    
1122
-- * Tags
1123

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

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

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

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

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

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

    
1142
maxTagLen :: Int
1143
maxTagLen = 128
1144

    
1145
maxTagsPerObj :: Int
1146
maxTagsPerObj = 4096
1147

    
1148
-- * Others
1149

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

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

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

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

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

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

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

    
1172
ip4Version :: Int
1173
ip4Version = 4
1174

    
1175
ip6Version :: Int
1176
ip6Version = 6
1177

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

    
1181
tcpPingTimeout :: Int
1182
tcpPingTimeout = 10
1183

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

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

    
1190
minVgSize :: Int
1191
minVgSize = 20480
1192

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

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

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

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

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

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

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

    
1219
-- * Runparts results
1220

    
1221
runpartsErr :: Int
1222
runpartsErr = 2
1223

    
1224
runpartsRun :: Int
1225
runpartsRun = 1
1226

    
1227
runpartsSkip :: Int
1228
runpartsSkip = 0
1229

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

    
1233
-- * RPC
1234

    
1235
rpcEncodingNone :: Int
1236
rpcEncodingNone = 0
1237

    
1238
rpcEncodingZlibBase64 :: Int
1239
rpcEncodingZlibBase64 = 1
1240

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

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

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

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

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

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

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

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

    
1273
-- OS
1274

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1332
esScriptCreate :: String
1333
esScriptCreate = esActionCreate
1334

    
1335
esScriptRemove :: String
1336
esScriptRemove = esActionRemove
1337

    
1338
esScriptGrow :: String
1339
esScriptGrow = esActionGrow
1340

    
1341
esScriptAttach :: String
1342
esScriptAttach = esActionAttach
1343

    
1344
esScriptDetach :: String
1345
esScriptDetach = esActionDetach
1346

    
1347
esScriptSetinfo :: String
1348
esScriptSetinfo = esActionSetinfo
1349

    
1350
esScriptVerify :: String
1351
esScriptVerify = esActionVerify
1352

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

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

    
1366
-- * Reboot types
1367

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

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

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

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

    
1380
-- * Instance reboot behaviors
1381

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

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

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

    
1391
-- * VTypes
1392

    
1393
vtypeBool :: VType
1394
vtypeBool = VTypeBool
1395

    
1396
vtypeInt :: VType
1397
vtypeInt = VTypeInt
1398

    
1399
vtypeMaybeString :: VType
1400
vtypeMaybeString = VTypeMaybeString
1401

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

    
1406
vtypeString :: VType
1407
vtypeString = VTypeString
1408

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1749
-- * Migration statuses
1750

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

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

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

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

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

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

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

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

    
1784
-- * Hypervisor state
1785

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

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

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

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

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

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

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

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

    
1826
-- * Disk state
1827

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

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

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

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

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

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

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

    
1857
-- Backend parameter names
1858

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1986
-- | Node parameter names
1987

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

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

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

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

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

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

    
2006
ndSshPort :: String
2007
ndSshPort = "ssh_port"
2008

    
2009
ndsParameterTypes :: Map String VType
2010
ndsParameterTypes =
2011
  Map.fromList
2012
  [(ndExclusiveStorage, VTypeBool),
2013
   (ndOobProgram, VTypeString),
2014
   (ndOvs, VTypeBool),
2015
   (ndOvsLink, VTypeMaybeString),
2016
   (ndOvsName, VTypeMaybeString),
2017
   (ndSpindleCount, VTypeInt),
2018
   (ndSshPort, VTypeInt)]
2019

    
2020
ndsParameters :: FrozenSet String
2021
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
2022

    
2023
ndsParameterTitles :: Map String String
2024
ndsParameterTitles =
2025
  Map.fromList
2026
  [(ndExclusiveStorage, "ExclusiveStorage"),
2027
   (ndOobProgram, "OutOfBandProgram"),
2028
   (ndOvs, "OpenvSwitch"),
2029
   (ndOvsLink, "OpenvSwitchLink"),
2030
   (ndOvsName, "OpenvSwitchName"),
2031
   (ndSpindleCount, "SpindleCount")]
2032

    
2033
-- * Logical Disks parameters
2034

    
2035
ldpAccess :: String
2036
ldpAccess = "access"
2037

    
2038
ldpBarriers :: String
2039
ldpBarriers = "disabled-barriers"
2040

    
2041
ldpDefaultMetavg :: String
2042
ldpDefaultMetavg = "default-metavg"
2043

    
2044
ldpDelayTarget :: String
2045
ldpDelayTarget = "c-delay-target"
2046

    
2047
ldpDiskCustom :: String
2048
ldpDiskCustom = "disk-custom"
2049

    
2050
ldpDynamicResync :: String
2051
ldpDynamicResync = "dynamic-resync"
2052

    
2053
ldpFillTarget :: String
2054
ldpFillTarget = "c-fill-target"
2055

    
2056
ldpMaxRate :: String
2057
ldpMaxRate = "c-max-rate"
2058

    
2059
ldpMinRate :: String
2060
ldpMinRate = "c-min-rate"
2061

    
2062
ldpNetCustom :: String
2063
ldpNetCustom = "net-custom"
2064

    
2065
ldpNoMetaFlush :: String
2066
ldpNoMetaFlush = "disable-meta-flush"
2067

    
2068
ldpPlanAhead :: String
2069
ldpPlanAhead = "c-plan-ahead"
2070

    
2071
ldpPool :: String
2072
ldpPool = "pool"
2073

    
2074
ldpProtocol :: String
2075
ldpProtocol = "protocol"
2076

    
2077
ldpResyncRate :: String
2078
ldpResyncRate = "resync-rate"
2079

    
2080
ldpStripes :: String
2081
ldpStripes = "stripes"
2082

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

    
2103
diskLdParameters :: FrozenSet String
2104
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2105

    
2106
-- * Disk template parameters
2107
--
2108
-- Disk template parameters can be set/changed by the user via
2109
-- gnt-cluster and gnt-group)
2110

    
2111
drbdResyncRate :: String
2112
drbdResyncRate = "resync-rate"
2113

    
2114
drbdDataStripes :: String
2115
drbdDataStripes = "data-stripes"
2116

    
2117
drbdMetaStripes :: String
2118
drbdMetaStripes = "meta-stripes"
2119

    
2120
drbdDiskBarriers :: String
2121
drbdDiskBarriers = "disk-barriers"
2122

    
2123
drbdMetaBarriers :: String
2124
drbdMetaBarriers = "meta-barriers"
2125

    
2126
drbdDefaultMetavg :: String
2127
drbdDefaultMetavg = "metavg"
2128

    
2129
drbdDiskCustom :: String
2130
drbdDiskCustom = "disk-custom"
2131

    
2132
drbdNetCustom :: String
2133
drbdNetCustom = "net-custom"
2134

    
2135
drbdProtocol :: String
2136
drbdProtocol = "protocol"
2137

    
2138
drbdDynamicResync :: String
2139
drbdDynamicResync = "dynamic-resync"
2140

    
2141
drbdPlanAhead :: String
2142
drbdPlanAhead = "c-plan-ahead"
2143

    
2144
drbdFillTarget :: String
2145
drbdFillTarget = "c-fill-target"
2146

    
2147
drbdDelayTarget :: String
2148
drbdDelayTarget = "c-delay-target"
2149

    
2150
drbdMaxRate :: String
2151
drbdMaxRate = "c-max-rate"
2152

    
2153
drbdMinRate :: String
2154
drbdMinRate = "c-min-rate"
2155

    
2156
lvStripes :: String
2157
lvStripes = "stripes"
2158

    
2159
rbdAccess :: String
2160
rbdAccess = "access"
2161

    
2162
rbdPool :: String
2163
rbdPool = "pool"
2164

    
2165
diskDtTypes :: Map String VType
2166
diskDtTypes =
2167
  Map.fromList [(drbdResyncRate, VTypeInt),
2168
                (drbdDataStripes, VTypeInt),
2169
                (drbdMetaStripes, VTypeInt),
2170
                (drbdDiskBarriers, VTypeString),
2171
                (drbdMetaBarriers, VTypeBool),
2172
                (drbdDefaultMetavg, VTypeString),
2173
                (drbdDiskCustom, VTypeString),
2174
                (drbdNetCustom, VTypeString),
2175
                (drbdProtocol, VTypeString),
2176
                (drbdDynamicResync, VTypeBool),
2177
                (drbdPlanAhead, VTypeInt),
2178
                (drbdFillTarget, VTypeInt),
2179
                (drbdDelayTarget, VTypeInt),
2180
                (drbdMaxRate, VTypeInt),
2181
                (drbdMinRate, VTypeInt),
2182
                (lvStripes, VTypeInt),
2183
                (rbdAccess, VTypeString),
2184
                (rbdPool, VTypeString),
2185
                (glusterHost, VTypeString),
2186
                (glusterVolume, VTypeString),
2187
                (glusterPort, VTypeInt)
2188
               ]
2189

    
2190
diskDtParameters :: FrozenSet String
2191
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2192

    
2193
-- * Dynamic disk parameters
2194

    
2195
ddpLocalIp :: String
2196
ddpLocalIp = "local-ip"
2197

    
2198
ddpRemoteIp :: String
2199
ddpRemoteIp = "remote-ip"
2200

    
2201
ddpPort :: String
2202
ddpPort = "port"
2203

    
2204
ddpLocalMinor :: String
2205
ddpLocalMinor = "local-minor"
2206

    
2207
ddpRemoteMinor :: String
2208
ddpRemoteMinor = "remote-minor"
2209

    
2210
-- * OOB supported commands
2211

    
2212
oobPowerOn :: String
2213
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2214

    
2215
oobPowerOff :: String
2216
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2217

    
2218
oobPowerCycle :: String
2219
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2220

    
2221
oobPowerStatus :: String
2222
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2223

    
2224
oobHealth :: String
2225
oobHealth = Types.oobCommandToRaw OobHealth
2226

    
2227
oobCommands :: FrozenSet String
2228
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2229

    
2230
oobPowerStatusPowered :: String
2231
oobPowerStatusPowered = "powered"
2232

    
2233
-- | 60 seconds
2234
oobTimeout :: Int
2235
oobTimeout = 60
2236

    
2237
-- | 2 seconds
2238
oobPowerDelay :: Double
2239
oobPowerDelay = 2.0
2240

    
2241
oobStatusCritical :: String
2242
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2243

    
2244
oobStatusOk :: String
2245
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2246

    
2247
oobStatusUnknown :: String
2248
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2249

    
2250
oobStatusWarning :: String
2251
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2252

    
2253
oobStatuses :: FrozenSet String
2254
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2255

    
2256
-- | Instance Parameters Profile
2257
ppDefault :: String
2258
ppDefault = "default"
2259

    
2260
-- * nic* constants are used inside the ganeti config
2261

    
2262
nicLink :: String
2263
nicLink = "link"
2264

    
2265
nicMode :: String
2266
nicMode = "mode"
2267

    
2268
nicVlan :: String
2269
nicVlan = "vlan"
2270

    
2271
nicsParameterTypes :: Map String VType
2272
nicsParameterTypes =
2273
  Map.fromList [(nicMode, vtypeString),
2274
                (nicLink, vtypeString),
2275
                (nicVlan, vtypeString)]
2276

    
2277
nicsParameters :: FrozenSet String
2278
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2279

    
2280
nicModeBridged :: String
2281
nicModeBridged = Types.nICModeToRaw NMBridged
2282

    
2283
nicModeRouted :: String
2284
nicModeRouted = Types.nICModeToRaw NMRouted
2285

    
2286
nicModeOvs :: String
2287
nicModeOvs = Types.nICModeToRaw NMOvs
2288

    
2289
nicIpPool :: String
2290
nicIpPool = Types.nICModeToRaw NMPool
2291

    
2292
nicValidModes :: FrozenSet String
2293
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2294

    
2295
releaseAction :: String
2296
releaseAction = "release"
2297

    
2298
reserveAction :: String
2299
reserveAction = "reserve"
2300

    
2301
-- * idisk* constants are used in opcodes, to create/change disks
2302

    
2303
idiskAdopt :: String
2304
idiskAdopt = "adopt"
2305

    
2306
idiskMetavg :: String
2307
idiskMetavg = "metavg"
2308

    
2309
idiskMode :: String
2310
idiskMode = "mode"
2311

    
2312
idiskName :: String
2313
idiskName = "name"
2314

    
2315
idiskSize :: String
2316
idiskSize = "size"
2317

    
2318
idiskSpindles :: String
2319
idiskSpindles = "spindles"
2320

    
2321
idiskVg :: String
2322
idiskVg = "vg"
2323

    
2324
idiskProvider :: String
2325
idiskProvider = "provider"
2326

    
2327
idiskParamsTypes :: Map String VType
2328
idiskParamsTypes =
2329
  Map.fromList [(idiskSize, VTypeSize),
2330
                (idiskSpindles, VTypeInt),
2331
                (idiskMode, VTypeString),
2332
                (idiskAdopt, VTypeString),
2333
                (idiskVg, VTypeString),
2334
                (idiskMetavg, VTypeString),
2335
                (idiskProvider, VTypeString),
2336
                (idiskName, VTypeMaybeString)]
2337

    
2338
idiskParams :: FrozenSet String
2339
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2340

    
2341
modifiableIdiskParamsTypes :: Map String VType
2342
modifiableIdiskParamsTypes =
2343
  Map.fromList [(idiskMode, VTypeString),
2344
                (idiskName, VTypeString)]
2345

    
2346
modifiableIdiskParams :: FrozenSet String
2347
modifiableIdiskParams =
2348
  ConstantUtils.mkSet (Map.keys modifiableIdiskParamsTypes)
2349

    
2350
-- * inic* constants are used in opcodes, to create/change nics
2351

    
2352
inicBridge :: String
2353
inicBridge = "bridge"
2354

    
2355
inicIp :: String
2356
inicIp = "ip"
2357

    
2358
inicLink :: String
2359
inicLink = "link"
2360

    
2361
inicMac :: String
2362
inicMac = "mac"
2363

    
2364
inicMode :: String
2365
inicMode = "mode"
2366

    
2367
inicName :: String
2368
inicName = "name"
2369

    
2370
inicNetwork :: String
2371
inicNetwork = "network"
2372

    
2373
inicVlan :: String
2374
inicVlan = "vlan"
2375

    
2376
inicParamsTypes :: Map String VType
2377
inicParamsTypes =
2378
  Map.fromList [(inicBridge, VTypeMaybeString),
2379
                (inicIp, VTypeMaybeString),
2380
                (inicLink, VTypeString),
2381
                (inicMac, VTypeString),
2382
                (inicMode, VTypeString),
2383
                (inicName, VTypeMaybeString),
2384
                (inicNetwork, VTypeMaybeString),
2385
                (inicVlan, VTypeMaybeString)]
2386

    
2387
inicParams :: FrozenSet String
2388
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2389

    
2390
-- * Hypervisor constants
2391

    
2392
htXenPvm :: String
2393
htXenPvm = Types.hypervisorToRaw XenPvm
2394

    
2395
htFake :: String
2396
htFake = Types.hypervisorToRaw Fake
2397

    
2398
htXenHvm :: String
2399
htXenHvm = Types.hypervisorToRaw XenHvm
2400

    
2401
htKvm :: String
2402
htKvm = Types.hypervisorToRaw Kvm
2403

    
2404
htChroot :: String
2405
htChroot = Types.hypervisorToRaw Chroot
2406

    
2407
htLxc :: String
2408
htLxc = Types.hypervisorToRaw Lxc
2409

    
2410
hyperTypes :: FrozenSet String
2411
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2412

    
2413
htsReqPort :: FrozenSet String
2414
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2415

    
2416
vncBasePort :: Int
2417
vncBasePort = 5900
2418

    
2419
vncDefaultBindAddress :: String
2420
vncDefaultBindAddress = ip4AddressAny
2421

    
2422
-- * NIC types
2423

    
2424
htNicE1000 :: String
2425
htNicE1000 = "e1000"
2426

    
2427
htNicI82551 :: String
2428
htNicI82551 = "i82551"
2429

    
2430
htNicI8259er :: String
2431
htNicI8259er = "i82559er"
2432

    
2433
htNicI85557b :: String
2434
htNicI85557b = "i82557b"
2435

    
2436
htNicNe2kIsa :: String
2437
htNicNe2kIsa = "ne2k_isa"
2438

    
2439
htNicNe2kPci :: String
2440
htNicNe2kPci = "ne2k_pci"
2441

    
2442
htNicParavirtual :: String
2443
htNicParavirtual = "paravirtual"
2444

    
2445
htNicPcnet :: String
2446
htNicPcnet = "pcnet"
2447

    
2448
htNicRtl8139 :: String
2449
htNicRtl8139 = "rtl8139"
2450

    
2451
htHvmValidNicTypes :: FrozenSet String
2452
htHvmValidNicTypes =
2453
  ConstantUtils.mkSet [htNicE1000,
2454
                       htNicNe2kIsa,
2455
                       htNicNe2kPci,
2456
                       htNicParavirtual,
2457
                       htNicRtl8139]
2458

    
2459
htKvmValidNicTypes :: FrozenSet String
2460
htKvmValidNicTypes =
2461
  ConstantUtils.mkSet [htNicE1000,
2462
                       htNicI82551,
2463
                       htNicI8259er,
2464
                       htNicI85557b,
2465
                       htNicNe2kIsa,
2466
                       htNicNe2kPci,
2467
                       htNicParavirtual,
2468
                       htNicPcnet,
2469
                       htNicRtl8139]
2470

    
2471
-- * Vif types
2472

    
2473
-- | Default vif type in xen-hvm
2474
htHvmVifIoemu :: String
2475
htHvmVifIoemu = "ioemu"
2476

    
2477
htHvmVifVif :: String
2478
htHvmVifVif = "vif"
2479

    
2480
htHvmValidVifTypes :: FrozenSet String
2481
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2482

    
2483
-- * Disk types
2484

    
2485
htDiskIde :: String
2486
htDiskIde = "ide"
2487

    
2488
htDiskIoemu :: String
2489
htDiskIoemu = "ioemu"
2490

    
2491
htDiskMtd :: String
2492
htDiskMtd = "mtd"
2493

    
2494
htDiskParavirtual :: String
2495
htDiskParavirtual = "paravirtual"
2496

    
2497
htDiskPflash :: String
2498
htDiskPflash = "pflash"
2499

    
2500
htDiskScsi :: String
2501
htDiskScsi = "scsi"
2502

    
2503
htDiskSd :: String
2504
htDiskSd = "sd"
2505

    
2506
htHvmValidDiskTypes :: FrozenSet String
2507
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2508

    
2509
htKvmValidDiskTypes :: FrozenSet String
2510
htKvmValidDiskTypes =
2511
  ConstantUtils.mkSet [htDiskIde,
2512
                       htDiskMtd,
2513
                       htDiskParavirtual,
2514
                       htDiskPflash,
2515
                       htDiskScsi,
2516
                       htDiskSd]
2517

    
2518
htCacheDefault :: String
2519
htCacheDefault = "default"
2520

    
2521
htCacheNone :: String
2522
htCacheNone = "none"
2523

    
2524
htCacheWback :: String
2525
htCacheWback = "writeback"
2526

    
2527
htCacheWthrough :: String
2528
htCacheWthrough = "writethrough"
2529

    
2530
htValidCacheTypes :: FrozenSet String
2531
htValidCacheTypes =
2532
  ConstantUtils.mkSet [htCacheDefault,
2533
                       htCacheNone,
2534
                       htCacheWback,
2535
                       htCacheWthrough]
2536

    
2537
-- * Mouse types
2538

    
2539
htMouseMouse :: String
2540
htMouseMouse = "mouse"
2541

    
2542
htMouseTablet :: String
2543
htMouseTablet = "tablet"
2544

    
2545
htKvmValidMouseTypes :: FrozenSet String
2546
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2547

    
2548
-- * Boot order
2549

    
2550
htBoCdrom :: String
2551
htBoCdrom = "cdrom"
2552

    
2553
htBoDisk :: String
2554
htBoDisk = "disk"
2555

    
2556
htBoFloppy :: String
2557
htBoFloppy = "floppy"
2558

    
2559
htBoNetwork :: String
2560
htBoNetwork = "network"
2561

    
2562
htKvmValidBoTypes :: FrozenSet String
2563
htKvmValidBoTypes =
2564
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2565

    
2566
-- * SPICE lossless image compression options
2567

    
2568
htKvmSpiceLosslessImgComprAutoGlz :: String
2569
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2570

    
2571
htKvmSpiceLosslessImgComprAutoLz :: String
2572
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2573

    
2574
htKvmSpiceLosslessImgComprGlz :: String
2575
htKvmSpiceLosslessImgComprGlz = "glz"
2576

    
2577
htKvmSpiceLosslessImgComprLz :: String
2578
htKvmSpiceLosslessImgComprLz = "lz"
2579

    
2580
htKvmSpiceLosslessImgComprOff :: String
2581
htKvmSpiceLosslessImgComprOff = "off"
2582

    
2583
htKvmSpiceLosslessImgComprQuic :: String
2584
htKvmSpiceLosslessImgComprQuic = "quic"
2585

    
2586
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2587
htKvmSpiceValidLosslessImgComprOptions =
2588
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2589
                       htKvmSpiceLosslessImgComprAutoLz,
2590
                       htKvmSpiceLosslessImgComprGlz,
2591
                       htKvmSpiceLosslessImgComprLz,
2592
                       htKvmSpiceLosslessImgComprOff,
2593
                       htKvmSpiceLosslessImgComprQuic]
2594

    
2595
htKvmSpiceLossyImgComprAlways :: String
2596
htKvmSpiceLossyImgComprAlways = "always"
2597

    
2598
htKvmSpiceLossyImgComprAuto :: String
2599
htKvmSpiceLossyImgComprAuto = "auto"
2600

    
2601
htKvmSpiceLossyImgComprNever :: String
2602
htKvmSpiceLossyImgComprNever = "never"
2603

    
2604
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2605
htKvmSpiceValidLossyImgComprOptions =
2606
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2607
                       htKvmSpiceLossyImgComprAuto,
2608
                       htKvmSpiceLossyImgComprNever]
2609

    
2610
-- * SPICE video stream detection
2611

    
2612
htKvmSpiceVideoStreamDetectionAll :: String
2613
htKvmSpiceVideoStreamDetectionAll = "all"
2614

    
2615
htKvmSpiceVideoStreamDetectionFilter :: String
2616
htKvmSpiceVideoStreamDetectionFilter = "filter"
2617

    
2618
htKvmSpiceVideoStreamDetectionOff :: String
2619
htKvmSpiceVideoStreamDetectionOff = "off"
2620

    
2621
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2622
htKvmSpiceValidVideoStreamDetectionOptions =
2623
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2624
                       htKvmSpiceVideoStreamDetectionFilter,
2625
                       htKvmSpiceVideoStreamDetectionOff]
2626

    
2627
-- * Security models
2628

    
2629
htSmNone :: String
2630
htSmNone = "none"
2631

    
2632
htSmPool :: String
2633
htSmPool = "pool"
2634

    
2635
htSmUser :: String
2636
htSmUser = "user"
2637

    
2638
htKvmValidSmTypes :: FrozenSet String
2639
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2640

    
2641
-- * Kvm flag values
2642

    
2643
htKvmDisabled :: String
2644
htKvmDisabled = "disabled"
2645

    
2646
htKvmEnabled :: String
2647
htKvmEnabled = "enabled"
2648

    
2649
htKvmFlagValues :: FrozenSet String
2650
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2651

    
2652
-- * Migration type
2653

    
2654
htMigrationLive :: String
2655
htMigrationLive = Types.migrationModeToRaw MigrationLive
2656

    
2657
htMigrationNonlive :: String
2658
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2659

    
2660
htMigrationModes :: FrozenSet String
2661
htMigrationModes =
2662
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2663

    
2664
-- * Cluster verify steps
2665

    
2666
verifyNplusoneMem :: String
2667
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2668

    
2669
verifyOptionalChecks :: FrozenSet String
2670
verifyOptionalChecks =
2671
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2672

    
2673
-- * Cluster Verify error classes
2674

    
2675
cvTcluster :: String
2676
cvTcluster = "cluster"
2677

    
2678
cvTgroup :: String
2679
cvTgroup = "group"
2680

    
2681
cvTnode :: String
2682
cvTnode = "node"
2683

    
2684
cvTinstance :: String
2685
cvTinstance = "instance"
2686

    
2687
-- * Cluster Verify error codes and documentation
2688

    
2689
cvEclustercert :: (String, String, String)
2690
cvEclustercert =
2691
  ("cluster",
2692
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2693
   "Cluster certificate files verification failure")
2694

    
2695
cvEclustercfg :: (String, String, String)
2696
cvEclustercfg =
2697
  ("cluster",
2698
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2699
   "Cluster configuration verification failure")
2700

    
2701
cvEclusterdanglinginst :: (String, String, String)
2702
cvEclusterdanglinginst =
2703
  ("node",
2704
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2705
   "Some instances have a non-existing primary node")
2706

    
2707
cvEclusterdanglingnodes :: (String, String, String)
2708
cvEclusterdanglingnodes =
2709
  ("node",
2710
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2711
   "Some nodes belong to non-existing groups")
2712

    
2713
cvEclusterfilecheck :: (String, String, String)
2714
cvEclusterfilecheck =
2715
  ("cluster",
2716
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2717
   "Cluster configuration verification failure")
2718

    
2719
cvEgroupdifferentpvsize :: (String, String, String)
2720
cvEgroupdifferentpvsize =
2721
  ("group",
2722
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2723
   "PVs in the group have different sizes")
2724

    
2725
cvEinstancebadnode :: (String, String, String)
2726
cvEinstancebadnode =
2727
  ("instance",
2728
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2729
   "Instance marked as running lives on an offline node")
2730

    
2731
cvEinstancedown :: (String, String, String)
2732
cvEinstancedown =
2733
  ("instance",
2734
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2735
   "Instance not running on its primary node")
2736

    
2737
cvEinstancefaultydisk :: (String, String, String)
2738
cvEinstancefaultydisk =
2739
  ("instance",
2740
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2741
   "Impossible to retrieve status for a disk")
2742

    
2743
cvEinstancelayout :: (String, String, String)
2744
cvEinstancelayout =
2745
  ("instance",
2746
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2747
   "Instance has multiple secondary nodes")
2748

    
2749
cvEinstancemissingcfgparameter :: (String, String, String)
2750
cvEinstancemissingcfgparameter =
2751
  ("instance",
2752
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2753
   "A configuration parameter for an instance is missing")
2754

    
2755
cvEinstancemissingdisk :: (String, String, String)
2756
cvEinstancemissingdisk =
2757
  ("instance",
2758
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2759
   "Missing volume on an instance")
2760

    
2761
cvEinstancepolicy :: (String, String, String)
2762
cvEinstancepolicy =
2763
  ("instance",
2764
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2765
   "Instance does not meet policy")
2766

    
2767
cvEinstancesplitgroups :: (String, String, String)
2768
cvEinstancesplitgroups =
2769
  ("instance",
2770
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2771
   "Instance with primary and secondary nodes in different groups")
2772

    
2773
cvEinstanceunsuitablenode :: (String, String, String)
2774
cvEinstanceunsuitablenode =
2775
  ("instance",
2776
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2777
   "Instance running on nodes that are not suitable for it")
2778

    
2779
cvEinstancewrongnode :: (String, String, String)
2780
cvEinstancewrongnode =
2781
  ("instance",
2782
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2783
   "Instance running on the wrong node")
2784

    
2785
cvEnodedrbd :: (String, String, String)
2786
cvEnodedrbd =
2787
  ("node",
2788
   Types.cVErrorCodeToRaw CvENODEDRBD,
2789
   "Error parsing the DRBD status file")
2790

    
2791
cvEnodedrbdhelper :: (String, String, String)
2792
cvEnodedrbdhelper =
2793
  ("node",
2794
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2795
   "Error caused by the DRBD helper")
2796

    
2797
cvEnodedrbdversion :: (String, String, String)
2798
cvEnodedrbdversion =
2799
  ("node",
2800
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2801
   "DRBD version mismatch within a node group")
2802

    
2803
cvEnodefilecheck :: (String, String, String)
2804
cvEnodefilecheck =
2805
  ("node",
2806
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2807
   "Error retrieving the checksum of the node files")
2808

    
2809
cvEnodefilestoragepaths :: (String, String, String)
2810
cvEnodefilestoragepaths =
2811
  ("node",
2812
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2813
   "Detected bad file storage paths")
2814

    
2815
cvEnodefilestoragepathunusable :: (String, String, String)
2816
cvEnodefilestoragepathunusable =
2817
  ("node",
2818
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2819
   "File storage path unusable")
2820

    
2821
cvEnodehooks :: (String, String, String)
2822
cvEnodehooks =
2823
  ("node",
2824
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2825
   "Communication failure in hooks execution")
2826

    
2827
cvEnodehv :: (String, String, String)
2828
cvEnodehv =
2829
  ("node",
2830
   Types.cVErrorCodeToRaw CvENODEHV,
2831
   "Hypervisor parameters verification failure")
2832

    
2833
cvEnodelvm :: (String, String, String)
2834
cvEnodelvm =
2835
  ("node",
2836
   Types.cVErrorCodeToRaw CvENODELVM,
2837
   "LVM-related node error")
2838

    
2839
cvEnoden1 :: (String, String, String)
2840
cvEnoden1 =
2841
  ("node",
2842
   Types.cVErrorCodeToRaw CvENODEN1,
2843
   "Not enough memory to accommodate instance failovers")
2844

    
2845
cvEnodenet :: (String, String, String)
2846
cvEnodenet =
2847
  ("node",
2848
   Types.cVErrorCodeToRaw CvENODENET,
2849
   "Network-related node error")
2850

    
2851
cvEnodeoobpath :: (String, String, String)
2852
cvEnodeoobpath =
2853
  ("node",
2854
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2855
   "Invalid Out Of Band path")
2856

    
2857
cvEnodeorphaninstance :: (String, String, String)
2858
cvEnodeorphaninstance =
2859
  ("node",
2860
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2861
   "Unknown intance running on a node")
2862

    
2863
cvEnodeorphanlv :: (String, String, String)
2864
cvEnodeorphanlv =
2865
  ("node",
2866
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2867
   "Unknown LVM logical volume")
2868

    
2869
cvEnodeos :: (String, String, String)
2870
cvEnodeos =
2871
  ("node",
2872
   Types.cVErrorCodeToRaw CvENODEOS,
2873
   "OS-related node error")
2874

    
2875
cvEnoderpc :: (String, String, String)
2876
cvEnoderpc =
2877
  ("node",
2878
   Types.cVErrorCodeToRaw CvENODERPC,
2879
   "Error during connection to the primary node of an instance")
2880

    
2881
cvEnodesetup :: (String, String, String)
2882
cvEnodesetup =
2883
  ("node",
2884
   Types.cVErrorCodeToRaw CvENODESETUP,
2885
   "Node setup error")
2886

    
2887
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2888
cvEnodesharedfilestoragepathunusable =
2889
  ("node",
2890
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2891
   "Shared file storage path unusable")
2892

    
2893
cvEnodessh :: (String, String, String)
2894
cvEnodessh =
2895
  ("node",
2896
   Types.cVErrorCodeToRaw CvENODESSH,
2897
   "SSH-related node error")
2898

    
2899
cvEnodetime :: (String, String, String)
2900
cvEnodetime =
2901
  ("node",
2902
   Types.cVErrorCodeToRaw CvENODETIME,
2903
   "Node returned invalid time")
2904

    
2905
cvEnodeuserscripts :: (String, String, String)
2906
cvEnodeuserscripts =
2907
  ("node",
2908
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2909
   "User scripts not present or not executable")
2910

    
2911
cvEnodeversion :: (String, String, String)
2912
cvEnodeversion =
2913
  ("node",
2914
   Types.cVErrorCodeToRaw CvENODEVERSION,
2915
   "Protocol version mismatch or Ganeti version mismatch")
2916

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

    
2959
cvAllEcodesStrings :: FrozenSet String
2960
cvAllEcodesStrings =
2961
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2962

    
2963
-- * Node verify constants
2964

    
2965
nvBridges :: String
2966
nvBridges = "bridges"
2967

    
2968
nvDrbdhelper :: String
2969
nvDrbdhelper = "drbd-helper"
2970

    
2971
nvDrbdversion :: String
2972
nvDrbdversion = "drbd-version"
2973

    
2974
nvDrbdlist :: String
2975
nvDrbdlist = "drbd-list"
2976

    
2977
nvExclusivepvs :: String
2978
nvExclusivepvs = "exclusive-pvs"
2979

    
2980
nvFilelist :: String
2981
nvFilelist = "filelist"
2982

    
2983
nvAcceptedStoragePaths :: String
2984
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2985

    
2986
nvFileStoragePath :: String
2987
nvFileStoragePath = "file-storage-path"
2988

    
2989
nvSharedFileStoragePath :: String
2990
nvSharedFileStoragePath = "shared-file-storage-path"
2991

    
2992
nvHvinfo :: String
2993
nvHvinfo = "hvinfo"
2994

    
2995
nvHvparams :: String
2996
nvHvparams = "hvparms"
2997

    
2998
nvHypervisor :: String
2999
nvHypervisor = "hypervisor"
3000

    
3001
nvInstancelist :: String
3002
nvInstancelist = "instancelist"
3003

    
3004
nvLvlist :: String
3005
nvLvlist = "lvlist"
3006

    
3007
nvMasterip :: String
3008
nvMasterip = "master-ip"
3009

    
3010
nvNodelist :: String
3011
nvNodelist = "nodelist"
3012

    
3013
nvNodenettest :: String
3014
nvNodenettest = "node-net-test"
3015

    
3016
nvNodesetup :: String
3017
nvNodesetup = "nodesetup"
3018

    
3019
nvOobPaths :: String
3020
nvOobPaths = "oob-paths"
3021

    
3022
nvOslist :: String
3023
nvOslist = "oslist"
3024

    
3025
nvPvlist :: String
3026
nvPvlist = "pvlist"
3027

    
3028
nvTime :: String
3029
nvTime = "time"
3030

    
3031
nvUserscripts :: String
3032
nvUserscripts = "user-scripts"
3033

    
3034
nvVersion :: String
3035
nvVersion = "version"
3036

    
3037
nvVglist :: String
3038
nvVglist = "vglist"
3039

    
3040
nvVmnodes :: String
3041
nvVmnodes = "vmnodes"
3042

    
3043
-- * Instance status
3044

    
3045
inststAdmindown :: String
3046
inststAdmindown = Types.instanceStatusToRaw StatusDown
3047

    
3048
inststAdminoffline :: String
3049
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3050

    
3051
inststErrordown :: String
3052
inststErrordown = Types.instanceStatusToRaw ErrorDown
3053

    
3054
inststErrorup :: String
3055
inststErrorup = Types.instanceStatusToRaw ErrorUp
3056

    
3057
inststNodedown :: String
3058
inststNodedown = Types.instanceStatusToRaw NodeDown
3059

    
3060
inststNodeoffline :: String
3061
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3062

    
3063
inststRunning :: String
3064
inststRunning = Types.instanceStatusToRaw Running
3065

    
3066
inststUserdown :: String
3067
inststUserdown = Types.instanceStatusToRaw UserDown
3068

    
3069
inststWrongnode :: String
3070
inststWrongnode = Types.instanceStatusToRaw WrongNode
3071

    
3072
inststAll :: FrozenSet String
3073
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3074

    
3075
-- * Admin states
3076

    
3077
adminstDown :: String
3078
adminstDown = Types.adminStateToRaw AdminDown
3079

    
3080
adminstOffline :: String
3081
adminstOffline = Types.adminStateToRaw AdminOffline
3082

    
3083
adminstUp :: String
3084
adminstUp = Types.adminStateToRaw AdminUp
3085

    
3086
adminstAll :: FrozenSet String
3087
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3088

    
3089
-- * Node roles
3090

    
3091
nrDrained :: String
3092
nrDrained = Types.nodeRoleToRaw NRDrained
3093

    
3094
nrMaster :: String
3095
nrMaster = Types.nodeRoleToRaw NRMaster
3096

    
3097
nrMcandidate :: String
3098
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3099

    
3100
nrOffline :: String
3101
nrOffline = Types.nodeRoleToRaw NROffline
3102

    
3103
nrRegular :: String
3104
nrRegular = Types.nodeRoleToRaw NRRegular
3105

    
3106
nrAll :: FrozenSet String
3107
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3108

    
3109
-- * SSL certificate check constants (in days)
3110

    
3111
sslCertExpirationError :: Int
3112
sslCertExpirationError = 7
3113

    
3114
sslCertExpirationWarn :: Int
3115
sslCertExpirationWarn = 30
3116

    
3117
-- * Allocator framework constants
3118

    
3119
iallocatorVersion :: Int
3120
iallocatorVersion = 2
3121

    
3122
iallocatorDirIn :: String
3123
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3124

    
3125
iallocatorDirOut :: String
3126
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3127

    
3128
validIallocatorDirections :: FrozenSet String
3129
validIallocatorDirections =
3130
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3131

    
3132
iallocatorModeAlloc :: String
3133
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3134

    
3135
iallocatorModeChgGroup :: String
3136
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3137

    
3138
iallocatorModeMultiAlloc :: String
3139
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3140

    
3141
iallocatorModeNodeEvac :: String
3142
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3143

    
3144
iallocatorModeReloc :: String
3145
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3146

    
3147
validIallocatorModes :: FrozenSet String
3148
validIallocatorModes =
3149
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3150

    
3151
iallocatorSearchPath :: [String]
3152
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3153

    
3154
defaultIallocatorShortcut :: String
3155
defaultIallocatorShortcut = "."
3156

    
3157
-- * Node evacuation
3158

    
3159
nodeEvacPri :: String
3160
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3161

    
3162
nodeEvacSec :: String
3163
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3164

    
3165
nodeEvacAll :: String
3166
nodeEvacAll = Types.evacModeToRaw ChangeAll
3167

    
3168
nodeEvacModes :: FrozenSet String
3169
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3170

    
3171
-- * Job queue
3172

    
3173
jobQueueVersion :: Int
3174
jobQueueVersion = 1
3175

    
3176
jobQueueSizeHardLimit :: Int
3177
jobQueueSizeHardLimit = 5000
3178

    
3179
jobQueueFilesPerms :: Int
3180
jobQueueFilesPerms = 0o640
3181

    
3182
-- * Unchanged job return
3183

    
3184
jobNotchanged :: String
3185
jobNotchanged = "nochange"
3186

    
3187
-- * Job status
3188

    
3189
jobStatusQueued :: String
3190
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3191

    
3192
jobStatusWaiting :: String
3193
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3194

    
3195
jobStatusCanceling :: String
3196
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3197

    
3198
jobStatusRunning :: String
3199
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3200

    
3201
jobStatusCanceled :: String
3202
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3203

    
3204
jobStatusSuccess :: String
3205
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3206

    
3207
jobStatusError :: String
3208
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3209

    
3210
jobsPending :: FrozenSet String
3211
jobsPending =
3212
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3213

    
3214
jobsFinalized :: FrozenSet String
3215
jobsFinalized =
3216
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3217

    
3218
jobStatusAll :: FrozenSet String
3219
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3220

    
3221
-- * OpCode status
3222

    
3223
-- ** Not yet finalized opcodes
3224

    
3225
opStatusCanceling :: String
3226
opStatusCanceling = "canceling"
3227

    
3228
opStatusQueued :: String
3229
opStatusQueued = "queued"
3230

    
3231
opStatusRunning :: String
3232
opStatusRunning = "running"
3233

    
3234
opStatusWaiting :: String
3235
opStatusWaiting = "waiting"
3236

    
3237
-- ** Finalized opcodes
3238

    
3239
opStatusCanceled :: String
3240
opStatusCanceled = "canceled"
3241

    
3242
opStatusError :: String
3243
opStatusError = "error"
3244

    
3245
opStatusSuccess :: String
3246
opStatusSuccess = "success"
3247

    
3248
opsFinalized :: FrozenSet String
3249
opsFinalized =
3250
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3251

    
3252
-- * OpCode priority
3253

    
3254
opPrioLowest :: Int
3255
opPrioLowest = 19
3256

    
3257
opPrioHighest :: Int
3258
opPrioHighest = -20
3259

    
3260
opPrioLow :: Int
3261
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3262

    
3263
opPrioNormal :: Int
3264
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3265

    
3266
opPrioHigh :: Int
3267
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3268

    
3269
opPrioSubmitValid :: FrozenSet Int
3270
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3271

    
3272
opPrioDefault :: Int
3273
opPrioDefault = opPrioNormal
3274

    
3275
-- * Lock recalculate mode
3276

    
3277
locksAppend :: String
3278
locksAppend = "append"
3279

    
3280
locksReplace :: String
3281
locksReplace = "replace"
3282

    
3283
-- * Lock timeout
3284
--
3285
-- The lock timeout (sum) before we transition into blocking acquire
3286
-- (this can still be reset by priority change).  Computed as max time
3287
-- (10 hours) before we should actually go into blocking acquire,
3288
-- given that we start from the default priority level.
3289

    
3290
lockAttemptsMaxwait :: Double
3291
lockAttemptsMaxwait = 15.0
3292

    
3293
lockAttemptsMinwait :: Double
3294
lockAttemptsMinwait = 1.0
3295

    
3296
lockAttemptsTimeout :: Int
3297
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3298

    
3299
-- * Execution log types
3300

    
3301
elogMessage :: String
3302
elogMessage = Types.eLogTypeToRaw ELogMessage
3303

    
3304
elogRemoteImport :: String
3305
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3306

    
3307
elogJqueueTest :: String
3308
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3309

    
3310
-- * /etc/hosts modification
3311

    
3312
etcHostsAdd :: String
3313
etcHostsAdd = "add"
3314

    
3315
etcHostsRemove :: String
3316
etcHostsRemove = "remove"
3317

    
3318
-- * Job queue test
3319

    
3320
jqtMsgprefix :: String
3321
jqtMsgprefix = "TESTMSG="
3322

    
3323
jqtExec :: String
3324
jqtExec = "exec"
3325

    
3326
jqtExpandnames :: String
3327
jqtExpandnames = "expandnames"
3328

    
3329
jqtLogmsg :: String
3330
jqtLogmsg = "logmsg"
3331

    
3332
jqtStartmsg :: String
3333
jqtStartmsg = "startmsg"
3334

    
3335
jqtAll :: FrozenSet String
3336
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3337

    
3338
-- * Query resources
3339

    
3340
qrCluster :: String
3341
qrCluster = "cluster"
3342

    
3343
qrExport :: String
3344
qrExport = "export"
3345

    
3346
qrExtstorage :: String
3347
qrExtstorage = "extstorage"
3348

    
3349
qrGroup :: String
3350
qrGroup = "group"
3351

    
3352
qrInstance :: String
3353
qrInstance = "instance"
3354

    
3355
qrJob :: String
3356
qrJob = "job"
3357

    
3358
qrLock :: String
3359
qrLock = "lock"
3360

    
3361
qrNetwork :: String
3362
qrNetwork = "network"
3363

    
3364
qrNode :: String
3365
qrNode = "node"
3366

    
3367
qrOs :: String
3368
qrOs = "os"
3369

    
3370
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3371
qrViaOp :: FrozenSet String
3372
qrViaOp =
3373
  ConstantUtils.mkSet [qrCluster,
3374
                       qrOs,
3375
                       qrExtstorage]
3376

    
3377
-- | List of resources which can be queried using Local UniX Interface
3378
qrViaLuxi :: FrozenSet String
3379
qrViaLuxi = ConstantUtils.mkSet [qrGroup,
3380
                                 qrExport,
3381
                                 qrInstance,
3382
                                 qrJob,
3383
                                 qrLock,
3384
                                 qrNetwork,
3385
                                 qrNode]
3386

    
3387
-- | List of resources which can be queried using RAPI
3388
qrViaRapi :: FrozenSet String
3389
qrViaRapi = qrViaLuxi
3390

    
3391
-- | List of resources which can be queried via RAPI including PUT requests
3392
qrViaRapiPut :: FrozenSet String
3393
qrViaRapiPut = ConstantUtils.mkSet [qrLock, qrJob]
3394

    
3395
-- * Query field types
3396

    
3397
qftBool :: String
3398
qftBool = "bool"
3399

    
3400
qftNumber :: String
3401
qftNumber = "number"
3402

    
3403
qftOther :: String
3404
qftOther = "other"
3405

    
3406
qftText :: String
3407
qftText = "text"
3408

    
3409
qftTimestamp :: String
3410
qftTimestamp = "timestamp"
3411

    
3412
qftUnit :: String
3413
qftUnit = "unit"
3414

    
3415
qftUnknown :: String
3416
qftUnknown = "unknown"
3417

    
3418
qftAll :: FrozenSet String
3419
qftAll =
3420
  ConstantUtils.mkSet [qftBool,
3421
                       qftNumber,
3422
                       qftOther,
3423
                       qftText,
3424
                       qftTimestamp,
3425
                       qftUnit,
3426
                       qftUnknown]
3427

    
3428
-- * Query result field status
3429
--
3430
-- Don't change or reuse values as they're used by clients.
3431
--
3432
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3433

    
3434
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3435
rsNodata :: Int
3436
rsNodata = 2
3437

    
3438
rsNormal :: Int
3439
rsNormal = 0
3440

    
3441
-- | Resource marked offline
3442
rsOffline :: Int
3443
rsOffline = 4
3444

    
3445
-- | Value unavailable/unsupported for item; if this field is
3446
-- supported but we cannot get the data for the moment, 'rsNodata' or
3447
-- 'rsOffline' should be used
3448
rsUnavail :: Int
3449
rsUnavail = 3
3450

    
3451
rsUnknown :: Int
3452
rsUnknown = 1
3453

    
3454
rsAll :: FrozenSet Int
3455
rsAll =
3456
  ConstantUtils.mkSet [rsNodata,
3457
                       rsNormal,
3458
                       rsOffline,
3459
                       rsUnavail,
3460
                       rsUnknown]
3461

    
3462
-- | Special field cases and their verbose/terse formatting
3463
rssDescription :: Map Int (String, String)
3464
rssDescription =
3465
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3466
                (rsNodata, ("(nodata)", "?")),
3467
                (rsOffline, ("(offline)", "*")),
3468
                (rsUnavail, ("(unavail)", "-"))]
3469

    
3470
-- * Max dynamic devices
3471

    
3472
maxDisks :: Int
3473
maxDisks = Types.maxDisks
3474

    
3475
maxNics :: Int
3476
maxNics = Types.maxNics
3477

    
3478
-- | SSCONF file prefix
3479
ssconfFileprefix :: String
3480
ssconfFileprefix = "ssconf_"
3481

    
3482
-- * SSCONF keys
3483

    
3484
ssClusterName :: String
3485
ssClusterName = "cluster_name"
3486

    
3487
ssClusterTags :: String
3488
ssClusterTags = "cluster_tags"
3489

    
3490
ssFileStorageDir :: String
3491
ssFileStorageDir = "file_storage_dir"
3492

    
3493
ssSharedFileStorageDir :: String
3494
ssSharedFileStorageDir = "shared_file_storage_dir"
3495

    
3496
ssGlusterStorageDir :: String
3497
ssGlusterStorageDir = "gluster_storage_dir"
3498

    
3499
ssMasterCandidates :: String
3500
ssMasterCandidates = "master_candidates"
3501

    
3502
ssMasterCandidatesIps :: String
3503
ssMasterCandidatesIps = "master_candidates_ips"
3504

    
3505
ssMasterCandidatesCerts :: String
3506
ssMasterCandidatesCerts = "master_candidates_certs"
3507

    
3508
ssMasterIp :: String
3509
ssMasterIp = "master_ip"
3510

    
3511
ssMasterNetdev :: String
3512
ssMasterNetdev = "master_netdev"
3513

    
3514
ssMasterNetmask :: String
3515
ssMasterNetmask = "master_netmask"
3516

    
3517
ssMasterNode :: String
3518
ssMasterNode = "master_node"
3519

    
3520
ssNodeList :: String
3521
ssNodeList = "node_list"
3522

    
3523
ssNodePrimaryIps :: String
3524
ssNodePrimaryIps = "node_primary_ips"
3525

    
3526
ssNodeSecondaryIps :: String
3527
ssNodeSecondaryIps = "node_secondary_ips"
3528

    
3529
ssOfflineNodes :: String
3530
ssOfflineNodes = "offline_nodes"
3531

    
3532
ssOnlineNodes :: String
3533
ssOnlineNodes = "online_nodes"
3534

    
3535
ssPrimaryIpFamily :: String
3536
ssPrimaryIpFamily = "primary_ip_family"
3537

    
3538
ssInstanceList :: String
3539
ssInstanceList = "instance_list"
3540

    
3541
ssReleaseVersion :: String
3542
ssReleaseVersion = "release_version"
3543

    
3544
ssHypervisorList :: String
3545
ssHypervisorList = "hypervisor_list"
3546

    
3547
ssMaintainNodeHealth :: String
3548
ssMaintainNodeHealth = "maintain_node_health"
3549

    
3550
ssUidPool :: String
3551
ssUidPool = "uid_pool"
3552

    
3553
ssNodegroups :: String
3554
ssNodegroups = "nodegroups"
3555

    
3556
ssNetworks :: String
3557
ssNetworks = "networks"
3558

    
3559
-- | This is not a complete SSCONF key, but the prefix for the
3560
-- hypervisor keys
3561
ssHvparamsPref :: String
3562
ssHvparamsPref = "hvparams_"
3563

    
3564
-- * Hvparams keys
3565

    
3566
ssHvparamsXenChroot :: String
3567
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3568

    
3569
ssHvparamsXenFake :: String
3570
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3571

    
3572
ssHvparamsXenHvm :: String
3573
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3574

    
3575
ssHvparamsXenKvm :: String
3576
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3577

    
3578
ssHvparamsXenLxc :: String
3579
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3580

    
3581
ssHvparamsXenPvm :: String
3582
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3583

    
3584
validSsHvparamsKeys :: FrozenSet String
3585
validSsHvparamsKeys =
3586
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3587
                       ssHvparamsXenLxc,
3588
                       ssHvparamsXenFake,
3589
                       ssHvparamsXenHvm,
3590
                       ssHvparamsXenKvm,
3591
                       ssHvparamsXenPvm]
3592

    
3593
ssFilePerms :: Int
3594
ssFilePerms = 0o444
3595

    
3596
-- | Cluster wide default parameters
3597
defaultEnabledHypervisor :: String
3598
defaultEnabledHypervisor = htXenPvm
3599

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

    
3712
hvcGlobals :: FrozenSet String
3713
hvcGlobals =
3714
  ConstantUtils.mkSet [hvMigrationBandwidth,
3715
                       hvMigrationMode,
3716
                       hvMigrationPort,
3717
                       hvXenCmd]
3718

    
3719
becDefaults :: Map String PyValueEx
3720
becDefaults =
3721
  Map.fromList
3722
  [ (beMinmem, PyValueEx (128 :: Int))
3723
  , (beMaxmem, PyValueEx (128 :: Int))
3724
  , (beVcpus, PyValueEx (1 :: Int))
3725
  , (beAutoBalance, PyValueEx True)
3726
  , (beAlwaysFailover, PyValueEx False)
3727
  , (beSpindleUse, PyValueEx (1 :: Int))
3728
  ]
3729

    
3730
ndcDefaults :: Map String PyValueEx
3731
ndcDefaults =
3732
  Map.fromList
3733
  [ (ndOobProgram,       PyValueEx "")
3734
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3735
  , (ndExclusiveStorage, PyValueEx False)
3736
  , (ndOvs,              PyValueEx False)
3737
  , (ndOvsName,          PyValueEx defaultOvs)
3738
  , (ndOvsLink,          PyValueEx "")
3739
  , (ndSshPort,          PyValueEx (22 :: Int))
3740
  ]
3741

    
3742
ndcGlobals :: FrozenSet String
3743
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3744

    
3745
-- | Default delay target measured in sectors
3746
defaultDelayTarget :: Int
3747
defaultDelayTarget = 1
3748

    
3749
defaultDiskCustom :: String
3750
defaultDiskCustom = ""
3751

    
3752
defaultDiskResync :: Bool
3753
defaultDiskResync = False
3754

    
3755
-- | Default fill target measured in sectors
3756
defaultFillTarget :: Int
3757
defaultFillTarget = 0
3758

    
3759
-- | Default mininum rate measured in KiB/s
3760
defaultMinRate :: Int
3761
defaultMinRate = 4 * 1024
3762

    
3763
defaultNetCustom :: String
3764
defaultNetCustom = ""
3765

    
3766
-- | Default plan ahead measured in sectors
3767
--
3768
-- The default values for the DRBD dynamic resync speed algorithm are
3769
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3770
-- (that we don't need to set to 0, because we have a separate option
3771
-- to enable it) and for c-max-rate, that we cap to the default value
3772
-- for the static resync rate.
3773
defaultPlanAhead :: Int
3774
defaultPlanAhead = 20
3775

    
3776
defaultRbdPool :: String
3777
defaultRbdPool = "rbd"
3778

    
3779
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3780
diskLdDefaults =
3781
  Map.fromList
3782
  [ (DTBlock, Map.empty)
3783
  , (DTDrbd8, Map.fromList
3784
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3785
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3786
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3787
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3788
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3789
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3790
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3791
              , (ldpMinRate,       PyValueEx defaultMinRate)
3792
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3793
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3794
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3795
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3796
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3797
              ])
3798
  , (DTExt, Map.empty)
3799
  , (DTFile, Map.empty)
3800
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3801
  , (DTRbd, Map.fromList
3802
            [ (ldpPool, PyValueEx defaultRbdPool)
3803
            , (ldpAccess, PyValueEx diskKernelspace)
3804
            ])
3805
  , (DTSharedFile, Map.empty)
3806
  , (DTGluster, Map.fromList
3807
                [ (rbdAccess, PyValueEx diskKernelspace)
3808
                , (glusterHost, PyValueEx glusterHostDefault)
3809
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3810
                , (glusterPort, PyValueEx glusterPortDefault)
3811
                ])
3812
  ]
3813

    
3814
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3815
diskDtDefaults =
3816
  Map.fromList
3817
  [ (DTBlock,      Map.empty)
3818
  , (DTDiskless,   Map.empty)
3819
  , (DTDrbd8,      Map.fromList
3820
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3821
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3822
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3823
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3824
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3825
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3826
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3827
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3828
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3829
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3830
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3831
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3832
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3833
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3834
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3835
                   ])
3836
  , (DTExt,        Map.empty)
3837
  , (DTFile,       Map.empty)
3838
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3839
  , (DTRbd,        Map.fromList
3840
                   [ (rbdPool, PyValueEx defaultRbdPool)
3841
                   , (rbdAccess, PyValueEx diskKernelspace)
3842
                   ])
3843
  , (DTSharedFile, Map.empty)
3844
  , (DTGluster, Map.fromList
3845
                [ (rbdAccess, PyValueEx diskKernelspace)
3846
                , (glusterHost, PyValueEx glusterHostDefault)
3847
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3848
                , (glusterPort, PyValueEx glusterPortDefault)
3849
                ])
3850
  ]
3851

    
3852
niccDefaults :: Map String PyValueEx
3853
niccDefaults =
3854
  Map.fromList
3855
  [ (nicMode, PyValueEx nicModeBridged)
3856
  , (nicLink, PyValueEx defaultBridge)
3857
  , (nicVlan, PyValueEx "")
3858
  ]
3859

    
3860
-- | All of the following values are quite arbitrary - there are no
3861
-- "good" defaults, these must be customised per-site
3862
ispecsMinmaxDefaults :: Map String (Map String Int)
3863
ispecsMinmaxDefaults =
3864
  Map.fromList
3865
  [(ispecsMin,
3866
    Map.fromList
3867
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3868
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3869
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3870
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3871
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3872
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3873
   (ispecsMax,
3874
    Map.fromList
3875
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3876
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3877
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3878
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3879
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3880
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3881

    
3882
ipolicyDefaults :: Map String PyValueEx
3883
ipolicyDefaults =
3884
  Map.fromList
3885
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3886
  , (ispecsStd,           PyValueEx (Map.fromList
3887
                                     [ (ispecMemSize,    128)
3888
                                     , (ispecCpuCount,   1)
3889
                                     , (ispecDiskCount,  1)
3890
                                     , (ispecDiskSize,   1024)
3891
                                     , (ispecNicCount,   1)
3892
                                     , (ispecSpindleUse, 1)
3893
                                     ] :: Map String Int))
3894
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3895
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3896
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3897
  ]
3898

    
3899
masterPoolSizeDefault :: Int
3900
masterPoolSizeDefault = 10
3901

    
3902
-- * Exclusive storage
3903

    
3904
-- | Error margin used to compare physical disks
3905
partMargin :: Double
3906
partMargin = 0.01
3907

    
3908
-- | Space reserved when creating instance disks
3909
partReserved :: Double
3910
partReserved = 0.02
3911

    
3912
-- * Luxid job scheduling
3913

    
3914
-- | Time intervall in seconds for polling updates on the job queue. This
3915
-- intervall is only relevant if the number of running jobs reaches the maximal
3916
-- allowed number, as otherwise new jobs will be started immediately anyway.
3917
luxidJobqueuePollInterval :: Int
3918
luxidJobqueuePollInterval = 3
3919

    
3920
-- | Maximal number of jobs to be running at the same time. Once this number is
3921
-- reached, new jobs will just be queued and only started, once some of the
3922
-- other jobs have finished.
3923
luxidMaximalRunningJobs :: Int
3924
luxidMaximalRunningJobs = 20
3925

    
3926
-- * Confd
3927

    
3928
confdProtocolVersion :: Int
3929
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3930

    
3931
-- Confd request type
3932

    
3933
confdReqPing :: Int
3934
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3935

    
3936
confdReqNodeRoleByname :: Int
3937
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3938

    
3939
confdReqNodePipByInstanceIp :: Int
3940
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3941

    
3942
confdReqClusterMaster :: Int
3943
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3944

    
3945
confdReqNodePipList :: Int
3946
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3947

    
3948
confdReqMcPipList :: Int
3949
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3950

    
3951
confdReqInstancesIpsList :: Int
3952
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3953

    
3954
confdReqNodeDrbd :: Int
3955
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3956

    
3957
confdReqNodeInstances :: Int
3958
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3959

    
3960
confdReqs :: FrozenSet Int
3961
confdReqs =
3962
  ConstantUtils.mkSet .
3963
  map Types.confdRequestTypeToRaw $
3964
  [minBound..] \\ [ReqNodeInstances]
3965

    
3966
-- * Confd request type
3967

    
3968
confdReqfieldName :: Int
3969
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3970

    
3971
confdReqfieldIp :: Int
3972
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3973

    
3974
confdReqfieldMnodePip :: Int
3975
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3976

    
3977
-- * Confd repl status
3978

    
3979
confdReplStatusOk :: Int
3980
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3981

    
3982
confdReplStatusError :: Int
3983
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3984

    
3985
confdReplStatusNotimplemented :: Int
3986
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3987

    
3988
confdReplStatuses :: FrozenSet Int
3989
confdReplStatuses =
3990
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3991

    
3992
-- * Confd node role
3993

    
3994
confdNodeRoleMaster :: Int
3995
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3996

    
3997
confdNodeRoleCandidate :: Int
3998
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3999

    
4000
confdNodeRoleOffline :: Int
4001
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
4002

    
4003
confdNodeRoleDrained :: Int
4004
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
4005

    
4006
confdNodeRoleRegular :: Int
4007
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
4008

    
4009
-- * A few common errors for confd
4010

    
4011
confdErrorUnknownEntry :: Int
4012
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
4013

    
4014
confdErrorInternal :: Int
4015
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
4016

    
4017
confdErrorArgument :: Int
4018
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
4019

    
4020
-- * Confd request query fields
4021

    
4022
confdReqqLink :: String
4023
confdReqqLink = ConstantUtils.confdReqqLink
4024

    
4025
confdReqqIp :: String
4026
confdReqqIp = ConstantUtils.confdReqqIp
4027

    
4028
confdReqqIplist :: String
4029
confdReqqIplist = ConstantUtils.confdReqqIplist
4030

    
4031
confdReqqFields :: String
4032
confdReqqFields = ConstantUtils.confdReqqFields
4033

    
4034
-- | Each request is "salted" by the current timestamp.
4035
--
4036
-- This constant decides how many seconds of skew to accept.
4037
--
4038
-- TODO: make this a default and allow the value to be more
4039
-- configurable
4040
confdMaxClockSkew :: Int
4041
confdMaxClockSkew = 2 * nodeMaxClockSkew
4042

    
4043
-- | When we haven't reloaded the config for more than this amount of
4044
-- seconds, we force a test to see if inotify is betraying us. Using a
4045
-- prime number to ensure we get less chance of 'same wakeup' with
4046
-- other processes.
4047
confdConfigReloadTimeout :: Int
4048
confdConfigReloadTimeout = 17
4049

    
4050
-- | If we receive more than one update in this amount of
4051
-- microseconds, we move to polling every RATELIMIT seconds, rather
4052
-- than relying on inotify, to be able to serve more requests.
4053
confdConfigReloadRatelimit :: Int
4054
confdConfigReloadRatelimit = 250000
4055

    
4056
-- | Magic number prepended to all confd queries.
4057
--
4058
-- This allows us to distinguish different types of confd protocols
4059
-- and handle them. For example by changing this we can move the whole
4060
-- payload to be compressed, or move away from json.
4061
confdMagicFourcc :: String
4062
confdMagicFourcc = "plj0"
4063

    
4064
-- | By default a confd request is sent to the minimum between this
4065
-- number and all MCs. 6 was chosen because even in the case of a
4066
-- disastrous 50% response rate, we should have enough answers to be
4067
-- able to compare more than one.
4068
confdDefaultReqCoverage :: Int
4069
confdDefaultReqCoverage = 6
4070

    
4071
-- | Timeout in seconds to expire pending query request in the confd
4072
-- client library. We don't actually expect any answer more than 10
4073
-- seconds after we sent a request.
4074
confdClientExpireTimeout :: Int
4075
confdClientExpireTimeout = 10
4076

    
4077
-- | Maximum UDP datagram size.
4078
--
4079
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4080
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4081
--   (assuming we can't use jumbo frames)
4082
-- We just set this to 60K, which should be enough
4083
maxUdpDataSize :: Int
4084
maxUdpDataSize = 61440
4085

    
4086
-- * User-id pool minimum/maximum acceptable user-ids
4087

    
4088
uidpoolUidMin :: Int
4089
uidpoolUidMin = 0
4090

    
4091
-- | Assuming 32 bit user-ids
4092
uidpoolUidMax :: Integer
4093
uidpoolUidMax = 2 ^ 32 - 1
4094

    
4095
-- | Name or path of the pgrep command
4096
pgrep :: String
4097
pgrep = "pgrep"
4098

    
4099
-- | Name of the node group that gets created at cluster init or
4100
-- upgrade
4101
initialNodeGroupName :: String
4102
initialNodeGroupName = "default"
4103

    
4104
-- * Possible values for NodeGroup.alloc_policy
4105

    
4106
allocPolicyLastResort :: String
4107
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4108

    
4109
allocPolicyPreferred :: String
4110
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4111

    
4112
allocPolicyUnallocable :: String
4113
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4114

    
4115
validAllocPolicies :: [String]
4116
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4117

    
4118
-- | Temporary external/shared storage parameters
4119
blockdevDriverManual :: String
4120
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4121

    
4122
-- | 'qemu-img' path, required for 'ovfconverter'
4123
qemuimgPath :: String
4124
qemuimgPath = AutoConf.qemuimgPath
4125

    
4126
-- | Whether htools was enabled at compilation time
4127
--
4128
-- FIXME: this should be moved next to the other enable constants,
4129
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4130
htools :: Bool
4131
htools = AutoConf.htools
4132

    
4133
-- | The hail iallocator
4134
iallocHail :: String
4135
iallocHail = "hail"
4136

    
4137
-- * Fake opcodes for functions that have hooks attached to them via
4138
-- backend.RunLocalHooks
4139

    
4140
fakeOpMasterTurndown :: String
4141
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4142

    
4143
fakeOpMasterTurnup :: String
4144
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4145

    
4146

    
4147
-- * Crypto Types
4148
-- Types of cryptographic tokens used in node communication
4149

    
4150
cryptoTypeSslDigest :: String
4151
cryptoTypeSslDigest = "ssl"
4152

    
4153
cryptoTypeSsh :: String
4154
cryptoTypeSsh = "ssh"
4155

    
4156
-- So far only ssl keys are used in the context of this constant
4157
cryptoTypes :: FrozenSet String
4158
cryptoTypes = ConstantUtils.mkSet [cryptoTypeSslDigest]
4159

    
4160
-- * Crypto Actions
4161
-- Actions that can be performed on crypto tokens
4162

    
4163
cryptoActionGet :: String
4164
cryptoActionGet = "get"
4165

    
4166
-- This is 'create and get'
4167
cryptoActionCreate :: String
4168
cryptoActionCreate = "create"
4169

    
4170
cryptoActions :: FrozenSet String
4171
cryptoActions = ConstantUtils.mkSet [cryptoActionGet, cryptoActionCreate]
4172

    
4173
-- * Options for CryptoActions
4174

    
4175
-- Filename of the certificate
4176
cryptoOptionCertFile :: String
4177
cryptoOptionCertFile = "cert_file"
4178

    
4179
-- * SSH key types
4180

    
4181
sshkDsa :: String
4182
sshkDsa = "dsa"
4183

    
4184
sshkRsa :: String
4185
sshkRsa = "rsa"
4186

    
4187
sshkAll :: FrozenSet String
4188
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4189

    
4190
-- * SSH authorized key types
4191

    
4192
sshakDss :: String
4193
sshakDss = "ssh-dss"
4194

    
4195
sshakRsa :: String
4196
sshakRsa = "ssh-rsa"
4197

    
4198
sshakAll :: FrozenSet String
4199
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4200

    
4201
-- * SSH setup
4202

    
4203
sshsClusterName :: String
4204
sshsClusterName = "cluster_name"
4205

    
4206
sshsSshHostKey :: String
4207
sshsSshHostKey = "ssh_host_key"
4208

    
4209
sshsSshRootKey :: String
4210
sshsSshRootKey = "ssh_root_key"
4211

    
4212
sshsNodeDaemonCertificate :: String
4213
sshsNodeDaemonCertificate = "node_daemon_certificate"
4214

    
4215
-- * Key files for SSH daemon
4216

    
4217
sshHostDsaPriv :: String
4218
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4219

    
4220
sshHostDsaPub :: String
4221
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4222

    
4223
sshHostRsaPriv :: String
4224
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4225

    
4226
sshHostRsaPub :: String
4227
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4228

    
4229
sshDaemonKeyfiles :: Map String (String, String)
4230
sshDaemonKeyfiles =
4231
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4232
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4233
               ]
4234

    
4235
-- * Node daemon setup
4236

    
4237
ndsClusterName :: String
4238
ndsClusterName = "cluster_name"
4239

    
4240
ndsNodeDaemonCertificate :: String
4241
ndsNodeDaemonCertificate = "node_daemon_certificate"
4242

    
4243
ndsSsconf :: String
4244
ndsSsconf = "ssconf"
4245

    
4246
ndsStartNodeDaemon :: String
4247
ndsStartNodeDaemon = "start_node_daemon"
4248

    
4249
-- * The source reasons for the execution of an OpCode
4250

    
4251
opcodeReasonSrcClient :: String
4252
opcodeReasonSrcClient = "gnt:client"
4253

    
4254
opcodeReasonSrcNoded :: String
4255
opcodeReasonSrcNoded = "gnt:daemon:noded"
4256

    
4257
opcodeReasonSrcOpcode :: String
4258
opcodeReasonSrcOpcode = "gnt:opcode"
4259

    
4260
opcodeReasonSrcRlib2 :: String
4261
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4262

    
4263
opcodeReasonSrcUser :: String
4264
opcodeReasonSrcUser = "gnt:user"
4265

    
4266
opcodeReasonSources :: FrozenSet String
4267
opcodeReasonSources =
4268
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4269
                       opcodeReasonSrcNoded,
4270
                       opcodeReasonSrcOpcode,
4271
                       opcodeReasonSrcRlib2,
4272
                       opcodeReasonSrcUser]
4273

    
4274
-- | Path generating random UUID
4275
randomUuidFile :: String
4276
randomUuidFile = ConstantUtils.randomUuidFile
4277

    
4278
-- * Auto-repair tag prefixes
4279

    
4280
autoRepairTagPrefix :: String
4281
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4282

    
4283
autoRepairTagEnabled :: String
4284
autoRepairTagEnabled = autoRepairTagPrefix
4285

    
4286
autoRepairTagPending :: String
4287
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4288

    
4289
autoRepairTagResult :: String
4290
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4291

    
4292
autoRepairTagSuspended :: String
4293
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4294

    
4295
-- * Auto-repair levels
4296

    
4297
autoRepairFailover :: String
4298
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4299

    
4300
autoRepairFixStorage :: String
4301
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4302

    
4303
autoRepairMigrate :: String
4304
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4305

    
4306
autoRepairReinstall :: String
4307
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4308

    
4309
autoRepairAllTypes :: FrozenSet String
4310
autoRepairAllTypes =
4311
  ConstantUtils.mkSet [autoRepairFailover,
4312
                       autoRepairFixStorage,
4313
                       autoRepairMigrate,
4314
                       autoRepairReinstall]
4315

    
4316
-- * Auto-repair results
4317

    
4318
autoRepairEnoperm :: String
4319
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4320

    
4321
autoRepairFailure :: String
4322
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4323

    
4324
autoRepairSuccess :: String
4325
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4326

    
4327
autoRepairAllResults :: FrozenSet String
4328
autoRepairAllResults =
4329
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4330

    
4331
-- | The version identifier for builtin data collectors
4332
builtinDataCollectorVersion :: String
4333
builtinDataCollectorVersion = "B"
4334

    
4335
-- | The reason trail opcode parameter name
4336
opcodeReason :: String
4337
opcodeReason = "reason"
4338

    
4339
diskstatsFile :: String
4340
diskstatsFile = "/proc/diskstats"
4341

    
4342
-- *  CPU load collector
4343

    
4344
statFile :: String
4345
statFile = "/proc/stat"
4346

    
4347
cpuavgloadBufferSize :: Int
4348
cpuavgloadBufferSize = 150
4349

    
4350
cpuavgloadWindowSize :: Int
4351
cpuavgloadWindowSize = 600
4352

    
4353
-- * Monitoring daemon
4354

    
4355
-- | Mond's variable for periodical data collection
4356
mondTimeInterval :: Int
4357
mondTimeInterval = 5
4358

    
4359
-- | Mond's latest API version
4360
mondLatestApiVersion :: Int
4361
mondLatestApiVersion = 1
4362

    
4363
-- * Disk access modes
4364

    
4365
diskUserspace :: String
4366
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4367

    
4368
diskKernelspace :: String
4369
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4370

    
4371
diskValidAccessModes :: FrozenSet String
4372
diskValidAccessModes =
4373
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4374

    
4375
-- | Timeout for queue draining in upgrades
4376
upgradeQueueDrainTimeout :: Int
4377
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4378

    
4379
-- | Intervall at which the queue is polled during upgrades
4380
upgradeQueuePollInterval :: Int
4381
upgradeQueuePollInterval  = 10
4382

    
4383
-- * Hotplug Actions
4384

    
4385
hotplugActionAdd :: String
4386
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4387

    
4388
hotplugActionRemove :: String
4389
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4390

    
4391
hotplugActionModify :: String
4392
hotplugActionModify = Types.hotplugActionToRaw HAMod
4393

    
4394
hotplugAllActions :: FrozenSet String
4395
hotplugAllActions =
4396
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4397

    
4398
-- * Hotplug Device Targets
4399

    
4400
hotplugTargetNic :: String
4401
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4402

    
4403
hotplugTargetDisk :: String
4404
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4405

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

    
4410
-- | Timeout for disk removal (seconds)
4411
diskRemoveRetryTimeout :: Int
4412
diskRemoveRetryTimeout = 30
4413

    
4414
-- | Interval between disk removal retries (seconds)
4415
diskRemoveRetryInterval :: Int
4416
diskRemoveRetryInterval  = 3
4417

    
4418
-- * UUID regex
4419

    
4420
uuidRegex :: String
4421
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4422

    
4423
-- * Luxi constants
4424

    
4425
luxiSocketPerms :: Int
4426
luxiSocketPerms = 0o660
4427

    
4428
luxiKeyMethod :: String
4429
luxiKeyMethod = "method"
4430

    
4431
luxiKeyArgs :: String
4432
luxiKeyArgs = "args"
4433

    
4434
luxiKeySuccess :: String
4435
luxiKeySuccess = "success"
4436

    
4437
luxiKeyResult :: String
4438
luxiKeyResult = "result"
4439

    
4440
luxiKeyVersion :: String
4441
luxiKeyVersion = "version"
4442

    
4443
luxiReqSubmitJob :: String
4444
luxiReqSubmitJob = "SubmitJob"
4445

    
4446
luxiReqSubmitJobToDrainedQueue :: String
4447
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4448

    
4449
luxiReqSubmitManyJobs :: String
4450
luxiReqSubmitManyJobs = "SubmitManyJobs"
4451

    
4452
luxiReqWaitForJobChange :: String
4453
luxiReqWaitForJobChange = "WaitForJobChange"
4454

    
4455
luxiReqPickupJob :: String
4456
luxiReqPickupJob = "PickupJob"
4457

    
4458
luxiReqCancelJob :: String
4459
luxiReqCancelJob = "CancelJob"
4460

    
4461
luxiReqArchiveJob :: String
4462
luxiReqArchiveJob = "ArchiveJob"
4463

    
4464
luxiReqChangeJobPriority :: String
4465
luxiReqChangeJobPriority = "ChangeJobPriority"
4466

    
4467
luxiReqAutoArchiveJobs :: String
4468
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4469

    
4470
luxiReqQuery :: String
4471
luxiReqQuery = "Query"
4472

    
4473
luxiReqQueryFields :: String
4474
luxiReqQueryFields = "QueryFields"
4475

    
4476
luxiReqQueryJobs :: String
4477
luxiReqQueryJobs = "QueryJobs"
4478

    
4479
luxiReqQueryInstances :: String
4480
luxiReqQueryInstances = "QueryInstances"
4481

    
4482
luxiReqQueryNodes :: String
4483
luxiReqQueryNodes = "QueryNodes"
4484

    
4485
luxiReqQueryGroups :: String
4486
luxiReqQueryGroups = "QueryGroups"
4487

    
4488
luxiReqQueryNetworks :: String
4489
luxiReqQueryNetworks = "QueryNetworks"
4490

    
4491
luxiReqQueryExports :: String
4492
luxiReqQueryExports = "QueryExports"
4493

    
4494
luxiReqQueryConfigValues :: String
4495
luxiReqQueryConfigValues = "QueryConfigValues"
4496

    
4497
luxiReqQueryClusterInfo :: String
4498
luxiReqQueryClusterInfo = "QueryClusterInfo"
4499

    
4500
luxiReqQueryTags :: String
4501
luxiReqQueryTags = "QueryTags"
4502

    
4503
luxiReqSetDrainFlag :: String
4504
luxiReqSetDrainFlag = "SetDrainFlag"
4505

    
4506
luxiReqSetWatcherPause :: String
4507
luxiReqSetWatcherPause = "SetWatcherPause"
4508

    
4509
luxiReqAll :: FrozenSet String
4510
luxiReqAll =
4511
  ConstantUtils.mkSet
4512
  [ luxiReqArchiveJob
4513
  , luxiReqAutoArchiveJobs
4514
  , luxiReqCancelJob
4515
  , luxiReqChangeJobPriority
4516
  , luxiReqQuery
4517
  , luxiReqQueryClusterInfo
4518
  , luxiReqQueryConfigValues
4519
  , luxiReqQueryExports
4520
  , luxiReqQueryFields
4521
  , luxiReqQueryGroups
4522
  , luxiReqQueryInstances
4523
  , luxiReqQueryJobs
4524
  , luxiReqQueryNodes
4525
  , luxiReqQueryNetworks
4526
  , luxiReqQueryTags
4527
  , luxiReqSetDrainFlag
4528
  , luxiReqSetWatcherPause
4529
  , luxiReqSubmitJob
4530
  , luxiReqSubmitJobToDrainedQueue
4531
  , luxiReqSubmitManyJobs
4532
  , luxiReqWaitForJobChange
4533
  , luxiReqPickupJob
4534
  ]
4535

    
4536
luxiDefCtmo :: Int
4537
luxiDefCtmo = 10
4538

    
4539
luxiDefRwto :: Int
4540
luxiDefRwto = 60
4541

    
4542
-- | 'WaitForJobChange' timeout
4543
luxiWfjcTimeout :: Int
4544
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4545

    
4546
-- * Query language constants
4547

    
4548
-- ** Logic operators with one or more operands, each of which is a
4549
-- filter on its own
4550

    
4551
qlangOpAnd :: String
4552
qlangOpAnd = "&"
4553

    
4554
qlangOpOr :: String
4555
qlangOpOr = "|"
4556

    
4557
-- ** Unary operators with exactly one operand
4558

    
4559
qlangOpNot :: String
4560
qlangOpNot = "!"
4561

    
4562
qlangOpTrue :: String
4563
qlangOpTrue = "?"
4564

    
4565
-- ** Binary operators with exactly two operands, the field name and
4566
-- an operator-specific value
4567

    
4568
qlangOpContains :: String
4569
qlangOpContains = "=[]"
4570

    
4571
qlangOpEqual :: String
4572
qlangOpEqual = "="
4573

    
4574
qlangOpGe :: String
4575
qlangOpGe = ">="
4576

    
4577
qlangOpGt :: String
4578
qlangOpGt = ">"
4579

    
4580
qlangOpLe :: String
4581
qlangOpLe = "<="
4582

    
4583
qlangOpLt :: String
4584
qlangOpLt = "<"
4585

    
4586
qlangOpNotEqual :: String
4587
qlangOpNotEqual = "!="
4588

    
4589
qlangOpRegexp :: String
4590
qlangOpRegexp = "=~"
4591

    
4592
-- | Characters used for detecting user-written filters (see
4593
-- L{_CheckFilter})
4594

    
4595
qlangFilterDetectionChars :: FrozenSet String
4596
qlangFilterDetectionChars =
4597
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4598
                       ")", "(", "\x0b", "\n",
4599
                       "\r", "\x0c", "/", "<",
4600
                       "\t", ">", "=", "\\", "~"]
4601

    
4602
-- | Characters used to detect globbing filters
4603
qlangGlobDetectionChars :: FrozenSet String
4604
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4605

    
4606
-- * Error related constants
4607
--
4608
-- 'OpPrereqError' failure types
4609

    
4610
-- | Environment error (e.g. node disk error)
4611
errorsEcodeEnviron :: String
4612
errorsEcodeEnviron = "environment_error"
4613

    
4614
-- | Entity already exists
4615
errorsEcodeExists :: String
4616
errorsEcodeExists = "already_exists"
4617

    
4618
-- | Internal cluster error
4619
errorsEcodeFault :: String
4620
errorsEcodeFault = "internal_error"
4621

    
4622
-- | Wrong arguments (at syntax level)
4623
errorsEcodeInval :: String
4624
errorsEcodeInval = "wrong_input"
4625

    
4626
-- | Entity not found
4627
errorsEcodeNoent :: String
4628
errorsEcodeNoent = "unknown_entity"
4629

    
4630
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4631
errorsEcodeNores :: String
4632
errorsEcodeNores = "insufficient_resources"
4633

    
4634
-- | Resource not unique (e.g. MAC or IP duplication)
4635
errorsEcodeNotunique :: String
4636
errorsEcodeNotunique = "resource_not_unique"
4637

    
4638
-- | Resolver errors
4639
errorsEcodeResolver :: String
4640
errorsEcodeResolver = "resolver_error"
4641

    
4642
-- | Wrong entity state
4643
errorsEcodeState :: String
4644
errorsEcodeState = "wrong_state"
4645

    
4646
-- | Temporarily out of resources; operation can be tried again
4647
errorsEcodeTempNores :: String
4648
errorsEcodeTempNores = "temp_insufficient_resources"
4649

    
4650
errorsEcodeAll :: FrozenSet String
4651
errorsEcodeAll =
4652
  ConstantUtils.mkSet [ errorsEcodeNores
4653
                      , errorsEcodeExists
4654
                      , errorsEcodeState
4655
                      , errorsEcodeNotunique
4656
                      , errorsEcodeTempNores
4657
                      , errorsEcodeNoent
4658
                      , errorsEcodeFault
4659
                      , errorsEcodeResolver
4660
                      , errorsEcodeInval
4661
                      , errorsEcodeEnviron
4662
                      ]
4663

    
4664
-- * Jstore related constants
4665

    
4666
jstoreJobsPerArchiveDirectory :: Int
4667
jstoreJobsPerArchiveDirectory = 10000
4668

    
4669
-- * Gluster settings
4670

    
4671
-- | Name of the Gluster host setting
4672
glusterHost :: String
4673
glusterHost = "host"
4674

    
4675
-- | Default value of the Gluster host setting
4676
glusterHostDefault :: String
4677
glusterHostDefault = "127.0.0.1"
4678

    
4679
-- | Name of the Gluster volume setting
4680
glusterVolume :: String
4681
glusterVolume = "volume"
4682

    
4683
-- | Default value of the Gluster volume setting
4684
glusterVolumeDefault :: String
4685
glusterVolumeDefault = "gv0"
4686

    
4687
-- | Name of the Gluster port setting
4688
glusterPort :: String
4689
glusterPort = "port"
4690

    
4691
-- | Default value of the Gluster port setting
4692
glusterPortDefault :: Int
4693
glusterPortDefault = 24007