Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 7d81bb8b

History | View | Annotate | Download (114.9 kB)

1
{-# OPTIONS -fno-warn-type-defaults #-}
2
{-| Constants contains the Haskell constants
3

    
4
The constants in this module are used in Haskell and are also
5
converted to Python.
6

    
7
Do not write any definitions in this file other than constants.  Do
8
not even write helper functions.  The definitions in this module are
9
automatically stripped to build the Makefile.am target
10
'ListConstants.hs'.  If there are helper functions in this module,
11
they will also be dragged and it will cause compilation to fail.
12
Therefore, all helper functions should go to a separate module and
13
imported.
14

    
15
-}
16

    
17
{-
18

    
19
Copyright (C) 2013 Google Inc.
20

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

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

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

    
36
-}
37
module Ganeti.Constants where
38

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

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

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

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

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

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

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

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

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

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

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

    
86
-- ** Build-time constants
87

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
135
-- * Various versions
136

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

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

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

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

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

    
152
osApiV10 :: Int
153
osApiV10 = 10
154

    
155
osApiV15 :: Int
156
osApiV15 = 15
157

    
158
osApiV20 :: Int
159
osApiV20 = 20
160

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

    
164
exportVersion :: Int
165
exportVersion = 0
166

    
167
rapiVersion :: Int
168
rapiVersion = 2
169

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

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

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

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

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

    
189
-- * User separation
190

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

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

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

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

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

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

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

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

    
215
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
enableSplitQuery :: Bool
317
enableSplitQuery = AutoConf.enableSplitQuery
318

    
319
-- * SSH constants
320

    
321
ssh :: String
322
ssh = "ssh"
323

    
324
scp :: String
325
scp = "scp"
326

    
327
-- * Daemons
328

    
329
confd :: String
330
confd = Runtime.daemonName GanetiConfd
331

    
332
masterd :: String
333
masterd = Runtime.daemonName GanetiMasterd
334

    
335
mond :: String
336
mond = Runtime.daemonName GanetiMond
337

    
338
noded :: String
339
noded = Runtime.daemonName GanetiNoded
340

    
341
luxid :: String
342
luxid = Runtime.daemonName GanetiLuxid
343

    
344
rapi :: String
345
rapi = Runtime.daemonName GanetiRapi
346

    
347
daemons :: FrozenSet String
348
daemons =
349
  ConstantUtils.mkSet [confd,
350
                       luxid,
351
                       masterd,
352
                       mond,
353
                       noded,
354
                       rapi]
355

    
356
defaultConfdPort :: Int
357
defaultConfdPort = 1814
358

    
359
defaultMondPort :: Int
360
defaultMondPort = 1815
361

    
362
defaultNodedPort :: Int
363
defaultNodedPort = 1811
364

    
365
defaultRapiPort :: Int
366
defaultRapiPort = 5080
367

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

    
376
firstDrbdPort :: Int
377
firstDrbdPort = 11000
378

    
379
lastDrbdPort :: Int
380
lastDrbdPort = 14999
381

    
382
daemonsLogbase :: Map String String
383
daemonsLogbase =
384
  Map.fromList
385
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
386

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

    
397
extraLogreasonAccess :: String
398
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
399

    
400
extraLogreasonError :: String
401
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
402

    
403
devConsole :: String
404
devConsole = ConstantUtils.devConsole
405

    
406
procMounts :: String
407
procMounts = "/proc/mounts"
408

    
409
-- * Luxi (Local UniX Interface) related constants
410

    
411
luxiEom :: PythonChar
412
luxiEom = PythonChar '\x03'
413

    
414
-- | Environment variable for the luxi override socket
415
luxiOverride :: String
416
luxiOverride = "FORCE_LUXI_SOCKET"
417

    
418
luxiOverrideMaster :: String
419
luxiOverrideMaster = "master"
420

    
421
luxiOverrideQuery :: String
422
luxiOverrideQuery = "query"
423

    
424
luxiVersion :: Int
425
luxiVersion = configVersion
426

    
427
-- * Syslog
428

    
429
syslogUsage :: String
430
syslogUsage = AutoConf.syslogUsage
431

    
432
syslogNo :: String
433
syslogNo = Logging.syslogUsageToRaw SyslogNo
434

    
435
syslogYes :: String
436
syslogYes = Logging.syslogUsageToRaw SyslogYes
437

    
438
syslogOnly :: String
439
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
440

    
441
syslogSocket :: String
442
syslogSocket = "/dev/log"
443

    
444
exportConfFile :: String
445
exportConfFile = "config.ini"
446

    
447
-- * Xen
448

    
449
xenBootloader :: String
450
xenBootloader = AutoConf.xenBootloader
451

    
452
xenCmdXl :: String
453
xenCmdXl = "xl"
454

    
455
xenCmdXm :: String
456
xenCmdXm = "xm"
457

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

    
461
xenKernel :: String
462
xenKernel = AutoConf.xenKernel
463

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

    
469
-- * KVM and socat
470

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

    
474
kvmKernel :: String
475
kvmKernel = AutoConf.kvmKernel
476

    
477
socatEscapeCode :: String
478
socatEscapeCode = "0x1d"
479

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

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

    
486
socatUseEscape :: Bool
487
socatUseEscape = AutoConf.socatUseEscape
488

    
489
-- * Console types
490

    
491
-- | Display a message for console access
492
consMessage :: String
493
consMessage = "msg"
494

    
495
-- | Console as SPICE server
496
consSpice :: String
497
consSpice = "spice"
498

    
499
-- | Console as SSH command
500
consSsh :: String
501
consSsh = "ssh"
502

    
503
-- | Console as VNC server
504
consVnc :: String
505
consVnc = "vnc"
506

    
507
consAll :: FrozenSet String
508
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
509

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

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

    
529
-- * X509
530

    
531
-- | commonName (CN) used in certificates
532
x509CertCn :: String
533
x509CertCn = "ganeti.example.com"
534

    
535
-- | Default validity of certificates in days
536
x509CertDefaultValidity :: Int
537
x509CertDefaultValidity = 365 * 5
538

    
539
x509CertSignatureHeader :: String
540
x509CertSignatureHeader = "X-Ganeti-Signature"
541

    
542
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
543
x509CertSignDigest :: String
544
x509CertSignDigest = "SHA1"
545

    
546
-- * Import/export daemon mode
547

    
548
iemExport :: String
549
iemExport = "export"
550

    
551
iemImport :: String
552
iemImport = "import"
553

    
554
-- * Import/export transport compression
555

    
556
iecGzip :: String
557
iecGzip = "gzip"
558

    
559
iecNone :: String
560
iecNone = "none"
561

    
562
iecAll :: [String]
563
iecAll = [iecGzip, iecNone]
564

    
565
ieCustomSize :: String
566
ieCustomSize = "fd"
567

    
568
-- * Import/export I/O
569

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

    
575
-- | Raw block device I/O using "dd"
576
ieioRawDisk :: String
577
ieioRawDisk = "raw"
578

    
579
-- | OS definition import/export script
580
ieioScript :: String
581
ieioScript = "script"
582

    
583
-- * Values
584

    
585
valueDefault :: String
586
valueDefault = "default"
587

    
588
valueAuto :: String
589
valueAuto = "auto"
590

    
591
valueGenerate :: String
592
valueGenerate = "generate"
593

    
594
valueNone :: String
595
valueNone = "none"
596

    
597
valueTrue :: String
598
valueTrue = "true"
599

    
600
valueFalse :: String
601
valueFalse = "false"
602

    
603
-- * Hooks
604

    
605
hooksNameCfgupdate :: String
606
hooksNameCfgupdate = "config-update"
607

    
608
hooksNameWatcher :: String
609
hooksNameWatcher = "watcher"
610

    
611
hooksPath :: String
612
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
613

    
614
hooksPhasePost :: String
615
hooksPhasePost = "post"
616

    
617
hooksPhasePre :: String
618
hooksPhasePre = "pre"
619

    
620
hooksVersion :: Int
621
hooksVersion = 2
622

    
623
-- * Hooks subject type (what object type does the LU deal with)
624

    
625
htypeCluster :: String
626
htypeCluster = "CLUSTER"
627

    
628
htypeGroup :: String
629
htypeGroup = "GROUP"
630

    
631
htypeInstance :: String
632
htypeInstance = "INSTANCE"
633

    
634
htypeNetwork :: String
635
htypeNetwork = "NETWORK"
636

    
637
htypeNode :: String
638
htypeNode = "NODE"
639

    
640
-- * Hkr
641

    
642
hkrSkip :: Int
643
hkrSkip = 0
644

    
645
hkrFail :: Int
646
hkrFail = 1
647

    
648
hkrSuccess :: Int
649
hkrSuccess = 2
650

    
651
-- * Storage types
652

    
653
stBlock :: String
654
stBlock = Types.storageTypeToRaw StorageBlock
655

    
656
stDiskless :: String
657
stDiskless = Types.storageTypeToRaw StorageDiskless
658

    
659
stExt :: String
660
stExt = Types.storageTypeToRaw StorageExt
661

    
662
stFile :: String
663
stFile = Types.storageTypeToRaw StorageFile
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 storage reporting is available
678
--
679
-- FIXME: Remove this, once storage reporting is available for all
680
-- types.
681
stsReport :: FrozenSet String
682
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
683

    
684
-- * Storage fields
685
-- ** First two are valid in LU context only, not passed to backend
686

    
687
sfNode :: String
688
sfNode = "node"
689

    
690
sfType :: String
691
sfType = "type"
692

    
693
-- ** and the rest are valid in backend
694

    
695
sfAllocatable :: String
696
sfAllocatable = Types.storageFieldToRaw SFAllocatable
697

    
698
sfFree :: String
699
sfFree = Types.storageFieldToRaw SFFree
700

    
701
sfName :: String
702
sfName = Types.storageFieldToRaw SFName
703

    
704
sfSize :: String
705
sfSize = Types.storageFieldToRaw SFSize
706

    
707
sfUsed :: String
708
sfUsed = Types.storageFieldToRaw SFUsed
709

    
710
validStorageFields :: FrozenSet String
711
validStorageFields =
712
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
713
                        [sfNode, sfType]
714

    
715
modifiableStorageFields :: Map String (FrozenSet String)
716
modifiableStorageFields =
717
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
718
                 ConstantUtils.mkSet [sfAllocatable])]
719

    
720
-- * Storage operations
721

    
722
soFixConsistency :: String
723
soFixConsistency = "fix-consistency"
724

    
725
validStorageOperations :: Map String (FrozenSet String)
726
validStorageOperations =
727
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
728
                 ConstantUtils.mkSet [soFixConsistency])]
729

    
730
-- * Volume fields
731

    
732
vfDev :: String
733
vfDev = "dev"
734

    
735
vfInstance :: String
736
vfInstance = "instance"
737

    
738
vfName :: String
739
vfName = "name"
740

    
741
vfNode :: String
742
vfNode = "node"
743

    
744
vfPhys :: String
745
vfPhys = "phys"
746

    
747
vfSize :: String
748
vfSize = "size"
749

    
750
vfVg :: String
751
vfVg = "vg"
752

    
753
-- * Local disk status
754

    
755
ldsFaulty :: Int
756
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
757

    
758
ldsOkay :: Int
759
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
760

    
761
ldsUnknown :: Int
762
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
763

    
764
ldsNames :: Map Int String
765
ldsNames =
766
  Map.fromList [ (Types.localDiskStatusToRaw ds,
767
                  localDiskStatusName ds) | ds <- [minBound..] ]
768

    
769
-- * Disk template types
770

    
771
dtDiskless :: String
772
dtDiskless = Types.diskTemplateToRaw DTDiskless
773

    
774
dtFile :: String
775
dtFile = Types.diskTemplateToRaw DTFile
776

    
777
dtSharedFile :: String
778
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
779

    
780
dtPlain :: String
781
dtPlain = Types.diskTemplateToRaw DTPlain
782

    
783
dtBlock :: String
784
dtBlock = Types.diskTemplateToRaw DTBlock
785

    
786
dtDrbd8 :: String
787
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
788

    
789
dtRbd :: String
790
dtRbd = Types.diskTemplateToRaw DTRbd
791

    
792
dtExt :: String
793
dtExt = Types.diskTemplateToRaw DTExt
794

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

    
805
diskTemplates :: FrozenSet String
806
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
807

    
808
-- | Disk templates that are enabled by default
809
defaultEnabledDiskTemplates :: [String]
810
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
811

    
812
-- | Mapping of disk templates to storage types
813
mapDiskTemplateStorageType :: Map String String
814
mapDiskTemplateStorageType =
815
  Map.fromList $
816
  map (Types.diskTemplateToRaw *** Types.storageTypeToRaw)
817
  [(DTBlock, StorageBlock),
818
   (DTDrbd8, StorageLvmVg),
819
   (DTExt, StorageExt),
820
   (DTSharedFile, StorageFile),
821
   (DTFile, StorageFile),
822
   (DTDiskless, StorageDiskless),
823
   (DTPlain, StorageLvmVg),
824
   (DTRbd, StorageRados)]
825

    
826
-- | The set of network-mirrored disk templates
827
dtsIntMirror :: FrozenSet String
828
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
829

    
830
-- | 'DTDiskless' is 'trivially' externally mirrored
831
dtsExtMirror :: FrozenSet String
832
dtsExtMirror =
833
  ConstantUtils.mkSet $
834
  map Types.diskTemplateToRaw [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd]
835

    
836
-- | The set of non-lvm-based disk templates
837
dtsNotLvm :: FrozenSet String
838
dtsNotLvm =
839
  ConstantUtils.mkSet $
840
  map Types.diskTemplateToRaw
841
  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd]
842

    
843
-- | The set of disk templates which can be grown
844
dtsGrowable :: FrozenSet String
845
dtsGrowable =
846
  ConstantUtils.mkSet $
847
  map Types.diskTemplateToRaw
848
  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd]
849

    
850
-- | The set of disk templates that allow adoption
851
dtsMayAdopt :: FrozenSet String
852
dtsMayAdopt =
853
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
854

    
855
-- | The set of disk templates that *must* use adoption
856
dtsMustAdopt :: FrozenSet String
857
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
858

    
859
-- | The set of disk templates that allow migrations
860
dtsMirrored :: FrozenSet String
861
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
862

    
863
-- | The set of file based disk templates
864
dtsFilebased :: FrozenSet String
865
dtsFilebased =
866
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTSharedFile, DTFile]
867

    
868
-- | The set of disk templates that can be moved by copying
869
--
870
-- Note: a requirement is that they're not accessed externally or
871
-- shared between nodes; in particular, sharedfile is not suitable.
872
dtsCopyable :: FrozenSet String
873
dtsCopyable =
874
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
875

    
876
-- | The set of disk templates that are supported by exclusive_storage
877
dtsExclStorage :: FrozenSet String
878
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
879

    
880
-- | Templates for which we don't perform checks on free space
881
dtsNoFreeSpaceCheck :: FrozenSet String
882
dtsNoFreeSpaceCheck =
883
  ConstantUtils.mkSet $
884
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd]
885

    
886
dtsBlock :: FrozenSet String
887
dtsBlock =
888
  ConstantUtils.mkSet $
889
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
890

    
891
-- | The set of lvm-based disk templates
892
dtsLvm :: FrozenSet String
893
dtsLvm = diskTemplates `ConstantUtils.difference` dtsNotLvm
894

    
895
-- | The set of lvm-based disk templates
896
dtsHaveAccess :: FrozenSet String
897
dtsHaveAccess = ConstantUtils.mkSet $
898
  map Types.diskTemplateToRaw [DTRbd, DTExt]
899

    
900
-- * Drbd
901

    
902
drbdHmacAlg :: String
903
drbdHmacAlg = "md5"
904

    
905
drbdDefaultNetProtocol :: String
906
drbdDefaultNetProtocol = "C"
907

    
908
drbdMigrationNetProtocol :: String
909
drbdMigrationNetProtocol = "C"
910

    
911
drbdStatusFile :: String
912
drbdStatusFile = "/proc/drbd"
913

    
914
-- | Size of DRBD meta block device
915
drbdMetaSize :: Int
916
drbdMetaSize = 128
917

    
918
-- * Drbd barrier types
919

    
920
drbdBDiskBarriers :: String
921
drbdBDiskBarriers = "b"
922

    
923
drbdBDiskDrain :: String
924
drbdBDiskDrain = "d"
925

    
926
drbdBDiskFlush :: String
927
drbdBDiskFlush = "f"
928

    
929
drbdBNone :: String
930
drbdBNone = "n"
931

    
932
-- | Valid barrier combinations: "n" or any non-null subset of "bfd"
933
drbdValidBarrierOpt :: FrozenSet (FrozenSet String)
934
drbdValidBarrierOpt =
935
  ConstantUtils.mkSet
936
  [ ConstantUtils.mkSet [drbdBNone]
937
  , ConstantUtils.mkSet [drbdBDiskBarriers]
938
  , ConstantUtils.mkSet [drbdBDiskDrain]
939
  , ConstantUtils.mkSet [drbdBDiskFlush]
940
  , ConstantUtils.mkSet [drbdBDiskDrain, drbdBDiskFlush]
941
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskDrain]
942
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush]
943
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush, drbdBDiskDrain]
944
  ]
945

    
946
-- | Rbd tool command
947
rbdCmd :: String
948
rbdCmd = "rbd"
949

    
950
-- * File backend driver
951

    
952
fdBlktap :: String
953
fdBlktap = Types.fileDriverToRaw FileBlktap
954

    
955
fdBlktap2 :: String
956
fdBlktap2 = Types.fileDriverToRaw FileBlktap2
957

    
958
fdLoop :: String
959
fdLoop = Types.fileDriverToRaw FileLoop
960

    
961
fdDefault :: String
962
fdDefault = fdLoop
963

    
964
fileDriver :: FrozenSet String
965
fileDriver =
966
  ConstantUtils.mkSet $
967
  map Types.fileDriverToRaw [minBound..]
968

    
969
-- | The set of drbd-like disk types
970
dtsDrbd :: FrozenSet String
971
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
972

    
973
-- * Disk access mode
974

    
975
diskRdonly :: String
976
diskRdonly = Types.diskModeToRaw DiskRdOnly
977

    
978
diskRdwr :: String
979
diskRdwr = Types.diskModeToRaw DiskRdWr
980

    
981
diskAccessSet :: FrozenSet String
982
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
983

    
984
-- * Disk replacement mode
985

    
986
replaceDiskAuto :: String
987
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
988

    
989
replaceDiskChg :: String
990
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
991

    
992
replaceDiskPri :: String
993
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
994

    
995
replaceDiskSec :: String
996
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
997

    
998
replaceModes :: FrozenSet String
999
replaceModes =
1000
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
1001

    
1002
-- * Instance export mode
1003

    
1004
exportModeLocal :: String
1005
exportModeLocal = Types.exportModeToRaw ExportModeLocal
1006

    
1007
exportModeRemote :: String
1008
exportModeRemote = Types.exportModeToRaw ExportModeRemote
1009

    
1010
exportModes :: FrozenSet String
1011
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
1012

    
1013
-- * Instance creation modes
1014

    
1015
instanceCreate :: String
1016
instanceCreate = Types.instCreateModeToRaw InstCreate
1017

    
1018
instanceImport :: String
1019
instanceImport = Types.instCreateModeToRaw InstImport
1020

    
1021
instanceRemoteImport :: String
1022
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1023

    
1024
instanceCreateModes :: FrozenSet String
1025
instanceCreateModes =
1026
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1027

    
1028
-- * Remote import/export handshake message and version
1029

    
1030
rieHandshake :: String
1031
rieHandshake = "Hi, I'm Ganeti"
1032

    
1033
rieVersion :: Int
1034
rieVersion = 0
1035

    
1036
-- | Remote import/export certificate validity (seconds)
1037
rieCertValidity :: Int
1038
rieCertValidity = 24 * 60 * 60
1039

    
1040
-- | Export only: how long to wait per connection attempt (seconds)
1041
rieConnectAttemptTimeout :: Int
1042
rieConnectAttemptTimeout = 20
1043

    
1044
-- | Export only: number of attempts to connect
1045
rieConnectRetries :: Int
1046
rieConnectRetries = 10
1047

    
1048
-- | Overall timeout for establishing connection
1049
rieConnectTimeout :: Int
1050
rieConnectTimeout = 180
1051

    
1052
-- | Give child process up to 5 seconds to exit after sending a signal
1053
childLingerTimeout :: Double
1054
childLingerTimeout = 5.0
1055

    
1056
-- * Import/export config options
1057

    
1058
inisectBep :: String
1059
inisectBep = "backend"
1060

    
1061
inisectExp :: String
1062
inisectExp = "export"
1063

    
1064
inisectHyp :: String
1065
inisectHyp = "hypervisor"
1066

    
1067
inisectIns :: String
1068
inisectIns = "instance"
1069

    
1070
inisectOsp :: String
1071
inisectOsp = "os"
1072

    
1073
-- * Dynamic device modification
1074

    
1075
ddmAdd :: String
1076
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1077

    
1078
ddmModify :: String
1079
ddmModify = Types.ddmFullToRaw DdmFullModify
1080

    
1081
ddmRemove :: String
1082
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1083

    
1084
ddmsValues :: FrozenSet String
1085
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1086

    
1087
ddmsValuesWithModify :: FrozenSet String
1088
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1089

    
1090
-- * Common exit codes
1091

    
1092
exitSuccess :: Int
1093
exitSuccess = 0
1094

    
1095
exitFailure :: Int
1096
exitFailure = ConstantUtils.exitFailure
1097

    
1098
exitNotcluster :: Int
1099
exitNotcluster = 5
1100

    
1101
exitNotmaster :: Int
1102
exitNotmaster = 11
1103

    
1104
exitNodesetupError :: Int
1105
exitNodesetupError = 12
1106

    
1107
-- | Need user confirmation
1108
exitConfirmation :: Int
1109
exitConfirmation = 13
1110

    
1111
-- | Exit code for query operations with unknown fields
1112
exitUnknownField :: Int
1113
exitUnknownField = 14
1114

    
1115
-- * Tags
1116

    
1117
tagCluster :: String
1118
tagCluster = Types.tagKindToRaw TagKindCluster
1119

    
1120
tagInstance :: String
1121
tagInstance = Types.tagKindToRaw TagKindInstance
1122

    
1123
tagNetwork :: String
1124
tagNetwork = Types.tagKindToRaw TagKindNetwork
1125

    
1126
tagNode :: String
1127
tagNode = Types.tagKindToRaw TagKindNode
1128

    
1129
tagNodegroup :: String
1130
tagNodegroup = Types.tagKindToRaw TagKindGroup
1131

    
1132
validTagTypes :: FrozenSet String
1133
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1134

    
1135
maxTagLen :: Int
1136
maxTagLen = 128
1137

    
1138
maxTagsPerObj :: Int
1139
maxTagsPerObj = 4096
1140

    
1141
-- * Others
1142

    
1143
defaultBridge :: String
1144
defaultBridge = "xen-br0"
1145

    
1146
defaultOvs :: String
1147
defaultOvs = "switch1"
1148

    
1149
-- | 60 MiB/s, expressed in KiB/s
1150
classicDrbdSyncSpeed :: Int
1151
classicDrbdSyncSpeed = 60 * 1024
1152

    
1153
ip4AddressAny :: String
1154
ip4AddressAny = "0.0.0.0"
1155

    
1156
ip4AddressLocalhost :: String
1157
ip4AddressLocalhost = "127.0.0.1"
1158

    
1159
ip6AddressAny :: String
1160
ip6AddressAny = "::"
1161

    
1162
ip6AddressLocalhost :: String
1163
ip6AddressLocalhost = "::1"
1164

    
1165
ip4Version :: Int
1166
ip4Version = 4
1167

    
1168
ip6Version :: Int
1169
ip6Version = 6
1170

    
1171
validIpVersions :: FrozenSet Int
1172
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1173

    
1174
tcpPingTimeout :: Int
1175
tcpPingTimeout = 10
1176

    
1177
defaultVg :: String
1178
defaultVg = "xenvg"
1179

    
1180
defaultDrbdHelper :: String
1181
defaultDrbdHelper = "/bin/true"
1182

    
1183
minVgSize :: Int
1184
minVgSize = 20480
1185

    
1186
defaultMacPrefix :: String
1187
defaultMacPrefix = "aa:00:00"
1188

    
1189
-- | Default maximum instance wait time (seconds)
1190
defaultShutdownTimeout :: Int
1191
defaultShutdownTimeout = 120
1192

    
1193
-- | Node clock skew (seconds)
1194
nodeMaxClockSkew :: Int
1195
nodeMaxClockSkew = 150
1196

    
1197
-- | Time for an intra-cluster disk transfer to wait for a connection
1198
diskTransferConnectTimeout :: Int
1199
diskTransferConnectTimeout = 60
1200

    
1201
-- | Disk index separator
1202
diskSeparator :: String
1203
diskSeparator = AutoConf.diskSeparator
1204

    
1205
ipCommandPath :: String
1206
ipCommandPath = AutoConf.ipPath
1207

    
1208
-- | Key for job IDs in opcode result
1209
jobIdsKey :: String
1210
jobIdsKey = "jobs"
1211

    
1212
-- * Runparts results
1213

    
1214
runpartsErr :: Int
1215
runpartsErr = 2
1216

    
1217
runpartsRun :: Int
1218
runpartsRun = 1
1219

    
1220
runpartsSkip :: Int
1221
runpartsSkip = 0
1222

    
1223
runpartsStatus :: [Int]
1224
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1225

    
1226
-- * RPC
1227

    
1228
rpcEncodingNone :: Int
1229
rpcEncodingNone = 0
1230

    
1231
rpcEncodingZlibBase64 :: Int
1232
rpcEncodingZlibBase64 = 1
1233

    
1234
-- * Timeout table
1235
--
1236
-- Various time constants for the timeout table
1237

    
1238
rpcTmoUrgent :: Int
1239
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1240

    
1241
rpcTmoFast :: Int
1242
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1243

    
1244
rpcTmoNormal :: Int
1245
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1246

    
1247
rpcTmoSlow :: Int
1248
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1249

    
1250
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1251
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1252
-- Python name.
1253
rpcTmo_4hrs :: Int
1254
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1255

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

    
1262
-- | Timeout for connecting to nodes (seconds)
1263
rpcConnectTimeout :: Int
1264
rpcConnectTimeout = 5
1265

    
1266
-- OS
1267

    
1268
osScriptCreate :: String
1269
osScriptCreate = "create"
1270

    
1271
osScriptExport :: String
1272
osScriptExport = "export"
1273

    
1274
osScriptImport :: String
1275
osScriptImport = "import"
1276

    
1277
osScriptRename :: String
1278
osScriptRename = "rename"
1279

    
1280
osScriptVerify :: String
1281
osScriptVerify = "verify"
1282

    
1283
osScripts :: [String]
1284
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1285
             osScriptVerify]
1286

    
1287
osApiFile :: String
1288
osApiFile = "ganeti_api_version"
1289

    
1290
osVariantsFile :: String
1291
osVariantsFile = "variants.list"
1292

    
1293
osParametersFile :: String
1294
osParametersFile = "parameters.list"
1295

    
1296
osValidateParameters :: String
1297
osValidateParameters = "parameters"
1298

    
1299
osValidateCalls :: FrozenSet String
1300
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1301

    
1302
-- | External Storage (ES) related constants
1303

    
1304
esActionAttach :: String
1305
esActionAttach = "attach"
1306

    
1307
esActionCreate :: String
1308
esActionCreate = "create"
1309

    
1310
esActionDetach :: String
1311
esActionDetach = "detach"
1312

    
1313
esActionGrow :: String
1314
esActionGrow = "grow"
1315

    
1316
esActionRemove :: String
1317
esActionRemove = "remove"
1318

    
1319
esActionSetinfo :: String
1320
esActionSetinfo = "setinfo"
1321

    
1322
esActionVerify :: String
1323
esActionVerify = "verify"
1324

    
1325
esActionSnapshot :: String
1326
esActionSnapshot = "snapshot"
1327

    
1328
esScriptCreate :: String
1329
esScriptCreate = esActionCreate
1330

    
1331
esScriptRemove :: String
1332
esScriptRemove = esActionRemove
1333

    
1334
esScriptGrow :: String
1335
esScriptGrow = esActionGrow
1336

    
1337
esScriptAttach :: String
1338
esScriptAttach = esActionAttach
1339

    
1340
esScriptDetach :: String
1341
esScriptDetach = esActionDetach
1342

    
1343
esScriptSetinfo :: String
1344
esScriptSetinfo = esActionSetinfo
1345

    
1346
esScriptVerify :: String
1347
esScriptVerify = esActionVerify
1348

    
1349
esScriptSnapshot :: String
1350
esScriptSnapshot = esActionSnapshot
1351

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

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

    
1366
-- * Reboot types
1367

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

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

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

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

    
1380
-- * Instance reboot behaviors
1381

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

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

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

    
1391
-- * VTypes
1392

    
1393
vtypeBool :: VType
1394
vtypeBool = VTypeBool
1395

    
1396
vtypeInt :: VType
1397
vtypeInt = VTypeInt
1398

    
1399
vtypeMaybeString :: VType
1400
vtypeMaybeString = VTypeMaybeString
1401

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

    
1406
vtypeString :: VType
1407
vtypeString = VTypeString
1408

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1520
hvKvmMigrationCaps :: String
1521
hvKvmMigrationCaps = "migration_caps"
1522

    
1523
hvKvmPath :: String
1524
hvKvmPath = "kvm_path"
1525

    
1526
hvKvmSpiceAudioCompr :: String
1527
hvKvmSpiceAudioCompr = "spice_playback_compression"
1528

    
1529
hvKvmSpiceBind :: String
1530
hvKvmSpiceBind = "spice_bind"
1531

    
1532
hvKvmSpiceIpVersion :: String
1533
hvKvmSpiceIpVersion = "spice_ip_version"
1534

    
1535
hvKvmSpiceJpegImgCompr :: String
1536
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1537

    
1538
hvKvmSpiceLosslessImgCompr :: String
1539
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1540

    
1541
hvKvmSpicePasswordFile :: String
1542
hvKvmSpicePasswordFile = "spice_password_file"
1543

    
1544
hvKvmSpiceStreamingVideoDetection :: String
1545
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1546

    
1547
hvKvmSpiceTlsCiphers :: String
1548
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1549

    
1550
hvKvmSpiceUseTls :: String
1551
hvKvmSpiceUseTls = "spice_use_tls"
1552

    
1553
hvKvmSpiceUseVdagent :: String
1554
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1555

    
1556
hvKvmSpiceZlibGlzImgCompr :: String
1557
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1558

    
1559
hvKvmUseChroot :: String
1560
hvKvmUseChroot = "use_chroot"
1561

    
1562
hvMemPath :: String
1563
hvMemPath = "mem_path"
1564

    
1565
hvMigrationBandwidth :: String
1566
hvMigrationBandwidth = "migration_bandwidth"
1567

    
1568
hvMigrationDowntime :: String
1569
hvMigrationDowntime = "migration_downtime"
1570

    
1571
hvMigrationMode :: String
1572
hvMigrationMode = "migration_mode"
1573

    
1574
hvMigrationPort :: String
1575
hvMigrationPort = "migration_port"
1576

    
1577
hvNicType :: String
1578
hvNicType = "nic_type"
1579

    
1580
hvPae :: String
1581
hvPae = "pae"
1582

    
1583
hvPassthrough :: String
1584
hvPassthrough = "pci_pass"
1585

    
1586
hvRebootBehavior :: String
1587
hvRebootBehavior = "reboot_behavior"
1588

    
1589
hvRootPath :: String
1590
hvRootPath = "root_path"
1591

    
1592
hvSecurityDomain :: String
1593
hvSecurityDomain = "security_domain"
1594

    
1595
hvSecurityModel :: String
1596
hvSecurityModel = "security_model"
1597

    
1598
hvSerialConsole :: String
1599
hvSerialConsole = "serial_console"
1600

    
1601
hvSerialSpeed :: String
1602
hvSerialSpeed = "serial_speed"
1603

    
1604
hvSoundhw :: String
1605
hvSoundhw = "soundhw"
1606

    
1607
hvUsbDevices :: String
1608
hvUsbDevices = "usb_devices"
1609

    
1610
hvUsbMouse :: String
1611
hvUsbMouse = "usb_mouse"
1612

    
1613
hvUseBootloader :: String
1614
hvUseBootloader = "use_bootloader"
1615

    
1616
hvUseLocaltime :: String
1617
hvUseLocaltime = "use_localtime"
1618

    
1619
hvVga :: String
1620
hvVga = "vga"
1621

    
1622
hvVhostNet :: String
1623
hvVhostNet = "vhost_net"
1624

    
1625
hvVifScript :: String
1626
hvVifScript = "vif_script"
1627

    
1628
hvVifType :: String
1629
hvVifType = "vif_type"
1630

    
1631
hvViridian :: String
1632
hvViridian = "viridian"
1633

    
1634
hvVncBindAddress :: String
1635
hvVncBindAddress = "vnc_bind_address"
1636

    
1637
hvVncPasswordFile :: String
1638
hvVncPasswordFile = "vnc_password_file"
1639

    
1640
hvVncTls :: String
1641
hvVncTls = "vnc_tls"
1642

    
1643
hvVncX509 :: String
1644
hvVncX509 = "vnc_x509_path"
1645

    
1646
hvVncX509Verify :: String
1647
hvVncX509Verify = "vnc_x509_verify"
1648

    
1649
hvVnetHdr :: String
1650
hvVnetHdr = "vnet_hdr"
1651

    
1652
hvXenCmd :: String
1653
hvXenCmd = "xen_cmd"
1654

    
1655
hvXenCpuid :: String
1656
hvXenCpuid = "cpuid"
1657

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

    
1673
hvsParameters :: FrozenSet String
1674
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1675

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

    
1753
-- * Migration statuses
1754

    
1755
hvMigrationActive :: String
1756
hvMigrationActive = "active"
1757

    
1758
hvMigrationCancelled :: String
1759
hvMigrationCancelled = "cancelled"
1760

    
1761
hvMigrationCompleted :: String
1762
hvMigrationCompleted = "completed"
1763

    
1764
hvMigrationFailed :: String
1765
hvMigrationFailed = "failed"
1766

    
1767
hvMigrationValidStatuses :: FrozenSet String
1768
hvMigrationValidStatuses =
1769
  ConstantUtils.mkSet [hvMigrationActive,
1770
                       hvMigrationCancelled,
1771
                       hvMigrationCompleted,
1772
                       hvMigrationFailed]
1773

    
1774
hvMigrationFailedStatuses :: FrozenSet String
1775
hvMigrationFailedStatuses =
1776
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1777

    
1778
-- | KVM-specific statuses
1779
--
1780
-- FIXME: this constant seems unnecessary
1781
hvKvmMigrationValidStatuses :: FrozenSet String
1782
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1783

    
1784
-- | Node info keys
1785
hvNodeinfoKeyVersion :: String
1786
hvNodeinfoKeyVersion = "hv_version"
1787

    
1788
-- * Hypervisor state
1789

    
1790
hvstCpuNode :: String
1791
hvstCpuNode = "cpu_node"
1792

    
1793
hvstCpuTotal :: String
1794
hvstCpuTotal = "cpu_total"
1795

    
1796
hvstMemoryHv :: String
1797
hvstMemoryHv = "mem_hv"
1798

    
1799
hvstMemoryNode :: String
1800
hvstMemoryNode = "mem_node"
1801

    
1802
hvstMemoryTotal :: String
1803
hvstMemoryTotal = "mem_total"
1804

    
1805
hvstsParameters :: FrozenSet String
1806
hvstsParameters =
1807
  ConstantUtils.mkSet [hvstCpuNode,
1808
                       hvstCpuTotal,
1809
                       hvstMemoryHv,
1810
                       hvstMemoryNode,
1811
                       hvstMemoryTotal]
1812

    
1813
hvstDefaults :: Map String Int
1814
hvstDefaults =
1815
  Map.fromList
1816
  [(hvstCpuNode, 1),
1817
   (hvstCpuTotal, 1),
1818
   (hvstMemoryHv, 0),
1819
   (hvstMemoryTotal, 0),
1820
   (hvstMemoryNode, 0)]
1821

    
1822
hvstsParameterTypes :: Map String VType
1823
hvstsParameterTypes =
1824
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1825
                (hvstMemoryNode, VTypeInt),
1826
                (hvstMemoryHv, VTypeInt),
1827
                (hvstCpuTotal, VTypeInt),
1828
                (hvstCpuNode, VTypeInt)]
1829

    
1830
-- * Disk state
1831

    
1832
dsDiskOverhead :: String
1833
dsDiskOverhead = "disk_overhead"
1834

    
1835
dsDiskReserved :: String
1836
dsDiskReserved = "disk_reserved"
1837

    
1838
dsDiskTotal :: String
1839
dsDiskTotal = "disk_total"
1840

    
1841
dsDefaults :: Map String Int
1842
dsDefaults =
1843
  Map.fromList
1844
  [(dsDiskTotal, 0),
1845
   (dsDiskReserved, 0),
1846
   (dsDiskOverhead, 0)]
1847

    
1848
dssParameterTypes :: Map String VType
1849
dssParameterTypes =
1850
  Map.fromList [(dsDiskTotal, VTypeInt),
1851
                (dsDiskReserved, VTypeInt),
1852
                (dsDiskOverhead, VTypeInt)]
1853

    
1854
dssParameters :: FrozenSet String
1855
dssParameters =
1856
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1857

    
1858
dsValidTypes :: FrozenSet String
1859
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1860

    
1861
-- Backend parameter names
1862

    
1863
beAlwaysFailover :: String
1864
beAlwaysFailover = "always_failover"
1865

    
1866
beAutoBalance :: String
1867
beAutoBalance = "auto_balance"
1868

    
1869
beMaxmem :: String
1870
beMaxmem = "maxmem"
1871

    
1872
-- | Deprecated and replaced by max and min mem
1873
beMemory :: String
1874
beMemory = "memory"
1875

    
1876
beMinmem :: String
1877
beMinmem = "minmem"
1878

    
1879
beSpindleUse :: String
1880
beSpindleUse = "spindle_use"
1881

    
1882
beVcpus :: String
1883
beVcpus = "vcpus"
1884

    
1885
besParameterTypes :: Map String VType
1886
besParameterTypes =
1887
  Map.fromList [(beAlwaysFailover, VTypeBool),
1888
                (beAutoBalance, VTypeBool),
1889
                (beMaxmem, VTypeSize),
1890
                (beMinmem, VTypeSize),
1891
                (beSpindleUse, VTypeInt),
1892
                (beVcpus, VTypeInt)]
1893

    
1894
besParameterTitles :: Map String String
1895
besParameterTitles =
1896
  Map.fromList [(beAutoBalance, "Auto_balance"),
1897
                (beMinmem, "ConfigMinMem"),
1898
                (beVcpus, "ConfigVCPUs"),
1899
                (beMaxmem, "ConfigMaxMem")]
1900

    
1901
besParameterCompat :: Map String VType
1902
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1903

    
1904
besParameters :: FrozenSet String
1905
besParameters =
1906
  ConstantUtils.mkSet [beAlwaysFailover,
1907
                       beAutoBalance,
1908
                       beMaxmem,
1909
                       beMinmem,
1910
                       beSpindleUse,
1911
                       beVcpus]
1912

    
1913
-- | Instance specs
1914
--
1915
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1916

    
1917
ispecMemSize :: String
1918
ispecMemSize = ConstantUtils.ispecMemSize
1919

    
1920
ispecCpuCount :: String
1921
ispecCpuCount = ConstantUtils.ispecCpuCount
1922

    
1923
ispecDiskCount :: String
1924
ispecDiskCount = ConstantUtils.ispecDiskCount
1925

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

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

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

    
1935
ispecsParameterTypes :: Map String VType
1936
ispecsParameterTypes =
1937
  Map.fromList
1938
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1939
   (ConstantUtils.ispecCpuCount, VTypeInt),
1940
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1941
   (ConstantUtils.ispecMemSize, VTypeInt),
1942
   (ConstantUtils.ispecNicCount, VTypeInt),
1943
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1944

    
1945
ispecsParameters :: FrozenSet String
1946
ispecsParameters =
1947
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1948
                       ConstantUtils.ispecDiskCount,
1949
                       ConstantUtils.ispecDiskSize,
1950
                       ConstantUtils.ispecMemSize,
1951
                       ConstantUtils.ispecNicCount,
1952
                       ConstantUtils.ispecSpindleUse]
1953

    
1954
ispecsMinmax :: String
1955
ispecsMinmax = ConstantUtils.ispecsMinmax
1956

    
1957
ispecsMax :: String
1958
ispecsMax = "max"
1959

    
1960
ispecsMin :: String
1961
ispecsMin = "min"
1962

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

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

    
1969
ipolicyVcpuRatio :: String
1970
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1971

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

    
1975
ispecsMinmaxKeys :: FrozenSet String
1976
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1977

    
1978
ipolicyParameters :: FrozenSet String
1979
ipolicyParameters =
1980
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1981
                       ConstantUtils.ipolicySpindleRatio]
1982

    
1983
ipolicyAllKeys :: FrozenSet String
1984
ipolicyAllKeys =
1985
  ConstantUtils.union ipolicyParameters $
1986
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1987
                       ConstantUtils.ispecsMinmax,
1988
                       ispecsStd]
1989

    
1990
-- | Node parameter names
1991

    
1992
ndExclusiveStorage :: String
1993
ndExclusiveStorage = "exclusive_storage"
1994

    
1995
ndOobProgram :: String
1996
ndOobProgram = "oob_program"
1997

    
1998
ndSpindleCount :: String
1999
ndSpindleCount = "spindle_count"
2000

    
2001
ndOvs :: String
2002
ndOvs = "ovs"
2003

    
2004
ndOvsLink :: String
2005
ndOvsLink = "ovs_link"
2006

    
2007
ndOvsName :: String
2008
ndOvsName = "ovs_name"
2009

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

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

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

    
2033
-- * Logical Disks parameters
2034

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2189
-- * Dynamic disk parameters
2190

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

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

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

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

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

    
2206
-- * OOB supported commands
2207

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2323
idiskAccess :: String
2324
idiskAccess = "access"
2325

    
2326
idiskSnapshotName :: String
2327
idiskSnapshotName = "snapshot_name"
2328

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

    
2342
idiskParams :: FrozenSet String
2343
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2344

    
2345
modifiableIdiskParamsTypes :: Map String VType
2346
modifiableIdiskParamsTypes =
2347
  Map.fromList [(idiskMode, VTypeString),
2348
                (idiskName, VTypeString)]
2349

    
2350
modifiableIdiskParams :: FrozenSet String
2351
modifiableIdiskParams =
2352
  ConstantUtils.mkSet (Map.keys modifiableIdiskParamsTypes)
2353

    
2354
-- * inic* constants are used in opcodes, to create/change nics
2355

    
2356
inicBridge :: String
2357
inicBridge = "bridge"
2358

    
2359
inicIp :: String
2360
inicIp = "ip"
2361

    
2362
inicLink :: String
2363
inicLink = "link"
2364

    
2365
inicMac :: String
2366
inicMac = "mac"
2367

    
2368
inicMode :: String
2369
inicMode = "mode"
2370

    
2371
inicName :: String
2372
inicName = "name"
2373

    
2374
inicNetwork :: String
2375
inicNetwork = "network"
2376

    
2377
inicVlan :: String
2378
inicVlan = "vlan"
2379

    
2380
inicParamsTypes :: Map String VType
2381
inicParamsTypes =
2382
  Map.fromList [(inicBridge, VTypeMaybeString),
2383
                (inicIp, VTypeMaybeString),
2384
                (inicLink, VTypeString),
2385
                (inicMac, VTypeString),
2386
                (inicMode, VTypeString),
2387
                (inicName, VTypeMaybeString),
2388
                (inicNetwork, VTypeMaybeString),
2389
                (inicVlan, VTypeMaybeString)]
2390

    
2391
inicParams :: FrozenSet String
2392
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2393

    
2394
-- * Hypervisor constants
2395

    
2396
htXenPvm :: String
2397
htXenPvm = Types.hypervisorToRaw XenPvm
2398

    
2399
htFake :: String
2400
htFake = Types.hypervisorToRaw Fake
2401

    
2402
htXenHvm :: String
2403
htXenHvm = Types.hypervisorToRaw XenHvm
2404

    
2405
htKvm :: String
2406
htKvm = Types.hypervisorToRaw Kvm
2407

    
2408
htChroot :: String
2409
htChroot = Types.hypervisorToRaw Chroot
2410

    
2411
htLxc :: String
2412
htLxc = Types.hypervisorToRaw Lxc
2413

    
2414
hyperTypes :: FrozenSet String
2415
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2416

    
2417
htsReqPort :: FrozenSet String
2418
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2419

    
2420
vncBasePort :: Int
2421
vncBasePort = 5900
2422

    
2423
vncDefaultBindAddress :: String
2424
vncDefaultBindAddress = ip4AddressAny
2425

    
2426
-- * NIC types
2427

    
2428
htNicE1000 :: String
2429
htNicE1000 = "e1000"
2430

    
2431
htNicI82551 :: String
2432
htNicI82551 = "i82551"
2433

    
2434
htNicI8259er :: String
2435
htNicI8259er = "i82559er"
2436

    
2437
htNicI85557b :: String
2438
htNicI85557b = "i82557b"
2439

    
2440
htNicNe2kIsa :: String
2441
htNicNe2kIsa = "ne2k_isa"
2442

    
2443
htNicNe2kPci :: String
2444
htNicNe2kPci = "ne2k_pci"
2445

    
2446
htNicParavirtual :: String
2447
htNicParavirtual = "paravirtual"
2448

    
2449
htNicPcnet :: String
2450
htNicPcnet = "pcnet"
2451

    
2452
htNicRtl8139 :: String
2453
htNicRtl8139 = "rtl8139"
2454

    
2455
htHvmValidNicTypes :: FrozenSet String
2456
htHvmValidNicTypes =
2457
  ConstantUtils.mkSet [htNicE1000,
2458
                       htNicNe2kIsa,
2459
                       htNicNe2kPci,
2460
                       htNicParavirtual,
2461
                       htNicRtl8139]
2462

    
2463
htKvmValidNicTypes :: FrozenSet String
2464
htKvmValidNicTypes =
2465
  ConstantUtils.mkSet [htNicE1000,
2466
                       htNicI82551,
2467
                       htNicI8259er,
2468
                       htNicI85557b,
2469
                       htNicNe2kIsa,
2470
                       htNicNe2kPci,
2471
                       htNicParavirtual,
2472
                       htNicPcnet,
2473
                       htNicRtl8139]
2474

    
2475
-- * Vif types
2476

    
2477
-- | Default vif type in xen-hvm
2478
htHvmVifIoemu :: String
2479
htHvmVifIoemu = "ioemu"
2480

    
2481
htHvmVifVif :: String
2482
htHvmVifVif = "vif"
2483

    
2484
htHvmValidVifTypes :: FrozenSet String
2485
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2486

    
2487
-- * Disk types
2488

    
2489
htDiskIde :: String
2490
htDiskIde = "ide"
2491

    
2492
htDiskIoemu :: String
2493
htDiskIoemu = "ioemu"
2494

    
2495
htDiskMtd :: String
2496
htDiskMtd = "mtd"
2497

    
2498
htDiskParavirtual :: String
2499
htDiskParavirtual = "paravirtual"
2500

    
2501
htDiskPflash :: String
2502
htDiskPflash = "pflash"
2503

    
2504
htDiskScsi :: String
2505
htDiskScsi = "scsi"
2506

    
2507
htDiskSd :: String
2508
htDiskSd = "sd"
2509

    
2510
htHvmValidDiskTypes :: FrozenSet String
2511
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2512

    
2513
htKvmValidDiskTypes :: FrozenSet String
2514
htKvmValidDiskTypes =
2515
  ConstantUtils.mkSet [htDiskIde,
2516
                       htDiskMtd,
2517
                       htDiskParavirtual,
2518
                       htDiskPflash,
2519
                       htDiskScsi,
2520
                       htDiskSd]
2521

    
2522
htCacheDefault :: String
2523
htCacheDefault = "default"
2524

    
2525
htCacheNone :: String
2526
htCacheNone = "none"
2527

    
2528
htCacheWback :: String
2529
htCacheWback = "writeback"
2530

    
2531
htCacheWthrough :: String
2532
htCacheWthrough = "writethrough"
2533

    
2534
htValidCacheTypes :: FrozenSet String
2535
htValidCacheTypes =
2536
  ConstantUtils.mkSet [htCacheDefault,
2537
                       htCacheNone,
2538
                       htCacheWback,
2539
                       htCacheWthrough]
2540

    
2541
-- * Mouse types
2542

    
2543
htMouseMouse :: String
2544
htMouseMouse = "mouse"
2545

    
2546
htMouseTablet :: String
2547
htMouseTablet = "tablet"
2548

    
2549
htKvmValidMouseTypes :: FrozenSet String
2550
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2551

    
2552
-- * Boot order
2553

    
2554
htBoCdrom :: String
2555
htBoCdrom = "cdrom"
2556

    
2557
htBoDisk :: String
2558
htBoDisk = "disk"
2559

    
2560
htBoFloppy :: String
2561
htBoFloppy = "floppy"
2562

    
2563
htBoNetwork :: String
2564
htBoNetwork = "network"
2565

    
2566
htKvmValidBoTypes :: FrozenSet String
2567
htKvmValidBoTypes =
2568
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2569

    
2570
-- * SPICE lossless image compression options
2571

    
2572
htKvmSpiceLosslessImgComprAutoGlz :: String
2573
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2574

    
2575
htKvmSpiceLosslessImgComprAutoLz :: String
2576
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2577

    
2578
htKvmSpiceLosslessImgComprGlz :: String
2579
htKvmSpiceLosslessImgComprGlz = "glz"
2580

    
2581
htKvmSpiceLosslessImgComprLz :: String
2582
htKvmSpiceLosslessImgComprLz = "lz"
2583

    
2584
htKvmSpiceLosslessImgComprOff :: String
2585
htKvmSpiceLosslessImgComprOff = "off"
2586

    
2587
htKvmSpiceLosslessImgComprQuic :: String
2588
htKvmSpiceLosslessImgComprQuic = "quic"
2589

    
2590
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2591
htKvmSpiceValidLosslessImgComprOptions =
2592
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2593
                       htKvmSpiceLosslessImgComprAutoLz,
2594
                       htKvmSpiceLosslessImgComprGlz,
2595
                       htKvmSpiceLosslessImgComprLz,
2596
                       htKvmSpiceLosslessImgComprOff,
2597
                       htKvmSpiceLosslessImgComprQuic]
2598

    
2599
htKvmSpiceLossyImgComprAlways :: String
2600
htKvmSpiceLossyImgComprAlways = "always"
2601

    
2602
htKvmSpiceLossyImgComprAuto :: String
2603
htKvmSpiceLossyImgComprAuto = "auto"
2604

    
2605
htKvmSpiceLossyImgComprNever :: String
2606
htKvmSpiceLossyImgComprNever = "never"
2607

    
2608
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2609
htKvmSpiceValidLossyImgComprOptions =
2610
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2611
                       htKvmSpiceLossyImgComprAuto,
2612
                       htKvmSpiceLossyImgComprNever]
2613

    
2614
-- * SPICE video stream detection
2615

    
2616
htKvmSpiceVideoStreamDetectionAll :: String
2617
htKvmSpiceVideoStreamDetectionAll = "all"
2618

    
2619
htKvmSpiceVideoStreamDetectionFilter :: String
2620
htKvmSpiceVideoStreamDetectionFilter = "filter"
2621

    
2622
htKvmSpiceVideoStreamDetectionOff :: String
2623
htKvmSpiceVideoStreamDetectionOff = "off"
2624

    
2625
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2626
htKvmSpiceValidVideoStreamDetectionOptions =
2627
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2628
                       htKvmSpiceVideoStreamDetectionFilter,
2629
                       htKvmSpiceVideoStreamDetectionOff]
2630

    
2631
-- * Security models
2632

    
2633
htSmNone :: String
2634
htSmNone = "none"
2635

    
2636
htSmPool :: String
2637
htSmPool = "pool"
2638

    
2639
htSmUser :: String
2640
htSmUser = "user"
2641

    
2642
htKvmValidSmTypes :: FrozenSet String
2643
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2644

    
2645
-- * Kvm flag values
2646

    
2647
htKvmDisabled :: String
2648
htKvmDisabled = "disabled"
2649

    
2650
htKvmEnabled :: String
2651
htKvmEnabled = "enabled"
2652

    
2653
htKvmFlagValues :: FrozenSet String
2654
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2655

    
2656
-- * Migration type
2657

    
2658
htMigrationLive :: String
2659
htMigrationLive = Types.migrationModeToRaw MigrationLive
2660

    
2661
htMigrationNonlive :: String
2662
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2663

    
2664
htMigrationModes :: FrozenSet String
2665
htMigrationModes =
2666
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2667

    
2668
-- * Cluster verify steps
2669

    
2670
verifyNplusoneMem :: String
2671
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2672

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

    
2677
-- * Cluster Verify error classes
2678

    
2679
cvTcluster :: String
2680
cvTcluster = "cluster"
2681

    
2682
cvTgroup :: String
2683
cvTgroup = "group"
2684

    
2685
cvTnode :: String
2686
cvTnode = "node"
2687

    
2688
cvTinstance :: String
2689
cvTinstance = "instance"
2690

    
2691
-- * Cluster Verify error codes and documentation
2692

    
2693
cvEclustercert :: (String, String, String)
2694
cvEclustercert =
2695
  ("cluster",
2696
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2697
   "Cluster certificate files verification failure")
2698

    
2699
cvEclustercfg :: (String, String, String)
2700
cvEclustercfg =
2701
  ("cluster",
2702
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2703
   "Cluster configuration verification failure")
2704

    
2705
cvEclusterdanglinginst :: (String, String, String)
2706
cvEclusterdanglinginst =
2707
  ("node",
2708
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2709
   "Some instances have a non-existing primary node")
2710

    
2711
cvEclusterdanglingnodes :: (String, String, String)
2712
cvEclusterdanglingnodes =
2713
  ("node",
2714
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2715
   "Some nodes belong to non-existing groups")
2716

    
2717
cvEclusterfilecheck :: (String, String, String)
2718
cvEclusterfilecheck =
2719
  ("cluster",
2720
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2721
   "Cluster configuration verification failure")
2722

    
2723
cvEgroupdifferentpvsize :: (String, String, String)
2724
cvEgroupdifferentpvsize =
2725
  ("group",
2726
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2727
   "PVs in the group have different sizes")
2728

    
2729
cvEinstancebadnode :: (String, String, String)
2730
cvEinstancebadnode =
2731
  ("instance",
2732
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2733
   "Instance marked as running lives on an offline node")
2734

    
2735
cvEinstancedown :: (String, String, String)
2736
cvEinstancedown =
2737
  ("instance",
2738
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2739
   "Instance not running on its primary node")
2740

    
2741
cvEinstancefaultydisk :: (String, String, String)
2742
cvEinstancefaultydisk =
2743
  ("instance",
2744
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2745
   "Impossible to retrieve status for a disk")
2746

    
2747
cvEinstancelayout :: (String, String, String)
2748
cvEinstancelayout =
2749
  ("instance",
2750
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2751
   "Instance has multiple secondary nodes")
2752

    
2753
cvEinstancemissingcfgparameter :: (String, String, String)
2754
cvEinstancemissingcfgparameter =
2755
  ("instance",
2756
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2757
   "A configuration parameter for an instance is missing")
2758

    
2759
cvEinstancemissingdisk :: (String, String, String)
2760
cvEinstancemissingdisk =
2761
  ("instance",
2762
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2763
   "Missing volume on an instance")
2764

    
2765
cvEinstancepolicy :: (String, String, String)
2766
cvEinstancepolicy =
2767
  ("instance",
2768
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2769
   "Instance does not meet policy")
2770

    
2771
cvEinstancesplitgroups :: (String, String, String)
2772
cvEinstancesplitgroups =
2773
  ("instance",
2774
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2775
   "Instance with primary and secondary nodes in different groups")
2776

    
2777
cvEinstanceunsuitablenode :: (String, String, String)
2778
cvEinstanceunsuitablenode =
2779
  ("instance",
2780
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2781
   "Instance running on nodes that are not suitable for it")
2782

    
2783
cvEinstancewrongnode :: (String, String, String)
2784
cvEinstancewrongnode =
2785
  ("instance",
2786
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2787
   "Instance running on the wrong node")
2788

    
2789
cvEnodedrbd :: (String, String, String)
2790
cvEnodedrbd =
2791
  ("node",
2792
   Types.cVErrorCodeToRaw CvENODEDRBD,
2793
   "Error parsing the DRBD status file")
2794

    
2795
cvEnodedrbdhelper :: (String, String, String)
2796
cvEnodedrbdhelper =
2797
  ("node",
2798
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2799
   "Error caused by the DRBD helper")
2800

    
2801
cvEnodedrbdversion :: (String, String, String)
2802
cvEnodedrbdversion =
2803
  ("node",
2804
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2805
   "DRBD version mismatch within a node group")
2806

    
2807
cvEnodefilecheck :: (String, String, String)
2808
cvEnodefilecheck =
2809
  ("node",
2810
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2811
   "Error retrieving the checksum of the node files")
2812

    
2813
cvEnodefilestoragepaths :: (String, String, String)
2814
cvEnodefilestoragepaths =
2815
  ("node",
2816
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2817
   "Detected bad file storage paths")
2818

    
2819
cvEnodefilestoragepathunusable :: (String, String, String)
2820
cvEnodefilestoragepathunusable =
2821
  ("node",
2822
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2823
   "File storage path unusable")
2824

    
2825
cvEnodehooks :: (String, String, String)
2826
cvEnodehooks =
2827
  ("node",
2828
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2829
   "Communication failure in hooks execution")
2830

    
2831
cvEnodehv :: (String, String, String)
2832
cvEnodehv =
2833
  ("node",
2834
   Types.cVErrorCodeToRaw CvENODEHV,
2835
   "Hypervisor parameters verification failure")
2836

    
2837
cvEnodelvm :: (String, String, String)
2838
cvEnodelvm =
2839
  ("node",
2840
   Types.cVErrorCodeToRaw CvENODELVM,
2841
   "LVM-related node error")
2842

    
2843
cvEnoden1 :: (String, String, String)
2844
cvEnoden1 =
2845
  ("node",
2846
   Types.cVErrorCodeToRaw CvENODEN1,
2847
   "Not enough memory to accommodate instance failovers")
2848

    
2849
cvEnodenet :: (String, String, String)
2850
cvEnodenet =
2851
  ("node",
2852
   Types.cVErrorCodeToRaw CvENODENET,
2853
   "Network-related node error")
2854

    
2855
cvEnodeoobpath :: (String, String, String)
2856
cvEnodeoobpath =
2857
  ("node",
2858
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2859
   "Invalid Out Of Band path")
2860

    
2861
cvEnodeorphaninstance :: (String, String, String)
2862
cvEnodeorphaninstance =
2863
  ("node",
2864
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2865
   "Unknown intance running on a node")
2866

    
2867
cvEnodeorphanlv :: (String, String, String)
2868
cvEnodeorphanlv =
2869
  ("node",
2870
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2871
   "Unknown LVM logical volume")
2872

    
2873
cvEnodeos :: (String, String, String)
2874
cvEnodeos =
2875
  ("node",
2876
   Types.cVErrorCodeToRaw CvENODEOS,
2877
   "OS-related node error")
2878

    
2879
cvEnoderpc :: (String, String, String)
2880
cvEnoderpc =
2881
  ("node",
2882
   Types.cVErrorCodeToRaw CvENODERPC,
2883
   "Error during connection to the primary node of an instance")
2884

    
2885
cvEnodesetup :: (String, String, String)
2886
cvEnodesetup =
2887
  ("node",
2888
   Types.cVErrorCodeToRaw CvENODESETUP,
2889
   "Node setup error")
2890

    
2891
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2892
cvEnodesharedfilestoragepathunusable =
2893
  ("node",
2894
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2895
   "Shared file storage path unusable")
2896

    
2897
cvEnodessh :: (String, String, String)
2898
cvEnodessh =
2899
  ("node",
2900
   Types.cVErrorCodeToRaw CvENODESSH,
2901
   "SSH-related node error")
2902

    
2903
cvEnodetime :: (String, String, String)
2904
cvEnodetime =
2905
  ("node",
2906
   Types.cVErrorCodeToRaw CvENODETIME,
2907
   "Node returned invalid time")
2908

    
2909
cvEnodeuserscripts :: (String, String, String)
2910
cvEnodeuserscripts =
2911
  ("node",
2912
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2913
   "User scripts not present or not executable")
2914

    
2915
cvEnodeversion :: (String, String, String)
2916
cvEnodeversion =
2917
  ("node",
2918
   Types.cVErrorCodeToRaw CvENODEVERSION,
2919
   "Protocol version mismatch or Ganeti version mismatch")
2920

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

    
2963
cvAllEcodesStrings :: FrozenSet String
2964
cvAllEcodesStrings =
2965
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2966

    
2967
-- * Node verify constants
2968

    
2969
nvBridges :: String
2970
nvBridges = "bridges"
2971

    
2972
nvDrbdhelper :: String
2973
nvDrbdhelper = "drbd-helper"
2974

    
2975
nvDrbdversion :: String
2976
nvDrbdversion = "drbd-version"
2977

    
2978
nvDrbdlist :: String
2979
nvDrbdlist = "drbd-list"
2980

    
2981
nvExclusivepvs :: String
2982
nvExclusivepvs = "exclusive-pvs"
2983

    
2984
nvFilelist :: String
2985
nvFilelist = "filelist"
2986

    
2987
nvAcceptedStoragePaths :: String
2988
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2989

    
2990
nvFileStoragePath :: String
2991
nvFileStoragePath = "file-storage-path"
2992

    
2993
nvSharedFileStoragePath :: String
2994
nvSharedFileStoragePath = "shared-file-storage-path"
2995

    
2996
nvHvinfo :: String
2997
nvHvinfo = "hvinfo"
2998

    
2999
nvHvparams :: String
3000
nvHvparams = "hvparms"
3001

    
3002
nvHypervisor :: String
3003
nvHypervisor = "hypervisor"
3004

    
3005
nvInstancelist :: String
3006
nvInstancelist = "instancelist"
3007

    
3008
nvLvlist :: String
3009
nvLvlist = "lvlist"
3010

    
3011
nvMasterip :: String
3012
nvMasterip = "master-ip"
3013

    
3014
nvNodelist :: String
3015
nvNodelist = "nodelist"
3016

    
3017
nvNodenettest :: String
3018
nvNodenettest = "node-net-test"
3019

    
3020
nvNodesetup :: String
3021
nvNodesetup = "nodesetup"
3022

    
3023
nvOobPaths :: String
3024
nvOobPaths = "oob-paths"
3025

    
3026
nvOslist :: String
3027
nvOslist = "oslist"
3028

    
3029
nvPvlist :: String
3030
nvPvlist = "pvlist"
3031

    
3032
nvTime :: String
3033
nvTime = "time"
3034

    
3035
nvUserscripts :: String
3036
nvUserscripts = "user-scripts"
3037

    
3038
nvVersion :: String
3039
nvVersion = "version"
3040

    
3041
nvVglist :: String
3042
nvVglist = "vglist"
3043

    
3044
nvVmnodes :: String
3045
nvVmnodes = "vmnodes"
3046

    
3047
-- * Instance status
3048

    
3049
inststAdmindown :: String
3050
inststAdmindown = Types.instanceStatusToRaw StatusDown
3051

    
3052
inststAdminoffline :: String
3053
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3054

    
3055
inststErrordown :: String
3056
inststErrordown = Types.instanceStatusToRaw ErrorDown
3057

    
3058
inststErrorup :: String
3059
inststErrorup = Types.instanceStatusToRaw ErrorUp
3060

    
3061
inststNodedown :: String
3062
inststNodedown = Types.instanceStatusToRaw NodeDown
3063

    
3064
inststNodeoffline :: String
3065
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3066

    
3067
inststRunning :: String
3068
inststRunning = Types.instanceStatusToRaw Running
3069

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

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

    
3076
-- * Admin states
3077

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

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

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

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

    
3090
-- * Node roles
3091

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

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

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

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

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

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

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

    
3112
sslCertExpirationError :: Int
3113
sslCertExpirationError = 7
3114

    
3115
sslCertExpirationWarn :: Int
3116
sslCertExpirationWarn = 30
3117

    
3118
-- * Allocator framework constants
3119

    
3120
iallocatorVersion :: Int
3121
iallocatorVersion = 2
3122

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

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

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

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

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

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

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

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

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

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

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

    
3158
-- * Node evacuation
3159

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

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

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

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

    
3172
-- * Job queue
3173

    
3174
jobQueueVersion :: Int
3175
jobQueueVersion = 1
3176

    
3177
jobQueueSizeHardLimit :: Int
3178
jobQueueSizeHardLimit = 5000
3179

    
3180
jobQueueFilesPerms :: Int
3181
jobQueueFilesPerms = 0o640
3182

    
3183
-- * Unchanged job return
3184

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

    
3188
-- * Job status
3189

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

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

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

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

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

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

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

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

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

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

    
3222
-- * OpCode status
3223

    
3224
-- ** Not yet finalized opcodes
3225

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

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

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

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

    
3238
-- ** Finalized opcodes
3239

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

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

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

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

    
3253
-- * OpCode priority
3254

    
3255
opPrioLowest :: Int
3256
opPrioLowest = 19
3257

    
3258
opPrioHighest :: Int
3259
opPrioHighest = -20
3260

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

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

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

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

    
3273
opPrioDefault :: Int
3274
opPrioDefault = opPrioNormal
3275

    
3276
-- * Lock recalculate mode
3277

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

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

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

    
3291
lockAttemptsMaxwait :: Double
3292
lockAttemptsMaxwait = 15.0
3293

    
3294
lockAttemptsMinwait :: Double
3295
lockAttemptsMinwait = 1.0
3296

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

    
3300
-- * Execution log types
3301

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

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

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

    
3311
-- * /etc/hosts modification
3312

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

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

    
3319
-- * Job queue test
3320

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

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

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

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

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

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

    
3339
-- * Query resources
3340

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

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

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

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

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

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

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

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

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

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

    
3371
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3372
qrViaOp :: FrozenSet String
3373
qrViaOp =
3374
  ConstantUtils.mkSet [qrCluster,
3375
                       qrInstance,
3376
                       qrNode,
3377
                       qrGroup,
3378
                       qrOs,
3379
                       qrExport,
3380
                       qrNetwork,
3381
                       qrExtstorage]
3382

    
3383
-- | List of resources which can be queried using Local UniX Interface
3384
qrViaLuxi :: FrozenSet String
3385
qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob]
3386

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

    
3391
-- * Query field types
3392

    
3393
qftBool :: String
3394
qftBool = "bool"
3395

    
3396
qftNumber :: String
3397
qftNumber = "number"
3398

    
3399
qftOther :: String
3400
qftOther = "other"
3401

    
3402
qftText :: String
3403
qftText = "text"
3404

    
3405
qftTimestamp :: String
3406
qftTimestamp = "timestamp"
3407

    
3408
qftUnit :: String
3409
qftUnit = "unit"
3410

    
3411
qftUnknown :: String
3412
qftUnknown = "unknown"
3413

    
3414
qftAll :: FrozenSet String
3415
qftAll =
3416
  ConstantUtils.mkSet [qftBool,
3417
                       qftNumber,
3418
                       qftOther,
3419
                       qftText,
3420
                       qftTimestamp,
3421
                       qftUnit,
3422
                       qftUnknown]
3423

    
3424
-- * Query result field status
3425
--
3426
-- Don't change or reuse values as they're used by clients.
3427
--
3428
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3429

    
3430
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3431
rsNodata :: Int
3432
rsNodata = 2
3433

    
3434
rsNormal :: Int
3435
rsNormal = 0
3436

    
3437
-- | Resource marked offline
3438
rsOffline :: Int
3439
rsOffline = 4
3440

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

    
3447
rsUnknown :: Int
3448
rsUnknown = 1
3449

    
3450
rsAll :: FrozenSet Int
3451
rsAll =
3452
  ConstantUtils.mkSet [rsNodata,
3453
                       rsNormal,
3454
                       rsOffline,
3455
                       rsUnavail,
3456
                       rsUnknown]
3457

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

    
3466
-- * Max dynamic devices
3467

    
3468
maxDisks :: Int
3469
maxDisks = Types.maxDisks
3470

    
3471
maxNics :: Int
3472
maxNics = Types.maxNics
3473

    
3474
-- | SSCONF file prefix
3475
ssconfFileprefix :: String
3476
ssconfFileprefix = "ssconf_"
3477

    
3478
-- * SSCONF keys
3479

    
3480
ssClusterName :: String
3481
ssClusterName = "cluster_name"
3482

    
3483
ssClusterTags :: String
3484
ssClusterTags = "cluster_tags"
3485

    
3486
ssFileStorageDir :: String
3487
ssFileStorageDir = "file_storage_dir"
3488

    
3489
ssSharedFileStorageDir :: String
3490
ssSharedFileStorageDir = "shared_file_storage_dir"
3491

    
3492
ssMasterCandidates :: String
3493
ssMasterCandidates = "master_candidates"
3494

    
3495
ssMasterCandidatesIps :: String
3496
ssMasterCandidatesIps = "master_candidates_ips"
3497

    
3498
ssMasterIp :: String
3499
ssMasterIp = "master_ip"
3500

    
3501
ssMasterNetdev :: String
3502
ssMasterNetdev = "master_netdev"
3503

    
3504
ssMasterNetmask :: String
3505
ssMasterNetmask = "master_netmask"
3506

    
3507
ssMasterNode :: String
3508
ssMasterNode = "master_node"
3509

    
3510
ssNodeList :: String
3511
ssNodeList = "node_list"
3512

    
3513
ssNodePrimaryIps :: String
3514
ssNodePrimaryIps = "node_primary_ips"
3515

    
3516
ssNodeSecondaryIps :: String
3517
ssNodeSecondaryIps = "node_secondary_ips"
3518

    
3519
ssOfflineNodes :: String
3520
ssOfflineNodes = "offline_nodes"
3521

    
3522
ssOnlineNodes :: String
3523
ssOnlineNodes = "online_nodes"
3524

    
3525
ssPrimaryIpFamily :: String
3526
ssPrimaryIpFamily = "primary_ip_family"
3527

    
3528
ssInstanceList :: String
3529
ssInstanceList = "instance_list"
3530

    
3531
ssReleaseVersion :: String
3532
ssReleaseVersion = "release_version"
3533

    
3534
ssHypervisorList :: String
3535
ssHypervisorList = "hypervisor_list"
3536

    
3537
ssMaintainNodeHealth :: String
3538
ssMaintainNodeHealth = "maintain_node_health"
3539

    
3540
ssUidPool :: String
3541
ssUidPool = "uid_pool"
3542

    
3543
ssNodegroups :: String
3544
ssNodegroups = "nodegroups"
3545

    
3546
ssNetworks :: String
3547
ssNetworks = "networks"
3548

    
3549
-- | This is not a complete SSCONF key, but the prefix for the
3550
-- hypervisor keys
3551
ssHvparamsPref :: String
3552
ssHvparamsPref = "hvparams_"
3553

    
3554
-- * Hvparams keys
3555

    
3556
ssHvparamsXenChroot :: String
3557
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3558

    
3559
ssHvparamsXenFake :: String
3560
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3561

    
3562
ssHvparamsXenHvm :: String
3563
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3564

    
3565
ssHvparamsXenKvm :: String
3566
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3567

    
3568
ssHvparamsXenLxc :: String
3569
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3570

    
3571
ssHvparamsXenPvm :: String
3572
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3573

    
3574
validSsHvparamsKeys :: FrozenSet String
3575
validSsHvparamsKeys =
3576
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3577
                       ssHvparamsXenLxc,
3578
                       ssHvparamsXenFake,
3579
                       ssHvparamsXenHvm,
3580
                       ssHvparamsXenKvm,
3581
                       ssHvparamsXenPvm]
3582

    
3583
ssFilePerms :: Int
3584
ssFilePerms = 0o444
3585

    
3586
-- | Cluster wide default parameters
3587
defaultEnabledHypervisor :: String
3588
defaultEnabledHypervisor = htXenPvm
3589

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

    
3703
hvcGlobals :: FrozenSet String
3704
hvcGlobals =
3705
  ConstantUtils.mkSet [hvMigrationBandwidth,
3706
                       hvMigrationMode,
3707
                       hvMigrationPort,
3708
                       hvXenCmd]
3709

    
3710
becDefaults :: Map String PyValueEx
3711
becDefaults =
3712
  Map.fromList
3713
  [ (beMinmem, PyValueEx (128 :: Int))
3714
  , (beMaxmem, PyValueEx (128 :: Int))
3715
  , (beVcpus, PyValueEx (1 :: Int))
3716
  , (beAutoBalance, PyValueEx True)
3717
  , (beAlwaysFailover, PyValueEx False)
3718
  , (beSpindleUse, PyValueEx (1 :: Int))
3719
  ]
3720

    
3721
ndcDefaults :: Map String PyValueEx
3722
ndcDefaults =
3723
  Map.fromList
3724
  [ (ndOobProgram,       PyValueEx "")
3725
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3726
  , (ndExclusiveStorage, PyValueEx False)
3727
  , (ndOvs,              PyValueEx False)
3728
  , (ndOvsName,          PyValueEx defaultOvs)
3729
  , (ndOvsLink,          PyValueEx "")
3730
  ]
3731

    
3732
ndcGlobals :: FrozenSet String
3733
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3734

    
3735
-- | Default delay target measured in sectors
3736
defaultDelayTarget :: Int
3737
defaultDelayTarget = 1
3738

    
3739
defaultDiskCustom :: String
3740
defaultDiskCustom = ""
3741

    
3742
defaultDiskResync :: Bool
3743
defaultDiskResync = False
3744

    
3745
-- | Default fill target measured in sectors
3746
defaultFillTarget :: Int
3747
defaultFillTarget = 0
3748

    
3749
-- | Default mininum rate measured in KiB/s
3750
defaultMinRate :: Int
3751
defaultMinRate = 4 * 1024
3752

    
3753
defaultNetCustom :: String
3754
defaultNetCustom = ""
3755

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

    
3766
defaultRbdPool :: String
3767
defaultRbdPool = "rbd"
3768

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

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

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

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

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

    
3881
masterPoolSizeDefault :: Int
3882
masterPoolSizeDefault = 10
3883

    
3884
-- * Exclusive storage
3885

    
3886
-- | Error margin used to compare physical disks
3887
partMargin :: Double
3888
partMargin = 0.01
3889

    
3890
-- | Space reserved when creating instance disks
3891
partReserved :: Double
3892
partReserved = 0.02
3893

    
3894
-- * Confd
3895

    
3896
confdProtocolVersion :: Int
3897
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3898

    
3899
-- Confd request type
3900

    
3901
confdReqPing :: Int
3902
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3903

    
3904
confdReqNodeRoleByname :: Int
3905
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3906

    
3907
confdReqNodePipByInstanceIp :: Int
3908
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3909

    
3910
confdReqClusterMaster :: Int
3911
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3912

    
3913
confdReqNodePipList :: Int
3914
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3915

    
3916
confdReqMcPipList :: Int
3917
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3918

    
3919
confdReqInstancesIpsList :: Int
3920
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3921

    
3922
confdReqNodeDrbd :: Int
3923
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3924

    
3925
confdReqNodeInstances :: Int
3926
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3927

    
3928
confdReqs :: FrozenSet Int
3929
confdReqs =
3930
  ConstantUtils.mkSet .
3931
  map Types.confdRequestTypeToRaw $
3932
  [minBound..] \\ [ReqNodeInstances]
3933

    
3934
-- * Confd request type
3935

    
3936
confdReqfieldName :: Int
3937
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3938

    
3939
confdReqfieldIp :: Int
3940
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3941

    
3942
confdReqfieldMnodePip :: Int
3943
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3944

    
3945
-- * Confd repl status
3946

    
3947
confdReplStatusOk :: Int
3948
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3949

    
3950
confdReplStatusError :: Int
3951
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3952

    
3953
confdReplStatusNotimplemented :: Int
3954
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3955

    
3956
confdReplStatuses :: FrozenSet Int
3957
confdReplStatuses =
3958
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3959

    
3960
-- * Confd node role
3961

    
3962
confdNodeRoleMaster :: Int
3963
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3964

    
3965
confdNodeRoleCandidate :: Int
3966
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3967

    
3968
confdNodeRoleOffline :: Int
3969
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3970

    
3971
confdNodeRoleDrained :: Int
3972
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3973

    
3974
confdNodeRoleRegular :: Int
3975
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3976

    
3977
-- * A few common errors for confd
3978

    
3979
confdErrorUnknownEntry :: Int
3980
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3981

    
3982
confdErrorInternal :: Int
3983
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3984

    
3985
confdErrorArgument :: Int
3986
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3987

    
3988
-- * Confd request query fields
3989

    
3990
confdReqqLink :: String
3991
confdReqqLink = ConstantUtils.confdReqqLink
3992

    
3993
confdReqqIp :: String
3994
confdReqqIp = ConstantUtils.confdReqqIp
3995

    
3996
confdReqqIplist :: String
3997
confdReqqIplist = ConstantUtils.confdReqqIplist
3998

    
3999
confdReqqFields :: String
4000
confdReqqFields = ConstantUtils.confdReqqFields
4001

    
4002
-- | Each request is "salted" by the current timestamp.
4003
--
4004
-- This constant decides how many seconds of skew to accept.
4005
--
4006
-- TODO: make this a default and allow the value to be more
4007
-- configurable
4008
confdMaxClockSkew :: Int
4009
confdMaxClockSkew = 2 * nodeMaxClockSkew
4010

    
4011
-- | When we haven't reloaded the config for more than this amount of
4012
-- seconds, we force a test to see if inotify is betraying us. Using a
4013
-- prime number to ensure we get less chance of 'same wakeup' with
4014
-- other processes.
4015
confdConfigReloadTimeout :: Int
4016
confdConfigReloadTimeout = 17
4017

    
4018
-- | If we receive more than one update in this amount of
4019
-- microseconds, we move to polling every RATELIMIT seconds, rather
4020
-- than relying on inotify, to be able to serve more requests.
4021
confdConfigReloadRatelimit :: Int
4022
confdConfigReloadRatelimit = 250000
4023

    
4024
-- | Magic number prepended to all confd queries.
4025
--
4026
-- This allows us to distinguish different types of confd protocols
4027
-- and handle them. For example by changing this we can move the whole
4028
-- payload to be compressed, or move away from json.
4029
confdMagicFourcc :: String
4030
confdMagicFourcc = "plj0"
4031

    
4032
-- | By default a confd request is sent to the minimum between this
4033
-- number and all MCs. 6 was chosen because even in the case of a
4034
-- disastrous 50% response rate, we should have enough answers to be
4035
-- able to compare more than one.
4036
confdDefaultReqCoverage :: Int
4037
confdDefaultReqCoverage = 6
4038

    
4039
-- | Timeout in seconds to expire pending query request in the confd
4040
-- client library. We don't actually expect any answer more than 10
4041
-- seconds after we sent a request.
4042
confdClientExpireTimeout :: Int
4043
confdClientExpireTimeout = 10
4044

    
4045
-- | Maximum UDP datagram size.
4046
--
4047
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4048
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4049
--   (assuming we can't use jumbo frames)
4050
-- We just set this to 60K, which should be enough
4051
maxUdpDataSize :: Int
4052
maxUdpDataSize = 61440
4053

    
4054
-- * User-id pool minimum/maximum acceptable user-ids
4055

    
4056
uidpoolUidMin :: Int
4057
uidpoolUidMin = 0
4058

    
4059
-- | Assuming 32 bit user-ids
4060
uidpoolUidMax :: Integer
4061
uidpoolUidMax = 2 ^ 32 - 1
4062

    
4063
-- | Name or path of the pgrep command
4064
pgrep :: String
4065
pgrep = "pgrep"
4066

    
4067
-- | Name of the node group that gets created at cluster init or
4068
-- upgrade
4069
initialNodeGroupName :: String
4070
initialNodeGroupName = "default"
4071

    
4072
-- * Possible values for NodeGroup.alloc_policy
4073

    
4074
allocPolicyLastResort :: String
4075
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4076

    
4077
allocPolicyPreferred :: String
4078
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4079

    
4080
allocPolicyUnallocable :: String
4081
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4082

    
4083
validAllocPolicies :: [String]
4084
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4085

    
4086
-- | Temporary external/shared storage parameters
4087
blockdevDriverManual :: String
4088
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4089

    
4090
-- | 'qemu-img' path, required for 'ovfconverter'
4091
qemuimgPath :: String
4092
qemuimgPath = AutoConf.qemuimgPath
4093

    
4094
-- | Whether htools was enabled at compilation time
4095
--
4096
-- FIXME: this should be moved next to the other enable constants,
4097
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4098
htools :: Bool
4099
htools = AutoConf.htools
4100

    
4101
-- | The hail iallocator
4102
iallocHail :: String
4103
iallocHail = "hail"
4104

    
4105
-- * Fake opcodes for functions that have hooks attached to them via
4106
-- backend.RunLocalHooks
4107

    
4108
fakeOpMasterTurndown :: String
4109
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4110

    
4111
fakeOpMasterTurnup :: String
4112
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4113

    
4114
-- * SSH key types
4115

    
4116
sshkDsa :: String
4117
sshkDsa = "dsa"
4118

    
4119
sshkRsa :: String
4120
sshkRsa = "rsa"
4121

    
4122
sshkAll :: FrozenSet String
4123
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4124

    
4125
-- * SSH authorized key types
4126

    
4127
sshakDss :: String
4128
sshakDss = "ssh-dss"
4129

    
4130
sshakRsa :: String
4131
sshakRsa = "ssh-rsa"
4132

    
4133
sshakAll :: FrozenSet String
4134
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4135

    
4136
-- * SSH setup
4137

    
4138
sshsClusterName :: String
4139
sshsClusterName = "cluster_name"
4140

    
4141
sshsSshHostKey :: String
4142
sshsSshHostKey = "ssh_host_key"
4143

    
4144
sshsSshRootKey :: String
4145
sshsSshRootKey = "ssh_root_key"
4146

    
4147
sshsNodeDaemonCertificate :: String
4148
sshsNodeDaemonCertificate = "node_daemon_certificate"
4149

    
4150
-- * Key files for SSH daemon
4151

    
4152
sshHostDsaPriv :: String
4153
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4154

    
4155
sshHostDsaPub :: String
4156
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4157

    
4158
sshHostRsaPriv :: String
4159
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4160

    
4161
sshHostRsaPub :: String
4162
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4163

    
4164
sshDaemonKeyfiles :: Map String (String, String)
4165
sshDaemonKeyfiles =
4166
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4167
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4168
               ]
4169

    
4170
-- * Node daemon setup
4171

    
4172
ndsClusterName :: String
4173
ndsClusterName = "cluster_name"
4174

    
4175
ndsNodeDaemonCertificate :: String
4176
ndsNodeDaemonCertificate = "node_daemon_certificate"
4177

    
4178
ndsSsconf :: String
4179
ndsSsconf = "ssconf"
4180

    
4181
ndsStartNodeDaemon :: String
4182
ndsStartNodeDaemon = "start_node_daemon"
4183

    
4184
-- * The source reasons for the execution of an OpCode
4185

    
4186
opcodeReasonSrcClient :: String
4187
opcodeReasonSrcClient = "gnt:client"
4188

    
4189
opcodeReasonSrcNoded :: String
4190
opcodeReasonSrcNoded = "gnt:daemon:noded"
4191

    
4192
opcodeReasonSrcOpcode :: String
4193
opcodeReasonSrcOpcode = "gnt:opcode"
4194

    
4195
opcodeReasonSrcRlib2 :: String
4196
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4197

    
4198
opcodeReasonSrcUser :: String
4199
opcodeReasonSrcUser = "gnt:user"
4200

    
4201
opcodeReasonSources :: FrozenSet String
4202
opcodeReasonSources =
4203
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4204
                       opcodeReasonSrcNoded,
4205
                       opcodeReasonSrcOpcode,
4206
                       opcodeReasonSrcRlib2,
4207
                       opcodeReasonSrcUser]
4208

    
4209
-- | Path generating random UUID
4210
randomUuidFile :: String
4211
randomUuidFile = ConstantUtils.randomUuidFile
4212

    
4213
-- * Auto-repair tag prefixes
4214

    
4215
autoRepairTagPrefix :: String
4216
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4217

    
4218
autoRepairTagEnabled :: String
4219
autoRepairTagEnabled = autoRepairTagPrefix
4220

    
4221
autoRepairTagPending :: String
4222
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4223

    
4224
autoRepairTagResult :: String
4225
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4226

    
4227
autoRepairTagSuspended :: String
4228
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4229

    
4230
-- * Auto-repair levels
4231

    
4232
autoRepairFailover :: String
4233
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4234

    
4235
autoRepairFixStorage :: String
4236
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4237

    
4238
autoRepairMigrate :: String
4239
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4240

    
4241
autoRepairReinstall :: String
4242
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4243

    
4244
autoRepairAllTypes :: FrozenSet String
4245
autoRepairAllTypes =
4246
  ConstantUtils.mkSet [autoRepairFailover,
4247
                       autoRepairFixStorage,
4248
                       autoRepairMigrate,
4249
                       autoRepairReinstall]
4250

    
4251
-- * Auto-repair results
4252

    
4253
autoRepairEnoperm :: String
4254
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4255

    
4256
autoRepairFailure :: String
4257
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4258

    
4259
autoRepairSuccess :: String
4260
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4261

    
4262
autoRepairAllResults :: FrozenSet String
4263
autoRepairAllResults =
4264
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4265

    
4266
-- | The version identifier for builtin data collectors
4267
builtinDataCollectorVersion :: String
4268
builtinDataCollectorVersion = "B"
4269

    
4270
-- | The reason trail opcode parameter name
4271
opcodeReason :: String
4272
opcodeReason = "reason"
4273

    
4274
-- | The reason trail opcode parameter name
4275
opcodeSequential :: String
4276
opcodeSequential = "sequential"
4277

    
4278
diskstatsFile :: String
4279
diskstatsFile = "/proc/diskstats"
4280

    
4281
-- *  CPU load collector
4282

    
4283
statFile :: String
4284
statFile = "/proc/stat"
4285

    
4286
cpuavgloadBufferSize :: Int
4287
cpuavgloadBufferSize = 150
4288

    
4289
cpuavgloadWindowSize :: Int
4290
cpuavgloadWindowSize = 600
4291

    
4292
-- * Monitoring daemon
4293

    
4294
-- | Mond's variable for periodical data collection
4295
mondTimeInterval :: Int
4296
mondTimeInterval = 5
4297

    
4298
-- | Mond's latest API version
4299
mondLatestApiVersion :: Int
4300
mondLatestApiVersion = 1
4301

    
4302
-- * Disk access modes
4303

    
4304
diskUserspace :: String
4305
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4306

    
4307
diskKernelspace :: String
4308
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4309

    
4310
diskValidAccessModes :: FrozenSet String
4311
diskValidAccessModes =
4312
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4313

    
4314
-- | Timeout for queue draining in upgrades
4315
upgradeQueueDrainTimeout :: Int
4316
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4317

    
4318
-- | Intervall at which the queue is polled during upgrades
4319
upgradeQueuePollInterval :: Int
4320
upgradeQueuePollInterval  = 10
4321

    
4322
-- * Hotplug Actions
4323

    
4324
hotplugActionAdd :: String
4325
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4326

    
4327
hotplugActionRemove :: String
4328
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4329

    
4330
hotplugActionModify :: String
4331
hotplugActionModify = Types.hotplugActionToRaw HAMod
4332

    
4333
hotplugAllActions :: FrozenSet String
4334
hotplugAllActions =
4335
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4336

    
4337
-- * Hotplug Device Targets
4338

    
4339
hotplugTargetNic :: String
4340
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4341

    
4342
hotplugTargetDisk :: String
4343
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4344

    
4345
hotplugAllTargets :: FrozenSet String
4346
hotplugAllTargets =
4347
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4348

    
4349
-- | Timeout for disk removal (seconds)
4350
diskRemoveRetryTimeout :: Int
4351
diskRemoveRetryTimeout = 30
4352

    
4353
-- | Interval between disk removal retries (seconds)
4354
diskRemoveRetryInterval :: Int
4355
diskRemoveRetryInterval  = 3
4356

    
4357
-- * UUID regex
4358

    
4359
uuidRegex :: String
4360
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4361

    
4362
-- * Luxi constants
4363

    
4364
luxiSocketPerms :: Int
4365
luxiSocketPerms = 0o660
4366

    
4367
luxiKeyMethod :: String
4368
luxiKeyMethod = "method"
4369

    
4370
luxiKeyArgs :: String
4371
luxiKeyArgs = "args"
4372

    
4373
luxiKeySuccess :: String
4374
luxiKeySuccess = "success"
4375

    
4376
luxiKeyResult :: String
4377
luxiKeyResult = "result"
4378

    
4379
luxiKeyVersion :: String
4380
luxiKeyVersion = "version"
4381

    
4382
luxiReqSubmitJob :: String
4383
luxiReqSubmitJob = "SubmitJob"
4384

    
4385
luxiReqSubmitJobToDrainedQueue :: String
4386
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4387

    
4388
luxiReqSubmitManyJobs :: String
4389
luxiReqSubmitManyJobs = "SubmitManyJobs"
4390

    
4391
luxiReqWaitForJobChange :: String
4392
luxiReqWaitForJobChange = "WaitForJobChange"
4393

    
4394
luxiReqCancelJob :: String
4395
luxiReqCancelJob = "CancelJob"
4396

    
4397
luxiReqArchiveJob :: String
4398
luxiReqArchiveJob = "ArchiveJob"
4399

    
4400
luxiReqChangeJobPriority :: String
4401
luxiReqChangeJobPriority = "ChangeJobPriority"
4402

    
4403
luxiReqAutoArchiveJobs :: String
4404
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4405

    
4406
luxiReqQuery :: String
4407
luxiReqQuery = "Query"
4408

    
4409
luxiReqQueryFields :: String
4410
luxiReqQueryFields = "QueryFields"
4411

    
4412
luxiReqQueryJobs :: String
4413
luxiReqQueryJobs = "QueryJobs"
4414

    
4415
luxiReqQueryInstances :: String
4416
luxiReqQueryInstances = "QueryInstances"
4417

    
4418
luxiReqQueryNodes :: String
4419
luxiReqQueryNodes = "QueryNodes"
4420

    
4421
luxiReqQueryGroups :: String
4422
luxiReqQueryGroups = "QueryGroups"
4423

    
4424
luxiReqQueryNetworks :: String
4425
luxiReqQueryNetworks = "QueryNetworks"
4426

    
4427
luxiReqQueryExports :: String
4428
luxiReqQueryExports = "QueryExports"
4429

    
4430
luxiReqQueryConfigValues :: String
4431
luxiReqQueryConfigValues = "QueryConfigValues"
4432

    
4433
luxiReqQueryClusterInfo :: String
4434
luxiReqQueryClusterInfo = "QueryClusterInfo"
4435

    
4436
luxiReqQueryTags :: String
4437
luxiReqQueryTags = "QueryTags"
4438

    
4439
luxiReqSetDrainFlag :: String
4440
luxiReqSetDrainFlag = "SetDrainFlag"
4441

    
4442
luxiReqSetWatcherPause :: String
4443
luxiReqSetWatcherPause = "SetWatcherPause"
4444

    
4445
luxiReqAll :: FrozenSet String
4446
luxiReqAll =
4447
  ConstantUtils.mkSet
4448
  [ luxiReqArchiveJob
4449
  , luxiReqAutoArchiveJobs
4450
  , luxiReqCancelJob
4451
  , luxiReqChangeJobPriority
4452
  , luxiReqQuery
4453
  , luxiReqQueryClusterInfo
4454
  , luxiReqQueryConfigValues
4455
  , luxiReqQueryExports
4456
  , luxiReqQueryFields
4457
  , luxiReqQueryGroups
4458
  , luxiReqQueryInstances
4459
  , luxiReqQueryJobs
4460
  , luxiReqQueryNodes
4461
  , luxiReqQueryNetworks
4462
  , luxiReqQueryTags
4463
  , luxiReqSetDrainFlag
4464
  , luxiReqSetWatcherPause
4465
  , luxiReqSubmitJob
4466
  , luxiReqSubmitJobToDrainedQueue
4467
  , luxiReqSubmitManyJobs
4468
  , luxiReqWaitForJobChange
4469
  ]
4470

    
4471
luxiDefCtmo :: Int
4472
luxiDefCtmo = 10
4473

    
4474
luxiDefRwto :: Int
4475
luxiDefRwto = 60
4476

    
4477
-- | 'WaitForJobChange' timeout
4478
luxiWfjcTimeout :: Int
4479
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4480

    
4481
-- * Query language constants
4482

    
4483
-- ** Logic operators with one or more operands, each of which is a
4484
-- filter on its own
4485

    
4486
qlangOpAnd :: String
4487
qlangOpAnd = "&"
4488

    
4489
qlangOpOr :: String
4490
qlangOpOr = "|"
4491

    
4492
-- ** Unary operators with exactly one operand
4493

    
4494
qlangOpNot :: String
4495
qlangOpNot = "!"
4496

    
4497
qlangOpTrue :: String
4498
qlangOpTrue = "?"
4499

    
4500
-- ** Binary operators with exactly two operands, the field name and
4501
-- an operator-specific value
4502

    
4503
qlangOpContains :: String
4504
qlangOpContains = "=[]"
4505

    
4506
qlangOpEqual :: String
4507
qlangOpEqual = "="
4508

    
4509
qlangOpGe :: String
4510
qlangOpGe = ">="
4511

    
4512
qlangOpGt :: String
4513
qlangOpGt = ">"
4514

    
4515
qlangOpLe :: String
4516
qlangOpLe = "<="
4517

    
4518
qlangOpLt :: String
4519
qlangOpLt = "<"
4520

    
4521
qlangOpNotEqual :: String
4522
qlangOpNotEqual = "!="
4523

    
4524
qlangOpRegexp :: String
4525
qlangOpRegexp = "=~"
4526

    
4527
-- | Characters used for detecting user-written filters (see
4528
-- L{_CheckFilter})
4529

    
4530
qlangFilterDetectionChars :: FrozenSet String
4531
qlangFilterDetectionChars =
4532
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4533
                       ")", "(", "\x0b", "\n",
4534
                       "\r", "\x0c", "/", "<",
4535
                       "\t", ">", "=", "\\", "~"]
4536

    
4537
-- | Characters used to detect globbing filters
4538
qlangGlobDetectionChars :: FrozenSet String
4539
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4540

    
4541
-- * Error related constants
4542
--
4543
-- 'OpPrereqError' failure types
4544

    
4545
-- | Environment error (e.g. node disk error)
4546
errorsEcodeEnviron :: String
4547
errorsEcodeEnviron = "environment_error"
4548

    
4549
-- | Entity already exists
4550
errorsEcodeExists :: String
4551
errorsEcodeExists = "already_exists"
4552

    
4553
-- | Internal cluster error
4554
errorsEcodeFault :: String
4555
errorsEcodeFault = "internal_error"
4556

    
4557
-- | Wrong arguments (at syntax level)
4558
errorsEcodeInval :: String
4559
errorsEcodeInval = "wrong_input"
4560

    
4561
-- | Entity not found
4562
errorsEcodeNoent :: String
4563
errorsEcodeNoent = "unknown_entity"
4564

    
4565
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4566
errorsEcodeNores :: String
4567
errorsEcodeNores = "insufficient_resources"
4568

    
4569
-- | Resource not unique (e.g. MAC or IP duplication)
4570
errorsEcodeNotunique :: String
4571
errorsEcodeNotunique = "resource_not_unique"
4572

    
4573
-- | Resolver errors
4574
errorsEcodeResolver :: String
4575
errorsEcodeResolver = "resolver_error"
4576

    
4577
-- | Wrong entity state
4578
errorsEcodeState :: String
4579
errorsEcodeState = "wrong_state"
4580

    
4581
-- | Temporarily out of resources; operation can be tried again
4582
errorsEcodeTempNores :: String
4583
errorsEcodeTempNores = "temp_insufficient_resources"
4584

    
4585
errorsEcodeAll :: FrozenSet String
4586
errorsEcodeAll =
4587
  ConstantUtils.mkSet [ errorsEcodeNores
4588
                      , errorsEcodeExists
4589
                      , errorsEcodeState
4590
                      , errorsEcodeNotunique
4591
                      , errorsEcodeTempNores
4592
                      , errorsEcodeNoent
4593
                      , errorsEcodeFault
4594
                      , errorsEcodeResolver
4595
                      , errorsEcodeInval
4596
                      , errorsEcodeEnviron
4597
                      ]
4598

    
4599
-- * Jstore related constants
4600

    
4601
jstoreJobsPerArchiveDirectory :: Int
4602
jstoreJobsPerArchiveDirectory = 10000