Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 81c717cd

History | View | Annotate | Download (119.8 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
metadUser :: String
204
metadUser = Runtime.daemonUser GanetiMetad
205

    
206
metadGroup :: String
207
metadGroup = Runtime.daemonGroup (DaemonGroup GanetiMetad)
208

    
209
rapiUser :: String
210
rapiUser = Runtime.daemonUser GanetiRapi
211

    
212
rapiGroup :: String
213
rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
214

    
215
confdUser :: String
216
confdUser = Runtime.daemonUser GanetiConfd
217

    
218
confdGroup :: String
219
confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
220

    
221
kvmdUser :: String
222
kvmdUser = Runtime.daemonUser GanetiKvmd
223

    
224
kvmdGroup :: String
225
kvmdGroup = Runtime.daemonGroup (DaemonGroup GanetiKvmd)
226

    
227
luxidUser :: String
228
luxidUser = Runtime.daemonUser GanetiLuxid
229

    
230
luxidGroup :: String
231
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
232

    
233
nodedUser :: String
234
nodedUser = Runtime.daemonUser GanetiNoded
235

    
236
nodedGroup :: String
237
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
238

    
239
mondUser :: String
240
mondUser = Runtime.daemonUser GanetiMond
241

    
242
mondGroup :: String
243
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
244

    
245
sshLoginUser :: String
246
sshLoginUser = AutoConf.sshLoginUser
247

    
248
sshConsoleUser :: String
249
sshConsoleUser = AutoConf.sshConsoleUser
250

    
251
-- * Cpu pinning separators and constants
252

    
253
cpuPinningSep :: String
254
cpuPinningSep = ":"
255

    
256
cpuPinningAll :: String
257
cpuPinningAll = "all"
258

    
259
-- | Internal representation of "all"
260
cpuPinningAllVal :: Int
261
cpuPinningAllVal = -1
262

    
263
-- | One "all" entry in a CPU list means CPU pinning is off
264
cpuPinningOff :: [Int]
265
cpuPinningOff = [cpuPinningAllVal]
266

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

    
283
-- | A KVM-specific implementation detail - the following value is
284
-- used to set CPU affinity to all processors (--0 through --31), per
285
-- taskset man page.
286
--
287
-- FIXME: This only works for machines with up to 32 CPU cores
288
cpuPinningAllKvm :: Int
289
cpuPinningAllKvm = 0xFFFFFFFF
290

    
291
-- * Wipe
292

    
293
ddCmd :: String
294
ddCmd = "dd"
295

    
296
-- | 1GB
297
maxWipeChunk :: Int
298
maxWipeChunk = 1024
299

    
300
minWipeChunkPercent :: Int
301
minWipeChunkPercent = 10
302

    
303
-- * Directories
304

    
305
runDirsMode :: Int
306
runDirsMode = 0o775
307

    
308
secureDirMode :: Int
309
secureDirMode = 0o700
310

    
311
secureFileMode :: Int
312
secureFileMode = 0o600
313

    
314
adoptableBlockdevRoot :: String
315
adoptableBlockdevRoot = "/dev/disk/"
316

    
317
-- * 'autoconf' enable/disable
318

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

    
322
enableMond :: Bool
323
enableMond = AutoConf.enableMond
324

    
325
enableRestrictedCommands :: Bool
326
enableRestrictedCommands = AutoConf.enableRestrictedCommands
327

    
328
-- * SSH constants
329

    
330
ssh :: String
331
ssh = "ssh"
332

    
333
scp :: String
334
scp = "scp"
335

    
336
-- * Daemons
337

    
338
confd :: String
339
confd = Runtime.daemonName GanetiConfd
340

    
341
masterd :: String
342
masterd = Runtime.daemonName GanetiMasterd
343

    
344
metad :: String
345
metad = Runtime.daemonName GanetiMetad
346

    
347
mond :: String
348
mond = Runtime.daemonName GanetiMond
349

    
350
noded :: String
351
noded = Runtime.daemonName GanetiNoded
352

    
353
luxid :: String
354
luxid = Runtime.daemonName GanetiLuxid
355

    
356
rapi :: String
357
rapi = Runtime.daemonName GanetiRapi
358

    
359
kvmd :: String
360
kvmd = Runtime.daemonName GanetiKvmd
361

    
362
daemons :: FrozenSet String
363
daemons =
364
  ConstantUtils.mkSet [confd,
365
                       luxid,
366
                       masterd,
367
                       mond,
368
                       noded,
369
                       rapi]
370

    
371
defaultConfdPort :: Int
372
defaultConfdPort = 1814
373

    
374
defaultMondPort :: Int
375
defaultMondPort = 1815
376

    
377
defaultMetadPort :: Int
378
defaultMetadPort = 8080
379

    
380
defaultNodedPort :: Int
381
defaultNodedPort = 1811
382

    
383
defaultRapiPort :: Int
384
defaultRapiPort = 5080
385

    
386
daemonsPorts :: Map String (Protocol, Int)
387
daemonsPorts =
388
  Map.fromList
389
  [ (confd, (Udp, defaultConfdPort))
390
  , (metad, (Tcp, defaultMetadPort))
391
  , (mond, (Tcp, defaultMondPort))
392
  , (noded, (Tcp, defaultNodedPort))
393
  , (rapi, (Tcp, defaultRapiPort))
394
  , (ssh, (Tcp, 22))
395
  ]
396

    
397
firstDrbdPort :: Int
398
firstDrbdPort = 11000
399

    
400
lastDrbdPort :: Int
401
lastDrbdPort = 14999
402

    
403
daemonsLogbase :: Map String String
404
daemonsLogbase =
405
  Map.fromList
406
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
407

    
408
daemonsExtraLogbase :: Map String (Map String String)
409
daemonsExtraLogbase =
410
  Map.fromList $
411
  map (Runtime.daemonName *** id)
412
  [ (GanetiMond, Map.fromList
413
                 [ ("access", Runtime.daemonsExtraLogbase GanetiMond AccessLog)
414
                 , ("error", Runtime.daemonsExtraLogbase GanetiMond ErrorLog)
415
                 ])
416
  ]
417

    
418
extraLogreasonAccess :: String
419
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
420

    
421
extraLogreasonError :: String
422
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
423

    
424
devConsole :: String
425
devConsole = ConstantUtils.devConsole
426

    
427
procMounts :: String
428
procMounts = "/proc/mounts"
429

    
430
-- * Luxi (Local UniX Interface) related constants
431

    
432
luxiEom :: PythonChar
433
luxiEom = PythonChar '\x03'
434

    
435
-- | Environment variable for the luxi override socket
436
luxiOverride :: String
437
luxiOverride = "FORCE_LUXI_SOCKET"
438

    
439
luxiOverrideMaster :: String
440
luxiOverrideMaster = "master"
441

    
442
luxiOverrideQuery :: String
443
luxiOverrideQuery = "query"
444

    
445
luxiVersion :: Int
446
luxiVersion = configVersion
447

    
448
-- * Syslog
449

    
450
syslogUsage :: String
451
syslogUsage = AutoConf.syslogUsage
452

    
453
syslogNo :: String
454
syslogNo = Logging.syslogUsageToRaw SyslogNo
455

    
456
syslogYes :: String
457
syslogYes = Logging.syslogUsageToRaw SyslogYes
458

    
459
syslogOnly :: String
460
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
461

    
462
syslogSocket :: String
463
syslogSocket = "/dev/log"
464

    
465
exportConfFile :: String
466
exportConfFile = "config.ini"
467

    
468
-- * Xen
469

    
470
xenBootloader :: String
471
xenBootloader = AutoConf.xenBootloader
472

    
473
xenCmdXl :: String
474
xenCmdXl = "xl"
475

    
476
xenCmdXm :: String
477
xenCmdXm = "xm"
478

    
479
xenInitrd :: String
480
xenInitrd = AutoConf.xenInitrd
481

    
482
xenKernel :: String
483
xenKernel = AutoConf.xenKernel
484

    
485
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
486
-- other constants
487
knownXenCommands :: FrozenSet String
488
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
489

    
490
-- * KVM and socat
491

    
492
kvmPath :: String
493
kvmPath = AutoConf.kvmPath
494

    
495
kvmKernel :: String
496
kvmKernel = AutoConf.kvmKernel
497

    
498
socatEscapeCode :: String
499
socatEscapeCode = "0x1d"
500

    
501
socatPath :: String
502
socatPath = AutoConf.socatPath
503

    
504
socatUseCompress :: Bool
505
socatUseCompress = AutoConf.socatUseCompress
506

    
507
socatUseEscape :: Bool
508
socatUseEscape = AutoConf.socatUseEscape
509

    
510
-- * Console types
511

    
512
-- | Display a message for console access
513
consMessage :: String
514
consMessage = "msg"
515

    
516
-- | Console as SPICE server
517
consSpice :: String
518
consSpice = "spice"
519

    
520
-- | Console as SSH command
521
consSsh :: String
522
consSsh = "ssh"
523

    
524
-- | Console as VNC server
525
consVnc :: String
526
consVnc = "vnc"
527

    
528
consAll :: FrozenSet String
529
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
530

    
531
-- | RSA key bit length
532
--
533
-- For RSA keys more bits are better, but they also make operations
534
-- more expensive. NIST SP 800-131 recommends a minimum of 2048 bits
535
-- from the year 2010 on.
536
rsaKeyBits :: Int
537
rsaKeyBits = 2048
538

    
539
-- | Ciphers allowed for SSL connections.
540
--
541
-- For the format, see ciphers(1). A better way to disable ciphers
542
-- would be to use the exclamation mark (!), but socat versions below
543
-- 1.5 can't parse exclamation marks in options properly. When
544
-- modifying the ciphers, ensure not to accidentially add something
545
-- after it's been removed. Use the "openssl" utility to check the
546
-- allowed ciphers, e.g.  "openssl ciphers -v HIGH:-DES".
547
opensslCiphers :: String
548
opensslCiphers = "HIGH:-DES:-3DES:-EXPORT:-ADH"
549

    
550
-- * X509
551

    
552
-- | commonName (CN) used in certificates
553
x509CertCn :: String
554
x509CertCn = "ganeti.example.com"
555

    
556
-- | Default validity of certificates in days
557
x509CertDefaultValidity :: Int
558
x509CertDefaultValidity = 365 * 5
559

    
560
x509CertSignatureHeader :: String
561
x509CertSignatureHeader = "X-Ganeti-Signature"
562

    
563
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
564
x509CertSignDigest :: String
565
x509CertSignDigest = "SHA1"
566

    
567
-- * Import/export daemon mode
568

    
569
iemExport :: String
570
iemExport = "export"
571

    
572
iemImport :: String
573
iemImport = "import"
574

    
575
-- * Import/export transport compression
576

    
577
iecGzip :: String
578
iecGzip = "gzip"
579

    
580
iecNone :: String
581
iecNone = "none"
582

    
583
iecAll :: [String]
584
iecAll = [iecGzip, iecNone]
585

    
586
ieCustomSize :: String
587
ieCustomSize = "fd"
588

    
589
-- * Import/export I/O
590

    
591
-- | Direct file I/O, equivalent to a shell's I/O redirection using
592
-- '<' or '>'
593
ieioFile :: String
594
ieioFile = "file"
595

    
596
-- | Raw block device I/O using "dd"
597
ieioRawDisk :: String
598
ieioRawDisk = "raw"
599

    
600
-- | OS definition import/export script
601
ieioScript :: String
602
ieioScript = "script"
603

    
604
-- * Values
605

    
606
valueDefault :: String
607
valueDefault = "default"
608

    
609
valueAuto :: String
610
valueAuto = "auto"
611

    
612
valueGenerate :: String
613
valueGenerate = "generate"
614

    
615
valueNone :: String
616
valueNone = "none"
617

    
618
valueTrue :: String
619
valueTrue = "true"
620

    
621
valueFalse :: String
622
valueFalse = "false"
623

    
624
-- * Hooks
625

    
626
hooksNameCfgupdate :: String
627
hooksNameCfgupdate = "config-update"
628

    
629
hooksNameWatcher :: String
630
hooksNameWatcher = "watcher"
631

    
632
hooksPath :: String
633
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
634

    
635
hooksPhasePost :: String
636
hooksPhasePost = "post"
637

    
638
hooksPhasePre :: String
639
hooksPhasePre = "pre"
640

    
641
hooksVersion :: Int
642
hooksVersion = 2
643

    
644
-- * Hooks subject type (what object type does the LU deal with)
645

    
646
htypeCluster :: String
647
htypeCluster = "CLUSTER"
648

    
649
htypeGroup :: String
650
htypeGroup = "GROUP"
651

    
652
htypeInstance :: String
653
htypeInstance = "INSTANCE"
654

    
655
htypeNetwork :: String
656
htypeNetwork = "NETWORK"
657

    
658
htypeNode :: String
659
htypeNode = "NODE"
660

    
661
-- * Hkr
662

    
663
hkrSkip :: Int
664
hkrSkip = 0
665

    
666
hkrFail :: Int
667
hkrFail = 1
668

    
669
hkrSuccess :: Int
670
hkrSuccess = 2
671

    
672
-- * Storage types
673

    
674
stBlock :: String
675
stBlock = Types.storageTypeToRaw StorageBlock
676

    
677
stDiskless :: String
678
stDiskless = Types.storageTypeToRaw StorageDiskless
679

    
680
stExt :: String
681
stExt = Types.storageTypeToRaw StorageExt
682

    
683
stFile :: String
684
stFile = Types.storageTypeToRaw StorageFile
685

    
686
stSharedFile :: String
687
stSharedFile = Types.storageTypeToRaw StorageSharedFile
688

    
689
stLvmPv :: String
690
stLvmPv = Types.storageTypeToRaw StorageLvmPv
691

    
692
stLvmVg :: String
693
stLvmVg = Types.storageTypeToRaw StorageLvmVg
694

    
695
stRados :: String
696
stRados = Types.storageTypeToRaw StorageRados
697

    
698
storageTypes :: FrozenSet String
699
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
700

    
701
-- | The set of storage types for which full storage reporting is available
702
stsReport :: FrozenSet String
703
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
704

    
705
-- | The set of storage types for which node storage reporting is available
706
-- | (as used by LUQueryNodeStorage)
707
stsReportNodeStorage :: FrozenSet String
708
stsReportNodeStorage = ConstantUtils.union stsReport $
709
                                           ConstantUtils.mkSet [stSharedFile]
710

    
711
-- * Storage fields
712
-- ** First two are valid in LU context only, not passed to backend
713

    
714
sfNode :: String
715
sfNode = "node"
716

    
717
sfType :: String
718
sfType = "type"
719

    
720
-- ** and the rest are valid in backend
721

    
722
sfAllocatable :: String
723
sfAllocatable = Types.storageFieldToRaw SFAllocatable
724

    
725
sfFree :: String
726
sfFree = Types.storageFieldToRaw SFFree
727

    
728
sfName :: String
729
sfName = Types.storageFieldToRaw SFName
730

    
731
sfSize :: String
732
sfSize = Types.storageFieldToRaw SFSize
733

    
734
sfUsed :: String
735
sfUsed = Types.storageFieldToRaw SFUsed
736

    
737
validStorageFields :: FrozenSet String
738
validStorageFields =
739
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
740
                        [sfNode, sfType]
741

    
742
modifiableStorageFields :: Map String (FrozenSet String)
743
modifiableStorageFields =
744
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
745
                 ConstantUtils.mkSet [sfAllocatable])]
746

    
747
-- * Storage operations
748

    
749
soFixConsistency :: String
750
soFixConsistency = "fix-consistency"
751

    
752
validStorageOperations :: Map String (FrozenSet String)
753
validStorageOperations =
754
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
755
                 ConstantUtils.mkSet [soFixConsistency])]
756

    
757
-- * Volume fields
758

    
759
vfDev :: String
760
vfDev = "dev"
761

    
762
vfInstance :: String
763
vfInstance = "instance"
764

    
765
vfName :: String
766
vfName = "name"
767

    
768
vfNode :: String
769
vfNode = "node"
770

    
771
vfPhys :: String
772
vfPhys = "phys"
773

    
774
vfSize :: String
775
vfSize = "size"
776

    
777
vfVg :: String
778
vfVg = "vg"
779

    
780
-- * Local disk status
781

    
782
ldsFaulty :: Int
783
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
784

    
785
ldsOkay :: Int
786
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
787

    
788
ldsUnknown :: Int
789
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
790

    
791
ldsNames :: Map Int String
792
ldsNames =
793
  Map.fromList [ (Types.localDiskStatusToRaw ds,
794
                  localDiskStatusName ds) | ds <- [minBound..] ]
795

    
796
-- * Disk template types
797

    
798
dtDiskless :: String
799
dtDiskless = Types.diskTemplateToRaw DTDiskless
800

    
801
dtFile :: String
802
dtFile = Types.diskTemplateToRaw DTFile
803

    
804
dtSharedFile :: String
805
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
806

    
807
dtPlain :: String
808
dtPlain = Types.diskTemplateToRaw DTPlain
809

    
810
dtBlock :: String
811
dtBlock = Types.diskTemplateToRaw DTBlock
812

    
813
dtDrbd8 :: String
814
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
815

    
816
dtRbd :: String
817
dtRbd = Types.diskTemplateToRaw DTRbd
818

    
819
dtExt :: String
820
dtExt = Types.diskTemplateToRaw DTExt
821

    
822
dtGluster :: String
823
dtGluster = Types.diskTemplateToRaw DTGluster
824

    
825
-- | This is used to order determine the default disk template when
826
-- the list of enabled disk templates is inferred from the current
827
-- state of the cluster.  This only happens on an upgrade from a
828
-- version of Ganeti that did not support the 'enabled_disk_templates'
829
-- so far.
830
diskTemplatePreference :: [String]
831
diskTemplatePreference =
832
  map Types.diskTemplateToRaw
833
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile,
834
   DTPlain, DTRbd, DTSharedFile, DTGluster]
835

    
836
diskTemplates :: FrozenSet String
837
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
838

    
839
-- | Disk templates that are enabled by default
840
defaultEnabledDiskTemplates :: [String]
841
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
842

    
843
-- | Mapping of disk templates to storage types
844
mapDiskTemplateStorageType :: Map String String
845
mapDiskTemplateStorageType =
846
  Map.fromList $
847
  map (Types.diskTemplateToRaw *** Types.storageTypeToRaw)
848
  [(DTBlock, StorageBlock),
849
   (DTDrbd8, StorageLvmVg),
850
   (DTExt, StorageExt),
851
   (DTSharedFile, StorageSharedFile),
852
   (DTFile, StorageFile),
853
   (DTDiskless, StorageDiskless),
854
   (DTPlain, StorageLvmVg),
855
   (DTRbd, StorageRados),
856
   (DTGluster, StorageSharedFile)]
857

    
858
-- | The set of network-mirrored disk templates
859
dtsIntMirror :: FrozenSet String
860
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
861

    
862
-- | 'DTDiskless' is 'trivially' externally mirrored
863
dtsExtMirror :: FrozenSet String
864
dtsExtMirror =
865
  ConstantUtils.mkSet $
866
  map Types.diskTemplateToRaw
867
  [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd, DTGluster]
868

    
869
-- | The set of non-lvm-based disk templates
870
dtsNotLvm :: FrozenSet String
871
dtsNotLvm =
872
  ConstantUtils.mkSet $
873
  map Types.diskTemplateToRaw
874
  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd, DTGluster]
875

    
876
-- | The set of disk templates which can be grown
877
dtsGrowable :: FrozenSet String
878
dtsGrowable =
879
  ConstantUtils.mkSet $
880
  map Types.diskTemplateToRaw
881
  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd, DTGluster]
882

    
883
-- | The set of disk templates that allow adoption
884
dtsMayAdopt :: FrozenSet String
885
dtsMayAdopt =
886
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
887

    
888
-- | The set of disk templates that *must* use adoption
889
dtsMustAdopt :: FrozenSet String
890
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
891

    
892
-- | The set of disk templates that allow migrations
893
dtsMirrored :: FrozenSet String
894
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
895

    
896
-- | The set of file based disk templates
897
dtsFilebased :: FrozenSet String
898
dtsFilebased =
899
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw
900
  [DTSharedFile, DTFile, DTGluster]
901

    
902
-- | The set of disk templates that can be moved by copying
903
--
904
-- Note: a requirement is that they're not accessed externally or
905
-- shared between nodes; in particular, sharedfile is not suitable.
906
dtsCopyable :: FrozenSet String
907
dtsCopyable =
908
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
909

    
910
-- | The set of disk templates that are supported by exclusive_storage
911
dtsExclStorage :: FrozenSet String
912
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
913

    
914
-- | Templates for which we don't perform checks on free space
915
dtsNoFreeSpaceCheck :: FrozenSet String
916
dtsNoFreeSpaceCheck =
917
  ConstantUtils.mkSet $
918
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd, DTGluster]
919

    
920
dtsBlock :: FrozenSet String
921
dtsBlock =
922
  ConstantUtils.mkSet $
923
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
924

    
925
-- | The set of lvm-based disk templates
926
dtsLvm :: FrozenSet String
927
dtsLvm = diskTemplates `ConstantUtils.difference` dtsNotLvm
928

    
929
-- | The set of lvm-based disk templates
930
dtsHaveAccess :: FrozenSet String
931
dtsHaveAccess = ConstantUtils.mkSet $
932
  map Types.diskTemplateToRaw [DTRbd, DTGluster]
933

    
934
-- * Drbd
935

    
936
drbdHmacAlg :: String
937
drbdHmacAlg = "md5"
938

    
939
drbdDefaultNetProtocol :: String
940
drbdDefaultNetProtocol = "C"
941

    
942
drbdMigrationNetProtocol :: String
943
drbdMigrationNetProtocol = "C"
944

    
945
drbdStatusFile :: String
946
drbdStatusFile = "/proc/drbd"
947

    
948
-- | Size of DRBD meta block device
949
drbdMetaSize :: Int
950
drbdMetaSize = 128
951

    
952
-- * Drbd barrier types
953

    
954
drbdBDiskBarriers :: String
955
drbdBDiskBarriers = "b"
956

    
957
drbdBDiskDrain :: String
958
drbdBDiskDrain = "d"
959

    
960
drbdBDiskFlush :: String
961
drbdBDiskFlush = "f"
962

    
963
drbdBNone :: String
964
drbdBNone = "n"
965

    
966
-- | Valid barrier combinations: "n" or any non-null subset of "bfd"
967
drbdValidBarrierOpt :: FrozenSet (FrozenSet String)
968
drbdValidBarrierOpt =
969
  ConstantUtils.mkSet
970
  [ ConstantUtils.mkSet [drbdBNone]
971
  , ConstantUtils.mkSet [drbdBDiskBarriers]
972
  , ConstantUtils.mkSet [drbdBDiskDrain]
973
  , ConstantUtils.mkSet [drbdBDiskFlush]
974
  , ConstantUtils.mkSet [drbdBDiskDrain, drbdBDiskFlush]
975
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskDrain]
976
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush]
977
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush, drbdBDiskDrain]
978
  ]
979

    
980
-- | Rbd tool command
981
rbdCmd :: String
982
rbdCmd = "rbd"
983

    
984
-- * File backend driver
985

    
986
fdBlktap :: String
987
fdBlktap = Types.fileDriverToRaw FileBlktap
988

    
989
fdBlktap2 :: String
990
fdBlktap2 = Types.fileDriverToRaw FileBlktap2
991

    
992
fdLoop :: String
993
fdLoop = Types.fileDriverToRaw FileLoop
994

    
995
fdDefault :: String
996
fdDefault = fdLoop
997

    
998
fileDriver :: FrozenSet String
999
fileDriver =
1000
  ConstantUtils.mkSet $
1001
  map Types.fileDriverToRaw [minBound..]
1002

    
1003
-- | The set of drbd-like disk types
1004
dtsDrbd :: FrozenSet String
1005
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
1006

    
1007
-- * Disk access mode
1008

    
1009
diskRdonly :: String
1010
diskRdonly = Types.diskModeToRaw DiskRdOnly
1011

    
1012
diskRdwr :: String
1013
diskRdwr = Types.diskModeToRaw DiskRdWr
1014

    
1015
diskAccessSet :: FrozenSet String
1016
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
1017

    
1018
-- * Disk replacement mode
1019

    
1020
replaceDiskAuto :: String
1021
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
1022

    
1023
replaceDiskChg :: String
1024
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
1025

    
1026
replaceDiskPri :: String
1027
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
1028

    
1029
replaceDiskSec :: String
1030
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
1031

    
1032
replaceModes :: FrozenSet String
1033
replaceModes =
1034
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
1035

    
1036
-- * Instance export mode
1037

    
1038
exportModeLocal :: String
1039
exportModeLocal = Types.exportModeToRaw ExportModeLocal
1040

    
1041
exportModeRemote :: String
1042
exportModeRemote = Types.exportModeToRaw ExportModeRemote
1043

    
1044
exportModes :: FrozenSet String
1045
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
1046

    
1047
-- * Instance creation modes
1048

    
1049
instanceCreate :: String
1050
instanceCreate = Types.instCreateModeToRaw InstCreate
1051

    
1052
instanceImport :: String
1053
instanceImport = Types.instCreateModeToRaw InstImport
1054

    
1055
instanceRemoteImport :: String
1056
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1057

    
1058
instanceCreateModes :: FrozenSet String
1059
instanceCreateModes =
1060
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1061

    
1062
-- * Remote import/export handshake message and version
1063

    
1064
rieHandshake :: String
1065
rieHandshake = "Hi, I'm Ganeti"
1066

    
1067
rieVersion :: Int
1068
rieVersion = 0
1069

    
1070
-- | Remote import/export certificate validity (seconds)
1071
rieCertValidity :: Int
1072
rieCertValidity = 24 * 60 * 60
1073

    
1074
-- | Export only: how long to wait per connection attempt (seconds)
1075
rieConnectAttemptTimeout :: Int
1076
rieConnectAttemptTimeout = 20
1077

    
1078
-- | Export only: number of attempts to connect
1079
rieConnectRetries :: Int
1080
rieConnectRetries = 10
1081

    
1082
-- | Overall timeout for establishing connection
1083
rieConnectTimeout :: Int
1084
rieConnectTimeout = 180
1085

    
1086
-- | Give child process up to 5 seconds to exit after sending a signal
1087
childLingerTimeout :: Double
1088
childLingerTimeout = 5.0
1089

    
1090
-- * Import/export config options
1091

    
1092
inisectBep :: String
1093
inisectBep = "backend"
1094

    
1095
inisectExp :: String
1096
inisectExp = "export"
1097

    
1098
inisectHyp :: String
1099
inisectHyp = "hypervisor"
1100

    
1101
inisectIns :: String
1102
inisectIns = "instance"
1103

    
1104
inisectOsp :: String
1105
inisectOsp = "os"
1106

    
1107
-- * Dynamic device modification
1108

    
1109
ddmAdd :: String
1110
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1111

    
1112
ddmModify :: String
1113
ddmModify = Types.ddmFullToRaw DdmFullModify
1114

    
1115
ddmRemove :: String
1116
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1117

    
1118
ddmsValues :: FrozenSet String
1119
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1120

    
1121
ddmsValuesWithModify :: FrozenSet String
1122
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1123

    
1124
-- * Common exit codes
1125

    
1126
exitSuccess :: Int
1127
exitSuccess = 0
1128

    
1129
exitFailure :: Int
1130
exitFailure = ConstantUtils.exitFailure
1131

    
1132
exitNotcluster :: Int
1133
exitNotcluster = 5
1134

    
1135
exitNotmaster :: Int
1136
exitNotmaster = 11
1137

    
1138
exitNodesetupError :: Int
1139
exitNodesetupError = 12
1140

    
1141
-- | Need user confirmation
1142
exitConfirmation :: Int
1143
exitConfirmation = 13
1144

    
1145
-- | Exit code for query operations with unknown fields
1146
exitUnknownField :: Int
1147
exitUnknownField = 14
1148

    
1149
-- * Tags
1150

    
1151
tagCluster :: String
1152
tagCluster = Types.tagKindToRaw TagKindCluster
1153

    
1154
tagInstance :: String
1155
tagInstance = Types.tagKindToRaw TagKindInstance
1156

    
1157
tagNetwork :: String
1158
tagNetwork = Types.tagKindToRaw TagKindNetwork
1159

    
1160
tagNode :: String
1161
tagNode = Types.tagKindToRaw TagKindNode
1162

    
1163
tagNodegroup :: String
1164
tagNodegroup = Types.tagKindToRaw TagKindGroup
1165

    
1166
validTagTypes :: FrozenSet String
1167
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1168

    
1169
maxTagLen :: Int
1170
maxTagLen = 128
1171

    
1172
maxTagsPerObj :: Int
1173
maxTagsPerObj = 4096
1174

    
1175
-- * Others
1176

    
1177
defaultBridge :: String
1178
defaultBridge = "xen-br0"
1179

    
1180
defaultOvs :: String
1181
defaultOvs = "switch1"
1182

    
1183
-- | 60 MiB/s, expressed in KiB/s
1184
classicDrbdSyncSpeed :: Int
1185
classicDrbdSyncSpeed = 60 * 1024
1186

    
1187
ip4AddressAny :: String
1188
ip4AddressAny = "0.0.0.0"
1189

    
1190
ip4AddressLocalhost :: String
1191
ip4AddressLocalhost = "127.0.0.1"
1192

    
1193
ip6AddressAny :: String
1194
ip6AddressAny = "::"
1195

    
1196
ip6AddressLocalhost :: String
1197
ip6AddressLocalhost = "::1"
1198

    
1199
ip4Version :: Int
1200
ip4Version = 4
1201

    
1202
ip6Version :: Int
1203
ip6Version = 6
1204

    
1205
validIpVersions :: FrozenSet Int
1206
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1207

    
1208
tcpPingTimeout :: Int
1209
tcpPingTimeout = 10
1210

    
1211
defaultVg :: String
1212
defaultVg = "xenvg"
1213

    
1214
defaultDrbdHelper :: String
1215
defaultDrbdHelper = "/bin/true"
1216

    
1217
minVgSize :: Int
1218
minVgSize = 20480
1219

    
1220
defaultMacPrefix :: String
1221
defaultMacPrefix = "aa:00:00"
1222

    
1223
-- | Default maximum instance wait time (seconds)
1224
defaultShutdownTimeout :: Int
1225
defaultShutdownTimeout = 120
1226

    
1227
-- | Node clock skew (seconds)
1228
nodeMaxClockSkew :: Int
1229
nodeMaxClockSkew = 150
1230

    
1231
-- | Time for an intra-cluster disk transfer to wait for a connection
1232
diskTransferConnectTimeout :: Int
1233
diskTransferConnectTimeout = 60
1234

    
1235
-- | Disk index separator
1236
diskSeparator :: String
1237
diskSeparator = AutoConf.diskSeparator
1238

    
1239
ipCommandPath :: String
1240
ipCommandPath = AutoConf.ipPath
1241

    
1242
-- | Key for job IDs in opcode result
1243
jobIdsKey :: String
1244
jobIdsKey = "jobs"
1245

    
1246
-- * Runparts results
1247

    
1248
runpartsErr :: Int
1249
runpartsErr = 2
1250

    
1251
runpartsRun :: Int
1252
runpartsRun = 1
1253

    
1254
runpartsSkip :: Int
1255
runpartsSkip = 0
1256

    
1257
runpartsStatus :: [Int]
1258
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1259

    
1260
-- * RPC
1261

    
1262
rpcEncodingNone :: Int
1263
rpcEncodingNone = 0
1264

    
1265
rpcEncodingZlibBase64 :: Int
1266
rpcEncodingZlibBase64 = 1
1267

    
1268
-- * Timeout table
1269
--
1270
-- Various time constants for the timeout table
1271

    
1272
rpcTmoUrgent :: Int
1273
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1274

    
1275
rpcTmoFast :: Int
1276
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1277

    
1278
rpcTmoNormal :: Int
1279
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1280

    
1281
rpcTmoSlow :: Int
1282
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1283

    
1284
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1285
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1286
-- Python name.
1287
rpcTmo_4hrs :: Int
1288
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1289

    
1290
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1291
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1292
-- Python name.
1293
rpcTmo_1day :: Int
1294
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1295

    
1296
-- | Timeout for connecting to nodes (seconds)
1297
rpcConnectTimeout :: Int
1298
rpcConnectTimeout = 5
1299

    
1300
-- OS
1301

    
1302
osScriptCreate :: String
1303
osScriptCreate = "create"
1304

    
1305
osScriptExport :: String
1306
osScriptExport = "export"
1307

    
1308
osScriptImport :: String
1309
osScriptImport = "import"
1310

    
1311
osScriptRename :: String
1312
osScriptRename = "rename"
1313

    
1314
osScriptVerify :: String
1315
osScriptVerify = "verify"
1316

    
1317
osScripts :: [String]
1318
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1319
             osScriptVerify]
1320

    
1321
osApiFile :: String
1322
osApiFile = "ganeti_api_version"
1323

    
1324
osVariantsFile :: String
1325
osVariantsFile = "variants.list"
1326

    
1327
osParametersFile :: String
1328
osParametersFile = "parameters.list"
1329

    
1330
osValidateParameters :: String
1331
osValidateParameters = "parameters"
1332

    
1333
osValidateCalls :: FrozenSet String
1334
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1335

    
1336
-- | External Storage (ES) related constants
1337

    
1338
esActionAttach :: String
1339
esActionAttach = "attach"
1340

    
1341
esActionCreate :: String
1342
esActionCreate = "create"
1343

    
1344
esActionDetach :: String
1345
esActionDetach = "detach"
1346

    
1347
esActionGrow :: String
1348
esActionGrow = "grow"
1349

    
1350
esActionRemove :: String
1351
esActionRemove = "remove"
1352

    
1353
esActionSetinfo :: String
1354
esActionSetinfo = "setinfo"
1355

    
1356
esActionVerify :: String
1357
esActionVerify = "verify"
1358

    
1359
esScriptCreate :: String
1360
esScriptCreate = esActionCreate
1361

    
1362
esScriptRemove :: String
1363
esScriptRemove = esActionRemove
1364

    
1365
esScriptGrow :: String
1366
esScriptGrow = esActionGrow
1367

    
1368
esScriptAttach :: String
1369
esScriptAttach = esActionAttach
1370

    
1371
esScriptDetach :: String
1372
esScriptDetach = esActionDetach
1373

    
1374
esScriptSetinfo :: String
1375
esScriptSetinfo = esActionSetinfo
1376

    
1377
esScriptVerify :: String
1378
esScriptVerify = esActionVerify
1379

    
1380
esScripts :: FrozenSet String
1381
esScripts =
1382
  ConstantUtils.mkSet [esScriptAttach,
1383
                       esScriptCreate,
1384
                       esScriptDetach,
1385
                       esScriptGrow,
1386
                       esScriptRemove,
1387
                       esScriptSetinfo,
1388
                       esScriptVerify]
1389

    
1390
esParametersFile :: String
1391
esParametersFile = "parameters.list"
1392

    
1393
-- * Reboot types
1394

    
1395
instanceRebootSoft :: String
1396
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1397

    
1398
instanceRebootHard :: String
1399
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1400

    
1401
instanceRebootFull :: String
1402
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1403

    
1404
rebootTypes :: FrozenSet String
1405
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1406

    
1407
-- * Instance reboot behaviors
1408

    
1409
instanceRebootAllowed :: String
1410
instanceRebootAllowed = "reboot"
1411

    
1412
instanceRebootExit :: String
1413
instanceRebootExit = "exit"
1414

    
1415
rebootBehaviors :: [String]
1416
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1417

    
1418
-- * VTypes
1419

    
1420
vtypeBool :: VType
1421
vtypeBool = VTypeBool
1422

    
1423
vtypeInt :: VType
1424
vtypeInt = VTypeInt
1425

    
1426
vtypeMaybeString :: VType
1427
vtypeMaybeString = VTypeMaybeString
1428

    
1429
-- | Size in MiBs
1430
vtypeSize :: VType
1431
vtypeSize = VTypeSize
1432

    
1433
vtypeString :: VType
1434
vtypeString = VTypeString
1435

    
1436
enforceableTypes :: FrozenSet VType
1437
enforceableTypes = ConstantUtils.mkSet [minBound..]
1438

    
1439
-- | Constant representing that the user does not specify any IP version
1440
ifaceNoIpVersionSpecified :: Int
1441
ifaceNoIpVersionSpecified = 0
1442

    
1443
validSerialSpeeds :: [Int]
1444
validSerialSpeeds =
1445
  [75,
1446
   110,
1447
   300,
1448
   600,
1449
   1200,
1450
   1800,
1451
   2400,
1452
   4800,
1453
   9600,
1454
   14400,
1455
   19200,
1456
   28800,
1457
   38400,
1458
   57600,
1459
   115200,
1460
   230400,
1461
   345600,
1462
   460800]
1463

    
1464
-- * HV parameter names (global namespace)
1465

    
1466
hvAcpi :: String
1467
hvAcpi = "acpi"
1468

    
1469
hvBlockdevPrefix :: String
1470
hvBlockdevPrefix = "blockdev_prefix"
1471

    
1472
hvBootloaderArgs :: String
1473
hvBootloaderArgs = "bootloader_args"
1474

    
1475
hvBootloaderPath :: String
1476
hvBootloaderPath = "bootloader_path"
1477

    
1478
hvBootOrder :: String
1479
hvBootOrder = "boot_order"
1480

    
1481
hvCdromImagePath :: String
1482
hvCdromImagePath = "cdrom_image_path"
1483

    
1484
hvCpuCap :: String
1485
hvCpuCap = "cpu_cap"
1486

    
1487
hvCpuCores :: String
1488
hvCpuCores = "cpu_cores"
1489

    
1490
hvCpuMask :: String
1491
hvCpuMask = "cpu_mask"
1492

    
1493
hvCpuSockets :: String
1494
hvCpuSockets = "cpu_sockets"
1495

    
1496
hvCpuThreads :: String
1497
hvCpuThreads = "cpu_threads"
1498

    
1499
hvCpuType :: String
1500
hvCpuType = "cpu_type"
1501

    
1502
hvCpuWeight :: String
1503
hvCpuWeight = "cpu_weight"
1504

    
1505
hvDeviceModel :: String
1506
hvDeviceModel = "device_model"
1507

    
1508
hvDiskCache :: String
1509
hvDiskCache = "disk_cache"
1510

    
1511
hvDiskType :: String
1512
hvDiskType = "disk_type"
1513

    
1514
hvInitrdPath :: String
1515
hvInitrdPath = "initrd_path"
1516

    
1517
hvInitScript :: String
1518
hvInitScript = "init_script"
1519

    
1520
hvKernelArgs :: String
1521
hvKernelArgs = "kernel_args"
1522

    
1523
hvKernelPath :: String
1524
hvKernelPath = "kernel_path"
1525

    
1526
hvKeymap :: String
1527
hvKeymap = "keymap"
1528

    
1529
hvKvmCdrom2ImagePath :: String
1530
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1531

    
1532
hvKvmCdromDiskType :: String
1533
hvKvmCdromDiskType = "cdrom_disk_type"
1534

    
1535
hvKvmExtra :: String
1536
hvKvmExtra = "kvm_extra"
1537

    
1538
hvKvmFlag :: String
1539
hvKvmFlag = "kvm_flag"
1540

    
1541
hvKvmFloppyImagePath :: String
1542
hvKvmFloppyImagePath = "floppy_image_path"
1543

    
1544
hvKvmMachineVersion :: String
1545
hvKvmMachineVersion = "machine_version"
1546

    
1547
hvKvmPath :: String
1548
hvKvmPath = "kvm_path"
1549

    
1550
hvKvmSpiceAudioCompr :: String
1551
hvKvmSpiceAudioCompr = "spice_playback_compression"
1552

    
1553
hvKvmSpiceBind :: String
1554
hvKvmSpiceBind = "spice_bind"
1555

    
1556
hvKvmSpiceIpVersion :: String
1557
hvKvmSpiceIpVersion = "spice_ip_version"
1558

    
1559
hvKvmSpiceJpegImgCompr :: String
1560
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1561

    
1562
hvKvmSpiceLosslessImgCompr :: String
1563
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1564

    
1565
hvKvmSpicePasswordFile :: String
1566
hvKvmSpicePasswordFile = "spice_password_file"
1567

    
1568
hvKvmSpiceStreamingVideoDetection :: String
1569
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1570

    
1571
hvKvmSpiceTlsCiphers :: String
1572
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1573

    
1574
hvKvmSpiceUseTls :: String
1575
hvKvmSpiceUseTls = "spice_use_tls"
1576

    
1577
hvKvmSpiceUseVdagent :: String
1578
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1579

    
1580
hvKvmSpiceZlibGlzImgCompr :: String
1581
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1582

    
1583
hvKvmUseChroot :: String
1584
hvKvmUseChroot = "use_chroot"
1585

    
1586
hvKvmUserShutdown :: String
1587
hvKvmUserShutdown = "user_shutdown"
1588

    
1589
hvMemPath :: String
1590
hvMemPath = "mem_path"
1591

    
1592
hvMigrationBandwidth :: String
1593
hvMigrationBandwidth = "migration_bandwidth"
1594

    
1595
hvMigrationDowntime :: String
1596
hvMigrationDowntime = "migration_downtime"
1597

    
1598
hvMigrationMode :: String
1599
hvMigrationMode = "migration_mode"
1600

    
1601
hvMigrationPort :: String
1602
hvMigrationPort = "migration_port"
1603

    
1604
hvNicType :: String
1605
hvNicType = "nic_type"
1606

    
1607
hvPae :: String
1608
hvPae = "pae"
1609

    
1610
hvPassthrough :: String
1611
hvPassthrough = "pci_pass"
1612

    
1613
hvRebootBehavior :: String
1614
hvRebootBehavior = "reboot_behavior"
1615

    
1616
hvRootPath :: String
1617
hvRootPath = "root_path"
1618

    
1619
hvSecurityDomain :: String
1620
hvSecurityDomain = "security_domain"
1621

    
1622
hvSecurityModel :: String
1623
hvSecurityModel = "security_model"
1624

    
1625
hvSerialConsole :: String
1626
hvSerialConsole = "serial_console"
1627

    
1628
hvSerialSpeed :: String
1629
hvSerialSpeed = "serial_speed"
1630

    
1631
hvSoundhw :: String
1632
hvSoundhw = "soundhw"
1633

    
1634
hvUsbDevices :: String
1635
hvUsbDevices = "usb_devices"
1636

    
1637
hvUsbMouse :: String
1638
hvUsbMouse = "usb_mouse"
1639

    
1640
hvUseBootloader :: String
1641
hvUseBootloader = "use_bootloader"
1642

    
1643
hvUseLocaltime :: String
1644
hvUseLocaltime = "use_localtime"
1645

    
1646
hvVga :: String
1647
hvVga = "vga"
1648

    
1649
hvVhostNet :: String
1650
hvVhostNet = "vhost_net"
1651

    
1652
hvVifScript :: String
1653
hvVifScript = "vif_script"
1654

    
1655
hvVifType :: String
1656
hvVifType = "vif_type"
1657

    
1658
hvViridian :: String
1659
hvViridian = "viridian"
1660

    
1661
hvVncBindAddress :: String
1662
hvVncBindAddress = "vnc_bind_address"
1663

    
1664
hvVncPasswordFile :: String
1665
hvVncPasswordFile = "vnc_password_file"
1666

    
1667
hvVncTls :: String
1668
hvVncTls = "vnc_tls"
1669

    
1670
hvVncX509 :: String
1671
hvVncX509 = "vnc_x509_path"
1672

    
1673
hvVncX509Verify :: String
1674
hvVncX509Verify = "vnc_x509_verify"
1675

    
1676
hvVnetHdr :: String
1677
hvVnetHdr = "vnet_hdr"
1678

    
1679
hvXenCmd :: String
1680
hvXenCmd = "xen_cmd"
1681

    
1682
hvXenCpuid :: String
1683
hvXenCpuid = "cpuid"
1684

    
1685
hvsParameterTitles :: Map String String
1686
hvsParameterTitles =
1687
  Map.fromList
1688
  [(hvAcpi, "ACPI"),
1689
   (hvBootOrder, "Boot_order"),
1690
   (hvCdromImagePath, "CDROM_image_path"),
1691
   (hvCpuType, "cpu_type"),
1692
   (hvDiskType, "Disk_type"),
1693
   (hvInitrdPath, "Initrd_path"),
1694
   (hvKernelPath, "Kernel_path"),
1695
   (hvNicType, "NIC_type"),
1696
   (hvPae, "PAE"),
1697
   (hvPassthrough, "pci_pass"),
1698
   (hvVncBindAddress, "VNC_bind_address")]
1699

    
1700
hvsParameters :: FrozenSet String
1701
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1702

    
1703
hvsParameterTypes :: Map String VType
1704
hvsParameterTypes = Map.fromList
1705
  [ (hvAcpi,                            VTypeBool)
1706
  , (hvBlockdevPrefix,                  VTypeString)
1707
  , (hvBootloaderArgs,                  VTypeString)
1708
  , (hvBootloaderPath,                  VTypeString)
1709
  , (hvBootOrder,                       VTypeString)
1710
  , (hvCdromImagePath,                  VTypeString)
1711
  , (hvCpuCap,                          VTypeInt)
1712
  , (hvCpuCores,                        VTypeInt)
1713
  , (hvCpuMask,                         VTypeString)
1714
  , (hvCpuSockets,                      VTypeInt)
1715
  , (hvCpuThreads,                      VTypeInt)
1716
  , (hvCpuType,                         VTypeString)
1717
  , (hvCpuWeight,                       VTypeInt)
1718
  , (hvDeviceModel,                     VTypeString)
1719
  , (hvDiskCache,                       VTypeString)
1720
  , (hvDiskType,                        VTypeString)
1721
  , (hvInitrdPath,                      VTypeString)
1722
  , (hvInitScript,                      VTypeString)
1723
  , (hvKernelArgs,                      VTypeString)
1724
  , (hvKernelPath,                      VTypeString)
1725
  , (hvKeymap,                          VTypeString)
1726
  , (hvKvmCdrom2ImagePath,              VTypeString)
1727
  , (hvKvmCdromDiskType,                VTypeString)
1728
  , (hvKvmExtra,                        VTypeString)
1729
  , (hvKvmFlag,                         VTypeString)
1730
  , (hvKvmFloppyImagePath,              VTypeString)
1731
  , (hvKvmMachineVersion,               VTypeString)
1732
  , (hvKvmPath,                         VTypeString)
1733
  , (hvKvmSpiceAudioCompr,              VTypeBool)
1734
  , (hvKvmSpiceBind,                    VTypeString)
1735
  , (hvKvmSpiceIpVersion,               VTypeInt)
1736
  , (hvKvmSpiceJpegImgCompr,            VTypeString)
1737
  , (hvKvmSpiceLosslessImgCompr,        VTypeString)
1738
  , (hvKvmSpicePasswordFile,            VTypeString)
1739
  , (hvKvmSpiceStreamingVideoDetection, VTypeString)
1740
  , (hvKvmSpiceTlsCiphers,              VTypeString)
1741
  , (hvKvmSpiceUseTls,                  VTypeBool)
1742
  , (hvKvmSpiceUseVdagent,              VTypeBool)
1743
  , (hvKvmSpiceZlibGlzImgCompr,         VTypeString)
1744
  , (hvKvmUseChroot,                    VTypeBool)
1745
  , (hvKvmUserShutdown,                 VTypeBool)
1746
  , (hvMemPath,                         VTypeString)
1747
  , (hvMigrationBandwidth,              VTypeInt)
1748
  , (hvMigrationDowntime,               VTypeInt)
1749
  , (hvMigrationMode,                   VTypeString)
1750
  , (hvMigrationPort,                   VTypeInt)
1751
  , (hvNicType,                         VTypeString)
1752
  , (hvPae,                             VTypeBool)
1753
  , (hvPassthrough,                     VTypeString)
1754
  , (hvRebootBehavior,                  VTypeString)
1755
  , (hvRootPath,                        VTypeMaybeString)
1756
  , (hvSecurityDomain,                  VTypeString)
1757
  , (hvSecurityModel,                   VTypeString)
1758
  , (hvSerialConsole,                   VTypeBool)
1759
  , (hvSerialSpeed,                     VTypeInt)
1760
  , (hvSoundhw,                         VTypeString)
1761
  , (hvUsbDevices,                      VTypeString)
1762
  , (hvUsbMouse,                        VTypeString)
1763
  , (hvUseBootloader,                   VTypeBool)
1764
  , (hvUseLocaltime,                    VTypeBool)
1765
  , (hvVga,                             VTypeString)
1766
  , (hvVhostNet,                        VTypeBool)
1767
  , (hvVifScript,                       VTypeString)
1768
  , (hvVifType,                         VTypeString)
1769
  , (hvViridian,                        VTypeBool)
1770
  , (hvVncBindAddress,                  VTypeString)
1771
  , (hvVncPasswordFile,                 VTypeString)
1772
  , (hvVncTls,                          VTypeBool)
1773
  , (hvVncX509,                         VTypeString)
1774
  , (hvVncX509Verify,                   VTypeBool)
1775
  , (hvVnetHdr,                         VTypeBool)
1776
  , (hvXenCmd,                          VTypeString)
1777
  , (hvXenCpuid,                        VTypeString)
1778
  ]
1779

    
1780
-- * Migration statuses
1781

    
1782
hvMigrationActive :: String
1783
hvMigrationActive = "active"
1784

    
1785
hvMigrationCancelled :: String
1786
hvMigrationCancelled = "cancelled"
1787

    
1788
hvMigrationCompleted :: String
1789
hvMigrationCompleted = "completed"
1790

    
1791
hvMigrationFailed :: String
1792
hvMigrationFailed = "failed"
1793

    
1794
hvMigrationValidStatuses :: FrozenSet String
1795
hvMigrationValidStatuses =
1796
  ConstantUtils.mkSet [hvMigrationActive,
1797
                       hvMigrationCancelled,
1798
                       hvMigrationCompleted,
1799
                       hvMigrationFailed]
1800

    
1801
hvMigrationFailedStatuses :: FrozenSet String
1802
hvMigrationFailedStatuses =
1803
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1804

    
1805
-- | KVM-specific statuses
1806
--
1807
-- FIXME: this constant seems unnecessary
1808
hvKvmMigrationValidStatuses :: FrozenSet String
1809
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1810

    
1811
-- | Node info keys
1812
hvNodeinfoKeyVersion :: String
1813
hvNodeinfoKeyVersion = "hv_version"
1814

    
1815
-- * Hypervisor state
1816

    
1817
hvstCpuNode :: String
1818
hvstCpuNode = "cpu_node"
1819

    
1820
hvstCpuTotal :: String
1821
hvstCpuTotal = "cpu_total"
1822

    
1823
hvstMemoryHv :: String
1824
hvstMemoryHv = "mem_hv"
1825

    
1826
hvstMemoryNode :: String
1827
hvstMemoryNode = "mem_node"
1828

    
1829
hvstMemoryTotal :: String
1830
hvstMemoryTotal = "mem_total"
1831

    
1832
hvstsParameters :: FrozenSet String
1833
hvstsParameters =
1834
  ConstantUtils.mkSet [hvstCpuNode,
1835
                       hvstCpuTotal,
1836
                       hvstMemoryHv,
1837
                       hvstMemoryNode,
1838
                       hvstMemoryTotal]
1839

    
1840
hvstDefaults :: Map String Int
1841
hvstDefaults =
1842
  Map.fromList
1843
  [(hvstCpuNode, 1),
1844
   (hvstCpuTotal, 1),
1845
   (hvstMemoryHv, 0),
1846
   (hvstMemoryTotal, 0),
1847
   (hvstMemoryNode, 0)]
1848

    
1849
hvstsParameterTypes :: Map String VType
1850
hvstsParameterTypes =
1851
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1852
                (hvstMemoryNode, VTypeInt),
1853
                (hvstMemoryHv, VTypeInt),
1854
                (hvstCpuTotal, VTypeInt),
1855
                (hvstCpuNode, VTypeInt)]
1856

    
1857
-- * Disk state
1858

    
1859
dsDiskOverhead :: String
1860
dsDiskOverhead = "disk_overhead"
1861

    
1862
dsDiskReserved :: String
1863
dsDiskReserved = "disk_reserved"
1864

    
1865
dsDiskTotal :: String
1866
dsDiskTotal = "disk_total"
1867

    
1868
dsDefaults :: Map String Int
1869
dsDefaults =
1870
  Map.fromList
1871
  [(dsDiskTotal, 0),
1872
   (dsDiskReserved, 0),
1873
   (dsDiskOverhead, 0)]
1874

    
1875
dssParameterTypes :: Map String VType
1876
dssParameterTypes =
1877
  Map.fromList [(dsDiskTotal, VTypeInt),
1878
                (dsDiskReserved, VTypeInt),
1879
                (dsDiskOverhead, VTypeInt)]
1880

    
1881
dssParameters :: FrozenSet String
1882
dssParameters =
1883
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1884

    
1885
dsValidTypes :: FrozenSet String
1886
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1887

    
1888
-- Backend parameter names
1889

    
1890
beAlwaysFailover :: String
1891
beAlwaysFailover = "always_failover"
1892

    
1893
beAutoBalance :: String
1894
beAutoBalance = "auto_balance"
1895

    
1896
beMaxmem :: String
1897
beMaxmem = "maxmem"
1898

    
1899
-- | Deprecated and replaced by max and min mem
1900
beMemory :: String
1901
beMemory = "memory"
1902

    
1903
beMinmem :: String
1904
beMinmem = "minmem"
1905

    
1906
beSpindleUse :: String
1907
beSpindleUse = "spindle_use"
1908

    
1909
beVcpus :: String
1910
beVcpus = "vcpus"
1911

    
1912
besParameterTypes :: Map String VType
1913
besParameterTypes =
1914
  Map.fromList [(beAlwaysFailover, VTypeBool),
1915
                (beAutoBalance, VTypeBool),
1916
                (beMaxmem, VTypeSize),
1917
                (beMinmem, VTypeSize),
1918
                (beSpindleUse, VTypeInt),
1919
                (beVcpus, VTypeInt)]
1920

    
1921
besParameterTitles :: Map String String
1922
besParameterTitles =
1923
  Map.fromList [(beAutoBalance, "Auto_balance"),
1924
                (beMinmem, "ConfigMinMem"),
1925
                (beVcpus, "ConfigVCPUs"),
1926
                (beMaxmem, "ConfigMaxMem")]
1927

    
1928
besParameterCompat :: Map String VType
1929
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1930

    
1931
besParameters :: FrozenSet String
1932
besParameters =
1933
  ConstantUtils.mkSet [beAlwaysFailover,
1934
                       beAutoBalance,
1935
                       beMaxmem,
1936
                       beMinmem,
1937
                       beSpindleUse,
1938
                       beVcpus]
1939

    
1940
-- | Instance specs
1941
--
1942
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1943

    
1944
ispecMemSize :: String
1945
ispecMemSize = ConstantUtils.ispecMemSize
1946

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

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

    
1953
ispecDiskSize :: String
1954
ispecDiskSize = ConstantUtils.ispecDiskSize
1955

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

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

    
1962
ispecsParameterTypes :: Map String VType
1963
ispecsParameterTypes =
1964
  Map.fromList
1965
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1966
   (ConstantUtils.ispecCpuCount, VTypeInt),
1967
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1968
   (ConstantUtils.ispecMemSize, VTypeInt),
1969
   (ConstantUtils.ispecNicCount, VTypeInt),
1970
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1971

    
1972
ispecsParameters :: FrozenSet String
1973
ispecsParameters =
1974
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1975
                       ConstantUtils.ispecDiskCount,
1976
                       ConstantUtils.ispecDiskSize,
1977
                       ConstantUtils.ispecMemSize,
1978
                       ConstantUtils.ispecNicCount,
1979
                       ConstantUtils.ispecSpindleUse]
1980

    
1981
ispecsMinmax :: String
1982
ispecsMinmax = ConstantUtils.ispecsMinmax
1983

    
1984
ispecsMax :: String
1985
ispecsMax = "max"
1986

    
1987
ispecsMin :: String
1988
ispecsMin = "min"
1989

    
1990
ispecsStd :: String
1991
ispecsStd = ConstantUtils.ispecsStd
1992

    
1993
ipolicyDts :: String
1994
ipolicyDts = ConstantUtils.ipolicyDts
1995

    
1996
ipolicyVcpuRatio :: String
1997
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1998

    
1999
ipolicySpindleRatio :: String
2000
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
2001

    
2002
ispecsMinmaxKeys :: FrozenSet String
2003
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
2004

    
2005
ipolicyParameters :: FrozenSet String
2006
ipolicyParameters =
2007
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
2008
                       ConstantUtils.ipolicySpindleRatio]
2009

    
2010
ipolicyAllKeys :: FrozenSet String
2011
ipolicyAllKeys =
2012
  ConstantUtils.union ipolicyParameters $
2013
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
2014
                       ConstantUtils.ispecsMinmax,
2015
                       ispecsStd]
2016

    
2017
-- | Node parameter names
2018

    
2019
ndExclusiveStorage :: String
2020
ndExclusiveStorage = "exclusive_storage"
2021

    
2022
ndOobProgram :: String
2023
ndOobProgram = "oob_program"
2024

    
2025
ndSpindleCount :: String
2026
ndSpindleCount = "spindle_count"
2027

    
2028
ndOvs :: String
2029
ndOvs = "ovs"
2030

    
2031
ndOvsLink :: String
2032
ndOvsLink = "ovs_link"
2033

    
2034
ndOvsName :: String
2035
ndOvsName = "ovs_name"
2036

    
2037
ndSshPort :: String
2038
ndSshPort = "ssh_port"
2039

    
2040
ndsParameterTypes :: Map String VType
2041
ndsParameterTypes =
2042
  Map.fromList
2043
  [(ndExclusiveStorage, VTypeBool),
2044
   (ndOobProgram, VTypeString),
2045
   (ndOvs, VTypeBool),
2046
   (ndOvsLink, VTypeMaybeString),
2047
   (ndOvsName, VTypeMaybeString),
2048
   (ndSpindleCount, VTypeInt),
2049
   (ndSshPort, VTypeInt)]
2050

    
2051
ndsParameters :: FrozenSet String
2052
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
2053

    
2054
ndsParameterTitles :: Map String String
2055
ndsParameterTitles =
2056
  Map.fromList
2057
  [(ndExclusiveStorage, "ExclusiveStorage"),
2058
   (ndOobProgram, "OutOfBandProgram"),
2059
   (ndOvs, "OpenvSwitch"),
2060
   (ndOvsLink, "OpenvSwitchLink"),
2061
   (ndOvsName, "OpenvSwitchName"),
2062
   (ndSpindleCount, "SpindleCount")]
2063

    
2064
-- * Logical Disks parameters
2065

    
2066
ldpAccess :: String
2067
ldpAccess = "access"
2068

    
2069
ldpBarriers :: String
2070
ldpBarriers = "disabled-barriers"
2071

    
2072
ldpDefaultMetavg :: String
2073
ldpDefaultMetavg = "default-metavg"
2074

    
2075
ldpDelayTarget :: String
2076
ldpDelayTarget = "c-delay-target"
2077

    
2078
ldpDiskCustom :: String
2079
ldpDiskCustom = "disk-custom"
2080

    
2081
ldpDynamicResync :: String
2082
ldpDynamicResync = "dynamic-resync"
2083

    
2084
ldpFillTarget :: String
2085
ldpFillTarget = "c-fill-target"
2086

    
2087
ldpMaxRate :: String
2088
ldpMaxRate = "c-max-rate"
2089

    
2090
ldpMinRate :: String
2091
ldpMinRate = "c-min-rate"
2092

    
2093
ldpNetCustom :: String
2094
ldpNetCustom = "net-custom"
2095

    
2096
ldpNoMetaFlush :: String
2097
ldpNoMetaFlush = "disable-meta-flush"
2098

    
2099
ldpPlanAhead :: String
2100
ldpPlanAhead = "c-plan-ahead"
2101

    
2102
ldpPool :: String
2103
ldpPool = "pool"
2104

    
2105
ldpProtocol :: String
2106
ldpProtocol = "protocol"
2107

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

    
2111
ldpStripes :: String
2112
ldpStripes = "stripes"
2113

    
2114
diskLdTypes :: Map String VType
2115
diskLdTypes =
2116
  Map.fromList
2117
  [(ldpAccess, VTypeString),
2118
   (ldpResyncRate, VTypeInt),
2119
   (ldpStripes, VTypeInt),
2120
   (ldpBarriers, VTypeString),
2121
   (ldpNoMetaFlush, VTypeBool),
2122
   (ldpDefaultMetavg, VTypeString),
2123
   (ldpDiskCustom, VTypeString),
2124
   (ldpNetCustom, VTypeString),
2125
   (ldpProtocol, VTypeString),
2126
   (ldpDynamicResync, VTypeBool),
2127
   (ldpPlanAhead, VTypeInt),
2128
   (ldpFillTarget, VTypeInt),
2129
   (ldpDelayTarget, VTypeInt),
2130
   (ldpMaxRate, VTypeInt),
2131
   (ldpMinRate, VTypeInt),
2132
   (ldpPool, VTypeString)]
2133

    
2134
diskLdParameters :: FrozenSet String
2135
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2136

    
2137
-- * Disk template parameters
2138
--
2139
-- Disk template parameters can be set/changed by the user via
2140
-- gnt-cluster and gnt-group)
2141

    
2142
drbdResyncRate :: String
2143
drbdResyncRate = "resync-rate"
2144

    
2145
drbdDataStripes :: String
2146
drbdDataStripes = "data-stripes"
2147

    
2148
drbdMetaStripes :: String
2149
drbdMetaStripes = "meta-stripes"
2150

    
2151
drbdDiskBarriers :: String
2152
drbdDiskBarriers = "disk-barriers"
2153

    
2154
drbdMetaBarriers :: String
2155
drbdMetaBarriers = "meta-barriers"
2156

    
2157
drbdDefaultMetavg :: String
2158
drbdDefaultMetavg = "metavg"
2159

    
2160
drbdDiskCustom :: String
2161
drbdDiskCustom = "disk-custom"
2162

    
2163
drbdNetCustom :: String
2164
drbdNetCustom = "net-custom"
2165

    
2166
drbdProtocol :: String
2167
drbdProtocol = "protocol"
2168

    
2169
drbdDynamicResync :: String
2170
drbdDynamicResync = "dynamic-resync"
2171

    
2172
drbdPlanAhead :: String
2173
drbdPlanAhead = "c-plan-ahead"
2174

    
2175
drbdFillTarget :: String
2176
drbdFillTarget = "c-fill-target"
2177

    
2178
drbdDelayTarget :: String
2179
drbdDelayTarget = "c-delay-target"
2180

    
2181
drbdMaxRate :: String
2182
drbdMaxRate = "c-max-rate"
2183

    
2184
drbdMinRate :: String
2185
drbdMinRate = "c-min-rate"
2186

    
2187
lvStripes :: String
2188
lvStripes = "stripes"
2189

    
2190
rbdAccess :: String
2191
rbdAccess = "access"
2192

    
2193
rbdPool :: String
2194
rbdPool = "pool"
2195

    
2196
diskDtTypes :: Map String VType
2197
diskDtTypes =
2198
  Map.fromList [(drbdResyncRate, VTypeInt),
2199
                (drbdDataStripes, VTypeInt),
2200
                (drbdMetaStripes, VTypeInt),
2201
                (drbdDiskBarriers, VTypeString),
2202
                (drbdMetaBarriers, VTypeBool),
2203
                (drbdDefaultMetavg, VTypeString),
2204
                (drbdDiskCustom, VTypeString),
2205
                (drbdNetCustom, VTypeString),
2206
                (drbdProtocol, VTypeString),
2207
                (drbdDynamicResync, VTypeBool),
2208
                (drbdPlanAhead, VTypeInt),
2209
                (drbdFillTarget, VTypeInt),
2210
                (drbdDelayTarget, VTypeInt),
2211
                (drbdMaxRate, VTypeInt),
2212
                (drbdMinRate, VTypeInt),
2213
                (lvStripes, VTypeInt),
2214
                (rbdAccess, VTypeString),
2215
                (rbdPool, VTypeString),
2216
                (glusterHost, VTypeString),
2217
                (glusterVolume, VTypeString),
2218
                (glusterPort, VTypeInt)
2219
               ]
2220

    
2221
diskDtParameters :: FrozenSet String
2222
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2223

    
2224
-- * Dynamic disk parameters
2225

    
2226
ddpLocalIp :: String
2227
ddpLocalIp = "local-ip"
2228

    
2229
ddpRemoteIp :: String
2230
ddpRemoteIp = "remote-ip"
2231

    
2232
ddpPort :: String
2233
ddpPort = "port"
2234

    
2235
ddpLocalMinor :: String
2236
ddpLocalMinor = "local-minor"
2237

    
2238
ddpRemoteMinor :: String
2239
ddpRemoteMinor = "remote-minor"
2240

    
2241
-- * OOB supported commands
2242

    
2243
oobPowerOn :: String
2244
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2245

    
2246
oobPowerOff :: String
2247
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2248

    
2249
oobPowerCycle :: String
2250
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2251

    
2252
oobPowerStatus :: String
2253
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2254

    
2255
oobHealth :: String
2256
oobHealth = Types.oobCommandToRaw OobHealth
2257

    
2258
oobCommands :: FrozenSet String
2259
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2260

    
2261
oobPowerStatusPowered :: String
2262
oobPowerStatusPowered = "powered"
2263

    
2264
-- | 60 seconds
2265
oobTimeout :: Int
2266
oobTimeout = 60
2267

    
2268
-- | 2 seconds
2269
oobPowerDelay :: Double
2270
oobPowerDelay = 2.0
2271

    
2272
oobStatusCritical :: String
2273
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2274

    
2275
oobStatusOk :: String
2276
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2277

    
2278
oobStatusUnknown :: String
2279
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2280

    
2281
oobStatusWarning :: String
2282
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2283

    
2284
oobStatuses :: FrozenSet String
2285
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2286

    
2287
-- | Instance Parameters Profile
2288
ppDefault :: String
2289
ppDefault = "default"
2290

    
2291
-- * nic* constants are used inside the ganeti config
2292

    
2293
nicLink :: String
2294
nicLink = "link"
2295

    
2296
nicMode :: String
2297
nicMode = "mode"
2298

    
2299
nicVlan :: String
2300
nicVlan = "vlan"
2301

    
2302
nicsParameterTypes :: Map String VType
2303
nicsParameterTypes =
2304
  Map.fromList [(nicMode, vtypeString),
2305
                (nicLink, vtypeString),
2306
                (nicVlan, vtypeString)]
2307

    
2308
nicsParameters :: FrozenSet String
2309
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2310

    
2311
nicModeBridged :: String
2312
nicModeBridged = Types.nICModeToRaw NMBridged
2313

    
2314
nicModeRouted :: String
2315
nicModeRouted = Types.nICModeToRaw NMRouted
2316

    
2317
nicModeOvs :: String
2318
nicModeOvs = Types.nICModeToRaw NMOvs
2319

    
2320
nicIpPool :: String
2321
nicIpPool = Types.nICModeToRaw NMPool
2322

    
2323
nicValidModes :: FrozenSet String
2324
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2325

    
2326
releaseAction :: String
2327
releaseAction = "release"
2328

    
2329
reserveAction :: String
2330
reserveAction = "reserve"
2331

    
2332
-- * idisk* constants are used in opcodes, to create/change disks
2333

    
2334
idiskAdopt :: String
2335
idiskAdopt = "adopt"
2336

    
2337
idiskMetavg :: String
2338
idiskMetavg = "metavg"
2339

    
2340
idiskMode :: String
2341
idiskMode = "mode"
2342

    
2343
idiskName :: String
2344
idiskName = "name"
2345

    
2346
idiskSize :: String
2347
idiskSize = "size"
2348

    
2349
idiskSpindles :: String
2350
idiskSpindles = "spindles"
2351

    
2352
idiskVg :: String
2353
idiskVg = "vg"
2354

    
2355
idiskProvider :: String
2356
idiskProvider = "provider"
2357

    
2358
idiskParamsTypes :: Map String VType
2359
idiskParamsTypes =
2360
  Map.fromList [(idiskSize, VTypeSize),
2361
                (idiskSpindles, VTypeInt),
2362
                (idiskMode, VTypeString),
2363
                (idiskAdopt, VTypeString),
2364
                (idiskVg, VTypeString),
2365
                (idiskMetavg, VTypeString),
2366
                (idiskProvider, VTypeString),
2367
                (idiskName, VTypeMaybeString)]
2368

    
2369
idiskParams :: FrozenSet String
2370
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2371

    
2372
modifiableIdiskParamsTypes :: Map String VType
2373
modifiableIdiskParamsTypes =
2374
  Map.fromList [(idiskMode, VTypeString),
2375
                (idiskName, VTypeString)]
2376

    
2377
modifiableIdiskParams :: FrozenSet String
2378
modifiableIdiskParams =
2379
  ConstantUtils.mkSet (Map.keys modifiableIdiskParamsTypes)
2380

    
2381
-- * inic* constants are used in opcodes, to create/change nics
2382

    
2383
inicBridge :: String
2384
inicBridge = "bridge"
2385

    
2386
inicIp :: String
2387
inicIp = "ip"
2388

    
2389
inicLink :: String
2390
inicLink = "link"
2391

    
2392
inicMac :: String
2393
inicMac = "mac"
2394

    
2395
inicMode :: String
2396
inicMode = "mode"
2397

    
2398
inicName :: String
2399
inicName = "name"
2400

    
2401
inicNetwork :: String
2402
inicNetwork = "network"
2403

    
2404
inicVlan :: String
2405
inicVlan = "vlan"
2406

    
2407
inicParamsTypes :: Map String VType
2408
inicParamsTypes =
2409
  Map.fromList [(inicBridge, VTypeMaybeString),
2410
                (inicIp, VTypeMaybeString),
2411
                (inicLink, VTypeString),
2412
                (inicMac, VTypeString),
2413
                (inicMode, VTypeString),
2414
                (inicName, VTypeMaybeString),
2415
                (inicNetwork, VTypeMaybeString),
2416
                (inicVlan, VTypeMaybeString)]
2417

    
2418
inicParams :: FrozenSet String
2419
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2420

    
2421
-- * Hypervisor constants
2422

    
2423
htXenPvm :: String
2424
htXenPvm = Types.hypervisorToRaw XenPvm
2425

    
2426
htFake :: String
2427
htFake = Types.hypervisorToRaw Fake
2428

    
2429
htXenHvm :: String
2430
htXenHvm = Types.hypervisorToRaw XenHvm
2431

    
2432
htKvm :: String
2433
htKvm = Types.hypervisorToRaw Kvm
2434

    
2435
htChroot :: String
2436
htChroot = Types.hypervisorToRaw Chroot
2437

    
2438
htLxc :: String
2439
htLxc = Types.hypervisorToRaw Lxc
2440

    
2441
hyperTypes :: FrozenSet String
2442
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2443

    
2444
htsReqPort :: FrozenSet String
2445
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2446

    
2447
vncBasePort :: Int
2448
vncBasePort = 5900
2449

    
2450
vncDefaultBindAddress :: String
2451
vncDefaultBindAddress = ip4AddressAny
2452

    
2453
-- * NIC types
2454

    
2455
htNicE1000 :: String
2456
htNicE1000 = "e1000"
2457

    
2458
htNicI82551 :: String
2459
htNicI82551 = "i82551"
2460

    
2461
htNicI8259er :: String
2462
htNicI8259er = "i82559er"
2463

    
2464
htNicI85557b :: String
2465
htNicI85557b = "i82557b"
2466

    
2467
htNicNe2kIsa :: String
2468
htNicNe2kIsa = "ne2k_isa"
2469

    
2470
htNicNe2kPci :: String
2471
htNicNe2kPci = "ne2k_pci"
2472

    
2473
htNicParavirtual :: String
2474
htNicParavirtual = "paravirtual"
2475

    
2476
htNicPcnet :: String
2477
htNicPcnet = "pcnet"
2478

    
2479
htNicRtl8139 :: String
2480
htNicRtl8139 = "rtl8139"
2481

    
2482
htHvmValidNicTypes :: FrozenSet String
2483
htHvmValidNicTypes =
2484
  ConstantUtils.mkSet [htNicE1000,
2485
                       htNicNe2kIsa,
2486
                       htNicNe2kPci,
2487
                       htNicParavirtual,
2488
                       htNicRtl8139]
2489

    
2490
htKvmValidNicTypes :: FrozenSet String
2491
htKvmValidNicTypes =
2492
  ConstantUtils.mkSet [htNicE1000,
2493
                       htNicI82551,
2494
                       htNicI8259er,
2495
                       htNicI85557b,
2496
                       htNicNe2kIsa,
2497
                       htNicNe2kPci,
2498
                       htNicParavirtual,
2499
                       htNicPcnet,
2500
                       htNicRtl8139]
2501

    
2502
-- * Vif types
2503

    
2504
-- | Default vif type in xen-hvm
2505
htHvmVifIoemu :: String
2506
htHvmVifIoemu = "ioemu"
2507

    
2508
htHvmVifVif :: String
2509
htHvmVifVif = "vif"
2510

    
2511
htHvmValidVifTypes :: FrozenSet String
2512
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2513

    
2514
-- * Disk types
2515

    
2516
htDiskIde :: String
2517
htDiskIde = "ide"
2518

    
2519
htDiskIoemu :: String
2520
htDiskIoemu = "ioemu"
2521

    
2522
htDiskMtd :: String
2523
htDiskMtd = "mtd"
2524

    
2525
htDiskParavirtual :: String
2526
htDiskParavirtual = "paravirtual"
2527

    
2528
htDiskPflash :: String
2529
htDiskPflash = "pflash"
2530

    
2531
htDiskScsi :: String
2532
htDiskScsi = "scsi"
2533

    
2534
htDiskSd :: String
2535
htDiskSd = "sd"
2536

    
2537
htHvmValidDiskTypes :: FrozenSet String
2538
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2539

    
2540
htKvmValidDiskTypes :: FrozenSet String
2541
htKvmValidDiskTypes =
2542
  ConstantUtils.mkSet [htDiskIde,
2543
                       htDiskMtd,
2544
                       htDiskParavirtual,
2545
                       htDiskPflash,
2546
                       htDiskScsi,
2547
                       htDiskSd]
2548

    
2549
htCacheDefault :: String
2550
htCacheDefault = "default"
2551

    
2552
htCacheNone :: String
2553
htCacheNone = "none"
2554

    
2555
htCacheWback :: String
2556
htCacheWback = "writeback"
2557

    
2558
htCacheWthrough :: String
2559
htCacheWthrough = "writethrough"
2560

    
2561
htValidCacheTypes :: FrozenSet String
2562
htValidCacheTypes =
2563
  ConstantUtils.mkSet [htCacheDefault,
2564
                       htCacheNone,
2565
                       htCacheWback,
2566
                       htCacheWthrough]
2567

    
2568
-- * Mouse types
2569

    
2570
htMouseMouse :: String
2571
htMouseMouse = "mouse"
2572

    
2573
htMouseTablet :: String
2574
htMouseTablet = "tablet"
2575

    
2576
htKvmValidMouseTypes :: FrozenSet String
2577
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2578

    
2579
-- * Boot order
2580

    
2581
htBoCdrom :: String
2582
htBoCdrom = "cdrom"
2583

    
2584
htBoDisk :: String
2585
htBoDisk = "disk"
2586

    
2587
htBoFloppy :: String
2588
htBoFloppy = "floppy"
2589

    
2590
htBoNetwork :: String
2591
htBoNetwork = "network"
2592

    
2593
htKvmValidBoTypes :: FrozenSet String
2594
htKvmValidBoTypes =
2595
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2596

    
2597
-- * SPICE lossless image compression options
2598

    
2599
htKvmSpiceLosslessImgComprAutoGlz :: String
2600
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2601

    
2602
htKvmSpiceLosslessImgComprAutoLz :: String
2603
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2604

    
2605
htKvmSpiceLosslessImgComprGlz :: String
2606
htKvmSpiceLosslessImgComprGlz = "glz"
2607

    
2608
htKvmSpiceLosslessImgComprLz :: String
2609
htKvmSpiceLosslessImgComprLz = "lz"
2610

    
2611
htKvmSpiceLosslessImgComprOff :: String
2612
htKvmSpiceLosslessImgComprOff = "off"
2613

    
2614
htKvmSpiceLosslessImgComprQuic :: String
2615
htKvmSpiceLosslessImgComprQuic = "quic"
2616

    
2617
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2618
htKvmSpiceValidLosslessImgComprOptions =
2619
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2620
                       htKvmSpiceLosslessImgComprAutoLz,
2621
                       htKvmSpiceLosslessImgComprGlz,
2622
                       htKvmSpiceLosslessImgComprLz,
2623
                       htKvmSpiceLosslessImgComprOff,
2624
                       htKvmSpiceLosslessImgComprQuic]
2625

    
2626
htKvmSpiceLossyImgComprAlways :: String
2627
htKvmSpiceLossyImgComprAlways = "always"
2628

    
2629
htKvmSpiceLossyImgComprAuto :: String
2630
htKvmSpiceLossyImgComprAuto = "auto"
2631

    
2632
htKvmSpiceLossyImgComprNever :: String
2633
htKvmSpiceLossyImgComprNever = "never"
2634

    
2635
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2636
htKvmSpiceValidLossyImgComprOptions =
2637
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2638
                       htKvmSpiceLossyImgComprAuto,
2639
                       htKvmSpiceLossyImgComprNever]
2640

    
2641
-- * SPICE video stream detection
2642

    
2643
htKvmSpiceVideoStreamDetectionAll :: String
2644
htKvmSpiceVideoStreamDetectionAll = "all"
2645

    
2646
htKvmSpiceVideoStreamDetectionFilter :: String
2647
htKvmSpiceVideoStreamDetectionFilter = "filter"
2648

    
2649
htKvmSpiceVideoStreamDetectionOff :: String
2650
htKvmSpiceVideoStreamDetectionOff = "off"
2651

    
2652
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2653
htKvmSpiceValidVideoStreamDetectionOptions =
2654
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2655
                       htKvmSpiceVideoStreamDetectionFilter,
2656
                       htKvmSpiceVideoStreamDetectionOff]
2657

    
2658
-- * Security models
2659

    
2660
htSmNone :: String
2661
htSmNone = "none"
2662

    
2663
htSmPool :: String
2664
htSmPool = "pool"
2665

    
2666
htSmUser :: String
2667
htSmUser = "user"
2668

    
2669
htKvmValidSmTypes :: FrozenSet String
2670
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2671

    
2672
-- * Kvm flag values
2673

    
2674
htKvmDisabled :: String
2675
htKvmDisabled = "disabled"
2676

    
2677
htKvmEnabled :: String
2678
htKvmEnabled = "enabled"
2679

    
2680
htKvmFlagValues :: FrozenSet String
2681
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2682

    
2683
-- * Migration type
2684

    
2685
htMigrationLive :: String
2686
htMigrationLive = Types.migrationModeToRaw MigrationLive
2687

    
2688
htMigrationNonlive :: String
2689
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2690

    
2691
htMigrationModes :: FrozenSet String
2692
htMigrationModes =
2693
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2694

    
2695
-- * Cluster verify steps
2696

    
2697
verifyNplusoneMem :: String
2698
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2699

    
2700
verifyOptionalChecks :: FrozenSet String
2701
verifyOptionalChecks =
2702
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2703

    
2704
-- * Cluster Verify error classes
2705

    
2706
cvTcluster :: String
2707
cvTcluster = "cluster"
2708

    
2709
cvTgroup :: String
2710
cvTgroup = "group"
2711

    
2712
cvTnode :: String
2713
cvTnode = "node"
2714

    
2715
cvTinstance :: String
2716
cvTinstance = "instance"
2717

    
2718
-- * Cluster Verify error levels
2719

    
2720
cvWarning :: String
2721
cvWarning = "WARNING"
2722

    
2723
cvError :: String
2724
cvError = "ERROR"
2725

    
2726
-- * Cluster Verify error codes and documentation
2727

    
2728
cvEclustercert :: (String, String, String)
2729
cvEclustercert =
2730
  ("cluster",
2731
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2732
   "Cluster certificate files verification failure")
2733

    
2734
cvEclusterclientcert :: (String, String, String)
2735
cvEclusterclientcert =
2736
  ("cluster",
2737
   Types.cVErrorCodeToRaw CvECLUSTERCLIENTCERT,
2738
   "Cluster client certificate files verification failure")
2739

    
2740
cvEclustercfg :: (String, String, String)
2741
cvEclustercfg =
2742
  ("cluster",
2743
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2744
   "Cluster configuration verification failure")
2745

    
2746
cvEclusterdanglinginst :: (String, String, String)
2747
cvEclusterdanglinginst =
2748
  ("node",
2749
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2750
   "Some instances have a non-existing primary node")
2751

    
2752
cvEclusterdanglingnodes :: (String, String, String)
2753
cvEclusterdanglingnodes =
2754
  ("node",
2755
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2756
   "Some nodes belong to non-existing groups")
2757

    
2758
cvEclusterfilecheck :: (String, String, String)
2759
cvEclusterfilecheck =
2760
  ("cluster",
2761
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2762
   "Cluster configuration verification failure")
2763

    
2764
cvEgroupdifferentpvsize :: (String, String, String)
2765
cvEgroupdifferentpvsize =
2766
  ("group",
2767
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2768
   "PVs in the group have different sizes")
2769

    
2770
cvEinstancebadnode :: (String, String, String)
2771
cvEinstancebadnode =
2772
  ("instance",
2773
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2774
   "Instance marked as running lives on an offline node")
2775

    
2776
cvEinstancedown :: (String, String, String)
2777
cvEinstancedown =
2778
  ("instance",
2779
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2780
   "Instance not running on its primary node")
2781

    
2782
cvEinstancefaultydisk :: (String, String, String)
2783
cvEinstancefaultydisk =
2784
  ("instance",
2785
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2786
   "Impossible to retrieve status for a disk")
2787

    
2788
cvEinstancelayout :: (String, String, String)
2789
cvEinstancelayout =
2790
  ("instance",
2791
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2792
   "Instance has multiple secondary nodes")
2793

    
2794
cvEinstancemissingcfgparameter :: (String, String, String)
2795
cvEinstancemissingcfgparameter =
2796
  ("instance",
2797
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2798
   "A configuration parameter for an instance is missing")
2799

    
2800
cvEinstancemissingdisk :: (String, String, String)
2801
cvEinstancemissingdisk =
2802
  ("instance",
2803
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2804
   "Missing volume on an instance")
2805

    
2806
cvEinstancepolicy :: (String, String, String)
2807
cvEinstancepolicy =
2808
  ("instance",
2809
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2810
   "Instance does not meet policy")
2811

    
2812
cvEinstancesplitgroups :: (String, String, String)
2813
cvEinstancesplitgroups =
2814
  ("instance",
2815
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2816
   "Instance with primary and secondary nodes in different groups")
2817

    
2818
cvEinstanceunsuitablenode :: (String, String, String)
2819
cvEinstanceunsuitablenode =
2820
  ("instance",
2821
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2822
   "Instance running on nodes that are not suitable for it")
2823

    
2824
cvEinstancewrongnode :: (String, String, String)
2825
cvEinstancewrongnode =
2826
  ("instance",
2827
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2828
   "Instance running on the wrong node")
2829

    
2830
cvEnodedrbd :: (String, String, String)
2831
cvEnodedrbd =
2832
  ("node",
2833
   Types.cVErrorCodeToRaw CvENODEDRBD,
2834
   "Error parsing the DRBD status file")
2835

    
2836
cvEnodedrbdhelper :: (String, String, String)
2837
cvEnodedrbdhelper =
2838
  ("node",
2839
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2840
   "Error caused by the DRBD helper")
2841

    
2842
cvEnodedrbdversion :: (String, String, String)
2843
cvEnodedrbdversion =
2844
  ("node",
2845
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2846
   "DRBD version mismatch within a node group")
2847

    
2848
cvEnodefilecheck :: (String, String, String)
2849
cvEnodefilecheck =
2850
  ("node",
2851
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2852
   "Error retrieving the checksum of the node files")
2853

    
2854
cvEnodefilestoragepaths :: (String, String, String)
2855
cvEnodefilestoragepaths =
2856
  ("node",
2857
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2858
   "Detected bad file storage paths")
2859

    
2860
cvEnodefilestoragepathunusable :: (String, String, String)
2861
cvEnodefilestoragepathunusable =
2862
  ("node",
2863
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2864
   "File storage path unusable")
2865

    
2866
cvEnodehooks :: (String, String, String)
2867
cvEnodehooks =
2868
  ("node",
2869
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2870
   "Communication failure in hooks execution")
2871

    
2872
cvEnodehv :: (String, String, String)
2873
cvEnodehv =
2874
  ("node",
2875
   Types.cVErrorCodeToRaw CvENODEHV,
2876
   "Hypervisor parameters verification failure")
2877

    
2878
cvEnodelvm :: (String, String, String)
2879
cvEnodelvm =
2880
  ("node",
2881
   Types.cVErrorCodeToRaw CvENODELVM,
2882
   "LVM-related node error")
2883

    
2884
cvEnoden1 :: (String, String, String)
2885
cvEnoden1 =
2886
  ("node",
2887
   Types.cVErrorCodeToRaw CvENODEN1,
2888
   "Not enough memory to accommodate instance failovers")
2889

    
2890
cvEnodenet :: (String, String, String)
2891
cvEnodenet =
2892
  ("node",
2893
   Types.cVErrorCodeToRaw CvENODENET,
2894
   "Network-related node error")
2895

    
2896
cvEnodeoobpath :: (String, String, String)
2897
cvEnodeoobpath =
2898
  ("node",
2899
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2900
   "Invalid Out Of Band path")
2901

    
2902
cvEnodeorphaninstance :: (String, String, String)
2903
cvEnodeorphaninstance =
2904
  ("node",
2905
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2906
   "Unknown intance running on a node")
2907

    
2908
cvEnodeorphanlv :: (String, String, String)
2909
cvEnodeorphanlv =
2910
  ("node",
2911
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2912
   "Unknown LVM logical volume")
2913

    
2914
cvEnodeos :: (String, String, String)
2915
cvEnodeos =
2916
  ("node",
2917
   Types.cVErrorCodeToRaw CvENODEOS,
2918
   "OS-related node error")
2919

    
2920
cvEnoderpc :: (String, String, String)
2921
cvEnoderpc =
2922
  ("node",
2923
   Types.cVErrorCodeToRaw CvENODERPC,
2924
   "Error during connection to the primary node of an instance")
2925

    
2926
cvEnodesetup :: (String, String, String)
2927
cvEnodesetup =
2928
  ("node",
2929
   Types.cVErrorCodeToRaw CvENODESETUP,
2930
   "Node setup error")
2931

    
2932
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2933
cvEnodesharedfilestoragepathunusable =
2934
  ("node",
2935
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2936
   "Shared file storage path unusable")
2937

    
2938
cvEnodessh :: (String, String, String)
2939
cvEnodessh =
2940
  ("node",
2941
   Types.cVErrorCodeToRaw CvENODESSH,
2942
   "SSH-related node error")
2943

    
2944
cvEnodetime :: (String, String, String)
2945
cvEnodetime =
2946
  ("node",
2947
   Types.cVErrorCodeToRaw CvENODETIME,
2948
   "Node returned invalid time")
2949

    
2950
cvEnodeuserscripts :: (String, String, String)
2951
cvEnodeuserscripts =
2952
  ("node",
2953
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2954
   "User scripts not present or not executable")
2955

    
2956
cvEnodeversion :: (String, String, String)
2957
cvEnodeversion =
2958
  ("node",
2959
   Types.cVErrorCodeToRaw CvENODEVERSION,
2960
   "Protocol version mismatch or Ganeti version mismatch")
2961

    
2962
cvAllEcodes :: FrozenSet (String, String, String)
2963
cvAllEcodes =
2964
  ConstantUtils.mkSet
2965
  [cvEclustercert,
2966
   cvEclustercfg,
2967
   cvEclusterdanglinginst,
2968
   cvEclusterdanglingnodes,
2969
   cvEclusterfilecheck,
2970
   cvEgroupdifferentpvsize,
2971
   cvEinstancebadnode,
2972
   cvEinstancedown,
2973
   cvEinstancefaultydisk,
2974
   cvEinstancelayout,
2975
   cvEinstancemissingcfgparameter,
2976
   cvEinstancemissingdisk,
2977
   cvEinstancepolicy,
2978
   cvEinstancesplitgroups,
2979
   cvEinstanceunsuitablenode,
2980
   cvEinstancewrongnode,
2981
   cvEnodedrbd,
2982
   cvEnodedrbdhelper,
2983
   cvEnodedrbdversion,
2984
   cvEnodefilecheck,
2985
   cvEnodefilestoragepaths,
2986
   cvEnodefilestoragepathunusable,
2987
   cvEnodehooks,
2988
   cvEnodehv,
2989
   cvEnodelvm,
2990
   cvEnoden1,
2991
   cvEnodenet,
2992
   cvEnodeoobpath,
2993
   cvEnodeorphaninstance,
2994
   cvEnodeorphanlv,
2995
   cvEnodeos,
2996
   cvEnoderpc,
2997
   cvEnodesetup,
2998
   cvEnodesharedfilestoragepathunusable,
2999
   cvEnodessh,
3000
   cvEnodetime,
3001
   cvEnodeuserscripts,
3002
   cvEnodeversion]
3003

    
3004
cvAllEcodesStrings :: FrozenSet String
3005
cvAllEcodesStrings =
3006
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
3007

    
3008
-- * Node verify constants
3009

    
3010
nvBridges :: String
3011
nvBridges = "bridges"
3012

    
3013
nvClientCert :: String
3014
nvClientCert = "client-cert"
3015

    
3016
nvDrbdhelper :: String
3017
nvDrbdhelper = "drbd-helper"
3018

    
3019
nvDrbdversion :: String
3020
nvDrbdversion = "drbd-version"
3021

    
3022
nvDrbdlist :: String
3023
nvDrbdlist = "drbd-list"
3024

    
3025
nvExclusivepvs :: String
3026
nvExclusivepvs = "exclusive-pvs"
3027

    
3028
nvFilelist :: String
3029
nvFilelist = "filelist"
3030

    
3031
nvAcceptedStoragePaths :: String
3032
nvAcceptedStoragePaths = "allowed-file-storage-paths"
3033

    
3034
nvFileStoragePath :: String
3035
nvFileStoragePath = "file-storage-path"
3036

    
3037
nvSharedFileStoragePath :: String
3038
nvSharedFileStoragePath = "shared-file-storage-path"
3039

    
3040
nvHvinfo :: String
3041
nvHvinfo = "hvinfo"
3042

    
3043
nvHvparams :: String
3044
nvHvparams = "hvparms"
3045

    
3046
nvHypervisor :: String
3047
nvHypervisor = "hypervisor"
3048

    
3049
nvInstancelist :: String
3050
nvInstancelist = "instancelist"
3051

    
3052
nvLvlist :: String
3053
nvLvlist = "lvlist"
3054

    
3055
nvMasterip :: String
3056
nvMasterip = "master-ip"
3057

    
3058
nvNodelist :: String
3059
nvNodelist = "nodelist"
3060

    
3061
nvNodenettest :: String
3062
nvNodenettest = "node-net-test"
3063

    
3064
nvNodesetup :: String
3065
nvNodesetup = "nodesetup"
3066

    
3067
nvOobPaths :: String
3068
nvOobPaths = "oob-paths"
3069

    
3070
nvOslist :: String
3071
nvOslist = "oslist"
3072

    
3073
nvPvlist :: String
3074
nvPvlist = "pvlist"
3075

    
3076
nvTime :: String
3077
nvTime = "time"
3078

    
3079
nvUserscripts :: String
3080
nvUserscripts = "user-scripts"
3081

    
3082
nvVersion :: String
3083
nvVersion = "version"
3084

    
3085
nvVglist :: String
3086
nvVglist = "vglist"
3087

    
3088
nvVmnodes :: String
3089
nvVmnodes = "vmnodes"
3090

    
3091
-- * Instance status
3092

    
3093
inststAdmindown :: String
3094
inststAdmindown = Types.instanceStatusToRaw StatusDown
3095

    
3096
inststAdminoffline :: String
3097
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3098

    
3099
inststErrordown :: String
3100
inststErrordown = Types.instanceStatusToRaw ErrorDown
3101

    
3102
inststErrorup :: String
3103
inststErrorup = Types.instanceStatusToRaw ErrorUp
3104

    
3105
inststNodedown :: String
3106
inststNodedown = Types.instanceStatusToRaw NodeDown
3107

    
3108
inststNodeoffline :: String
3109
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3110

    
3111
inststRunning :: String
3112
inststRunning = Types.instanceStatusToRaw Running
3113

    
3114
inststUserdown :: String
3115
inststUserdown = Types.instanceStatusToRaw UserDown
3116

    
3117
inststWrongnode :: String
3118
inststWrongnode = Types.instanceStatusToRaw WrongNode
3119

    
3120
inststAll :: FrozenSet String
3121
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3122

    
3123
-- * Admin states
3124

    
3125
adminstDown :: String
3126
adminstDown = Types.adminStateToRaw AdminDown
3127

    
3128
adminstOffline :: String
3129
adminstOffline = Types.adminStateToRaw AdminOffline
3130

    
3131
adminstUp :: String
3132
adminstUp = Types.adminStateToRaw AdminUp
3133

    
3134
adminstAll :: FrozenSet String
3135
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3136

    
3137
-- * Node roles
3138

    
3139
nrDrained :: String
3140
nrDrained = Types.nodeRoleToRaw NRDrained
3141

    
3142
nrMaster :: String
3143
nrMaster = Types.nodeRoleToRaw NRMaster
3144

    
3145
nrMcandidate :: String
3146
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3147

    
3148
nrOffline :: String
3149
nrOffline = Types.nodeRoleToRaw NROffline
3150

    
3151
nrRegular :: String
3152
nrRegular = Types.nodeRoleToRaw NRRegular
3153

    
3154
nrAll :: FrozenSet String
3155
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3156

    
3157
-- * SSL certificate check constants (in days)
3158

    
3159
sslCertExpirationError :: Int
3160
sslCertExpirationError = 7
3161

    
3162
sslCertExpirationWarn :: Int
3163
sslCertExpirationWarn = 30
3164

    
3165
-- * Allocator framework constants
3166

    
3167
iallocatorVersion :: Int
3168
iallocatorVersion = 2
3169

    
3170
iallocatorDirIn :: String
3171
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3172

    
3173
iallocatorDirOut :: String
3174
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3175

    
3176
validIallocatorDirections :: FrozenSet String
3177
validIallocatorDirections =
3178
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3179

    
3180
iallocatorModeAlloc :: String
3181
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3182

    
3183
iallocatorModeChgGroup :: String
3184
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3185

    
3186
iallocatorModeMultiAlloc :: String
3187
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3188

    
3189
iallocatorModeNodeEvac :: String
3190
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3191

    
3192
iallocatorModeReloc :: String
3193
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3194

    
3195
validIallocatorModes :: FrozenSet String
3196
validIallocatorModes =
3197
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3198

    
3199
iallocatorSearchPath :: [String]
3200
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3201

    
3202
defaultIallocatorShortcut :: String
3203
defaultIallocatorShortcut = "."
3204

    
3205
-- * Node evacuation
3206

    
3207
nodeEvacPri :: String
3208
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3209

    
3210
nodeEvacSec :: String
3211
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3212

    
3213
nodeEvacAll :: String
3214
nodeEvacAll = Types.evacModeToRaw ChangeAll
3215

    
3216
nodeEvacModes :: FrozenSet String
3217
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3218

    
3219
-- * Job queue
3220

    
3221
jobQueueVersion :: Int
3222
jobQueueVersion = 1
3223

    
3224
jobQueueSizeHardLimit :: Int
3225
jobQueueSizeHardLimit = 5000
3226

    
3227
jobQueueFilesPerms :: Int
3228
jobQueueFilesPerms = 0o640
3229

    
3230
-- * Unchanged job return
3231

    
3232
jobNotchanged :: String
3233
jobNotchanged = "nochange"
3234

    
3235
-- * Job status
3236

    
3237
jobStatusQueued :: String
3238
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3239

    
3240
jobStatusWaiting :: String
3241
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3242

    
3243
jobStatusCanceling :: String
3244
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3245

    
3246
jobStatusRunning :: String
3247
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3248

    
3249
jobStatusCanceled :: String
3250
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3251

    
3252
jobStatusSuccess :: String
3253
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3254

    
3255
jobStatusError :: String
3256
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3257

    
3258
jobsPending :: FrozenSet String
3259
jobsPending =
3260
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3261

    
3262
jobsFinalized :: FrozenSet String
3263
jobsFinalized =
3264
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3265

    
3266
jobStatusAll :: FrozenSet String
3267
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3268

    
3269
-- * OpCode status
3270

    
3271
-- ** Not yet finalized opcodes
3272

    
3273
opStatusCanceling :: String
3274
opStatusCanceling = "canceling"
3275

    
3276
opStatusQueued :: String
3277
opStatusQueued = "queued"
3278

    
3279
opStatusRunning :: String
3280
opStatusRunning = "running"
3281

    
3282
opStatusWaiting :: String
3283
opStatusWaiting = "waiting"
3284

    
3285
-- ** Finalized opcodes
3286

    
3287
opStatusCanceled :: String
3288
opStatusCanceled = "canceled"
3289

    
3290
opStatusError :: String
3291
opStatusError = "error"
3292

    
3293
opStatusSuccess :: String
3294
opStatusSuccess = "success"
3295

    
3296
opsFinalized :: FrozenSet String
3297
opsFinalized =
3298
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3299

    
3300
-- * OpCode priority
3301

    
3302
opPrioLowest :: Int
3303
opPrioLowest = 19
3304

    
3305
opPrioHighest :: Int
3306
opPrioHighest = -20
3307

    
3308
opPrioLow :: Int
3309
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3310

    
3311
opPrioNormal :: Int
3312
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3313

    
3314
opPrioHigh :: Int
3315
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3316

    
3317
opPrioSubmitValid :: FrozenSet Int
3318
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3319

    
3320
opPrioDefault :: Int
3321
opPrioDefault = opPrioNormal
3322

    
3323
-- * Lock recalculate mode
3324

    
3325
locksAppend :: String
3326
locksAppend = "append"
3327

    
3328
locksReplace :: String
3329
locksReplace = "replace"
3330

    
3331
-- * Lock timeout
3332
--
3333
-- The lock timeout (sum) before we transition into blocking acquire
3334
-- (this can still be reset by priority change).  Computed as max time
3335
-- (10 hours) before we should actually go into blocking acquire,
3336
-- given that we start from the default priority level.
3337

    
3338
lockAttemptsMaxwait :: Double
3339
lockAttemptsMaxwait = 15.0
3340

    
3341
lockAttemptsMinwait :: Double
3342
lockAttemptsMinwait = 1.0
3343

    
3344
lockAttemptsTimeout :: Int
3345
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3346

    
3347
-- * Execution log types
3348

    
3349
elogMessage :: String
3350
elogMessage = Types.eLogTypeToRaw ELogMessage
3351

    
3352
elogRemoteImport :: String
3353
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3354

    
3355
elogJqueueTest :: String
3356
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3357

    
3358
-- * /etc/hosts modification
3359

    
3360
etcHostsAdd :: String
3361
etcHostsAdd = "add"
3362

    
3363
etcHostsRemove :: String
3364
etcHostsRemove = "remove"
3365

    
3366
-- * Job queue test
3367

    
3368
jqtMsgprefix :: String
3369
jqtMsgprefix = "TESTMSG="
3370

    
3371
jqtExec :: String
3372
jqtExec = "exec"
3373

    
3374
jqtExpandnames :: String
3375
jqtExpandnames = "expandnames"
3376

    
3377
jqtLogmsg :: String
3378
jqtLogmsg = "logmsg"
3379

    
3380
jqtStartmsg :: String
3381
jqtStartmsg = "startmsg"
3382

    
3383
jqtAll :: FrozenSet String
3384
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3385

    
3386
-- * Query resources
3387

    
3388
qrCluster :: String
3389
qrCluster = "cluster"
3390

    
3391
qrExport :: String
3392
qrExport = "export"
3393

    
3394
qrExtstorage :: String
3395
qrExtstorage = "extstorage"
3396

    
3397
qrGroup :: String
3398
qrGroup = "group"
3399

    
3400
qrInstance :: String
3401
qrInstance = "instance"
3402

    
3403
qrJob :: String
3404
qrJob = "job"
3405

    
3406
qrLock :: String
3407
qrLock = "lock"
3408

    
3409
qrNetwork :: String
3410
qrNetwork = "network"
3411

    
3412
qrNode :: String
3413
qrNode = "node"
3414

    
3415
qrOs :: String
3416
qrOs = "os"
3417

    
3418
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3419
qrViaOp :: FrozenSet String
3420
qrViaOp =
3421
  ConstantUtils.mkSet [qrCluster,
3422
                       qrOs,
3423
                       qrExtstorage]
3424

    
3425
-- | List of resources which can be queried using Local UniX Interface
3426
qrViaLuxi :: FrozenSet String
3427
qrViaLuxi = ConstantUtils.mkSet [qrGroup,
3428
                                 qrExport,
3429
                                 qrInstance,
3430
                                 qrJob,
3431
                                 qrLock,
3432
                                 qrNetwork,
3433
                                 qrNode]
3434

    
3435
-- | List of resources which can be queried using RAPI
3436
qrViaRapi :: FrozenSet String
3437
qrViaRapi = qrViaLuxi
3438

    
3439
-- | List of resources which can be queried via RAPI including PUT requests
3440
qrViaRapiPut :: FrozenSet String
3441
qrViaRapiPut = ConstantUtils.mkSet [qrLock, qrJob]
3442

    
3443
-- * Query field types
3444

    
3445
qftBool :: String
3446
qftBool = "bool"
3447

    
3448
qftNumber :: String
3449
qftNumber = "number"
3450

    
3451
qftOther :: String
3452
qftOther = "other"
3453

    
3454
qftText :: String
3455
qftText = "text"
3456

    
3457
qftTimestamp :: String
3458
qftTimestamp = "timestamp"
3459

    
3460
qftUnit :: String
3461
qftUnit = "unit"
3462

    
3463
qftUnknown :: String
3464
qftUnknown = "unknown"
3465

    
3466
qftAll :: FrozenSet String
3467
qftAll =
3468
  ConstantUtils.mkSet [qftBool,
3469
                       qftNumber,
3470
                       qftOther,
3471
                       qftText,
3472
                       qftTimestamp,
3473
                       qftUnit,
3474
                       qftUnknown]
3475

    
3476
-- * Query result field status
3477
--
3478
-- Don't change or reuse values as they're used by clients.
3479
--
3480
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3481

    
3482
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3483
rsNodata :: Int
3484
rsNodata = 2
3485

    
3486
rsNormal :: Int
3487
rsNormal = 0
3488

    
3489
-- | Resource marked offline
3490
rsOffline :: Int
3491
rsOffline = 4
3492

    
3493
-- | Value unavailable/unsupported for item; if this field is
3494
-- supported but we cannot get the data for the moment, 'rsNodata' or
3495
-- 'rsOffline' should be used
3496
rsUnavail :: Int
3497
rsUnavail = 3
3498

    
3499
rsUnknown :: Int
3500
rsUnknown = 1
3501

    
3502
rsAll :: FrozenSet Int
3503
rsAll =
3504
  ConstantUtils.mkSet [rsNodata,
3505
                       rsNormal,
3506
                       rsOffline,
3507
                       rsUnavail,
3508
                       rsUnknown]
3509

    
3510
-- | Special field cases and their verbose/terse formatting
3511
rssDescription :: Map Int (String, String)
3512
rssDescription =
3513
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3514
                (rsNodata, ("(nodata)", "?")),
3515
                (rsOffline, ("(offline)", "*")),
3516
                (rsUnavail, ("(unavail)", "-"))]
3517

    
3518
-- * Max dynamic devices
3519

    
3520
maxDisks :: Int
3521
maxDisks = Types.maxDisks
3522

    
3523
maxNics :: Int
3524
maxNics = Types.maxNics
3525

    
3526
-- | SSCONF file prefix
3527
ssconfFileprefix :: String
3528
ssconfFileprefix = "ssconf_"
3529

    
3530
-- * SSCONF keys
3531

    
3532
ssClusterName :: String
3533
ssClusterName = "cluster_name"
3534

    
3535
ssClusterTags :: String
3536
ssClusterTags = "cluster_tags"
3537

    
3538
ssFileStorageDir :: String
3539
ssFileStorageDir = "file_storage_dir"
3540

    
3541
ssSharedFileStorageDir :: String
3542
ssSharedFileStorageDir = "shared_file_storage_dir"
3543

    
3544
ssGlusterStorageDir :: String
3545
ssGlusterStorageDir = "gluster_storage_dir"
3546

    
3547
ssMasterCandidates :: String
3548
ssMasterCandidates = "master_candidates"
3549

    
3550
ssMasterCandidatesIps :: String
3551
ssMasterCandidatesIps = "master_candidates_ips"
3552

    
3553
ssMasterCandidatesCerts :: String
3554
ssMasterCandidatesCerts = "master_candidates_certs"
3555

    
3556
ssMasterIp :: String
3557
ssMasterIp = "master_ip"
3558

    
3559
ssMasterNetdev :: String
3560
ssMasterNetdev = "master_netdev"
3561

    
3562
ssMasterNetmask :: String
3563
ssMasterNetmask = "master_netmask"
3564

    
3565
ssMasterNode :: String
3566
ssMasterNode = "master_node"
3567

    
3568
ssNodeList :: String
3569
ssNodeList = "node_list"
3570

    
3571
ssNodePrimaryIps :: String
3572
ssNodePrimaryIps = "node_primary_ips"
3573

    
3574
ssNodeSecondaryIps :: String
3575
ssNodeSecondaryIps = "node_secondary_ips"
3576

    
3577
ssOfflineNodes :: String
3578
ssOfflineNodes = "offline_nodes"
3579

    
3580
ssOnlineNodes :: String
3581
ssOnlineNodes = "online_nodes"
3582

    
3583
ssPrimaryIpFamily :: String
3584
ssPrimaryIpFamily = "primary_ip_family"
3585

    
3586
ssInstanceList :: String
3587
ssInstanceList = "instance_list"
3588

    
3589
ssReleaseVersion :: String
3590
ssReleaseVersion = "release_version"
3591

    
3592
ssHypervisorList :: String
3593
ssHypervisorList = "hypervisor_list"
3594

    
3595
ssMaintainNodeHealth :: String
3596
ssMaintainNodeHealth = "maintain_node_health"
3597

    
3598
ssUidPool :: String
3599
ssUidPool = "uid_pool"
3600

    
3601
ssNodegroups :: String
3602
ssNodegroups = "nodegroups"
3603

    
3604
ssNetworks :: String
3605
ssNetworks = "networks"
3606

    
3607
-- | This is not a complete SSCONF key, but the prefix for the
3608
-- hypervisor keys
3609
ssHvparamsPref :: String
3610
ssHvparamsPref = "hvparams_"
3611

    
3612
-- * Hvparams keys
3613

    
3614
ssHvparamsXenChroot :: String
3615
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3616

    
3617
ssHvparamsXenFake :: String
3618
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3619

    
3620
ssHvparamsXenHvm :: String
3621
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3622

    
3623
ssHvparamsXenKvm :: String
3624
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3625

    
3626
ssHvparamsXenLxc :: String
3627
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3628

    
3629
ssHvparamsXenPvm :: String
3630
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3631

    
3632
validSsHvparamsKeys :: FrozenSet String
3633
validSsHvparamsKeys =
3634
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3635
                       ssHvparamsXenLxc,
3636
                       ssHvparamsXenFake,
3637
                       ssHvparamsXenHvm,
3638
                       ssHvparamsXenKvm,
3639
                       ssHvparamsXenPvm]
3640

    
3641
ssFilePerms :: Int
3642
ssFilePerms = 0o444
3643

    
3644
-- | Cluster wide default parameters
3645
defaultEnabledHypervisor :: String
3646
defaultEnabledHypervisor = htXenPvm
3647

    
3648
hvcDefaults :: Map Hypervisor (Map String PyValueEx)
3649
hvcDefaults =
3650
  Map.fromList
3651
  [ (XenPvm, Map.fromList
3652
             [ (hvUseBootloader,  PyValueEx False)
3653
             , (hvBootloaderPath, PyValueEx xenBootloader)
3654
             , (hvBootloaderArgs, PyValueEx "")
3655
             , (hvKernelPath,     PyValueEx xenKernel)
3656
             , (hvInitrdPath,     PyValueEx "")
3657
             , (hvRootPath,       PyValueEx "/dev/xvda1")
3658
             , (hvKernelArgs,     PyValueEx "ro")
3659
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3660
             , (hvMigrationMode,  PyValueEx htMigrationLive)
3661
             , (hvBlockdevPrefix, PyValueEx "sd")
3662
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3663
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3664
             , (hvCpuCap,         PyValueEx (0 :: Int))
3665
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3666
             , (hvVifScript,      PyValueEx "")
3667
             , (hvXenCmd,         PyValueEx xenCmdXm)
3668
             , (hvXenCpuid,       PyValueEx "")
3669
             , (hvSoundhw,        PyValueEx "")
3670
             ])
3671
  , (XenHvm, Map.fromList
3672
             [ (hvBootOrder,      PyValueEx "cd")
3673
             , (hvCdromImagePath, PyValueEx "")
3674
             , (hvNicType,        PyValueEx htNicRtl8139)
3675
             , (hvDiskType,       PyValueEx htDiskParavirtual)
3676
             , (hvVncBindAddress, PyValueEx ip4AddressAny)
3677
             , (hvAcpi,           PyValueEx True)
3678
             , (hvPae,            PyValueEx True)
3679
             , (hvKernelPath,     PyValueEx "/usr/lib/xen/boot/hvmloader")
3680
             , (hvDeviceModel,    PyValueEx "/usr/lib/xen/bin/qemu-dm")
3681
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3682
             , (hvMigrationMode,  PyValueEx htMigrationNonlive)
3683
             , (hvUseLocaltime,   PyValueEx False)
3684
             , (hvBlockdevPrefix, PyValueEx "hd")
3685
             , (hvPassthrough,    PyValueEx "")
3686
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3687
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3688
             , (hvCpuCap,         PyValueEx (0 :: Int))
3689
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3690
             , (hvVifType,        PyValueEx htHvmVifIoemu)
3691
             , (hvVifScript,      PyValueEx "")
3692
             , (hvViridian,       PyValueEx False)
3693
             , (hvXenCmd,         PyValueEx xenCmdXm)
3694
             , (hvXenCpuid,       PyValueEx "")
3695
             , (hvSoundhw,        PyValueEx "")
3696
             ])
3697
  , (Kvm, Map.fromList
3698
          [ (hvKvmPath,                         PyValueEx kvmPath)
3699
          , (hvKernelPath,                      PyValueEx kvmKernel)
3700
          , (hvInitrdPath,                      PyValueEx "")
3701
          , (hvKernelArgs,                      PyValueEx "ro")
3702
          , (hvRootPath,                        PyValueEx "/dev/vda1")
3703
          , (hvAcpi,                            PyValueEx True)
3704
          , (hvSerialConsole,                   PyValueEx True)
3705
          , (hvSerialSpeed,                     PyValueEx (38400 :: Int))
3706
          , (hvVncBindAddress,                  PyValueEx "")
3707
          , (hvVncTls,                          PyValueEx False)
3708
          , (hvVncX509,                         PyValueEx "")
3709
          , (hvVncX509Verify,                   PyValueEx False)
3710
          , (hvVncPasswordFile,                 PyValueEx "")
3711
          , (hvKvmSpiceBind,                    PyValueEx "")
3712
          , (hvKvmSpiceIpVersion,           PyValueEx ifaceNoIpVersionSpecified)
3713
          , (hvKvmSpicePasswordFile,            PyValueEx "")
3714
          , (hvKvmSpiceLosslessImgCompr,        PyValueEx "")
3715
          , (hvKvmSpiceJpegImgCompr,            PyValueEx "")
3716
          , (hvKvmSpiceZlibGlzImgCompr,         PyValueEx "")
3717
          , (hvKvmSpiceStreamingVideoDetection, PyValueEx "")
3718
          , (hvKvmSpiceAudioCompr,              PyValueEx True)
3719
          , (hvKvmSpiceUseTls,                  PyValueEx False)
3720
          , (hvKvmSpiceTlsCiphers,              PyValueEx opensslCiphers)
3721
          , (hvKvmSpiceUseVdagent,              PyValueEx True)
3722
          , (hvKvmFloppyImagePath,              PyValueEx "")
3723
          , (hvCdromImagePath,                  PyValueEx "")
3724
          , (hvKvmCdrom2ImagePath,              PyValueEx "")
3725
          , (hvBootOrder,                       PyValueEx htBoDisk)
3726
          , (hvNicType,                         PyValueEx htNicParavirtual)
3727
          , (hvDiskType,                        PyValueEx htDiskParavirtual)
3728
          , (hvKvmCdromDiskType,                PyValueEx "")
3729
          , (hvUsbMouse,                        PyValueEx "")
3730
          , (hvKeymap,                          PyValueEx "")
3731
          , (hvMigrationPort,                   PyValueEx (8102 :: Int))
3732
          , (hvMigrationBandwidth,              PyValueEx (32 :: Int))
3733
          , (hvMigrationDowntime,               PyValueEx (30 :: Int))
3734
          , (hvMigrationMode,                   PyValueEx htMigrationLive)
3735
          , (hvUseLocaltime,                    PyValueEx False)
3736
          , (hvDiskCache,                       PyValueEx htCacheDefault)
3737
          , (hvSecurityModel,                   PyValueEx htSmNone)
3738
          , (hvSecurityDomain,                  PyValueEx "")
3739
          , (hvKvmFlag,                         PyValueEx "")
3740
          , (hvVhostNet,                        PyValueEx False)
3741
          , (hvKvmUseChroot,                    PyValueEx False)
3742
          , (hvKvmUserShutdown,                 PyValueEx False)
3743
          , (hvMemPath,                         PyValueEx "")
3744
          , (hvRebootBehavior,                  PyValueEx instanceRebootAllowed)
3745
          , (hvCpuMask,                         PyValueEx cpuPinningAll)
3746
          , (hvCpuType,                         PyValueEx "")
3747
          , (hvCpuCores,                        PyValueEx (0 :: Int))
3748
          , (hvCpuThreads,                      PyValueEx (0 :: Int))
3749
          , (hvCpuSockets,                      PyValueEx (0 :: Int))
3750
          , (hvSoundhw,                         PyValueEx "")
3751
          , (hvUsbDevices,                      PyValueEx "")
3752
          , (hvVga,                             PyValueEx "")
3753
          , (hvKvmExtra,                        PyValueEx "")
3754
          , (hvKvmMachineVersion,               PyValueEx "")
3755
          , (hvVnetHdr,                         PyValueEx True)])
3756
  , (Fake, Map.fromList [(hvMigrationMode, PyValueEx htMigrationLive)])
3757
  , (Chroot, Map.fromList [(hvInitScript, PyValueEx "/ganeti-chroot")])
3758
  , (Lxc, Map.fromList [(hvCpuMask, PyValueEx "")])
3759
  ]
3760

    
3761
hvcGlobals :: FrozenSet String
3762
hvcGlobals =
3763
  ConstantUtils.mkSet [hvMigrationBandwidth,
3764
                       hvMigrationMode,
3765
                       hvMigrationPort,
3766
                       hvXenCmd]
3767

    
3768
becDefaults :: Map String PyValueEx
3769
becDefaults =
3770
  Map.fromList
3771
  [ (beMinmem, PyValueEx (128 :: Int))
3772
  , (beMaxmem, PyValueEx (128 :: Int))
3773
  , (beVcpus, PyValueEx (1 :: Int))
3774
  , (beAutoBalance, PyValueEx True)
3775
  , (beAlwaysFailover, PyValueEx False)
3776
  , (beSpindleUse, PyValueEx (1 :: Int))
3777
  ]
3778

    
3779
ndcDefaults :: Map String PyValueEx
3780
ndcDefaults =
3781
  Map.fromList
3782
  [ (ndOobProgram,       PyValueEx "")
3783
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3784
  , (ndExclusiveStorage, PyValueEx False)
3785
  , (ndOvs,              PyValueEx False)
3786
  , (ndOvsName,          PyValueEx defaultOvs)
3787
  , (ndOvsLink,          PyValueEx "")
3788
  , (ndSshPort,          PyValueEx (22 :: Int))
3789
  ]
3790

    
3791
ndcGlobals :: FrozenSet String
3792
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3793

    
3794
-- | Default delay target measured in sectors
3795
defaultDelayTarget :: Int
3796
defaultDelayTarget = 1
3797

    
3798
defaultDiskCustom :: String
3799
defaultDiskCustom = ""
3800

    
3801
defaultDiskResync :: Bool
3802
defaultDiskResync = False
3803

    
3804
-- | Default fill target measured in sectors
3805
defaultFillTarget :: Int
3806
defaultFillTarget = 0
3807

    
3808
-- | Default mininum rate measured in KiB/s
3809
defaultMinRate :: Int
3810
defaultMinRate = 4 * 1024
3811

    
3812
defaultNetCustom :: String
3813
defaultNetCustom = ""
3814

    
3815
-- | Default plan ahead measured in sectors
3816
--
3817
-- The default values for the DRBD dynamic resync speed algorithm are
3818
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3819
-- (that we don't need to set to 0, because we have a separate option
3820
-- to enable it) and for c-max-rate, that we cap to the default value
3821
-- for the static resync rate.
3822
defaultPlanAhead :: Int
3823
defaultPlanAhead = 20
3824

    
3825
defaultRbdPool :: String
3826
defaultRbdPool = "rbd"
3827

    
3828
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3829
diskLdDefaults =
3830
  Map.fromList
3831
  [ (DTBlock, Map.empty)
3832
  , (DTDrbd8, Map.fromList
3833
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3834
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3835
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3836
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3837
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3838
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3839
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3840
              , (ldpMinRate,       PyValueEx defaultMinRate)
3841
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3842
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3843
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3844
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3845
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3846
              ])
3847
  , (DTExt, Map.empty)
3848
  , (DTFile, Map.empty)
3849
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3850
  , (DTRbd, Map.fromList
3851
            [ (ldpPool, PyValueEx defaultRbdPool)
3852
            , (ldpAccess, PyValueEx diskKernelspace)
3853
            ])
3854
  , (DTSharedFile, Map.empty)
3855
  , (DTGluster, Map.fromList
3856
                [ (rbdAccess, PyValueEx diskKernelspace)
3857
                , (glusterHost, PyValueEx glusterHostDefault)
3858
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3859
                , (glusterPort, PyValueEx glusterPortDefault)
3860
                ])
3861
  ]
3862

    
3863
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3864
diskDtDefaults =
3865
  Map.fromList
3866
  [ (DTBlock,      Map.empty)
3867
  , (DTDiskless,   Map.empty)
3868
  , (DTDrbd8,      Map.fromList
3869
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3870
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3871
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3872
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3873
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3874
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3875
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3876
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3877
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3878
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3879
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3880
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3881
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3882
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3883
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3884
                   ])
3885
  , (DTExt,        Map.empty)
3886
  , (DTFile,       Map.empty)
3887
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3888
  , (DTRbd,        Map.fromList
3889
                   [ (rbdPool, PyValueEx defaultRbdPool)
3890
                   , (rbdAccess, PyValueEx diskKernelspace)
3891
                   ])
3892
  , (DTSharedFile, Map.empty)
3893
  , (DTGluster, Map.fromList
3894
                [ (rbdAccess, PyValueEx diskKernelspace)
3895
                , (glusterHost, PyValueEx glusterHostDefault)
3896
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3897
                , (glusterPort, PyValueEx glusterPortDefault)
3898
                ])
3899
  ]
3900

    
3901
niccDefaults :: Map String PyValueEx
3902
niccDefaults =
3903
  Map.fromList
3904
  [ (nicMode, PyValueEx nicModeBridged)
3905
  , (nicLink, PyValueEx defaultBridge)
3906
  , (nicVlan, PyValueEx "")
3907
  ]
3908

    
3909
-- | All of the following values are quite arbitrary - there are no
3910
-- "good" defaults, these must be customised per-site
3911
ispecsMinmaxDefaults :: Map String (Map String Int)
3912
ispecsMinmaxDefaults =
3913
  Map.fromList
3914
  [(ispecsMin,
3915
    Map.fromList
3916
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3917
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3918
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3919
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3920
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3921
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3922
   (ispecsMax,
3923
    Map.fromList
3924
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3925
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3926
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3927
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3928
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3929
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3930

    
3931
ipolicyDefaults :: Map String PyValueEx
3932
ipolicyDefaults =
3933
  Map.fromList
3934
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3935
  , (ispecsStd,           PyValueEx (Map.fromList
3936
                                     [ (ispecMemSize,    128)
3937
                                     , (ispecCpuCount,   1)
3938
                                     , (ispecDiskCount,  1)
3939
                                     , (ispecDiskSize,   1024)
3940
                                     , (ispecNicCount,   1)
3941
                                     , (ispecSpindleUse, 1)
3942
                                     ] :: Map String Int))
3943
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3944
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3945
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3946
  ]
3947

    
3948
masterPoolSizeDefault :: Int
3949
masterPoolSizeDefault = 10
3950

    
3951
-- * Exclusive storage
3952

    
3953
-- | Error margin used to compare physical disks
3954
partMargin :: Double
3955
partMargin = 0.01
3956

    
3957
-- | Space reserved when creating instance disks
3958
partReserved :: Double
3959
partReserved = 0.02
3960

    
3961
-- * Luxid job scheduling
3962

    
3963
-- | Time intervall in seconds for polling updates on the job queue. This
3964
-- intervall is only relevant if the number of running jobs reaches the maximal
3965
-- allowed number, as otherwise new jobs will be started immediately anyway.
3966
-- Also, as jobs are watched via inotify, scheduling usually works independent
3967
-- of polling. Therefore we chose a sufficiently large interval, in the order of
3968
-- 5 minutes. As with the interval for reloading the configuration, we chose a
3969
-- prime number to avoid accidental 'same wakeup' with other processes.
3970
luxidJobqueuePollInterval :: Int
3971
luxidJobqueuePollInterval = 307
3972

    
3973
-- | The default value for the maximal number of jobs to be running at the same
3974
-- time. Once the maximal number is reached, new jobs will just be queued and
3975
-- only started, once some of the other jobs have finished.
3976
luxidMaximalRunningJobsDefault :: Int
3977
luxidMaximalRunningJobsDefault = 20
3978

    
3979
-- * Confd
3980

    
3981
confdProtocolVersion :: Int
3982
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3983

    
3984
-- Confd request type
3985

    
3986
confdReqPing :: Int
3987
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3988

    
3989
confdReqNodeRoleByname :: Int
3990
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3991

    
3992
confdReqNodePipByInstanceIp :: Int
3993
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3994

    
3995
confdReqClusterMaster :: Int
3996
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3997

    
3998
confdReqNodePipList :: Int
3999
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
4000

    
4001
confdReqMcPipList :: Int
4002
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
4003

    
4004
confdReqInstancesIpsList :: Int
4005
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
4006

    
4007
confdReqNodeDrbd :: Int
4008
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
4009

    
4010
confdReqNodeInstances :: Int
4011
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
4012

    
4013
confdReqs :: FrozenSet Int
4014
confdReqs =
4015
  ConstantUtils.mkSet .
4016
  map Types.confdRequestTypeToRaw $
4017
  [minBound..] \\ [ReqNodeInstances]
4018

    
4019
-- * Confd request type
4020

    
4021
confdReqfieldName :: Int
4022
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
4023

    
4024
confdReqfieldIp :: Int
4025
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
4026

    
4027
confdReqfieldMnodePip :: Int
4028
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
4029

    
4030
-- * Confd repl status
4031

    
4032
confdReplStatusOk :: Int
4033
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
4034

    
4035
confdReplStatusError :: Int
4036
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
4037

    
4038
confdReplStatusNotimplemented :: Int
4039
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
4040

    
4041
confdReplStatuses :: FrozenSet Int
4042
confdReplStatuses =
4043
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
4044

    
4045
-- * Confd node role
4046

    
4047
confdNodeRoleMaster :: Int
4048
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
4049

    
4050
confdNodeRoleCandidate :: Int
4051
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
4052

    
4053
confdNodeRoleOffline :: Int
4054
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
4055

    
4056
confdNodeRoleDrained :: Int
4057
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
4058

    
4059
confdNodeRoleRegular :: Int
4060
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
4061

    
4062
-- * A few common errors for confd
4063

    
4064
confdErrorUnknownEntry :: Int
4065
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
4066

    
4067
confdErrorInternal :: Int
4068
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
4069

    
4070
confdErrorArgument :: Int
4071
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
4072

    
4073
-- * Confd request query fields
4074

    
4075
confdReqqLink :: String
4076
confdReqqLink = ConstantUtils.confdReqqLink
4077

    
4078
confdReqqIp :: String
4079
confdReqqIp = ConstantUtils.confdReqqIp
4080

    
4081
confdReqqIplist :: String
4082
confdReqqIplist = ConstantUtils.confdReqqIplist
4083

    
4084
confdReqqFields :: String
4085
confdReqqFields = ConstantUtils.confdReqqFields
4086

    
4087
-- | Each request is "salted" by the current timestamp.
4088
--
4089
-- This constant decides how many seconds of skew to accept.
4090
--
4091
-- TODO: make this a default and allow the value to be more
4092
-- configurable
4093
confdMaxClockSkew :: Int
4094
confdMaxClockSkew = 2 * nodeMaxClockSkew
4095

    
4096
-- | When we haven't reloaded the config for more than this amount of
4097
-- seconds, we force a test to see if inotify is betraying us. Using a
4098
-- prime number to ensure we get less chance of 'same wakeup' with
4099
-- other processes.
4100
confdConfigReloadTimeout :: Int
4101
confdConfigReloadTimeout = 17
4102

    
4103
-- | If we receive more than one update in this amount of
4104
-- microseconds, we move to polling every RATELIMIT seconds, rather
4105
-- than relying on inotify, to be able to serve more requests.
4106
confdConfigReloadRatelimit :: Int
4107
confdConfigReloadRatelimit = 250000
4108

    
4109
-- | Magic number prepended to all confd queries.
4110
--
4111
-- This allows us to distinguish different types of confd protocols
4112
-- and handle them. For example by changing this we can move the whole
4113
-- payload to be compressed, or move away from json.
4114
confdMagicFourcc :: String
4115
confdMagicFourcc = "plj0"
4116

    
4117
-- | By default a confd request is sent to the minimum between this
4118
-- number and all MCs. 6 was chosen because even in the case of a
4119
-- disastrous 50% response rate, we should have enough answers to be
4120
-- able to compare more than one.
4121
confdDefaultReqCoverage :: Int
4122
confdDefaultReqCoverage = 6
4123

    
4124
-- | Timeout in seconds to expire pending query request in the confd
4125
-- client library. We don't actually expect any answer more than 10
4126
-- seconds after we sent a request.
4127
confdClientExpireTimeout :: Int
4128
confdClientExpireTimeout = 10
4129

    
4130
-- | Maximum UDP datagram size.
4131
--
4132
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4133
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4134
--   (assuming we can't use jumbo frames)
4135
-- We just set this to 60K, which should be enough
4136
maxUdpDataSize :: Int
4137
maxUdpDataSize = 61440
4138

    
4139
-- * User-id pool minimum/maximum acceptable user-ids
4140

    
4141
uidpoolUidMin :: Int
4142
uidpoolUidMin = 0
4143

    
4144
-- | Assuming 32 bit user-ids
4145
uidpoolUidMax :: Integer
4146
uidpoolUidMax = 2 ^ 32 - 1
4147

    
4148
-- | Name or path of the pgrep command
4149
pgrep :: String
4150
pgrep = "pgrep"
4151

    
4152
-- | Name of the node group that gets created at cluster init or
4153
-- upgrade
4154
initialNodeGroupName :: String
4155
initialNodeGroupName = "default"
4156

    
4157
-- * Possible values for NodeGroup.alloc_policy
4158

    
4159
allocPolicyLastResort :: String
4160
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4161

    
4162
allocPolicyPreferred :: String
4163
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4164

    
4165
allocPolicyUnallocable :: String
4166
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4167

    
4168
validAllocPolicies :: [String]
4169
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4170

    
4171
-- | Temporary external/shared storage parameters
4172
blockdevDriverManual :: String
4173
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4174

    
4175
-- | 'qemu-img' path, required for 'ovfconverter'
4176
qemuimgPath :: String
4177
qemuimgPath = AutoConf.qemuimgPath
4178

    
4179
-- | Whether htools was enabled at compilation time
4180
--
4181
-- FIXME: this should be moved next to the other enable constants,
4182
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4183
htools :: Bool
4184
htools = AutoConf.htools
4185

    
4186
-- | The hail iallocator
4187
iallocHail :: String
4188
iallocHail = "hail"
4189

    
4190
-- * Fake opcodes for functions that have hooks attached to them via
4191
-- backend.RunLocalHooks
4192

    
4193
fakeOpMasterTurndown :: String
4194
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4195

    
4196
fakeOpMasterTurnup :: String
4197
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4198

    
4199

    
4200
-- * Crypto Types
4201
-- Types of cryptographic tokens used in node communication
4202

    
4203
cryptoTypeSslDigest :: String
4204
cryptoTypeSslDigest = "ssl"
4205

    
4206
cryptoTypeSsh :: String
4207
cryptoTypeSsh = "ssh"
4208

    
4209
-- So far only ssl keys are used in the context of this constant
4210
cryptoTypes :: FrozenSet String
4211
cryptoTypes = ConstantUtils.mkSet [cryptoTypeSslDigest]
4212

    
4213
-- * Crypto Actions
4214
-- Actions that can be performed on crypto tokens
4215

    
4216
cryptoActionGet :: String
4217
cryptoActionGet = "get"
4218

    
4219
-- This is 'create and get'
4220
cryptoActionCreate :: String
4221
cryptoActionCreate = "create"
4222

    
4223
cryptoActions :: FrozenSet String
4224
cryptoActions = ConstantUtils.mkSet [cryptoActionGet, cryptoActionCreate]
4225

    
4226
-- * Options for CryptoActions
4227

    
4228
-- Filename of the certificate
4229
cryptoOptionCertFile :: String
4230
cryptoOptionCertFile = "cert_file"
4231

    
4232
-- * SSH key types
4233

    
4234
sshkDsa :: String
4235
sshkDsa = "dsa"
4236

    
4237
sshkRsa :: String
4238
sshkRsa = "rsa"
4239

    
4240
sshkAll :: FrozenSet String
4241
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4242

    
4243
-- * SSH authorized key types
4244

    
4245
sshakDss :: String
4246
sshakDss = "ssh-dss"
4247

    
4248
sshakRsa :: String
4249
sshakRsa = "ssh-rsa"
4250

    
4251
sshakAll :: FrozenSet String
4252
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4253

    
4254
-- * SSH setup
4255

    
4256
sshsClusterName :: String
4257
sshsClusterName = "cluster_name"
4258

    
4259
sshsSshHostKey :: String
4260
sshsSshHostKey = "ssh_host_key"
4261

    
4262
sshsSshRootKey :: String
4263
sshsSshRootKey = "ssh_root_key"
4264

    
4265
sshsNodeDaemonCertificate :: String
4266
sshsNodeDaemonCertificate = "node_daemon_certificate"
4267

    
4268
-- * Key files for SSH daemon
4269

    
4270
sshHostDsaPriv :: String
4271
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4272

    
4273
sshHostDsaPub :: String
4274
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4275

    
4276
sshHostRsaPriv :: String
4277
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4278

    
4279
sshHostRsaPub :: String
4280
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4281

    
4282
sshDaemonKeyfiles :: Map String (String, String)
4283
sshDaemonKeyfiles =
4284
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4285
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4286
               ]
4287

    
4288
-- * Node daemon setup
4289

    
4290
ndsClusterName :: String
4291
ndsClusterName = "cluster_name"
4292

    
4293
ndsNodeDaemonCertificate :: String
4294
ndsNodeDaemonCertificate = "node_daemon_certificate"
4295

    
4296
ndsSsconf :: String
4297
ndsSsconf = "ssconf"
4298

    
4299
ndsStartNodeDaemon :: String
4300
ndsStartNodeDaemon = "start_node_daemon"
4301

    
4302
-- * VCluster related constants
4303

    
4304
vClusterEtcHosts :: String
4305
vClusterEtcHosts = "/etc/hosts"
4306

    
4307
vClusterVirtPathPrefix :: String
4308
vClusterVirtPathPrefix = "/###-VIRTUAL-PATH-###,"
4309

    
4310
vClusterRootdirEnvname :: String
4311
vClusterRootdirEnvname = "GANETI_ROOTDIR"
4312

    
4313
vClusterHostnameEnvname :: String
4314
vClusterHostnameEnvname = "GANETI_HOSTNAME"
4315

    
4316
vClusterVpathWhitelist :: FrozenSet String
4317
vClusterVpathWhitelist = ConstantUtils.mkSet [ vClusterEtcHosts ]
4318

    
4319
-- * The source reasons for the execution of an OpCode
4320

    
4321
opcodeReasonSrcClient :: String
4322
opcodeReasonSrcClient = "gnt:client"
4323

    
4324
opcodeReasonSrcNoded :: String
4325
opcodeReasonSrcNoded = "gnt:daemon:noded"
4326

    
4327
opcodeReasonSrcOpcode :: String
4328
opcodeReasonSrcOpcode = "gnt:opcode"
4329

    
4330
opcodeReasonSrcRlib2 :: String
4331
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4332

    
4333
opcodeReasonSrcUser :: String
4334
opcodeReasonSrcUser = "gnt:user"
4335

    
4336
opcodeReasonSources :: FrozenSet String
4337
opcodeReasonSources =
4338
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4339
                       opcodeReasonSrcNoded,
4340
                       opcodeReasonSrcOpcode,
4341
                       opcodeReasonSrcRlib2,
4342
                       opcodeReasonSrcUser]
4343

    
4344
-- | Path generating random UUID
4345
randomUuidFile :: String
4346
randomUuidFile = ConstantUtils.randomUuidFile
4347

    
4348
-- * Auto-repair tag prefixes
4349

    
4350
autoRepairTagPrefix :: String
4351
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4352

    
4353
autoRepairTagEnabled :: String
4354
autoRepairTagEnabled = autoRepairTagPrefix
4355

    
4356
autoRepairTagPending :: String
4357
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4358

    
4359
autoRepairTagResult :: String
4360
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4361

    
4362
autoRepairTagSuspended :: String
4363
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4364

    
4365
-- * Auto-repair levels
4366

    
4367
autoRepairFailover :: String
4368
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4369

    
4370
autoRepairFixStorage :: String
4371
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4372

    
4373
autoRepairMigrate :: String
4374
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4375

    
4376
autoRepairReinstall :: String
4377
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4378

    
4379
autoRepairAllTypes :: FrozenSet String
4380
autoRepairAllTypes =
4381
  ConstantUtils.mkSet [autoRepairFailover,
4382
                       autoRepairFixStorage,
4383
                       autoRepairMigrate,
4384
                       autoRepairReinstall]
4385

    
4386
-- * Auto-repair results
4387

    
4388
autoRepairEnoperm :: String
4389
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4390

    
4391
autoRepairFailure :: String
4392
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4393

    
4394
autoRepairSuccess :: String
4395
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4396

    
4397
autoRepairAllResults :: FrozenSet String
4398
autoRepairAllResults =
4399
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4400

    
4401
-- | The version identifier for builtin data collectors
4402
builtinDataCollectorVersion :: String
4403
builtinDataCollectorVersion = "B"
4404

    
4405
-- | The reason trail opcode parameter name
4406
opcodeReason :: String
4407
opcodeReason = "reason"
4408

    
4409
diskstatsFile :: String
4410
diskstatsFile = "/proc/diskstats"
4411

    
4412
-- *  CPU load collector
4413

    
4414
statFile :: String
4415
statFile = "/proc/stat"
4416

    
4417
cpuavgloadBufferSize :: Int
4418
cpuavgloadBufferSize = 150
4419

    
4420
cpuavgloadWindowSize :: Int
4421
cpuavgloadWindowSize = 600
4422

    
4423
-- * Monitoring daemon
4424

    
4425
-- | Mond's variable for periodical data collection
4426
mondTimeInterval :: Int
4427
mondTimeInterval = 5
4428

    
4429
-- | Mond's latest API version
4430
mondLatestApiVersion :: Int
4431
mondLatestApiVersion = 1
4432

    
4433
-- * Disk access modes
4434

    
4435
diskUserspace :: String
4436
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4437

    
4438
diskKernelspace :: String
4439
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4440

    
4441
diskValidAccessModes :: FrozenSet String
4442
diskValidAccessModes =
4443
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4444

    
4445
-- | Timeout for queue draining in upgrades
4446
upgradeQueueDrainTimeout :: Int
4447
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4448

    
4449
-- | Intervall at which the queue is polled during upgrades
4450
upgradeQueuePollInterval :: Int
4451
upgradeQueuePollInterval  = 10
4452

    
4453
-- * Hotplug Actions
4454

    
4455
hotplugActionAdd :: String
4456
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4457

    
4458
hotplugActionRemove :: String
4459
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4460

    
4461
hotplugActionModify :: String
4462
hotplugActionModify = Types.hotplugActionToRaw HAMod
4463

    
4464
hotplugAllActions :: FrozenSet String
4465
hotplugAllActions =
4466
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4467

    
4468
-- * Hotplug Device Targets
4469

    
4470
hotplugTargetNic :: String
4471
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4472

    
4473
hotplugTargetDisk :: String
4474
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4475

    
4476
hotplugAllTargets :: FrozenSet String
4477
hotplugAllTargets =
4478
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4479

    
4480
-- | Timeout for disk removal (seconds)
4481
diskRemoveRetryTimeout :: Int
4482
diskRemoveRetryTimeout = 30
4483

    
4484
-- | Interval between disk removal retries (seconds)
4485
diskRemoveRetryInterval :: Int
4486
diskRemoveRetryInterval  = 3
4487

    
4488
-- * UUID regex
4489

    
4490
uuidRegex :: String
4491
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4492

    
4493
-- * Luxi constants
4494

    
4495
luxiSocketPerms :: Int
4496
luxiSocketPerms = 0o660
4497

    
4498
luxiKeyMethod :: String
4499
luxiKeyMethod = "method"
4500

    
4501
luxiKeyArgs :: String
4502
luxiKeyArgs = "args"
4503

    
4504
luxiKeySuccess :: String
4505
luxiKeySuccess = "success"
4506

    
4507
luxiKeyResult :: String
4508
luxiKeyResult = "result"
4509

    
4510
luxiKeyVersion :: String
4511
luxiKeyVersion = "version"
4512

    
4513
luxiReqSubmitJob :: String
4514
luxiReqSubmitJob = "SubmitJob"
4515

    
4516
luxiReqSubmitJobToDrainedQueue :: String
4517
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4518

    
4519
luxiReqSubmitManyJobs :: String
4520
luxiReqSubmitManyJobs = "SubmitManyJobs"
4521

    
4522
luxiReqWaitForJobChange :: String
4523
luxiReqWaitForJobChange = "WaitForJobChange"
4524

    
4525
luxiReqPickupJob :: String
4526
luxiReqPickupJob = "PickupJob"
4527

    
4528
luxiReqCancelJob :: String
4529
luxiReqCancelJob = "CancelJob"
4530

    
4531
luxiReqArchiveJob :: String
4532
luxiReqArchiveJob = "ArchiveJob"
4533

    
4534
luxiReqChangeJobPriority :: String
4535
luxiReqChangeJobPriority = "ChangeJobPriority"
4536

    
4537
luxiReqAutoArchiveJobs :: String
4538
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4539

    
4540
luxiReqQuery :: String
4541
luxiReqQuery = "Query"
4542

    
4543
luxiReqQueryFields :: String
4544
luxiReqQueryFields = "QueryFields"
4545

    
4546
luxiReqQueryJobs :: String
4547
luxiReqQueryJobs = "QueryJobs"
4548

    
4549
luxiReqQueryInstances :: String
4550
luxiReqQueryInstances = "QueryInstances"
4551

    
4552
luxiReqQueryNodes :: String
4553
luxiReqQueryNodes = "QueryNodes"
4554

    
4555
luxiReqQueryGroups :: String
4556
luxiReqQueryGroups = "QueryGroups"
4557

    
4558
luxiReqQueryNetworks :: String
4559
luxiReqQueryNetworks = "QueryNetworks"
4560

    
4561
luxiReqQueryExports :: String
4562
luxiReqQueryExports = "QueryExports"
4563

    
4564
luxiReqQueryConfigValues :: String
4565
luxiReqQueryConfigValues = "QueryConfigValues"
4566

    
4567
luxiReqQueryClusterInfo :: String
4568
luxiReqQueryClusterInfo = "QueryClusterInfo"
4569

    
4570
luxiReqQueryTags :: String
4571
luxiReqQueryTags = "QueryTags"
4572

    
4573
luxiReqSetDrainFlag :: String
4574
luxiReqSetDrainFlag = "SetDrainFlag"
4575

    
4576
luxiReqSetWatcherPause :: String
4577
luxiReqSetWatcherPause = "SetWatcherPause"
4578

    
4579
luxiReqAll :: FrozenSet String
4580
luxiReqAll =
4581
  ConstantUtils.mkSet
4582
  [ luxiReqArchiveJob
4583
  , luxiReqAutoArchiveJobs
4584
  , luxiReqCancelJob
4585
  , luxiReqChangeJobPriority
4586
  , luxiReqQuery
4587
  , luxiReqQueryClusterInfo
4588
  , luxiReqQueryConfigValues
4589
  , luxiReqQueryExports
4590
  , luxiReqQueryFields
4591
  , luxiReqQueryGroups
4592
  , luxiReqQueryInstances
4593
  , luxiReqQueryJobs
4594
  , luxiReqQueryNodes
4595
  , luxiReqQueryNetworks
4596
  , luxiReqQueryTags
4597
  , luxiReqSetDrainFlag
4598
  , luxiReqSetWatcherPause
4599
  , luxiReqSubmitJob
4600
  , luxiReqSubmitJobToDrainedQueue
4601
  , luxiReqSubmitManyJobs
4602
  , luxiReqWaitForJobChange
4603
  , luxiReqPickupJob
4604
  ]
4605

    
4606
luxiDefCtmo :: Int
4607
luxiDefCtmo = 10
4608

    
4609
luxiDefRwto :: Int
4610
luxiDefRwto = 60
4611

    
4612
-- | 'WaitForJobChange' timeout
4613
luxiWfjcTimeout :: Int
4614
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4615

    
4616
-- * Query language constants
4617

    
4618
-- ** Logic operators with one or more operands, each of which is a
4619
-- filter on its own
4620

    
4621
qlangOpAnd :: String
4622
qlangOpAnd = "&"
4623

    
4624
qlangOpOr :: String
4625
qlangOpOr = "|"
4626

    
4627
-- ** Unary operators with exactly one operand
4628

    
4629
qlangOpNot :: String
4630
qlangOpNot = "!"
4631

    
4632
qlangOpTrue :: String
4633
qlangOpTrue = "?"
4634

    
4635
-- ** Binary operators with exactly two operands, the field name and
4636
-- an operator-specific value
4637

    
4638
qlangOpContains :: String
4639
qlangOpContains = "=[]"
4640

    
4641
qlangOpEqual :: String
4642
qlangOpEqual = "="
4643

    
4644
qlangOpGe :: String
4645
qlangOpGe = ">="
4646

    
4647
qlangOpGt :: String
4648
qlangOpGt = ">"
4649

    
4650
qlangOpLe :: String
4651
qlangOpLe = "<="
4652

    
4653
qlangOpLt :: String
4654
qlangOpLt = "<"
4655

    
4656
qlangOpNotEqual :: String
4657
qlangOpNotEqual = "!="
4658

    
4659
qlangOpRegexp :: String
4660
qlangOpRegexp = "=~"
4661

    
4662
-- | Characters used for detecting user-written filters (see
4663
-- L{_CheckFilter})
4664

    
4665
qlangFilterDetectionChars :: FrozenSet String
4666
qlangFilterDetectionChars =
4667
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4668
                       ")", "(", "\x0b", "\n",
4669
                       "\r", "\x0c", "/", "<",
4670
                       "\t", ">", "=", "\\", "~"]
4671

    
4672
-- | Characters used to detect globbing filters
4673
qlangGlobDetectionChars :: FrozenSet String
4674
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4675

    
4676
-- * Error related constants
4677
--
4678
-- 'OpPrereqError' failure types
4679

    
4680
-- | Environment error (e.g. node disk error)
4681
errorsEcodeEnviron :: String
4682
errorsEcodeEnviron = "environment_error"
4683

    
4684
-- | Entity already exists
4685
errorsEcodeExists :: String
4686
errorsEcodeExists = "already_exists"
4687

    
4688
-- | Internal cluster error
4689
errorsEcodeFault :: String
4690
errorsEcodeFault = "internal_error"
4691

    
4692
-- | Wrong arguments (at syntax level)
4693
errorsEcodeInval :: String
4694
errorsEcodeInval = "wrong_input"
4695

    
4696
-- | Entity not found
4697
errorsEcodeNoent :: String
4698
errorsEcodeNoent = "unknown_entity"
4699

    
4700
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4701
errorsEcodeNores :: String
4702
errorsEcodeNores = "insufficient_resources"
4703

    
4704
-- | Resource not unique (e.g. MAC or IP duplication)
4705
errorsEcodeNotunique :: String
4706
errorsEcodeNotunique = "resource_not_unique"
4707

    
4708
-- | Resolver errors
4709
errorsEcodeResolver :: String
4710
errorsEcodeResolver = "resolver_error"
4711

    
4712
-- | Wrong entity state
4713
errorsEcodeState :: String
4714
errorsEcodeState = "wrong_state"
4715

    
4716
-- | Temporarily out of resources; operation can be tried again
4717
errorsEcodeTempNores :: String
4718
errorsEcodeTempNores = "temp_insufficient_resources"
4719

    
4720
errorsEcodeAll :: FrozenSet String
4721
errorsEcodeAll =
4722
  ConstantUtils.mkSet [ errorsEcodeNores
4723
                      , errorsEcodeExists
4724
                      , errorsEcodeState
4725
                      , errorsEcodeNotunique
4726
                      , errorsEcodeTempNores
4727
                      , errorsEcodeNoent
4728
                      , errorsEcodeFault
4729
                      , errorsEcodeResolver
4730
                      , errorsEcodeInval
4731
                      , errorsEcodeEnviron
4732
                      ]
4733

    
4734
-- * Jstore related constants
4735

    
4736
jstoreJobsPerArchiveDirectory :: Int
4737
jstoreJobsPerArchiveDirectory = 10000
4738

    
4739
-- * Gluster settings
4740

    
4741
-- | Name of the Gluster host setting
4742
glusterHost :: String
4743
glusterHost = "host"
4744

    
4745
-- | Default value of the Gluster host setting
4746
glusterHostDefault :: String
4747
glusterHostDefault = "127.0.0.1"
4748

    
4749
-- | Name of the Gluster volume setting
4750
glusterVolume :: String
4751
glusterVolume = "volume"
4752

    
4753
-- | Default value of the Gluster volume setting
4754
glusterVolumeDefault :: String
4755
glusterVolumeDefault = "gv0"
4756

    
4757
-- | Name of the Gluster port setting
4758
glusterPort :: String
4759
glusterPort = "port"
4760

    
4761
-- | Default value of the Gluster port setting
4762
glusterPortDefault :: Int
4763
glusterPortDefault = 24007
4764

    
4765
-- * Instance communication
4766

    
4767
instanceCommunicationNetwork :: String
4768
instanceCommunicationNetwork = "ganeti:network:communication"
4769

    
4770
instanceCommunicationNicPrefix :: String
4771
instanceCommunicationNicPrefix = "ganeti:communication:"