Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 5a904197

History | View | Annotate | Download (116.6 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
fileDriver :: FrozenSet String
969
fileDriver =
970
  ConstantUtils.mkSet $
971
  map Types.fileDriverToRaw [minBound..]
972

    
973
-- | The set of drbd-like disk types
974
dtsDrbd :: FrozenSet String
975
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
976

    
977
-- * Disk access mode
978

    
979
diskRdonly :: String
980
diskRdonly = Types.diskModeToRaw DiskRdOnly
981

    
982
diskRdwr :: String
983
diskRdwr = Types.diskModeToRaw DiskRdWr
984

    
985
diskAccessSet :: FrozenSet String
986
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
987

    
988
-- * Disk replacement mode
989

    
990
replaceDiskAuto :: String
991
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
992

    
993
replaceDiskChg :: String
994
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
995

    
996
replaceDiskPri :: String
997
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
998

    
999
replaceDiskSec :: String
1000
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
1001

    
1002
replaceModes :: FrozenSet String
1003
replaceModes =
1004
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
1005

    
1006
-- * Instance export mode
1007

    
1008
exportModeLocal :: String
1009
exportModeLocal = Types.exportModeToRaw ExportModeLocal
1010

    
1011
exportModeRemote :: String
1012
exportModeRemote = Types.exportModeToRaw ExportModeRemote
1013

    
1014
exportModes :: FrozenSet String
1015
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
1016

    
1017
-- * Instance creation modes
1018

    
1019
instanceCreate :: String
1020
instanceCreate = Types.instCreateModeToRaw InstCreate
1021

    
1022
instanceImport :: String
1023
instanceImport = Types.instCreateModeToRaw InstImport
1024

    
1025
instanceRemoteImport :: String
1026
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1027

    
1028
instanceCreateModes :: FrozenSet String
1029
instanceCreateModes =
1030
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1031

    
1032
-- * Remote import/export handshake message and version
1033

    
1034
rieHandshake :: String
1035
rieHandshake = "Hi, I'm Ganeti"
1036

    
1037
rieVersion :: Int
1038
rieVersion = 0
1039

    
1040
-- | Remote import/export certificate validity (seconds)
1041
rieCertValidity :: Int
1042
rieCertValidity = 24 * 60 * 60
1043

    
1044
-- | Export only: how long to wait per connection attempt (seconds)
1045
rieConnectAttemptTimeout :: Int
1046
rieConnectAttemptTimeout = 20
1047

    
1048
-- | Export only: number of attempts to connect
1049
rieConnectRetries :: Int
1050
rieConnectRetries = 10
1051

    
1052
-- | Overall timeout for establishing connection
1053
rieConnectTimeout :: Int
1054
rieConnectTimeout = 180
1055

    
1056
-- | Give child process up to 5 seconds to exit after sending a signal
1057
childLingerTimeout :: Double
1058
childLingerTimeout = 5.0
1059

    
1060
-- * Import/export config options
1061

    
1062
inisectBep :: String
1063
inisectBep = "backend"
1064

    
1065
inisectExp :: String
1066
inisectExp = "export"
1067

    
1068
inisectHyp :: String
1069
inisectHyp = "hypervisor"
1070

    
1071
inisectIns :: String
1072
inisectIns = "instance"
1073

    
1074
inisectOsp :: String
1075
inisectOsp = "os"
1076

    
1077
-- * Dynamic device modification
1078

    
1079
ddmAdd :: String
1080
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1081

    
1082
ddmModify :: String
1083
ddmModify = Types.ddmFullToRaw DdmFullModify
1084

    
1085
ddmRemove :: String
1086
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1087

    
1088
ddmsValues :: FrozenSet String
1089
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1090

    
1091
ddmsValuesWithModify :: FrozenSet String
1092
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1093

    
1094
-- * Common exit codes
1095

    
1096
exitSuccess :: Int
1097
exitSuccess = 0
1098

    
1099
exitFailure :: Int
1100
exitFailure = ConstantUtils.exitFailure
1101

    
1102
exitNotcluster :: Int
1103
exitNotcluster = 5
1104

    
1105
exitNotmaster :: Int
1106
exitNotmaster = 11
1107

    
1108
exitNodesetupError :: Int
1109
exitNodesetupError = 12
1110

    
1111
-- | Need user confirmation
1112
exitConfirmation :: Int
1113
exitConfirmation = 13
1114

    
1115
-- | Exit code for query operations with unknown fields
1116
exitUnknownField :: Int
1117
exitUnknownField = 14
1118

    
1119
-- * Tags
1120

    
1121
tagCluster :: String
1122
tagCluster = Types.tagKindToRaw TagKindCluster
1123

    
1124
tagInstance :: String
1125
tagInstance = Types.tagKindToRaw TagKindInstance
1126

    
1127
tagNetwork :: String
1128
tagNetwork = Types.tagKindToRaw TagKindNetwork
1129

    
1130
tagNode :: String
1131
tagNode = Types.tagKindToRaw TagKindNode
1132

    
1133
tagNodegroup :: String
1134
tagNodegroup = Types.tagKindToRaw TagKindGroup
1135

    
1136
validTagTypes :: FrozenSet String
1137
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1138

    
1139
maxTagLen :: Int
1140
maxTagLen = 128
1141

    
1142
maxTagsPerObj :: Int
1143
maxTagsPerObj = 4096
1144

    
1145
-- * Others
1146

    
1147
defaultBridge :: String
1148
defaultBridge = "xen-br0"
1149

    
1150
defaultOvs :: String
1151
defaultOvs = "switch1"
1152

    
1153
-- | 60 MiB/s, expressed in KiB/s
1154
classicDrbdSyncSpeed :: Int
1155
classicDrbdSyncSpeed = 60 * 1024
1156

    
1157
ip4AddressAny :: String
1158
ip4AddressAny = "0.0.0.0"
1159

    
1160
ip4AddressLocalhost :: String
1161
ip4AddressLocalhost = "127.0.0.1"
1162

    
1163
ip6AddressAny :: String
1164
ip6AddressAny = "::"
1165

    
1166
ip6AddressLocalhost :: String
1167
ip6AddressLocalhost = "::1"
1168

    
1169
ip4Version :: Int
1170
ip4Version = 4
1171

    
1172
ip6Version :: Int
1173
ip6Version = 6
1174

    
1175
validIpVersions :: FrozenSet Int
1176
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1177

    
1178
tcpPingTimeout :: Int
1179
tcpPingTimeout = 10
1180

    
1181
defaultVg :: String
1182
defaultVg = "xenvg"
1183

    
1184
defaultDrbdHelper :: String
1185
defaultDrbdHelper = "/bin/true"
1186

    
1187
minVgSize :: Int
1188
minVgSize = 20480
1189

    
1190
defaultMacPrefix :: String
1191
defaultMacPrefix = "aa:00:00"
1192

    
1193
-- | Default maximum instance wait time (seconds)
1194
defaultShutdownTimeout :: Int
1195
defaultShutdownTimeout = 120
1196

    
1197
-- | Node clock skew (seconds)
1198
nodeMaxClockSkew :: Int
1199
nodeMaxClockSkew = 150
1200

    
1201
-- | Time for an intra-cluster disk transfer to wait for a connection
1202
diskTransferConnectTimeout :: Int
1203
diskTransferConnectTimeout = 60
1204

    
1205
-- | Disk index separator
1206
diskSeparator :: String
1207
diskSeparator = AutoConf.diskSeparator
1208

    
1209
ipCommandPath :: String
1210
ipCommandPath = AutoConf.ipPath
1211

    
1212
-- | Key for job IDs in opcode result
1213
jobIdsKey :: String
1214
jobIdsKey = "jobs"
1215

    
1216
-- * Runparts results
1217

    
1218
runpartsErr :: Int
1219
runpartsErr = 2
1220

    
1221
runpartsRun :: Int
1222
runpartsRun = 1
1223

    
1224
runpartsSkip :: Int
1225
runpartsSkip = 0
1226

    
1227
runpartsStatus :: [Int]
1228
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1229

    
1230
-- * RPC
1231

    
1232
rpcEncodingNone :: Int
1233
rpcEncodingNone = 0
1234

    
1235
rpcEncodingZlibBase64 :: Int
1236
rpcEncodingZlibBase64 = 1
1237

    
1238
-- * Timeout table
1239
--
1240
-- Various time constants for the timeout table
1241

    
1242
rpcTmoUrgent :: Int
1243
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1244

    
1245
rpcTmoFast :: Int
1246
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1247

    
1248
rpcTmoNormal :: Int
1249
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1250

    
1251
rpcTmoSlow :: Int
1252
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1253

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

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

    
1266
-- | Timeout for connecting to nodes (seconds)
1267
rpcConnectTimeout :: Int
1268
rpcConnectTimeout = 5
1269

    
1270
-- OS
1271

    
1272
osScriptCreate :: String
1273
osScriptCreate = "create"
1274

    
1275
osScriptExport :: String
1276
osScriptExport = "export"
1277

    
1278
osScriptImport :: String
1279
osScriptImport = "import"
1280

    
1281
osScriptRename :: String
1282
osScriptRename = "rename"
1283

    
1284
osScriptVerify :: String
1285
osScriptVerify = "verify"
1286

    
1287
osScripts :: [String]
1288
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1289
             osScriptVerify]
1290

    
1291
osApiFile :: String
1292
osApiFile = "ganeti_api_version"
1293

    
1294
osVariantsFile :: String
1295
osVariantsFile = "variants.list"
1296

    
1297
osParametersFile :: String
1298
osParametersFile = "parameters.list"
1299

    
1300
osValidateParameters :: String
1301
osValidateParameters = "parameters"
1302

    
1303
osValidateCalls :: FrozenSet String
1304
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1305

    
1306
-- | External Storage (ES) related constants
1307

    
1308
esActionAttach :: String
1309
esActionAttach = "attach"
1310

    
1311
esActionCreate :: String
1312
esActionCreate = "create"
1313

    
1314
esActionDetach :: String
1315
esActionDetach = "detach"
1316

    
1317
esActionGrow :: String
1318
esActionGrow = "grow"
1319

    
1320
esActionRemove :: String
1321
esActionRemove = "remove"
1322

    
1323
esActionSetinfo :: String
1324
esActionSetinfo = "setinfo"
1325

    
1326
esActionVerify :: String
1327
esActionVerify = "verify"
1328

    
1329
esScriptCreate :: String
1330
esScriptCreate = esActionCreate
1331

    
1332
esScriptRemove :: String
1333
esScriptRemove = esActionRemove
1334

    
1335
esScriptGrow :: String
1336
esScriptGrow = esActionGrow
1337

    
1338
esScriptAttach :: String
1339
esScriptAttach = esActionAttach
1340

    
1341
esScriptDetach :: String
1342
esScriptDetach = esActionDetach
1343

    
1344
esScriptSetinfo :: String
1345
esScriptSetinfo = esActionSetinfo
1346

    
1347
esScriptVerify :: String
1348
esScriptVerify = esActionVerify
1349

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

    
1360
esParametersFile :: String
1361
esParametersFile = "parameters.list"
1362

    
1363
-- * Reboot types
1364

    
1365
instanceRebootSoft :: String
1366
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1367

    
1368
instanceRebootHard :: String
1369
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1370

    
1371
instanceRebootFull :: String
1372
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1373

    
1374
rebootTypes :: FrozenSet String
1375
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1376

    
1377
-- * Instance reboot behaviors
1378

    
1379
instanceRebootAllowed :: String
1380
instanceRebootAllowed = "reboot"
1381

    
1382
instanceRebootExit :: String
1383
instanceRebootExit = "exit"
1384

    
1385
rebootBehaviors :: [String]
1386
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1387

    
1388
-- * VTypes
1389

    
1390
vtypeBool :: VType
1391
vtypeBool = VTypeBool
1392

    
1393
vtypeInt :: VType
1394
vtypeInt = VTypeInt
1395

    
1396
vtypeMaybeString :: VType
1397
vtypeMaybeString = VTypeMaybeString
1398

    
1399
-- | Size in MiBs
1400
vtypeSize :: VType
1401
vtypeSize = VTypeSize
1402

    
1403
vtypeString :: VType
1404
vtypeString = VTypeString
1405

    
1406
enforceableTypes :: FrozenSet VType
1407
enforceableTypes = ConstantUtils.mkSet [minBound..]
1408

    
1409
-- | Constant representing that the user does not specify any IP version
1410
ifaceNoIpVersionSpecified :: Int
1411
ifaceNoIpVersionSpecified = 0
1412

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

    
1434
-- * HV parameter names (global namespace)
1435

    
1436
hvAcpi :: String
1437
hvAcpi = "acpi"
1438

    
1439
hvBlockdevPrefix :: String
1440
hvBlockdevPrefix = "blockdev_prefix"
1441

    
1442
hvBootloaderArgs :: String
1443
hvBootloaderArgs = "bootloader_args"
1444

    
1445
hvBootloaderPath :: String
1446
hvBootloaderPath = "bootloader_path"
1447

    
1448
hvBootOrder :: String
1449
hvBootOrder = "boot_order"
1450

    
1451
hvCdromImagePath :: String
1452
hvCdromImagePath = "cdrom_image_path"
1453

    
1454
hvCpuCap :: String
1455
hvCpuCap = "cpu_cap"
1456

    
1457
hvCpuCores :: String
1458
hvCpuCores = "cpu_cores"
1459

    
1460
hvCpuMask :: String
1461
hvCpuMask = "cpu_mask"
1462

    
1463
hvCpuSockets :: String
1464
hvCpuSockets = "cpu_sockets"
1465

    
1466
hvCpuThreads :: String
1467
hvCpuThreads = "cpu_threads"
1468

    
1469
hvCpuType :: String
1470
hvCpuType = "cpu_type"
1471

    
1472
hvCpuWeight :: String
1473
hvCpuWeight = "cpu_weight"
1474

    
1475
hvDeviceModel :: String
1476
hvDeviceModel = "device_model"
1477

    
1478
hvDiskCache :: String
1479
hvDiskCache = "disk_cache"
1480

    
1481
hvDiskType :: String
1482
hvDiskType = "disk_type"
1483

    
1484
hvInitrdPath :: String
1485
hvInitrdPath = "initrd_path"
1486

    
1487
hvInitScript :: String
1488
hvInitScript = "init_script"
1489

    
1490
hvKernelArgs :: String
1491
hvKernelArgs = "kernel_args"
1492

    
1493
hvKernelPath :: String
1494
hvKernelPath = "kernel_path"
1495

    
1496
hvKeymap :: String
1497
hvKeymap = "keymap"
1498

    
1499
hvKvmCdrom2ImagePath :: String
1500
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1501

    
1502
hvKvmCdromDiskType :: String
1503
hvKvmCdromDiskType = "cdrom_disk_type"
1504

    
1505
hvKvmExtra :: String
1506
hvKvmExtra = "kvm_extra"
1507

    
1508
hvKvmFlag :: String
1509
hvKvmFlag = "kvm_flag"
1510

    
1511
hvKvmFloppyImagePath :: String
1512
hvKvmFloppyImagePath = "floppy_image_path"
1513

    
1514
hvKvmMachineVersion :: String
1515
hvKvmMachineVersion = "machine_version"
1516

    
1517
hvKvmPath :: String
1518
hvKvmPath = "kvm_path"
1519

    
1520
hvKvmSpiceAudioCompr :: String
1521
hvKvmSpiceAudioCompr = "spice_playback_compression"
1522

    
1523
hvKvmSpiceBind :: String
1524
hvKvmSpiceBind = "spice_bind"
1525

    
1526
hvKvmSpiceIpVersion :: String
1527
hvKvmSpiceIpVersion = "spice_ip_version"
1528

    
1529
hvKvmSpiceJpegImgCompr :: String
1530
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1531

    
1532
hvKvmSpiceLosslessImgCompr :: String
1533
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1534

    
1535
hvKvmSpicePasswordFile :: String
1536
hvKvmSpicePasswordFile = "spice_password_file"
1537

    
1538
hvKvmSpiceStreamingVideoDetection :: String
1539
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1540

    
1541
hvKvmSpiceTlsCiphers :: String
1542
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1543

    
1544
hvKvmSpiceUseTls :: String
1545
hvKvmSpiceUseTls = "spice_use_tls"
1546

    
1547
hvKvmSpiceUseVdagent :: String
1548
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1549

    
1550
hvKvmSpiceZlibGlzImgCompr :: String
1551
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1552

    
1553
hvKvmUseChroot :: String
1554
hvKvmUseChroot = "use_chroot"
1555

    
1556
hvMemPath :: String
1557
hvMemPath = "mem_path"
1558

    
1559
hvMigrationBandwidth :: String
1560
hvMigrationBandwidth = "migration_bandwidth"
1561

    
1562
hvMigrationDowntime :: String
1563
hvMigrationDowntime = "migration_downtime"
1564

    
1565
hvMigrationMode :: String
1566
hvMigrationMode = "migration_mode"
1567

    
1568
hvMigrationPort :: String
1569
hvMigrationPort = "migration_port"
1570

    
1571
hvNicType :: String
1572
hvNicType = "nic_type"
1573

    
1574
hvPae :: String
1575
hvPae = "pae"
1576

    
1577
hvPassthrough :: String
1578
hvPassthrough = "pci_pass"
1579

    
1580
hvRebootBehavior :: String
1581
hvRebootBehavior = "reboot_behavior"
1582

    
1583
hvRootPath :: String
1584
hvRootPath = "root_path"
1585

    
1586
hvSecurityDomain :: String
1587
hvSecurityDomain = "security_domain"
1588

    
1589
hvSecurityModel :: String
1590
hvSecurityModel = "security_model"
1591

    
1592
hvSerialConsole :: String
1593
hvSerialConsole = "serial_console"
1594

    
1595
hvSerialSpeed :: String
1596
hvSerialSpeed = "serial_speed"
1597

    
1598
hvSoundhw :: String
1599
hvSoundhw = "soundhw"
1600

    
1601
hvUsbDevices :: String
1602
hvUsbDevices = "usb_devices"
1603

    
1604
hvUsbMouse :: String
1605
hvUsbMouse = "usb_mouse"
1606

    
1607
hvUseBootloader :: String
1608
hvUseBootloader = "use_bootloader"
1609

    
1610
hvUseLocaltime :: String
1611
hvUseLocaltime = "use_localtime"
1612

    
1613
hvVga :: String
1614
hvVga = "vga"
1615

    
1616
hvVhostNet :: String
1617
hvVhostNet = "vhost_net"
1618

    
1619
hvVifScript :: String
1620
hvVifScript = "vif_script"
1621

    
1622
hvVifType :: String
1623
hvVifType = "vif_type"
1624

    
1625
hvViridian :: String
1626
hvViridian = "viridian"
1627

    
1628
hvVncBindAddress :: String
1629
hvVncBindAddress = "vnc_bind_address"
1630

    
1631
hvVncPasswordFile :: String
1632
hvVncPasswordFile = "vnc_password_file"
1633

    
1634
hvVncTls :: String
1635
hvVncTls = "vnc_tls"
1636

    
1637
hvVncX509 :: String
1638
hvVncX509 = "vnc_x509_path"
1639

    
1640
hvVncX509Verify :: String
1641
hvVncX509Verify = "vnc_x509_verify"
1642

    
1643
hvVnetHdr :: String
1644
hvVnetHdr = "vnet_hdr"
1645

    
1646
hvXenCmd :: String
1647
hvXenCmd = "xen_cmd"
1648

    
1649
hvXenCpuid :: String
1650
hvXenCpuid = "cpuid"
1651

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

    
1667
hvsParameters :: FrozenSet String
1668
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1669

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

    
1746
-- * Migration statuses
1747

    
1748
hvMigrationActive :: String
1749
hvMigrationActive = "active"
1750

    
1751
hvMigrationCancelled :: String
1752
hvMigrationCancelled = "cancelled"
1753

    
1754
hvMigrationCompleted :: String
1755
hvMigrationCompleted = "completed"
1756

    
1757
hvMigrationFailed :: String
1758
hvMigrationFailed = "failed"
1759

    
1760
hvMigrationValidStatuses :: FrozenSet String
1761
hvMigrationValidStatuses =
1762
  ConstantUtils.mkSet [hvMigrationActive,
1763
                       hvMigrationCancelled,
1764
                       hvMigrationCompleted,
1765
                       hvMigrationFailed]
1766

    
1767
hvMigrationFailedStatuses :: FrozenSet String
1768
hvMigrationFailedStatuses =
1769
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1770

    
1771
-- | KVM-specific statuses
1772
--
1773
-- FIXME: this constant seems unnecessary
1774
hvKvmMigrationValidStatuses :: FrozenSet String
1775
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1776

    
1777
-- | Node info keys
1778
hvNodeinfoKeyVersion :: String
1779
hvNodeinfoKeyVersion = "hv_version"
1780

    
1781
-- * Hypervisor state
1782

    
1783
hvstCpuNode :: String
1784
hvstCpuNode = "cpu_node"
1785

    
1786
hvstCpuTotal :: String
1787
hvstCpuTotal = "cpu_total"
1788

    
1789
hvstMemoryHv :: String
1790
hvstMemoryHv = "mem_hv"
1791

    
1792
hvstMemoryNode :: String
1793
hvstMemoryNode = "mem_node"
1794

    
1795
hvstMemoryTotal :: String
1796
hvstMemoryTotal = "mem_total"
1797

    
1798
hvstsParameters :: FrozenSet String
1799
hvstsParameters =
1800
  ConstantUtils.mkSet [hvstCpuNode,
1801
                       hvstCpuTotal,
1802
                       hvstMemoryHv,
1803
                       hvstMemoryNode,
1804
                       hvstMemoryTotal]
1805

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

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

    
1823
-- * Disk state
1824

    
1825
dsDiskOverhead :: String
1826
dsDiskOverhead = "disk_overhead"
1827

    
1828
dsDiskReserved :: String
1829
dsDiskReserved = "disk_reserved"
1830

    
1831
dsDiskTotal :: String
1832
dsDiskTotal = "disk_total"
1833

    
1834
dsDefaults :: Map String Int
1835
dsDefaults =
1836
  Map.fromList
1837
  [(dsDiskTotal, 0),
1838
   (dsDiskReserved, 0),
1839
   (dsDiskOverhead, 0)]
1840

    
1841
dssParameterTypes :: Map String VType
1842
dssParameterTypes =
1843
  Map.fromList [(dsDiskTotal, VTypeInt),
1844
                (dsDiskReserved, VTypeInt),
1845
                (dsDiskOverhead, VTypeInt)]
1846

    
1847
dssParameters :: FrozenSet String
1848
dssParameters =
1849
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1850

    
1851
dsValidTypes :: FrozenSet String
1852
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1853

    
1854
-- Backend parameter names
1855

    
1856
beAlwaysFailover :: String
1857
beAlwaysFailover = "always_failover"
1858

    
1859
beAutoBalance :: String
1860
beAutoBalance = "auto_balance"
1861

    
1862
beMaxmem :: String
1863
beMaxmem = "maxmem"
1864

    
1865
-- | Deprecated and replaced by max and min mem
1866
beMemory :: String
1867
beMemory = "memory"
1868

    
1869
beMinmem :: String
1870
beMinmem = "minmem"
1871

    
1872
beSpindleUse :: String
1873
beSpindleUse = "spindle_use"
1874

    
1875
beVcpus :: String
1876
beVcpus = "vcpus"
1877

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

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

    
1894
besParameterCompat :: Map String VType
1895
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1896

    
1897
besParameters :: FrozenSet String
1898
besParameters =
1899
  ConstantUtils.mkSet [beAlwaysFailover,
1900
                       beAutoBalance,
1901
                       beMaxmem,
1902
                       beMinmem,
1903
                       beSpindleUse,
1904
                       beVcpus]
1905

    
1906
-- | Instance specs
1907
--
1908
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1909

    
1910
ispecMemSize :: String
1911
ispecMemSize = ConstantUtils.ispecMemSize
1912

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

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

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

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

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

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

    
1938
ispecsParameters :: FrozenSet String
1939
ispecsParameters =
1940
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1941
                       ConstantUtils.ispecDiskCount,
1942
                       ConstantUtils.ispecDiskSize,
1943
                       ConstantUtils.ispecMemSize,
1944
                       ConstantUtils.ispecNicCount,
1945
                       ConstantUtils.ispecSpindleUse]
1946

    
1947
ispecsMinmax :: String
1948
ispecsMinmax = ConstantUtils.ispecsMinmax
1949

    
1950
ispecsMax :: String
1951
ispecsMax = "max"
1952

    
1953
ispecsMin :: String
1954
ispecsMin = "min"
1955

    
1956
ispecsStd :: String
1957
ispecsStd = ConstantUtils.ispecsStd
1958

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

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

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

    
1968
ispecsMinmaxKeys :: FrozenSet String
1969
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1970

    
1971
ipolicyParameters :: FrozenSet String
1972
ipolicyParameters =
1973
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1974
                       ConstantUtils.ipolicySpindleRatio]
1975

    
1976
ipolicyAllKeys :: FrozenSet String
1977
ipolicyAllKeys =
1978
  ConstantUtils.union ipolicyParameters $
1979
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1980
                       ConstantUtils.ispecsMinmax,
1981
                       ispecsStd]
1982

    
1983
-- | Node parameter names
1984

    
1985
ndExclusiveStorage :: String
1986
ndExclusiveStorage = "exclusive_storage"
1987

    
1988
ndOobProgram :: String
1989
ndOobProgram = "oob_program"
1990

    
1991
ndSpindleCount :: String
1992
ndSpindleCount = "spindle_count"
1993

    
1994
ndOvs :: String
1995
ndOvs = "ovs"
1996

    
1997
ndOvsLink :: String
1998
ndOvsLink = "ovs_link"
1999

    
2000
ndOvsName :: String
2001
ndOvsName = "ovs_name"
2002

    
2003
ndSshPort :: String
2004
ndSshPort = "ssh_port"
2005

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

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

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

    
2030
-- * Logical Disks parameters
2031

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2187
diskDtParameters :: FrozenSet String
2188
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2189

    
2190
-- * Dynamic disk parameters
2191

    
2192
ddpLocalIp :: String
2193
ddpLocalIp = "local-ip"
2194

    
2195
ddpRemoteIp :: String
2196
ddpRemoteIp = "remote-ip"
2197

    
2198
ddpPort :: String
2199
ddpPort = "port"
2200

    
2201
ddpLocalMinor :: String
2202
ddpLocalMinor = "local-minor"
2203

    
2204
ddpRemoteMinor :: String
2205
ddpRemoteMinor = "remote-minor"
2206

    
2207
-- * OOB supported commands
2208

    
2209
oobPowerOn :: String
2210
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2211

    
2212
oobPowerOff :: String
2213
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2214

    
2215
oobPowerCycle :: String
2216
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2217

    
2218
oobPowerStatus :: String
2219
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2220

    
2221
oobHealth :: String
2222
oobHealth = Types.oobCommandToRaw OobHealth
2223

    
2224
oobCommands :: FrozenSet String
2225
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2226

    
2227
oobPowerStatusPowered :: String
2228
oobPowerStatusPowered = "powered"
2229

    
2230
-- | 60 seconds
2231
oobTimeout :: Int
2232
oobTimeout = 60
2233

    
2234
-- | 2 seconds
2235
oobPowerDelay :: Double
2236
oobPowerDelay = 2.0
2237

    
2238
oobStatusCritical :: String
2239
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2240

    
2241
oobStatusOk :: String
2242
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2243

    
2244
oobStatusUnknown :: String
2245
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2246

    
2247
oobStatusWarning :: String
2248
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2249

    
2250
oobStatuses :: FrozenSet String
2251
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2252

    
2253
-- | Instance Parameters Profile
2254
ppDefault :: String
2255
ppDefault = "default"
2256

    
2257
-- * nic* constants are used inside the ganeti config
2258

    
2259
nicLink :: String
2260
nicLink = "link"
2261

    
2262
nicMode :: String
2263
nicMode = "mode"
2264

    
2265
nicVlan :: String
2266
nicVlan = "vlan"
2267

    
2268
nicsParameterTypes :: Map String VType
2269
nicsParameterTypes =
2270
  Map.fromList [(nicMode, vtypeString),
2271
                (nicLink, vtypeString),
2272
                (nicVlan, vtypeString)]
2273

    
2274
nicsParameters :: FrozenSet String
2275
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2276

    
2277
nicModeBridged :: String
2278
nicModeBridged = Types.nICModeToRaw NMBridged
2279

    
2280
nicModeRouted :: String
2281
nicModeRouted = Types.nICModeToRaw NMRouted
2282

    
2283
nicModeOvs :: String
2284
nicModeOvs = Types.nICModeToRaw NMOvs
2285

    
2286
nicIpPool :: String
2287
nicIpPool = Types.nICModeToRaw NMPool
2288

    
2289
nicValidModes :: FrozenSet String
2290
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2291

    
2292
releaseAction :: String
2293
releaseAction = "release"
2294

    
2295
reserveAction :: String
2296
reserveAction = "reserve"
2297

    
2298
-- * idisk* constants are used in opcodes, to create/change disks
2299

    
2300
idiskAdopt :: String
2301
idiskAdopt = "adopt"
2302

    
2303
idiskMetavg :: String
2304
idiskMetavg = "metavg"
2305

    
2306
idiskMode :: String
2307
idiskMode = "mode"
2308

    
2309
idiskName :: String
2310
idiskName = "name"
2311

    
2312
idiskSize :: String
2313
idiskSize = "size"
2314

    
2315
idiskSpindles :: String
2316
idiskSpindles = "spindles"
2317

    
2318
idiskVg :: String
2319
idiskVg = "vg"
2320

    
2321
idiskProvider :: String
2322
idiskProvider = "provider"
2323

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

    
2335
idiskParams :: FrozenSet String
2336
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2337

    
2338
-- * inic* constants are used in opcodes, to create/change nics
2339

    
2340
inicBridge :: String
2341
inicBridge = "bridge"
2342

    
2343
inicIp :: String
2344
inicIp = "ip"
2345

    
2346
inicLink :: String
2347
inicLink = "link"
2348

    
2349
inicMac :: String
2350
inicMac = "mac"
2351

    
2352
inicMode :: String
2353
inicMode = "mode"
2354

    
2355
inicName :: String
2356
inicName = "name"
2357

    
2358
inicNetwork :: String
2359
inicNetwork = "network"
2360

    
2361
inicVlan :: String
2362
inicVlan = "vlan"
2363

    
2364
inicParamsTypes :: Map String VType
2365
inicParamsTypes =
2366
  Map.fromList [(inicBridge, VTypeMaybeString),
2367
                (inicIp, VTypeMaybeString),
2368
                (inicLink, VTypeString),
2369
                (inicMac, VTypeString),
2370
                (inicMode, VTypeString),
2371
                (inicName, VTypeMaybeString),
2372
                (inicNetwork, VTypeMaybeString),
2373
                (inicVlan, VTypeMaybeString)]
2374

    
2375
inicParams :: FrozenSet String
2376
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2377

    
2378
-- * Hypervisor constants
2379

    
2380
htXenPvm :: String
2381
htXenPvm = Types.hypervisorToRaw XenPvm
2382

    
2383
htFake :: String
2384
htFake = Types.hypervisorToRaw Fake
2385

    
2386
htXenHvm :: String
2387
htXenHvm = Types.hypervisorToRaw XenHvm
2388

    
2389
htKvm :: String
2390
htKvm = Types.hypervisorToRaw Kvm
2391

    
2392
htChroot :: String
2393
htChroot = Types.hypervisorToRaw Chroot
2394

    
2395
htLxc :: String
2396
htLxc = Types.hypervisorToRaw Lxc
2397

    
2398
hyperTypes :: FrozenSet String
2399
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2400

    
2401
htsReqPort :: FrozenSet String
2402
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2403

    
2404
vncBasePort :: Int
2405
vncBasePort = 5900
2406

    
2407
vncDefaultBindAddress :: String
2408
vncDefaultBindAddress = ip4AddressAny
2409

    
2410
-- * NIC types
2411

    
2412
htNicE1000 :: String
2413
htNicE1000 = "e1000"
2414

    
2415
htNicI82551 :: String
2416
htNicI82551 = "i82551"
2417

    
2418
htNicI8259er :: String
2419
htNicI8259er = "i82559er"
2420

    
2421
htNicI85557b :: String
2422
htNicI85557b = "i82557b"
2423

    
2424
htNicNe2kIsa :: String
2425
htNicNe2kIsa = "ne2k_isa"
2426

    
2427
htNicNe2kPci :: String
2428
htNicNe2kPci = "ne2k_pci"
2429

    
2430
htNicParavirtual :: String
2431
htNicParavirtual = "paravirtual"
2432

    
2433
htNicPcnet :: String
2434
htNicPcnet = "pcnet"
2435

    
2436
htNicRtl8139 :: String
2437
htNicRtl8139 = "rtl8139"
2438

    
2439
htHvmValidNicTypes :: FrozenSet String
2440
htHvmValidNicTypes =
2441
  ConstantUtils.mkSet [htNicE1000,
2442
                       htNicNe2kIsa,
2443
                       htNicNe2kPci,
2444
                       htNicParavirtual,
2445
                       htNicRtl8139]
2446

    
2447
htKvmValidNicTypes :: FrozenSet String
2448
htKvmValidNicTypes =
2449
  ConstantUtils.mkSet [htNicE1000,
2450
                       htNicI82551,
2451
                       htNicI8259er,
2452
                       htNicI85557b,
2453
                       htNicNe2kIsa,
2454
                       htNicNe2kPci,
2455
                       htNicParavirtual,
2456
                       htNicPcnet,
2457
                       htNicRtl8139]
2458

    
2459
-- * Vif types
2460

    
2461
-- | Default vif type in xen-hvm
2462
htHvmVifIoemu :: String
2463
htHvmVifIoemu = "ioemu"
2464

    
2465
htHvmVifVif :: String
2466
htHvmVifVif = "vif"
2467

    
2468
htHvmValidVifTypes :: FrozenSet String
2469
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2470

    
2471
-- * Disk types
2472

    
2473
htDiskIde :: String
2474
htDiskIde = "ide"
2475

    
2476
htDiskIoemu :: String
2477
htDiskIoemu = "ioemu"
2478

    
2479
htDiskMtd :: String
2480
htDiskMtd = "mtd"
2481

    
2482
htDiskParavirtual :: String
2483
htDiskParavirtual = "paravirtual"
2484

    
2485
htDiskPflash :: String
2486
htDiskPflash = "pflash"
2487

    
2488
htDiskScsi :: String
2489
htDiskScsi = "scsi"
2490

    
2491
htDiskSd :: String
2492
htDiskSd = "sd"
2493

    
2494
htHvmValidDiskTypes :: FrozenSet String
2495
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2496

    
2497
htKvmValidDiskTypes :: FrozenSet String
2498
htKvmValidDiskTypes =
2499
  ConstantUtils.mkSet [htDiskIde,
2500
                       htDiskMtd,
2501
                       htDiskParavirtual,
2502
                       htDiskPflash,
2503
                       htDiskScsi,
2504
                       htDiskSd]
2505

    
2506
htCacheDefault :: String
2507
htCacheDefault = "default"
2508

    
2509
htCacheNone :: String
2510
htCacheNone = "none"
2511

    
2512
htCacheWback :: String
2513
htCacheWback = "writeback"
2514

    
2515
htCacheWthrough :: String
2516
htCacheWthrough = "writethrough"
2517

    
2518
htValidCacheTypes :: FrozenSet String
2519
htValidCacheTypes =
2520
  ConstantUtils.mkSet [htCacheDefault,
2521
                       htCacheNone,
2522
                       htCacheWback,
2523
                       htCacheWthrough]
2524

    
2525
-- * Mouse types
2526

    
2527
htMouseMouse :: String
2528
htMouseMouse = "mouse"
2529

    
2530
htMouseTablet :: String
2531
htMouseTablet = "tablet"
2532

    
2533
htKvmValidMouseTypes :: FrozenSet String
2534
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2535

    
2536
-- * Boot order
2537

    
2538
htBoCdrom :: String
2539
htBoCdrom = "cdrom"
2540

    
2541
htBoDisk :: String
2542
htBoDisk = "disk"
2543

    
2544
htBoFloppy :: String
2545
htBoFloppy = "floppy"
2546

    
2547
htBoNetwork :: String
2548
htBoNetwork = "network"
2549

    
2550
htKvmValidBoTypes :: FrozenSet String
2551
htKvmValidBoTypes =
2552
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2553

    
2554
-- * SPICE lossless image compression options
2555

    
2556
htKvmSpiceLosslessImgComprAutoGlz :: String
2557
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2558

    
2559
htKvmSpiceLosslessImgComprAutoLz :: String
2560
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2561

    
2562
htKvmSpiceLosslessImgComprGlz :: String
2563
htKvmSpiceLosslessImgComprGlz = "glz"
2564

    
2565
htKvmSpiceLosslessImgComprLz :: String
2566
htKvmSpiceLosslessImgComprLz = "lz"
2567

    
2568
htKvmSpiceLosslessImgComprOff :: String
2569
htKvmSpiceLosslessImgComprOff = "off"
2570

    
2571
htKvmSpiceLosslessImgComprQuic :: String
2572
htKvmSpiceLosslessImgComprQuic = "quic"
2573

    
2574
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2575
htKvmSpiceValidLosslessImgComprOptions =
2576
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2577
                       htKvmSpiceLosslessImgComprAutoLz,
2578
                       htKvmSpiceLosslessImgComprGlz,
2579
                       htKvmSpiceLosslessImgComprLz,
2580
                       htKvmSpiceLosslessImgComprOff,
2581
                       htKvmSpiceLosslessImgComprQuic]
2582

    
2583
htKvmSpiceLossyImgComprAlways :: String
2584
htKvmSpiceLossyImgComprAlways = "always"
2585

    
2586
htKvmSpiceLossyImgComprAuto :: String
2587
htKvmSpiceLossyImgComprAuto = "auto"
2588

    
2589
htKvmSpiceLossyImgComprNever :: String
2590
htKvmSpiceLossyImgComprNever = "never"
2591

    
2592
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2593
htKvmSpiceValidLossyImgComprOptions =
2594
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2595
                       htKvmSpiceLossyImgComprAuto,
2596
                       htKvmSpiceLossyImgComprNever]
2597

    
2598
-- * SPICE video stream detection
2599

    
2600
htKvmSpiceVideoStreamDetectionAll :: String
2601
htKvmSpiceVideoStreamDetectionAll = "all"
2602

    
2603
htKvmSpiceVideoStreamDetectionFilter :: String
2604
htKvmSpiceVideoStreamDetectionFilter = "filter"
2605

    
2606
htKvmSpiceVideoStreamDetectionOff :: String
2607
htKvmSpiceVideoStreamDetectionOff = "off"
2608

    
2609
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2610
htKvmSpiceValidVideoStreamDetectionOptions =
2611
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2612
                       htKvmSpiceVideoStreamDetectionFilter,
2613
                       htKvmSpiceVideoStreamDetectionOff]
2614

    
2615
-- * Security models
2616

    
2617
htSmNone :: String
2618
htSmNone = "none"
2619

    
2620
htSmPool :: String
2621
htSmPool = "pool"
2622

    
2623
htSmUser :: String
2624
htSmUser = "user"
2625

    
2626
htKvmValidSmTypes :: FrozenSet String
2627
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2628

    
2629
-- * Kvm flag values
2630

    
2631
htKvmDisabled :: String
2632
htKvmDisabled = "disabled"
2633

    
2634
htKvmEnabled :: String
2635
htKvmEnabled = "enabled"
2636

    
2637
htKvmFlagValues :: FrozenSet String
2638
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2639

    
2640
-- * Migration type
2641

    
2642
htMigrationLive :: String
2643
htMigrationLive = Types.migrationModeToRaw MigrationLive
2644

    
2645
htMigrationNonlive :: String
2646
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2647

    
2648
htMigrationModes :: FrozenSet String
2649
htMigrationModes =
2650
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2651

    
2652
-- * Cluster verify steps
2653

    
2654
verifyNplusoneMem :: String
2655
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2656

    
2657
verifyOptionalChecks :: FrozenSet String
2658
verifyOptionalChecks =
2659
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2660

    
2661
-- * Cluster Verify error classes
2662

    
2663
cvTcluster :: String
2664
cvTcluster = "cluster"
2665

    
2666
cvTgroup :: String
2667
cvTgroup = "group"
2668

    
2669
cvTnode :: String
2670
cvTnode = "node"
2671

    
2672
cvTinstance :: String
2673
cvTinstance = "instance"
2674

    
2675
-- * Cluster Verify error codes and documentation
2676

    
2677
cvEclustercert :: (String, String, String)
2678
cvEclustercert =
2679
  ("cluster",
2680
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2681
   "Cluster certificate files verification failure")
2682

    
2683
cvEclustercfg :: (String, String, String)
2684
cvEclustercfg =
2685
  ("cluster",
2686
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2687
   "Cluster configuration verification failure")
2688

    
2689
cvEclusterdanglinginst :: (String, String, String)
2690
cvEclusterdanglinginst =
2691
  ("node",
2692
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2693
   "Some instances have a non-existing primary node")
2694

    
2695
cvEclusterdanglingnodes :: (String, String, String)
2696
cvEclusterdanglingnodes =
2697
  ("node",
2698
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2699
   "Some nodes belong to non-existing groups")
2700

    
2701
cvEclusterfilecheck :: (String, String, String)
2702
cvEclusterfilecheck =
2703
  ("cluster",
2704
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2705
   "Cluster configuration verification failure")
2706

    
2707
cvEgroupdifferentpvsize :: (String, String, String)
2708
cvEgroupdifferentpvsize =
2709
  ("group",
2710
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2711
   "PVs in the group have different sizes")
2712

    
2713
cvEinstancebadnode :: (String, String, String)
2714
cvEinstancebadnode =
2715
  ("instance",
2716
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2717
   "Instance marked as running lives on an offline node")
2718

    
2719
cvEinstancedown :: (String, String, String)
2720
cvEinstancedown =
2721
  ("instance",
2722
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2723
   "Instance not running on its primary node")
2724

    
2725
cvEinstancefaultydisk :: (String, String, String)
2726
cvEinstancefaultydisk =
2727
  ("instance",
2728
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2729
   "Impossible to retrieve status for a disk")
2730

    
2731
cvEinstancelayout :: (String, String, String)
2732
cvEinstancelayout =
2733
  ("instance",
2734
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2735
   "Instance has multiple secondary nodes")
2736

    
2737
cvEinstancemissingcfgparameter :: (String, String, String)
2738
cvEinstancemissingcfgparameter =
2739
  ("instance",
2740
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2741
   "A configuration parameter for an instance is missing")
2742

    
2743
cvEinstancemissingdisk :: (String, String, String)
2744
cvEinstancemissingdisk =
2745
  ("instance",
2746
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2747
   "Missing volume on an instance")
2748

    
2749
cvEinstancepolicy :: (String, String, String)
2750
cvEinstancepolicy =
2751
  ("instance",
2752
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2753
   "Instance does not meet policy")
2754

    
2755
cvEinstancesplitgroups :: (String, String, String)
2756
cvEinstancesplitgroups =
2757
  ("instance",
2758
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2759
   "Instance with primary and secondary nodes in different groups")
2760

    
2761
cvEinstanceunsuitablenode :: (String, String, String)
2762
cvEinstanceunsuitablenode =
2763
  ("instance",
2764
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2765
   "Instance running on nodes that are not suitable for it")
2766

    
2767
cvEinstancewrongnode :: (String, String, String)
2768
cvEinstancewrongnode =
2769
  ("instance",
2770
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2771
   "Instance running on the wrong node")
2772

    
2773
cvEnodedrbd :: (String, String, String)
2774
cvEnodedrbd =
2775
  ("node",
2776
   Types.cVErrorCodeToRaw CvENODEDRBD,
2777
   "Error parsing the DRBD status file")
2778

    
2779
cvEnodedrbdhelper :: (String, String, String)
2780
cvEnodedrbdhelper =
2781
  ("node",
2782
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2783
   "Error caused by the DRBD helper")
2784

    
2785
cvEnodedrbdversion :: (String, String, String)
2786
cvEnodedrbdversion =
2787
  ("node",
2788
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2789
   "DRBD version mismatch within a node group")
2790

    
2791
cvEnodefilecheck :: (String, String, String)
2792
cvEnodefilecheck =
2793
  ("node",
2794
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2795
   "Error retrieving the checksum of the node files")
2796

    
2797
cvEnodefilestoragepaths :: (String, String, String)
2798
cvEnodefilestoragepaths =
2799
  ("node",
2800
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2801
   "Detected bad file storage paths")
2802

    
2803
cvEnodefilestoragepathunusable :: (String, String, String)
2804
cvEnodefilestoragepathunusable =
2805
  ("node",
2806
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2807
   "File storage path unusable")
2808

    
2809
cvEnodehooks :: (String, String, String)
2810
cvEnodehooks =
2811
  ("node",
2812
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2813
   "Communication failure in hooks execution")
2814

    
2815
cvEnodehv :: (String, String, String)
2816
cvEnodehv =
2817
  ("node",
2818
   Types.cVErrorCodeToRaw CvENODEHV,
2819
   "Hypervisor parameters verification failure")
2820

    
2821
cvEnodelvm :: (String, String, String)
2822
cvEnodelvm =
2823
  ("node",
2824
   Types.cVErrorCodeToRaw CvENODELVM,
2825
   "LVM-related node error")
2826

    
2827
cvEnoden1 :: (String, String, String)
2828
cvEnoden1 =
2829
  ("node",
2830
   Types.cVErrorCodeToRaw CvENODEN1,
2831
   "Not enough memory to accommodate instance failovers")
2832

    
2833
cvEnodenet :: (String, String, String)
2834
cvEnodenet =
2835
  ("node",
2836
   Types.cVErrorCodeToRaw CvENODENET,
2837
   "Network-related node error")
2838

    
2839
cvEnodeoobpath :: (String, String, String)
2840
cvEnodeoobpath =
2841
  ("node",
2842
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2843
   "Invalid Out Of Band path")
2844

    
2845
cvEnodeorphaninstance :: (String, String, String)
2846
cvEnodeorphaninstance =
2847
  ("node",
2848
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2849
   "Unknown intance running on a node")
2850

    
2851
cvEnodeorphanlv :: (String, String, String)
2852
cvEnodeorphanlv =
2853
  ("node",
2854
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2855
   "Unknown LVM logical volume")
2856

    
2857
cvEnodeos :: (String, String, String)
2858
cvEnodeos =
2859
  ("node",
2860
   Types.cVErrorCodeToRaw CvENODEOS,
2861
   "OS-related node error")
2862

    
2863
cvEnoderpc :: (String, String, String)
2864
cvEnoderpc =
2865
  ("node",
2866
   Types.cVErrorCodeToRaw CvENODERPC,
2867
   "Error during connection to the primary node of an instance")
2868

    
2869
cvEnodesetup :: (String, String, String)
2870
cvEnodesetup =
2871
  ("node",
2872
   Types.cVErrorCodeToRaw CvENODESETUP,
2873
   "Node setup error")
2874

    
2875
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2876
cvEnodesharedfilestoragepathunusable =
2877
  ("node",
2878
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2879
   "Shared file storage path unusable")
2880

    
2881
cvEnodessh :: (String, String, String)
2882
cvEnodessh =
2883
  ("node",
2884
   Types.cVErrorCodeToRaw CvENODESSH,
2885
   "SSH-related node error")
2886

    
2887
cvEnodetime :: (String, String, String)
2888
cvEnodetime =
2889
  ("node",
2890
   Types.cVErrorCodeToRaw CvENODETIME,
2891
   "Node returned invalid time")
2892

    
2893
cvEnodeuserscripts :: (String, String, String)
2894
cvEnodeuserscripts =
2895
  ("node",
2896
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2897
   "User scripts not present or not executable")
2898

    
2899
cvEnodeversion :: (String, String, String)
2900
cvEnodeversion =
2901
  ("node",
2902
   Types.cVErrorCodeToRaw CvENODEVERSION,
2903
   "Protocol version mismatch or Ganeti version mismatch")
2904

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

    
2947
cvAllEcodesStrings :: FrozenSet String
2948
cvAllEcodesStrings =
2949
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2950

    
2951
-- * Node verify constants
2952

    
2953
nvBridges :: String
2954
nvBridges = "bridges"
2955

    
2956
nvDrbdhelper :: String
2957
nvDrbdhelper = "drbd-helper"
2958

    
2959
nvDrbdversion :: String
2960
nvDrbdversion = "drbd-version"
2961

    
2962
nvDrbdlist :: String
2963
nvDrbdlist = "drbd-list"
2964

    
2965
nvExclusivepvs :: String
2966
nvExclusivepvs = "exclusive-pvs"
2967

    
2968
nvFilelist :: String
2969
nvFilelist = "filelist"
2970

    
2971
nvAcceptedStoragePaths :: String
2972
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2973

    
2974
nvFileStoragePath :: String
2975
nvFileStoragePath = "file-storage-path"
2976

    
2977
nvSharedFileStoragePath :: String
2978
nvSharedFileStoragePath = "shared-file-storage-path"
2979

    
2980
nvHvinfo :: String
2981
nvHvinfo = "hvinfo"
2982

    
2983
nvHvparams :: String
2984
nvHvparams = "hvparms"
2985

    
2986
nvHypervisor :: String
2987
nvHypervisor = "hypervisor"
2988

    
2989
nvInstancelist :: String
2990
nvInstancelist = "instancelist"
2991

    
2992
nvLvlist :: String
2993
nvLvlist = "lvlist"
2994

    
2995
nvMasterip :: String
2996
nvMasterip = "master-ip"
2997

    
2998
nvNodelist :: String
2999
nvNodelist = "nodelist"
3000

    
3001
nvNodenettest :: String
3002
nvNodenettest = "node-net-test"
3003

    
3004
nvNodesetup :: String
3005
nvNodesetup = "nodesetup"
3006

    
3007
nvOobPaths :: String
3008
nvOobPaths = "oob-paths"
3009

    
3010
nvOslist :: String
3011
nvOslist = "oslist"
3012

    
3013
nvPvlist :: String
3014
nvPvlist = "pvlist"
3015

    
3016
nvTime :: String
3017
nvTime = "time"
3018

    
3019
nvUserscripts :: String
3020
nvUserscripts = "user-scripts"
3021

    
3022
nvVersion :: String
3023
nvVersion = "version"
3024

    
3025
nvVglist :: String
3026
nvVglist = "vglist"
3027

    
3028
nvVmnodes :: String
3029
nvVmnodes = "vmnodes"
3030

    
3031
-- * Instance status
3032

    
3033
inststAdmindown :: String
3034
inststAdmindown = Types.instanceStatusToRaw StatusDown
3035

    
3036
inststAdminoffline :: String
3037
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3038

    
3039
inststErrordown :: String
3040
inststErrordown = Types.instanceStatusToRaw ErrorDown
3041

    
3042
inststErrorup :: String
3043
inststErrorup = Types.instanceStatusToRaw ErrorUp
3044

    
3045
inststNodedown :: String
3046
inststNodedown = Types.instanceStatusToRaw NodeDown
3047

    
3048
inststNodeoffline :: String
3049
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3050

    
3051
inststRunning :: String
3052
inststRunning = Types.instanceStatusToRaw Running
3053

    
3054
inststUserdown :: String
3055
inststUserdown = Types.instanceStatusToRaw UserDown
3056

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

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

    
3063
-- * Admin states
3064

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

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

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

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

    
3077
-- * Node roles
3078

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

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

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

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

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

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

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

    
3099
sslCertExpirationError :: Int
3100
sslCertExpirationError = 7
3101

    
3102
sslCertExpirationWarn :: Int
3103
sslCertExpirationWarn = 30
3104

    
3105
-- * Allocator framework constants
3106

    
3107
iallocatorVersion :: Int
3108
iallocatorVersion = 2
3109

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

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

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

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

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

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

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

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

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

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

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

    
3145
-- * Node evacuation
3146

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

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

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

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

    
3159
-- * Job queue
3160

    
3161
jobQueueVersion :: Int
3162
jobQueueVersion = 1
3163

    
3164
jobQueueSizeHardLimit :: Int
3165
jobQueueSizeHardLimit = 5000
3166

    
3167
jobQueueFilesPerms :: Int
3168
jobQueueFilesPerms = 0o640
3169

    
3170
-- * Unchanged job return
3171

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

    
3175
-- * Job status
3176

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

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

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

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

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

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

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

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

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

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

    
3209
-- * OpCode status
3210

    
3211
-- ** Not yet finalized opcodes
3212

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

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

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

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

    
3225
-- ** Finalized opcodes
3226

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

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

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

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

    
3240
-- * OpCode priority
3241

    
3242
opPrioLowest :: Int
3243
opPrioLowest = 19
3244

    
3245
opPrioHighest :: Int
3246
opPrioHighest = -20
3247

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

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

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

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

    
3260
opPrioDefault :: Int
3261
opPrioDefault = opPrioNormal
3262

    
3263
-- * Lock recalculate mode
3264

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

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

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

    
3278
lockAttemptsMaxwait :: Double
3279
lockAttemptsMaxwait = 15.0
3280

    
3281
lockAttemptsMinwait :: Double
3282
lockAttemptsMinwait = 1.0
3283

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

    
3287
-- * Execution log types
3288

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

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

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

    
3298
-- * /etc/hosts modification
3299

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

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

    
3306
-- * Job queue test
3307

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

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

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

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

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

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

    
3326
-- * Query resources
3327

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

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

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

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

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

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

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

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

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

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

    
3358
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3359
qrViaOp :: FrozenSet String
3360
qrViaOp =
3361
  ConstantUtils.mkSet [qrCluster,
3362
                       qrOs,
3363
                       qrExtstorage]
3364

    
3365
-- | List of resources which can be queried using Local UniX Interface
3366
qrViaLuxi :: FrozenSet String
3367
qrViaLuxi = ConstantUtils.mkSet [qrGroup,
3368
                                 qrExport,
3369
                                 qrInstance,
3370
                                 qrJob,
3371
                                 qrLock,
3372
                                 qrNetwork,
3373
                                 qrNode]
3374

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

    
3379
-- | List of resources which can be queried via RAPI including PUT requests
3380
qrViaRapiPut :: FrozenSet String
3381
qrViaRapiPut = ConstantUtils.mkSet [qrLock, qrJob]
3382

    
3383
-- * Query field types
3384

    
3385
qftBool :: String
3386
qftBool = "bool"
3387

    
3388
qftNumber :: String
3389
qftNumber = "number"
3390

    
3391
qftOther :: String
3392
qftOther = "other"
3393

    
3394
qftText :: String
3395
qftText = "text"
3396

    
3397
qftTimestamp :: String
3398
qftTimestamp = "timestamp"
3399

    
3400
qftUnit :: String
3401
qftUnit = "unit"
3402

    
3403
qftUnknown :: String
3404
qftUnknown = "unknown"
3405

    
3406
qftAll :: FrozenSet String
3407
qftAll =
3408
  ConstantUtils.mkSet [qftBool,
3409
                       qftNumber,
3410
                       qftOther,
3411
                       qftText,
3412
                       qftTimestamp,
3413
                       qftUnit,
3414
                       qftUnknown]
3415

    
3416
-- * Query result field status
3417
--
3418
-- Don't change or reuse values as they're used by clients.
3419
--
3420
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3421

    
3422
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3423
rsNodata :: Int
3424
rsNodata = 2
3425

    
3426
rsNormal :: Int
3427
rsNormal = 0
3428

    
3429
-- | Resource marked offline
3430
rsOffline :: Int
3431
rsOffline = 4
3432

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

    
3439
rsUnknown :: Int
3440
rsUnknown = 1
3441

    
3442
rsAll :: FrozenSet Int
3443
rsAll =
3444
  ConstantUtils.mkSet [rsNodata,
3445
                       rsNormal,
3446
                       rsOffline,
3447
                       rsUnavail,
3448
                       rsUnknown]
3449

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

    
3458
-- * Max dynamic devices
3459

    
3460
maxDisks :: Int
3461
maxDisks = Types.maxDisks
3462

    
3463
maxNics :: Int
3464
maxNics = Types.maxNics
3465

    
3466
-- | SSCONF file prefix
3467
ssconfFileprefix :: String
3468
ssconfFileprefix = "ssconf_"
3469

    
3470
-- * SSCONF keys
3471

    
3472
ssClusterName :: String
3473
ssClusterName = "cluster_name"
3474

    
3475
ssClusterTags :: String
3476
ssClusterTags = "cluster_tags"
3477

    
3478
ssFileStorageDir :: String
3479
ssFileStorageDir = "file_storage_dir"
3480

    
3481
ssSharedFileStorageDir :: String
3482
ssSharedFileStorageDir = "shared_file_storage_dir"
3483

    
3484
ssGlusterStorageDir :: String
3485
ssGlusterStorageDir = "gluster_storage_dir"
3486

    
3487
ssMasterCandidates :: String
3488
ssMasterCandidates = "master_candidates"
3489

    
3490
ssMasterCandidatesIps :: String
3491
ssMasterCandidatesIps = "master_candidates_ips"
3492

    
3493
ssMasterIp :: String
3494
ssMasterIp = "master_ip"
3495

    
3496
ssMasterNetdev :: String
3497
ssMasterNetdev = "master_netdev"
3498

    
3499
ssMasterNetmask :: String
3500
ssMasterNetmask = "master_netmask"
3501

    
3502
ssMasterNode :: String
3503
ssMasterNode = "master_node"
3504

    
3505
ssNodeList :: String
3506
ssNodeList = "node_list"
3507

    
3508
ssNodePrimaryIps :: String
3509
ssNodePrimaryIps = "node_primary_ips"
3510

    
3511
ssNodeSecondaryIps :: String
3512
ssNodeSecondaryIps = "node_secondary_ips"
3513

    
3514
ssOfflineNodes :: String
3515
ssOfflineNodes = "offline_nodes"
3516

    
3517
ssOnlineNodes :: String
3518
ssOnlineNodes = "online_nodes"
3519

    
3520
ssPrimaryIpFamily :: String
3521
ssPrimaryIpFamily = "primary_ip_family"
3522

    
3523
ssInstanceList :: String
3524
ssInstanceList = "instance_list"
3525

    
3526
ssReleaseVersion :: String
3527
ssReleaseVersion = "release_version"
3528

    
3529
ssHypervisorList :: String
3530
ssHypervisorList = "hypervisor_list"
3531

    
3532
ssMaintainNodeHealth :: String
3533
ssMaintainNodeHealth = "maintain_node_health"
3534

    
3535
ssUidPool :: String
3536
ssUidPool = "uid_pool"
3537

    
3538
ssNodegroups :: String
3539
ssNodegroups = "nodegroups"
3540

    
3541
ssNetworks :: String
3542
ssNetworks = "networks"
3543

    
3544
-- | This is not a complete SSCONF key, but the prefix for the
3545
-- hypervisor keys
3546
ssHvparamsPref :: String
3547
ssHvparamsPref = "hvparams_"
3548

    
3549
-- * Hvparams keys
3550

    
3551
ssHvparamsXenChroot :: String
3552
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3553

    
3554
ssHvparamsXenFake :: String
3555
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3556

    
3557
ssHvparamsXenHvm :: String
3558
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3559

    
3560
ssHvparamsXenKvm :: String
3561
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3562

    
3563
ssHvparamsXenLxc :: String
3564
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3565

    
3566
ssHvparamsXenPvm :: String
3567
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3568

    
3569
validSsHvparamsKeys :: FrozenSet String
3570
validSsHvparamsKeys =
3571
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3572
                       ssHvparamsXenLxc,
3573
                       ssHvparamsXenFake,
3574
                       ssHvparamsXenHvm,
3575
                       ssHvparamsXenKvm,
3576
                       ssHvparamsXenPvm]
3577

    
3578
ssFilePerms :: Int
3579
ssFilePerms = 0o444
3580

    
3581
-- | Cluster wide default parameters
3582
defaultEnabledHypervisor :: String
3583
defaultEnabledHypervisor = htXenPvm
3584

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

    
3697
hvcGlobals :: FrozenSet String
3698
hvcGlobals =
3699
  ConstantUtils.mkSet [hvMigrationBandwidth,
3700
                       hvMigrationMode,
3701
                       hvMigrationPort,
3702
                       hvXenCmd]
3703

    
3704
becDefaults :: Map String PyValueEx
3705
becDefaults =
3706
  Map.fromList
3707
  [ (beMinmem, PyValueEx (128 :: Int))
3708
  , (beMaxmem, PyValueEx (128 :: Int))
3709
  , (beVcpus, PyValueEx (1 :: Int))
3710
  , (beAutoBalance, PyValueEx True)
3711
  , (beAlwaysFailover, PyValueEx False)
3712
  , (beSpindleUse, PyValueEx (1 :: Int))
3713
  ]
3714

    
3715
ndcDefaults :: Map String PyValueEx
3716
ndcDefaults =
3717
  Map.fromList
3718
  [ (ndOobProgram,       PyValueEx "")
3719
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3720
  , (ndExclusiveStorage, PyValueEx False)
3721
  , (ndOvs,              PyValueEx False)
3722
  , (ndOvsName,          PyValueEx defaultOvs)
3723
  , (ndOvsLink,          PyValueEx "")
3724
  , (ndSshPort,          PyValueEx (22 :: Int))
3725
  ]
3726

    
3727
ndcGlobals :: FrozenSet String
3728
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3729

    
3730
-- | Default delay target measured in sectors
3731
defaultDelayTarget :: Int
3732
defaultDelayTarget = 1
3733

    
3734
defaultDiskCustom :: String
3735
defaultDiskCustom = ""
3736

    
3737
defaultDiskResync :: Bool
3738
defaultDiskResync = False
3739

    
3740
-- | Default fill target measured in sectors
3741
defaultFillTarget :: Int
3742
defaultFillTarget = 0
3743

    
3744
-- | Default mininum rate measured in KiB/s
3745
defaultMinRate :: Int
3746
defaultMinRate = 4 * 1024
3747

    
3748
defaultNetCustom :: String
3749
defaultNetCustom = ""
3750

    
3751
-- | Default plan ahead measured in sectors
3752
--
3753
-- The default values for the DRBD dynamic resync speed algorithm are
3754
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3755
-- (that we don't need to set to 0, because we have a separate option
3756
-- to enable it) and for c-max-rate, that we cap to the default value
3757
-- for the static resync rate.
3758
defaultPlanAhead :: Int
3759
defaultPlanAhead = 20
3760

    
3761
defaultRbdPool :: String
3762
defaultRbdPool = "rbd"
3763

    
3764
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3765
diskLdDefaults =
3766
  Map.fromList
3767
  [ (DTBlock, Map.empty)
3768
  , (DTDrbd8, Map.fromList
3769
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3770
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3771
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3772
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3773
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3774
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3775
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3776
              , (ldpMinRate,       PyValueEx defaultMinRate)
3777
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3778
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3779
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3780
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3781
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3782
              ])
3783
  , (DTExt, Map.empty)
3784
  , (DTFile, Map.empty)
3785
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3786
  , (DTRbd, Map.fromList
3787
            [ (ldpPool, PyValueEx defaultRbdPool)
3788
            , (ldpAccess, PyValueEx diskKernelspace)
3789
            ])
3790
  , (DTSharedFile, Map.empty)
3791
  , (DTGluster, Map.fromList
3792
                [ (rbdAccess, PyValueEx diskKernelspace)
3793
                , (glusterHost, PyValueEx glusterHostDefault)
3794
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3795
                , (glusterPort, PyValueEx glusterPortDefault)
3796
                ])
3797
  ]
3798

    
3799
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3800
diskDtDefaults =
3801
  Map.fromList
3802
  [ (DTBlock,      Map.empty)
3803
  , (DTDiskless,   Map.empty)
3804
  , (DTDrbd8,      Map.fromList
3805
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3806
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3807
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3808
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3809
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3810
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3811
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3812
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3813
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3814
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3815
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3816
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3817
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3818
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3819
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3820
                   ])
3821
  , (DTExt,        Map.empty)
3822
  , (DTFile,       Map.empty)
3823
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3824
  , (DTRbd,        Map.fromList
3825
                   [ (rbdPool, PyValueEx defaultRbdPool)
3826
                   , (rbdAccess, PyValueEx diskKernelspace)
3827
                   ])
3828
  , (DTSharedFile, Map.empty)
3829
  , (DTGluster, Map.fromList
3830
                [ (rbdAccess, PyValueEx diskKernelspace)
3831
                , (glusterHost, PyValueEx glusterHostDefault)
3832
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3833
                , (glusterPort, PyValueEx glusterPortDefault)
3834
                ])
3835
  ]
3836

    
3837
niccDefaults :: Map String PyValueEx
3838
niccDefaults =
3839
  Map.fromList
3840
  [ (nicMode, PyValueEx nicModeBridged)
3841
  , (nicLink, PyValueEx defaultBridge)
3842
  , (nicVlan, PyValueEx "")
3843
  ]
3844

    
3845
-- | All of the following values are quite arbitrary - there are no
3846
-- "good" defaults, these must be customised per-site
3847
ispecsMinmaxDefaults :: Map String (Map String Int)
3848
ispecsMinmaxDefaults =
3849
  Map.fromList
3850
  [(ispecsMin,
3851
    Map.fromList
3852
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3853
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3854
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3855
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3856
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3857
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3858
   (ispecsMax,
3859
    Map.fromList
3860
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3861
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3862
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3863
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3864
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3865
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3866

    
3867
ipolicyDefaults :: Map String PyValueEx
3868
ipolicyDefaults =
3869
  Map.fromList
3870
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3871
  , (ispecsStd,           PyValueEx (Map.fromList
3872
                                     [ (ispecMemSize,    128)
3873
                                     , (ispecCpuCount,   1)
3874
                                     , (ispecDiskCount,  1)
3875
                                     , (ispecDiskSize,   1024)
3876
                                     , (ispecNicCount,   1)
3877
                                     , (ispecSpindleUse, 1)
3878
                                     ] :: Map String Int))
3879
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3880
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3881
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3882
  ]
3883

    
3884
masterPoolSizeDefault :: Int
3885
masterPoolSizeDefault = 10
3886

    
3887
-- * Exclusive storage
3888

    
3889
-- | Error margin used to compare physical disks
3890
partMargin :: Double
3891
partMargin = 0.01
3892

    
3893
-- | Space reserved when creating instance disks
3894
partReserved :: Double
3895
partReserved = 0.02
3896

    
3897
-- * Luxid job scheduling
3898

    
3899
-- | Time intervall in seconds for polling updates on the job queue. This
3900
-- intervall is only relevant if the number of running jobs reaches the maximal
3901
-- allowed number, as otherwise new jobs will be started immediately anyway.
3902
luxidJobqueuePollInterval :: Int
3903
luxidJobqueuePollInterval = 3
3904

    
3905
-- | Maximal number of jobs to be running at the same time. Once this number is
3906
-- reached, new jobs will just be queued and only started, once some of the
3907
-- other jobs have finished.
3908
luxidMaximalRunningJobs :: Int
3909
luxidMaximalRunningJobs = 20
3910

    
3911
-- * Confd
3912

    
3913
confdProtocolVersion :: Int
3914
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3915

    
3916
-- Confd request type
3917

    
3918
confdReqPing :: Int
3919
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3920

    
3921
confdReqNodeRoleByname :: Int
3922
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3923

    
3924
confdReqNodePipByInstanceIp :: Int
3925
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3926

    
3927
confdReqClusterMaster :: Int
3928
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3929

    
3930
confdReqNodePipList :: Int
3931
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3932

    
3933
confdReqMcPipList :: Int
3934
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3935

    
3936
confdReqInstancesIpsList :: Int
3937
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3938

    
3939
confdReqNodeDrbd :: Int
3940
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3941

    
3942
confdReqNodeInstances :: Int
3943
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3944

    
3945
confdReqs :: FrozenSet Int
3946
confdReqs =
3947
  ConstantUtils.mkSet .
3948
  map Types.confdRequestTypeToRaw $
3949
  [minBound..] \\ [ReqNodeInstances]
3950

    
3951
-- * Confd request type
3952

    
3953
confdReqfieldName :: Int
3954
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3955

    
3956
confdReqfieldIp :: Int
3957
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3958

    
3959
confdReqfieldMnodePip :: Int
3960
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3961

    
3962
-- * Confd repl status
3963

    
3964
confdReplStatusOk :: Int
3965
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3966

    
3967
confdReplStatusError :: Int
3968
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3969

    
3970
confdReplStatusNotimplemented :: Int
3971
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3972

    
3973
confdReplStatuses :: FrozenSet Int
3974
confdReplStatuses =
3975
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3976

    
3977
-- * Confd node role
3978

    
3979
confdNodeRoleMaster :: Int
3980
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3981

    
3982
confdNodeRoleCandidate :: Int
3983
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3984

    
3985
confdNodeRoleOffline :: Int
3986
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3987

    
3988
confdNodeRoleDrained :: Int
3989
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3990

    
3991
confdNodeRoleRegular :: Int
3992
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3993

    
3994
-- * A few common errors for confd
3995

    
3996
confdErrorUnknownEntry :: Int
3997
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3998

    
3999
confdErrorInternal :: Int
4000
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
4001

    
4002
confdErrorArgument :: Int
4003
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
4004

    
4005
-- * Confd request query fields
4006

    
4007
confdReqqLink :: String
4008
confdReqqLink = ConstantUtils.confdReqqLink
4009

    
4010
confdReqqIp :: String
4011
confdReqqIp = ConstantUtils.confdReqqIp
4012

    
4013
confdReqqIplist :: String
4014
confdReqqIplist = ConstantUtils.confdReqqIplist
4015

    
4016
confdReqqFields :: String
4017
confdReqqFields = ConstantUtils.confdReqqFields
4018

    
4019
-- | Each request is "salted" by the current timestamp.
4020
--
4021
-- This constant decides how many seconds of skew to accept.
4022
--
4023
-- TODO: make this a default and allow the value to be more
4024
-- configurable
4025
confdMaxClockSkew :: Int
4026
confdMaxClockSkew = 2 * nodeMaxClockSkew
4027

    
4028
-- | When we haven't reloaded the config for more than this amount of
4029
-- seconds, we force a test to see if inotify is betraying us. Using a
4030
-- prime number to ensure we get less chance of 'same wakeup' with
4031
-- other processes.
4032
confdConfigReloadTimeout :: Int
4033
confdConfigReloadTimeout = 17
4034

    
4035
-- | If we receive more than one update in this amount of
4036
-- microseconds, we move to polling every RATELIMIT seconds, rather
4037
-- than relying on inotify, to be able to serve more requests.
4038
confdConfigReloadRatelimit :: Int
4039
confdConfigReloadRatelimit = 250000
4040

    
4041
-- | Magic number prepended to all confd queries.
4042
--
4043
-- This allows us to distinguish different types of confd protocols
4044
-- and handle them. For example by changing this we can move the whole
4045
-- payload to be compressed, or move away from json.
4046
confdMagicFourcc :: String
4047
confdMagicFourcc = "plj0"
4048

    
4049
-- | By default a confd request is sent to the minimum between this
4050
-- number and all MCs. 6 was chosen because even in the case of a
4051
-- disastrous 50% response rate, we should have enough answers to be
4052
-- able to compare more than one.
4053
confdDefaultReqCoverage :: Int
4054
confdDefaultReqCoverage = 6
4055

    
4056
-- | Timeout in seconds to expire pending query request in the confd
4057
-- client library. We don't actually expect any answer more than 10
4058
-- seconds after we sent a request.
4059
confdClientExpireTimeout :: Int
4060
confdClientExpireTimeout = 10
4061

    
4062
-- | Maximum UDP datagram size.
4063
--
4064
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4065
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4066
--   (assuming we can't use jumbo frames)
4067
-- We just set this to 60K, which should be enough
4068
maxUdpDataSize :: Int
4069
maxUdpDataSize = 61440
4070

    
4071
-- * User-id pool minimum/maximum acceptable user-ids
4072

    
4073
uidpoolUidMin :: Int
4074
uidpoolUidMin = 0
4075

    
4076
-- | Assuming 32 bit user-ids
4077
uidpoolUidMax :: Integer
4078
uidpoolUidMax = 2 ^ 32 - 1
4079

    
4080
-- | Name or path of the pgrep command
4081
pgrep :: String
4082
pgrep = "pgrep"
4083

    
4084
-- | Name of the node group that gets created at cluster init or
4085
-- upgrade
4086
initialNodeGroupName :: String
4087
initialNodeGroupName = "default"
4088

    
4089
-- * Possible values for NodeGroup.alloc_policy
4090

    
4091
allocPolicyLastResort :: String
4092
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4093

    
4094
allocPolicyPreferred :: String
4095
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4096

    
4097
allocPolicyUnallocable :: String
4098
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4099

    
4100
validAllocPolicies :: [String]
4101
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4102

    
4103
-- | Temporary external/shared storage parameters
4104
blockdevDriverManual :: String
4105
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4106

    
4107
-- | 'qemu-img' path, required for 'ovfconverter'
4108
qemuimgPath :: String
4109
qemuimgPath = AutoConf.qemuimgPath
4110

    
4111
-- | Whether htools was enabled at compilation time
4112
--
4113
-- FIXME: this should be moved next to the other enable constants,
4114
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4115
htools :: Bool
4116
htools = AutoConf.htools
4117

    
4118
-- | The hail iallocator
4119
iallocHail :: String
4120
iallocHail = "hail"
4121

    
4122
-- * Fake opcodes for functions that have hooks attached to them via
4123
-- backend.RunLocalHooks
4124

    
4125
fakeOpMasterTurndown :: String
4126
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4127

    
4128
fakeOpMasterTurnup :: String
4129
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4130

    
4131
-- * SSH key types
4132

    
4133
sshkDsa :: String
4134
sshkDsa = "dsa"
4135

    
4136
sshkRsa :: String
4137
sshkRsa = "rsa"
4138

    
4139
sshkAll :: FrozenSet String
4140
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4141

    
4142
-- * SSH authorized key types
4143

    
4144
sshakDss :: String
4145
sshakDss = "ssh-dss"
4146

    
4147
sshakRsa :: String
4148
sshakRsa = "ssh-rsa"
4149

    
4150
sshakAll :: FrozenSet String
4151
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4152

    
4153
-- * SSH setup
4154

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

    
4158
sshsSshHostKey :: String
4159
sshsSshHostKey = "ssh_host_key"
4160

    
4161
sshsSshRootKey :: String
4162
sshsSshRootKey = "ssh_root_key"
4163

    
4164
sshsNodeDaemonCertificate :: String
4165
sshsNodeDaemonCertificate = "node_daemon_certificate"
4166

    
4167
-- * Key files for SSH daemon
4168

    
4169
sshHostDsaPriv :: String
4170
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4171

    
4172
sshHostDsaPub :: String
4173
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4174

    
4175
sshHostRsaPriv :: String
4176
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4177

    
4178
sshHostRsaPub :: String
4179
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4180

    
4181
sshDaemonKeyfiles :: Map String (String, String)
4182
sshDaemonKeyfiles =
4183
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4184
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4185
               ]
4186

    
4187
-- * Node daemon setup
4188

    
4189
ndsClusterName :: String
4190
ndsClusterName = "cluster_name"
4191

    
4192
ndsNodeDaemonCertificate :: String
4193
ndsNodeDaemonCertificate = "node_daemon_certificate"
4194

    
4195
ndsSsconf :: String
4196
ndsSsconf = "ssconf"
4197

    
4198
ndsStartNodeDaemon :: String
4199
ndsStartNodeDaemon = "start_node_daemon"
4200

    
4201
-- * The source reasons for the execution of an OpCode
4202

    
4203
opcodeReasonSrcClient :: String
4204
opcodeReasonSrcClient = "gnt:client"
4205

    
4206
opcodeReasonSrcNoded :: String
4207
opcodeReasonSrcNoded = "gnt:daemon:noded"
4208

    
4209
opcodeReasonSrcOpcode :: String
4210
opcodeReasonSrcOpcode = "gnt:opcode"
4211

    
4212
opcodeReasonSrcRlib2 :: String
4213
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4214

    
4215
opcodeReasonSrcUser :: String
4216
opcodeReasonSrcUser = "gnt:user"
4217

    
4218
opcodeReasonSources :: FrozenSet String
4219
opcodeReasonSources =
4220
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4221
                       opcodeReasonSrcNoded,
4222
                       opcodeReasonSrcOpcode,
4223
                       opcodeReasonSrcRlib2,
4224
                       opcodeReasonSrcUser]
4225

    
4226
-- | Path generating random UUID
4227
randomUuidFile :: String
4228
randomUuidFile = ConstantUtils.randomUuidFile
4229

    
4230
-- * Auto-repair tag prefixes
4231

    
4232
autoRepairTagPrefix :: String
4233
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4234

    
4235
autoRepairTagEnabled :: String
4236
autoRepairTagEnabled = autoRepairTagPrefix
4237

    
4238
autoRepairTagPending :: String
4239
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4240

    
4241
autoRepairTagResult :: String
4242
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4243

    
4244
autoRepairTagSuspended :: String
4245
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4246

    
4247
-- * Auto-repair levels
4248

    
4249
autoRepairFailover :: String
4250
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4251

    
4252
autoRepairFixStorage :: String
4253
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4254

    
4255
autoRepairMigrate :: String
4256
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4257

    
4258
autoRepairReinstall :: String
4259
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4260

    
4261
autoRepairAllTypes :: FrozenSet String
4262
autoRepairAllTypes =
4263
  ConstantUtils.mkSet [autoRepairFailover,
4264
                       autoRepairFixStorage,
4265
                       autoRepairMigrate,
4266
                       autoRepairReinstall]
4267

    
4268
-- * Auto-repair results
4269

    
4270
autoRepairEnoperm :: String
4271
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4272

    
4273
autoRepairFailure :: String
4274
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4275

    
4276
autoRepairSuccess :: String
4277
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4278

    
4279
autoRepairAllResults :: FrozenSet String
4280
autoRepairAllResults =
4281
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4282

    
4283
-- | The version identifier for builtin data collectors
4284
builtinDataCollectorVersion :: String
4285
builtinDataCollectorVersion = "B"
4286

    
4287
-- | The reason trail opcode parameter name
4288
opcodeReason :: String
4289
opcodeReason = "reason"
4290

    
4291
diskstatsFile :: String
4292
diskstatsFile = "/proc/diskstats"
4293

    
4294
-- *  CPU load collector
4295

    
4296
statFile :: String
4297
statFile = "/proc/stat"
4298

    
4299
cpuavgloadBufferSize :: Int
4300
cpuavgloadBufferSize = 150
4301

    
4302
cpuavgloadWindowSize :: Int
4303
cpuavgloadWindowSize = 600
4304

    
4305
-- * Monitoring daemon
4306

    
4307
-- | Mond's variable for periodical data collection
4308
mondTimeInterval :: Int
4309
mondTimeInterval = 5
4310

    
4311
-- | Mond's latest API version
4312
mondLatestApiVersion :: Int
4313
mondLatestApiVersion = 1
4314

    
4315
-- * Disk access modes
4316

    
4317
diskUserspace :: String
4318
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4319

    
4320
diskKernelspace :: String
4321
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4322

    
4323
diskValidAccessModes :: FrozenSet String
4324
diskValidAccessModes =
4325
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4326

    
4327
-- | Timeout for queue draining in upgrades
4328
upgradeQueueDrainTimeout :: Int
4329
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4330

    
4331
-- | Intervall at which the queue is polled during upgrades
4332
upgradeQueuePollInterval :: Int
4333
upgradeQueuePollInterval  = 10
4334

    
4335
-- * Hotplug Actions
4336

    
4337
hotplugActionAdd :: String
4338
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4339

    
4340
hotplugActionRemove :: String
4341
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4342

    
4343
hotplugActionModify :: String
4344
hotplugActionModify = Types.hotplugActionToRaw HAMod
4345

    
4346
hotplugAllActions :: FrozenSet String
4347
hotplugAllActions =
4348
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4349

    
4350
-- * Hotplug Device Targets
4351

    
4352
hotplugTargetNic :: String
4353
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4354

    
4355
hotplugTargetDisk :: String
4356
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4357

    
4358
hotplugAllTargets :: FrozenSet String
4359
hotplugAllTargets =
4360
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4361

    
4362
-- | Timeout for disk removal (seconds)
4363
diskRemoveRetryTimeout :: Int
4364
diskRemoveRetryTimeout = 30
4365

    
4366
-- | Interval between disk removal retries (seconds)
4367
diskRemoveRetryInterval :: Int
4368
diskRemoveRetryInterval  = 3
4369

    
4370
-- * UUID regex
4371

    
4372
uuidRegex :: String
4373
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4374

    
4375
-- * Luxi constants
4376

    
4377
luxiKeyMethod :: String
4378
luxiKeyMethod = "method"
4379

    
4380
luxiKeyArgs :: String
4381
luxiKeyArgs = "args"
4382

    
4383
luxiKeySuccess :: String
4384
luxiKeySuccess = "success"
4385

    
4386
luxiKeyResult :: String
4387
luxiKeyResult = "result"
4388

    
4389
luxiKeyVersion :: String
4390
luxiKeyVersion = "version"
4391

    
4392
luxiReqSubmitJob :: String
4393
luxiReqSubmitJob = "SubmitJob"
4394

    
4395
luxiReqSubmitJobToDrainedQueue :: String
4396
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4397

    
4398
luxiReqSubmitManyJobs :: String
4399
luxiReqSubmitManyJobs = "SubmitManyJobs"
4400

    
4401
luxiReqWaitForJobChange :: String
4402
luxiReqWaitForJobChange = "WaitForJobChange"
4403

    
4404
luxiReqPickupJob :: String
4405
luxiReqPickupJob = "PickupJob"
4406

    
4407
luxiReqCancelJob :: String
4408
luxiReqCancelJob = "CancelJob"
4409

    
4410
luxiReqArchiveJob :: String
4411
luxiReqArchiveJob = "ArchiveJob"
4412

    
4413
luxiReqChangeJobPriority :: String
4414
luxiReqChangeJobPriority = "ChangeJobPriority"
4415

    
4416
luxiReqAutoArchiveJobs :: String
4417
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4418

    
4419
luxiReqQuery :: String
4420
luxiReqQuery = "Query"
4421

    
4422
luxiReqQueryFields :: String
4423
luxiReqQueryFields = "QueryFields"
4424

    
4425
luxiReqQueryJobs :: String
4426
luxiReqQueryJobs = "QueryJobs"
4427

    
4428
luxiReqQueryInstances :: String
4429
luxiReqQueryInstances = "QueryInstances"
4430

    
4431
luxiReqQueryNodes :: String
4432
luxiReqQueryNodes = "QueryNodes"
4433

    
4434
luxiReqQueryGroups :: String
4435
luxiReqQueryGroups = "QueryGroups"
4436

    
4437
luxiReqQueryNetworks :: String
4438
luxiReqQueryNetworks = "QueryNetworks"
4439

    
4440
luxiReqQueryExports :: String
4441
luxiReqQueryExports = "QueryExports"
4442

    
4443
luxiReqQueryConfigValues :: String
4444
luxiReqQueryConfigValues = "QueryConfigValues"
4445

    
4446
luxiReqQueryClusterInfo :: String
4447
luxiReqQueryClusterInfo = "QueryClusterInfo"
4448

    
4449
luxiReqQueryTags :: String
4450
luxiReqQueryTags = "QueryTags"
4451

    
4452
luxiReqSetDrainFlag :: String
4453
luxiReqSetDrainFlag = "SetDrainFlag"
4454

    
4455
luxiReqSetWatcherPause :: String
4456
luxiReqSetWatcherPause = "SetWatcherPause"
4457

    
4458
luxiReqAll :: FrozenSet String
4459
luxiReqAll =
4460
  ConstantUtils.mkSet
4461
  [ luxiReqArchiveJob
4462
  , luxiReqAutoArchiveJobs
4463
  , luxiReqCancelJob
4464
  , luxiReqChangeJobPriority
4465
  , luxiReqQuery
4466
  , luxiReqQueryClusterInfo
4467
  , luxiReqQueryConfigValues
4468
  , luxiReqQueryExports
4469
  , luxiReqQueryFields
4470
  , luxiReqQueryGroups
4471
  , luxiReqQueryInstances
4472
  , luxiReqQueryJobs
4473
  , luxiReqQueryNodes
4474
  , luxiReqQueryNetworks
4475
  , luxiReqQueryTags
4476
  , luxiReqSetDrainFlag
4477
  , luxiReqSetWatcherPause
4478
  , luxiReqSubmitJob
4479
  , luxiReqSubmitJobToDrainedQueue
4480
  , luxiReqSubmitManyJobs
4481
  , luxiReqWaitForJobChange
4482
  , luxiReqPickupJob
4483
  ]
4484

    
4485
luxiDefCtmo :: Int
4486
luxiDefCtmo = 10
4487

    
4488
luxiDefRwto :: Int
4489
luxiDefRwto = 60
4490

    
4491
-- | 'WaitForJobChange' timeout
4492
luxiWfjcTimeout :: Int
4493
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4494

    
4495
-- * Query language constants
4496

    
4497
-- ** Logic operators with one or more operands, each of which is a
4498
-- filter on its own
4499

    
4500
qlangOpAnd :: String
4501
qlangOpAnd = "&"
4502

    
4503
qlangOpOr :: String
4504
qlangOpOr = "|"
4505

    
4506
-- ** Unary operators with exactly one operand
4507

    
4508
qlangOpNot :: String
4509
qlangOpNot = "!"
4510

    
4511
qlangOpTrue :: String
4512
qlangOpTrue = "?"
4513

    
4514
-- ** Binary operators with exactly two operands, the field name and
4515
-- an operator-specific value
4516

    
4517
qlangOpContains :: String
4518
qlangOpContains = "=[]"
4519

    
4520
qlangOpEqual :: String
4521
qlangOpEqual = "="
4522

    
4523
qlangOpGe :: String
4524
qlangOpGe = ">="
4525

    
4526
qlangOpGt :: String
4527
qlangOpGt = ">"
4528

    
4529
qlangOpLe :: String
4530
qlangOpLe = "<="
4531

    
4532
qlangOpLt :: String
4533
qlangOpLt = "<"
4534

    
4535
qlangOpNotEqual :: String
4536
qlangOpNotEqual = "!="
4537

    
4538
qlangOpRegexp :: String
4539
qlangOpRegexp = "=~"
4540

    
4541
-- | Characters used for detecting user-written filters (see
4542
-- L{_CheckFilter})
4543

    
4544
qlangFilterDetectionChars :: FrozenSet String
4545
qlangFilterDetectionChars =
4546
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4547
                       ")", "(", "\x0b", "\n",
4548
                       "\r", "\x0c", "/", "<",
4549
                       "\t", ">", "=", "\\", "~"]
4550

    
4551
-- | Characters used to detect globbing filters
4552
qlangGlobDetectionChars :: FrozenSet String
4553
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4554

    
4555
-- * Error related constants
4556
--
4557
-- 'OpPrereqError' failure types
4558

    
4559
-- | Environment error (e.g. node disk error)
4560
errorsEcodeEnviron :: String
4561
errorsEcodeEnviron = "environment_error"
4562

    
4563
-- | Entity already exists
4564
errorsEcodeExists :: String
4565
errorsEcodeExists = "already_exists"
4566

    
4567
-- | Internal cluster error
4568
errorsEcodeFault :: String
4569
errorsEcodeFault = "internal_error"
4570

    
4571
-- | Wrong arguments (at syntax level)
4572
errorsEcodeInval :: String
4573
errorsEcodeInval = "wrong_input"
4574

    
4575
-- | Entity not found
4576
errorsEcodeNoent :: String
4577
errorsEcodeNoent = "unknown_entity"
4578

    
4579
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4580
errorsEcodeNores :: String
4581
errorsEcodeNores = "insufficient_resources"
4582

    
4583
-- | Resource not unique (e.g. MAC or IP duplication)
4584
errorsEcodeNotunique :: String
4585
errorsEcodeNotunique = "resource_not_unique"
4586

    
4587
-- | Resolver errors
4588
errorsEcodeResolver :: String
4589
errorsEcodeResolver = "resolver_error"
4590

    
4591
-- | Wrong entity state
4592
errorsEcodeState :: String
4593
errorsEcodeState = "wrong_state"
4594

    
4595
-- | Temporarily out of resources; operation can be tried again
4596
errorsEcodeTempNores :: String
4597
errorsEcodeTempNores = "temp_insufficient_resources"
4598

    
4599
errorsEcodeAll :: FrozenSet String
4600
errorsEcodeAll =
4601
  ConstantUtils.mkSet [ errorsEcodeNores
4602
                      , errorsEcodeExists
4603
                      , errorsEcodeState
4604
                      , errorsEcodeNotunique
4605
                      , errorsEcodeTempNores
4606
                      , errorsEcodeNoent
4607
                      , errorsEcodeFault
4608
                      , errorsEcodeResolver
4609
                      , errorsEcodeInval
4610
                      , errorsEcodeEnviron
4611
                      ]
4612

    
4613
-- * Jstore related constants
4614

    
4615
jstoreJobsPerArchiveDirectory :: Int
4616
jstoreJobsPerArchiveDirectory = 10000
4617

    
4618
-- * Gluster settings
4619

    
4620
-- | Name of the Gluster host setting
4621
glusterHost :: String
4622
glusterHost = "host"
4623

    
4624
-- | Default value of the Gluster host setting
4625
glusterHostDefault :: String
4626
glusterHostDefault = "127.0.0.1"
4627

    
4628
-- | Name of the Gluster volume setting
4629
glusterVolume :: String
4630
glusterVolume = "volume"
4631

    
4632
-- | Default value of the Gluster volume setting
4633
glusterVolumeDefault :: String
4634
glusterVolumeDefault = "gv0"
4635

    
4636
-- | Name of the Gluster port setting
4637
glusterPort :: String
4638
glusterPort = "port"
4639

    
4640
-- | Default value of the Gluster port setting
4641
glusterPortDefault :: Int
4642
glusterPortDefault = 24007