Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 4084d18f

History | View | Annotate | Download (118.6 kB)

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

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

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

    
15
-}
16

    
17
{-
18

    
19
Copyright (C) 2013 Google Inc.
20

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

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

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

    
36
-}
37
module Ganeti.Constants where
38

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

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

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

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

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

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

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

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

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

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

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

    
86
-- ** Build-time constants
87

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
135
-- * Various versions
136

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

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

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

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

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

    
152
osApiV10 :: Int
153
osApiV10 = 10
154

    
155
osApiV15 :: Int
156
osApiV15 = 15
157

    
158
osApiV20 :: Int
159
osApiV20 = 20
160

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

    
164
exportVersion :: Int
165
exportVersion = 0
166

    
167
rapiVersion :: Int
168
rapiVersion = 2
169

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

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

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

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

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

    
189
-- * User separation
190

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

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

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

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

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

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

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

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

    
215
kvmdUser :: String
216
kvmdUser = Runtime.daemonUser GanetiKvmd
217

    
218
kvmdGroup :: String
219
kvmdGroup = Runtime.daemonGroup (DaemonGroup GanetiKvmd)
220

    
221
luxidUser :: String
222
luxidUser = Runtime.daemonUser GanetiLuxid
223

    
224
luxidGroup :: String
225
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
226

    
227
nodedUser :: String
228
nodedUser = Runtime.daemonUser GanetiNoded
229

    
230
nodedGroup :: String
231
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
232

    
233
mondUser :: String
234
mondUser = Runtime.daemonUser GanetiMond
235

    
236
mondGroup :: String
237
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
238

    
239
sshLoginUser :: String
240
sshLoginUser = AutoConf.sshLoginUser
241

    
242
sshConsoleUser :: String
243
sshConsoleUser = AutoConf.sshConsoleUser
244

    
245
-- * Cpu pinning separators and constants
246

    
247
cpuPinningSep :: String
248
cpuPinningSep = ":"
249

    
250
cpuPinningAll :: String
251
cpuPinningAll = "all"
252

    
253
-- | Internal representation of "all"
254
cpuPinningAllVal :: Int
255
cpuPinningAllVal = -1
256

    
257
-- | One "all" entry in a CPU list means CPU pinning is off
258
cpuPinningOff :: [Int]
259
cpuPinningOff = [cpuPinningAllVal]
260

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

    
277
-- | A KVM-specific implementation detail - the following value is
278
-- used to set CPU affinity to all processors (--0 through --31), per
279
-- taskset man page.
280
--
281
-- FIXME: This only works for machines with up to 32 CPU cores
282
cpuPinningAllKvm :: Int
283
cpuPinningAllKvm = 0xFFFFFFFF
284

    
285
-- * Wipe
286

    
287
ddCmd :: String
288
ddCmd = "dd"
289

    
290
-- | 1GB
291
maxWipeChunk :: Int
292
maxWipeChunk = 1024
293

    
294
minWipeChunkPercent :: Int
295
minWipeChunkPercent = 10
296

    
297
-- * Directories
298

    
299
runDirsMode :: Int
300
runDirsMode = 0o775
301

    
302
secureDirMode :: Int
303
secureDirMode = 0o700
304

    
305
secureFileMode :: Int
306
secureFileMode = 0o600
307

    
308
adoptableBlockdevRoot :: String
309
adoptableBlockdevRoot = "/dev/disk/"
310

    
311
-- * 'autoconf' enable/disable
312

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

    
316
enableMond :: Bool
317
enableMond = AutoConf.enableMond
318

    
319
enableRestrictedCommands :: Bool
320
enableRestrictedCommands = AutoConf.enableRestrictedCommands
321

    
322
-- * SSH constants
323

    
324
ssh :: String
325
ssh = "ssh"
326

    
327
scp :: String
328
scp = "scp"
329

    
330
-- * Daemons
331

    
332
confd :: String
333
confd = Runtime.daemonName GanetiConfd
334

    
335
masterd :: String
336
masterd = Runtime.daemonName GanetiMasterd
337

    
338
mond :: String
339
mond = Runtime.daemonName GanetiMond
340

    
341
noded :: String
342
noded = Runtime.daemonName GanetiNoded
343

    
344
luxid :: String
345
luxid = Runtime.daemonName GanetiLuxid
346

    
347
rapi :: String
348
rapi = Runtime.daemonName GanetiRapi
349

    
350
kvmd :: String
351
kvmd = Runtime.daemonName GanetiKvmd
352

    
353
daemons :: FrozenSet String
354
daemons =
355
  ConstantUtils.mkSet [confd,
356
                       luxid,
357
                       masterd,
358
                       mond,
359
                       noded,
360
                       rapi]
361

    
362
defaultConfdPort :: Int
363
defaultConfdPort = 1814
364

    
365
defaultMondPort :: Int
366
defaultMondPort = 1815
367

    
368
defaultNodedPort :: Int
369
defaultNodedPort = 1811
370

    
371
defaultRapiPort :: Int
372
defaultRapiPort = 5080
373

    
374
daemonsPorts :: Map String (Protocol, Int)
375
daemonsPorts =
376
  Map.fromList [(confd, (Udp, defaultConfdPort)),
377
                (mond, (Tcp, defaultMondPort)),
378
                (noded, (Tcp, defaultNodedPort)),
379
                (rapi, (Tcp, defaultRapiPort)),
380
                (ssh, (Tcp, 22))]
381

    
382
firstDrbdPort :: Int
383
firstDrbdPort = 11000
384

    
385
lastDrbdPort :: Int
386
lastDrbdPort = 14999
387

    
388
daemonsLogbase :: Map String String
389
daemonsLogbase =
390
  Map.fromList
391
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
392

    
393
daemonsExtraLogbase :: Map String (Map String String)
394
daemonsExtraLogbase =
395
  Map.fromList $
396
  map (Runtime.daemonName *** id)
397
  [ (GanetiMond, Map.fromList
398
                 [ ("access", Runtime.daemonsExtraLogbase GanetiMond AccessLog)
399
                 , ("error", Runtime.daemonsExtraLogbase GanetiMond ErrorLog)
400
                 ])
401
  ]
402

    
403
extraLogreasonAccess :: String
404
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
405

    
406
extraLogreasonError :: String
407
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
408

    
409
devConsole :: String
410
devConsole = ConstantUtils.devConsole
411

    
412
procMounts :: String
413
procMounts = "/proc/mounts"
414

    
415
-- * Luxi (Local UniX Interface) related constants
416

    
417
luxiEom :: PythonChar
418
luxiEom = PythonChar '\x03'
419

    
420
-- | Environment variable for the luxi override socket
421
luxiOverride :: String
422
luxiOverride = "FORCE_LUXI_SOCKET"
423

    
424
luxiOverrideMaster :: String
425
luxiOverrideMaster = "master"
426

    
427
luxiOverrideQuery :: String
428
luxiOverrideQuery = "query"
429

    
430
luxiVersion :: Int
431
luxiVersion = configVersion
432

    
433
-- * Syslog
434

    
435
syslogUsage :: String
436
syslogUsage = AutoConf.syslogUsage
437

    
438
syslogNo :: String
439
syslogNo = Logging.syslogUsageToRaw SyslogNo
440

    
441
syslogYes :: String
442
syslogYes = Logging.syslogUsageToRaw SyslogYes
443

    
444
syslogOnly :: String
445
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
446

    
447
syslogSocket :: String
448
syslogSocket = "/dev/log"
449

    
450
exportConfFile :: String
451
exportConfFile = "config.ini"
452

    
453
-- * Xen
454

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

    
458
xenCmdXl :: String
459
xenCmdXl = "xl"
460

    
461
xenCmdXm :: String
462
xenCmdXm = "xm"
463

    
464
xenInitrd :: String
465
xenInitrd = AutoConf.xenInitrd
466

    
467
xenKernel :: String
468
xenKernel = AutoConf.xenKernel
469

    
470
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
471
-- other constants
472
knownXenCommands :: FrozenSet String
473
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
474

    
475
-- * KVM and socat
476

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

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

    
483
socatEscapeCode :: String
484
socatEscapeCode = "0x1d"
485

    
486
socatPath :: String
487
socatPath = AutoConf.socatPath
488

    
489
socatUseCompress :: Bool
490
socatUseCompress = AutoConf.socatUseCompress
491

    
492
socatUseEscape :: Bool
493
socatUseEscape = AutoConf.socatUseEscape
494

    
495
-- * Console types
496

    
497
-- | Display a message for console access
498
consMessage :: String
499
consMessage = "msg"
500

    
501
-- | Console as SPICE server
502
consSpice :: String
503
consSpice = "spice"
504

    
505
-- | Console as SSH command
506
consSsh :: String
507
consSsh = "ssh"
508

    
509
-- | Console as VNC server
510
consVnc :: String
511
consVnc = "vnc"
512

    
513
consAll :: FrozenSet String
514
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
515

    
516
-- | RSA key bit length
517
--
518
-- For RSA keys more bits are better, but they also make operations
519
-- more expensive. NIST SP 800-131 recommends a minimum of 2048 bits
520
-- from the year 2010 on.
521
rsaKeyBits :: Int
522
rsaKeyBits = 2048
523

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

    
535
-- * X509
536

    
537
-- | commonName (CN) used in certificates
538
x509CertCn :: String
539
x509CertCn = "ganeti.example.com"
540

    
541
-- | Default validity of certificates in days
542
x509CertDefaultValidity :: Int
543
x509CertDefaultValidity = 365 * 5
544

    
545
x509CertSignatureHeader :: String
546
x509CertSignatureHeader = "X-Ganeti-Signature"
547

    
548
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
549
x509CertSignDigest :: String
550
x509CertSignDigest = "SHA1"
551

    
552
-- * Import/export daemon mode
553

    
554
iemExport :: String
555
iemExport = "export"
556

    
557
iemImport :: String
558
iemImport = "import"
559

    
560
-- * Import/export transport compression
561

    
562
iecGzip :: String
563
iecGzip = "gzip"
564

    
565
iecNone :: String
566
iecNone = "none"
567

    
568
iecAll :: [String]
569
iecAll = [iecGzip, iecNone]
570

    
571
ieCustomSize :: String
572
ieCustomSize = "fd"
573

    
574
-- * Import/export I/O
575

    
576
-- | Direct file I/O, equivalent to a shell's I/O redirection using
577
-- '<' or '>'
578
ieioFile :: String
579
ieioFile = "file"
580

    
581
-- | Raw block device I/O using "dd"
582
ieioRawDisk :: String
583
ieioRawDisk = "raw"
584

    
585
-- | OS definition import/export script
586
ieioScript :: String
587
ieioScript = "script"
588

    
589
-- * Values
590

    
591
valueDefault :: String
592
valueDefault = "default"
593

    
594
valueAuto :: String
595
valueAuto = "auto"
596

    
597
valueGenerate :: String
598
valueGenerate = "generate"
599

    
600
valueNone :: String
601
valueNone = "none"
602

    
603
valueTrue :: String
604
valueTrue = "true"
605

    
606
valueFalse :: String
607
valueFalse = "false"
608

    
609
-- * Hooks
610

    
611
hooksNameCfgupdate :: String
612
hooksNameCfgupdate = "config-update"
613

    
614
hooksNameWatcher :: String
615
hooksNameWatcher = "watcher"
616

    
617
hooksPath :: String
618
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
619

    
620
hooksPhasePost :: String
621
hooksPhasePost = "post"
622

    
623
hooksPhasePre :: String
624
hooksPhasePre = "pre"
625

    
626
hooksVersion :: Int
627
hooksVersion = 2
628

    
629
-- * Hooks subject type (what object type does the LU deal with)
630

    
631
htypeCluster :: String
632
htypeCluster = "CLUSTER"
633

    
634
htypeGroup :: String
635
htypeGroup = "GROUP"
636

    
637
htypeInstance :: String
638
htypeInstance = "INSTANCE"
639

    
640
htypeNetwork :: String
641
htypeNetwork = "NETWORK"
642

    
643
htypeNode :: String
644
htypeNode = "NODE"
645

    
646
-- * Hkr
647

    
648
hkrSkip :: Int
649
hkrSkip = 0
650

    
651
hkrFail :: Int
652
hkrFail = 1
653

    
654
hkrSuccess :: Int
655
hkrSuccess = 2
656

    
657
-- * Storage types
658

    
659
stBlock :: String
660
stBlock = Types.storageTypeToRaw StorageBlock
661

    
662
stDiskless :: String
663
stDiskless = Types.storageTypeToRaw StorageDiskless
664

    
665
stExt :: String
666
stExt = Types.storageTypeToRaw StorageExt
667

    
668
stFile :: String
669
stFile = Types.storageTypeToRaw StorageFile
670

    
671
stSharedFile :: String
672
stSharedFile = Types.storageTypeToRaw StorageSharedFile
673

    
674
stLvmPv :: String
675
stLvmPv = Types.storageTypeToRaw StorageLvmPv
676

    
677
stLvmVg :: String
678
stLvmVg = Types.storageTypeToRaw StorageLvmVg
679

    
680
stRados :: String
681
stRados = Types.storageTypeToRaw StorageRados
682

    
683
storageTypes :: FrozenSet String
684
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
685

    
686
-- | The set of storage types for which full storage reporting is available
687
stsReport :: FrozenSet String
688
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
689

    
690
-- | The set of storage types for which node storage reporting is available
691
-- | (as used by LUQueryNodeStorage)
692
stsReportNodeStorage :: FrozenSet String
693
stsReportNodeStorage = ConstantUtils.union stsReport $
694
                                           ConstantUtils.mkSet [stSharedFile]
695

    
696
-- * Storage fields
697
-- ** First two are valid in LU context only, not passed to backend
698

    
699
sfNode :: String
700
sfNode = "node"
701

    
702
sfType :: String
703
sfType = "type"
704

    
705
-- ** and the rest are valid in backend
706

    
707
sfAllocatable :: String
708
sfAllocatable = Types.storageFieldToRaw SFAllocatable
709

    
710
sfFree :: String
711
sfFree = Types.storageFieldToRaw SFFree
712

    
713
sfName :: String
714
sfName = Types.storageFieldToRaw SFName
715

    
716
sfSize :: String
717
sfSize = Types.storageFieldToRaw SFSize
718

    
719
sfUsed :: String
720
sfUsed = Types.storageFieldToRaw SFUsed
721

    
722
validStorageFields :: FrozenSet String
723
validStorageFields =
724
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
725
                        [sfNode, sfType]
726

    
727
modifiableStorageFields :: Map String (FrozenSet String)
728
modifiableStorageFields =
729
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
730
                 ConstantUtils.mkSet [sfAllocatable])]
731

    
732
-- * Storage operations
733

    
734
soFixConsistency :: String
735
soFixConsistency = "fix-consistency"
736

    
737
validStorageOperations :: Map String (FrozenSet String)
738
validStorageOperations =
739
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
740
                 ConstantUtils.mkSet [soFixConsistency])]
741

    
742
-- * Volume fields
743

    
744
vfDev :: String
745
vfDev = "dev"
746

    
747
vfInstance :: String
748
vfInstance = "instance"
749

    
750
vfName :: String
751
vfName = "name"
752

    
753
vfNode :: String
754
vfNode = "node"
755

    
756
vfPhys :: String
757
vfPhys = "phys"
758

    
759
vfSize :: String
760
vfSize = "size"
761

    
762
vfVg :: String
763
vfVg = "vg"
764

    
765
-- * Local disk status
766

    
767
ldsFaulty :: Int
768
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
769

    
770
ldsOkay :: Int
771
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
772

    
773
ldsUnknown :: Int
774
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
775

    
776
ldsNames :: Map Int String
777
ldsNames =
778
  Map.fromList [ (Types.localDiskStatusToRaw ds,
779
                  localDiskStatusName ds) | ds <- [minBound..] ]
780

    
781
-- * Disk template types
782

    
783
dtDiskless :: String
784
dtDiskless = Types.diskTemplateToRaw DTDiskless
785

    
786
dtFile :: String
787
dtFile = Types.diskTemplateToRaw DTFile
788

    
789
dtSharedFile :: String
790
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
791

    
792
dtPlain :: String
793
dtPlain = Types.diskTemplateToRaw DTPlain
794

    
795
dtBlock :: String
796
dtBlock = Types.diskTemplateToRaw DTBlock
797

    
798
dtDrbd8 :: String
799
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
800

    
801
dtRbd :: String
802
dtRbd = Types.diskTemplateToRaw DTRbd
803

    
804
dtExt :: String
805
dtExt = Types.diskTemplateToRaw DTExt
806

    
807
dtGluster :: String
808
dtGluster = Types.diskTemplateToRaw DTGluster
809

    
810
-- | This is used to order determine the default disk template when
811
-- the list of enabled disk templates is inferred from the current
812
-- state of the cluster.  This only happens on an upgrade from a
813
-- version of Ganeti that did not support the 'enabled_disk_templates'
814
-- so far.
815
diskTemplatePreference :: [String]
816
diskTemplatePreference =
817
  map Types.diskTemplateToRaw
818
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile,
819
   DTPlain, DTRbd, DTSharedFile, DTGluster]
820

    
821
diskTemplates :: FrozenSet String
822
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
823

    
824
-- | Disk templates that are enabled by default
825
defaultEnabledDiskTemplates :: [String]
826
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
827

    
828
-- | Mapping of disk templates to storage types
829
mapDiskTemplateStorageType :: Map String String
830
mapDiskTemplateStorageType =
831
  Map.fromList $
832
  map (Types.diskTemplateToRaw *** Types.storageTypeToRaw)
833
  [(DTBlock, StorageBlock),
834
   (DTDrbd8, StorageLvmVg),
835
   (DTExt, StorageExt),
836
   (DTSharedFile, StorageSharedFile),
837
   (DTFile, StorageFile),
838
   (DTDiskless, StorageDiskless),
839
   (DTPlain, StorageLvmVg),
840
   (DTRbd, StorageRados),
841
   (DTGluster, StorageSharedFile)]
842

    
843
-- | The set of network-mirrored disk templates
844
dtsIntMirror :: FrozenSet String
845
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
846

    
847
-- | 'DTDiskless' is 'trivially' externally mirrored
848
dtsExtMirror :: FrozenSet String
849
dtsExtMirror =
850
  ConstantUtils.mkSet $
851
  map Types.diskTemplateToRaw
852
  [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd, DTGluster]
853

    
854
-- | The set of non-lvm-based disk templates
855
dtsNotLvm :: FrozenSet String
856
dtsNotLvm =
857
  ConstantUtils.mkSet $
858
  map Types.diskTemplateToRaw
859
  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd, DTGluster]
860

    
861
-- | The set of disk templates which can be grown
862
dtsGrowable :: FrozenSet String
863
dtsGrowable =
864
  ConstantUtils.mkSet $
865
  map Types.diskTemplateToRaw
866
  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd, DTGluster]
867

    
868
-- | The set of disk templates that allow adoption
869
dtsMayAdopt :: FrozenSet String
870
dtsMayAdopt =
871
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
872

    
873
-- | The set of disk templates that *must* use adoption
874
dtsMustAdopt :: FrozenSet String
875
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
876

    
877
-- | The set of disk templates that allow migrations
878
dtsMirrored :: FrozenSet String
879
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
880

    
881
-- | The set of file based disk templates
882
dtsFilebased :: FrozenSet String
883
dtsFilebased =
884
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw
885
  [DTSharedFile, DTFile, DTGluster]
886

    
887
-- | The set of disk templates that can be moved by copying
888
--
889
-- Note: a requirement is that they're not accessed externally or
890
-- shared between nodes; in particular, sharedfile is not suitable.
891
dtsCopyable :: FrozenSet String
892
dtsCopyable =
893
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
894

    
895
-- | The set of disk templates that are supported by exclusive_storage
896
dtsExclStorage :: FrozenSet String
897
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
898

    
899
-- | Templates for which we don't perform checks on free space
900
dtsNoFreeSpaceCheck :: FrozenSet String
901
dtsNoFreeSpaceCheck =
902
  ConstantUtils.mkSet $
903
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd, DTGluster]
904

    
905
dtsBlock :: FrozenSet String
906
dtsBlock =
907
  ConstantUtils.mkSet $
908
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
909

    
910
-- | The set of lvm-based disk templates
911
dtsLvm :: FrozenSet String
912
dtsLvm = diskTemplates `ConstantUtils.difference` dtsNotLvm
913

    
914
-- | The set of lvm-based disk templates
915
dtsHaveAccess :: FrozenSet String
916
dtsHaveAccess = ConstantUtils.mkSet $
917
  map Types.diskTemplateToRaw [DTRbd, DTGluster]
918

    
919
-- * Drbd
920

    
921
drbdHmacAlg :: String
922
drbdHmacAlg = "md5"
923

    
924
drbdDefaultNetProtocol :: String
925
drbdDefaultNetProtocol = "C"
926

    
927
drbdMigrationNetProtocol :: String
928
drbdMigrationNetProtocol = "C"
929

    
930
drbdStatusFile :: String
931
drbdStatusFile = "/proc/drbd"
932

    
933
-- | Size of DRBD meta block device
934
drbdMetaSize :: Int
935
drbdMetaSize = 128
936

    
937
-- * Drbd barrier types
938

    
939
drbdBDiskBarriers :: String
940
drbdBDiskBarriers = "b"
941

    
942
drbdBDiskDrain :: String
943
drbdBDiskDrain = "d"
944

    
945
drbdBDiskFlush :: String
946
drbdBDiskFlush = "f"
947

    
948
drbdBNone :: String
949
drbdBNone = "n"
950

    
951
-- | Valid barrier combinations: "n" or any non-null subset of "bfd"
952
drbdValidBarrierOpt :: FrozenSet (FrozenSet String)
953
drbdValidBarrierOpt =
954
  ConstantUtils.mkSet
955
  [ ConstantUtils.mkSet [drbdBNone]
956
  , ConstantUtils.mkSet [drbdBDiskBarriers]
957
  , ConstantUtils.mkSet [drbdBDiskDrain]
958
  , ConstantUtils.mkSet [drbdBDiskFlush]
959
  , ConstantUtils.mkSet [drbdBDiskDrain, drbdBDiskFlush]
960
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskDrain]
961
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush]
962
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush, drbdBDiskDrain]
963
  ]
964

    
965
-- | Rbd tool command
966
rbdCmd :: String
967
rbdCmd = "rbd"
968

    
969
-- * File backend driver
970

    
971
fdBlktap :: String
972
fdBlktap = Types.fileDriverToRaw FileBlktap
973

    
974
fdLoop :: String
975
fdLoop = Types.fileDriverToRaw FileLoop
976

    
977
fdDefault :: String
978
fdDefault = fdLoop
979

    
980
fileDriver :: FrozenSet String
981
fileDriver =
982
  ConstantUtils.mkSet $
983
  map Types.fileDriverToRaw [minBound..]
984

    
985
-- | The set of drbd-like disk types
986
dtsDrbd :: FrozenSet String
987
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
988

    
989
-- * Disk access mode
990

    
991
diskRdonly :: String
992
diskRdonly = Types.diskModeToRaw DiskRdOnly
993

    
994
diskRdwr :: String
995
diskRdwr = Types.diskModeToRaw DiskRdWr
996

    
997
diskAccessSet :: FrozenSet String
998
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
999

    
1000
-- * Disk replacement mode
1001

    
1002
replaceDiskAuto :: String
1003
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
1004

    
1005
replaceDiskChg :: String
1006
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
1007

    
1008
replaceDiskPri :: String
1009
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
1010

    
1011
replaceDiskSec :: String
1012
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
1013

    
1014
replaceModes :: FrozenSet String
1015
replaceModes =
1016
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
1017

    
1018
-- * Instance export mode
1019

    
1020
exportModeLocal :: String
1021
exportModeLocal = Types.exportModeToRaw ExportModeLocal
1022

    
1023
exportModeRemote :: String
1024
exportModeRemote = Types.exportModeToRaw ExportModeRemote
1025

    
1026
exportModes :: FrozenSet String
1027
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
1028

    
1029
-- * Instance creation modes
1030

    
1031
instanceCreate :: String
1032
instanceCreate = Types.instCreateModeToRaw InstCreate
1033

    
1034
instanceImport :: String
1035
instanceImport = Types.instCreateModeToRaw InstImport
1036

    
1037
instanceRemoteImport :: String
1038
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1039

    
1040
instanceCreateModes :: FrozenSet String
1041
instanceCreateModes =
1042
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1043

    
1044
-- * Remote import/export handshake message and version
1045

    
1046
rieHandshake :: String
1047
rieHandshake = "Hi, I'm Ganeti"
1048

    
1049
rieVersion :: Int
1050
rieVersion = 0
1051

    
1052
-- | Remote import/export certificate validity (seconds)
1053
rieCertValidity :: Int
1054
rieCertValidity = 24 * 60 * 60
1055

    
1056
-- | Export only: how long to wait per connection attempt (seconds)
1057
rieConnectAttemptTimeout :: Int
1058
rieConnectAttemptTimeout = 20
1059

    
1060
-- | Export only: number of attempts to connect
1061
rieConnectRetries :: Int
1062
rieConnectRetries = 10
1063

    
1064
-- | Overall timeout for establishing connection
1065
rieConnectTimeout :: Int
1066
rieConnectTimeout = 180
1067

    
1068
-- | Give child process up to 5 seconds to exit after sending a signal
1069
childLingerTimeout :: Double
1070
childLingerTimeout = 5.0
1071

    
1072
-- * Import/export config options
1073

    
1074
inisectBep :: String
1075
inisectBep = "backend"
1076

    
1077
inisectExp :: String
1078
inisectExp = "export"
1079

    
1080
inisectHyp :: String
1081
inisectHyp = "hypervisor"
1082

    
1083
inisectIns :: String
1084
inisectIns = "instance"
1085

    
1086
inisectOsp :: String
1087
inisectOsp = "os"
1088

    
1089
-- * Dynamic device modification
1090

    
1091
ddmAdd :: String
1092
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1093

    
1094
ddmModify :: String
1095
ddmModify = Types.ddmFullToRaw DdmFullModify
1096

    
1097
ddmRemove :: String
1098
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1099

    
1100
ddmsValues :: FrozenSet String
1101
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1102

    
1103
ddmsValuesWithModify :: FrozenSet String
1104
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1105

    
1106
-- * Common exit codes
1107

    
1108
exitSuccess :: Int
1109
exitSuccess = 0
1110

    
1111
exitFailure :: Int
1112
exitFailure = ConstantUtils.exitFailure
1113

    
1114
exitNotcluster :: Int
1115
exitNotcluster = 5
1116

    
1117
exitNotmaster :: Int
1118
exitNotmaster = 11
1119

    
1120
exitNodesetupError :: Int
1121
exitNodesetupError = 12
1122

    
1123
-- | Need user confirmation
1124
exitConfirmation :: Int
1125
exitConfirmation = 13
1126

    
1127
-- | Exit code for query operations with unknown fields
1128
exitUnknownField :: Int
1129
exitUnknownField = 14
1130

    
1131
-- * Tags
1132

    
1133
tagCluster :: String
1134
tagCluster = Types.tagKindToRaw TagKindCluster
1135

    
1136
tagInstance :: String
1137
tagInstance = Types.tagKindToRaw TagKindInstance
1138

    
1139
tagNetwork :: String
1140
tagNetwork = Types.tagKindToRaw TagKindNetwork
1141

    
1142
tagNode :: String
1143
tagNode = Types.tagKindToRaw TagKindNode
1144

    
1145
tagNodegroup :: String
1146
tagNodegroup = Types.tagKindToRaw TagKindGroup
1147

    
1148
validTagTypes :: FrozenSet String
1149
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1150

    
1151
maxTagLen :: Int
1152
maxTagLen = 128
1153

    
1154
maxTagsPerObj :: Int
1155
maxTagsPerObj = 4096
1156

    
1157
-- * Others
1158

    
1159
defaultBridge :: String
1160
defaultBridge = "xen-br0"
1161

    
1162
defaultOvs :: String
1163
defaultOvs = "switch1"
1164

    
1165
-- | 60 MiB/s, expressed in KiB/s
1166
classicDrbdSyncSpeed :: Int
1167
classicDrbdSyncSpeed = 60 * 1024
1168

    
1169
ip4AddressAny :: String
1170
ip4AddressAny = "0.0.0.0"
1171

    
1172
ip4AddressLocalhost :: String
1173
ip4AddressLocalhost = "127.0.0.1"
1174

    
1175
ip6AddressAny :: String
1176
ip6AddressAny = "::"
1177

    
1178
ip6AddressLocalhost :: String
1179
ip6AddressLocalhost = "::1"
1180

    
1181
ip4Version :: Int
1182
ip4Version = 4
1183

    
1184
ip6Version :: Int
1185
ip6Version = 6
1186

    
1187
validIpVersions :: FrozenSet Int
1188
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1189

    
1190
tcpPingTimeout :: Int
1191
tcpPingTimeout = 10
1192

    
1193
defaultVg :: String
1194
defaultVg = "xenvg"
1195

    
1196
defaultDrbdHelper :: String
1197
defaultDrbdHelper = "/bin/true"
1198

    
1199
minVgSize :: Int
1200
minVgSize = 20480
1201

    
1202
defaultMacPrefix :: String
1203
defaultMacPrefix = "aa:00:00"
1204

    
1205
-- | Default maximum instance wait time (seconds)
1206
defaultShutdownTimeout :: Int
1207
defaultShutdownTimeout = 120
1208

    
1209
-- | Node clock skew (seconds)
1210
nodeMaxClockSkew :: Int
1211
nodeMaxClockSkew = 150
1212

    
1213
-- | Time for an intra-cluster disk transfer to wait for a connection
1214
diskTransferConnectTimeout :: Int
1215
diskTransferConnectTimeout = 60
1216

    
1217
-- | Disk index separator
1218
diskSeparator :: String
1219
diskSeparator = AutoConf.diskSeparator
1220

    
1221
ipCommandPath :: String
1222
ipCommandPath = AutoConf.ipPath
1223

    
1224
-- | Key for job IDs in opcode result
1225
jobIdsKey :: String
1226
jobIdsKey = "jobs"
1227

    
1228
-- * Runparts results
1229

    
1230
runpartsErr :: Int
1231
runpartsErr = 2
1232

    
1233
runpartsRun :: Int
1234
runpartsRun = 1
1235

    
1236
runpartsSkip :: Int
1237
runpartsSkip = 0
1238

    
1239
runpartsStatus :: [Int]
1240
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1241

    
1242
-- * RPC
1243

    
1244
rpcEncodingNone :: Int
1245
rpcEncodingNone = 0
1246

    
1247
rpcEncodingZlibBase64 :: Int
1248
rpcEncodingZlibBase64 = 1
1249

    
1250
-- * Timeout table
1251
--
1252
-- Various time constants for the timeout table
1253

    
1254
rpcTmoUrgent :: Int
1255
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1256

    
1257
rpcTmoFast :: Int
1258
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1259

    
1260
rpcTmoNormal :: Int
1261
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1262

    
1263
rpcTmoSlow :: Int
1264
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1265

    
1266
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1267
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1268
-- Python name.
1269
rpcTmo_4hrs :: Int
1270
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1271

    
1272
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1273
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1274
-- Python name.
1275
rpcTmo_1day :: Int
1276
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1277

    
1278
-- | Timeout for connecting to nodes (seconds)
1279
rpcConnectTimeout :: Int
1280
rpcConnectTimeout = 5
1281

    
1282
-- OS
1283

    
1284
osScriptCreate :: String
1285
osScriptCreate = "create"
1286

    
1287
osScriptExport :: String
1288
osScriptExport = "export"
1289

    
1290
osScriptImport :: String
1291
osScriptImport = "import"
1292

    
1293
osScriptRename :: String
1294
osScriptRename = "rename"
1295

    
1296
osScriptVerify :: String
1297
osScriptVerify = "verify"
1298

    
1299
osScripts :: [String]
1300
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1301
             osScriptVerify]
1302

    
1303
osApiFile :: String
1304
osApiFile = "ganeti_api_version"
1305

    
1306
osVariantsFile :: String
1307
osVariantsFile = "variants.list"
1308

    
1309
osParametersFile :: String
1310
osParametersFile = "parameters.list"
1311

    
1312
osValidateParameters :: String
1313
osValidateParameters = "parameters"
1314

    
1315
osValidateCalls :: FrozenSet String
1316
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1317

    
1318
-- | External Storage (ES) related constants
1319

    
1320
esActionAttach :: String
1321
esActionAttach = "attach"
1322

    
1323
esActionCreate :: String
1324
esActionCreate = "create"
1325

    
1326
esActionDetach :: String
1327
esActionDetach = "detach"
1328

    
1329
esActionGrow :: String
1330
esActionGrow = "grow"
1331

    
1332
esActionRemove :: String
1333
esActionRemove = "remove"
1334

    
1335
esActionSetinfo :: String
1336
esActionSetinfo = "setinfo"
1337

    
1338
esActionVerify :: String
1339
esActionVerify = "verify"
1340

    
1341
esScriptCreate :: String
1342
esScriptCreate = esActionCreate
1343

    
1344
esScriptRemove :: String
1345
esScriptRemove = esActionRemove
1346

    
1347
esScriptGrow :: String
1348
esScriptGrow = esActionGrow
1349

    
1350
esScriptAttach :: String
1351
esScriptAttach = esActionAttach
1352

    
1353
esScriptDetach :: String
1354
esScriptDetach = esActionDetach
1355

    
1356
esScriptSetinfo :: String
1357
esScriptSetinfo = esActionSetinfo
1358

    
1359
esScriptVerify :: String
1360
esScriptVerify = esActionVerify
1361

    
1362
esScripts :: FrozenSet String
1363
esScripts =
1364
  ConstantUtils.mkSet [esScriptAttach,
1365
                       esScriptCreate,
1366
                       esScriptDetach,
1367
                       esScriptGrow,
1368
                       esScriptRemove,
1369
                       esScriptSetinfo,
1370
                       esScriptVerify]
1371

    
1372
esParametersFile :: String
1373
esParametersFile = "parameters.list"
1374

    
1375
-- * Reboot types
1376

    
1377
instanceRebootSoft :: String
1378
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1379

    
1380
instanceRebootHard :: String
1381
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1382

    
1383
instanceRebootFull :: String
1384
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1385

    
1386
rebootTypes :: FrozenSet String
1387
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1388

    
1389
-- * Instance reboot behaviors
1390

    
1391
instanceRebootAllowed :: String
1392
instanceRebootAllowed = "reboot"
1393

    
1394
instanceRebootExit :: String
1395
instanceRebootExit = "exit"
1396

    
1397
rebootBehaviors :: [String]
1398
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1399

    
1400
-- * VTypes
1401

    
1402
vtypeBool :: VType
1403
vtypeBool = VTypeBool
1404

    
1405
vtypeInt :: VType
1406
vtypeInt = VTypeInt
1407

    
1408
vtypeMaybeString :: VType
1409
vtypeMaybeString = VTypeMaybeString
1410

    
1411
-- | Size in MiBs
1412
vtypeSize :: VType
1413
vtypeSize = VTypeSize
1414

    
1415
vtypeString :: VType
1416
vtypeString = VTypeString
1417

    
1418
enforceableTypes :: FrozenSet VType
1419
enforceableTypes = ConstantUtils.mkSet [minBound..]
1420

    
1421
-- | Constant representing that the user does not specify any IP version
1422
ifaceNoIpVersionSpecified :: Int
1423
ifaceNoIpVersionSpecified = 0
1424

    
1425
validSerialSpeeds :: [Int]
1426
validSerialSpeeds =
1427
  [75,
1428
   110,
1429
   300,
1430
   600,
1431
   1200,
1432
   1800,
1433
   2400,
1434
   4800,
1435
   9600,
1436
   14400,
1437
   19200,
1438
   28800,
1439
   38400,
1440
   57600,
1441
   115200,
1442
   230400,
1443
   345600,
1444
   460800]
1445

    
1446
-- * HV parameter names (global namespace)
1447

    
1448
hvAcpi :: String
1449
hvAcpi = "acpi"
1450

    
1451
hvBlockdevPrefix :: String
1452
hvBlockdevPrefix = "blockdev_prefix"
1453

    
1454
hvBootloaderArgs :: String
1455
hvBootloaderArgs = "bootloader_args"
1456

    
1457
hvBootloaderPath :: String
1458
hvBootloaderPath = "bootloader_path"
1459

    
1460
hvBootOrder :: String
1461
hvBootOrder = "boot_order"
1462

    
1463
hvCdromImagePath :: String
1464
hvCdromImagePath = "cdrom_image_path"
1465

    
1466
hvCpuCap :: String
1467
hvCpuCap = "cpu_cap"
1468

    
1469
hvCpuCores :: String
1470
hvCpuCores = "cpu_cores"
1471

    
1472
hvCpuMask :: String
1473
hvCpuMask = "cpu_mask"
1474

    
1475
hvCpuSockets :: String
1476
hvCpuSockets = "cpu_sockets"
1477

    
1478
hvCpuThreads :: String
1479
hvCpuThreads = "cpu_threads"
1480

    
1481
hvCpuType :: String
1482
hvCpuType = "cpu_type"
1483

    
1484
hvCpuWeight :: String
1485
hvCpuWeight = "cpu_weight"
1486

    
1487
hvDeviceModel :: String
1488
hvDeviceModel = "device_model"
1489

    
1490
hvDiskCache :: String
1491
hvDiskCache = "disk_cache"
1492

    
1493
hvDiskType :: String
1494
hvDiskType = "disk_type"
1495

    
1496
hvInitrdPath :: String
1497
hvInitrdPath = "initrd_path"
1498

    
1499
hvInitScript :: String
1500
hvInitScript = "init_script"
1501

    
1502
hvKernelArgs :: String
1503
hvKernelArgs = "kernel_args"
1504

    
1505
hvKernelPath :: String
1506
hvKernelPath = "kernel_path"
1507

    
1508
hvKeymap :: String
1509
hvKeymap = "keymap"
1510

    
1511
hvKvmCdrom2ImagePath :: String
1512
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1513

    
1514
hvKvmCdromDiskType :: String
1515
hvKvmCdromDiskType = "cdrom_disk_type"
1516

    
1517
hvKvmExtra :: String
1518
hvKvmExtra = "kvm_extra"
1519

    
1520
hvKvmFlag :: String
1521
hvKvmFlag = "kvm_flag"
1522

    
1523
hvKvmFloppyImagePath :: String
1524
hvKvmFloppyImagePath = "floppy_image_path"
1525

    
1526
hvKvmMachineVersion :: String
1527
hvKvmMachineVersion = "machine_version"
1528

    
1529
hvKvmPath :: String
1530
hvKvmPath = "kvm_path"
1531

    
1532
hvKvmSpiceAudioCompr :: String
1533
hvKvmSpiceAudioCompr = "spice_playback_compression"
1534

    
1535
hvKvmSpiceBind :: String
1536
hvKvmSpiceBind = "spice_bind"
1537

    
1538
hvKvmSpiceIpVersion :: String
1539
hvKvmSpiceIpVersion = "spice_ip_version"
1540

    
1541
hvKvmSpiceJpegImgCompr :: String
1542
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1543

    
1544
hvKvmSpiceLosslessImgCompr :: String
1545
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1546

    
1547
hvKvmSpicePasswordFile :: String
1548
hvKvmSpicePasswordFile = "spice_password_file"
1549

    
1550
hvKvmSpiceStreamingVideoDetection :: String
1551
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1552

    
1553
hvKvmSpiceTlsCiphers :: String
1554
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1555

    
1556
hvKvmSpiceUseTls :: String
1557
hvKvmSpiceUseTls = "spice_use_tls"
1558

    
1559
hvKvmSpiceUseVdagent :: String
1560
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1561

    
1562
hvKvmSpiceZlibGlzImgCompr :: String
1563
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1564

    
1565
hvKvmUseChroot :: String
1566
hvKvmUseChroot = "use_chroot"
1567

    
1568
hvMemPath :: String
1569
hvMemPath = "mem_path"
1570

    
1571
hvMigrationBandwidth :: String
1572
hvMigrationBandwidth = "migration_bandwidth"
1573

    
1574
hvMigrationDowntime :: String
1575
hvMigrationDowntime = "migration_downtime"
1576

    
1577
hvMigrationMode :: String
1578
hvMigrationMode = "migration_mode"
1579

    
1580
hvMigrationPort :: String
1581
hvMigrationPort = "migration_port"
1582

    
1583
hvNicType :: String
1584
hvNicType = "nic_type"
1585

    
1586
hvPae :: String
1587
hvPae = "pae"
1588

    
1589
hvPassthrough :: String
1590
hvPassthrough = "pci_pass"
1591

    
1592
hvRebootBehavior :: String
1593
hvRebootBehavior = "reboot_behavior"
1594

    
1595
hvRootPath :: String
1596
hvRootPath = "root_path"
1597

    
1598
hvSecurityDomain :: String
1599
hvSecurityDomain = "security_domain"
1600

    
1601
hvSecurityModel :: String
1602
hvSecurityModel = "security_model"
1603

    
1604
hvSerialConsole :: String
1605
hvSerialConsole = "serial_console"
1606

    
1607
hvSerialSpeed :: String
1608
hvSerialSpeed = "serial_speed"
1609

    
1610
hvSoundhw :: String
1611
hvSoundhw = "soundhw"
1612

    
1613
hvUsbDevices :: String
1614
hvUsbDevices = "usb_devices"
1615

    
1616
hvUsbMouse :: String
1617
hvUsbMouse = "usb_mouse"
1618

    
1619
hvUseBootloader :: String
1620
hvUseBootloader = "use_bootloader"
1621

    
1622
hvUseLocaltime :: String
1623
hvUseLocaltime = "use_localtime"
1624

    
1625
hvVga :: String
1626
hvVga = "vga"
1627

    
1628
hvVhostNet :: String
1629
hvVhostNet = "vhost_net"
1630

    
1631
hvVifScript :: String
1632
hvVifScript = "vif_script"
1633

    
1634
hvVifType :: String
1635
hvVifType = "vif_type"
1636

    
1637
hvViridian :: String
1638
hvViridian = "viridian"
1639

    
1640
hvVncBindAddress :: String
1641
hvVncBindAddress = "vnc_bind_address"
1642

    
1643
hvVncPasswordFile :: String
1644
hvVncPasswordFile = "vnc_password_file"
1645

    
1646
hvVncTls :: String
1647
hvVncTls = "vnc_tls"
1648

    
1649
hvVncX509 :: String
1650
hvVncX509 = "vnc_x509_path"
1651

    
1652
hvVncX509Verify :: String
1653
hvVncX509Verify = "vnc_x509_verify"
1654

    
1655
hvVnetHdr :: String
1656
hvVnetHdr = "vnet_hdr"
1657

    
1658
hvXenCmd :: String
1659
hvXenCmd = "xen_cmd"
1660

    
1661
hvXenCpuid :: String
1662
hvXenCpuid = "cpuid"
1663

    
1664
hvsParameterTitles :: Map String String
1665
hvsParameterTitles =
1666
  Map.fromList
1667
  [(hvAcpi, "ACPI"),
1668
   (hvBootOrder, "Boot_order"),
1669
   (hvCdromImagePath, "CDROM_image_path"),
1670
   (hvCpuType, "cpu_type"),
1671
   (hvDiskType, "Disk_type"),
1672
   (hvInitrdPath, "Initrd_path"),
1673
   (hvKernelPath, "Kernel_path"),
1674
   (hvNicType, "NIC_type"),
1675
   (hvPae, "PAE"),
1676
   (hvPassthrough, "pci_pass"),
1677
   (hvVncBindAddress, "VNC_bind_address")]
1678

    
1679
hvsParameters :: FrozenSet String
1680
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1681

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

    
1758
-- * Migration statuses
1759

    
1760
hvMigrationActive :: String
1761
hvMigrationActive = "active"
1762

    
1763
hvMigrationCancelled :: String
1764
hvMigrationCancelled = "cancelled"
1765

    
1766
hvMigrationCompleted :: String
1767
hvMigrationCompleted = "completed"
1768

    
1769
hvMigrationFailed :: String
1770
hvMigrationFailed = "failed"
1771

    
1772
hvMigrationValidStatuses :: FrozenSet String
1773
hvMigrationValidStatuses =
1774
  ConstantUtils.mkSet [hvMigrationActive,
1775
                       hvMigrationCancelled,
1776
                       hvMigrationCompleted,
1777
                       hvMigrationFailed]
1778

    
1779
hvMigrationFailedStatuses :: FrozenSet String
1780
hvMigrationFailedStatuses =
1781
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1782

    
1783
-- | KVM-specific statuses
1784
--
1785
-- FIXME: this constant seems unnecessary
1786
hvKvmMigrationValidStatuses :: FrozenSet String
1787
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1788

    
1789
-- | Node info keys
1790
hvNodeinfoKeyVersion :: String
1791
hvNodeinfoKeyVersion = "hv_version"
1792

    
1793
-- * Hypervisor state
1794

    
1795
hvstCpuNode :: String
1796
hvstCpuNode = "cpu_node"
1797

    
1798
hvstCpuTotal :: String
1799
hvstCpuTotal = "cpu_total"
1800

    
1801
hvstMemoryHv :: String
1802
hvstMemoryHv = "mem_hv"
1803

    
1804
hvstMemoryNode :: String
1805
hvstMemoryNode = "mem_node"
1806

    
1807
hvstMemoryTotal :: String
1808
hvstMemoryTotal = "mem_total"
1809

    
1810
hvstsParameters :: FrozenSet String
1811
hvstsParameters =
1812
  ConstantUtils.mkSet [hvstCpuNode,
1813
                       hvstCpuTotal,
1814
                       hvstMemoryHv,
1815
                       hvstMemoryNode,
1816
                       hvstMemoryTotal]
1817

    
1818
hvstDefaults :: Map String Int
1819
hvstDefaults =
1820
  Map.fromList
1821
  [(hvstCpuNode, 1),
1822
   (hvstCpuTotal, 1),
1823
   (hvstMemoryHv, 0),
1824
   (hvstMemoryTotal, 0),
1825
   (hvstMemoryNode, 0)]
1826

    
1827
hvstsParameterTypes :: Map String VType
1828
hvstsParameterTypes =
1829
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1830
                (hvstMemoryNode, VTypeInt),
1831
                (hvstMemoryHv, VTypeInt),
1832
                (hvstCpuTotal, VTypeInt),
1833
                (hvstCpuNode, VTypeInt)]
1834

    
1835
-- * Disk state
1836

    
1837
dsDiskOverhead :: String
1838
dsDiskOverhead = "disk_overhead"
1839

    
1840
dsDiskReserved :: String
1841
dsDiskReserved = "disk_reserved"
1842

    
1843
dsDiskTotal :: String
1844
dsDiskTotal = "disk_total"
1845

    
1846
dsDefaults :: Map String Int
1847
dsDefaults =
1848
  Map.fromList
1849
  [(dsDiskTotal, 0),
1850
   (dsDiskReserved, 0),
1851
   (dsDiskOverhead, 0)]
1852

    
1853
dssParameterTypes :: Map String VType
1854
dssParameterTypes =
1855
  Map.fromList [(dsDiskTotal, VTypeInt),
1856
                (dsDiskReserved, VTypeInt),
1857
                (dsDiskOverhead, VTypeInt)]
1858

    
1859
dssParameters :: FrozenSet String
1860
dssParameters =
1861
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1862

    
1863
dsValidTypes :: FrozenSet String
1864
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1865

    
1866
-- Backend parameter names
1867

    
1868
beAlwaysFailover :: String
1869
beAlwaysFailover = "always_failover"
1870

    
1871
beAutoBalance :: String
1872
beAutoBalance = "auto_balance"
1873

    
1874
beMaxmem :: String
1875
beMaxmem = "maxmem"
1876

    
1877
-- | Deprecated and replaced by max and min mem
1878
beMemory :: String
1879
beMemory = "memory"
1880

    
1881
beMinmem :: String
1882
beMinmem = "minmem"
1883

    
1884
beSpindleUse :: String
1885
beSpindleUse = "spindle_use"
1886

    
1887
beVcpus :: String
1888
beVcpus = "vcpus"
1889

    
1890
besParameterTypes :: Map String VType
1891
besParameterTypes =
1892
  Map.fromList [(beAlwaysFailover, VTypeBool),
1893
                (beAutoBalance, VTypeBool),
1894
                (beMaxmem, VTypeSize),
1895
                (beMinmem, VTypeSize),
1896
                (beSpindleUse, VTypeInt),
1897
                (beVcpus, VTypeInt)]
1898

    
1899
besParameterTitles :: Map String String
1900
besParameterTitles =
1901
  Map.fromList [(beAutoBalance, "Auto_balance"),
1902
                (beMinmem, "ConfigMinMem"),
1903
                (beVcpus, "ConfigVCPUs"),
1904
                (beMaxmem, "ConfigMaxMem")]
1905

    
1906
besParameterCompat :: Map String VType
1907
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1908

    
1909
besParameters :: FrozenSet String
1910
besParameters =
1911
  ConstantUtils.mkSet [beAlwaysFailover,
1912
                       beAutoBalance,
1913
                       beMaxmem,
1914
                       beMinmem,
1915
                       beSpindleUse,
1916
                       beVcpus]
1917

    
1918
-- | Instance specs
1919
--
1920
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1921

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

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

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

    
1931
ispecDiskSize :: String
1932
ispecDiskSize = ConstantUtils.ispecDiskSize
1933

    
1934
ispecNicCount :: String
1935
ispecNicCount = ConstantUtils.ispecNicCount
1936

    
1937
ispecSpindleUse :: String
1938
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1939

    
1940
ispecsParameterTypes :: Map String VType
1941
ispecsParameterTypes =
1942
  Map.fromList
1943
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1944
   (ConstantUtils.ispecCpuCount, VTypeInt),
1945
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1946
   (ConstantUtils.ispecMemSize, VTypeInt),
1947
   (ConstantUtils.ispecNicCount, VTypeInt),
1948
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1949

    
1950
ispecsParameters :: FrozenSet String
1951
ispecsParameters =
1952
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1953
                       ConstantUtils.ispecDiskCount,
1954
                       ConstantUtils.ispecDiskSize,
1955
                       ConstantUtils.ispecMemSize,
1956
                       ConstantUtils.ispecNicCount,
1957
                       ConstantUtils.ispecSpindleUse]
1958

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

    
1962
ispecsMax :: String
1963
ispecsMax = "max"
1964

    
1965
ispecsMin :: String
1966
ispecsMin = "min"
1967

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

    
1971
ipolicyDts :: String
1972
ipolicyDts = ConstantUtils.ipolicyDts
1973

    
1974
ipolicyVcpuRatio :: String
1975
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1976

    
1977
ipolicySpindleRatio :: String
1978
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
1979

    
1980
ispecsMinmaxKeys :: FrozenSet String
1981
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1982

    
1983
ipolicyParameters :: FrozenSet String
1984
ipolicyParameters =
1985
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1986
                       ConstantUtils.ipolicySpindleRatio]
1987

    
1988
ipolicyAllKeys :: FrozenSet String
1989
ipolicyAllKeys =
1990
  ConstantUtils.union ipolicyParameters $
1991
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1992
                       ConstantUtils.ispecsMinmax,
1993
                       ispecsStd]
1994

    
1995
-- | Node parameter names
1996

    
1997
ndExclusiveStorage :: String
1998
ndExclusiveStorage = "exclusive_storage"
1999

    
2000
ndOobProgram :: String
2001
ndOobProgram = "oob_program"
2002

    
2003
ndSpindleCount :: String
2004
ndSpindleCount = "spindle_count"
2005

    
2006
ndOvs :: String
2007
ndOvs = "ovs"
2008

    
2009
ndOvsLink :: String
2010
ndOvsLink = "ovs_link"
2011

    
2012
ndOvsName :: String
2013
ndOvsName = "ovs_name"
2014

    
2015
ndSshPort :: String
2016
ndSshPort = "ssh_port"
2017

    
2018
ndsParameterTypes :: Map String VType
2019
ndsParameterTypes =
2020
  Map.fromList
2021
  [(ndExclusiveStorage, VTypeBool),
2022
   (ndOobProgram, VTypeString),
2023
   (ndOvs, VTypeBool),
2024
   (ndOvsLink, VTypeMaybeString),
2025
   (ndOvsName, VTypeMaybeString),
2026
   (ndSpindleCount, VTypeInt),
2027
   (ndSshPort, VTypeInt)]
2028

    
2029
ndsParameters :: FrozenSet String
2030
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
2031

    
2032
ndsParameterTitles :: Map String String
2033
ndsParameterTitles =
2034
  Map.fromList
2035
  [(ndExclusiveStorage, "ExclusiveStorage"),
2036
   (ndOobProgram, "OutOfBandProgram"),
2037
   (ndOvs, "OpenvSwitch"),
2038
   (ndOvsLink, "OpenvSwitchLink"),
2039
   (ndOvsName, "OpenvSwitchName"),
2040
   (ndSpindleCount, "SpindleCount")]
2041

    
2042
-- * Logical Disks parameters
2043

    
2044
ldpAccess :: String
2045
ldpAccess = "access"
2046

    
2047
ldpBarriers :: String
2048
ldpBarriers = "disabled-barriers"
2049

    
2050
ldpDefaultMetavg :: String
2051
ldpDefaultMetavg = "default-metavg"
2052

    
2053
ldpDelayTarget :: String
2054
ldpDelayTarget = "c-delay-target"
2055

    
2056
ldpDiskCustom :: String
2057
ldpDiskCustom = "disk-custom"
2058

    
2059
ldpDynamicResync :: String
2060
ldpDynamicResync = "dynamic-resync"
2061

    
2062
ldpFillTarget :: String
2063
ldpFillTarget = "c-fill-target"
2064

    
2065
ldpMaxRate :: String
2066
ldpMaxRate = "c-max-rate"
2067

    
2068
ldpMinRate :: String
2069
ldpMinRate = "c-min-rate"
2070

    
2071
ldpNetCustom :: String
2072
ldpNetCustom = "net-custom"
2073

    
2074
ldpNoMetaFlush :: String
2075
ldpNoMetaFlush = "disable-meta-flush"
2076

    
2077
ldpPlanAhead :: String
2078
ldpPlanAhead = "c-plan-ahead"
2079

    
2080
ldpPool :: String
2081
ldpPool = "pool"
2082

    
2083
ldpProtocol :: String
2084
ldpProtocol = "protocol"
2085

    
2086
ldpResyncRate :: String
2087
ldpResyncRate = "resync-rate"
2088

    
2089
ldpStripes :: String
2090
ldpStripes = "stripes"
2091

    
2092
diskLdTypes :: Map String VType
2093
diskLdTypes =
2094
  Map.fromList
2095
  [(ldpAccess, VTypeString),
2096
   (ldpResyncRate, VTypeInt),
2097
   (ldpStripes, VTypeInt),
2098
   (ldpBarriers, VTypeString),
2099
   (ldpNoMetaFlush, VTypeBool),
2100
   (ldpDefaultMetavg, VTypeString),
2101
   (ldpDiskCustom, VTypeString),
2102
   (ldpNetCustom, VTypeString),
2103
   (ldpProtocol, VTypeString),
2104
   (ldpDynamicResync, VTypeBool),
2105
   (ldpPlanAhead, VTypeInt),
2106
   (ldpFillTarget, VTypeInt),
2107
   (ldpDelayTarget, VTypeInt),
2108
   (ldpMaxRate, VTypeInt),
2109
   (ldpMinRate, VTypeInt),
2110
   (ldpPool, VTypeString)]
2111

    
2112
diskLdParameters :: FrozenSet String
2113
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2114

    
2115
-- * Disk template parameters
2116
--
2117
-- Disk template parameters can be set/changed by the user via
2118
-- gnt-cluster and gnt-group)
2119

    
2120
drbdResyncRate :: String
2121
drbdResyncRate = "resync-rate"
2122

    
2123
drbdDataStripes :: String
2124
drbdDataStripes = "data-stripes"
2125

    
2126
drbdMetaStripes :: String
2127
drbdMetaStripes = "meta-stripes"
2128

    
2129
drbdDiskBarriers :: String
2130
drbdDiskBarriers = "disk-barriers"
2131

    
2132
drbdMetaBarriers :: String
2133
drbdMetaBarriers = "meta-barriers"
2134

    
2135
drbdDefaultMetavg :: String
2136
drbdDefaultMetavg = "metavg"
2137

    
2138
drbdDiskCustom :: String
2139
drbdDiskCustom = "disk-custom"
2140

    
2141
drbdNetCustom :: String
2142
drbdNetCustom = "net-custom"
2143

    
2144
drbdProtocol :: String
2145
drbdProtocol = "protocol"
2146

    
2147
drbdDynamicResync :: String
2148
drbdDynamicResync = "dynamic-resync"
2149

    
2150
drbdPlanAhead :: String
2151
drbdPlanAhead = "c-plan-ahead"
2152

    
2153
drbdFillTarget :: String
2154
drbdFillTarget = "c-fill-target"
2155

    
2156
drbdDelayTarget :: String
2157
drbdDelayTarget = "c-delay-target"
2158

    
2159
drbdMaxRate :: String
2160
drbdMaxRate = "c-max-rate"
2161

    
2162
drbdMinRate :: String
2163
drbdMinRate = "c-min-rate"
2164

    
2165
lvStripes :: String
2166
lvStripes = "stripes"
2167

    
2168
rbdAccess :: String
2169
rbdAccess = "access"
2170

    
2171
rbdPool :: String
2172
rbdPool = "pool"
2173

    
2174
diskDtTypes :: Map String VType
2175
diskDtTypes =
2176
  Map.fromList [(drbdResyncRate, VTypeInt),
2177
                (drbdDataStripes, VTypeInt),
2178
                (drbdMetaStripes, VTypeInt),
2179
                (drbdDiskBarriers, VTypeString),
2180
                (drbdMetaBarriers, VTypeBool),
2181
                (drbdDefaultMetavg, VTypeString),
2182
                (drbdDiskCustom, VTypeString),
2183
                (drbdNetCustom, VTypeString),
2184
                (drbdProtocol, VTypeString),
2185
                (drbdDynamicResync, VTypeBool),
2186
                (drbdPlanAhead, VTypeInt),
2187
                (drbdFillTarget, VTypeInt),
2188
                (drbdDelayTarget, VTypeInt),
2189
                (drbdMaxRate, VTypeInt),
2190
                (drbdMinRate, VTypeInt),
2191
                (lvStripes, VTypeInt),
2192
                (rbdAccess, VTypeString),
2193
                (rbdPool, VTypeString),
2194
                (glusterHost, VTypeString),
2195
                (glusterVolume, VTypeString),
2196
                (glusterPort, VTypeInt)
2197
               ]
2198

    
2199
diskDtParameters :: FrozenSet String
2200
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2201

    
2202
-- * Dynamic disk parameters
2203

    
2204
ddpLocalIp :: String
2205
ddpLocalIp = "local-ip"
2206

    
2207
ddpRemoteIp :: String
2208
ddpRemoteIp = "remote-ip"
2209

    
2210
ddpPort :: String
2211
ddpPort = "port"
2212

    
2213
ddpLocalMinor :: String
2214
ddpLocalMinor = "local-minor"
2215

    
2216
ddpRemoteMinor :: String
2217
ddpRemoteMinor = "remote-minor"
2218

    
2219
-- * OOB supported commands
2220

    
2221
oobPowerOn :: String
2222
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2223

    
2224
oobPowerOff :: String
2225
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2226

    
2227
oobPowerCycle :: String
2228
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2229

    
2230
oobPowerStatus :: String
2231
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2232

    
2233
oobHealth :: String
2234
oobHealth = Types.oobCommandToRaw OobHealth
2235

    
2236
oobCommands :: FrozenSet String
2237
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2238

    
2239
oobPowerStatusPowered :: String
2240
oobPowerStatusPowered = "powered"
2241

    
2242
-- | 60 seconds
2243
oobTimeout :: Int
2244
oobTimeout = 60
2245

    
2246
-- | 2 seconds
2247
oobPowerDelay :: Double
2248
oobPowerDelay = 2.0
2249

    
2250
oobStatusCritical :: String
2251
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2252

    
2253
oobStatusOk :: String
2254
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2255

    
2256
oobStatusUnknown :: String
2257
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2258

    
2259
oobStatusWarning :: String
2260
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2261

    
2262
oobStatuses :: FrozenSet String
2263
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2264

    
2265
-- | Instance Parameters Profile
2266
ppDefault :: String
2267
ppDefault = "default"
2268

    
2269
-- * nic* constants are used inside the ganeti config
2270

    
2271
nicLink :: String
2272
nicLink = "link"
2273

    
2274
nicMode :: String
2275
nicMode = "mode"
2276

    
2277
nicVlan :: String
2278
nicVlan = "vlan"
2279

    
2280
nicsParameterTypes :: Map String VType
2281
nicsParameterTypes =
2282
  Map.fromList [(nicMode, vtypeString),
2283
                (nicLink, vtypeString),
2284
                (nicVlan, vtypeString)]
2285

    
2286
nicsParameters :: FrozenSet String
2287
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2288

    
2289
nicModeBridged :: String
2290
nicModeBridged = Types.nICModeToRaw NMBridged
2291

    
2292
nicModeRouted :: String
2293
nicModeRouted = Types.nICModeToRaw NMRouted
2294

    
2295
nicModeOvs :: String
2296
nicModeOvs = Types.nICModeToRaw NMOvs
2297

    
2298
nicIpPool :: String
2299
nicIpPool = Types.nICModeToRaw NMPool
2300

    
2301
nicValidModes :: FrozenSet String
2302
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2303

    
2304
releaseAction :: String
2305
releaseAction = "release"
2306

    
2307
reserveAction :: String
2308
reserveAction = "reserve"
2309

    
2310
-- * idisk* constants are used in opcodes, to create/change disks
2311

    
2312
idiskAdopt :: String
2313
idiskAdopt = "adopt"
2314

    
2315
idiskMetavg :: String
2316
idiskMetavg = "metavg"
2317

    
2318
idiskMode :: String
2319
idiskMode = "mode"
2320

    
2321
idiskName :: String
2322
idiskName = "name"
2323

    
2324
idiskSize :: String
2325
idiskSize = "size"
2326

    
2327
idiskSpindles :: String
2328
idiskSpindles = "spindles"
2329

    
2330
idiskVg :: String
2331
idiskVg = "vg"
2332

    
2333
idiskProvider :: String
2334
idiskProvider = "provider"
2335

    
2336
idiskParamsTypes :: Map String VType
2337
idiskParamsTypes =
2338
  Map.fromList [(idiskSize, VTypeSize),
2339
                (idiskSpindles, VTypeInt),
2340
                (idiskMode, VTypeString),
2341
                (idiskAdopt, VTypeString),
2342
                (idiskVg, VTypeString),
2343
                (idiskMetavg, VTypeString),
2344
                (idiskProvider, VTypeString),
2345
                (idiskName, VTypeMaybeString)]
2346

    
2347
idiskParams :: FrozenSet String
2348
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2349

    
2350
modifiableIdiskParamsTypes :: Map String VType
2351
modifiableIdiskParamsTypes =
2352
  Map.fromList [(idiskMode, VTypeString),
2353
                (idiskName, VTypeString)]
2354

    
2355
modifiableIdiskParams :: FrozenSet String
2356
modifiableIdiskParams =
2357
  ConstantUtils.mkSet (Map.keys modifiableIdiskParamsTypes)
2358

    
2359
-- * inic* constants are used in opcodes, to create/change nics
2360

    
2361
inicBridge :: String
2362
inicBridge = "bridge"
2363

    
2364
inicIp :: String
2365
inicIp = "ip"
2366

    
2367
inicLink :: String
2368
inicLink = "link"
2369

    
2370
inicMac :: String
2371
inicMac = "mac"
2372

    
2373
inicMode :: String
2374
inicMode = "mode"
2375

    
2376
inicName :: String
2377
inicName = "name"
2378

    
2379
inicNetwork :: String
2380
inicNetwork = "network"
2381

    
2382
inicVlan :: String
2383
inicVlan = "vlan"
2384

    
2385
inicParamsTypes :: Map String VType
2386
inicParamsTypes =
2387
  Map.fromList [(inicBridge, VTypeMaybeString),
2388
                (inicIp, VTypeMaybeString),
2389
                (inicLink, VTypeString),
2390
                (inicMac, VTypeString),
2391
                (inicMode, VTypeString),
2392
                (inicName, VTypeMaybeString),
2393
                (inicNetwork, VTypeMaybeString),
2394
                (inicVlan, VTypeMaybeString)]
2395

    
2396
inicParams :: FrozenSet String
2397
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2398

    
2399
-- * Hypervisor constants
2400

    
2401
htXenPvm :: String
2402
htXenPvm = Types.hypervisorToRaw XenPvm
2403

    
2404
htFake :: String
2405
htFake = Types.hypervisorToRaw Fake
2406

    
2407
htXenHvm :: String
2408
htXenHvm = Types.hypervisorToRaw XenHvm
2409

    
2410
htKvm :: String
2411
htKvm = Types.hypervisorToRaw Kvm
2412

    
2413
htChroot :: String
2414
htChroot = Types.hypervisorToRaw Chroot
2415

    
2416
htLxc :: String
2417
htLxc = Types.hypervisorToRaw Lxc
2418

    
2419
hyperTypes :: FrozenSet String
2420
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2421

    
2422
htsReqPort :: FrozenSet String
2423
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2424

    
2425
vncBasePort :: Int
2426
vncBasePort = 5900
2427

    
2428
vncDefaultBindAddress :: String
2429
vncDefaultBindAddress = ip4AddressAny
2430

    
2431
-- * NIC types
2432

    
2433
htNicE1000 :: String
2434
htNicE1000 = "e1000"
2435

    
2436
htNicI82551 :: String
2437
htNicI82551 = "i82551"
2438

    
2439
htNicI8259er :: String
2440
htNicI8259er = "i82559er"
2441

    
2442
htNicI85557b :: String
2443
htNicI85557b = "i82557b"
2444

    
2445
htNicNe2kIsa :: String
2446
htNicNe2kIsa = "ne2k_isa"
2447

    
2448
htNicNe2kPci :: String
2449
htNicNe2kPci = "ne2k_pci"
2450

    
2451
htNicParavirtual :: String
2452
htNicParavirtual = "paravirtual"
2453

    
2454
htNicPcnet :: String
2455
htNicPcnet = "pcnet"
2456

    
2457
htNicRtl8139 :: String
2458
htNicRtl8139 = "rtl8139"
2459

    
2460
htHvmValidNicTypes :: FrozenSet String
2461
htHvmValidNicTypes =
2462
  ConstantUtils.mkSet [htNicE1000,
2463
                       htNicNe2kIsa,
2464
                       htNicNe2kPci,
2465
                       htNicParavirtual,
2466
                       htNicRtl8139]
2467

    
2468
htKvmValidNicTypes :: FrozenSet String
2469
htKvmValidNicTypes =
2470
  ConstantUtils.mkSet [htNicE1000,
2471
                       htNicI82551,
2472
                       htNicI8259er,
2473
                       htNicI85557b,
2474
                       htNicNe2kIsa,
2475
                       htNicNe2kPci,
2476
                       htNicParavirtual,
2477
                       htNicPcnet,
2478
                       htNicRtl8139]
2479

    
2480
-- * Vif types
2481

    
2482
-- | Default vif type in xen-hvm
2483
htHvmVifIoemu :: String
2484
htHvmVifIoemu = "ioemu"
2485

    
2486
htHvmVifVif :: String
2487
htHvmVifVif = "vif"
2488

    
2489
htHvmValidVifTypes :: FrozenSet String
2490
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2491

    
2492
-- * Disk types
2493

    
2494
htDiskIde :: String
2495
htDiskIde = "ide"
2496

    
2497
htDiskIoemu :: String
2498
htDiskIoemu = "ioemu"
2499

    
2500
htDiskMtd :: String
2501
htDiskMtd = "mtd"
2502

    
2503
htDiskParavirtual :: String
2504
htDiskParavirtual = "paravirtual"
2505

    
2506
htDiskPflash :: String
2507
htDiskPflash = "pflash"
2508

    
2509
htDiskScsi :: String
2510
htDiskScsi = "scsi"
2511

    
2512
htDiskSd :: String
2513
htDiskSd = "sd"
2514

    
2515
htHvmValidDiskTypes :: FrozenSet String
2516
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2517

    
2518
htKvmValidDiskTypes :: FrozenSet String
2519
htKvmValidDiskTypes =
2520
  ConstantUtils.mkSet [htDiskIde,
2521
                       htDiskMtd,
2522
                       htDiskParavirtual,
2523
                       htDiskPflash,
2524
                       htDiskScsi,
2525
                       htDiskSd]
2526

    
2527
htCacheDefault :: String
2528
htCacheDefault = "default"
2529

    
2530
htCacheNone :: String
2531
htCacheNone = "none"
2532

    
2533
htCacheWback :: String
2534
htCacheWback = "writeback"
2535

    
2536
htCacheWthrough :: String
2537
htCacheWthrough = "writethrough"
2538

    
2539
htValidCacheTypes :: FrozenSet String
2540
htValidCacheTypes =
2541
  ConstantUtils.mkSet [htCacheDefault,
2542
                       htCacheNone,
2543
                       htCacheWback,
2544
                       htCacheWthrough]
2545

    
2546
-- * Mouse types
2547

    
2548
htMouseMouse :: String
2549
htMouseMouse = "mouse"
2550

    
2551
htMouseTablet :: String
2552
htMouseTablet = "tablet"
2553

    
2554
htKvmValidMouseTypes :: FrozenSet String
2555
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2556

    
2557
-- * Boot order
2558

    
2559
htBoCdrom :: String
2560
htBoCdrom = "cdrom"
2561

    
2562
htBoDisk :: String
2563
htBoDisk = "disk"
2564

    
2565
htBoFloppy :: String
2566
htBoFloppy = "floppy"
2567

    
2568
htBoNetwork :: String
2569
htBoNetwork = "network"
2570

    
2571
htKvmValidBoTypes :: FrozenSet String
2572
htKvmValidBoTypes =
2573
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2574

    
2575
-- * SPICE lossless image compression options
2576

    
2577
htKvmSpiceLosslessImgComprAutoGlz :: String
2578
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2579

    
2580
htKvmSpiceLosslessImgComprAutoLz :: String
2581
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2582

    
2583
htKvmSpiceLosslessImgComprGlz :: String
2584
htKvmSpiceLosslessImgComprGlz = "glz"
2585

    
2586
htKvmSpiceLosslessImgComprLz :: String
2587
htKvmSpiceLosslessImgComprLz = "lz"
2588

    
2589
htKvmSpiceLosslessImgComprOff :: String
2590
htKvmSpiceLosslessImgComprOff = "off"
2591

    
2592
htKvmSpiceLosslessImgComprQuic :: String
2593
htKvmSpiceLosslessImgComprQuic = "quic"
2594

    
2595
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2596
htKvmSpiceValidLosslessImgComprOptions =
2597
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2598
                       htKvmSpiceLosslessImgComprAutoLz,
2599
                       htKvmSpiceLosslessImgComprGlz,
2600
                       htKvmSpiceLosslessImgComprLz,
2601
                       htKvmSpiceLosslessImgComprOff,
2602
                       htKvmSpiceLosslessImgComprQuic]
2603

    
2604
htKvmSpiceLossyImgComprAlways :: String
2605
htKvmSpiceLossyImgComprAlways = "always"
2606

    
2607
htKvmSpiceLossyImgComprAuto :: String
2608
htKvmSpiceLossyImgComprAuto = "auto"
2609

    
2610
htKvmSpiceLossyImgComprNever :: String
2611
htKvmSpiceLossyImgComprNever = "never"
2612

    
2613
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2614
htKvmSpiceValidLossyImgComprOptions =
2615
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2616
                       htKvmSpiceLossyImgComprAuto,
2617
                       htKvmSpiceLossyImgComprNever]
2618

    
2619
-- * SPICE video stream detection
2620

    
2621
htKvmSpiceVideoStreamDetectionAll :: String
2622
htKvmSpiceVideoStreamDetectionAll = "all"
2623

    
2624
htKvmSpiceVideoStreamDetectionFilter :: String
2625
htKvmSpiceVideoStreamDetectionFilter = "filter"
2626

    
2627
htKvmSpiceVideoStreamDetectionOff :: String
2628
htKvmSpiceVideoStreamDetectionOff = "off"
2629

    
2630
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2631
htKvmSpiceValidVideoStreamDetectionOptions =
2632
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2633
                       htKvmSpiceVideoStreamDetectionFilter,
2634
                       htKvmSpiceVideoStreamDetectionOff]
2635

    
2636
-- * Security models
2637

    
2638
htSmNone :: String
2639
htSmNone = "none"
2640

    
2641
htSmPool :: String
2642
htSmPool = "pool"
2643

    
2644
htSmUser :: String
2645
htSmUser = "user"
2646

    
2647
htKvmValidSmTypes :: FrozenSet String
2648
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2649

    
2650
-- * Kvm flag values
2651

    
2652
htKvmDisabled :: String
2653
htKvmDisabled = "disabled"
2654

    
2655
htKvmEnabled :: String
2656
htKvmEnabled = "enabled"
2657

    
2658
htKvmFlagValues :: FrozenSet String
2659
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2660

    
2661
-- * Migration type
2662

    
2663
htMigrationLive :: String
2664
htMigrationLive = Types.migrationModeToRaw MigrationLive
2665

    
2666
htMigrationNonlive :: String
2667
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2668

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

    
2673
-- * Cluster verify steps
2674

    
2675
verifyNplusoneMem :: String
2676
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2677

    
2678
verifyOptionalChecks :: FrozenSet String
2679
verifyOptionalChecks =
2680
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2681

    
2682
-- * Cluster Verify error classes
2683

    
2684
cvTcluster :: String
2685
cvTcluster = "cluster"
2686

    
2687
cvTgroup :: String
2688
cvTgroup = "group"
2689

    
2690
cvTnode :: String
2691
cvTnode = "node"
2692

    
2693
cvTinstance :: String
2694
cvTinstance = "instance"
2695

    
2696
-- * Cluster Verify error levels
2697

    
2698
cvWarning :: String
2699
cvWarning = "WARNING"
2700

    
2701
cvError :: String
2702
cvError = "ERROR"
2703

    
2704
-- * Cluster Verify error codes and documentation
2705

    
2706
cvEclustercert :: (String, String, String)
2707
cvEclustercert =
2708
  ("cluster",
2709
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2710
   "Cluster certificate files verification failure")
2711

    
2712
cvEclusterclientcert :: (String, String, String)
2713
cvEclusterclientcert =
2714
  ("cluster",
2715
   Types.cVErrorCodeToRaw CvECLUSTERCLIENTCERT,
2716
   "Cluster client certificate files verification failure")
2717

    
2718
cvEclustercfg :: (String, String, String)
2719
cvEclustercfg =
2720
  ("cluster",
2721
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2722
   "Cluster configuration verification failure")
2723

    
2724
cvEclusterdanglinginst :: (String, String, String)
2725
cvEclusterdanglinginst =
2726
  ("node",
2727
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2728
   "Some instances have a non-existing primary node")
2729

    
2730
cvEclusterdanglingnodes :: (String, String, String)
2731
cvEclusterdanglingnodes =
2732
  ("node",
2733
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2734
   "Some nodes belong to non-existing groups")
2735

    
2736
cvEclusterfilecheck :: (String, String, String)
2737
cvEclusterfilecheck =
2738
  ("cluster",
2739
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2740
   "Cluster configuration verification failure")
2741

    
2742
cvEgroupdifferentpvsize :: (String, String, String)
2743
cvEgroupdifferentpvsize =
2744
  ("group",
2745
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2746
   "PVs in the group have different sizes")
2747

    
2748
cvEinstancebadnode :: (String, String, String)
2749
cvEinstancebadnode =
2750
  ("instance",
2751
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2752
   "Instance marked as running lives on an offline node")
2753

    
2754
cvEinstancedown :: (String, String, String)
2755
cvEinstancedown =
2756
  ("instance",
2757
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2758
   "Instance not running on its primary node")
2759

    
2760
cvEinstancefaultydisk :: (String, String, String)
2761
cvEinstancefaultydisk =
2762
  ("instance",
2763
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2764
   "Impossible to retrieve status for a disk")
2765

    
2766
cvEinstancelayout :: (String, String, String)
2767
cvEinstancelayout =
2768
  ("instance",
2769
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2770
   "Instance has multiple secondary nodes")
2771

    
2772
cvEinstancemissingcfgparameter :: (String, String, String)
2773
cvEinstancemissingcfgparameter =
2774
  ("instance",
2775
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2776
   "A configuration parameter for an instance is missing")
2777

    
2778
cvEinstancemissingdisk :: (String, String, String)
2779
cvEinstancemissingdisk =
2780
  ("instance",
2781
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2782
   "Missing volume on an instance")
2783

    
2784
cvEinstancepolicy :: (String, String, String)
2785
cvEinstancepolicy =
2786
  ("instance",
2787
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2788
   "Instance does not meet policy")
2789

    
2790
cvEinstancesplitgroups :: (String, String, String)
2791
cvEinstancesplitgroups =
2792
  ("instance",
2793
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2794
   "Instance with primary and secondary nodes in different groups")
2795

    
2796
cvEinstanceunsuitablenode :: (String, String, String)
2797
cvEinstanceunsuitablenode =
2798
  ("instance",
2799
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2800
   "Instance running on nodes that are not suitable for it")
2801

    
2802
cvEinstancewrongnode :: (String, String, String)
2803
cvEinstancewrongnode =
2804
  ("instance",
2805
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2806
   "Instance running on the wrong node")
2807

    
2808
cvEnodedrbd :: (String, String, String)
2809
cvEnodedrbd =
2810
  ("node",
2811
   Types.cVErrorCodeToRaw CvENODEDRBD,
2812
   "Error parsing the DRBD status file")
2813

    
2814
cvEnodedrbdhelper :: (String, String, String)
2815
cvEnodedrbdhelper =
2816
  ("node",
2817
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2818
   "Error caused by the DRBD helper")
2819

    
2820
cvEnodedrbdversion :: (String, String, String)
2821
cvEnodedrbdversion =
2822
  ("node",
2823
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2824
   "DRBD version mismatch within a node group")
2825

    
2826
cvEnodefilecheck :: (String, String, String)
2827
cvEnodefilecheck =
2828
  ("node",
2829
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2830
   "Error retrieving the checksum of the node files")
2831

    
2832
cvEnodefilestoragepaths :: (String, String, String)
2833
cvEnodefilestoragepaths =
2834
  ("node",
2835
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2836
   "Detected bad file storage paths")
2837

    
2838
cvEnodefilestoragepathunusable :: (String, String, String)
2839
cvEnodefilestoragepathunusable =
2840
  ("node",
2841
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2842
   "File storage path unusable")
2843

    
2844
cvEnodehooks :: (String, String, String)
2845
cvEnodehooks =
2846
  ("node",
2847
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2848
   "Communication failure in hooks execution")
2849

    
2850
cvEnodehv :: (String, String, String)
2851
cvEnodehv =
2852
  ("node",
2853
   Types.cVErrorCodeToRaw CvENODEHV,
2854
   "Hypervisor parameters verification failure")
2855

    
2856
cvEnodelvm :: (String, String, String)
2857
cvEnodelvm =
2858
  ("node",
2859
   Types.cVErrorCodeToRaw CvENODELVM,
2860
   "LVM-related node error")
2861

    
2862
cvEnoden1 :: (String, String, String)
2863
cvEnoden1 =
2864
  ("node",
2865
   Types.cVErrorCodeToRaw CvENODEN1,
2866
   "Not enough memory to accommodate instance failovers")
2867

    
2868
cvEnodenet :: (String, String, String)
2869
cvEnodenet =
2870
  ("node",
2871
   Types.cVErrorCodeToRaw CvENODENET,
2872
   "Network-related node error")
2873

    
2874
cvEnodeoobpath :: (String, String, String)
2875
cvEnodeoobpath =
2876
  ("node",
2877
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2878
   "Invalid Out Of Band path")
2879

    
2880
cvEnodeorphaninstance :: (String, String, String)
2881
cvEnodeorphaninstance =
2882
  ("node",
2883
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2884
   "Unknown intance running on a node")
2885

    
2886
cvEnodeorphanlv :: (String, String, String)
2887
cvEnodeorphanlv =
2888
  ("node",
2889
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2890
   "Unknown LVM logical volume")
2891

    
2892
cvEnodeos :: (String, String, String)
2893
cvEnodeos =
2894
  ("node",
2895
   Types.cVErrorCodeToRaw CvENODEOS,
2896
   "OS-related node error")
2897

    
2898
cvEnoderpc :: (String, String, String)
2899
cvEnoderpc =
2900
  ("node",
2901
   Types.cVErrorCodeToRaw CvENODERPC,
2902
   "Error during connection to the primary node of an instance")
2903

    
2904
cvEnodesetup :: (String, String, String)
2905
cvEnodesetup =
2906
  ("node",
2907
   Types.cVErrorCodeToRaw CvENODESETUP,
2908
   "Node setup error")
2909

    
2910
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2911
cvEnodesharedfilestoragepathunusable =
2912
  ("node",
2913
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2914
   "Shared file storage path unusable")
2915

    
2916
cvEnodessh :: (String, String, String)
2917
cvEnodessh =
2918
  ("node",
2919
   Types.cVErrorCodeToRaw CvENODESSH,
2920
   "SSH-related node error")
2921

    
2922
cvEnodetime :: (String, String, String)
2923
cvEnodetime =
2924
  ("node",
2925
   Types.cVErrorCodeToRaw CvENODETIME,
2926
   "Node returned invalid time")
2927

    
2928
cvEnodeuserscripts :: (String, String, String)
2929
cvEnodeuserscripts =
2930
  ("node",
2931
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2932
   "User scripts not present or not executable")
2933

    
2934
cvEnodeversion :: (String, String, String)
2935
cvEnodeversion =
2936
  ("node",
2937
   Types.cVErrorCodeToRaw CvENODEVERSION,
2938
   "Protocol version mismatch or Ganeti version mismatch")
2939

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

    
2982
cvAllEcodesStrings :: FrozenSet String
2983
cvAllEcodesStrings =
2984
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2985

    
2986
-- * Node verify constants
2987

    
2988
nvBridges :: String
2989
nvBridges = "bridges"
2990

    
2991
nvClientCert :: String
2992
nvClientCert = "client-cert"
2993

    
2994
nvDrbdhelper :: String
2995
nvDrbdhelper = "drbd-helper"
2996

    
2997
nvDrbdversion :: String
2998
nvDrbdversion = "drbd-version"
2999

    
3000
nvDrbdlist :: String
3001
nvDrbdlist = "drbd-list"
3002

    
3003
nvExclusivepvs :: String
3004
nvExclusivepvs = "exclusive-pvs"
3005

    
3006
nvFilelist :: String
3007
nvFilelist = "filelist"
3008

    
3009
nvAcceptedStoragePaths :: String
3010
nvAcceptedStoragePaths = "allowed-file-storage-paths"
3011

    
3012
nvFileStoragePath :: String
3013
nvFileStoragePath = "file-storage-path"
3014

    
3015
nvSharedFileStoragePath :: String
3016
nvSharedFileStoragePath = "shared-file-storage-path"
3017

    
3018
nvHvinfo :: String
3019
nvHvinfo = "hvinfo"
3020

    
3021
nvHvparams :: String
3022
nvHvparams = "hvparms"
3023

    
3024
nvHypervisor :: String
3025
nvHypervisor = "hypervisor"
3026

    
3027
nvInstancelist :: String
3028
nvInstancelist = "instancelist"
3029

    
3030
nvLvlist :: String
3031
nvLvlist = "lvlist"
3032

    
3033
nvMasterip :: String
3034
nvMasterip = "master-ip"
3035

    
3036
nvNodelist :: String
3037
nvNodelist = "nodelist"
3038

    
3039
nvNodenettest :: String
3040
nvNodenettest = "node-net-test"
3041

    
3042
nvNodesetup :: String
3043
nvNodesetup = "nodesetup"
3044

    
3045
nvOobPaths :: String
3046
nvOobPaths = "oob-paths"
3047

    
3048
nvOslist :: String
3049
nvOslist = "oslist"
3050

    
3051
nvPvlist :: String
3052
nvPvlist = "pvlist"
3053

    
3054
nvTime :: String
3055
nvTime = "time"
3056

    
3057
nvUserscripts :: String
3058
nvUserscripts = "user-scripts"
3059

    
3060
nvVersion :: String
3061
nvVersion = "version"
3062

    
3063
nvVglist :: String
3064
nvVglist = "vglist"
3065

    
3066
nvVmnodes :: String
3067
nvVmnodes = "vmnodes"
3068

    
3069
-- * Instance status
3070

    
3071
inststAdmindown :: String
3072
inststAdmindown = Types.instanceStatusToRaw StatusDown
3073

    
3074
inststAdminoffline :: String
3075
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3076

    
3077
inststErrordown :: String
3078
inststErrordown = Types.instanceStatusToRaw ErrorDown
3079

    
3080
inststErrorup :: String
3081
inststErrorup = Types.instanceStatusToRaw ErrorUp
3082

    
3083
inststNodedown :: String
3084
inststNodedown = Types.instanceStatusToRaw NodeDown
3085

    
3086
inststNodeoffline :: String
3087
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3088

    
3089
inststRunning :: String
3090
inststRunning = Types.instanceStatusToRaw Running
3091

    
3092
inststUserdown :: String
3093
inststUserdown = Types.instanceStatusToRaw UserDown
3094

    
3095
inststWrongnode :: String
3096
inststWrongnode = Types.instanceStatusToRaw WrongNode
3097

    
3098
inststAll :: FrozenSet String
3099
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3100

    
3101
-- * Admin states
3102

    
3103
adminstDown :: String
3104
adminstDown = Types.adminStateToRaw AdminDown
3105

    
3106
adminstOffline :: String
3107
adminstOffline = Types.adminStateToRaw AdminOffline
3108

    
3109
adminstUp :: String
3110
adminstUp = Types.adminStateToRaw AdminUp
3111

    
3112
adminstAll :: FrozenSet String
3113
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3114

    
3115
-- * Node roles
3116

    
3117
nrDrained :: String
3118
nrDrained = Types.nodeRoleToRaw NRDrained
3119

    
3120
nrMaster :: String
3121
nrMaster = Types.nodeRoleToRaw NRMaster
3122

    
3123
nrMcandidate :: String
3124
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3125

    
3126
nrOffline :: String
3127
nrOffline = Types.nodeRoleToRaw NROffline
3128

    
3129
nrRegular :: String
3130
nrRegular = Types.nodeRoleToRaw NRRegular
3131

    
3132
nrAll :: FrozenSet String
3133
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3134

    
3135
-- * SSL certificate check constants (in days)
3136

    
3137
sslCertExpirationError :: Int
3138
sslCertExpirationError = 7
3139

    
3140
sslCertExpirationWarn :: Int
3141
sslCertExpirationWarn = 30
3142

    
3143
-- * Allocator framework constants
3144

    
3145
iallocatorVersion :: Int
3146
iallocatorVersion = 2
3147

    
3148
iallocatorDirIn :: String
3149
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3150

    
3151
iallocatorDirOut :: String
3152
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3153

    
3154
validIallocatorDirections :: FrozenSet String
3155
validIallocatorDirections =
3156
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3157

    
3158
iallocatorModeAlloc :: String
3159
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3160

    
3161
iallocatorModeChgGroup :: String
3162
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3163

    
3164
iallocatorModeMultiAlloc :: String
3165
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3166

    
3167
iallocatorModeNodeEvac :: String
3168
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3169

    
3170
iallocatorModeReloc :: String
3171
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3172

    
3173
validIallocatorModes :: FrozenSet String
3174
validIallocatorModes =
3175
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3176

    
3177
iallocatorSearchPath :: [String]
3178
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3179

    
3180
defaultIallocatorShortcut :: String
3181
defaultIallocatorShortcut = "."
3182

    
3183
-- * Node evacuation
3184

    
3185
nodeEvacPri :: String
3186
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3187

    
3188
nodeEvacSec :: String
3189
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3190

    
3191
nodeEvacAll :: String
3192
nodeEvacAll = Types.evacModeToRaw ChangeAll
3193

    
3194
nodeEvacModes :: FrozenSet String
3195
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3196

    
3197
-- * Job queue
3198

    
3199
jobQueueVersion :: Int
3200
jobQueueVersion = 1
3201

    
3202
jobQueueSizeHardLimit :: Int
3203
jobQueueSizeHardLimit = 5000
3204

    
3205
jobQueueFilesPerms :: Int
3206
jobQueueFilesPerms = 0o640
3207

    
3208
-- * Unchanged job return
3209

    
3210
jobNotchanged :: String
3211
jobNotchanged = "nochange"
3212

    
3213
-- * Job status
3214

    
3215
jobStatusQueued :: String
3216
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3217

    
3218
jobStatusWaiting :: String
3219
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3220

    
3221
jobStatusCanceling :: String
3222
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3223

    
3224
jobStatusRunning :: String
3225
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3226

    
3227
jobStatusCanceled :: String
3228
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3229

    
3230
jobStatusSuccess :: String
3231
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3232

    
3233
jobStatusError :: String
3234
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3235

    
3236
jobsPending :: FrozenSet String
3237
jobsPending =
3238
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3239

    
3240
jobsFinalized :: FrozenSet String
3241
jobsFinalized =
3242
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3243

    
3244
jobStatusAll :: FrozenSet String
3245
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3246

    
3247
-- * OpCode status
3248

    
3249
-- ** Not yet finalized opcodes
3250

    
3251
opStatusCanceling :: String
3252
opStatusCanceling = "canceling"
3253

    
3254
opStatusQueued :: String
3255
opStatusQueued = "queued"
3256

    
3257
opStatusRunning :: String
3258
opStatusRunning = "running"
3259

    
3260
opStatusWaiting :: String
3261
opStatusWaiting = "waiting"
3262

    
3263
-- ** Finalized opcodes
3264

    
3265
opStatusCanceled :: String
3266
opStatusCanceled = "canceled"
3267

    
3268
opStatusError :: String
3269
opStatusError = "error"
3270

    
3271
opStatusSuccess :: String
3272
opStatusSuccess = "success"
3273

    
3274
opsFinalized :: FrozenSet String
3275
opsFinalized =
3276
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3277

    
3278
-- * OpCode priority
3279

    
3280
opPrioLowest :: Int
3281
opPrioLowest = 19
3282

    
3283
opPrioHighest :: Int
3284
opPrioHighest = -20
3285

    
3286
opPrioLow :: Int
3287
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3288

    
3289
opPrioNormal :: Int
3290
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3291

    
3292
opPrioHigh :: Int
3293
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3294

    
3295
opPrioSubmitValid :: FrozenSet Int
3296
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3297

    
3298
opPrioDefault :: Int
3299
opPrioDefault = opPrioNormal
3300

    
3301
-- * Lock recalculate mode
3302

    
3303
locksAppend :: String
3304
locksAppend = "append"
3305

    
3306
locksReplace :: String
3307
locksReplace = "replace"
3308

    
3309
-- * Lock timeout
3310
--
3311
-- The lock timeout (sum) before we transition into blocking acquire
3312
-- (this can still be reset by priority change).  Computed as max time
3313
-- (10 hours) before we should actually go into blocking acquire,
3314
-- given that we start from the default priority level.
3315

    
3316
lockAttemptsMaxwait :: Double
3317
lockAttemptsMaxwait = 15.0
3318

    
3319
lockAttemptsMinwait :: Double
3320
lockAttemptsMinwait = 1.0
3321

    
3322
lockAttemptsTimeout :: Int
3323
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3324

    
3325
-- * Execution log types
3326

    
3327
elogMessage :: String
3328
elogMessage = Types.eLogTypeToRaw ELogMessage
3329

    
3330
elogRemoteImport :: String
3331
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3332

    
3333
elogJqueueTest :: String
3334
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3335

    
3336
-- * /etc/hosts modification
3337

    
3338
etcHostsAdd :: String
3339
etcHostsAdd = "add"
3340

    
3341
etcHostsRemove :: String
3342
etcHostsRemove = "remove"
3343

    
3344
-- * Job queue test
3345

    
3346
jqtMsgprefix :: String
3347
jqtMsgprefix = "TESTMSG="
3348

    
3349
jqtExec :: String
3350
jqtExec = "exec"
3351

    
3352
jqtExpandnames :: String
3353
jqtExpandnames = "expandnames"
3354

    
3355
jqtLogmsg :: String
3356
jqtLogmsg = "logmsg"
3357

    
3358
jqtStartmsg :: String
3359
jqtStartmsg = "startmsg"
3360

    
3361
jqtAll :: FrozenSet String
3362
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3363

    
3364
-- * Query resources
3365

    
3366
qrCluster :: String
3367
qrCluster = "cluster"
3368

    
3369
qrExport :: String
3370
qrExport = "export"
3371

    
3372
qrExtstorage :: String
3373
qrExtstorage = "extstorage"
3374

    
3375
qrGroup :: String
3376
qrGroup = "group"
3377

    
3378
qrInstance :: String
3379
qrInstance = "instance"
3380

    
3381
qrJob :: String
3382
qrJob = "job"
3383

    
3384
qrLock :: String
3385
qrLock = "lock"
3386

    
3387
qrNetwork :: String
3388
qrNetwork = "network"
3389

    
3390
qrNode :: String
3391
qrNode = "node"
3392

    
3393
qrOs :: String
3394
qrOs = "os"
3395

    
3396
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3397
qrViaOp :: FrozenSet String
3398
qrViaOp =
3399
  ConstantUtils.mkSet [qrCluster,
3400
                       qrOs,
3401
                       qrExtstorage]
3402

    
3403
-- | List of resources which can be queried using Local UniX Interface
3404
qrViaLuxi :: FrozenSet String
3405
qrViaLuxi = ConstantUtils.mkSet [qrGroup,
3406
                                 qrExport,
3407
                                 qrInstance,
3408
                                 qrJob,
3409
                                 qrLock,
3410
                                 qrNetwork,
3411
                                 qrNode]
3412

    
3413
-- | List of resources which can be queried using RAPI
3414
qrViaRapi :: FrozenSet String
3415
qrViaRapi = qrViaLuxi
3416

    
3417
-- | List of resources which can be queried via RAPI including PUT requests
3418
qrViaRapiPut :: FrozenSet String
3419
qrViaRapiPut = ConstantUtils.mkSet [qrLock, qrJob]
3420

    
3421
-- * Query field types
3422

    
3423
qftBool :: String
3424
qftBool = "bool"
3425

    
3426
qftNumber :: String
3427
qftNumber = "number"
3428

    
3429
qftOther :: String
3430
qftOther = "other"
3431

    
3432
qftText :: String
3433
qftText = "text"
3434

    
3435
qftTimestamp :: String
3436
qftTimestamp = "timestamp"
3437

    
3438
qftUnit :: String
3439
qftUnit = "unit"
3440

    
3441
qftUnknown :: String
3442
qftUnknown = "unknown"
3443

    
3444
qftAll :: FrozenSet String
3445
qftAll =
3446
  ConstantUtils.mkSet [qftBool,
3447
                       qftNumber,
3448
                       qftOther,
3449
                       qftText,
3450
                       qftTimestamp,
3451
                       qftUnit,
3452
                       qftUnknown]
3453

    
3454
-- * Query result field status
3455
--
3456
-- Don't change or reuse values as they're used by clients.
3457
--
3458
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3459

    
3460
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3461
rsNodata :: Int
3462
rsNodata = 2
3463

    
3464
rsNormal :: Int
3465
rsNormal = 0
3466

    
3467
-- | Resource marked offline
3468
rsOffline :: Int
3469
rsOffline = 4
3470

    
3471
-- | Value unavailable/unsupported for item; if this field is
3472
-- supported but we cannot get the data for the moment, 'rsNodata' or
3473
-- 'rsOffline' should be used
3474
rsUnavail :: Int
3475
rsUnavail = 3
3476

    
3477
rsUnknown :: Int
3478
rsUnknown = 1
3479

    
3480
rsAll :: FrozenSet Int
3481
rsAll =
3482
  ConstantUtils.mkSet [rsNodata,
3483
                       rsNormal,
3484
                       rsOffline,
3485
                       rsUnavail,
3486
                       rsUnknown]
3487

    
3488
-- | Special field cases and their verbose/terse formatting
3489
rssDescription :: Map Int (String, String)
3490
rssDescription =
3491
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3492
                (rsNodata, ("(nodata)", "?")),
3493
                (rsOffline, ("(offline)", "*")),
3494
                (rsUnavail, ("(unavail)", "-"))]
3495

    
3496
-- * Max dynamic devices
3497

    
3498
maxDisks :: Int
3499
maxDisks = Types.maxDisks
3500

    
3501
maxNics :: Int
3502
maxNics = Types.maxNics
3503

    
3504
-- | SSCONF file prefix
3505
ssconfFileprefix :: String
3506
ssconfFileprefix = "ssconf_"
3507

    
3508
-- * SSCONF keys
3509

    
3510
ssClusterName :: String
3511
ssClusterName = "cluster_name"
3512

    
3513
ssClusterTags :: String
3514
ssClusterTags = "cluster_tags"
3515

    
3516
ssFileStorageDir :: String
3517
ssFileStorageDir = "file_storage_dir"
3518

    
3519
ssSharedFileStorageDir :: String
3520
ssSharedFileStorageDir = "shared_file_storage_dir"
3521

    
3522
ssGlusterStorageDir :: String
3523
ssGlusterStorageDir = "gluster_storage_dir"
3524

    
3525
ssMasterCandidates :: String
3526
ssMasterCandidates = "master_candidates"
3527

    
3528
ssMasterCandidatesIps :: String
3529
ssMasterCandidatesIps = "master_candidates_ips"
3530

    
3531
ssMasterCandidatesCerts :: String
3532
ssMasterCandidatesCerts = "master_candidates_certs"
3533

    
3534
ssMasterIp :: String
3535
ssMasterIp = "master_ip"
3536

    
3537
ssMasterNetdev :: String
3538
ssMasterNetdev = "master_netdev"
3539

    
3540
ssMasterNetmask :: String
3541
ssMasterNetmask = "master_netmask"
3542

    
3543
ssMasterNode :: String
3544
ssMasterNode = "master_node"
3545

    
3546
ssNodeList :: String
3547
ssNodeList = "node_list"
3548

    
3549
ssNodePrimaryIps :: String
3550
ssNodePrimaryIps = "node_primary_ips"
3551

    
3552
ssNodeSecondaryIps :: String
3553
ssNodeSecondaryIps = "node_secondary_ips"
3554

    
3555
ssOfflineNodes :: String
3556
ssOfflineNodes = "offline_nodes"
3557

    
3558
ssOnlineNodes :: String
3559
ssOnlineNodes = "online_nodes"
3560

    
3561
ssPrimaryIpFamily :: String
3562
ssPrimaryIpFamily = "primary_ip_family"
3563

    
3564
ssInstanceList :: String
3565
ssInstanceList = "instance_list"
3566

    
3567
ssReleaseVersion :: String
3568
ssReleaseVersion = "release_version"
3569

    
3570
ssHypervisorList :: String
3571
ssHypervisorList = "hypervisor_list"
3572

    
3573
ssMaintainNodeHealth :: String
3574
ssMaintainNodeHealth = "maintain_node_health"
3575

    
3576
ssUidPool :: String
3577
ssUidPool = "uid_pool"
3578

    
3579
ssNodegroups :: String
3580
ssNodegroups = "nodegroups"
3581

    
3582
ssNetworks :: String
3583
ssNetworks = "networks"
3584

    
3585
-- | This is not a complete SSCONF key, but the prefix for the
3586
-- hypervisor keys
3587
ssHvparamsPref :: String
3588
ssHvparamsPref = "hvparams_"
3589

    
3590
-- * Hvparams keys
3591

    
3592
ssHvparamsXenChroot :: String
3593
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3594

    
3595
ssHvparamsXenFake :: String
3596
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3597

    
3598
ssHvparamsXenHvm :: String
3599
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3600

    
3601
ssHvparamsXenKvm :: String
3602
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3603

    
3604
ssHvparamsXenLxc :: String
3605
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3606

    
3607
ssHvparamsXenPvm :: String
3608
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3609

    
3610
validSsHvparamsKeys :: FrozenSet String
3611
validSsHvparamsKeys =
3612
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3613
                       ssHvparamsXenLxc,
3614
                       ssHvparamsXenFake,
3615
                       ssHvparamsXenHvm,
3616
                       ssHvparamsXenKvm,
3617
                       ssHvparamsXenPvm]
3618

    
3619
ssFilePerms :: Int
3620
ssFilePerms = 0o444
3621

    
3622
-- | Cluster wide default parameters
3623
defaultEnabledHypervisor :: String
3624
defaultEnabledHypervisor = htXenPvm
3625

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

    
3738
hvcGlobals :: FrozenSet String
3739
hvcGlobals =
3740
  ConstantUtils.mkSet [hvMigrationBandwidth,
3741
                       hvMigrationMode,
3742
                       hvMigrationPort,
3743
                       hvXenCmd]
3744

    
3745
becDefaults :: Map String PyValueEx
3746
becDefaults =
3747
  Map.fromList
3748
  [ (beMinmem, PyValueEx (128 :: Int))
3749
  , (beMaxmem, PyValueEx (128 :: Int))
3750
  , (beVcpus, PyValueEx (1 :: Int))
3751
  , (beAutoBalance, PyValueEx True)
3752
  , (beAlwaysFailover, PyValueEx False)
3753
  , (beSpindleUse, PyValueEx (1 :: Int))
3754
  ]
3755

    
3756
ndcDefaults :: Map String PyValueEx
3757
ndcDefaults =
3758
  Map.fromList
3759
  [ (ndOobProgram,       PyValueEx "")
3760
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3761
  , (ndExclusiveStorage, PyValueEx False)
3762
  , (ndOvs,              PyValueEx False)
3763
  , (ndOvsName,          PyValueEx defaultOvs)
3764
  , (ndOvsLink,          PyValueEx "")
3765
  , (ndSshPort,          PyValueEx (22 :: Int))
3766
  ]
3767

    
3768
ndcGlobals :: FrozenSet String
3769
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3770

    
3771
-- | Default delay target measured in sectors
3772
defaultDelayTarget :: Int
3773
defaultDelayTarget = 1
3774

    
3775
defaultDiskCustom :: String
3776
defaultDiskCustom = ""
3777

    
3778
defaultDiskResync :: Bool
3779
defaultDiskResync = False
3780

    
3781
-- | Default fill target measured in sectors
3782
defaultFillTarget :: Int
3783
defaultFillTarget = 0
3784

    
3785
-- | Default mininum rate measured in KiB/s
3786
defaultMinRate :: Int
3787
defaultMinRate = 4 * 1024
3788

    
3789
defaultNetCustom :: String
3790
defaultNetCustom = ""
3791

    
3792
-- | Default plan ahead measured in sectors
3793
--
3794
-- The default values for the DRBD dynamic resync speed algorithm are
3795
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3796
-- (that we don't need to set to 0, because we have a separate option
3797
-- to enable it) and for c-max-rate, that we cap to the default value
3798
-- for the static resync rate.
3799
defaultPlanAhead :: Int
3800
defaultPlanAhead = 20
3801

    
3802
defaultRbdPool :: String
3803
defaultRbdPool = "rbd"
3804

    
3805
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3806
diskLdDefaults =
3807
  Map.fromList
3808
  [ (DTBlock, Map.empty)
3809
  , (DTDrbd8, Map.fromList
3810
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3811
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3812
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3813
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3814
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3815
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3816
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3817
              , (ldpMinRate,       PyValueEx defaultMinRate)
3818
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3819
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3820
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3821
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3822
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3823
              ])
3824
  , (DTExt, Map.empty)
3825
  , (DTFile, Map.empty)
3826
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3827
  , (DTRbd, Map.fromList
3828
            [ (ldpPool, PyValueEx defaultRbdPool)
3829
            , (ldpAccess, PyValueEx diskKernelspace)
3830
            ])
3831
  , (DTSharedFile, Map.empty)
3832
  , (DTGluster, Map.fromList
3833
                [ (rbdAccess, PyValueEx diskKernelspace)
3834
                , (glusterHost, PyValueEx glusterHostDefault)
3835
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3836
                , (glusterPort, PyValueEx glusterPortDefault)
3837
                ])
3838
  ]
3839

    
3840
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3841
diskDtDefaults =
3842
  Map.fromList
3843
  [ (DTBlock,      Map.empty)
3844
  , (DTDiskless,   Map.empty)
3845
  , (DTDrbd8,      Map.fromList
3846
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3847
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3848
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3849
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3850
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3851
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3852
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3853
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3854
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3855
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3856
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3857
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3858
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3859
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3860
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3861
                   ])
3862
  , (DTExt,        Map.empty)
3863
  , (DTFile,       Map.empty)
3864
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3865
  , (DTRbd,        Map.fromList
3866
                   [ (rbdPool, PyValueEx defaultRbdPool)
3867
                   , (rbdAccess, PyValueEx diskKernelspace)
3868
                   ])
3869
  , (DTSharedFile, Map.empty)
3870
  , (DTGluster, Map.fromList
3871
                [ (rbdAccess, PyValueEx diskKernelspace)
3872
                , (glusterHost, PyValueEx glusterHostDefault)
3873
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3874
                , (glusterPort, PyValueEx glusterPortDefault)
3875
                ])
3876
  ]
3877

    
3878
niccDefaults :: Map String PyValueEx
3879
niccDefaults =
3880
  Map.fromList
3881
  [ (nicMode, PyValueEx nicModeBridged)
3882
  , (nicLink, PyValueEx defaultBridge)
3883
  , (nicVlan, PyValueEx "")
3884
  ]
3885

    
3886
-- | All of the following values are quite arbitrary - there are no
3887
-- "good" defaults, these must be customised per-site
3888
ispecsMinmaxDefaults :: Map String (Map String Int)
3889
ispecsMinmaxDefaults =
3890
  Map.fromList
3891
  [(ispecsMin,
3892
    Map.fromList
3893
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3894
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3895
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3896
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3897
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3898
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3899
   (ispecsMax,
3900
    Map.fromList
3901
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3902
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3903
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3904
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3905
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3906
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3907

    
3908
ipolicyDefaults :: Map String PyValueEx
3909
ipolicyDefaults =
3910
  Map.fromList
3911
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3912
  , (ispecsStd,           PyValueEx (Map.fromList
3913
                                     [ (ispecMemSize,    128)
3914
                                     , (ispecCpuCount,   1)
3915
                                     , (ispecDiskCount,  1)
3916
                                     , (ispecDiskSize,   1024)
3917
                                     , (ispecNicCount,   1)
3918
                                     , (ispecSpindleUse, 1)
3919
                                     ] :: Map String Int))
3920
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3921
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3922
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3923
  ]
3924

    
3925
masterPoolSizeDefault :: Int
3926
masterPoolSizeDefault = 10
3927

    
3928
-- * Exclusive storage
3929

    
3930
-- | Error margin used to compare physical disks
3931
partMargin :: Double
3932
partMargin = 0.01
3933

    
3934
-- | Space reserved when creating instance disks
3935
partReserved :: Double
3936
partReserved = 0.02
3937

    
3938
-- * Luxid job scheduling
3939

    
3940
-- | Time intervall in seconds for polling updates on the job queue. This
3941
-- intervall is only relevant if the number of running jobs reaches the maximal
3942
-- allowed number, as otherwise new jobs will be started immediately anyway.
3943
-- Also, as jobs are watched via inotify, scheduling usually works independent
3944
-- of polling. Therefore we chose a sufficiently large interval, in the order of
3945
-- 5 minutes. As with the interval for reloading the configuration, we chose a
3946
-- prime number to avoid accidental 'same wakeup' with other processes.
3947
luxidJobqueuePollInterval :: Int
3948
luxidJobqueuePollInterval = 307
3949

    
3950
-- | Maximal number of jobs to be running at the same time. Once this number is
3951
-- reached, new jobs will just be queued and only started, once some of the
3952
-- other jobs have finished.
3953
luxidMaximalRunningJobs :: Int
3954
luxidMaximalRunningJobs = 20
3955

    
3956
-- * Confd
3957

    
3958
confdProtocolVersion :: Int
3959
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3960

    
3961
-- Confd request type
3962

    
3963
confdReqPing :: Int
3964
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3965

    
3966
confdReqNodeRoleByname :: Int
3967
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3968

    
3969
confdReqNodePipByInstanceIp :: Int
3970
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3971

    
3972
confdReqClusterMaster :: Int
3973
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3974

    
3975
confdReqNodePipList :: Int
3976
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3977

    
3978
confdReqMcPipList :: Int
3979
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3980

    
3981
confdReqInstancesIpsList :: Int
3982
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3983

    
3984
confdReqNodeDrbd :: Int
3985
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3986

    
3987
confdReqNodeInstances :: Int
3988
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3989

    
3990
confdReqs :: FrozenSet Int
3991
confdReqs =
3992
  ConstantUtils.mkSet .
3993
  map Types.confdRequestTypeToRaw $
3994
  [minBound..] \\ [ReqNodeInstances]
3995

    
3996
-- * Confd request type
3997

    
3998
confdReqfieldName :: Int
3999
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
4000

    
4001
confdReqfieldIp :: Int
4002
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
4003

    
4004
confdReqfieldMnodePip :: Int
4005
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
4006

    
4007
-- * Confd repl status
4008

    
4009
confdReplStatusOk :: Int
4010
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
4011

    
4012
confdReplStatusError :: Int
4013
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
4014

    
4015
confdReplStatusNotimplemented :: Int
4016
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
4017

    
4018
confdReplStatuses :: FrozenSet Int
4019
confdReplStatuses =
4020
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
4021

    
4022
-- * Confd node role
4023

    
4024
confdNodeRoleMaster :: Int
4025
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
4026

    
4027
confdNodeRoleCandidate :: Int
4028
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
4029

    
4030
confdNodeRoleOffline :: Int
4031
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
4032

    
4033
confdNodeRoleDrained :: Int
4034
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
4035

    
4036
confdNodeRoleRegular :: Int
4037
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
4038

    
4039
-- * A few common errors for confd
4040

    
4041
confdErrorUnknownEntry :: Int
4042
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
4043

    
4044
confdErrorInternal :: Int
4045
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
4046

    
4047
confdErrorArgument :: Int
4048
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
4049

    
4050
-- * Confd request query fields
4051

    
4052
confdReqqLink :: String
4053
confdReqqLink = ConstantUtils.confdReqqLink
4054

    
4055
confdReqqIp :: String
4056
confdReqqIp = ConstantUtils.confdReqqIp
4057

    
4058
confdReqqIplist :: String
4059
confdReqqIplist = ConstantUtils.confdReqqIplist
4060

    
4061
confdReqqFields :: String
4062
confdReqqFields = ConstantUtils.confdReqqFields
4063

    
4064
-- | Each request is "salted" by the current timestamp.
4065
--
4066
-- This constant decides how many seconds of skew to accept.
4067
--
4068
-- TODO: make this a default and allow the value to be more
4069
-- configurable
4070
confdMaxClockSkew :: Int
4071
confdMaxClockSkew = 2 * nodeMaxClockSkew
4072

    
4073
-- | When we haven't reloaded the config for more than this amount of
4074
-- seconds, we force a test to see if inotify is betraying us. Using a
4075
-- prime number to ensure we get less chance of 'same wakeup' with
4076
-- other processes.
4077
confdConfigReloadTimeout :: Int
4078
confdConfigReloadTimeout = 17
4079

    
4080
-- | If we receive more than one update in this amount of
4081
-- microseconds, we move to polling every RATELIMIT seconds, rather
4082
-- than relying on inotify, to be able to serve more requests.
4083
confdConfigReloadRatelimit :: Int
4084
confdConfigReloadRatelimit = 250000
4085

    
4086
-- | Magic number prepended to all confd queries.
4087
--
4088
-- This allows us to distinguish different types of confd protocols
4089
-- and handle them. For example by changing this we can move the whole
4090
-- payload to be compressed, or move away from json.
4091
confdMagicFourcc :: String
4092
confdMagicFourcc = "plj0"
4093

    
4094
-- | By default a confd request is sent to the minimum between this
4095
-- number and all MCs. 6 was chosen because even in the case of a
4096
-- disastrous 50% response rate, we should have enough answers to be
4097
-- able to compare more than one.
4098
confdDefaultReqCoverage :: Int
4099
confdDefaultReqCoverage = 6
4100

    
4101
-- | Timeout in seconds to expire pending query request in the confd
4102
-- client library. We don't actually expect any answer more than 10
4103
-- seconds after we sent a request.
4104
confdClientExpireTimeout :: Int
4105
confdClientExpireTimeout = 10
4106

    
4107
-- | Maximum UDP datagram size.
4108
--
4109
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4110
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4111
--   (assuming we can't use jumbo frames)
4112
-- We just set this to 60K, which should be enough
4113
maxUdpDataSize :: Int
4114
maxUdpDataSize = 61440
4115

    
4116
-- * User-id pool minimum/maximum acceptable user-ids
4117

    
4118
uidpoolUidMin :: Int
4119
uidpoolUidMin = 0
4120

    
4121
-- | Assuming 32 bit user-ids
4122
uidpoolUidMax :: Integer
4123
uidpoolUidMax = 2 ^ 32 - 1
4124

    
4125
-- | Name or path of the pgrep command
4126
pgrep :: String
4127
pgrep = "pgrep"
4128

    
4129
-- | Name of the node group that gets created at cluster init or
4130
-- upgrade
4131
initialNodeGroupName :: String
4132
initialNodeGroupName = "default"
4133

    
4134
-- * Possible values for NodeGroup.alloc_policy
4135

    
4136
allocPolicyLastResort :: String
4137
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4138

    
4139
allocPolicyPreferred :: String
4140
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4141

    
4142
allocPolicyUnallocable :: String
4143
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4144

    
4145
validAllocPolicies :: [String]
4146
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4147

    
4148
-- | Temporary external/shared storage parameters
4149
blockdevDriverManual :: String
4150
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4151

    
4152
-- | 'qemu-img' path, required for 'ovfconverter'
4153
qemuimgPath :: String
4154
qemuimgPath = AutoConf.qemuimgPath
4155

    
4156
-- | Whether htools was enabled at compilation time
4157
--
4158
-- FIXME: this should be moved next to the other enable constants,
4159
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4160
htools :: Bool
4161
htools = AutoConf.htools
4162

    
4163
-- | The hail iallocator
4164
iallocHail :: String
4165
iallocHail = "hail"
4166

    
4167
-- * Fake opcodes for functions that have hooks attached to them via
4168
-- backend.RunLocalHooks
4169

    
4170
fakeOpMasterTurndown :: String
4171
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4172

    
4173
fakeOpMasterTurnup :: String
4174
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4175

    
4176

    
4177
-- * Crypto Types
4178
-- Types of cryptographic tokens used in node communication
4179

    
4180
cryptoTypeSslDigest :: String
4181
cryptoTypeSslDigest = "ssl"
4182

    
4183
cryptoTypeSsh :: String
4184
cryptoTypeSsh = "ssh"
4185

    
4186
-- So far only ssl keys are used in the context of this constant
4187
cryptoTypes :: FrozenSet String
4188
cryptoTypes = ConstantUtils.mkSet [cryptoTypeSslDigest]
4189

    
4190
-- * Crypto Actions
4191
-- Actions that can be performed on crypto tokens
4192

    
4193
cryptoActionGet :: String
4194
cryptoActionGet = "get"
4195

    
4196
-- This is 'create and get'
4197
cryptoActionCreate :: String
4198
cryptoActionCreate = "create"
4199

    
4200
cryptoActions :: FrozenSet String
4201
cryptoActions = ConstantUtils.mkSet [cryptoActionGet, cryptoActionCreate]
4202

    
4203
-- * Options for CryptoActions
4204

    
4205
-- Filename of the certificate
4206
cryptoOptionCertFile :: String
4207
cryptoOptionCertFile = "cert_file"
4208

    
4209
-- * SSH key types
4210

    
4211
sshkDsa :: String
4212
sshkDsa = "dsa"
4213

    
4214
sshkRsa :: String
4215
sshkRsa = "rsa"
4216

    
4217
sshkAll :: FrozenSet String
4218
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4219

    
4220
-- * SSH authorized key types
4221

    
4222
sshakDss :: String
4223
sshakDss = "ssh-dss"
4224

    
4225
sshakRsa :: String
4226
sshakRsa = "ssh-rsa"
4227

    
4228
sshakAll :: FrozenSet String
4229
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4230

    
4231
-- * SSH setup
4232

    
4233
sshsClusterName :: String
4234
sshsClusterName = "cluster_name"
4235

    
4236
sshsSshHostKey :: String
4237
sshsSshHostKey = "ssh_host_key"
4238

    
4239
sshsSshRootKey :: String
4240
sshsSshRootKey = "ssh_root_key"
4241

    
4242
sshsNodeDaemonCertificate :: String
4243
sshsNodeDaemonCertificate = "node_daemon_certificate"
4244

    
4245
-- * Key files for SSH daemon
4246

    
4247
sshHostDsaPriv :: String
4248
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4249

    
4250
sshHostDsaPub :: String
4251
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4252

    
4253
sshHostRsaPriv :: String
4254
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4255

    
4256
sshHostRsaPub :: String
4257
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4258

    
4259
sshDaemonKeyfiles :: Map String (String, String)
4260
sshDaemonKeyfiles =
4261
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4262
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4263
               ]
4264

    
4265
-- * Node daemon setup
4266

    
4267
ndsClusterName :: String
4268
ndsClusterName = "cluster_name"
4269

    
4270
ndsNodeDaemonCertificate :: String
4271
ndsNodeDaemonCertificate = "node_daemon_certificate"
4272

    
4273
ndsSsconf :: String
4274
ndsSsconf = "ssconf"
4275

    
4276
ndsStartNodeDaemon :: String
4277
ndsStartNodeDaemon = "start_node_daemon"
4278

    
4279
-- * The source reasons for the execution of an OpCode
4280

    
4281
opcodeReasonSrcClient :: String
4282
opcodeReasonSrcClient = "gnt:client"
4283

    
4284
opcodeReasonSrcNoded :: String
4285
opcodeReasonSrcNoded = "gnt:daemon:noded"
4286

    
4287
opcodeReasonSrcOpcode :: String
4288
opcodeReasonSrcOpcode = "gnt:opcode"
4289

    
4290
opcodeReasonSrcRlib2 :: String
4291
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4292

    
4293
opcodeReasonSrcUser :: String
4294
opcodeReasonSrcUser = "gnt:user"
4295

    
4296
opcodeReasonSources :: FrozenSet String
4297
opcodeReasonSources =
4298
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4299
                       opcodeReasonSrcNoded,
4300
                       opcodeReasonSrcOpcode,
4301
                       opcodeReasonSrcRlib2,
4302
                       opcodeReasonSrcUser]
4303

    
4304
-- | Path generating random UUID
4305
randomUuidFile :: String
4306
randomUuidFile = ConstantUtils.randomUuidFile
4307

    
4308
-- * Auto-repair tag prefixes
4309

    
4310
autoRepairTagPrefix :: String
4311
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4312

    
4313
autoRepairTagEnabled :: String
4314
autoRepairTagEnabled = autoRepairTagPrefix
4315

    
4316
autoRepairTagPending :: String
4317
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4318

    
4319
autoRepairTagResult :: String
4320
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4321

    
4322
autoRepairTagSuspended :: String
4323
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4324

    
4325
-- * Auto-repair levels
4326

    
4327
autoRepairFailover :: String
4328
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4329

    
4330
autoRepairFixStorage :: String
4331
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4332

    
4333
autoRepairMigrate :: String
4334
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4335

    
4336
autoRepairReinstall :: String
4337
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4338

    
4339
autoRepairAllTypes :: FrozenSet String
4340
autoRepairAllTypes =
4341
  ConstantUtils.mkSet [autoRepairFailover,
4342
                       autoRepairFixStorage,
4343
                       autoRepairMigrate,
4344
                       autoRepairReinstall]
4345

    
4346
-- * Auto-repair results
4347

    
4348
autoRepairEnoperm :: String
4349
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4350

    
4351
autoRepairFailure :: String
4352
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4353

    
4354
autoRepairSuccess :: String
4355
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4356

    
4357
autoRepairAllResults :: FrozenSet String
4358
autoRepairAllResults =
4359
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4360

    
4361
-- | The version identifier for builtin data collectors
4362
builtinDataCollectorVersion :: String
4363
builtinDataCollectorVersion = "B"
4364

    
4365
-- | The reason trail opcode parameter name
4366
opcodeReason :: String
4367
opcodeReason = "reason"
4368

    
4369
diskstatsFile :: String
4370
diskstatsFile = "/proc/diskstats"
4371

    
4372
-- *  CPU load collector
4373

    
4374
statFile :: String
4375
statFile = "/proc/stat"
4376

    
4377
cpuavgloadBufferSize :: Int
4378
cpuavgloadBufferSize = 150
4379

    
4380
cpuavgloadWindowSize :: Int
4381
cpuavgloadWindowSize = 600
4382

    
4383
-- * Monitoring daemon
4384

    
4385
-- | Mond's variable for periodical data collection
4386
mondTimeInterval :: Int
4387
mondTimeInterval = 5
4388

    
4389
-- | Mond's latest API version
4390
mondLatestApiVersion :: Int
4391
mondLatestApiVersion = 1
4392

    
4393
-- * Disk access modes
4394

    
4395
diskUserspace :: String
4396
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4397

    
4398
diskKernelspace :: String
4399
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4400

    
4401
diskValidAccessModes :: FrozenSet String
4402
diskValidAccessModes =
4403
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4404

    
4405
-- | Timeout for queue draining in upgrades
4406
upgradeQueueDrainTimeout :: Int
4407
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4408

    
4409
-- | Intervall at which the queue is polled during upgrades
4410
upgradeQueuePollInterval :: Int
4411
upgradeQueuePollInterval  = 10
4412

    
4413
-- * Hotplug Actions
4414

    
4415
hotplugActionAdd :: String
4416
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4417

    
4418
hotplugActionRemove :: String
4419
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4420

    
4421
hotplugActionModify :: String
4422
hotplugActionModify = Types.hotplugActionToRaw HAMod
4423

    
4424
hotplugAllActions :: FrozenSet String
4425
hotplugAllActions =
4426
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4427

    
4428
-- * Hotplug Device Targets
4429

    
4430
hotplugTargetNic :: String
4431
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4432

    
4433
hotplugTargetDisk :: String
4434
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4435

    
4436
hotplugAllTargets :: FrozenSet String
4437
hotplugAllTargets =
4438
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4439

    
4440
-- | Timeout for disk removal (seconds)
4441
diskRemoveRetryTimeout :: Int
4442
diskRemoveRetryTimeout = 30
4443

    
4444
-- | Interval between disk removal retries (seconds)
4445
diskRemoveRetryInterval :: Int
4446
diskRemoveRetryInterval  = 3
4447

    
4448
-- * UUID regex
4449

    
4450
uuidRegex :: String
4451
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4452

    
4453
-- * Luxi constants
4454

    
4455
luxiSocketPerms :: Int
4456
luxiSocketPerms = 0o660
4457

    
4458
luxiKeyMethod :: String
4459
luxiKeyMethod = "method"
4460

    
4461
luxiKeyArgs :: String
4462
luxiKeyArgs = "args"
4463

    
4464
luxiKeySuccess :: String
4465
luxiKeySuccess = "success"
4466

    
4467
luxiKeyResult :: String
4468
luxiKeyResult = "result"
4469

    
4470
luxiKeyVersion :: String
4471
luxiKeyVersion = "version"
4472

    
4473
luxiReqSubmitJob :: String
4474
luxiReqSubmitJob = "SubmitJob"
4475

    
4476
luxiReqSubmitJobToDrainedQueue :: String
4477
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4478

    
4479
luxiReqSubmitManyJobs :: String
4480
luxiReqSubmitManyJobs = "SubmitManyJobs"
4481

    
4482
luxiReqWaitForJobChange :: String
4483
luxiReqWaitForJobChange = "WaitForJobChange"
4484

    
4485
luxiReqPickupJob :: String
4486
luxiReqPickupJob = "PickupJob"
4487

    
4488
luxiReqCancelJob :: String
4489
luxiReqCancelJob = "CancelJob"
4490

    
4491
luxiReqArchiveJob :: String
4492
luxiReqArchiveJob = "ArchiveJob"
4493

    
4494
luxiReqChangeJobPriority :: String
4495
luxiReqChangeJobPriority = "ChangeJobPriority"
4496

    
4497
luxiReqAutoArchiveJobs :: String
4498
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4499

    
4500
luxiReqQuery :: String
4501
luxiReqQuery = "Query"
4502

    
4503
luxiReqQueryFields :: String
4504
luxiReqQueryFields = "QueryFields"
4505

    
4506
luxiReqQueryJobs :: String
4507
luxiReqQueryJobs = "QueryJobs"
4508

    
4509
luxiReqQueryInstances :: String
4510
luxiReqQueryInstances = "QueryInstances"
4511

    
4512
luxiReqQueryNodes :: String
4513
luxiReqQueryNodes = "QueryNodes"
4514

    
4515
luxiReqQueryGroups :: String
4516
luxiReqQueryGroups = "QueryGroups"
4517

    
4518
luxiReqQueryNetworks :: String
4519
luxiReqQueryNetworks = "QueryNetworks"
4520

    
4521
luxiReqQueryExports :: String
4522
luxiReqQueryExports = "QueryExports"
4523

    
4524
luxiReqQueryConfigValues :: String
4525
luxiReqQueryConfigValues = "QueryConfigValues"
4526

    
4527
luxiReqQueryClusterInfo :: String
4528
luxiReqQueryClusterInfo = "QueryClusterInfo"
4529

    
4530
luxiReqQueryTags :: String
4531
luxiReqQueryTags = "QueryTags"
4532

    
4533
luxiReqSetDrainFlag :: String
4534
luxiReqSetDrainFlag = "SetDrainFlag"
4535

    
4536
luxiReqSetWatcherPause :: String
4537
luxiReqSetWatcherPause = "SetWatcherPause"
4538

    
4539
luxiReqAll :: FrozenSet String
4540
luxiReqAll =
4541
  ConstantUtils.mkSet
4542
  [ luxiReqArchiveJob
4543
  , luxiReqAutoArchiveJobs
4544
  , luxiReqCancelJob
4545
  , luxiReqChangeJobPriority
4546
  , luxiReqQuery
4547
  , luxiReqQueryClusterInfo
4548
  , luxiReqQueryConfigValues
4549
  , luxiReqQueryExports
4550
  , luxiReqQueryFields
4551
  , luxiReqQueryGroups
4552
  , luxiReqQueryInstances
4553
  , luxiReqQueryJobs
4554
  , luxiReqQueryNodes
4555
  , luxiReqQueryNetworks
4556
  , luxiReqQueryTags
4557
  , luxiReqSetDrainFlag
4558
  , luxiReqSetWatcherPause
4559
  , luxiReqSubmitJob
4560
  , luxiReqSubmitJobToDrainedQueue
4561
  , luxiReqSubmitManyJobs
4562
  , luxiReqWaitForJobChange
4563
  , luxiReqPickupJob
4564
  ]
4565

    
4566
luxiDefCtmo :: Int
4567
luxiDefCtmo = 10
4568

    
4569
luxiDefRwto :: Int
4570
luxiDefRwto = 60
4571

    
4572
-- | 'WaitForJobChange' timeout
4573
luxiWfjcTimeout :: Int
4574
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4575

    
4576
-- * Query language constants
4577

    
4578
-- ** Logic operators with one or more operands, each of which is a
4579
-- filter on its own
4580

    
4581
qlangOpAnd :: String
4582
qlangOpAnd = "&"
4583

    
4584
qlangOpOr :: String
4585
qlangOpOr = "|"
4586

    
4587
-- ** Unary operators with exactly one operand
4588

    
4589
qlangOpNot :: String
4590
qlangOpNot = "!"
4591

    
4592
qlangOpTrue :: String
4593
qlangOpTrue = "?"
4594

    
4595
-- ** Binary operators with exactly two operands, the field name and
4596
-- an operator-specific value
4597

    
4598
qlangOpContains :: String
4599
qlangOpContains = "=[]"
4600

    
4601
qlangOpEqual :: String
4602
qlangOpEqual = "="
4603

    
4604
qlangOpGe :: String
4605
qlangOpGe = ">="
4606

    
4607
qlangOpGt :: String
4608
qlangOpGt = ">"
4609

    
4610
qlangOpLe :: String
4611
qlangOpLe = "<="
4612

    
4613
qlangOpLt :: String
4614
qlangOpLt = "<"
4615

    
4616
qlangOpNotEqual :: String
4617
qlangOpNotEqual = "!="
4618

    
4619
qlangOpRegexp :: String
4620
qlangOpRegexp = "=~"
4621

    
4622
-- | Characters used for detecting user-written filters (see
4623
-- L{_CheckFilter})
4624

    
4625
qlangFilterDetectionChars :: FrozenSet String
4626
qlangFilterDetectionChars =
4627
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4628
                       ")", "(", "\x0b", "\n",
4629
                       "\r", "\x0c", "/", "<",
4630
                       "\t", ">", "=", "\\", "~"]
4631

    
4632
-- | Characters used to detect globbing filters
4633
qlangGlobDetectionChars :: FrozenSet String
4634
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4635

    
4636
-- * Error related constants
4637
--
4638
-- 'OpPrereqError' failure types
4639

    
4640
-- | Environment error (e.g. node disk error)
4641
errorsEcodeEnviron :: String
4642
errorsEcodeEnviron = "environment_error"
4643

    
4644
-- | Entity already exists
4645
errorsEcodeExists :: String
4646
errorsEcodeExists = "already_exists"
4647

    
4648
-- | Internal cluster error
4649
errorsEcodeFault :: String
4650
errorsEcodeFault = "internal_error"
4651

    
4652
-- | Wrong arguments (at syntax level)
4653
errorsEcodeInval :: String
4654
errorsEcodeInval = "wrong_input"
4655

    
4656
-- | Entity not found
4657
errorsEcodeNoent :: String
4658
errorsEcodeNoent = "unknown_entity"
4659

    
4660
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4661
errorsEcodeNores :: String
4662
errorsEcodeNores = "insufficient_resources"
4663

    
4664
-- | Resource not unique (e.g. MAC or IP duplication)
4665
errorsEcodeNotunique :: String
4666
errorsEcodeNotunique = "resource_not_unique"
4667

    
4668
-- | Resolver errors
4669
errorsEcodeResolver :: String
4670
errorsEcodeResolver = "resolver_error"
4671

    
4672
-- | Wrong entity state
4673
errorsEcodeState :: String
4674
errorsEcodeState = "wrong_state"
4675

    
4676
-- | Temporarily out of resources; operation can be tried again
4677
errorsEcodeTempNores :: String
4678
errorsEcodeTempNores = "temp_insufficient_resources"
4679

    
4680
errorsEcodeAll :: FrozenSet String
4681
errorsEcodeAll =
4682
  ConstantUtils.mkSet [ errorsEcodeNores
4683
                      , errorsEcodeExists
4684
                      , errorsEcodeState
4685
                      , errorsEcodeNotunique
4686
                      , errorsEcodeTempNores
4687
                      , errorsEcodeNoent
4688
                      , errorsEcodeFault
4689
                      , errorsEcodeResolver
4690
                      , errorsEcodeInval
4691
                      , errorsEcodeEnviron
4692
                      ]
4693

    
4694
-- * Jstore related constants
4695

    
4696
jstoreJobsPerArchiveDirectory :: Int
4697
jstoreJobsPerArchiveDirectory = 10000
4698

    
4699
-- * Gluster settings
4700

    
4701
-- | Name of the Gluster host setting
4702
glusterHost :: String
4703
glusterHost = "host"
4704

    
4705
-- | Default value of the Gluster host setting
4706
glusterHostDefault :: String
4707
glusterHostDefault = "127.0.0.1"
4708

    
4709
-- | Name of the Gluster volume setting
4710
glusterVolume :: String
4711
glusterVolume = "volume"
4712

    
4713
-- | Default value of the Gluster volume setting
4714
glusterVolumeDefault :: String
4715
glusterVolumeDefault = "gv0"
4716

    
4717
-- | Name of the Gluster port setting
4718
glusterPort :: String
4719
glusterPort = "port"
4720

    
4721
-- | Default value of the Gluster port setting
4722
glusterPortDefault :: Int
4723
glusterPortDefault = 24007