Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ d3e6fd0e

History | View | Annotate | Download (115 kB)

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

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

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

    
15
-}
16

    
17
{-
18

    
19
Copyright (C) 2013 Google Inc.
20

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

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

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

    
36
-}
37
module Ganeti.Constants where
38

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

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

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

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

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

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

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

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

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

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

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

    
86
-- ** Build-time constants
87

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
135
-- * Various versions
136

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

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

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

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

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

    
152
osApiV10 :: Int
153
osApiV10 = 10
154

    
155
osApiV15 :: Int
156
osApiV15 = 15
157

    
158
osApiV20 :: Int
159
osApiV20 = 20
160

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

    
164
exportVersion :: Int
165
exportVersion = 0
166

    
167
rapiVersion :: Int
168
rapiVersion = 2
169

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

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

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

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

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

    
189
-- * User separation
190

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

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

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

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

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

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

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

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

    
215
luxidUser :: String
216
luxidUser = Runtime.daemonUser GanetiLuxid
217

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

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

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

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

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

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

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

    
239
-- * Cpu pinning separators and constants
240

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

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

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

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

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

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

    
279
-- * Wipe
280

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

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

    
288
minWipeChunkPercent :: Int
289
minWipeChunkPercent = 10
290

    
291
-- * Directories
292

    
293
runDirsMode :: Int
294
runDirsMode = 0o775
295

    
296
secureDirMode :: Int
297
secureDirMode = 0o700
298

    
299
secureFileMode :: Int
300
secureFileMode = 0o600
301

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

    
305
-- * 'autoconf' enable/disable
306

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

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

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

    
316
-- * SSH constants
317

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

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

    
324
-- * Daemons
325

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

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

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

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

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

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

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

    
353
defaultConfdPort :: Int
354
defaultConfdPort = 1814
355

    
356
defaultMondPort :: Int
357
defaultMondPort = 1815
358

    
359
defaultNodedPort :: Int
360
defaultNodedPort = 1811
361

    
362
defaultRapiPort :: Int
363
defaultRapiPort = 5080
364

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

    
373
firstDrbdPort :: Int
374
firstDrbdPort = 11000
375

    
376
lastDrbdPort :: Int
377
lastDrbdPort = 14999
378

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

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

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

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

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

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

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

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

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

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

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

    
421
luxiVersion :: Int
422
luxiVersion = configVersion
423

    
424
-- * Syslog
425

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

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

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

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

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

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

    
444
-- * Xen
445

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

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

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

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

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

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

    
466
-- * KVM and socat
467

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

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

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

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

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

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

    
486
-- * Console types
487

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

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

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

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

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

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

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

    
526
-- * X509
527

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

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

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

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

    
543
-- * Import/export daemon mode
544

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

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

    
551
-- * Import/export transport compression
552

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

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

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

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

    
565
-- * Import/export I/O
566

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

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

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

    
580
-- * Values
581

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

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

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

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

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

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

    
600
-- * Hooks
601

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

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

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

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

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

    
617
hooksVersion :: Int
618
hooksVersion = 2
619

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

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

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

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

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

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

    
637
-- * Hkr
638

    
639
hkrSkip :: Int
640
hkrSkip = 0
641

    
642
hkrFail :: Int
643
hkrFail = 1
644

    
645
hkrSuccess :: Int
646
hkrSuccess = 2
647

    
648
-- * Storage types
649

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

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

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

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

    
662
stLvmPv :: String
663
stLvmPv = Types.storageTypeToRaw StorageLvmPv
664

    
665
stLvmVg :: String
666
stLvmVg = Types.storageTypeToRaw StorageLvmVg
667

    
668
stRados :: String
669
stRados = Types.storageTypeToRaw StorageRados
670

    
671
storageTypes :: FrozenSet String
672
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
673

    
674
-- | The set of storage types for which storage reporting is available
675
--
676
-- FIXME: Remove this, once storage reporting is available for all
677
-- types.
678
stsReport :: FrozenSet String
679
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
680

    
681
-- * Storage fields
682
-- ** First two are valid in LU context only, not passed to backend
683

    
684
sfNode :: String
685
sfNode = "node"
686

    
687
sfType :: String
688
sfType = "type"
689

    
690
-- ** and the rest are valid in backend
691

    
692
sfAllocatable :: String
693
sfAllocatable = Types.storageFieldToRaw SFAllocatable
694

    
695
sfFree :: String
696
sfFree = Types.storageFieldToRaw SFFree
697

    
698
sfName :: String
699
sfName = Types.storageFieldToRaw SFName
700

    
701
sfSize :: String
702
sfSize = Types.storageFieldToRaw SFSize
703

    
704
sfUsed :: String
705
sfUsed = Types.storageFieldToRaw SFUsed
706

    
707
validStorageFields :: FrozenSet String
708
validStorageFields =
709
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
710
                        [sfNode, sfType]
711

    
712
modifiableStorageFields :: Map String (FrozenSet String)
713
modifiableStorageFields =
714
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
715
                 ConstantUtils.mkSet [sfAllocatable])]
716

    
717
-- * Storage operations
718

    
719
soFixConsistency :: String
720
soFixConsistency = "fix-consistency"
721

    
722
validStorageOperations :: Map String (FrozenSet String)
723
validStorageOperations =
724
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
725
                 ConstantUtils.mkSet [soFixConsistency])]
726

    
727
-- * Volume fields
728

    
729
vfDev :: String
730
vfDev = "dev"
731

    
732
vfInstance :: String
733
vfInstance = "instance"
734

    
735
vfName :: String
736
vfName = "name"
737

    
738
vfNode :: String
739
vfNode = "node"
740

    
741
vfPhys :: String
742
vfPhys = "phys"
743

    
744
vfSize :: String
745
vfSize = "size"
746

    
747
vfVg :: String
748
vfVg = "vg"
749

    
750
-- * Local disk status
751

    
752
ldsFaulty :: Int
753
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
754

    
755
ldsOkay :: Int
756
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
757

    
758
ldsUnknown :: Int
759
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
760

    
761
ldsNames :: Map Int String
762
ldsNames =
763
  Map.fromList [ (Types.localDiskStatusToRaw ds,
764
                  localDiskStatusName ds) | ds <- [minBound..] ]
765

    
766
-- * Disk template types
767

    
768
dtDiskless :: String
769
dtDiskless = Types.diskTemplateToRaw DTDiskless
770

    
771
dtFile :: String
772
dtFile = Types.diskTemplateToRaw DTFile
773

    
774
dtSharedFile :: String
775
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
776

    
777
dtPlain :: String
778
dtPlain = Types.diskTemplateToRaw DTPlain
779

    
780
dtBlock :: String
781
dtBlock = Types.diskTemplateToRaw DTBlock
782

    
783
dtDrbd8 :: String
784
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
785

    
786
dtRbd :: String
787
dtRbd = Types.diskTemplateToRaw DTRbd
788

    
789
dtExt :: String
790
dtExt = Types.diskTemplateToRaw DTExt
791

    
792
dtGluster :: String
793
dtGluster = Types.diskTemplateToRaw DTGluster
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,
804
   DTPlain, DTRbd, DTSharedFile, DTGluster]
805

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

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

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

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

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

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

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

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

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

    
862
-- | The set of disk templates that allow migrations
863
dtsMirrored :: FrozenSet String
864
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
865

    
866
-- | The set of file based disk templates
867
dtsFilebased :: FrozenSet String
868
dtsFilebased =
869
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw
870
  [DTSharedFile, DTFile, DTGluster]
871

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

    
880
-- | The set of disk templates that are supported by exclusive_storage
881
dtsExclStorage :: FrozenSet String
882
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
883

    
884
-- | Templates for which we don't perform checks on free space
885
dtsNoFreeSpaceCheck :: FrozenSet String
886
dtsNoFreeSpaceCheck =
887
  ConstantUtils.mkSet $
888
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd, DTGluster]
889

    
890
dtsBlock :: FrozenSet String
891
dtsBlock =
892
  ConstantUtils.mkSet $
893
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
894

    
895
-- | The set of lvm-based disk templates
896
dtsLvm :: FrozenSet String
897
dtsLvm = diskTemplates `ConstantUtils.difference` dtsNotLvm
898

    
899
-- * Drbd
900

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

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

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

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

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

    
917
-- * Drbd barrier types
918

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

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

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

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

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

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

    
949
-- * File backend driver
950

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

    
954
fdLoop :: String
955
fdLoop = Types.fileDriverToRaw FileLoop
956

    
957
fileDriver :: FrozenSet String
958
fileDriver =
959
  ConstantUtils.mkSet $
960
  map Types.fileDriverToRaw [minBound..]
961

    
962
-- | The set of drbd-like disk types
963
dtsDrbd :: FrozenSet String
964
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
965

    
966
-- * Disk access mode
967

    
968
diskRdonly :: String
969
diskRdonly = Types.diskModeToRaw DiskRdOnly
970

    
971
diskRdwr :: String
972
diskRdwr = Types.diskModeToRaw DiskRdWr
973

    
974
diskAccessSet :: FrozenSet String
975
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
976

    
977
-- * Disk replacement mode
978

    
979
replaceDiskAuto :: String
980
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
981

    
982
replaceDiskChg :: String
983
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
984

    
985
replaceDiskPri :: String
986
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
987

    
988
replaceDiskSec :: String
989
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
990

    
991
replaceModes :: FrozenSet String
992
replaceModes =
993
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
994

    
995
-- * Instance export mode
996

    
997
exportModeLocal :: String
998
exportModeLocal = Types.exportModeToRaw ExportModeLocal
999

    
1000
exportModeRemote :: String
1001
exportModeRemote = Types.exportModeToRaw ExportModeRemote
1002

    
1003
exportModes :: FrozenSet String
1004
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
1005

    
1006
-- * Instance creation modes
1007

    
1008
instanceCreate :: String
1009
instanceCreate = Types.instCreateModeToRaw InstCreate
1010

    
1011
instanceImport :: String
1012
instanceImport = Types.instCreateModeToRaw InstImport
1013

    
1014
instanceRemoteImport :: String
1015
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1016

    
1017
instanceCreateModes :: FrozenSet String
1018
instanceCreateModes =
1019
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1020

    
1021
-- * Remote import/export handshake message and version
1022

    
1023
rieHandshake :: String
1024
rieHandshake = "Hi, I'm Ganeti"
1025

    
1026
rieVersion :: Int
1027
rieVersion = 0
1028

    
1029
-- | Remote import/export certificate validity (seconds)
1030
rieCertValidity :: Int
1031
rieCertValidity = 24 * 60 * 60
1032

    
1033
-- | Export only: how long to wait per connection attempt (seconds)
1034
rieConnectAttemptTimeout :: Int
1035
rieConnectAttemptTimeout = 20
1036

    
1037
-- | Export only: number of attempts to connect
1038
rieConnectRetries :: Int
1039
rieConnectRetries = 10
1040

    
1041
-- | Overall timeout for establishing connection
1042
rieConnectTimeout :: Int
1043
rieConnectTimeout = 180
1044

    
1045
-- | Give child process up to 5 seconds to exit after sending a signal
1046
childLingerTimeout :: Double
1047
childLingerTimeout = 5.0
1048

    
1049
-- * Import/export config options
1050

    
1051
inisectBep :: String
1052
inisectBep = "backend"
1053

    
1054
inisectExp :: String
1055
inisectExp = "export"
1056

    
1057
inisectHyp :: String
1058
inisectHyp = "hypervisor"
1059

    
1060
inisectIns :: String
1061
inisectIns = "instance"
1062

    
1063
inisectOsp :: String
1064
inisectOsp = "os"
1065

    
1066
-- * Dynamic device modification
1067

    
1068
ddmAdd :: String
1069
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1070

    
1071
ddmModify :: String
1072
ddmModify = Types.ddmFullToRaw DdmFullModify
1073

    
1074
ddmRemove :: String
1075
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1076

    
1077
ddmsValues :: FrozenSet String
1078
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1079

    
1080
ddmsValuesWithModify :: FrozenSet String
1081
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1082

    
1083
-- * Common exit codes
1084

    
1085
exitSuccess :: Int
1086
exitSuccess = 0
1087

    
1088
exitFailure :: Int
1089
exitFailure = ConstantUtils.exitFailure
1090

    
1091
exitNotcluster :: Int
1092
exitNotcluster = 5
1093

    
1094
exitNotmaster :: Int
1095
exitNotmaster = 11
1096

    
1097
exitNodesetupError :: Int
1098
exitNodesetupError = 12
1099

    
1100
-- | Need user confirmation
1101
exitConfirmation :: Int
1102
exitConfirmation = 13
1103

    
1104
-- | Exit code for query operations with unknown fields
1105
exitUnknownField :: Int
1106
exitUnknownField = 14
1107

    
1108
-- * Tags
1109

    
1110
tagCluster :: String
1111
tagCluster = Types.tagKindToRaw TagKindCluster
1112

    
1113
tagInstance :: String
1114
tagInstance = Types.tagKindToRaw TagKindInstance
1115

    
1116
tagNetwork :: String
1117
tagNetwork = Types.tagKindToRaw TagKindNetwork
1118

    
1119
tagNode :: String
1120
tagNode = Types.tagKindToRaw TagKindNode
1121

    
1122
tagNodegroup :: String
1123
tagNodegroup = Types.tagKindToRaw TagKindGroup
1124

    
1125
validTagTypes :: FrozenSet String
1126
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1127

    
1128
maxTagLen :: Int
1129
maxTagLen = 128
1130

    
1131
maxTagsPerObj :: Int
1132
maxTagsPerObj = 4096
1133

    
1134
-- * Others
1135

    
1136
defaultBridge :: String
1137
defaultBridge = "xen-br0"
1138

    
1139
defaultOvs :: String
1140
defaultOvs = "switch1"
1141

    
1142
-- | 60 MiB/s, expressed in KiB/s
1143
classicDrbdSyncSpeed :: Int
1144
classicDrbdSyncSpeed = 60 * 1024
1145

    
1146
ip4AddressAny :: String
1147
ip4AddressAny = "0.0.0.0"
1148

    
1149
ip4AddressLocalhost :: String
1150
ip4AddressLocalhost = "127.0.0.1"
1151

    
1152
ip6AddressAny :: String
1153
ip6AddressAny = "::"
1154

    
1155
ip6AddressLocalhost :: String
1156
ip6AddressLocalhost = "::1"
1157

    
1158
ip4Version :: Int
1159
ip4Version = 4
1160

    
1161
ip6Version :: Int
1162
ip6Version = 6
1163

    
1164
validIpVersions :: FrozenSet Int
1165
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1166

    
1167
tcpPingTimeout :: Int
1168
tcpPingTimeout = 10
1169

    
1170
defaultVg :: String
1171
defaultVg = "xenvg"
1172

    
1173
defaultDrbdHelper :: String
1174
defaultDrbdHelper = "/bin/true"
1175

    
1176
minVgSize :: Int
1177
minVgSize = 20480
1178

    
1179
defaultMacPrefix :: String
1180
defaultMacPrefix = "aa:00:00"
1181

    
1182
-- | Default maximum instance wait time (seconds)
1183
defaultShutdownTimeout :: Int
1184
defaultShutdownTimeout = 120
1185

    
1186
-- | Node clock skew (seconds)
1187
nodeMaxClockSkew :: Int
1188
nodeMaxClockSkew = 150
1189

    
1190
-- | Time for an intra-cluster disk transfer to wait for a connection
1191
diskTransferConnectTimeout :: Int
1192
diskTransferConnectTimeout = 60
1193

    
1194
-- | Disk index separator
1195
diskSeparator :: String
1196
diskSeparator = AutoConf.diskSeparator
1197

    
1198
ipCommandPath :: String
1199
ipCommandPath = AutoConf.ipPath
1200

    
1201
-- | Key for job IDs in opcode result
1202
jobIdsKey :: String
1203
jobIdsKey = "jobs"
1204

    
1205
-- * Runparts results
1206

    
1207
runpartsErr :: Int
1208
runpartsErr = 2
1209

    
1210
runpartsRun :: Int
1211
runpartsRun = 1
1212

    
1213
runpartsSkip :: Int
1214
runpartsSkip = 0
1215

    
1216
runpartsStatus :: [Int]
1217
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1218

    
1219
-- * RPC
1220

    
1221
rpcEncodingNone :: Int
1222
rpcEncodingNone = 0
1223

    
1224
rpcEncodingZlibBase64 :: Int
1225
rpcEncodingZlibBase64 = 1
1226

    
1227
-- * Timeout table
1228
--
1229
-- Various time constants for the timeout table
1230

    
1231
rpcTmoUrgent :: Int
1232
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1233

    
1234
rpcTmoFast :: Int
1235
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1236

    
1237
rpcTmoNormal :: Int
1238
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1239

    
1240
rpcTmoSlow :: Int
1241
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1242

    
1243
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1244
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1245
-- Python name.
1246
rpcTmo_4hrs :: Int
1247
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1248

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

    
1255
-- | Timeout for connecting to nodes (seconds)
1256
rpcConnectTimeout :: Int
1257
rpcConnectTimeout = 5
1258

    
1259
-- OS
1260

    
1261
osScriptCreate :: String
1262
osScriptCreate = "create"
1263

    
1264
osScriptExport :: String
1265
osScriptExport = "export"
1266

    
1267
osScriptImport :: String
1268
osScriptImport = "import"
1269

    
1270
osScriptRename :: String
1271
osScriptRename = "rename"
1272

    
1273
osScriptVerify :: String
1274
osScriptVerify = "verify"
1275

    
1276
osScripts :: [String]
1277
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1278
             osScriptVerify]
1279

    
1280
osApiFile :: String
1281
osApiFile = "ganeti_api_version"
1282

    
1283
osVariantsFile :: String
1284
osVariantsFile = "variants.list"
1285

    
1286
osParametersFile :: String
1287
osParametersFile = "parameters.list"
1288

    
1289
osValidateParameters :: String
1290
osValidateParameters = "parameters"
1291

    
1292
osValidateCalls :: FrozenSet String
1293
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1294

    
1295
-- | External Storage (ES) related constants
1296

    
1297
esActionAttach :: String
1298
esActionAttach = "attach"
1299

    
1300
esActionCreate :: String
1301
esActionCreate = "create"
1302

    
1303
esActionDetach :: String
1304
esActionDetach = "detach"
1305

    
1306
esActionGrow :: String
1307
esActionGrow = "grow"
1308

    
1309
esActionRemove :: String
1310
esActionRemove = "remove"
1311

    
1312
esActionSetinfo :: String
1313
esActionSetinfo = "setinfo"
1314

    
1315
esActionVerify :: String
1316
esActionVerify = "verify"
1317

    
1318
esScriptCreate :: String
1319
esScriptCreate = esActionCreate
1320

    
1321
esScriptRemove :: String
1322
esScriptRemove = esActionRemove
1323

    
1324
esScriptGrow :: String
1325
esScriptGrow = esActionGrow
1326

    
1327
esScriptAttach :: String
1328
esScriptAttach = esActionAttach
1329

    
1330
esScriptDetach :: String
1331
esScriptDetach = esActionDetach
1332

    
1333
esScriptSetinfo :: String
1334
esScriptSetinfo = esActionSetinfo
1335

    
1336
esScriptVerify :: String
1337
esScriptVerify = esActionVerify
1338

    
1339
esScripts :: FrozenSet String
1340
esScripts =
1341
  ConstantUtils.mkSet [esScriptAttach,
1342
                       esScriptCreate,
1343
                       esScriptDetach,
1344
                       esScriptGrow,
1345
                       esScriptRemove,
1346
                       esScriptSetinfo,
1347
                       esScriptVerify]
1348

    
1349
esParametersFile :: String
1350
esParametersFile = "parameters.list"
1351

    
1352
-- * Reboot types
1353

    
1354
instanceRebootSoft :: String
1355
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1356

    
1357
instanceRebootHard :: String
1358
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1359

    
1360
instanceRebootFull :: String
1361
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1362

    
1363
rebootTypes :: FrozenSet String
1364
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1365

    
1366
-- * Instance reboot behaviors
1367

    
1368
instanceRebootAllowed :: String
1369
instanceRebootAllowed = "reboot"
1370

    
1371
instanceRebootExit :: String
1372
instanceRebootExit = "exit"
1373

    
1374
rebootBehaviors :: [String]
1375
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1376

    
1377
-- * VTypes
1378

    
1379
vtypeBool :: VType
1380
vtypeBool = VTypeBool
1381

    
1382
vtypeInt :: VType
1383
vtypeInt = VTypeInt
1384

    
1385
vtypeMaybeString :: VType
1386
vtypeMaybeString = VTypeMaybeString
1387

    
1388
-- | Size in MiBs
1389
vtypeSize :: VType
1390
vtypeSize = VTypeSize
1391

    
1392
vtypeString :: VType
1393
vtypeString = VTypeString
1394

    
1395
enforceableTypes :: FrozenSet VType
1396
enforceableTypes = ConstantUtils.mkSet [minBound..]
1397

    
1398
-- | Constant representing that the user does not specify any IP version
1399
ifaceNoIpVersionSpecified :: Int
1400
ifaceNoIpVersionSpecified = 0
1401

    
1402
validSerialSpeeds :: [Int]
1403
validSerialSpeeds =
1404
  [75,
1405
   110,
1406
   300,
1407
   600,
1408
   1200,
1409
   1800,
1410
   2400,
1411
   4800,
1412
   9600,
1413
   14400,
1414
   19200,
1415
   28800,
1416
   38400,
1417
   57600,
1418
   115200,
1419
   230400,
1420
   345600,
1421
   460800]
1422

    
1423
-- * HV parameter names (global namespace)
1424

    
1425
hvAcpi :: String
1426
hvAcpi = "acpi"
1427

    
1428
hvBlockdevPrefix :: String
1429
hvBlockdevPrefix = "blockdev_prefix"
1430

    
1431
hvBootloaderArgs :: String
1432
hvBootloaderArgs = "bootloader_args"
1433

    
1434
hvBootloaderPath :: String
1435
hvBootloaderPath = "bootloader_path"
1436

    
1437
hvBootOrder :: String
1438
hvBootOrder = "boot_order"
1439

    
1440
hvCdromImagePath :: String
1441
hvCdromImagePath = "cdrom_image_path"
1442

    
1443
hvCpuCap :: String
1444
hvCpuCap = "cpu_cap"
1445

    
1446
hvCpuCores :: String
1447
hvCpuCores = "cpu_cores"
1448

    
1449
hvCpuMask :: String
1450
hvCpuMask = "cpu_mask"
1451

    
1452
hvCpuSockets :: String
1453
hvCpuSockets = "cpu_sockets"
1454

    
1455
hvCpuThreads :: String
1456
hvCpuThreads = "cpu_threads"
1457

    
1458
hvCpuType :: String
1459
hvCpuType = "cpu_type"
1460

    
1461
hvCpuWeight :: String
1462
hvCpuWeight = "cpu_weight"
1463

    
1464
hvDeviceModel :: String
1465
hvDeviceModel = "device_model"
1466

    
1467
hvDiskCache :: String
1468
hvDiskCache = "disk_cache"
1469

    
1470
hvDiskType :: String
1471
hvDiskType = "disk_type"
1472

    
1473
hvInitrdPath :: String
1474
hvInitrdPath = "initrd_path"
1475

    
1476
hvInitScript :: String
1477
hvInitScript = "init_script"
1478

    
1479
hvKernelArgs :: String
1480
hvKernelArgs = "kernel_args"
1481

    
1482
hvKernelPath :: String
1483
hvKernelPath = "kernel_path"
1484

    
1485
hvKeymap :: String
1486
hvKeymap = "keymap"
1487

    
1488
hvKvmCdrom2ImagePath :: String
1489
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1490

    
1491
hvKvmCdromDiskType :: String
1492
hvKvmCdromDiskType = "cdrom_disk_type"
1493

    
1494
hvKvmExtra :: String
1495
hvKvmExtra = "kvm_extra"
1496

    
1497
hvKvmFlag :: String
1498
hvKvmFlag = "kvm_flag"
1499

    
1500
hvKvmFloppyImagePath :: String
1501
hvKvmFloppyImagePath = "floppy_image_path"
1502

    
1503
hvKvmMachineVersion :: String
1504
hvKvmMachineVersion = "machine_version"
1505

    
1506
hvKvmPath :: String
1507
hvKvmPath = "kvm_path"
1508

    
1509
hvKvmSpiceAudioCompr :: String
1510
hvKvmSpiceAudioCompr = "spice_playback_compression"
1511

    
1512
hvKvmSpiceBind :: String
1513
hvKvmSpiceBind = "spice_bind"
1514

    
1515
hvKvmSpiceIpVersion :: String
1516
hvKvmSpiceIpVersion = "spice_ip_version"
1517

    
1518
hvKvmSpiceJpegImgCompr :: String
1519
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1520

    
1521
hvKvmSpiceLosslessImgCompr :: String
1522
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1523

    
1524
hvKvmSpicePasswordFile :: String
1525
hvKvmSpicePasswordFile = "spice_password_file"
1526

    
1527
hvKvmSpiceStreamingVideoDetection :: String
1528
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1529

    
1530
hvKvmSpiceTlsCiphers :: String
1531
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1532

    
1533
hvKvmSpiceUseTls :: String
1534
hvKvmSpiceUseTls = "spice_use_tls"
1535

    
1536
hvKvmSpiceUseVdagent :: String
1537
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1538

    
1539
hvKvmSpiceZlibGlzImgCompr :: String
1540
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1541

    
1542
hvKvmUseChroot :: String
1543
hvKvmUseChroot = "use_chroot"
1544

    
1545
hvMemPath :: String
1546
hvMemPath = "mem_path"
1547

    
1548
hvMigrationBandwidth :: String
1549
hvMigrationBandwidth = "migration_bandwidth"
1550

    
1551
hvMigrationDowntime :: String
1552
hvMigrationDowntime = "migration_downtime"
1553

    
1554
hvMigrationMode :: String
1555
hvMigrationMode = "migration_mode"
1556

    
1557
hvMigrationPort :: String
1558
hvMigrationPort = "migration_port"
1559

    
1560
hvNicType :: String
1561
hvNicType = "nic_type"
1562

    
1563
hvPae :: String
1564
hvPae = "pae"
1565

    
1566
hvPassthrough :: String
1567
hvPassthrough = "pci_pass"
1568

    
1569
hvRebootBehavior :: String
1570
hvRebootBehavior = "reboot_behavior"
1571

    
1572
hvRootPath :: String
1573
hvRootPath = "root_path"
1574

    
1575
hvSecurityDomain :: String
1576
hvSecurityDomain = "security_domain"
1577

    
1578
hvSecurityModel :: String
1579
hvSecurityModel = "security_model"
1580

    
1581
hvSerialConsole :: String
1582
hvSerialConsole = "serial_console"
1583

    
1584
hvSerialSpeed :: String
1585
hvSerialSpeed = "serial_speed"
1586

    
1587
hvSoundhw :: String
1588
hvSoundhw = "soundhw"
1589

    
1590
hvUsbDevices :: String
1591
hvUsbDevices = "usb_devices"
1592

    
1593
hvUsbMouse :: String
1594
hvUsbMouse = "usb_mouse"
1595

    
1596
hvUseBootloader :: String
1597
hvUseBootloader = "use_bootloader"
1598

    
1599
hvUseLocaltime :: String
1600
hvUseLocaltime = "use_localtime"
1601

    
1602
hvVga :: String
1603
hvVga = "vga"
1604

    
1605
hvVhostNet :: String
1606
hvVhostNet = "vhost_net"
1607

    
1608
hvVifScript :: String
1609
hvVifScript = "vif_script"
1610

    
1611
hvVifType :: String
1612
hvVifType = "vif_type"
1613

    
1614
hvViridian :: String
1615
hvViridian = "viridian"
1616

    
1617
hvVncBindAddress :: String
1618
hvVncBindAddress = "vnc_bind_address"
1619

    
1620
hvVncPasswordFile :: String
1621
hvVncPasswordFile = "vnc_password_file"
1622

    
1623
hvVncTls :: String
1624
hvVncTls = "vnc_tls"
1625

    
1626
hvVncX509 :: String
1627
hvVncX509 = "vnc_x509_path"
1628

    
1629
hvVncX509Verify :: String
1630
hvVncX509Verify = "vnc_x509_verify"
1631

    
1632
hvVnetHdr :: String
1633
hvVnetHdr = "vnet_hdr"
1634

    
1635
hvXenCmd :: String
1636
hvXenCmd = "xen_cmd"
1637

    
1638
hvXenCpuid :: String
1639
hvXenCpuid = "cpuid"
1640

    
1641
hvsParameterTitles :: Map String String
1642
hvsParameterTitles =
1643
  Map.fromList
1644
  [(hvAcpi, "ACPI"),
1645
   (hvBootOrder, "Boot_order"),
1646
   (hvCdromImagePath, "CDROM_image_path"),
1647
   (hvCpuType, "cpu_type"),
1648
   (hvDiskType, "Disk_type"),
1649
   (hvInitrdPath, "Initrd_path"),
1650
   (hvKernelPath, "Kernel_path"),
1651
   (hvNicType, "NIC_type"),
1652
   (hvPae, "PAE"),
1653
   (hvPassthrough, "pci_pass"),
1654
   (hvVncBindAddress, "VNC_bind_address")]
1655

    
1656
hvsParameters :: FrozenSet String
1657
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1658

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

    
1735
-- * Migration statuses
1736

    
1737
hvMigrationActive :: String
1738
hvMigrationActive = "active"
1739

    
1740
hvMigrationCancelled :: String
1741
hvMigrationCancelled = "cancelled"
1742

    
1743
hvMigrationCompleted :: String
1744
hvMigrationCompleted = "completed"
1745

    
1746
hvMigrationFailed :: String
1747
hvMigrationFailed = "failed"
1748

    
1749
hvMigrationValidStatuses :: FrozenSet String
1750
hvMigrationValidStatuses =
1751
  ConstantUtils.mkSet [hvMigrationActive,
1752
                       hvMigrationCancelled,
1753
                       hvMigrationCompleted,
1754
                       hvMigrationFailed]
1755

    
1756
hvMigrationFailedStatuses :: FrozenSet String
1757
hvMigrationFailedStatuses =
1758
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1759

    
1760
-- | KVM-specific statuses
1761
--
1762
-- FIXME: this constant seems unnecessary
1763
hvKvmMigrationValidStatuses :: FrozenSet String
1764
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1765

    
1766
-- | Node info keys
1767
hvNodeinfoKeyVersion :: String
1768
hvNodeinfoKeyVersion = "hv_version"
1769

    
1770
-- * Hypervisor state
1771

    
1772
hvstCpuNode :: String
1773
hvstCpuNode = "cpu_node"
1774

    
1775
hvstCpuTotal :: String
1776
hvstCpuTotal = "cpu_total"
1777

    
1778
hvstMemoryHv :: String
1779
hvstMemoryHv = "mem_hv"
1780

    
1781
hvstMemoryNode :: String
1782
hvstMemoryNode = "mem_node"
1783

    
1784
hvstMemoryTotal :: String
1785
hvstMemoryTotal = "mem_total"
1786

    
1787
hvstsParameters :: FrozenSet String
1788
hvstsParameters =
1789
  ConstantUtils.mkSet [hvstCpuNode,
1790
                       hvstCpuTotal,
1791
                       hvstMemoryHv,
1792
                       hvstMemoryNode,
1793
                       hvstMemoryTotal]
1794

    
1795
hvstDefaults :: Map String Int
1796
hvstDefaults =
1797
  Map.fromList
1798
  [(hvstCpuNode, 1),
1799
   (hvstCpuTotal, 1),
1800
   (hvstMemoryHv, 0),
1801
   (hvstMemoryTotal, 0),
1802
   (hvstMemoryNode, 0)]
1803

    
1804
hvstsParameterTypes :: Map String VType
1805
hvstsParameterTypes =
1806
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1807
                (hvstMemoryNode, VTypeInt),
1808
                (hvstMemoryHv, VTypeInt),
1809
                (hvstCpuTotal, VTypeInt),
1810
                (hvstCpuNode, VTypeInt)]
1811

    
1812
-- * Disk state
1813

    
1814
dsDiskOverhead :: String
1815
dsDiskOverhead = "disk_overhead"
1816

    
1817
dsDiskReserved :: String
1818
dsDiskReserved = "disk_reserved"
1819

    
1820
dsDiskTotal :: String
1821
dsDiskTotal = "disk_total"
1822

    
1823
dsDefaults :: Map String Int
1824
dsDefaults =
1825
  Map.fromList
1826
  [(dsDiskTotal, 0),
1827
   (dsDiskReserved, 0),
1828
   (dsDiskOverhead, 0)]
1829

    
1830
dssParameterTypes :: Map String VType
1831
dssParameterTypes =
1832
  Map.fromList [(dsDiskTotal, VTypeInt),
1833
                (dsDiskReserved, VTypeInt),
1834
                (dsDiskOverhead, VTypeInt)]
1835

    
1836
dssParameters :: FrozenSet String
1837
dssParameters =
1838
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1839

    
1840
dsValidTypes :: FrozenSet String
1841
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1842

    
1843
-- Backend parameter names
1844

    
1845
beAlwaysFailover :: String
1846
beAlwaysFailover = "always_failover"
1847

    
1848
beAutoBalance :: String
1849
beAutoBalance = "auto_balance"
1850

    
1851
beMaxmem :: String
1852
beMaxmem = "maxmem"
1853

    
1854
-- | Deprecated and replaced by max and min mem
1855
beMemory :: String
1856
beMemory = "memory"
1857

    
1858
beMinmem :: String
1859
beMinmem = "minmem"
1860

    
1861
beSpindleUse :: String
1862
beSpindleUse = "spindle_use"
1863

    
1864
beVcpus :: String
1865
beVcpus = "vcpus"
1866

    
1867
besParameterTypes :: Map String VType
1868
besParameterTypes =
1869
  Map.fromList [(beAlwaysFailover, VTypeBool),
1870
                (beAutoBalance, VTypeBool),
1871
                (beMaxmem, VTypeSize),
1872
                (beMinmem, VTypeSize),
1873
                (beSpindleUse, VTypeInt),
1874
                (beVcpus, VTypeInt)]
1875

    
1876
besParameterTitles :: Map String String
1877
besParameterTitles =
1878
  Map.fromList [(beAutoBalance, "Auto_balance"),
1879
                (beMinmem, "ConfigMinMem"),
1880
                (beVcpus, "ConfigVCPUs"),
1881
                (beMaxmem, "ConfigMaxMem")]
1882

    
1883
besParameterCompat :: Map String VType
1884
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1885

    
1886
besParameters :: FrozenSet String
1887
besParameters =
1888
  ConstantUtils.mkSet [beAlwaysFailover,
1889
                       beAutoBalance,
1890
                       beMaxmem,
1891
                       beMinmem,
1892
                       beSpindleUse,
1893
                       beVcpus]
1894

    
1895
-- | Instance specs
1896
--
1897
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1898

    
1899
ispecMemSize :: String
1900
ispecMemSize = ConstantUtils.ispecMemSize
1901

    
1902
ispecCpuCount :: String
1903
ispecCpuCount = ConstantUtils.ispecCpuCount
1904

    
1905
ispecDiskCount :: String
1906
ispecDiskCount = ConstantUtils.ispecDiskCount
1907

    
1908
ispecDiskSize :: String
1909
ispecDiskSize = ConstantUtils.ispecDiskSize
1910

    
1911
ispecNicCount :: String
1912
ispecNicCount = ConstantUtils.ispecNicCount
1913

    
1914
ispecSpindleUse :: String
1915
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1916

    
1917
ispecsParameterTypes :: Map String VType
1918
ispecsParameterTypes =
1919
  Map.fromList
1920
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1921
   (ConstantUtils.ispecCpuCount, VTypeInt),
1922
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1923
   (ConstantUtils.ispecMemSize, VTypeInt),
1924
   (ConstantUtils.ispecNicCount, VTypeInt),
1925
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1926

    
1927
ispecsParameters :: FrozenSet String
1928
ispecsParameters =
1929
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1930
                       ConstantUtils.ispecDiskCount,
1931
                       ConstantUtils.ispecDiskSize,
1932
                       ConstantUtils.ispecMemSize,
1933
                       ConstantUtils.ispecNicCount,
1934
                       ConstantUtils.ispecSpindleUse]
1935

    
1936
ispecsMinmax :: String
1937
ispecsMinmax = ConstantUtils.ispecsMinmax
1938

    
1939
ispecsMax :: String
1940
ispecsMax = "max"
1941

    
1942
ispecsMin :: String
1943
ispecsMin = "min"
1944

    
1945
ispecsStd :: String
1946
ispecsStd = ConstantUtils.ispecsStd
1947

    
1948
ipolicyDts :: String
1949
ipolicyDts = ConstantUtils.ipolicyDts
1950

    
1951
ipolicyVcpuRatio :: String
1952
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1953

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

    
1957
ispecsMinmaxKeys :: FrozenSet String
1958
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1959

    
1960
ipolicyParameters :: FrozenSet String
1961
ipolicyParameters =
1962
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1963
                       ConstantUtils.ipolicySpindleRatio]
1964

    
1965
ipolicyAllKeys :: FrozenSet String
1966
ipolicyAllKeys =
1967
  ConstantUtils.union ipolicyParameters $
1968
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1969
                       ConstantUtils.ispecsMinmax,
1970
                       ispecsStd]
1971

    
1972
-- | Node parameter names
1973

    
1974
ndExclusiveStorage :: String
1975
ndExclusiveStorage = "exclusive_storage"
1976

    
1977
ndOobProgram :: String
1978
ndOobProgram = "oob_program"
1979

    
1980
ndSpindleCount :: String
1981
ndSpindleCount = "spindle_count"
1982

    
1983
ndOvs :: String
1984
ndOvs = "ovs"
1985

    
1986
ndOvsLink :: String
1987
ndOvsLink = "ovs_link"
1988

    
1989
ndOvsName :: String
1990
ndOvsName = "ovs_name"
1991

    
1992
ndSshPort :: String
1993
ndSshPort = "ssh_port"
1994

    
1995
ndsParameterTypes :: Map String VType
1996
ndsParameterTypes =
1997
  Map.fromList
1998
  [(ndExclusiveStorage, VTypeBool),
1999
   (ndOobProgram, VTypeString),
2000
   (ndOvs, VTypeBool),
2001
   (ndOvsLink, VTypeMaybeString),
2002
   (ndOvsName, VTypeMaybeString),
2003
   (ndSpindleCount, VTypeInt),
2004
   (ndSshPort, VTypeInt)]
2005

    
2006
ndsParameters :: FrozenSet String
2007
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
2008

    
2009
ndsParameterTitles :: Map String String
2010
ndsParameterTitles =
2011
  Map.fromList
2012
  [(ndExclusiveStorage, "ExclusiveStorage"),
2013
   (ndOobProgram, "OutOfBandProgram"),
2014
   (ndOvs, "OpenvSwitch"),
2015
   (ndOvsLink, "OpenvSwitchLink"),
2016
   (ndOvsName, "OpenvSwitchName"),
2017
   (ndSpindleCount, "SpindleCount")]
2018

    
2019
-- * Logical Disks parameters
2020

    
2021
ldpAccess :: String
2022
ldpAccess = "access"
2023

    
2024
ldpBarriers :: String
2025
ldpBarriers = "disabled-barriers"
2026

    
2027
ldpDefaultMetavg :: String
2028
ldpDefaultMetavg = "default-metavg"
2029

    
2030
ldpDelayTarget :: String
2031
ldpDelayTarget = "c-delay-target"
2032

    
2033
ldpDiskCustom :: String
2034
ldpDiskCustom = "disk-custom"
2035

    
2036
ldpDynamicResync :: String
2037
ldpDynamicResync = "dynamic-resync"
2038

    
2039
ldpFillTarget :: String
2040
ldpFillTarget = "c-fill-target"
2041

    
2042
ldpMaxRate :: String
2043
ldpMaxRate = "c-max-rate"
2044

    
2045
ldpMinRate :: String
2046
ldpMinRate = "c-min-rate"
2047

    
2048
ldpNetCustom :: String
2049
ldpNetCustom = "net-custom"
2050

    
2051
ldpNoMetaFlush :: String
2052
ldpNoMetaFlush = "disable-meta-flush"
2053

    
2054
ldpPlanAhead :: String
2055
ldpPlanAhead = "c-plan-ahead"
2056

    
2057
ldpPool :: String
2058
ldpPool = "pool"
2059

    
2060
ldpProtocol :: String
2061
ldpProtocol = "protocol"
2062

    
2063
ldpResyncRate :: String
2064
ldpResyncRate = "resync-rate"
2065

    
2066
ldpStripes :: String
2067
ldpStripes = "stripes"
2068

    
2069
diskLdTypes :: Map String VType
2070
diskLdTypes =
2071
  Map.fromList
2072
  [(ldpAccess, VTypeString),
2073
   (ldpResyncRate, VTypeInt),
2074
   (ldpStripes, VTypeInt),
2075
   (ldpBarriers, VTypeString),
2076
   (ldpNoMetaFlush, VTypeBool),
2077
   (ldpDefaultMetavg, VTypeString),
2078
   (ldpDiskCustom, VTypeString),
2079
   (ldpNetCustom, VTypeString),
2080
   (ldpProtocol, VTypeString),
2081
   (ldpDynamicResync, VTypeBool),
2082
   (ldpPlanAhead, VTypeInt),
2083
   (ldpFillTarget, VTypeInt),
2084
   (ldpDelayTarget, VTypeInt),
2085
   (ldpMaxRate, VTypeInt),
2086
   (ldpMinRate, VTypeInt),
2087
   (ldpPool, VTypeString)]
2088

    
2089
diskLdParameters :: FrozenSet String
2090
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2091

    
2092
-- * Disk template parameters
2093
--
2094
-- Disk template parameters can be set/changed by the user via
2095
-- gnt-cluster and gnt-group)
2096

    
2097
drbdResyncRate :: String
2098
drbdResyncRate = "resync-rate"
2099

    
2100
drbdDataStripes :: String
2101
drbdDataStripes = "data-stripes"
2102

    
2103
drbdMetaStripes :: String
2104
drbdMetaStripes = "meta-stripes"
2105

    
2106
drbdDiskBarriers :: String
2107
drbdDiskBarriers = "disk-barriers"
2108

    
2109
drbdMetaBarriers :: String
2110
drbdMetaBarriers = "meta-barriers"
2111

    
2112
drbdDefaultMetavg :: String
2113
drbdDefaultMetavg = "metavg"
2114

    
2115
drbdDiskCustom :: String
2116
drbdDiskCustom = "disk-custom"
2117

    
2118
drbdNetCustom :: String
2119
drbdNetCustom = "net-custom"
2120

    
2121
drbdProtocol :: String
2122
drbdProtocol = "protocol"
2123

    
2124
drbdDynamicResync :: String
2125
drbdDynamicResync = "dynamic-resync"
2126

    
2127
drbdPlanAhead :: String
2128
drbdPlanAhead = "c-plan-ahead"
2129

    
2130
drbdFillTarget :: String
2131
drbdFillTarget = "c-fill-target"
2132

    
2133
drbdDelayTarget :: String
2134
drbdDelayTarget = "c-delay-target"
2135

    
2136
drbdMaxRate :: String
2137
drbdMaxRate = "c-max-rate"
2138

    
2139
drbdMinRate :: String
2140
drbdMinRate = "c-min-rate"
2141

    
2142
lvStripes :: String
2143
lvStripes = "stripes"
2144

    
2145
rbdAccess :: String
2146
rbdAccess = "access"
2147

    
2148
rbdPool :: String
2149
rbdPool = "pool"
2150

    
2151
diskDtTypes :: Map String VType
2152
diskDtTypes =
2153
  Map.fromList [(drbdResyncRate, VTypeInt),
2154
                (drbdDataStripes, VTypeInt),
2155
                (drbdMetaStripes, VTypeInt),
2156
                (drbdDiskBarriers, VTypeString),
2157
                (drbdMetaBarriers, VTypeBool),
2158
                (drbdDefaultMetavg, VTypeString),
2159
                (drbdDiskCustom, VTypeString),
2160
                (drbdNetCustom, VTypeString),
2161
                (drbdProtocol, VTypeString),
2162
                (drbdDynamicResync, VTypeBool),
2163
                (drbdPlanAhead, VTypeInt),
2164
                (drbdFillTarget, VTypeInt),
2165
                (drbdDelayTarget, VTypeInt),
2166
                (drbdMaxRate, VTypeInt),
2167
                (drbdMinRate, VTypeInt),
2168
                (lvStripes, VTypeInt),
2169
                (rbdAccess, VTypeString),
2170
                (rbdPool, VTypeString)]
2171

    
2172
diskDtParameters :: FrozenSet String
2173
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2174

    
2175
-- * Dynamic disk parameters
2176

    
2177
ddpLocalIp :: String
2178
ddpLocalIp = "local-ip"
2179

    
2180
ddpRemoteIp :: String
2181
ddpRemoteIp = "remote-ip"
2182

    
2183
ddpPort :: String
2184
ddpPort = "port"
2185

    
2186
ddpLocalMinor :: String
2187
ddpLocalMinor = "local-minor"
2188

    
2189
ddpRemoteMinor :: String
2190
ddpRemoteMinor = "remote-minor"
2191

    
2192
-- * OOB supported commands
2193

    
2194
oobPowerOn :: String
2195
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2196

    
2197
oobPowerOff :: String
2198
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2199

    
2200
oobPowerCycle :: String
2201
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2202

    
2203
oobPowerStatus :: String
2204
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2205

    
2206
oobHealth :: String
2207
oobHealth = Types.oobCommandToRaw OobHealth
2208

    
2209
oobCommands :: FrozenSet String
2210
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2211

    
2212
oobPowerStatusPowered :: String
2213
oobPowerStatusPowered = "powered"
2214

    
2215
-- | 60 seconds
2216
oobTimeout :: Int
2217
oobTimeout = 60
2218

    
2219
-- | 2 seconds
2220
oobPowerDelay :: Double
2221
oobPowerDelay = 2.0
2222

    
2223
oobStatusCritical :: String
2224
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2225

    
2226
oobStatusOk :: String
2227
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2228

    
2229
oobStatusUnknown :: String
2230
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2231

    
2232
oobStatusWarning :: String
2233
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2234

    
2235
oobStatuses :: FrozenSet String
2236
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2237

    
2238
-- | Instance Parameters Profile
2239
ppDefault :: String
2240
ppDefault = "default"
2241

    
2242
-- * nic* constants are used inside the ganeti config
2243

    
2244
nicLink :: String
2245
nicLink = "link"
2246

    
2247
nicMode :: String
2248
nicMode = "mode"
2249

    
2250
nicVlan :: String
2251
nicVlan = "vlan"
2252

    
2253
nicsParameterTypes :: Map String VType
2254
nicsParameterTypes =
2255
  Map.fromList [(nicMode, vtypeString),
2256
                (nicLink, vtypeString),
2257
                (nicVlan, vtypeString)]
2258

    
2259
nicsParameters :: FrozenSet String
2260
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2261

    
2262
nicModeBridged :: String
2263
nicModeBridged = Types.nICModeToRaw NMBridged
2264

    
2265
nicModeRouted :: String
2266
nicModeRouted = Types.nICModeToRaw NMRouted
2267

    
2268
nicModeOvs :: String
2269
nicModeOvs = Types.nICModeToRaw NMOvs
2270

    
2271
nicIpPool :: String
2272
nicIpPool = Types.nICModeToRaw NMPool
2273

    
2274
nicValidModes :: FrozenSet String
2275
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2276

    
2277
releaseAction :: String
2278
releaseAction = "release"
2279

    
2280
reserveAction :: String
2281
reserveAction = "reserve"
2282

    
2283
-- * idisk* constants are used in opcodes, to create/change disks
2284

    
2285
idiskAdopt :: String
2286
idiskAdopt = "adopt"
2287

    
2288
idiskMetavg :: String
2289
idiskMetavg = "metavg"
2290

    
2291
idiskMode :: String
2292
idiskMode = "mode"
2293

    
2294
idiskName :: String
2295
idiskName = "name"
2296

    
2297
idiskSize :: String
2298
idiskSize = "size"
2299

    
2300
idiskSpindles :: String
2301
idiskSpindles = "spindles"
2302

    
2303
idiskVg :: String
2304
idiskVg = "vg"
2305

    
2306
idiskProvider :: String
2307
idiskProvider = "provider"
2308

    
2309
idiskParamsTypes :: Map String VType
2310
idiskParamsTypes =
2311
  Map.fromList [(idiskSize, VTypeSize),
2312
                (idiskSpindles, VTypeInt),
2313
                (idiskMode, VTypeString),
2314
                (idiskAdopt, VTypeString),
2315
                (idiskVg, VTypeString),
2316
                (idiskMetavg, VTypeString),
2317
                (idiskProvider, VTypeString),
2318
                (idiskName, VTypeMaybeString)]
2319

    
2320
idiskParams :: FrozenSet String
2321
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2322

    
2323
-- * inic* constants are used in opcodes, to create/change nics
2324

    
2325
inicBridge :: String
2326
inicBridge = "bridge"
2327

    
2328
inicIp :: String
2329
inicIp = "ip"
2330

    
2331
inicLink :: String
2332
inicLink = "link"
2333

    
2334
inicMac :: String
2335
inicMac = "mac"
2336

    
2337
inicMode :: String
2338
inicMode = "mode"
2339

    
2340
inicName :: String
2341
inicName = "name"
2342

    
2343
inicNetwork :: String
2344
inicNetwork = "network"
2345

    
2346
inicVlan :: String
2347
inicVlan = "vlan"
2348

    
2349
inicParamsTypes :: Map String VType
2350
inicParamsTypes =
2351
  Map.fromList [(inicBridge, VTypeMaybeString),
2352
                (inicIp, VTypeMaybeString),
2353
                (inicLink, VTypeString),
2354
                (inicMac, VTypeString),
2355
                (inicMode, VTypeString),
2356
                (inicName, VTypeMaybeString),
2357
                (inicNetwork, VTypeMaybeString),
2358
                (inicVlan, VTypeMaybeString)]
2359

    
2360
inicParams :: FrozenSet String
2361
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2362

    
2363
-- * Hypervisor constants
2364

    
2365
htXenPvm :: String
2366
htXenPvm = Types.hypervisorToRaw XenPvm
2367

    
2368
htFake :: String
2369
htFake = Types.hypervisorToRaw Fake
2370

    
2371
htXenHvm :: String
2372
htXenHvm = Types.hypervisorToRaw XenHvm
2373

    
2374
htKvm :: String
2375
htKvm = Types.hypervisorToRaw Kvm
2376

    
2377
htChroot :: String
2378
htChroot = Types.hypervisorToRaw Chroot
2379

    
2380
htLxc :: String
2381
htLxc = Types.hypervisorToRaw Lxc
2382

    
2383
hyperTypes :: FrozenSet String
2384
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2385

    
2386
htsReqPort :: FrozenSet String
2387
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2388

    
2389
vncBasePort :: Int
2390
vncBasePort = 5900
2391

    
2392
vncDefaultBindAddress :: String
2393
vncDefaultBindAddress = ip4AddressAny
2394

    
2395
-- * NIC types
2396

    
2397
htNicE1000 :: String
2398
htNicE1000 = "e1000"
2399

    
2400
htNicI82551 :: String
2401
htNicI82551 = "i82551"
2402

    
2403
htNicI8259er :: String
2404
htNicI8259er = "i82559er"
2405

    
2406
htNicI85557b :: String
2407
htNicI85557b = "i82557b"
2408

    
2409
htNicNe2kIsa :: String
2410
htNicNe2kIsa = "ne2k_isa"
2411

    
2412
htNicNe2kPci :: String
2413
htNicNe2kPci = "ne2k_pci"
2414

    
2415
htNicParavirtual :: String
2416
htNicParavirtual = "paravirtual"
2417

    
2418
htNicPcnet :: String
2419
htNicPcnet = "pcnet"
2420

    
2421
htNicRtl8139 :: String
2422
htNicRtl8139 = "rtl8139"
2423

    
2424
htHvmValidNicTypes :: FrozenSet String
2425
htHvmValidNicTypes =
2426
  ConstantUtils.mkSet [htNicE1000,
2427
                       htNicNe2kIsa,
2428
                       htNicNe2kPci,
2429
                       htNicParavirtual,
2430
                       htNicRtl8139]
2431

    
2432
htKvmValidNicTypes :: FrozenSet String
2433
htKvmValidNicTypes =
2434
  ConstantUtils.mkSet [htNicE1000,
2435
                       htNicI82551,
2436
                       htNicI8259er,
2437
                       htNicI85557b,
2438
                       htNicNe2kIsa,
2439
                       htNicNe2kPci,
2440
                       htNicParavirtual,
2441
                       htNicPcnet,
2442
                       htNicRtl8139]
2443

    
2444
-- * Vif types
2445

    
2446
-- | Default vif type in xen-hvm
2447
htHvmVifIoemu :: String
2448
htHvmVifIoemu = "ioemu"
2449

    
2450
htHvmVifVif :: String
2451
htHvmVifVif = "vif"
2452

    
2453
htHvmValidVifTypes :: FrozenSet String
2454
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2455

    
2456
-- * Disk types
2457

    
2458
htDiskIde :: String
2459
htDiskIde = "ide"
2460

    
2461
htDiskIoemu :: String
2462
htDiskIoemu = "ioemu"
2463

    
2464
htDiskMtd :: String
2465
htDiskMtd = "mtd"
2466

    
2467
htDiskParavirtual :: String
2468
htDiskParavirtual = "paravirtual"
2469

    
2470
htDiskPflash :: String
2471
htDiskPflash = "pflash"
2472

    
2473
htDiskScsi :: String
2474
htDiskScsi = "scsi"
2475

    
2476
htDiskSd :: String
2477
htDiskSd = "sd"
2478

    
2479
htHvmValidDiskTypes :: FrozenSet String
2480
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2481

    
2482
htKvmValidDiskTypes :: FrozenSet String
2483
htKvmValidDiskTypes =
2484
  ConstantUtils.mkSet [htDiskIde,
2485
                       htDiskMtd,
2486
                       htDiskParavirtual,
2487
                       htDiskPflash,
2488
                       htDiskScsi,
2489
                       htDiskSd]
2490

    
2491
htCacheDefault :: String
2492
htCacheDefault = "default"
2493

    
2494
htCacheNone :: String
2495
htCacheNone = "none"
2496

    
2497
htCacheWback :: String
2498
htCacheWback = "writeback"
2499

    
2500
htCacheWthrough :: String
2501
htCacheWthrough = "writethrough"
2502

    
2503
htValidCacheTypes :: FrozenSet String
2504
htValidCacheTypes =
2505
  ConstantUtils.mkSet [htCacheDefault,
2506
                       htCacheNone,
2507
                       htCacheWback,
2508
                       htCacheWthrough]
2509

    
2510
-- * Mouse types
2511

    
2512
htMouseMouse :: String
2513
htMouseMouse = "mouse"
2514

    
2515
htMouseTablet :: String
2516
htMouseTablet = "tablet"
2517

    
2518
htKvmValidMouseTypes :: FrozenSet String
2519
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2520

    
2521
-- * Boot order
2522

    
2523
htBoCdrom :: String
2524
htBoCdrom = "cdrom"
2525

    
2526
htBoDisk :: String
2527
htBoDisk = "disk"
2528

    
2529
htBoFloppy :: String
2530
htBoFloppy = "floppy"
2531

    
2532
htBoNetwork :: String
2533
htBoNetwork = "network"
2534

    
2535
htKvmValidBoTypes :: FrozenSet String
2536
htKvmValidBoTypes =
2537
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2538

    
2539
-- * SPICE lossless image compression options
2540

    
2541
htKvmSpiceLosslessImgComprAutoGlz :: String
2542
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2543

    
2544
htKvmSpiceLosslessImgComprAutoLz :: String
2545
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2546

    
2547
htKvmSpiceLosslessImgComprGlz :: String
2548
htKvmSpiceLosslessImgComprGlz = "glz"
2549

    
2550
htKvmSpiceLosslessImgComprLz :: String
2551
htKvmSpiceLosslessImgComprLz = "lz"
2552

    
2553
htKvmSpiceLosslessImgComprOff :: String
2554
htKvmSpiceLosslessImgComprOff = "off"
2555

    
2556
htKvmSpiceLosslessImgComprQuic :: String
2557
htKvmSpiceLosslessImgComprQuic = "quic"
2558

    
2559
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2560
htKvmSpiceValidLosslessImgComprOptions =
2561
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2562
                       htKvmSpiceLosslessImgComprAutoLz,
2563
                       htKvmSpiceLosslessImgComprGlz,
2564
                       htKvmSpiceLosslessImgComprLz,
2565
                       htKvmSpiceLosslessImgComprOff,
2566
                       htKvmSpiceLosslessImgComprQuic]
2567

    
2568
htKvmSpiceLossyImgComprAlways :: String
2569
htKvmSpiceLossyImgComprAlways = "always"
2570

    
2571
htKvmSpiceLossyImgComprAuto :: String
2572
htKvmSpiceLossyImgComprAuto = "auto"
2573

    
2574
htKvmSpiceLossyImgComprNever :: String
2575
htKvmSpiceLossyImgComprNever = "never"
2576

    
2577
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2578
htKvmSpiceValidLossyImgComprOptions =
2579
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2580
                       htKvmSpiceLossyImgComprAuto,
2581
                       htKvmSpiceLossyImgComprNever]
2582

    
2583
-- * SPICE video stream detection
2584

    
2585
htKvmSpiceVideoStreamDetectionAll :: String
2586
htKvmSpiceVideoStreamDetectionAll = "all"
2587

    
2588
htKvmSpiceVideoStreamDetectionFilter :: String
2589
htKvmSpiceVideoStreamDetectionFilter = "filter"
2590

    
2591
htKvmSpiceVideoStreamDetectionOff :: String
2592
htKvmSpiceVideoStreamDetectionOff = "off"
2593

    
2594
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2595
htKvmSpiceValidVideoStreamDetectionOptions =
2596
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2597
                       htKvmSpiceVideoStreamDetectionFilter,
2598
                       htKvmSpiceVideoStreamDetectionOff]
2599

    
2600
-- * Security models
2601

    
2602
htSmNone :: String
2603
htSmNone = "none"
2604

    
2605
htSmPool :: String
2606
htSmPool = "pool"
2607

    
2608
htSmUser :: String
2609
htSmUser = "user"
2610

    
2611
htKvmValidSmTypes :: FrozenSet String
2612
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2613

    
2614
-- * Kvm flag values
2615

    
2616
htKvmDisabled :: String
2617
htKvmDisabled = "disabled"
2618

    
2619
htKvmEnabled :: String
2620
htKvmEnabled = "enabled"
2621

    
2622
htKvmFlagValues :: FrozenSet String
2623
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2624

    
2625
-- * Migration type
2626

    
2627
htMigrationLive :: String
2628
htMigrationLive = Types.migrationModeToRaw MigrationLive
2629

    
2630
htMigrationNonlive :: String
2631
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2632

    
2633
htMigrationModes :: FrozenSet String
2634
htMigrationModes =
2635
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2636

    
2637
-- * Cluster verify steps
2638

    
2639
verifyNplusoneMem :: String
2640
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2641

    
2642
verifyOptionalChecks :: FrozenSet String
2643
verifyOptionalChecks =
2644
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2645

    
2646
-- * Cluster Verify error classes
2647

    
2648
cvTcluster :: String
2649
cvTcluster = "cluster"
2650

    
2651
cvTgroup :: String
2652
cvTgroup = "group"
2653

    
2654
cvTnode :: String
2655
cvTnode = "node"
2656

    
2657
cvTinstance :: String
2658
cvTinstance = "instance"
2659

    
2660
-- * Cluster Verify error codes and documentation
2661

    
2662
cvEclustercert :: (String, String, String)
2663
cvEclustercert =
2664
  ("cluster",
2665
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2666
   "Cluster certificate files verification failure")
2667

    
2668
cvEclustercfg :: (String, String, String)
2669
cvEclustercfg =
2670
  ("cluster",
2671
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2672
   "Cluster configuration verification failure")
2673

    
2674
cvEclusterdanglinginst :: (String, String, String)
2675
cvEclusterdanglinginst =
2676
  ("node",
2677
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2678
   "Some instances have a non-existing primary node")
2679

    
2680
cvEclusterdanglingnodes :: (String, String, String)
2681
cvEclusterdanglingnodes =
2682
  ("node",
2683
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2684
   "Some nodes belong to non-existing groups")
2685

    
2686
cvEclusterfilecheck :: (String, String, String)
2687
cvEclusterfilecheck =
2688
  ("cluster",
2689
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2690
   "Cluster configuration verification failure")
2691

    
2692
cvEgroupdifferentpvsize :: (String, String, String)
2693
cvEgroupdifferentpvsize =
2694
  ("group",
2695
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2696
   "PVs in the group have different sizes")
2697

    
2698
cvEinstancebadnode :: (String, String, String)
2699
cvEinstancebadnode =
2700
  ("instance",
2701
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2702
   "Instance marked as running lives on an offline node")
2703

    
2704
cvEinstancedown :: (String, String, String)
2705
cvEinstancedown =
2706
  ("instance",
2707
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2708
   "Instance not running on its primary node")
2709

    
2710
cvEinstancefaultydisk :: (String, String, String)
2711
cvEinstancefaultydisk =
2712
  ("instance",
2713
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2714
   "Impossible to retrieve status for a disk")
2715

    
2716
cvEinstancelayout :: (String, String, String)
2717
cvEinstancelayout =
2718
  ("instance",
2719
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2720
   "Instance has multiple secondary nodes")
2721

    
2722
cvEinstancemissingcfgparameter :: (String, String, String)
2723
cvEinstancemissingcfgparameter =
2724
  ("instance",
2725
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2726
   "A configuration parameter for an instance is missing")
2727

    
2728
cvEinstancemissingdisk :: (String, String, String)
2729
cvEinstancemissingdisk =
2730
  ("instance",
2731
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2732
   "Missing volume on an instance")
2733

    
2734
cvEinstancepolicy :: (String, String, String)
2735
cvEinstancepolicy =
2736
  ("instance",
2737
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2738
   "Instance does not meet policy")
2739

    
2740
cvEinstancesplitgroups :: (String, String, String)
2741
cvEinstancesplitgroups =
2742
  ("instance",
2743
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2744
   "Instance with primary and secondary nodes in different groups")
2745

    
2746
cvEinstanceunsuitablenode :: (String, String, String)
2747
cvEinstanceunsuitablenode =
2748
  ("instance",
2749
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2750
   "Instance running on nodes that are not suitable for it")
2751

    
2752
cvEinstancewrongnode :: (String, String, String)
2753
cvEinstancewrongnode =
2754
  ("instance",
2755
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2756
   "Instance running on the wrong node")
2757

    
2758
cvEnodedrbd :: (String, String, String)
2759
cvEnodedrbd =
2760
  ("node",
2761
   Types.cVErrorCodeToRaw CvENODEDRBD,
2762
   "Error parsing the DRBD status file")
2763

    
2764
cvEnodedrbdhelper :: (String, String, String)
2765
cvEnodedrbdhelper =
2766
  ("node",
2767
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2768
   "Error caused by the DRBD helper")
2769

    
2770
cvEnodedrbdversion :: (String, String, String)
2771
cvEnodedrbdversion =
2772
  ("node",
2773
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2774
   "DRBD version mismatch within a node group")
2775

    
2776
cvEnodefilecheck :: (String, String, String)
2777
cvEnodefilecheck =
2778
  ("node",
2779
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2780
   "Error retrieving the checksum of the node files")
2781

    
2782
cvEnodefilestoragepaths :: (String, String, String)
2783
cvEnodefilestoragepaths =
2784
  ("node",
2785
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2786
   "Detected bad file storage paths")
2787

    
2788
cvEnodefilestoragepathunusable :: (String, String, String)
2789
cvEnodefilestoragepathunusable =
2790
  ("node",
2791
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2792
   "File storage path unusable")
2793

    
2794
cvEnodehooks :: (String, String, String)
2795
cvEnodehooks =
2796
  ("node",
2797
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2798
   "Communication failure in hooks execution")
2799

    
2800
cvEnodehv :: (String, String, String)
2801
cvEnodehv =
2802
  ("node",
2803
   Types.cVErrorCodeToRaw CvENODEHV,
2804
   "Hypervisor parameters verification failure")
2805

    
2806
cvEnodelvm :: (String, String, String)
2807
cvEnodelvm =
2808
  ("node",
2809
   Types.cVErrorCodeToRaw CvENODELVM,
2810
   "LVM-related node error")
2811

    
2812
cvEnoden1 :: (String, String, String)
2813
cvEnoden1 =
2814
  ("node",
2815
   Types.cVErrorCodeToRaw CvENODEN1,
2816
   "Not enough memory to accommodate instance failovers")
2817

    
2818
cvEnodenet :: (String, String, String)
2819
cvEnodenet =
2820
  ("node",
2821
   Types.cVErrorCodeToRaw CvENODENET,
2822
   "Network-related node error")
2823

    
2824
cvEnodeoobpath :: (String, String, String)
2825
cvEnodeoobpath =
2826
  ("node",
2827
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2828
   "Invalid Out Of Band path")
2829

    
2830
cvEnodeorphaninstance :: (String, String, String)
2831
cvEnodeorphaninstance =
2832
  ("node",
2833
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2834
   "Unknown intance running on a node")
2835

    
2836
cvEnodeorphanlv :: (String, String, String)
2837
cvEnodeorphanlv =
2838
  ("node",
2839
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2840
   "Unknown LVM logical volume")
2841

    
2842
cvEnodeos :: (String, String, String)
2843
cvEnodeos =
2844
  ("node",
2845
   Types.cVErrorCodeToRaw CvENODEOS,
2846
   "OS-related node error")
2847

    
2848
cvEnoderpc :: (String, String, String)
2849
cvEnoderpc =
2850
  ("node",
2851
   Types.cVErrorCodeToRaw CvENODERPC,
2852
   "Error during connection to the primary node of an instance")
2853

    
2854
cvEnodesetup :: (String, String, String)
2855
cvEnodesetup =
2856
  ("node",
2857
   Types.cVErrorCodeToRaw CvENODESETUP,
2858
   "Node setup error")
2859

    
2860
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2861
cvEnodesharedfilestoragepathunusable =
2862
  ("node",
2863
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2864
   "Shared file storage path unusable")
2865

    
2866
cvEnodessh :: (String, String, String)
2867
cvEnodessh =
2868
  ("node",
2869
   Types.cVErrorCodeToRaw CvENODESSH,
2870
   "SSH-related node error")
2871

    
2872
cvEnodetime :: (String, String, String)
2873
cvEnodetime =
2874
  ("node",
2875
   Types.cVErrorCodeToRaw CvENODETIME,
2876
   "Node returned invalid time")
2877

    
2878
cvEnodeuserscripts :: (String, String, String)
2879
cvEnodeuserscripts =
2880
  ("node",
2881
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2882
   "User scripts not present or not executable")
2883

    
2884
cvEnodeversion :: (String, String, String)
2885
cvEnodeversion =
2886
  ("node",
2887
   Types.cVErrorCodeToRaw CvENODEVERSION,
2888
   "Protocol version mismatch or Ganeti version mismatch")
2889

    
2890
cvAllEcodes :: FrozenSet (String, String, String)
2891
cvAllEcodes =
2892
  ConstantUtils.mkSet
2893
  [cvEclustercert,
2894
   cvEclustercfg,
2895
   cvEclusterdanglinginst,
2896
   cvEclusterdanglingnodes,
2897
   cvEclusterfilecheck,
2898
   cvEgroupdifferentpvsize,
2899
   cvEinstancebadnode,
2900
   cvEinstancedown,
2901
   cvEinstancefaultydisk,
2902
   cvEinstancelayout,
2903
   cvEinstancemissingcfgparameter,
2904
   cvEinstancemissingdisk,
2905
   cvEinstancepolicy,
2906
   cvEinstancesplitgroups,
2907
   cvEinstanceunsuitablenode,
2908
   cvEinstancewrongnode,
2909
   cvEnodedrbd,
2910
   cvEnodedrbdhelper,
2911
   cvEnodedrbdversion,
2912
   cvEnodefilecheck,
2913
   cvEnodefilestoragepaths,
2914
   cvEnodefilestoragepathunusable,
2915
   cvEnodehooks,
2916
   cvEnodehv,
2917
   cvEnodelvm,
2918
   cvEnoden1,
2919
   cvEnodenet,
2920
   cvEnodeoobpath,
2921
   cvEnodeorphaninstance,
2922
   cvEnodeorphanlv,
2923
   cvEnodeos,
2924
   cvEnoderpc,
2925
   cvEnodesetup,
2926
   cvEnodesharedfilestoragepathunusable,
2927
   cvEnodessh,
2928
   cvEnodetime,
2929
   cvEnodeuserscripts,
2930
   cvEnodeversion]
2931

    
2932
cvAllEcodesStrings :: FrozenSet String
2933
cvAllEcodesStrings =
2934
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2935

    
2936
-- * Node verify constants
2937

    
2938
nvBridges :: String
2939
nvBridges = "bridges"
2940

    
2941
nvDrbdhelper :: String
2942
nvDrbdhelper = "drbd-helper"
2943

    
2944
nvDrbdversion :: String
2945
nvDrbdversion = "drbd-version"
2946

    
2947
nvDrbdlist :: String
2948
nvDrbdlist = "drbd-list"
2949

    
2950
nvExclusivepvs :: String
2951
nvExclusivepvs = "exclusive-pvs"
2952

    
2953
nvFilelist :: String
2954
nvFilelist = "filelist"
2955

    
2956
nvAcceptedStoragePaths :: String
2957
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2958

    
2959
nvFileStoragePath :: String
2960
nvFileStoragePath = "file-storage-path"
2961

    
2962
nvSharedFileStoragePath :: String
2963
nvSharedFileStoragePath = "shared-file-storage-path"
2964

    
2965
nvHvinfo :: String
2966
nvHvinfo = "hvinfo"
2967

    
2968
nvHvparams :: String
2969
nvHvparams = "hvparms"
2970

    
2971
nvHypervisor :: String
2972
nvHypervisor = "hypervisor"
2973

    
2974
nvInstancelist :: String
2975
nvInstancelist = "instancelist"
2976

    
2977
nvLvlist :: String
2978
nvLvlist = "lvlist"
2979

    
2980
nvMasterip :: String
2981
nvMasterip = "master-ip"
2982

    
2983
nvNodelist :: String
2984
nvNodelist = "nodelist"
2985

    
2986
nvNodenettest :: String
2987
nvNodenettest = "node-net-test"
2988

    
2989
nvNodesetup :: String
2990
nvNodesetup = "nodesetup"
2991

    
2992
nvOobPaths :: String
2993
nvOobPaths = "oob-paths"
2994

    
2995
nvOslist :: String
2996
nvOslist = "oslist"
2997

    
2998
nvPvlist :: String
2999
nvPvlist = "pvlist"
3000

    
3001
nvTime :: String
3002
nvTime = "time"
3003

    
3004
nvUserscripts :: String
3005
nvUserscripts = "user-scripts"
3006

    
3007
nvVersion :: String
3008
nvVersion = "version"
3009

    
3010
nvVglist :: String
3011
nvVglist = "vglist"
3012

    
3013
nvVmnodes :: String
3014
nvVmnodes = "vmnodes"
3015

    
3016
-- * Instance status
3017

    
3018
inststAdmindown :: String
3019
inststAdmindown = Types.instanceStatusToRaw StatusDown
3020

    
3021
inststAdminoffline :: String
3022
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3023

    
3024
inststErrordown :: String
3025
inststErrordown = Types.instanceStatusToRaw ErrorDown
3026

    
3027
inststErrorup :: String
3028
inststErrorup = Types.instanceStatusToRaw ErrorUp
3029

    
3030
inststNodedown :: String
3031
inststNodedown = Types.instanceStatusToRaw NodeDown
3032

    
3033
inststNodeoffline :: String
3034
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3035

    
3036
inststRunning :: String
3037
inststRunning = Types.instanceStatusToRaw Running
3038

    
3039
inststUserdown :: String
3040
inststUserdown = Types.instanceStatusToRaw UserDown
3041

    
3042
inststWrongnode :: String
3043
inststWrongnode = Types.instanceStatusToRaw WrongNode
3044

    
3045
inststAll :: FrozenSet String
3046
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3047

    
3048
-- * Admin states
3049

    
3050
adminstDown :: String
3051
adminstDown = Types.adminStateToRaw AdminDown
3052

    
3053
adminstOffline :: String
3054
adminstOffline = Types.adminStateToRaw AdminOffline
3055

    
3056
adminstUp :: String
3057
adminstUp = Types.adminStateToRaw AdminUp
3058

    
3059
adminstAll :: FrozenSet String
3060
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3061

    
3062
-- * Node roles
3063

    
3064
nrDrained :: String
3065
nrDrained = Types.nodeRoleToRaw NRDrained
3066

    
3067
nrMaster :: String
3068
nrMaster = Types.nodeRoleToRaw NRMaster
3069

    
3070
nrMcandidate :: String
3071
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3072

    
3073
nrOffline :: String
3074
nrOffline = Types.nodeRoleToRaw NROffline
3075

    
3076
nrRegular :: String
3077
nrRegular = Types.nodeRoleToRaw NRRegular
3078

    
3079
nrAll :: FrozenSet String
3080
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3081

    
3082
-- * SSL certificate check constants (in days)
3083

    
3084
sslCertExpirationError :: Int
3085
sslCertExpirationError = 7
3086

    
3087
sslCertExpirationWarn :: Int
3088
sslCertExpirationWarn = 30
3089

    
3090
-- * Allocator framework constants
3091

    
3092
iallocatorVersion :: Int
3093
iallocatorVersion = 2
3094

    
3095
iallocatorDirIn :: String
3096
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3097

    
3098
iallocatorDirOut :: String
3099
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3100

    
3101
validIallocatorDirections :: FrozenSet String
3102
validIallocatorDirections =
3103
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3104

    
3105
iallocatorModeAlloc :: String
3106
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3107

    
3108
iallocatorModeChgGroup :: String
3109
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3110

    
3111
iallocatorModeMultiAlloc :: String
3112
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3113

    
3114
iallocatorModeNodeEvac :: String
3115
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3116

    
3117
iallocatorModeReloc :: String
3118
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3119

    
3120
validIallocatorModes :: FrozenSet String
3121
validIallocatorModes =
3122
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3123

    
3124
iallocatorSearchPath :: [String]
3125
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3126

    
3127
defaultIallocatorShortcut :: String
3128
defaultIallocatorShortcut = "."
3129

    
3130
-- * Node evacuation
3131

    
3132
nodeEvacPri :: String
3133
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3134

    
3135
nodeEvacSec :: String
3136
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3137

    
3138
nodeEvacAll :: String
3139
nodeEvacAll = Types.evacModeToRaw ChangeAll
3140

    
3141
nodeEvacModes :: FrozenSet String
3142
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3143

    
3144
-- * Job queue
3145

    
3146
jobQueueVersion :: Int
3147
jobQueueVersion = 1
3148

    
3149
jobQueueSizeHardLimit :: Int
3150
jobQueueSizeHardLimit = 5000
3151

    
3152
jobQueueFilesPerms :: Int
3153
jobQueueFilesPerms = 0o640
3154

    
3155
-- * Unchanged job return
3156

    
3157
jobNotchanged :: String
3158
jobNotchanged = "nochange"
3159

    
3160
-- * Job status
3161

    
3162
jobStatusQueued :: String
3163
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3164

    
3165
jobStatusWaiting :: String
3166
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3167

    
3168
jobStatusCanceling :: String
3169
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3170

    
3171
jobStatusRunning :: String
3172
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3173

    
3174
jobStatusCanceled :: String
3175
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3176

    
3177
jobStatusSuccess :: String
3178
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3179

    
3180
jobStatusError :: String
3181
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3182

    
3183
jobsPending :: FrozenSet String
3184
jobsPending =
3185
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3186

    
3187
jobsFinalized :: FrozenSet String
3188
jobsFinalized =
3189
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3190

    
3191
jobStatusAll :: FrozenSet String
3192
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3193

    
3194
-- * OpCode status
3195

    
3196
-- ** Not yet finalized opcodes
3197

    
3198
opStatusCanceling :: String
3199
opStatusCanceling = "canceling"
3200

    
3201
opStatusQueued :: String
3202
opStatusQueued = "queued"
3203

    
3204
opStatusRunning :: String
3205
opStatusRunning = "running"
3206

    
3207
opStatusWaiting :: String
3208
opStatusWaiting = "waiting"
3209

    
3210
-- ** Finalized opcodes
3211

    
3212
opStatusCanceled :: String
3213
opStatusCanceled = "canceled"
3214

    
3215
opStatusError :: String
3216
opStatusError = "error"
3217

    
3218
opStatusSuccess :: String
3219
opStatusSuccess = "success"
3220

    
3221
opsFinalized :: FrozenSet String
3222
opsFinalized =
3223
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3224

    
3225
-- * OpCode priority
3226

    
3227
opPrioLowest :: Int
3228
opPrioLowest = 19
3229

    
3230
opPrioHighest :: Int
3231
opPrioHighest = -20
3232

    
3233
opPrioLow :: Int
3234
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3235

    
3236
opPrioNormal :: Int
3237
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3238

    
3239
opPrioHigh :: Int
3240
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3241

    
3242
opPrioSubmitValid :: FrozenSet Int
3243
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3244

    
3245
opPrioDefault :: Int
3246
opPrioDefault = opPrioNormal
3247

    
3248
-- * Lock recalculate mode
3249

    
3250
locksAppend :: String
3251
locksAppend = "append"
3252

    
3253
locksReplace :: String
3254
locksReplace = "replace"
3255

    
3256
-- * Lock timeout
3257
--
3258
-- The lock timeout (sum) before we transition into blocking acquire
3259
-- (this can still be reset by priority change).  Computed as max time
3260
-- (10 hours) before we should actually go into blocking acquire,
3261
-- given that we start from the default priority level.
3262

    
3263
lockAttemptsMaxwait :: Double
3264
lockAttemptsMaxwait = 15.0
3265

    
3266
lockAttemptsMinwait :: Double
3267
lockAttemptsMinwait = 1.0
3268

    
3269
lockAttemptsTimeout :: Int
3270
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3271

    
3272
-- * Execution log types
3273

    
3274
elogMessage :: String
3275
elogMessage = Types.eLogTypeToRaw ELogMessage
3276

    
3277
elogRemoteImport :: String
3278
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3279

    
3280
elogJqueueTest :: String
3281
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3282

    
3283
-- * /etc/hosts modification
3284

    
3285
etcHostsAdd :: String
3286
etcHostsAdd = "add"
3287

    
3288
etcHostsRemove :: String
3289
etcHostsRemove = "remove"
3290

    
3291
-- * Job queue test
3292

    
3293
jqtMsgprefix :: String
3294
jqtMsgprefix = "TESTMSG="
3295

    
3296
jqtExec :: String
3297
jqtExec = "exec"
3298

    
3299
jqtExpandnames :: String
3300
jqtExpandnames = "expandnames"
3301

    
3302
jqtLogmsg :: String
3303
jqtLogmsg = "logmsg"
3304

    
3305
jqtStartmsg :: String
3306
jqtStartmsg = "startmsg"
3307

    
3308
jqtAll :: FrozenSet String
3309
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3310

    
3311
-- * Query resources
3312

    
3313
qrCluster :: String
3314
qrCluster = "cluster"
3315

    
3316
qrExport :: String
3317
qrExport = "export"
3318

    
3319
qrExtstorage :: String
3320
qrExtstorage = "extstorage"
3321

    
3322
qrGroup :: String
3323
qrGroup = "group"
3324

    
3325
qrInstance :: String
3326
qrInstance = "instance"
3327

    
3328
qrJob :: String
3329
qrJob = "job"
3330

    
3331
qrLock :: String
3332
qrLock = "lock"
3333

    
3334
qrNetwork :: String
3335
qrNetwork = "network"
3336

    
3337
qrNode :: String
3338
qrNode = "node"
3339

    
3340
qrOs :: String
3341
qrOs = "os"
3342

    
3343
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3344
qrViaOp :: FrozenSet String
3345
qrViaOp =
3346
  ConstantUtils.mkSet [qrCluster,
3347
                       qrOs,
3348
                       qrExtstorage]
3349

    
3350
-- | List of resources which can be queried using Local UniX Interface
3351
qrViaLuxi :: FrozenSet String
3352
qrViaLuxi = ConstantUtils.mkSet [qrGroup,
3353
                                 qrExport,
3354
                                 qrInstance,
3355
                                 qrJob,
3356
                                 qrLock,
3357
                                 qrNetwork,
3358
                                 qrNode]
3359

    
3360
-- | List of resources which can be queried using RAPI
3361
qrViaRapi :: FrozenSet String
3362
qrViaRapi = qrViaLuxi
3363

    
3364
-- | List of resources which can be queried via RAPI including PUT requests
3365
qrViaRapiPut :: FrozenSet String
3366
qrViaRapiPut = ConstantUtils.mkSet [qrLock, qrJob]
3367

    
3368
-- * Query field types
3369

    
3370
qftBool :: String
3371
qftBool = "bool"
3372

    
3373
qftNumber :: String
3374
qftNumber = "number"
3375

    
3376
qftOther :: String
3377
qftOther = "other"
3378

    
3379
qftText :: String
3380
qftText = "text"
3381

    
3382
qftTimestamp :: String
3383
qftTimestamp = "timestamp"
3384

    
3385
qftUnit :: String
3386
qftUnit = "unit"
3387

    
3388
qftUnknown :: String
3389
qftUnknown = "unknown"
3390

    
3391
qftAll :: FrozenSet String
3392
qftAll =
3393
  ConstantUtils.mkSet [qftBool,
3394
                       qftNumber,
3395
                       qftOther,
3396
                       qftText,
3397
                       qftTimestamp,
3398
                       qftUnit,
3399
                       qftUnknown]
3400

    
3401
-- * Query result field status
3402
--
3403
-- Don't change or reuse values as they're used by clients.
3404
--
3405
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3406

    
3407
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3408
rsNodata :: Int
3409
rsNodata = 2
3410

    
3411
rsNormal :: Int
3412
rsNormal = 0
3413

    
3414
-- | Resource marked offline
3415
rsOffline :: Int
3416
rsOffline = 4
3417

    
3418
-- | Value unavailable/unsupported for item; if this field is
3419
-- supported but we cannot get the data for the moment, 'rsNodata' or
3420
-- 'rsOffline' should be used
3421
rsUnavail :: Int
3422
rsUnavail = 3
3423

    
3424
rsUnknown :: Int
3425
rsUnknown = 1
3426

    
3427
rsAll :: FrozenSet Int
3428
rsAll =
3429
  ConstantUtils.mkSet [rsNodata,
3430
                       rsNormal,
3431
                       rsOffline,
3432
                       rsUnavail,
3433
                       rsUnknown]
3434

    
3435
-- | Special field cases and their verbose/terse formatting
3436
rssDescription :: Map Int (String, String)
3437
rssDescription =
3438
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3439
                (rsNodata, ("(nodata)", "?")),
3440
                (rsOffline, ("(offline)", "*")),
3441
                (rsUnavail, ("(unavail)", "-"))]
3442

    
3443
-- * Max dynamic devices
3444

    
3445
maxDisks :: Int
3446
maxDisks = Types.maxDisks
3447

    
3448
maxNics :: Int
3449
maxNics = Types.maxNics
3450

    
3451
-- | SSCONF file prefix
3452
ssconfFileprefix :: String
3453
ssconfFileprefix = "ssconf_"
3454

    
3455
-- * SSCONF keys
3456

    
3457
ssClusterName :: String
3458
ssClusterName = "cluster_name"
3459

    
3460
ssClusterTags :: String
3461
ssClusterTags = "cluster_tags"
3462

    
3463
ssFileStorageDir :: String
3464
ssFileStorageDir = "file_storage_dir"
3465

    
3466
ssSharedFileStorageDir :: String
3467
ssSharedFileStorageDir = "shared_file_storage_dir"
3468

    
3469
ssGlusterStorageDir :: String
3470
ssGlusterStorageDir = "gluster_storage_dir"
3471

    
3472
ssMasterCandidates :: String
3473
ssMasterCandidates = "master_candidates"
3474

    
3475
ssMasterCandidatesIps :: String
3476
ssMasterCandidatesIps = "master_candidates_ips"
3477

    
3478
ssMasterIp :: String
3479
ssMasterIp = "master_ip"
3480

    
3481
ssMasterNetdev :: String
3482
ssMasterNetdev = "master_netdev"
3483

    
3484
ssMasterNetmask :: String
3485
ssMasterNetmask = "master_netmask"
3486

    
3487
ssMasterNode :: String
3488
ssMasterNode = "master_node"
3489

    
3490
ssNodeList :: String
3491
ssNodeList = "node_list"
3492

    
3493
ssNodePrimaryIps :: String
3494
ssNodePrimaryIps = "node_primary_ips"
3495

    
3496
ssNodeSecondaryIps :: String
3497
ssNodeSecondaryIps = "node_secondary_ips"
3498

    
3499
ssOfflineNodes :: String
3500
ssOfflineNodes = "offline_nodes"
3501

    
3502
ssOnlineNodes :: String
3503
ssOnlineNodes = "online_nodes"
3504

    
3505
ssPrimaryIpFamily :: String
3506
ssPrimaryIpFamily = "primary_ip_family"
3507

    
3508
ssInstanceList :: String
3509
ssInstanceList = "instance_list"
3510

    
3511
ssReleaseVersion :: String
3512
ssReleaseVersion = "release_version"
3513

    
3514
ssHypervisorList :: String
3515
ssHypervisorList = "hypervisor_list"
3516

    
3517
ssMaintainNodeHealth :: String
3518
ssMaintainNodeHealth = "maintain_node_health"
3519

    
3520
ssUidPool :: String
3521
ssUidPool = "uid_pool"
3522

    
3523
ssNodegroups :: String
3524
ssNodegroups = "nodegroups"
3525

    
3526
ssNetworks :: String
3527
ssNetworks = "networks"
3528

    
3529
-- | This is not a complete SSCONF key, but the prefix for the
3530
-- hypervisor keys
3531
ssHvparamsPref :: String
3532
ssHvparamsPref = "hvparams_"
3533

    
3534
-- * Hvparams keys
3535

    
3536
ssHvparamsXenChroot :: String
3537
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3538

    
3539
ssHvparamsXenFake :: String
3540
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3541

    
3542
ssHvparamsXenHvm :: String
3543
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3544

    
3545
ssHvparamsXenKvm :: String
3546
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3547

    
3548
ssHvparamsXenLxc :: String
3549
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3550

    
3551
ssHvparamsXenPvm :: String
3552
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3553

    
3554
validSsHvparamsKeys :: FrozenSet String
3555
validSsHvparamsKeys =
3556
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3557
                       ssHvparamsXenLxc,
3558
                       ssHvparamsXenFake,
3559
                       ssHvparamsXenHvm,
3560
                       ssHvparamsXenKvm,
3561
                       ssHvparamsXenPvm]
3562

    
3563
ssFilePerms :: Int
3564
ssFilePerms = 0o444
3565

    
3566
-- | Cluster wide default parameters
3567
defaultEnabledHypervisor :: String
3568
defaultEnabledHypervisor = htXenPvm
3569

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

    
3682
hvcGlobals :: FrozenSet String
3683
hvcGlobals =
3684
  ConstantUtils.mkSet [hvMigrationBandwidth,
3685
                       hvMigrationMode,
3686
                       hvMigrationPort,
3687
                       hvXenCmd]
3688

    
3689
becDefaults :: Map String PyValueEx
3690
becDefaults =
3691
  Map.fromList
3692
  [ (beMinmem, PyValueEx (128 :: Int))
3693
  , (beMaxmem, PyValueEx (128 :: Int))
3694
  , (beVcpus, PyValueEx (1 :: Int))
3695
  , (beAutoBalance, PyValueEx True)
3696
  , (beAlwaysFailover, PyValueEx False)
3697
  , (beSpindleUse, PyValueEx (1 :: Int))
3698
  ]
3699

    
3700
ndcDefaults :: Map String PyValueEx
3701
ndcDefaults =
3702
  Map.fromList
3703
  [ (ndOobProgram,       PyValueEx "")
3704
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3705
  , (ndExclusiveStorage, PyValueEx False)
3706
  , (ndOvs,              PyValueEx False)
3707
  , (ndOvsName,          PyValueEx defaultOvs)
3708
  , (ndOvsLink,          PyValueEx "")
3709
  , (ndSshPort,          PyValueEx (22 :: Int))
3710
  ]
3711

    
3712
ndcGlobals :: FrozenSet String
3713
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3714

    
3715
-- | Default delay target measured in sectors
3716
defaultDelayTarget :: Int
3717
defaultDelayTarget = 1
3718

    
3719
defaultDiskCustom :: String
3720
defaultDiskCustom = ""
3721

    
3722
defaultDiskResync :: Bool
3723
defaultDiskResync = False
3724

    
3725
-- | Default fill target measured in sectors
3726
defaultFillTarget :: Int
3727
defaultFillTarget = 0
3728

    
3729
-- | Default mininum rate measured in KiB/s
3730
defaultMinRate :: Int
3731
defaultMinRate = 4 * 1024
3732

    
3733
defaultNetCustom :: String
3734
defaultNetCustom = ""
3735

    
3736
-- | Default plan ahead measured in sectors
3737
--
3738
-- The default values for the DRBD dynamic resync speed algorithm are
3739
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3740
-- (that we don't need to set to 0, because we have a separate option
3741
-- to enable it) and for c-max-rate, that we cap to the default value
3742
-- for the static resync rate.
3743
defaultPlanAhead :: Int
3744
defaultPlanAhead = 20
3745

    
3746
defaultRbdPool :: String
3747
defaultRbdPool = "rbd"
3748

    
3749
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3750
diskLdDefaults =
3751
  Map.fromList
3752
  [ (DTBlock, Map.empty)
3753
  , (DTDrbd8, Map.fromList
3754
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3755
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3756
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3757
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3758
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3759
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3760
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3761
              , (ldpMinRate,       PyValueEx defaultMinRate)
3762
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3763
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3764
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3765
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3766
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3767
              ])
3768
  , (DTExt, Map.empty)
3769
  , (DTFile, Map.empty)
3770
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3771
  , (DTRbd, Map.fromList
3772
            [ (ldpPool, PyValueEx defaultRbdPool)
3773
            , (ldpAccess, PyValueEx diskKernelspace)
3774
            ])
3775
  , (DTSharedFile, Map.empty)
3776
  , (DTGluster, Map.empty)
3777
  ]
3778

    
3779
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3780
diskDtDefaults =
3781
  Map.fromList
3782
  [ (DTBlock,      Map.empty)
3783
  , (DTDiskless,   Map.empty)
3784
  , (DTDrbd8,      Map.fromList
3785
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3786
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3787
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3788
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3789
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3790
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3791
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3792
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3793
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3794
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3795
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3796
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3797
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3798
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3799
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3800
                   ])
3801
  , (DTExt,        Map.empty)
3802
  , (DTFile,       Map.empty)
3803
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3804
  , (DTRbd,        Map.fromList
3805
                   [ (rbdPool, PyValueEx defaultRbdPool)
3806
                   , (rbdAccess, PyValueEx diskKernelspace)
3807
                   ])
3808
  , (DTSharedFile, Map.empty)
3809
  , (DTGluster, Map.empty)
3810
  ]
3811

    
3812
niccDefaults :: Map String PyValueEx
3813
niccDefaults =
3814
  Map.fromList
3815
  [ (nicMode, PyValueEx nicModeBridged)
3816
  , (nicLink, PyValueEx defaultBridge)
3817
  , (nicVlan, PyValueEx "")
3818
  ]
3819

    
3820
-- | All of the following values are quite arbitrary - there are no
3821
-- "good" defaults, these must be customised per-site
3822
ispecsMinmaxDefaults :: Map String (Map String Int)
3823
ispecsMinmaxDefaults =
3824
  Map.fromList
3825
  [(ispecsMin,
3826
    Map.fromList
3827
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3828
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3829
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3830
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3831
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3832
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3833
   (ispecsMax,
3834
    Map.fromList
3835
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3836
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3837
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3838
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3839
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3840
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3841

    
3842
ipolicyDefaults :: Map String PyValueEx
3843
ipolicyDefaults =
3844
  Map.fromList
3845
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3846
  , (ispecsStd,           PyValueEx (Map.fromList
3847
                                     [ (ispecMemSize,    128)
3848
                                     , (ispecCpuCount,   1)
3849
                                     , (ispecDiskCount,  1)
3850
                                     , (ispecDiskSize,   1024)
3851
                                     , (ispecNicCount,   1)
3852
                                     , (ispecSpindleUse, 1)
3853
                                     ] :: Map String Int))
3854
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3855
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3856
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3857
  ]
3858

    
3859
masterPoolSizeDefault :: Int
3860
masterPoolSizeDefault = 10
3861

    
3862
-- * Exclusive storage
3863

    
3864
-- | Error margin used to compare physical disks
3865
partMargin :: Double
3866
partMargin = 0.01
3867

    
3868
-- | Space reserved when creating instance disks
3869
partReserved :: Double
3870
partReserved = 0.02
3871

    
3872
-- * Luxid job scheduling
3873

    
3874
-- | Time intervall in seconds for polling updates on the job queue. This
3875
-- intervall is only relevant if the number of running jobs reaches the maximal
3876
-- allowed number, as otherwise new jobs will be started immediately anyway.
3877
luxidJobqueuePollInterval :: Int
3878
luxidJobqueuePollInterval = 3
3879

    
3880
-- | Maximal number of jobs to be running at the same time. Once this number is
3881
-- reached, new jobs will just be queued and only started, once some of the
3882
-- other jobs have finished.
3883
luxidMaximalRunningJobs :: Int
3884
luxidMaximalRunningJobs = 20
3885

    
3886
-- * Confd
3887

    
3888
confdProtocolVersion :: Int
3889
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3890

    
3891
-- Confd request type
3892

    
3893
confdReqPing :: Int
3894
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3895

    
3896
confdReqNodeRoleByname :: Int
3897
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3898

    
3899
confdReqNodePipByInstanceIp :: Int
3900
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3901

    
3902
confdReqClusterMaster :: Int
3903
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3904

    
3905
confdReqNodePipList :: Int
3906
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3907

    
3908
confdReqMcPipList :: Int
3909
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3910

    
3911
confdReqInstancesIpsList :: Int
3912
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3913

    
3914
confdReqNodeDrbd :: Int
3915
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3916

    
3917
confdReqNodeInstances :: Int
3918
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3919

    
3920
confdReqs :: FrozenSet Int
3921
confdReqs =
3922
  ConstantUtils.mkSet .
3923
  map Types.confdRequestTypeToRaw $
3924
  [minBound..] \\ [ReqNodeInstances]
3925

    
3926
-- * Confd request type
3927

    
3928
confdReqfieldName :: Int
3929
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3930

    
3931
confdReqfieldIp :: Int
3932
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3933

    
3934
confdReqfieldMnodePip :: Int
3935
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3936

    
3937
-- * Confd repl status
3938

    
3939
confdReplStatusOk :: Int
3940
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3941

    
3942
confdReplStatusError :: Int
3943
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3944

    
3945
confdReplStatusNotimplemented :: Int
3946
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3947

    
3948
confdReplStatuses :: FrozenSet Int
3949
confdReplStatuses =
3950
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3951

    
3952
-- * Confd node role
3953

    
3954
confdNodeRoleMaster :: Int
3955
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3956

    
3957
confdNodeRoleCandidate :: Int
3958
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3959

    
3960
confdNodeRoleOffline :: Int
3961
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3962

    
3963
confdNodeRoleDrained :: Int
3964
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3965

    
3966
confdNodeRoleRegular :: Int
3967
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3968

    
3969
-- * A few common errors for confd
3970

    
3971
confdErrorUnknownEntry :: Int
3972
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3973

    
3974
confdErrorInternal :: Int
3975
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3976

    
3977
confdErrorArgument :: Int
3978
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3979

    
3980
-- * Confd request query fields
3981

    
3982
confdReqqLink :: String
3983
confdReqqLink = ConstantUtils.confdReqqLink
3984

    
3985
confdReqqIp :: String
3986
confdReqqIp = ConstantUtils.confdReqqIp
3987

    
3988
confdReqqIplist :: String
3989
confdReqqIplist = ConstantUtils.confdReqqIplist
3990

    
3991
confdReqqFields :: String
3992
confdReqqFields = ConstantUtils.confdReqqFields
3993

    
3994
-- | Each request is "salted" by the current timestamp.
3995
--
3996
-- This constant decides how many seconds of skew to accept.
3997
--
3998
-- TODO: make this a default and allow the value to be more
3999
-- configurable
4000
confdMaxClockSkew :: Int
4001
confdMaxClockSkew = 2 * nodeMaxClockSkew
4002

    
4003
-- | When we haven't reloaded the config for more than this amount of
4004
-- seconds, we force a test to see if inotify is betraying us. Using a
4005
-- prime number to ensure we get less chance of 'same wakeup' with
4006
-- other processes.
4007
confdConfigReloadTimeout :: Int
4008
confdConfigReloadTimeout = 17
4009

    
4010
-- | If we receive more than one update in this amount of
4011
-- microseconds, we move to polling every RATELIMIT seconds, rather
4012
-- than relying on inotify, to be able to serve more requests.
4013
confdConfigReloadRatelimit :: Int
4014
confdConfigReloadRatelimit = 250000
4015

    
4016
-- | Magic number prepended to all confd queries.
4017
--
4018
-- This allows us to distinguish different types of confd protocols
4019
-- and handle them. For example by changing this we can move the whole
4020
-- payload to be compressed, or move away from json.
4021
confdMagicFourcc :: String
4022
confdMagicFourcc = "plj0"
4023

    
4024
-- | By default a confd request is sent to the minimum between this
4025
-- number and all MCs. 6 was chosen because even in the case of a
4026
-- disastrous 50% response rate, we should have enough answers to be
4027
-- able to compare more than one.
4028
confdDefaultReqCoverage :: Int
4029
confdDefaultReqCoverage = 6
4030

    
4031
-- | Timeout in seconds to expire pending query request in the confd
4032
-- client library. We don't actually expect any answer more than 10
4033
-- seconds after we sent a request.
4034
confdClientExpireTimeout :: Int
4035
confdClientExpireTimeout = 10
4036

    
4037
-- | Maximum UDP datagram size.
4038
--
4039
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4040
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4041
--   (assuming we can't use jumbo frames)
4042
-- We just set this to 60K, which should be enough
4043
maxUdpDataSize :: Int
4044
maxUdpDataSize = 61440
4045

    
4046
-- * User-id pool minimum/maximum acceptable user-ids
4047

    
4048
uidpoolUidMin :: Int
4049
uidpoolUidMin = 0
4050

    
4051
-- | Assuming 32 bit user-ids
4052
uidpoolUidMax :: Integer
4053
uidpoolUidMax = 2 ^ 32 - 1
4054

    
4055
-- | Name or path of the pgrep command
4056
pgrep :: String
4057
pgrep = "pgrep"
4058

    
4059
-- | Name of the node group that gets created at cluster init or
4060
-- upgrade
4061
initialNodeGroupName :: String
4062
initialNodeGroupName = "default"
4063

    
4064
-- * Possible values for NodeGroup.alloc_policy
4065

    
4066
allocPolicyLastResort :: String
4067
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4068

    
4069
allocPolicyPreferred :: String
4070
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4071

    
4072
allocPolicyUnallocable :: String
4073
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4074

    
4075
validAllocPolicies :: [String]
4076
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4077

    
4078
-- | Temporary external/shared storage parameters
4079
blockdevDriverManual :: String
4080
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4081

    
4082
-- | 'qemu-img' path, required for 'ovfconverter'
4083
qemuimgPath :: String
4084
qemuimgPath = AutoConf.qemuimgPath
4085

    
4086
-- | Whether htools was enabled at compilation time
4087
--
4088
-- FIXME: this should be moved next to the other enable constants,
4089
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4090
htools :: Bool
4091
htools = AutoConf.htools
4092

    
4093
-- | The hail iallocator
4094
iallocHail :: String
4095
iallocHail = "hail"
4096

    
4097
-- * Fake opcodes for functions that have hooks attached to them via
4098
-- backend.RunLocalHooks
4099

    
4100
fakeOpMasterTurndown :: String
4101
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4102

    
4103
fakeOpMasterTurnup :: String
4104
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4105

    
4106
-- * SSH key types
4107

    
4108
sshkDsa :: String
4109
sshkDsa = "dsa"
4110

    
4111
sshkRsa :: String
4112
sshkRsa = "rsa"
4113

    
4114
sshkAll :: FrozenSet String
4115
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4116

    
4117
-- * SSH authorized key types
4118

    
4119
sshakDss :: String
4120
sshakDss = "ssh-dss"
4121

    
4122
sshakRsa :: String
4123
sshakRsa = "ssh-rsa"
4124

    
4125
sshakAll :: FrozenSet String
4126
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4127

    
4128
-- * SSH setup
4129

    
4130
sshsClusterName :: String
4131
sshsClusterName = "cluster_name"
4132

    
4133
sshsSshHostKey :: String
4134
sshsSshHostKey = "ssh_host_key"
4135

    
4136
sshsSshRootKey :: String
4137
sshsSshRootKey = "ssh_root_key"
4138

    
4139
sshsNodeDaemonCertificate :: String
4140
sshsNodeDaemonCertificate = "node_daemon_certificate"
4141

    
4142
-- * Key files for SSH daemon
4143

    
4144
sshHostDsaPriv :: String
4145
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4146

    
4147
sshHostDsaPub :: String
4148
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4149

    
4150
sshHostRsaPriv :: String
4151
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4152

    
4153
sshHostRsaPub :: String
4154
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4155

    
4156
sshDaemonKeyfiles :: Map String (String, String)
4157
sshDaemonKeyfiles =
4158
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4159
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4160
               ]
4161

    
4162
-- * Node daemon setup
4163

    
4164
ndsClusterName :: String
4165
ndsClusterName = "cluster_name"
4166

    
4167
ndsNodeDaemonCertificate :: String
4168
ndsNodeDaemonCertificate = "node_daemon_certificate"
4169

    
4170
ndsSsconf :: String
4171
ndsSsconf = "ssconf"
4172

    
4173
ndsStartNodeDaemon :: String
4174
ndsStartNodeDaemon = "start_node_daemon"
4175

    
4176
-- * The source reasons for the execution of an OpCode
4177

    
4178
opcodeReasonSrcClient :: String
4179
opcodeReasonSrcClient = "gnt:client"
4180

    
4181
opcodeReasonSrcNoded :: String
4182
opcodeReasonSrcNoded = "gnt:daemon:noded"
4183

    
4184
opcodeReasonSrcOpcode :: String
4185
opcodeReasonSrcOpcode = "gnt:opcode"
4186

    
4187
opcodeReasonSrcRlib2 :: String
4188
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4189

    
4190
opcodeReasonSrcUser :: String
4191
opcodeReasonSrcUser = "gnt:user"
4192

    
4193
opcodeReasonSources :: FrozenSet String
4194
opcodeReasonSources =
4195
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4196
                       opcodeReasonSrcNoded,
4197
                       opcodeReasonSrcOpcode,
4198
                       opcodeReasonSrcRlib2,
4199
                       opcodeReasonSrcUser]
4200

    
4201
-- | Path generating random UUID
4202
randomUuidFile :: String
4203
randomUuidFile = ConstantUtils.randomUuidFile
4204

    
4205
-- * Auto-repair tag prefixes
4206

    
4207
autoRepairTagPrefix :: String
4208
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4209

    
4210
autoRepairTagEnabled :: String
4211
autoRepairTagEnabled = autoRepairTagPrefix
4212

    
4213
autoRepairTagPending :: String
4214
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4215

    
4216
autoRepairTagResult :: String
4217
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4218

    
4219
autoRepairTagSuspended :: String
4220
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4221

    
4222
-- * Auto-repair levels
4223

    
4224
autoRepairFailover :: String
4225
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4226

    
4227
autoRepairFixStorage :: String
4228
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4229

    
4230
autoRepairMigrate :: String
4231
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4232

    
4233
autoRepairReinstall :: String
4234
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4235

    
4236
autoRepairAllTypes :: FrozenSet String
4237
autoRepairAllTypes =
4238
  ConstantUtils.mkSet [autoRepairFailover,
4239
                       autoRepairFixStorage,
4240
                       autoRepairMigrate,
4241
                       autoRepairReinstall]
4242

    
4243
-- * Auto-repair results
4244

    
4245
autoRepairEnoperm :: String
4246
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4247

    
4248
autoRepairFailure :: String
4249
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4250

    
4251
autoRepairSuccess :: String
4252
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4253

    
4254
autoRepairAllResults :: FrozenSet String
4255
autoRepairAllResults =
4256
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4257

    
4258
-- | The version identifier for builtin data collectors
4259
builtinDataCollectorVersion :: String
4260
builtinDataCollectorVersion = "B"
4261

    
4262
-- | The reason trail opcode parameter name
4263
opcodeReason :: String
4264
opcodeReason = "reason"
4265

    
4266
diskstatsFile :: String
4267
diskstatsFile = "/proc/diskstats"
4268

    
4269
-- *  CPU load collector
4270

    
4271
statFile :: String
4272
statFile = "/proc/stat"
4273

    
4274
cpuavgloadBufferSize :: Int
4275
cpuavgloadBufferSize = 150
4276

    
4277
cpuavgloadWindowSize :: Int
4278
cpuavgloadWindowSize = 600
4279

    
4280
-- * Monitoring daemon
4281

    
4282
-- | Mond's variable for periodical data collection
4283
mondTimeInterval :: Int
4284
mondTimeInterval = 5
4285

    
4286
-- | Mond's latest API version
4287
mondLatestApiVersion :: Int
4288
mondLatestApiVersion = 1
4289

    
4290
-- * Disk access modes
4291

    
4292
diskUserspace :: String
4293
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4294

    
4295
diskKernelspace :: String
4296
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4297

    
4298
diskValidAccessModes :: FrozenSet String
4299
diskValidAccessModes =
4300
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4301

    
4302
-- | Timeout for queue draining in upgrades
4303
upgradeQueueDrainTimeout :: Int
4304
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4305

    
4306
-- | Intervall at which the queue is polled during upgrades
4307
upgradeQueuePollInterval :: Int
4308
upgradeQueuePollInterval  = 10
4309

    
4310
-- * Hotplug Actions
4311

    
4312
hotplugActionAdd :: String
4313
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4314

    
4315
hotplugActionRemove :: String
4316
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4317

    
4318
hotplugActionModify :: String
4319
hotplugActionModify = Types.hotplugActionToRaw HAMod
4320

    
4321
hotplugAllActions :: FrozenSet String
4322
hotplugAllActions =
4323
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4324

    
4325
-- * Hotplug Device Targets
4326

    
4327
hotplugTargetNic :: String
4328
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4329

    
4330
hotplugTargetDisk :: String
4331
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4332

    
4333
hotplugAllTargets :: FrozenSet String
4334
hotplugAllTargets =
4335
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4336

    
4337
-- | Timeout for disk removal (seconds)
4338
diskRemoveRetryTimeout :: Int
4339
diskRemoveRetryTimeout = 30
4340

    
4341
-- | Interval between disk removal retries (seconds)
4342
diskRemoveRetryInterval :: Int
4343
diskRemoveRetryInterval  = 3
4344

    
4345
-- * UUID regex
4346

    
4347
uuidRegex :: String
4348
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4349

    
4350
-- * Luxi constants
4351

    
4352
luxiKeyMethod :: String
4353
luxiKeyMethod = "method"
4354

    
4355
luxiKeyArgs :: String
4356
luxiKeyArgs = "args"
4357

    
4358
luxiKeySuccess :: String
4359
luxiKeySuccess = "success"
4360

    
4361
luxiKeyResult :: String
4362
luxiKeyResult = "result"
4363

    
4364
luxiKeyVersion :: String
4365
luxiKeyVersion = "version"
4366

    
4367
luxiReqSubmitJob :: String
4368
luxiReqSubmitJob = "SubmitJob"
4369

    
4370
luxiReqSubmitJobToDrainedQueue :: String
4371
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4372

    
4373
luxiReqSubmitManyJobs :: String
4374
luxiReqSubmitManyJobs = "SubmitManyJobs"
4375

    
4376
luxiReqWaitForJobChange :: String
4377
luxiReqWaitForJobChange = "WaitForJobChange"
4378

    
4379
luxiReqPickupJob :: String
4380
luxiReqPickupJob = "PickupJob"
4381

    
4382
luxiReqCancelJob :: String
4383
luxiReqCancelJob = "CancelJob"
4384

    
4385
luxiReqArchiveJob :: String
4386
luxiReqArchiveJob = "ArchiveJob"
4387

    
4388
luxiReqChangeJobPriority :: String
4389
luxiReqChangeJobPriority = "ChangeJobPriority"
4390

    
4391
luxiReqAutoArchiveJobs :: String
4392
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4393

    
4394
luxiReqQuery :: String
4395
luxiReqQuery = "Query"
4396

    
4397
luxiReqQueryFields :: String
4398
luxiReqQueryFields = "QueryFields"
4399

    
4400
luxiReqQueryJobs :: String
4401
luxiReqQueryJobs = "QueryJobs"
4402

    
4403
luxiReqQueryInstances :: String
4404
luxiReqQueryInstances = "QueryInstances"
4405

    
4406
luxiReqQueryNodes :: String
4407
luxiReqQueryNodes = "QueryNodes"
4408

    
4409
luxiReqQueryGroups :: String
4410
luxiReqQueryGroups = "QueryGroups"
4411

    
4412
luxiReqQueryNetworks :: String
4413
luxiReqQueryNetworks = "QueryNetworks"
4414

    
4415
luxiReqQueryExports :: String
4416
luxiReqQueryExports = "QueryExports"
4417

    
4418
luxiReqQueryConfigValues :: String
4419
luxiReqQueryConfigValues = "QueryConfigValues"
4420

    
4421
luxiReqQueryClusterInfo :: String
4422
luxiReqQueryClusterInfo = "QueryClusterInfo"
4423

    
4424
luxiReqQueryTags :: String
4425
luxiReqQueryTags = "QueryTags"
4426

    
4427
luxiReqSetDrainFlag :: String
4428
luxiReqSetDrainFlag = "SetDrainFlag"
4429

    
4430
luxiReqSetWatcherPause :: String
4431
luxiReqSetWatcherPause = "SetWatcherPause"
4432

    
4433
luxiReqAll :: FrozenSet String
4434
luxiReqAll =
4435
  ConstantUtils.mkSet
4436
  [ luxiReqArchiveJob
4437
  , luxiReqAutoArchiveJobs
4438
  , luxiReqCancelJob
4439
  , luxiReqChangeJobPriority
4440
  , luxiReqQuery
4441
  , luxiReqQueryClusterInfo
4442
  , luxiReqQueryConfigValues
4443
  , luxiReqQueryExports
4444
  , luxiReqQueryFields
4445
  , luxiReqQueryGroups
4446
  , luxiReqQueryInstances
4447
  , luxiReqQueryJobs
4448
  , luxiReqQueryNodes
4449
  , luxiReqQueryNetworks
4450
  , luxiReqQueryTags
4451
  , luxiReqSetDrainFlag
4452
  , luxiReqSetWatcherPause
4453
  , luxiReqSubmitJob
4454
  , luxiReqSubmitJobToDrainedQueue
4455
  , luxiReqSubmitManyJobs
4456
  , luxiReqWaitForJobChange
4457
  , luxiReqPickupJob
4458
  ]
4459

    
4460
luxiDefCtmo :: Int
4461
luxiDefCtmo = 10
4462

    
4463
luxiDefRwto :: Int
4464
luxiDefRwto = 60
4465

    
4466
-- | 'WaitForJobChange' timeout
4467
luxiWfjcTimeout :: Int
4468
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4469

    
4470
-- * Query language constants
4471

    
4472
-- ** Logic operators with one or more operands, each of which is a
4473
-- filter on its own
4474

    
4475
qlangOpAnd :: String
4476
qlangOpAnd = "&"
4477

    
4478
qlangOpOr :: String
4479
qlangOpOr = "|"
4480

    
4481
-- ** Unary operators with exactly one operand
4482

    
4483
qlangOpNot :: String
4484
qlangOpNot = "!"
4485

    
4486
qlangOpTrue :: String
4487
qlangOpTrue = "?"
4488

    
4489
-- ** Binary operators with exactly two operands, the field name and
4490
-- an operator-specific value
4491

    
4492
qlangOpContains :: String
4493
qlangOpContains = "=[]"
4494

    
4495
qlangOpEqual :: String
4496
qlangOpEqual = "="
4497

    
4498
qlangOpGe :: String
4499
qlangOpGe = ">="
4500

    
4501
qlangOpGt :: String
4502
qlangOpGt = ">"
4503

    
4504
qlangOpLe :: String
4505
qlangOpLe = "<="
4506

    
4507
qlangOpLt :: String
4508
qlangOpLt = "<"
4509

    
4510
qlangOpNotEqual :: String
4511
qlangOpNotEqual = "!="
4512

    
4513
qlangOpRegexp :: String
4514
qlangOpRegexp = "=~"
4515

    
4516
-- | Characters used for detecting user-written filters (see
4517
-- L{_CheckFilter})
4518

    
4519
qlangFilterDetectionChars :: FrozenSet String
4520
qlangFilterDetectionChars =
4521
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4522
                       ")", "(", "\x0b", "\n",
4523
                       "\r", "\x0c", "/", "<",
4524
                       "\t", ">", "=", "\\", "~"]
4525

    
4526
-- | Characters used to detect globbing filters
4527
qlangGlobDetectionChars :: FrozenSet String
4528
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4529

    
4530
-- * Error related constants
4531
--
4532
-- 'OpPrereqError' failure types
4533

    
4534
-- | Environment error (e.g. node disk error)
4535
errorsEcodeEnviron :: String
4536
errorsEcodeEnviron = "environment_error"
4537

    
4538
-- | Entity already exists
4539
errorsEcodeExists :: String
4540
errorsEcodeExists = "already_exists"
4541

    
4542
-- | Internal cluster error
4543
errorsEcodeFault :: String
4544
errorsEcodeFault = "internal_error"
4545

    
4546
-- | Wrong arguments (at syntax level)
4547
errorsEcodeInval :: String
4548
errorsEcodeInval = "wrong_input"
4549

    
4550
-- | Entity not found
4551
errorsEcodeNoent :: String
4552
errorsEcodeNoent = "unknown_entity"
4553

    
4554
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4555
errorsEcodeNores :: String
4556
errorsEcodeNores = "insufficient_resources"
4557

    
4558
-- | Resource not unique (e.g. MAC or IP duplication)
4559
errorsEcodeNotunique :: String
4560
errorsEcodeNotunique = "resource_not_unique"
4561

    
4562
-- | Resolver errors
4563
errorsEcodeResolver :: String
4564
errorsEcodeResolver = "resolver_error"
4565

    
4566
-- | Wrong entity state
4567
errorsEcodeState :: String
4568
errorsEcodeState = "wrong_state"
4569

    
4570
-- | Temporarily out of resources; operation can be tried again
4571
errorsEcodeTempNores :: String
4572
errorsEcodeTempNores = "temp_insufficient_resources"
4573

    
4574
errorsEcodeAll :: FrozenSet String
4575
errorsEcodeAll =
4576
  ConstantUtils.mkSet [ errorsEcodeNores
4577
                      , errorsEcodeExists
4578
                      , errorsEcodeState
4579
                      , errorsEcodeNotunique
4580
                      , errorsEcodeTempNores
4581
                      , errorsEcodeNoent
4582
                      , errorsEcodeFault
4583
                      , errorsEcodeResolver
4584
                      , errorsEcodeInval
4585
                      , errorsEcodeEnviron
4586
                      ]
4587

    
4588
-- * Jstore related constants
4589

    
4590
jstoreJobsPerArchiveDirectory :: Int
4591
jstoreJobsPerArchiveDirectory = 10000
4592

    
4593
-- * Gluster settings
4594

    
4595
-- | Where Ganeti should manage Gluster volume mountpoints
4596
glusterMountpoint :: String
4597
glusterMountpoint = "/var/run/ganeti/gluster"