Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 54a2661e

History | View | Annotate | Download (118.4 kB)

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

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

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

    
15
-}
16

    
17
{-
18

    
19
Copyright (C) 2013 Google Inc.
20

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

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

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

    
36
-}
37
module Ganeti.Constants where
38

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

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

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

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

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

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

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

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

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

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

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

    
86
-- ** Build-time constants
87

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
135
-- * Various versions
136

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

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

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

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

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

    
152
osApiV10 :: Int
153
osApiV10 = 10
154

    
155
osApiV15 :: Int
156
osApiV15 = 15
157

    
158
osApiV20 :: Int
159
osApiV20 = 20
160

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

    
164
exportVersion :: Int
165
exportVersion = 0
166

    
167
rapiVersion :: Int
168
rapiVersion = 2
169

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

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

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

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

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

    
189
-- * User separation
190

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
239
-- * Cpu pinning separators and constants
240

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

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

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

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

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

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

    
279
-- * Wipe
280

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

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

    
288
minWipeChunkPercent :: Int
289
minWipeChunkPercent = 10
290

    
291
-- * Directories
292

    
293
runDirsMode :: Int
294
runDirsMode = 0o775
295

    
296
secureDirMode :: Int
297
secureDirMode = 0o700
298

    
299
secureFileMode :: Int
300
secureFileMode = 0o600
301

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

    
305
-- * 'autoconf' enable/disable
306

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

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

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

    
316
-- * SSH constants
317

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

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

    
324
-- * Daemons
325

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

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

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

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

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

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

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

    
353
defaultConfdPort :: Int
354
defaultConfdPort = 1814
355

    
356
defaultMondPort :: Int
357
defaultMondPort = 1815
358

    
359
defaultNodedPort :: Int
360
defaultNodedPort = 1811
361

    
362
defaultRapiPort :: Int
363
defaultRapiPort = 5080
364

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

    
373
firstDrbdPort :: Int
374
firstDrbdPort = 11000
375

    
376
lastDrbdPort :: Int
377
lastDrbdPort = 14999
378

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

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

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

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

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

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

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

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

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

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

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

    
421
luxiVersion :: Int
422
luxiVersion = configVersion
423

    
424
-- * Syslog
425

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

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

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

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

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

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

    
444
-- * Xen
445

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

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

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

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

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

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

    
466
-- * KVM and socat
467

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

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

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

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

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

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

    
486
-- * Console types
487

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

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

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

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

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

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

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

    
526
-- * X509
527

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

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

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

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

    
543
-- * Import/export daemon mode
544

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

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

    
551
-- * Import/export transport compression
552

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

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

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

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

    
565
-- * Import/export I/O
566

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

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

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

    
580
-- * Values
581

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

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

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

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

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

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

    
600
-- * Hooks
601

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

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

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

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

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

    
617
hooksVersion :: Int
618
hooksVersion = 2
619

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

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

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

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

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

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

    
637
-- * Hkr
638

    
639
hkrSkip :: Int
640
hkrSkip = 0
641

    
642
hkrFail :: Int
643
hkrFail = 1
644

    
645
hkrSuccess :: Int
646
hkrSuccess = 2
647

    
648
-- * Storage types
649

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
723
-- * Storage operations
724

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

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

    
733
-- * Volume fields
734

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

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

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

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

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

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

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

    
756
-- * Local disk status
757

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

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

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

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

    
772
-- * Disk template types
773

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
910
-- * Drbd
911

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

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

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

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

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

    
928
-- * Drbd barrier types
929

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

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

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

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

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

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

    
960
-- * File backend driver
961

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

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

    
968
fdDefault :: String
969
fdDefault = fdLoop
970

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

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

    
980
-- * Disk access mode
981

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

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

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

    
991
-- * Disk replacement mode
992

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

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

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

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

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

    
1009
-- * Instance export mode
1010

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

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

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

    
1020
-- * Instance creation modes
1021

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

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

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

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

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

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

    
1040
rieVersion :: Int
1041
rieVersion = 0
1042

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

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

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

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

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

    
1063
-- * Import/export config options
1064

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

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

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

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

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

    
1080
-- * Dynamic device modification
1081

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

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

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

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

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

    
1097
-- * Common exit codes
1098

    
1099
exitSuccess :: Int
1100
exitSuccess = 0
1101

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

    
1105
exitNotcluster :: Int
1106
exitNotcluster = 5
1107

    
1108
exitNotmaster :: Int
1109
exitNotmaster = 11
1110

    
1111
exitNodesetupError :: Int
1112
exitNodesetupError = 12
1113

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

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

    
1122
-- * Tags
1123

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

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

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

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

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

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

    
1142
maxTagLen :: Int
1143
maxTagLen = 128
1144

    
1145
maxTagsPerObj :: Int
1146
maxTagsPerObj = 4096
1147

    
1148
-- * Others
1149

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

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

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

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

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

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

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

    
1172
ip4Version :: Int
1173
ip4Version = 4
1174

    
1175
ip6Version :: Int
1176
ip6Version = 6
1177

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

    
1181
tcpPingTimeout :: Int
1182
tcpPingTimeout = 10
1183

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

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

    
1190
minVgSize :: Int
1191
minVgSize = 20480
1192

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

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

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

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

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

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

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

    
1219
-- * Runparts results
1220

    
1221
runpartsErr :: Int
1222
runpartsErr = 2
1223

    
1224
runpartsRun :: Int
1225
runpartsRun = 1
1226

    
1227
runpartsSkip :: Int
1228
runpartsSkip = 0
1229

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

    
1233
-- * RPC
1234

    
1235
rpcEncodingNone :: Int
1236
rpcEncodingNone = 0
1237

    
1238
rpcEncodingZlibBase64 :: Int
1239
rpcEncodingZlibBase64 = 1
1240

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

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

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

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

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

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

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

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

    
1273
-- OS
1274

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1332
esScriptCreate :: String
1333
esScriptCreate = esActionCreate
1334

    
1335
esScriptRemove :: String
1336
esScriptRemove = esActionRemove
1337

    
1338
esScriptGrow :: String
1339
esScriptGrow = esActionGrow
1340

    
1341
esScriptAttach :: String
1342
esScriptAttach = esActionAttach
1343

    
1344
esScriptDetach :: String
1345
esScriptDetach = esActionDetach
1346

    
1347
esScriptSetinfo :: String
1348
esScriptSetinfo = esActionSetinfo
1349

    
1350
esScriptVerify :: String
1351
esScriptVerify = esActionVerify
1352

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

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

    
1366
-- * Reboot types
1367

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

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

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

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

    
1380
-- * Instance reboot behaviors
1381

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

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

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

    
1391
-- * VTypes
1392

    
1393
vtypeBool :: VType
1394
vtypeBool = VTypeBool
1395

    
1396
vtypeInt :: VType
1397
vtypeInt = VTypeInt
1398

    
1399
vtypeMaybeString :: VType
1400
vtypeMaybeString = VTypeMaybeString
1401

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

    
1406
vtypeString :: VType
1407
vtypeString = VTypeString
1408

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1749
-- * Migration statuses
1750

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

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

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

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

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

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

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

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

    
1784
-- * Hypervisor state
1785

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

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

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

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

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

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

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

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

    
1826
-- * Disk state
1827

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

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

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

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

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

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

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

    
1857
-- Backend parameter names
1858

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1986
-- | Node parameter names
1987

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

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

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

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

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

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

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

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

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

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

    
2033
-- * Logical Disks parameters
2034

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2193
-- * Dynamic disk parameters
2194

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

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

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

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

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

    
2210
-- * OOB supported commands
2211

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2390
-- * Hypervisor constants
2391

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

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

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

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

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

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

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

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

    
2416
vncBasePort :: Int
2417
vncBasePort = 5900
2418

    
2419
vncDefaultBindAddress :: String
2420
vncDefaultBindAddress = ip4AddressAny
2421

    
2422
-- * NIC types
2423

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

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

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

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

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

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

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

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

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

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

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

    
2471
-- * Vif types
2472

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

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

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

    
2483
-- * Disk types
2484

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2537
-- * Mouse types
2538

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

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

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

    
2548
-- * Boot order
2549

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

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

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

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

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

    
2566
-- * SPICE lossless image compression options
2567

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

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

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

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

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

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

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

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

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

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

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

    
2610
-- * SPICE video stream detection
2611

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

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

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

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

    
2627
-- * Security models
2628

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

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

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

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

    
2641
-- * Kvm flag values
2642

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

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

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

    
2652
-- * Migration type
2653

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

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

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

    
2664
-- * Cluster verify steps
2665

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

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

    
2673
-- * Cluster Verify error classes
2674

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

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

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

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

    
2687
-- * Cluster Verify error levels
2688

    
2689
cvWarning :: String
2690
cvWarning = "WARNING"
2691

    
2692
cvError :: String
2693
cvError = "ERROR"
2694

    
2695
-- * Cluster Verify error codes and documentation
2696

    
2697
cvEclustercert :: (String, String, String)
2698
cvEclustercert =
2699
  ("cluster",
2700
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2701
   "Cluster certificate files verification failure")
2702

    
2703
cvEclusterclientcert :: (String, String, String)
2704
cvEclusterclientcert =
2705
  ("cluster",
2706
   Types.cVErrorCodeToRaw CvECLUSTERCLIENTCERT,
2707
   "Cluster client certificate files verification failure")
2708

    
2709
cvEclustercfg :: (String, String, String)
2710
cvEclustercfg =
2711
  ("cluster",
2712
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2713
   "Cluster configuration verification failure")
2714

    
2715
cvEclusterdanglinginst :: (String, String, String)
2716
cvEclusterdanglinginst =
2717
  ("node",
2718
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2719
   "Some instances have a non-existing primary node")
2720

    
2721
cvEclusterdanglingnodes :: (String, String, String)
2722
cvEclusterdanglingnodes =
2723
  ("node",
2724
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2725
   "Some nodes belong to non-existing groups")
2726

    
2727
cvEclusterfilecheck :: (String, String, String)
2728
cvEclusterfilecheck =
2729
  ("cluster",
2730
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2731
   "Cluster configuration verification failure")
2732

    
2733
cvEgroupdifferentpvsize :: (String, String, String)
2734
cvEgroupdifferentpvsize =
2735
  ("group",
2736
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2737
   "PVs in the group have different sizes")
2738

    
2739
cvEinstancebadnode :: (String, String, String)
2740
cvEinstancebadnode =
2741
  ("instance",
2742
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2743
   "Instance marked as running lives on an offline node")
2744

    
2745
cvEinstancedown :: (String, String, String)
2746
cvEinstancedown =
2747
  ("instance",
2748
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2749
   "Instance not running on its primary node")
2750

    
2751
cvEinstancefaultydisk :: (String, String, String)
2752
cvEinstancefaultydisk =
2753
  ("instance",
2754
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2755
   "Impossible to retrieve status for a disk")
2756

    
2757
cvEinstancelayout :: (String, String, String)
2758
cvEinstancelayout =
2759
  ("instance",
2760
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2761
   "Instance has multiple secondary nodes")
2762

    
2763
cvEinstancemissingcfgparameter :: (String, String, String)
2764
cvEinstancemissingcfgparameter =
2765
  ("instance",
2766
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2767
   "A configuration parameter for an instance is missing")
2768

    
2769
cvEinstancemissingdisk :: (String, String, String)
2770
cvEinstancemissingdisk =
2771
  ("instance",
2772
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2773
   "Missing volume on an instance")
2774

    
2775
cvEinstancepolicy :: (String, String, String)
2776
cvEinstancepolicy =
2777
  ("instance",
2778
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2779
   "Instance does not meet policy")
2780

    
2781
cvEinstancesplitgroups :: (String, String, String)
2782
cvEinstancesplitgroups =
2783
  ("instance",
2784
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2785
   "Instance with primary and secondary nodes in different groups")
2786

    
2787
cvEinstanceunsuitablenode :: (String, String, String)
2788
cvEinstanceunsuitablenode =
2789
  ("instance",
2790
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2791
   "Instance running on nodes that are not suitable for it")
2792

    
2793
cvEinstancewrongnode :: (String, String, String)
2794
cvEinstancewrongnode =
2795
  ("instance",
2796
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2797
   "Instance running on the wrong node")
2798

    
2799
cvEnodedrbd :: (String, String, String)
2800
cvEnodedrbd =
2801
  ("node",
2802
   Types.cVErrorCodeToRaw CvENODEDRBD,
2803
   "Error parsing the DRBD status file")
2804

    
2805
cvEnodedrbdhelper :: (String, String, String)
2806
cvEnodedrbdhelper =
2807
  ("node",
2808
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2809
   "Error caused by the DRBD helper")
2810

    
2811
cvEnodedrbdversion :: (String, String, String)
2812
cvEnodedrbdversion =
2813
  ("node",
2814
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2815
   "DRBD version mismatch within a node group")
2816

    
2817
cvEnodefilecheck :: (String, String, String)
2818
cvEnodefilecheck =
2819
  ("node",
2820
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2821
   "Error retrieving the checksum of the node files")
2822

    
2823
cvEnodefilestoragepaths :: (String, String, String)
2824
cvEnodefilestoragepaths =
2825
  ("node",
2826
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2827
   "Detected bad file storage paths")
2828

    
2829
cvEnodefilestoragepathunusable :: (String, String, String)
2830
cvEnodefilestoragepathunusable =
2831
  ("node",
2832
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2833
   "File storage path unusable")
2834

    
2835
cvEnodehooks :: (String, String, String)
2836
cvEnodehooks =
2837
  ("node",
2838
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2839
   "Communication failure in hooks execution")
2840

    
2841
cvEnodehv :: (String, String, String)
2842
cvEnodehv =
2843
  ("node",
2844
   Types.cVErrorCodeToRaw CvENODEHV,
2845
   "Hypervisor parameters verification failure")
2846

    
2847
cvEnodelvm :: (String, String, String)
2848
cvEnodelvm =
2849
  ("node",
2850
   Types.cVErrorCodeToRaw CvENODELVM,
2851
   "LVM-related node error")
2852

    
2853
cvEnoden1 :: (String, String, String)
2854
cvEnoden1 =
2855
  ("node",
2856
   Types.cVErrorCodeToRaw CvENODEN1,
2857
   "Not enough memory to accommodate instance failovers")
2858

    
2859
cvEnodenet :: (String, String, String)
2860
cvEnodenet =
2861
  ("node",
2862
   Types.cVErrorCodeToRaw CvENODENET,
2863
   "Network-related node error")
2864

    
2865
cvEnodeoobpath :: (String, String, String)
2866
cvEnodeoobpath =
2867
  ("node",
2868
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2869
   "Invalid Out Of Band path")
2870

    
2871
cvEnodeorphaninstance :: (String, String, String)
2872
cvEnodeorphaninstance =
2873
  ("node",
2874
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2875
   "Unknown intance running on a node")
2876

    
2877
cvEnodeorphanlv :: (String, String, String)
2878
cvEnodeorphanlv =
2879
  ("node",
2880
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2881
   "Unknown LVM logical volume")
2882

    
2883
cvEnodeos :: (String, String, String)
2884
cvEnodeos =
2885
  ("node",
2886
   Types.cVErrorCodeToRaw CvENODEOS,
2887
   "OS-related node error")
2888

    
2889
cvEnoderpc :: (String, String, String)
2890
cvEnoderpc =
2891
  ("node",
2892
   Types.cVErrorCodeToRaw CvENODERPC,
2893
   "Error during connection to the primary node of an instance")
2894

    
2895
cvEnodesetup :: (String, String, String)
2896
cvEnodesetup =
2897
  ("node",
2898
   Types.cVErrorCodeToRaw CvENODESETUP,
2899
   "Node setup error")
2900

    
2901
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2902
cvEnodesharedfilestoragepathunusable =
2903
  ("node",
2904
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2905
   "Shared file storage path unusable")
2906

    
2907
cvEnodessh :: (String, String, String)
2908
cvEnodessh =
2909
  ("node",
2910
   Types.cVErrorCodeToRaw CvENODESSH,
2911
   "SSH-related node error")
2912

    
2913
cvEnodetime :: (String, String, String)
2914
cvEnodetime =
2915
  ("node",
2916
   Types.cVErrorCodeToRaw CvENODETIME,
2917
   "Node returned invalid time")
2918

    
2919
cvEnodeuserscripts :: (String, String, String)
2920
cvEnodeuserscripts =
2921
  ("node",
2922
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2923
   "User scripts not present or not executable")
2924

    
2925
cvEnodeversion :: (String, String, String)
2926
cvEnodeversion =
2927
  ("node",
2928
   Types.cVErrorCodeToRaw CvENODEVERSION,
2929
   "Protocol version mismatch or Ganeti version mismatch")
2930

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

    
2973
cvAllEcodesStrings :: FrozenSet String
2974
cvAllEcodesStrings =
2975
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2976

    
2977
-- * Node verify constants
2978

    
2979
nvBridges :: String
2980
nvBridges = "bridges"
2981

    
2982
nvClientCert :: String
2983
nvClientCert = "client-cert"
2984

    
2985
nvDrbdhelper :: String
2986
nvDrbdhelper = "drbd-helper"
2987

    
2988
nvDrbdversion :: String
2989
nvDrbdversion = "drbd-version"
2990

    
2991
nvDrbdlist :: String
2992
nvDrbdlist = "drbd-list"
2993

    
2994
nvExclusivepvs :: String
2995
nvExclusivepvs = "exclusive-pvs"
2996

    
2997
nvFilelist :: String
2998
nvFilelist = "filelist"
2999

    
3000
nvAcceptedStoragePaths :: String
3001
nvAcceptedStoragePaths = "allowed-file-storage-paths"
3002

    
3003
nvFileStoragePath :: String
3004
nvFileStoragePath = "file-storage-path"
3005

    
3006
nvSharedFileStoragePath :: String
3007
nvSharedFileStoragePath = "shared-file-storage-path"
3008

    
3009
nvHvinfo :: String
3010
nvHvinfo = "hvinfo"
3011

    
3012
nvHvparams :: String
3013
nvHvparams = "hvparms"
3014

    
3015
nvHypervisor :: String
3016
nvHypervisor = "hypervisor"
3017

    
3018
nvInstancelist :: String
3019
nvInstancelist = "instancelist"
3020

    
3021
nvLvlist :: String
3022
nvLvlist = "lvlist"
3023

    
3024
nvMasterip :: String
3025
nvMasterip = "master-ip"
3026

    
3027
nvNodelist :: String
3028
nvNodelist = "nodelist"
3029

    
3030
nvNodenettest :: String
3031
nvNodenettest = "node-net-test"
3032

    
3033
nvNodesetup :: String
3034
nvNodesetup = "nodesetup"
3035

    
3036
nvOobPaths :: String
3037
nvOobPaths = "oob-paths"
3038

    
3039
nvOslist :: String
3040
nvOslist = "oslist"
3041

    
3042
nvPvlist :: String
3043
nvPvlist = "pvlist"
3044

    
3045
nvTime :: String
3046
nvTime = "time"
3047

    
3048
nvUserscripts :: String
3049
nvUserscripts = "user-scripts"
3050

    
3051
nvVersion :: String
3052
nvVersion = "version"
3053

    
3054
nvVglist :: String
3055
nvVglist = "vglist"
3056

    
3057
nvVmnodes :: String
3058
nvVmnodes = "vmnodes"
3059

    
3060
-- * Instance status
3061

    
3062
inststAdmindown :: String
3063
inststAdmindown = Types.instanceStatusToRaw StatusDown
3064

    
3065
inststAdminoffline :: String
3066
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3067

    
3068
inststErrordown :: String
3069
inststErrordown = Types.instanceStatusToRaw ErrorDown
3070

    
3071
inststErrorup :: String
3072
inststErrorup = Types.instanceStatusToRaw ErrorUp
3073

    
3074
inststNodedown :: String
3075
inststNodedown = Types.instanceStatusToRaw NodeDown
3076

    
3077
inststNodeoffline :: String
3078
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3079

    
3080
inststRunning :: String
3081
inststRunning = Types.instanceStatusToRaw Running
3082

    
3083
inststUserdown :: String
3084
inststUserdown = Types.instanceStatusToRaw UserDown
3085

    
3086
inststWrongnode :: String
3087
inststWrongnode = Types.instanceStatusToRaw WrongNode
3088

    
3089
inststAll :: FrozenSet String
3090
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3091

    
3092
-- * Admin states
3093

    
3094
adminstDown :: String
3095
adminstDown = Types.adminStateToRaw AdminDown
3096

    
3097
adminstOffline :: String
3098
adminstOffline = Types.adminStateToRaw AdminOffline
3099

    
3100
adminstUp :: String
3101
adminstUp = Types.adminStateToRaw AdminUp
3102

    
3103
adminstAll :: FrozenSet String
3104
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3105

    
3106
-- * Node roles
3107

    
3108
nrDrained :: String
3109
nrDrained = Types.nodeRoleToRaw NRDrained
3110

    
3111
nrMaster :: String
3112
nrMaster = Types.nodeRoleToRaw NRMaster
3113

    
3114
nrMcandidate :: String
3115
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3116

    
3117
nrOffline :: String
3118
nrOffline = Types.nodeRoleToRaw NROffline
3119

    
3120
nrRegular :: String
3121
nrRegular = Types.nodeRoleToRaw NRRegular
3122

    
3123
nrAll :: FrozenSet String
3124
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3125

    
3126
-- * SSL certificate check constants (in days)
3127

    
3128
sslCertExpirationError :: Int
3129
sslCertExpirationError = 7
3130

    
3131
sslCertExpirationWarn :: Int
3132
sslCertExpirationWarn = 30
3133

    
3134
-- * Allocator framework constants
3135

    
3136
iallocatorVersion :: Int
3137
iallocatorVersion = 2
3138

    
3139
iallocatorDirIn :: String
3140
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3141

    
3142
iallocatorDirOut :: String
3143
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3144

    
3145
validIallocatorDirections :: FrozenSet String
3146
validIallocatorDirections =
3147
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3148

    
3149
iallocatorModeAlloc :: String
3150
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3151

    
3152
iallocatorModeChgGroup :: String
3153
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3154

    
3155
iallocatorModeMultiAlloc :: String
3156
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3157

    
3158
iallocatorModeNodeEvac :: String
3159
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3160

    
3161
iallocatorModeReloc :: String
3162
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3163

    
3164
validIallocatorModes :: FrozenSet String
3165
validIallocatorModes =
3166
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3167

    
3168
iallocatorSearchPath :: [String]
3169
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3170

    
3171
defaultIallocatorShortcut :: String
3172
defaultIallocatorShortcut = "."
3173

    
3174
-- * Node evacuation
3175

    
3176
nodeEvacPri :: String
3177
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3178

    
3179
nodeEvacSec :: String
3180
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3181

    
3182
nodeEvacAll :: String
3183
nodeEvacAll = Types.evacModeToRaw ChangeAll
3184

    
3185
nodeEvacModes :: FrozenSet String
3186
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3187

    
3188
-- * Job queue
3189

    
3190
jobQueueVersion :: Int
3191
jobQueueVersion = 1
3192

    
3193
jobQueueSizeHardLimit :: Int
3194
jobQueueSizeHardLimit = 5000
3195

    
3196
jobQueueFilesPerms :: Int
3197
jobQueueFilesPerms = 0o640
3198

    
3199
-- * Unchanged job return
3200

    
3201
jobNotchanged :: String
3202
jobNotchanged = "nochange"
3203

    
3204
-- * Job status
3205

    
3206
jobStatusQueued :: String
3207
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3208

    
3209
jobStatusWaiting :: String
3210
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3211

    
3212
jobStatusCanceling :: String
3213
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3214

    
3215
jobStatusRunning :: String
3216
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3217

    
3218
jobStatusCanceled :: String
3219
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3220

    
3221
jobStatusSuccess :: String
3222
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3223

    
3224
jobStatusError :: String
3225
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3226

    
3227
jobsPending :: FrozenSet String
3228
jobsPending =
3229
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3230

    
3231
jobsFinalized :: FrozenSet String
3232
jobsFinalized =
3233
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3234

    
3235
jobStatusAll :: FrozenSet String
3236
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3237

    
3238
-- * OpCode status
3239

    
3240
-- ** Not yet finalized opcodes
3241

    
3242
opStatusCanceling :: String
3243
opStatusCanceling = "canceling"
3244

    
3245
opStatusQueued :: String
3246
opStatusQueued = "queued"
3247

    
3248
opStatusRunning :: String
3249
opStatusRunning = "running"
3250

    
3251
opStatusWaiting :: String
3252
opStatusWaiting = "waiting"
3253

    
3254
-- ** Finalized opcodes
3255

    
3256
opStatusCanceled :: String
3257
opStatusCanceled = "canceled"
3258

    
3259
opStatusError :: String
3260
opStatusError = "error"
3261

    
3262
opStatusSuccess :: String
3263
opStatusSuccess = "success"
3264

    
3265
opsFinalized :: FrozenSet String
3266
opsFinalized =
3267
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3268

    
3269
-- * OpCode priority
3270

    
3271
opPrioLowest :: Int
3272
opPrioLowest = 19
3273

    
3274
opPrioHighest :: Int
3275
opPrioHighest = -20
3276

    
3277
opPrioLow :: Int
3278
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3279

    
3280
opPrioNormal :: Int
3281
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3282

    
3283
opPrioHigh :: Int
3284
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3285

    
3286
opPrioSubmitValid :: FrozenSet Int
3287
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3288

    
3289
opPrioDefault :: Int
3290
opPrioDefault = opPrioNormal
3291

    
3292
-- * Lock recalculate mode
3293

    
3294
locksAppend :: String
3295
locksAppend = "append"
3296

    
3297
locksReplace :: String
3298
locksReplace = "replace"
3299

    
3300
-- * Lock timeout
3301
--
3302
-- The lock timeout (sum) before we transition into blocking acquire
3303
-- (this can still be reset by priority change).  Computed as max time
3304
-- (10 hours) before we should actually go into blocking acquire,
3305
-- given that we start from the default priority level.
3306

    
3307
lockAttemptsMaxwait :: Double
3308
lockAttemptsMaxwait = 15.0
3309

    
3310
lockAttemptsMinwait :: Double
3311
lockAttemptsMinwait = 1.0
3312

    
3313
lockAttemptsTimeout :: Int
3314
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3315

    
3316
-- * Execution log types
3317

    
3318
elogMessage :: String
3319
elogMessage = Types.eLogTypeToRaw ELogMessage
3320

    
3321
elogRemoteImport :: String
3322
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3323

    
3324
elogJqueueTest :: String
3325
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3326

    
3327
-- * /etc/hosts modification
3328

    
3329
etcHostsAdd :: String
3330
etcHostsAdd = "add"
3331

    
3332
etcHostsRemove :: String
3333
etcHostsRemove = "remove"
3334

    
3335
-- * Job queue test
3336

    
3337
jqtMsgprefix :: String
3338
jqtMsgprefix = "TESTMSG="
3339

    
3340
jqtExec :: String
3341
jqtExec = "exec"
3342

    
3343
jqtExpandnames :: String
3344
jqtExpandnames = "expandnames"
3345

    
3346
jqtLogmsg :: String
3347
jqtLogmsg = "logmsg"
3348

    
3349
jqtStartmsg :: String
3350
jqtStartmsg = "startmsg"
3351

    
3352
jqtAll :: FrozenSet String
3353
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3354

    
3355
-- * Query resources
3356

    
3357
qrCluster :: String
3358
qrCluster = "cluster"
3359

    
3360
qrExport :: String
3361
qrExport = "export"
3362

    
3363
qrExtstorage :: String
3364
qrExtstorage = "extstorage"
3365

    
3366
qrGroup :: String
3367
qrGroup = "group"
3368

    
3369
qrInstance :: String
3370
qrInstance = "instance"
3371

    
3372
qrJob :: String
3373
qrJob = "job"
3374

    
3375
qrLock :: String
3376
qrLock = "lock"
3377

    
3378
qrNetwork :: String
3379
qrNetwork = "network"
3380

    
3381
qrNode :: String
3382
qrNode = "node"
3383

    
3384
qrOs :: String
3385
qrOs = "os"
3386

    
3387
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3388
qrViaOp :: FrozenSet String
3389
qrViaOp =
3390
  ConstantUtils.mkSet [qrCluster,
3391
                       qrOs,
3392
                       qrExtstorage]
3393

    
3394
-- | List of resources which can be queried using Local UniX Interface
3395
qrViaLuxi :: FrozenSet String
3396
qrViaLuxi = ConstantUtils.mkSet [qrGroup,
3397
                                 qrExport,
3398
                                 qrInstance,
3399
                                 qrJob,
3400
                                 qrLock,
3401
                                 qrNetwork,
3402
                                 qrNode]
3403

    
3404
-- | List of resources which can be queried using RAPI
3405
qrViaRapi :: FrozenSet String
3406
qrViaRapi = qrViaLuxi
3407

    
3408
-- | List of resources which can be queried via RAPI including PUT requests
3409
qrViaRapiPut :: FrozenSet String
3410
qrViaRapiPut = ConstantUtils.mkSet [qrLock, qrJob]
3411

    
3412
-- * Query field types
3413

    
3414
qftBool :: String
3415
qftBool = "bool"
3416

    
3417
qftNumber :: String
3418
qftNumber = "number"
3419

    
3420
qftOther :: String
3421
qftOther = "other"
3422

    
3423
qftText :: String
3424
qftText = "text"
3425

    
3426
qftTimestamp :: String
3427
qftTimestamp = "timestamp"
3428

    
3429
qftUnit :: String
3430
qftUnit = "unit"
3431

    
3432
qftUnknown :: String
3433
qftUnknown = "unknown"
3434

    
3435
qftAll :: FrozenSet String
3436
qftAll =
3437
  ConstantUtils.mkSet [qftBool,
3438
                       qftNumber,
3439
                       qftOther,
3440
                       qftText,
3441
                       qftTimestamp,
3442
                       qftUnit,
3443
                       qftUnknown]
3444

    
3445
-- * Query result field status
3446
--
3447
-- Don't change or reuse values as they're used by clients.
3448
--
3449
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3450

    
3451
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3452
rsNodata :: Int
3453
rsNodata = 2
3454

    
3455
rsNormal :: Int
3456
rsNormal = 0
3457

    
3458
-- | Resource marked offline
3459
rsOffline :: Int
3460
rsOffline = 4
3461

    
3462
-- | Value unavailable/unsupported for item; if this field is
3463
-- supported but we cannot get the data for the moment, 'rsNodata' or
3464
-- 'rsOffline' should be used
3465
rsUnavail :: Int
3466
rsUnavail = 3
3467

    
3468
rsUnknown :: Int
3469
rsUnknown = 1
3470

    
3471
rsAll :: FrozenSet Int
3472
rsAll =
3473
  ConstantUtils.mkSet [rsNodata,
3474
                       rsNormal,
3475
                       rsOffline,
3476
                       rsUnavail,
3477
                       rsUnknown]
3478

    
3479
-- | Special field cases and their verbose/terse formatting
3480
rssDescription :: Map Int (String, String)
3481
rssDescription =
3482
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3483
                (rsNodata, ("(nodata)", "?")),
3484
                (rsOffline, ("(offline)", "*")),
3485
                (rsUnavail, ("(unavail)", "-"))]
3486

    
3487
-- * Max dynamic devices
3488

    
3489
maxDisks :: Int
3490
maxDisks = Types.maxDisks
3491

    
3492
maxNics :: Int
3493
maxNics = Types.maxNics
3494

    
3495
-- | SSCONF file prefix
3496
ssconfFileprefix :: String
3497
ssconfFileprefix = "ssconf_"
3498

    
3499
-- * SSCONF keys
3500

    
3501
ssClusterName :: String
3502
ssClusterName = "cluster_name"
3503

    
3504
ssClusterTags :: String
3505
ssClusterTags = "cluster_tags"
3506

    
3507
ssFileStorageDir :: String
3508
ssFileStorageDir = "file_storage_dir"
3509

    
3510
ssSharedFileStorageDir :: String
3511
ssSharedFileStorageDir = "shared_file_storage_dir"
3512

    
3513
ssGlusterStorageDir :: String
3514
ssGlusterStorageDir = "gluster_storage_dir"
3515

    
3516
ssMasterCandidates :: String
3517
ssMasterCandidates = "master_candidates"
3518

    
3519
ssMasterCandidatesIps :: String
3520
ssMasterCandidatesIps = "master_candidates_ips"
3521

    
3522
ssMasterCandidatesCerts :: String
3523
ssMasterCandidatesCerts = "master_candidates_certs"
3524

    
3525
ssMasterIp :: String
3526
ssMasterIp = "master_ip"
3527

    
3528
ssMasterNetdev :: String
3529
ssMasterNetdev = "master_netdev"
3530

    
3531
ssMasterNetmask :: String
3532
ssMasterNetmask = "master_netmask"
3533

    
3534
ssMasterNode :: String
3535
ssMasterNode = "master_node"
3536

    
3537
ssNodeList :: String
3538
ssNodeList = "node_list"
3539

    
3540
ssNodePrimaryIps :: String
3541
ssNodePrimaryIps = "node_primary_ips"
3542

    
3543
ssNodeSecondaryIps :: String
3544
ssNodeSecondaryIps = "node_secondary_ips"
3545

    
3546
ssOfflineNodes :: String
3547
ssOfflineNodes = "offline_nodes"
3548

    
3549
ssOnlineNodes :: String
3550
ssOnlineNodes = "online_nodes"
3551

    
3552
ssPrimaryIpFamily :: String
3553
ssPrimaryIpFamily = "primary_ip_family"
3554

    
3555
ssInstanceList :: String
3556
ssInstanceList = "instance_list"
3557

    
3558
ssReleaseVersion :: String
3559
ssReleaseVersion = "release_version"
3560

    
3561
ssHypervisorList :: String
3562
ssHypervisorList = "hypervisor_list"
3563

    
3564
ssMaintainNodeHealth :: String
3565
ssMaintainNodeHealth = "maintain_node_health"
3566

    
3567
ssUidPool :: String
3568
ssUidPool = "uid_pool"
3569

    
3570
ssNodegroups :: String
3571
ssNodegroups = "nodegroups"
3572

    
3573
ssNetworks :: String
3574
ssNetworks = "networks"
3575

    
3576
-- | This is not a complete SSCONF key, but the prefix for the
3577
-- hypervisor keys
3578
ssHvparamsPref :: String
3579
ssHvparamsPref = "hvparams_"
3580

    
3581
-- * Hvparams keys
3582

    
3583
ssHvparamsXenChroot :: String
3584
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3585

    
3586
ssHvparamsXenFake :: String
3587
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3588

    
3589
ssHvparamsXenHvm :: String
3590
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3591

    
3592
ssHvparamsXenKvm :: String
3593
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3594

    
3595
ssHvparamsXenLxc :: String
3596
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3597

    
3598
ssHvparamsXenPvm :: String
3599
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3600

    
3601
validSsHvparamsKeys :: FrozenSet String
3602
validSsHvparamsKeys =
3603
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3604
                       ssHvparamsXenLxc,
3605
                       ssHvparamsXenFake,
3606
                       ssHvparamsXenHvm,
3607
                       ssHvparamsXenKvm,
3608
                       ssHvparamsXenPvm]
3609

    
3610
ssFilePerms :: Int
3611
ssFilePerms = 0o444
3612

    
3613
-- | Cluster wide default parameters
3614
defaultEnabledHypervisor :: String
3615
defaultEnabledHypervisor = htXenPvm
3616

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

    
3729
hvcGlobals :: FrozenSet String
3730
hvcGlobals =
3731
  ConstantUtils.mkSet [hvMigrationBandwidth,
3732
                       hvMigrationMode,
3733
                       hvMigrationPort,
3734
                       hvXenCmd]
3735

    
3736
becDefaults :: Map String PyValueEx
3737
becDefaults =
3738
  Map.fromList
3739
  [ (beMinmem, PyValueEx (128 :: Int))
3740
  , (beMaxmem, PyValueEx (128 :: Int))
3741
  , (beVcpus, PyValueEx (1 :: Int))
3742
  , (beAutoBalance, PyValueEx True)
3743
  , (beAlwaysFailover, PyValueEx False)
3744
  , (beSpindleUse, PyValueEx (1 :: Int))
3745
  ]
3746

    
3747
ndcDefaults :: Map String PyValueEx
3748
ndcDefaults =
3749
  Map.fromList
3750
  [ (ndOobProgram,       PyValueEx "")
3751
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3752
  , (ndExclusiveStorage, PyValueEx False)
3753
  , (ndOvs,              PyValueEx False)
3754
  , (ndOvsName,          PyValueEx defaultOvs)
3755
  , (ndOvsLink,          PyValueEx "")
3756
  , (ndSshPort,          PyValueEx (22 :: Int))
3757
  ]
3758

    
3759
ndcGlobals :: FrozenSet String
3760
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3761

    
3762
-- | Default delay target measured in sectors
3763
defaultDelayTarget :: Int
3764
defaultDelayTarget = 1
3765

    
3766
defaultDiskCustom :: String
3767
defaultDiskCustom = ""
3768

    
3769
defaultDiskResync :: Bool
3770
defaultDiskResync = False
3771

    
3772
-- | Default fill target measured in sectors
3773
defaultFillTarget :: Int
3774
defaultFillTarget = 0
3775

    
3776
-- | Default mininum rate measured in KiB/s
3777
defaultMinRate :: Int
3778
defaultMinRate = 4 * 1024
3779

    
3780
defaultNetCustom :: String
3781
defaultNetCustom = ""
3782

    
3783
-- | Default plan ahead measured in sectors
3784
--
3785
-- The default values for the DRBD dynamic resync speed algorithm are
3786
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3787
-- (that we don't need to set to 0, because we have a separate option
3788
-- to enable it) and for c-max-rate, that we cap to the default value
3789
-- for the static resync rate.
3790
defaultPlanAhead :: Int
3791
defaultPlanAhead = 20
3792

    
3793
defaultRbdPool :: String
3794
defaultRbdPool = "rbd"
3795

    
3796
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3797
diskLdDefaults =
3798
  Map.fromList
3799
  [ (DTBlock, Map.empty)
3800
  , (DTDrbd8, Map.fromList
3801
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3802
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3803
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3804
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3805
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3806
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3807
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3808
              , (ldpMinRate,       PyValueEx defaultMinRate)
3809
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3810
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3811
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3812
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3813
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3814
              ])
3815
  , (DTExt, Map.empty)
3816
  , (DTFile, Map.empty)
3817
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3818
  , (DTRbd, Map.fromList
3819
            [ (ldpPool, PyValueEx defaultRbdPool)
3820
            , (ldpAccess, PyValueEx diskKernelspace)
3821
            ])
3822
  , (DTSharedFile, Map.empty)
3823
  , (DTGluster, Map.fromList
3824
                [ (rbdAccess, PyValueEx diskKernelspace)
3825
                , (glusterHost, PyValueEx glusterHostDefault)
3826
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3827
                , (glusterPort, PyValueEx glusterPortDefault)
3828
                ])
3829
  ]
3830

    
3831
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3832
diskDtDefaults =
3833
  Map.fromList
3834
  [ (DTBlock,      Map.empty)
3835
  , (DTDiskless,   Map.empty)
3836
  , (DTDrbd8,      Map.fromList
3837
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3838
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3839
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3840
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3841
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3842
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3843
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3844
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3845
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3846
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3847
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3848
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3849
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3850
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3851
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3852
                   ])
3853
  , (DTExt,        Map.empty)
3854
  , (DTFile,       Map.empty)
3855
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3856
  , (DTRbd,        Map.fromList
3857
                   [ (rbdPool, PyValueEx defaultRbdPool)
3858
                   , (rbdAccess, PyValueEx diskKernelspace)
3859
                   ])
3860
  , (DTSharedFile, Map.empty)
3861
  , (DTGluster, Map.fromList
3862
                [ (rbdAccess, PyValueEx diskKernelspace)
3863
                , (glusterHost, PyValueEx glusterHostDefault)
3864
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3865
                , (glusterPort, PyValueEx glusterPortDefault)
3866
                ])
3867
  ]
3868

    
3869
niccDefaults :: Map String PyValueEx
3870
niccDefaults =
3871
  Map.fromList
3872
  [ (nicMode, PyValueEx nicModeBridged)
3873
  , (nicLink, PyValueEx defaultBridge)
3874
  , (nicVlan, PyValueEx "")
3875
  ]
3876

    
3877
-- | All of the following values are quite arbitrary - there are no
3878
-- "good" defaults, these must be customised per-site
3879
ispecsMinmaxDefaults :: Map String (Map String Int)
3880
ispecsMinmaxDefaults =
3881
  Map.fromList
3882
  [(ispecsMin,
3883
    Map.fromList
3884
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3885
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3886
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3887
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3888
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3889
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3890
   (ispecsMax,
3891
    Map.fromList
3892
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3893
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3894
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3895
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3896
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3897
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3898

    
3899
ipolicyDefaults :: Map String PyValueEx
3900
ipolicyDefaults =
3901
  Map.fromList
3902
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3903
  , (ispecsStd,           PyValueEx (Map.fromList
3904
                                     [ (ispecMemSize,    128)
3905
                                     , (ispecCpuCount,   1)
3906
                                     , (ispecDiskCount,  1)
3907
                                     , (ispecDiskSize,   1024)
3908
                                     , (ispecNicCount,   1)
3909
                                     , (ispecSpindleUse, 1)
3910
                                     ] :: Map String Int))
3911
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3912
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3913
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3914
  ]
3915

    
3916
masterPoolSizeDefault :: Int
3917
masterPoolSizeDefault = 10
3918

    
3919
-- * Exclusive storage
3920

    
3921
-- | Error margin used to compare physical disks
3922
partMargin :: Double
3923
partMargin = 0.01
3924

    
3925
-- | Space reserved when creating instance disks
3926
partReserved :: Double
3927
partReserved = 0.02
3928

    
3929
-- * Luxid job scheduling
3930

    
3931
-- | Time intervall in seconds for polling updates on the job queue. This
3932
-- intervall is only relevant if the number of running jobs reaches the maximal
3933
-- allowed number, as otherwise new jobs will be started immediately anyway.
3934
-- Also, as jobs are watched via inotify, scheduling usually works independent
3935
-- of polling. Therefore we chose a sufficiently large interval, in the order of
3936
-- 5 minutes. As with the interval for reloading the configuration, we chose a
3937
-- prime number to avoid accidental 'same wakeup' with other processes.
3938
luxidJobqueuePollInterval :: Int
3939
luxidJobqueuePollInterval = 307
3940

    
3941
-- | Maximal number of jobs to be running at the same time. Once this number is
3942
-- reached, new jobs will just be queued and only started, once some of the
3943
-- other jobs have finished.
3944
luxidMaximalRunningJobs :: Int
3945
luxidMaximalRunningJobs = 20
3946

    
3947
-- * Confd
3948

    
3949
confdProtocolVersion :: Int
3950
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3951

    
3952
-- Confd request type
3953

    
3954
confdReqPing :: Int
3955
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3956

    
3957
confdReqNodeRoleByname :: Int
3958
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3959

    
3960
confdReqNodePipByInstanceIp :: Int
3961
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3962

    
3963
confdReqClusterMaster :: Int
3964
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3965

    
3966
confdReqNodePipList :: Int
3967
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3968

    
3969
confdReqMcPipList :: Int
3970
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3971

    
3972
confdReqInstancesIpsList :: Int
3973
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3974

    
3975
confdReqNodeDrbd :: Int
3976
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3977

    
3978
confdReqNodeInstances :: Int
3979
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3980

    
3981
confdReqs :: FrozenSet Int
3982
confdReqs =
3983
  ConstantUtils.mkSet .
3984
  map Types.confdRequestTypeToRaw $
3985
  [minBound..] \\ [ReqNodeInstances]
3986

    
3987
-- * Confd request type
3988

    
3989
confdReqfieldName :: Int
3990
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3991

    
3992
confdReqfieldIp :: Int
3993
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3994

    
3995
confdReqfieldMnodePip :: Int
3996
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3997

    
3998
-- * Confd repl status
3999

    
4000
confdReplStatusOk :: Int
4001
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
4002

    
4003
confdReplStatusError :: Int
4004
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
4005

    
4006
confdReplStatusNotimplemented :: Int
4007
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
4008

    
4009
confdReplStatuses :: FrozenSet Int
4010
confdReplStatuses =
4011
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
4012

    
4013
-- * Confd node role
4014

    
4015
confdNodeRoleMaster :: Int
4016
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
4017

    
4018
confdNodeRoleCandidate :: Int
4019
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
4020

    
4021
confdNodeRoleOffline :: Int
4022
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
4023

    
4024
confdNodeRoleDrained :: Int
4025
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
4026

    
4027
confdNodeRoleRegular :: Int
4028
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
4029

    
4030
-- * A few common errors for confd
4031

    
4032
confdErrorUnknownEntry :: Int
4033
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
4034

    
4035
confdErrorInternal :: Int
4036
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
4037

    
4038
confdErrorArgument :: Int
4039
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
4040

    
4041
-- * Confd request query fields
4042

    
4043
confdReqqLink :: String
4044
confdReqqLink = ConstantUtils.confdReqqLink
4045

    
4046
confdReqqIp :: String
4047
confdReqqIp = ConstantUtils.confdReqqIp
4048

    
4049
confdReqqIplist :: String
4050
confdReqqIplist = ConstantUtils.confdReqqIplist
4051

    
4052
confdReqqFields :: String
4053
confdReqqFields = ConstantUtils.confdReqqFields
4054

    
4055
-- | Each request is "salted" by the current timestamp.
4056
--
4057
-- This constant decides how many seconds of skew to accept.
4058
--
4059
-- TODO: make this a default and allow the value to be more
4060
-- configurable
4061
confdMaxClockSkew :: Int
4062
confdMaxClockSkew = 2 * nodeMaxClockSkew
4063

    
4064
-- | When we haven't reloaded the config for more than this amount of
4065
-- seconds, we force a test to see if inotify is betraying us. Using a
4066
-- prime number to ensure we get less chance of 'same wakeup' with
4067
-- other processes.
4068
confdConfigReloadTimeout :: Int
4069
confdConfigReloadTimeout = 17
4070

    
4071
-- | If we receive more than one update in this amount of
4072
-- microseconds, we move to polling every RATELIMIT seconds, rather
4073
-- than relying on inotify, to be able to serve more requests.
4074
confdConfigReloadRatelimit :: Int
4075
confdConfigReloadRatelimit = 250000
4076

    
4077
-- | Magic number prepended to all confd queries.
4078
--
4079
-- This allows us to distinguish different types of confd protocols
4080
-- and handle them. For example by changing this we can move the whole
4081
-- payload to be compressed, or move away from json.
4082
confdMagicFourcc :: String
4083
confdMagicFourcc = "plj0"
4084

    
4085
-- | By default a confd request is sent to the minimum between this
4086
-- number and all MCs. 6 was chosen because even in the case of a
4087
-- disastrous 50% response rate, we should have enough answers to be
4088
-- able to compare more than one.
4089
confdDefaultReqCoverage :: Int
4090
confdDefaultReqCoverage = 6
4091

    
4092
-- | Timeout in seconds to expire pending query request in the confd
4093
-- client library. We don't actually expect any answer more than 10
4094
-- seconds after we sent a request.
4095
confdClientExpireTimeout :: Int
4096
confdClientExpireTimeout = 10
4097

    
4098
-- | Maximum UDP datagram size.
4099
--
4100
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4101
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4102
--   (assuming we can't use jumbo frames)
4103
-- We just set this to 60K, which should be enough
4104
maxUdpDataSize :: Int
4105
maxUdpDataSize = 61440
4106

    
4107
-- * User-id pool minimum/maximum acceptable user-ids
4108

    
4109
uidpoolUidMin :: Int
4110
uidpoolUidMin = 0
4111

    
4112
-- | Assuming 32 bit user-ids
4113
uidpoolUidMax :: Integer
4114
uidpoolUidMax = 2 ^ 32 - 1
4115

    
4116
-- | Name or path of the pgrep command
4117
pgrep :: String
4118
pgrep = "pgrep"
4119

    
4120
-- | Name of the node group that gets created at cluster init or
4121
-- upgrade
4122
initialNodeGroupName :: String
4123
initialNodeGroupName = "default"
4124

    
4125
-- * Possible values for NodeGroup.alloc_policy
4126

    
4127
allocPolicyLastResort :: String
4128
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4129

    
4130
allocPolicyPreferred :: String
4131
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4132

    
4133
allocPolicyUnallocable :: String
4134
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4135

    
4136
validAllocPolicies :: [String]
4137
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4138

    
4139
-- | Temporary external/shared storage parameters
4140
blockdevDriverManual :: String
4141
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4142

    
4143
-- | 'qemu-img' path, required for 'ovfconverter'
4144
qemuimgPath :: String
4145
qemuimgPath = AutoConf.qemuimgPath
4146

    
4147
-- | Whether htools was enabled at compilation time
4148
--
4149
-- FIXME: this should be moved next to the other enable constants,
4150
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4151
htools :: Bool
4152
htools = AutoConf.htools
4153

    
4154
-- | The hail iallocator
4155
iallocHail :: String
4156
iallocHail = "hail"
4157

    
4158
-- * Fake opcodes for functions that have hooks attached to them via
4159
-- backend.RunLocalHooks
4160

    
4161
fakeOpMasterTurndown :: String
4162
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4163

    
4164
fakeOpMasterTurnup :: String
4165
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4166

    
4167

    
4168
-- * Crypto Types
4169
-- Types of cryptographic tokens used in node communication
4170

    
4171
cryptoTypeSslDigest :: String
4172
cryptoTypeSslDigest = "ssl"
4173

    
4174
cryptoTypeSsh :: String
4175
cryptoTypeSsh = "ssh"
4176

    
4177
-- So far only ssl keys are used in the context of this constant
4178
cryptoTypes :: FrozenSet String
4179
cryptoTypes = ConstantUtils.mkSet [cryptoTypeSslDigest]
4180

    
4181
-- * Crypto Actions
4182
-- Actions that can be performed on crypto tokens
4183

    
4184
cryptoActionGet :: String
4185
cryptoActionGet = "get"
4186

    
4187
-- This is 'create and get'
4188
cryptoActionCreate :: String
4189
cryptoActionCreate = "create"
4190

    
4191
cryptoActions :: FrozenSet String
4192
cryptoActions = ConstantUtils.mkSet [cryptoActionGet, cryptoActionCreate]
4193

    
4194
-- * Options for CryptoActions
4195

    
4196
-- Filename of the certificate
4197
cryptoOptionCertFile :: String
4198
cryptoOptionCertFile = "cert_file"
4199

    
4200
-- * SSH key types
4201

    
4202
sshkDsa :: String
4203
sshkDsa = "dsa"
4204

    
4205
sshkRsa :: String
4206
sshkRsa = "rsa"
4207

    
4208
sshkAll :: FrozenSet String
4209
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4210

    
4211
-- * SSH authorized key types
4212

    
4213
sshakDss :: String
4214
sshakDss = "ssh-dss"
4215

    
4216
sshakRsa :: String
4217
sshakRsa = "ssh-rsa"
4218

    
4219
sshakAll :: FrozenSet String
4220
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4221

    
4222
-- * SSH setup
4223

    
4224
sshsClusterName :: String
4225
sshsClusterName = "cluster_name"
4226

    
4227
sshsSshHostKey :: String
4228
sshsSshHostKey = "ssh_host_key"
4229

    
4230
sshsSshRootKey :: String
4231
sshsSshRootKey = "ssh_root_key"
4232

    
4233
sshsNodeDaemonCertificate :: String
4234
sshsNodeDaemonCertificate = "node_daemon_certificate"
4235

    
4236
-- * Key files for SSH daemon
4237

    
4238
sshHostDsaPriv :: String
4239
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4240

    
4241
sshHostDsaPub :: String
4242
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4243

    
4244
sshHostRsaPriv :: String
4245
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4246

    
4247
sshHostRsaPub :: String
4248
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4249

    
4250
sshDaemonKeyfiles :: Map String (String, String)
4251
sshDaemonKeyfiles =
4252
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4253
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4254
               ]
4255

    
4256
-- * Node daemon setup
4257

    
4258
ndsClusterName :: String
4259
ndsClusterName = "cluster_name"
4260

    
4261
ndsNodeDaemonCertificate :: String
4262
ndsNodeDaemonCertificate = "node_daemon_certificate"
4263

    
4264
ndsSsconf :: String
4265
ndsSsconf = "ssconf"
4266

    
4267
ndsStartNodeDaemon :: String
4268
ndsStartNodeDaemon = "start_node_daemon"
4269

    
4270
-- * The source reasons for the execution of an OpCode
4271

    
4272
opcodeReasonSrcClient :: String
4273
opcodeReasonSrcClient = "gnt:client"
4274

    
4275
opcodeReasonSrcNoded :: String
4276
opcodeReasonSrcNoded = "gnt:daemon:noded"
4277

    
4278
opcodeReasonSrcOpcode :: String
4279
opcodeReasonSrcOpcode = "gnt:opcode"
4280

    
4281
opcodeReasonSrcRlib2 :: String
4282
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4283

    
4284
opcodeReasonSrcUser :: String
4285
opcodeReasonSrcUser = "gnt:user"
4286

    
4287
opcodeReasonSources :: FrozenSet String
4288
opcodeReasonSources =
4289
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4290
                       opcodeReasonSrcNoded,
4291
                       opcodeReasonSrcOpcode,
4292
                       opcodeReasonSrcRlib2,
4293
                       opcodeReasonSrcUser]
4294

    
4295
-- | Path generating random UUID
4296
randomUuidFile :: String
4297
randomUuidFile = ConstantUtils.randomUuidFile
4298

    
4299
-- * Auto-repair tag prefixes
4300

    
4301
autoRepairTagPrefix :: String
4302
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4303

    
4304
autoRepairTagEnabled :: String
4305
autoRepairTagEnabled = autoRepairTagPrefix
4306

    
4307
autoRepairTagPending :: String
4308
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4309

    
4310
autoRepairTagResult :: String
4311
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4312

    
4313
autoRepairTagSuspended :: String
4314
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4315

    
4316
-- * Auto-repair levels
4317

    
4318
autoRepairFailover :: String
4319
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4320

    
4321
autoRepairFixStorage :: String
4322
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4323

    
4324
autoRepairMigrate :: String
4325
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4326

    
4327
autoRepairReinstall :: String
4328
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4329

    
4330
autoRepairAllTypes :: FrozenSet String
4331
autoRepairAllTypes =
4332
  ConstantUtils.mkSet [autoRepairFailover,
4333
                       autoRepairFixStorage,
4334
                       autoRepairMigrate,
4335
                       autoRepairReinstall]
4336

    
4337
-- * Auto-repair results
4338

    
4339
autoRepairEnoperm :: String
4340
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4341

    
4342
autoRepairFailure :: String
4343
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4344

    
4345
autoRepairSuccess :: String
4346
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4347

    
4348
autoRepairAllResults :: FrozenSet String
4349
autoRepairAllResults =
4350
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4351

    
4352
-- | The version identifier for builtin data collectors
4353
builtinDataCollectorVersion :: String
4354
builtinDataCollectorVersion = "B"
4355

    
4356
-- | The reason trail opcode parameter name
4357
opcodeReason :: String
4358
opcodeReason = "reason"
4359

    
4360
diskstatsFile :: String
4361
diskstatsFile = "/proc/diskstats"
4362

    
4363
-- *  CPU load collector
4364

    
4365
statFile :: String
4366
statFile = "/proc/stat"
4367

    
4368
cpuavgloadBufferSize :: Int
4369
cpuavgloadBufferSize = 150
4370

    
4371
cpuavgloadWindowSize :: Int
4372
cpuavgloadWindowSize = 600
4373

    
4374
-- * Monitoring daemon
4375

    
4376
-- | Mond's variable for periodical data collection
4377
mondTimeInterval :: Int
4378
mondTimeInterval = 5
4379

    
4380
-- | Mond's latest API version
4381
mondLatestApiVersion :: Int
4382
mondLatestApiVersion = 1
4383

    
4384
-- * Disk access modes
4385

    
4386
diskUserspace :: String
4387
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4388

    
4389
diskKernelspace :: String
4390
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4391

    
4392
diskValidAccessModes :: FrozenSet String
4393
diskValidAccessModes =
4394
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4395

    
4396
-- | Timeout for queue draining in upgrades
4397
upgradeQueueDrainTimeout :: Int
4398
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4399

    
4400
-- | Intervall at which the queue is polled during upgrades
4401
upgradeQueuePollInterval :: Int
4402
upgradeQueuePollInterval  = 10
4403

    
4404
-- * Hotplug Actions
4405

    
4406
hotplugActionAdd :: String
4407
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4408

    
4409
hotplugActionRemove :: String
4410
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4411

    
4412
hotplugActionModify :: String
4413
hotplugActionModify = Types.hotplugActionToRaw HAMod
4414

    
4415
hotplugAllActions :: FrozenSet String
4416
hotplugAllActions =
4417
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4418

    
4419
-- * Hotplug Device Targets
4420

    
4421
hotplugTargetNic :: String
4422
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4423

    
4424
hotplugTargetDisk :: String
4425
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4426

    
4427
hotplugAllTargets :: FrozenSet String
4428
hotplugAllTargets =
4429
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4430

    
4431
-- | Timeout for disk removal (seconds)
4432
diskRemoveRetryTimeout :: Int
4433
diskRemoveRetryTimeout = 30
4434

    
4435
-- | Interval between disk removal retries (seconds)
4436
diskRemoveRetryInterval :: Int
4437
diskRemoveRetryInterval  = 3
4438

    
4439
-- * UUID regex
4440

    
4441
uuidRegex :: String
4442
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4443

    
4444
-- * Luxi constants
4445

    
4446
luxiSocketPerms :: Int
4447
luxiSocketPerms = 0o660
4448

    
4449
luxiKeyMethod :: String
4450
luxiKeyMethod = "method"
4451

    
4452
luxiKeyArgs :: String
4453
luxiKeyArgs = "args"
4454

    
4455
luxiKeySuccess :: String
4456
luxiKeySuccess = "success"
4457

    
4458
luxiKeyResult :: String
4459
luxiKeyResult = "result"
4460

    
4461
luxiKeyVersion :: String
4462
luxiKeyVersion = "version"
4463

    
4464
luxiReqSubmitJob :: String
4465
luxiReqSubmitJob = "SubmitJob"
4466

    
4467
luxiReqSubmitJobToDrainedQueue :: String
4468
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4469

    
4470
luxiReqSubmitManyJobs :: String
4471
luxiReqSubmitManyJobs = "SubmitManyJobs"
4472

    
4473
luxiReqWaitForJobChange :: String
4474
luxiReqWaitForJobChange = "WaitForJobChange"
4475

    
4476
luxiReqPickupJob :: String
4477
luxiReqPickupJob = "PickupJob"
4478

    
4479
luxiReqCancelJob :: String
4480
luxiReqCancelJob = "CancelJob"
4481

    
4482
luxiReqArchiveJob :: String
4483
luxiReqArchiveJob = "ArchiveJob"
4484

    
4485
luxiReqChangeJobPriority :: String
4486
luxiReqChangeJobPriority = "ChangeJobPriority"
4487

    
4488
luxiReqAutoArchiveJobs :: String
4489
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4490

    
4491
luxiReqQuery :: String
4492
luxiReqQuery = "Query"
4493

    
4494
luxiReqQueryFields :: String
4495
luxiReqQueryFields = "QueryFields"
4496

    
4497
luxiReqQueryJobs :: String
4498
luxiReqQueryJobs = "QueryJobs"
4499

    
4500
luxiReqQueryInstances :: String
4501
luxiReqQueryInstances = "QueryInstances"
4502

    
4503
luxiReqQueryNodes :: String
4504
luxiReqQueryNodes = "QueryNodes"
4505

    
4506
luxiReqQueryGroups :: String
4507
luxiReqQueryGroups = "QueryGroups"
4508

    
4509
luxiReqQueryNetworks :: String
4510
luxiReqQueryNetworks = "QueryNetworks"
4511

    
4512
luxiReqQueryExports :: String
4513
luxiReqQueryExports = "QueryExports"
4514

    
4515
luxiReqQueryConfigValues :: String
4516
luxiReqQueryConfigValues = "QueryConfigValues"
4517

    
4518
luxiReqQueryClusterInfo :: String
4519
luxiReqQueryClusterInfo = "QueryClusterInfo"
4520

    
4521
luxiReqQueryTags :: String
4522
luxiReqQueryTags = "QueryTags"
4523

    
4524
luxiReqSetDrainFlag :: String
4525
luxiReqSetDrainFlag = "SetDrainFlag"
4526

    
4527
luxiReqSetWatcherPause :: String
4528
luxiReqSetWatcherPause = "SetWatcherPause"
4529

    
4530
luxiReqAll :: FrozenSet String
4531
luxiReqAll =
4532
  ConstantUtils.mkSet
4533
  [ luxiReqArchiveJob
4534
  , luxiReqAutoArchiveJobs
4535
  , luxiReqCancelJob
4536
  , luxiReqChangeJobPriority
4537
  , luxiReqQuery
4538
  , luxiReqQueryClusterInfo
4539
  , luxiReqQueryConfigValues
4540
  , luxiReqQueryExports
4541
  , luxiReqQueryFields
4542
  , luxiReqQueryGroups
4543
  , luxiReqQueryInstances
4544
  , luxiReqQueryJobs
4545
  , luxiReqQueryNodes
4546
  , luxiReqQueryNetworks
4547
  , luxiReqQueryTags
4548
  , luxiReqSetDrainFlag
4549
  , luxiReqSetWatcherPause
4550
  , luxiReqSubmitJob
4551
  , luxiReqSubmitJobToDrainedQueue
4552
  , luxiReqSubmitManyJobs
4553
  , luxiReqWaitForJobChange
4554
  , luxiReqPickupJob
4555
  ]
4556

    
4557
luxiDefCtmo :: Int
4558
luxiDefCtmo = 10
4559

    
4560
luxiDefRwto :: Int
4561
luxiDefRwto = 60
4562

    
4563
-- | 'WaitForJobChange' timeout
4564
luxiWfjcTimeout :: Int
4565
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4566

    
4567
-- * Query language constants
4568

    
4569
-- ** Logic operators with one or more operands, each of which is a
4570
-- filter on its own
4571

    
4572
qlangOpAnd :: String
4573
qlangOpAnd = "&"
4574

    
4575
qlangOpOr :: String
4576
qlangOpOr = "|"
4577

    
4578
-- ** Unary operators with exactly one operand
4579

    
4580
qlangOpNot :: String
4581
qlangOpNot = "!"
4582

    
4583
qlangOpTrue :: String
4584
qlangOpTrue = "?"
4585

    
4586
-- ** Binary operators with exactly two operands, the field name and
4587
-- an operator-specific value
4588

    
4589
qlangOpContains :: String
4590
qlangOpContains = "=[]"
4591

    
4592
qlangOpEqual :: String
4593
qlangOpEqual = "="
4594

    
4595
qlangOpGe :: String
4596
qlangOpGe = ">="
4597

    
4598
qlangOpGt :: String
4599
qlangOpGt = ">"
4600

    
4601
qlangOpLe :: String
4602
qlangOpLe = "<="
4603

    
4604
qlangOpLt :: String
4605
qlangOpLt = "<"
4606

    
4607
qlangOpNotEqual :: String
4608
qlangOpNotEqual = "!="
4609

    
4610
qlangOpRegexp :: String
4611
qlangOpRegexp = "=~"
4612

    
4613
-- | Characters used for detecting user-written filters (see
4614
-- L{_CheckFilter})
4615

    
4616
qlangFilterDetectionChars :: FrozenSet String
4617
qlangFilterDetectionChars =
4618
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4619
                       ")", "(", "\x0b", "\n",
4620
                       "\r", "\x0c", "/", "<",
4621
                       "\t", ">", "=", "\\", "~"]
4622

    
4623
-- | Characters used to detect globbing filters
4624
qlangGlobDetectionChars :: FrozenSet String
4625
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4626

    
4627
-- * Error related constants
4628
--
4629
-- 'OpPrereqError' failure types
4630

    
4631
-- | Environment error (e.g. node disk error)
4632
errorsEcodeEnviron :: String
4633
errorsEcodeEnviron = "environment_error"
4634

    
4635
-- | Entity already exists
4636
errorsEcodeExists :: String
4637
errorsEcodeExists = "already_exists"
4638

    
4639
-- | Internal cluster error
4640
errorsEcodeFault :: String
4641
errorsEcodeFault = "internal_error"
4642

    
4643
-- | Wrong arguments (at syntax level)
4644
errorsEcodeInval :: String
4645
errorsEcodeInval = "wrong_input"
4646

    
4647
-- | Entity not found
4648
errorsEcodeNoent :: String
4649
errorsEcodeNoent = "unknown_entity"
4650

    
4651
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4652
errorsEcodeNores :: String
4653
errorsEcodeNores = "insufficient_resources"
4654

    
4655
-- | Resource not unique (e.g. MAC or IP duplication)
4656
errorsEcodeNotunique :: String
4657
errorsEcodeNotunique = "resource_not_unique"
4658

    
4659
-- | Resolver errors
4660
errorsEcodeResolver :: String
4661
errorsEcodeResolver = "resolver_error"
4662

    
4663
-- | Wrong entity state
4664
errorsEcodeState :: String
4665
errorsEcodeState = "wrong_state"
4666

    
4667
-- | Temporarily out of resources; operation can be tried again
4668
errorsEcodeTempNores :: String
4669
errorsEcodeTempNores = "temp_insufficient_resources"
4670

    
4671
errorsEcodeAll :: FrozenSet String
4672
errorsEcodeAll =
4673
  ConstantUtils.mkSet [ errorsEcodeNores
4674
                      , errorsEcodeExists
4675
                      , errorsEcodeState
4676
                      , errorsEcodeNotunique
4677
                      , errorsEcodeTempNores
4678
                      , errorsEcodeNoent
4679
                      , errorsEcodeFault
4680
                      , errorsEcodeResolver
4681
                      , errorsEcodeInval
4682
                      , errorsEcodeEnviron
4683
                      ]
4684

    
4685
-- * Jstore related constants
4686

    
4687
jstoreJobsPerArchiveDirectory :: Int
4688
jstoreJobsPerArchiveDirectory = 10000
4689

    
4690
-- * Gluster settings
4691

    
4692
-- | Name of the Gluster host setting
4693
glusterHost :: String
4694
glusterHost = "host"
4695

    
4696
-- | Default value of the Gluster host setting
4697
glusterHostDefault :: String
4698
glusterHostDefault = "127.0.0.1"
4699

    
4700
-- | Name of the Gluster volume setting
4701
glusterVolume :: String
4702
glusterVolume = "volume"
4703

    
4704
-- | Default value of the Gluster volume setting
4705
glusterVolumeDefault :: String
4706
glusterVolumeDefault = "gv0"
4707

    
4708
-- | Name of the Gluster port setting
4709
glusterPort :: String
4710
glusterPort = "port"
4711

    
4712
-- | Default value of the Gluster port setting
4713
glusterPortDefault :: Int
4714
glusterPortDefault = 24007