Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ d6a7518a

History | View | Annotate | Download (121.6 kB)

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

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

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

    
15
-}
16

    
17
{-
18

    
19
Copyright (C) 2013, 2014 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
inisectOspPrivate :: String
1108
inisectOspPrivate = "os_private"
1109

    
1110
-- * Dynamic device modification
1111

    
1112
ddmAdd :: String
1113
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1114

    
1115
ddmModify :: String
1116
ddmModify = Types.ddmFullToRaw DdmFullModify
1117

    
1118
ddmRemove :: String
1119
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1120

    
1121
ddmsValues :: FrozenSet String
1122
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1123

    
1124
ddmsValuesWithModify :: FrozenSet String
1125
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1126

    
1127
-- * Common exit codes
1128

    
1129
exitSuccess :: Int
1130
exitSuccess = 0
1131

    
1132
exitFailure :: Int
1133
exitFailure = ConstantUtils.exitFailure
1134

    
1135
exitNotcluster :: Int
1136
exitNotcluster = 5
1137

    
1138
exitNotmaster :: Int
1139
exitNotmaster = 11
1140

    
1141
exitNodesetupError :: Int
1142
exitNodesetupError = 12
1143

    
1144
-- | Need user confirmation
1145
exitConfirmation :: Int
1146
exitConfirmation = 13
1147

    
1148
-- | Exit code for query operations with unknown fields
1149
exitUnknownField :: Int
1150
exitUnknownField = 14
1151

    
1152
-- * Tags
1153

    
1154
tagCluster :: String
1155
tagCluster = Types.tagKindToRaw TagKindCluster
1156

    
1157
tagInstance :: String
1158
tagInstance = Types.tagKindToRaw TagKindInstance
1159

    
1160
tagNetwork :: String
1161
tagNetwork = Types.tagKindToRaw TagKindNetwork
1162

    
1163
tagNode :: String
1164
tagNode = Types.tagKindToRaw TagKindNode
1165

    
1166
tagNodegroup :: String
1167
tagNodegroup = Types.tagKindToRaw TagKindGroup
1168

    
1169
validTagTypes :: FrozenSet String
1170
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1171

    
1172
maxTagLen :: Int
1173
maxTagLen = 128
1174

    
1175
maxTagsPerObj :: Int
1176
maxTagsPerObj = 4096
1177

    
1178
-- * Others
1179

    
1180
defaultBridge :: String
1181
defaultBridge = "xen-br0"
1182

    
1183
defaultOvs :: String
1184
defaultOvs = "switch1"
1185

    
1186
-- | 60 MiB/s, expressed in KiB/s
1187
classicDrbdSyncSpeed :: Int
1188
classicDrbdSyncSpeed = 60 * 1024
1189

    
1190
ip4AddressAny :: String
1191
ip4AddressAny = "0.0.0.0"
1192

    
1193
ip4AddressLocalhost :: String
1194
ip4AddressLocalhost = "127.0.0.1"
1195

    
1196
ip6AddressAny :: String
1197
ip6AddressAny = "::"
1198

    
1199
ip6AddressLocalhost :: String
1200
ip6AddressLocalhost = "::1"
1201

    
1202
ip4Version :: Int
1203
ip4Version = 4
1204

    
1205
ip6Version :: Int
1206
ip6Version = 6
1207

    
1208
validIpVersions :: FrozenSet Int
1209
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1210

    
1211
tcpPingTimeout :: Int
1212
tcpPingTimeout = 10
1213

    
1214
defaultVg :: String
1215
defaultVg = "xenvg"
1216

    
1217
defaultDrbdHelper :: String
1218
defaultDrbdHelper = "/bin/true"
1219

    
1220
minVgSize :: Int
1221
minVgSize = 20480
1222

    
1223
defaultMacPrefix :: String
1224
defaultMacPrefix = "aa:00:00"
1225

    
1226
-- | Default maximum instance wait time (seconds)
1227
defaultShutdownTimeout :: Int
1228
defaultShutdownTimeout = 120
1229

    
1230
-- | Node clock skew (seconds)
1231
nodeMaxClockSkew :: Int
1232
nodeMaxClockSkew = 150
1233

    
1234
-- | Time for an intra-cluster disk transfer to wait for a connection
1235
diskTransferConnectTimeout :: Int
1236
diskTransferConnectTimeout = 60
1237

    
1238
-- | Disk index separator
1239
diskSeparator :: String
1240
diskSeparator = AutoConf.diskSeparator
1241

    
1242
ipCommandPath :: String
1243
ipCommandPath = AutoConf.ipPath
1244

    
1245
-- | Key for job IDs in opcode result
1246
jobIdsKey :: String
1247
jobIdsKey = "jobs"
1248

    
1249
-- * Runparts results
1250

    
1251
runpartsErr :: Int
1252
runpartsErr = 2
1253

    
1254
runpartsRun :: Int
1255
runpartsRun = 1
1256

    
1257
runpartsSkip :: Int
1258
runpartsSkip = 0
1259

    
1260
runpartsStatus :: [Int]
1261
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1262

    
1263
-- * RPC
1264

    
1265
rpcEncodingNone :: Int
1266
rpcEncodingNone = 0
1267

    
1268
rpcEncodingZlibBase64 :: Int
1269
rpcEncodingZlibBase64 = 1
1270

    
1271
-- * Timeout table
1272
--
1273
-- Various time constants for the timeout table
1274

    
1275
rpcTmoUrgent :: Int
1276
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1277

    
1278
rpcTmoFast :: Int
1279
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1280

    
1281
rpcTmoNormal :: Int
1282
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1283

    
1284
rpcTmoSlow :: Int
1285
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1286

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

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

    
1299
-- | Timeout for connecting to nodes (seconds)
1300
rpcConnectTimeout :: Int
1301
rpcConnectTimeout = 5
1302

    
1303
-- OS
1304

    
1305
osScriptCreate :: String
1306
osScriptCreate = "create"
1307

    
1308
osScriptExport :: String
1309
osScriptExport = "export"
1310

    
1311
osScriptImport :: String
1312
osScriptImport = "import"
1313

    
1314
osScriptRename :: String
1315
osScriptRename = "rename"
1316

    
1317
osScriptVerify :: String
1318
osScriptVerify = "verify"
1319

    
1320
osScripts :: [String]
1321
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1322
             osScriptVerify]
1323

    
1324
osApiFile :: String
1325
osApiFile = "ganeti_api_version"
1326

    
1327
osVariantsFile :: String
1328
osVariantsFile = "variants.list"
1329

    
1330
osParametersFile :: String
1331
osParametersFile = "parameters.list"
1332

    
1333
osValidateParameters :: String
1334
osValidateParameters = "parameters"
1335

    
1336
osValidateCalls :: FrozenSet String
1337
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1338

    
1339
-- | External Storage (ES) related constants
1340

    
1341
esActionAttach :: String
1342
esActionAttach = "attach"
1343

    
1344
esActionCreate :: String
1345
esActionCreate = "create"
1346

    
1347
esActionDetach :: String
1348
esActionDetach = "detach"
1349

    
1350
esActionGrow :: String
1351
esActionGrow = "grow"
1352

    
1353
esActionRemove :: String
1354
esActionRemove = "remove"
1355

    
1356
esActionSetinfo :: String
1357
esActionSetinfo = "setinfo"
1358

    
1359
esActionVerify :: String
1360
esActionVerify = "verify"
1361

    
1362
esScriptCreate :: String
1363
esScriptCreate = esActionCreate
1364

    
1365
esScriptRemove :: String
1366
esScriptRemove = esActionRemove
1367

    
1368
esScriptGrow :: String
1369
esScriptGrow = esActionGrow
1370

    
1371
esScriptAttach :: String
1372
esScriptAttach = esActionAttach
1373

    
1374
esScriptDetach :: String
1375
esScriptDetach = esActionDetach
1376

    
1377
esScriptSetinfo :: String
1378
esScriptSetinfo = esActionSetinfo
1379

    
1380
esScriptVerify :: String
1381
esScriptVerify = esActionVerify
1382

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

    
1393
esParametersFile :: String
1394
esParametersFile = "parameters.list"
1395

    
1396
-- * Reboot types
1397

    
1398
instanceRebootSoft :: String
1399
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1400

    
1401
instanceRebootHard :: String
1402
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1403

    
1404
instanceRebootFull :: String
1405
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1406

    
1407
rebootTypes :: FrozenSet String
1408
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1409

    
1410
-- * Instance reboot behaviors
1411

    
1412
instanceRebootAllowed :: String
1413
instanceRebootAllowed = "reboot"
1414

    
1415
instanceRebootExit :: String
1416
instanceRebootExit = "exit"
1417

    
1418
rebootBehaviors :: [String]
1419
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1420

    
1421
-- * VTypes
1422

    
1423
vtypeBool :: VType
1424
vtypeBool = VTypeBool
1425

    
1426
vtypeInt :: VType
1427
vtypeInt = VTypeInt
1428

    
1429
vtypeMaybeString :: VType
1430
vtypeMaybeString = VTypeMaybeString
1431

    
1432
-- | Size in MiBs
1433
vtypeSize :: VType
1434
vtypeSize = VTypeSize
1435

    
1436
vtypeString :: VType
1437
vtypeString = VTypeString
1438

    
1439
enforceableTypes :: FrozenSet VType
1440
enforceableTypes = ConstantUtils.mkSet [minBound..]
1441

    
1442
-- | Constant representing that the user does not specify any IP version
1443
ifaceNoIpVersionSpecified :: Int
1444
ifaceNoIpVersionSpecified = 0
1445

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

    
1467
-- * HV parameter names (global namespace)
1468

    
1469
hvAcpi :: String
1470
hvAcpi = "acpi"
1471

    
1472
hvBlockdevPrefix :: String
1473
hvBlockdevPrefix = "blockdev_prefix"
1474

    
1475
hvBootloaderArgs :: String
1476
hvBootloaderArgs = "bootloader_args"
1477

    
1478
hvBootloaderPath :: String
1479
hvBootloaderPath = "bootloader_path"
1480

    
1481
hvBootOrder :: String
1482
hvBootOrder = "boot_order"
1483

    
1484
hvCdromImagePath :: String
1485
hvCdromImagePath = "cdrom_image_path"
1486

    
1487
hvCpuCap :: String
1488
hvCpuCap = "cpu_cap"
1489

    
1490
hvCpuCores :: String
1491
hvCpuCores = "cpu_cores"
1492

    
1493
hvCpuMask :: String
1494
hvCpuMask = "cpu_mask"
1495

    
1496
hvCpuSockets :: String
1497
hvCpuSockets = "cpu_sockets"
1498

    
1499
hvCpuThreads :: String
1500
hvCpuThreads = "cpu_threads"
1501

    
1502
hvCpuType :: String
1503
hvCpuType = "cpu_type"
1504

    
1505
hvCpuWeight :: String
1506
hvCpuWeight = "cpu_weight"
1507

    
1508
hvDeviceModel :: String
1509
hvDeviceModel = "device_model"
1510

    
1511
hvDiskCache :: String
1512
hvDiskCache = "disk_cache"
1513

    
1514
hvDiskType :: String
1515
hvDiskType = "disk_type"
1516

    
1517
hvInitrdPath :: String
1518
hvInitrdPath = "initrd_path"
1519

    
1520
hvInitScript :: String
1521
hvInitScript = "init_script"
1522

    
1523
hvKernelArgs :: String
1524
hvKernelArgs = "kernel_args"
1525

    
1526
hvKernelPath :: String
1527
hvKernelPath = "kernel_path"
1528

    
1529
hvKeymap :: String
1530
hvKeymap = "keymap"
1531

    
1532
hvKvmCdrom2ImagePath :: String
1533
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1534

    
1535
hvKvmCdromDiskType :: String
1536
hvKvmCdromDiskType = "cdrom_disk_type"
1537

    
1538
hvKvmExtra :: String
1539
hvKvmExtra = "kvm_extra"
1540

    
1541
hvKvmFlag :: String
1542
hvKvmFlag = "kvm_flag"
1543

    
1544
hvKvmFloppyImagePath :: String
1545
hvKvmFloppyImagePath = "floppy_image_path"
1546

    
1547
hvKvmMachineVersion :: String
1548
hvKvmMachineVersion = "machine_version"
1549

    
1550
hvKvmPath :: String
1551
hvKvmPath = "kvm_path"
1552

    
1553
hvKvmSpiceAudioCompr :: String
1554
hvKvmSpiceAudioCompr = "spice_playback_compression"
1555

    
1556
hvKvmSpiceBind :: String
1557
hvKvmSpiceBind = "spice_bind"
1558

    
1559
hvKvmSpiceIpVersion :: String
1560
hvKvmSpiceIpVersion = "spice_ip_version"
1561

    
1562
hvKvmSpiceJpegImgCompr :: String
1563
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1564

    
1565
hvKvmSpiceLosslessImgCompr :: String
1566
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1567

    
1568
hvKvmSpicePasswordFile :: String
1569
hvKvmSpicePasswordFile = "spice_password_file"
1570

    
1571
hvKvmSpiceStreamingVideoDetection :: String
1572
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1573

    
1574
hvKvmSpiceTlsCiphers :: String
1575
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1576

    
1577
hvKvmSpiceUseTls :: String
1578
hvKvmSpiceUseTls = "spice_use_tls"
1579

    
1580
hvKvmSpiceUseVdagent :: String
1581
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1582

    
1583
hvKvmSpiceZlibGlzImgCompr :: String
1584
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1585

    
1586
hvKvmUseChroot :: String
1587
hvKvmUseChroot = "use_chroot"
1588

    
1589
hvKvmUserShutdown :: String
1590
hvKvmUserShutdown = "user_shutdown"
1591

    
1592
hvMemPath :: String
1593
hvMemPath = "mem_path"
1594

    
1595
hvMigrationBandwidth :: String
1596
hvMigrationBandwidth = "migration_bandwidth"
1597

    
1598
hvMigrationDowntime :: String
1599
hvMigrationDowntime = "migration_downtime"
1600

    
1601
hvMigrationMode :: String
1602
hvMigrationMode = "migration_mode"
1603

    
1604
hvMigrationPort :: String
1605
hvMigrationPort = "migration_port"
1606

    
1607
hvNicType :: String
1608
hvNicType = "nic_type"
1609

    
1610
hvPae :: String
1611
hvPae = "pae"
1612

    
1613
hvPassthrough :: String
1614
hvPassthrough = "pci_pass"
1615

    
1616
hvRebootBehavior :: String
1617
hvRebootBehavior = "reboot_behavior"
1618

    
1619
hvRootPath :: String
1620
hvRootPath = "root_path"
1621

    
1622
hvSecurityDomain :: String
1623
hvSecurityDomain = "security_domain"
1624

    
1625
hvSecurityModel :: String
1626
hvSecurityModel = "security_model"
1627

    
1628
hvSerialConsole :: String
1629
hvSerialConsole = "serial_console"
1630

    
1631
hvSerialSpeed :: String
1632
hvSerialSpeed = "serial_speed"
1633

    
1634
hvSoundhw :: String
1635
hvSoundhw = "soundhw"
1636

    
1637
hvUsbDevices :: String
1638
hvUsbDevices = "usb_devices"
1639

    
1640
hvUsbMouse :: String
1641
hvUsbMouse = "usb_mouse"
1642

    
1643
hvUseBootloader :: String
1644
hvUseBootloader = "use_bootloader"
1645

    
1646
hvUseLocaltime :: String
1647
hvUseLocaltime = "use_localtime"
1648

    
1649
hvVga :: String
1650
hvVga = "vga"
1651

    
1652
hvVhostNet :: String
1653
hvVhostNet = "vhost_net"
1654

    
1655
hvVifScript :: String
1656
hvVifScript = "vif_script"
1657

    
1658
hvVifType :: String
1659
hvVifType = "vif_type"
1660

    
1661
hvViridian :: String
1662
hvViridian = "viridian"
1663

    
1664
hvVncBindAddress :: String
1665
hvVncBindAddress = "vnc_bind_address"
1666

    
1667
hvVncPasswordFile :: String
1668
hvVncPasswordFile = "vnc_password_file"
1669

    
1670
hvVncTls :: String
1671
hvVncTls = "vnc_tls"
1672

    
1673
hvVncX509 :: String
1674
hvVncX509 = "vnc_x509_path"
1675

    
1676
hvVncX509Verify :: String
1677
hvVncX509Verify = "vnc_x509_verify"
1678

    
1679
hvVnetHdr :: String
1680
hvVnetHdr = "vnet_hdr"
1681

    
1682
hvXenCmd :: String
1683
hvXenCmd = "xen_cmd"
1684

    
1685
hvXenCpuid :: String
1686
hvXenCpuid = "cpuid"
1687

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

    
1703
hvsParameters :: FrozenSet String
1704
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1705

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

    
1783
-- * Migration statuses
1784

    
1785
hvMigrationActive :: String
1786
hvMigrationActive = "active"
1787

    
1788
hvMigrationCancelled :: String
1789
hvMigrationCancelled = "cancelled"
1790

    
1791
hvMigrationCompleted :: String
1792
hvMigrationCompleted = "completed"
1793

    
1794
hvMigrationFailed :: String
1795
hvMigrationFailed = "failed"
1796

    
1797
hvMigrationValidStatuses :: FrozenSet String
1798
hvMigrationValidStatuses =
1799
  ConstantUtils.mkSet [hvMigrationActive,
1800
                       hvMigrationCancelled,
1801
                       hvMigrationCompleted,
1802
                       hvMigrationFailed]
1803

    
1804
hvMigrationFailedStatuses :: FrozenSet String
1805
hvMigrationFailedStatuses =
1806
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1807

    
1808
-- | KVM-specific statuses
1809
--
1810
-- FIXME: this constant seems unnecessary
1811
hvKvmMigrationValidStatuses :: FrozenSet String
1812
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1813

    
1814
-- | Node info keys
1815
hvNodeinfoKeyVersion :: String
1816
hvNodeinfoKeyVersion = "hv_version"
1817

    
1818
-- * Hypervisor state
1819

    
1820
hvstCpuNode :: String
1821
hvstCpuNode = "cpu_node"
1822

    
1823
hvstCpuTotal :: String
1824
hvstCpuTotal = "cpu_total"
1825

    
1826
hvstMemoryHv :: String
1827
hvstMemoryHv = "mem_hv"
1828

    
1829
hvstMemoryNode :: String
1830
hvstMemoryNode = "mem_node"
1831

    
1832
hvstMemoryTotal :: String
1833
hvstMemoryTotal = "mem_total"
1834

    
1835
hvstsParameters :: FrozenSet String
1836
hvstsParameters =
1837
  ConstantUtils.mkSet [hvstCpuNode,
1838
                       hvstCpuTotal,
1839
                       hvstMemoryHv,
1840
                       hvstMemoryNode,
1841
                       hvstMemoryTotal]
1842

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

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

    
1860
-- * Disk state
1861

    
1862
dsDiskOverhead :: String
1863
dsDiskOverhead = "disk_overhead"
1864

    
1865
dsDiskReserved :: String
1866
dsDiskReserved = "disk_reserved"
1867

    
1868
dsDiskTotal :: String
1869
dsDiskTotal = "disk_total"
1870

    
1871
dsDefaults :: Map String Int
1872
dsDefaults =
1873
  Map.fromList
1874
  [(dsDiskTotal, 0),
1875
   (dsDiskReserved, 0),
1876
   (dsDiskOverhead, 0)]
1877

    
1878
dssParameterTypes :: Map String VType
1879
dssParameterTypes =
1880
  Map.fromList [(dsDiskTotal, VTypeInt),
1881
                (dsDiskReserved, VTypeInt),
1882
                (dsDiskOverhead, VTypeInt)]
1883

    
1884
dssParameters :: FrozenSet String
1885
dssParameters =
1886
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1887

    
1888
dsValidTypes :: FrozenSet String
1889
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1890

    
1891
-- Backend parameter names
1892

    
1893
beAlwaysFailover :: String
1894
beAlwaysFailover = "always_failover"
1895

    
1896
beAutoBalance :: String
1897
beAutoBalance = "auto_balance"
1898

    
1899
beMaxmem :: String
1900
beMaxmem = "maxmem"
1901

    
1902
-- | Deprecated and replaced by max and min mem
1903
beMemory :: String
1904
beMemory = "memory"
1905

    
1906
beMinmem :: String
1907
beMinmem = "minmem"
1908

    
1909
beSpindleUse :: String
1910
beSpindleUse = "spindle_use"
1911

    
1912
beVcpus :: String
1913
beVcpus = "vcpus"
1914

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

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

    
1931
besParameterCompat :: Map String VType
1932
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1933

    
1934
besParameters :: FrozenSet String
1935
besParameters =
1936
  ConstantUtils.mkSet [beAlwaysFailover,
1937
                       beAutoBalance,
1938
                       beMaxmem,
1939
                       beMinmem,
1940
                       beSpindleUse,
1941
                       beVcpus]
1942

    
1943
-- | Instance specs
1944
--
1945
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1946

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

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

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

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

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

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

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

    
1975
ispecsParameters :: FrozenSet String
1976
ispecsParameters =
1977
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1978
                       ConstantUtils.ispecDiskCount,
1979
                       ConstantUtils.ispecDiskSize,
1980
                       ConstantUtils.ispecMemSize,
1981
                       ConstantUtils.ispecNicCount,
1982
                       ConstantUtils.ispecSpindleUse]
1983

    
1984
ispecsMinmax :: String
1985
ispecsMinmax = ConstantUtils.ispecsMinmax
1986

    
1987
ispecsMax :: String
1988
ispecsMax = "max"
1989

    
1990
ispecsMin :: String
1991
ispecsMin = "min"
1992

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

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

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

    
2002
ipolicySpindleRatio :: String
2003
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
2004

    
2005
ispecsMinmaxKeys :: FrozenSet String
2006
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
2007

    
2008
ipolicyParameters :: FrozenSet String
2009
ipolicyParameters =
2010
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
2011
                       ConstantUtils.ipolicySpindleRatio]
2012

    
2013
ipolicyAllKeys :: FrozenSet String
2014
ipolicyAllKeys =
2015
  ConstantUtils.union ipolicyParameters $
2016
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
2017
                       ConstantUtils.ispecsMinmax,
2018
                       ispecsStd]
2019

    
2020
-- | Node parameter names
2021

    
2022
ndExclusiveStorage :: String
2023
ndExclusiveStorage = "exclusive_storage"
2024

    
2025
ndOobProgram :: String
2026
ndOobProgram = "oob_program"
2027

    
2028
ndSpindleCount :: String
2029
ndSpindleCount = "spindle_count"
2030

    
2031
ndOvs :: String
2032
ndOvs = "ovs"
2033

    
2034
ndOvsLink :: String
2035
ndOvsLink = "ovs_link"
2036

    
2037
ndOvsName :: String
2038
ndOvsName = "ovs_name"
2039

    
2040
ndSshPort :: String
2041
ndSshPort = "ssh_port"
2042

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

    
2054
ndsParameters :: FrozenSet String
2055
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
2056

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

    
2067
-- * Logical Disks parameters
2068

    
2069
ldpAccess :: String
2070
ldpAccess = "access"
2071

    
2072
ldpBarriers :: String
2073
ldpBarriers = "disabled-barriers"
2074

    
2075
ldpDefaultMetavg :: String
2076
ldpDefaultMetavg = "default-metavg"
2077

    
2078
ldpDelayTarget :: String
2079
ldpDelayTarget = "c-delay-target"
2080

    
2081
ldpDiskCustom :: String
2082
ldpDiskCustom = "disk-custom"
2083

    
2084
ldpDynamicResync :: String
2085
ldpDynamicResync = "dynamic-resync"
2086

    
2087
ldpFillTarget :: String
2088
ldpFillTarget = "c-fill-target"
2089

    
2090
ldpMaxRate :: String
2091
ldpMaxRate = "c-max-rate"
2092

    
2093
ldpMinRate :: String
2094
ldpMinRate = "c-min-rate"
2095

    
2096
ldpNetCustom :: String
2097
ldpNetCustom = "net-custom"
2098

    
2099
ldpNoMetaFlush :: String
2100
ldpNoMetaFlush = "disable-meta-flush"
2101

    
2102
ldpPlanAhead :: String
2103
ldpPlanAhead = "c-plan-ahead"
2104

    
2105
ldpPool :: String
2106
ldpPool = "pool"
2107

    
2108
ldpProtocol :: String
2109
ldpProtocol = "protocol"
2110

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

    
2114
ldpStripes :: String
2115
ldpStripes = "stripes"
2116

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

    
2137
diskLdParameters :: FrozenSet String
2138
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2139

    
2140
-- * Disk template parameters
2141
--
2142
-- Disk template parameters can be set/changed by the user via
2143
-- gnt-cluster and gnt-group)
2144

    
2145
drbdResyncRate :: String
2146
drbdResyncRate = "resync-rate"
2147

    
2148
drbdDataStripes :: String
2149
drbdDataStripes = "data-stripes"
2150

    
2151
drbdMetaStripes :: String
2152
drbdMetaStripes = "meta-stripes"
2153

    
2154
drbdDiskBarriers :: String
2155
drbdDiskBarriers = "disk-barriers"
2156

    
2157
drbdMetaBarriers :: String
2158
drbdMetaBarriers = "meta-barriers"
2159

    
2160
drbdDefaultMetavg :: String
2161
drbdDefaultMetavg = "metavg"
2162

    
2163
drbdDiskCustom :: String
2164
drbdDiskCustom = "disk-custom"
2165

    
2166
drbdNetCustom :: String
2167
drbdNetCustom = "net-custom"
2168

    
2169
drbdProtocol :: String
2170
drbdProtocol = "protocol"
2171

    
2172
drbdDynamicResync :: String
2173
drbdDynamicResync = "dynamic-resync"
2174

    
2175
drbdPlanAhead :: String
2176
drbdPlanAhead = "c-plan-ahead"
2177

    
2178
drbdFillTarget :: String
2179
drbdFillTarget = "c-fill-target"
2180

    
2181
drbdDelayTarget :: String
2182
drbdDelayTarget = "c-delay-target"
2183

    
2184
drbdMaxRate :: String
2185
drbdMaxRate = "c-max-rate"
2186

    
2187
drbdMinRate :: String
2188
drbdMinRate = "c-min-rate"
2189

    
2190
lvStripes :: String
2191
lvStripes = "stripes"
2192

    
2193
rbdAccess :: String
2194
rbdAccess = "access"
2195

    
2196
rbdPool :: String
2197
rbdPool = "pool"
2198

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

    
2224
diskDtParameters :: FrozenSet String
2225
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2226

    
2227
-- * Dynamic disk parameters
2228

    
2229
ddpLocalIp :: String
2230
ddpLocalIp = "local-ip"
2231

    
2232
ddpRemoteIp :: String
2233
ddpRemoteIp = "remote-ip"
2234

    
2235
ddpPort :: String
2236
ddpPort = "port"
2237

    
2238
ddpLocalMinor :: String
2239
ddpLocalMinor = "local-minor"
2240

    
2241
ddpRemoteMinor :: String
2242
ddpRemoteMinor = "remote-minor"
2243

    
2244
-- * OOB supported commands
2245

    
2246
oobPowerOn :: String
2247
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2248

    
2249
oobPowerOff :: String
2250
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2251

    
2252
oobPowerCycle :: String
2253
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2254

    
2255
oobPowerStatus :: String
2256
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2257

    
2258
oobHealth :: String
2259
oobHealth = Types.oobCommandToRaw OobHealth
2260

    
2261
oobCommands :: FrozenSet String
2262
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2263

    
2264
oobPowerStatusPowered :: String
2265
oobPowerStatusPowered = "powered"
2266

    
2267
-- | 60 seconds
2268
oobTimeout :: Int
2269
oobTimeout = 60
2270

    
2271
-- | 2 seconds
2272
oobPowerDelay :: Double
2273
oobPowerDelay = 2.0
2274

    
2275
oobStatusCritical :: String
2276
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2277

    
2278
oobStatusOk :: String
2279
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2280

    
2281
oobStatusUnknown :: String
2282
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2283

    
2284
oobStatusWarning :: String
2285
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2286

    
2287
oobStatuses :: FrozenSet String
2288
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2289

    
2290
-- | Instance Parameters Profile
2291
ppDefault :: String
2292
ppDefault = "default"
2293

    
2294
-- * nic* constants are used inside the ganeti config
2295

    
2296
nicLink :: String
2297
nicLink = "link"
2298

    
2299
nicMode :: String
2300
nicMode = "mode"
2301

    
2302
nicVlan :: String
2303
nicVlan = "vlan"
2304

    
2305
nicsParameterTypes :: Map String VType
2306
nicsParameterTypes =
2307
  Map.fromList [(nicMode, vtypeString),
2308
                (nicLink, vtypeString),
2309
                (nicVlan, vtypeString)]
2310

    
2311
nicsParameters :: FrozenSet String
2312
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2313

    
2314
nicModeBridged :: String
2315
nicModeBridged = Types.nICModeToRaw NMBridged
2316

    
2317
nicModeRouted :: String
2318
nicModeRouted = Types.nICModeToRaw NMRouted
2319

    
2320
nicModeOvs :: String
2321
nicModeOvs = Types.nICModeToRaw NMOvs
2322

    
2323
nicIpPool :: String
2324
nicIpPool = Types.nICModeToRaw NMPool
2325

    
2326
nicValidModes :: FrozenSet String
2327
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2328

    
2329
releaseAction :: String
2330
releaseAction = "release"
2331

    
2332
reserveAction :: String
2333
reserveAction = "reserve"
2334

    
2335
-- * idisk* constants are used in opcodes, to create/change disks
2336

    
2337
idiskAdopt :: String
2338
idiskAdopt = "adopt"
2339

    
2340
idiskMetavg :: String
2341
idiskMetavg = "metavg"
2342

    
2343
idiskMode :: String
2344
idiskMode = "mode"
2345

    
2346
idiskName :: String
2347
idiskName = "name"
2348

    
2349
idiskSize :: String
2350
idiskSize = "size"
2351

    
2352
idiskSpindles :: String
2353
idiskSpindles = "spindles"
2354

    
2355
idiskVg :: String
2356
idiskVg = "vg"
2357

    
2358
idiskProvider :: String
2359
idiskProvider = "provider"
2360

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

    
2372
idiskParams :: FrozenSet String
2373
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2374

    
2375
modifiableIdiskParamsTypes :: Map String VType
2376
modifiableIdiskParamsTypes =
2377
  Map.fromList [(idiskMode, VTypeString),
2378
                (idiskName, VTypeString)]
2379

    
2380
modifiableIdiskParams :: FrozenSet String
2381
modifiableIdiskParams =
2382
  ConstantUtils.mkSet (Map.keys modifiableIdiskParamsTypes)
2383

    
2384
-- * inic* constants are used in opcodes, to create/change nics
2385

    
2386
inicBridge :: String
2387
inicBridge = "bridge"
2388

    
2389
inicIp :: String
2390
inicIp = "ip"
2391

    
2392
inicLink :: String
2393
inicLink = "link"
2394

    
2395
inicMac :: String
2396
inicMac = "mac"
2397

    
2398
inicMode :: String
2399
inicMode = "mode"
2400

    
2401
inicName :: String
2402
inicName = "name"
2403

    
2404
inicNetwork :: String
2405
inicNetwork = "network"
2406

    
2407
inicVlan :: String
2408
inicVlan = "vlan"
2409

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

    
2421
inicParams :: FrozenSet String
2422
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2423

    
2424
-- * Hypervisor constants
2425

    
2426
htXenPvm :: String
2427
htXenPvm = Types.hypervisorToRaw XenPvm
2428

    
2429
htFake :: String
2430
htFake = Types.hypervisorToRaw Fake
2431

    
2432
htXenHvm :: String
2433
htXenHvm = Types.hypervisorToRaw XenHvm
2434

    
2435
htKvm :: String
2436
htKvm = Types.hypervisorToRaw Kvm
2437

    
2438
htChroot :: String
2439
htChroot = Types.hypervisorToRaw Chroot
2440

    
2441
htLxc :: String
2442
htLxc = Types.hypervisorToRaw Lxc
2443

    
2444
hyperTypes :: FrozenSet String
2445
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2446

    
2447
htsReqPort :: FrozenSet String
2448
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2449

    
2450
vncBasePort :: Int
2451
vncBasePort = 5900
2452

    
2453
vncDefaultBindAddress :: String
2454
vncDefaultBindAddress = ip4AddressAny
2455

    
2456
-- * NIC types
2457

    
2458
htNicE1000 :: String
2459
htNicE1000 = "e1000"
2460

    
2461
htNicI82551 :: String
2462
htNicI82551 = "i82551"
2463

    
2464
htNicI8259er :: String
2465
htNicI8259er = "i82559er"
2466

    
2467
htNicI85557b :: String
2468
htNicI85557b = "i82557b"
2469

    
2470
htNicNe2kIsa :: String
2471
htNicNe2kIsa = "ne2k_isa"
2472

    
2473
htNicNe2kPci :: String
2474
htNicNe2kPci = "ne2k_pci"
2475

    
2476
htNicParavirtual :: String
2477
htNicParavirtual = "paravirtual"
2478

    
2479
htNicPcnet :: String
2480
htNicPcnet = "pcnet"
2481

    
2482
htNicRtl8139 :: String
2483
htNicRtl8139 = "rtl8139"
2484

    
2485
htHvmValidNicTypes :: FrozenSet String
2486
htHvmValidNicTypes =
2487
  ConstantUtils.mkSet [htNicE1000,
2488
                       htNicNe2kIsa,
2489
                       htNicNe2kPci,
2490
                       htNicParavirtual,
2491
                       htNicRtl8139]
2492

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

    
2505
-- * Vif types
2506

    
2507
-- | Default vif type in xen-hvm
2508
htHvmVifIoemu :: String
2509
htHvmVifIoemu = "ioemu"
2510

    
2511
htHvmVifVif :: String
2512
htHvmVifVif = "vif"
2513

    
2514
htHvmValidVifTypes :: FrozenSet String
2515
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2516

    
2517
-- * Disk types
2518

    
2519
htDiskIde :: String
2520
htDiskIde = "ide"
2521

    
2522
htDiskIoemu :: String
2523
htDiskIoemu = "ioemu"
2524

    
2525
htDiskMtd :: String
2526
htDiskMtd = "mtd"
2527

    
2528
htDiskParavirtual :: String
2529
htDiskParavirtual = "paravirtual"
2530

    
2531
htDiskPflash :: String
2532
htDiskPflash = "pflash"
2533

    
2534
htDiskScsi :: String
2535
htDiskScsi = "scsi"
2536

    
2537
htDiskSd :: String
2538
htDiskSd = "sd"
2539

    
2540
htHvmValidDiskTypes :: FrozenSet String
2541
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2542

    
2543
htKvmValidDiskTypes :: FrozenSet String
2544
htKvmValidDiskTypes =
2545
  ConstantUtils.mkSet [htDiskIde,
2546
                       htDiskMtd,
2547
                       htDiskParavirtual,
2548
                       htDiskPflash,
2549
                       htDiskScsi,
2550
                       htDiskSd]
2551

    
2552
htCacheDefault :: String
2553
htCacheDefault = "default"
2554

    
2555
htCacheNone :: String
2556
htCacheNone = "none"
2557

    
2558
htCacheWback :: String
2559
htCacheWback = "writeback"
2560

    
2561
htCacheWthrough :: String
2562
htCacheWthrough = "writethrough"
2563

    
2564
htValidCacheTypes :: FrozenSet String
2565
htValidCacheTypes =
2566
  ConstantUtils.mkSet [htCacheDefault,
2567
                       htCacheNone,
2568
                       htCacheWback,
2569
                       htCacheWthrough]
2570

    
2571
-- * Mouse types
2572

    
2573
htMouseMouse :: String
2574
htMouseMouse = "mouse"
2575

    
2576
htMouseTablet :: String
2577
htMouseTablet = "tablet"
2578

    
2579
htKvmValidMouseTypes :: FrozenSet String
2580
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2581

    
2582
-- * Boot order
2583

    
2584
htBoCdrom :: String
2585
htBoCdrom = "cdrom"
2586

    
2587
htBoDisk :: String
2588
htBoDisk = "disk"
2589

    
2590
htBoFloppy :: String
2591
htBoFloppy = "floppy"
2592

    
2593
htBoNetwork :: String
2594
htBoNetwork = "network"
2595

    
2596
htKvmValidBoTypes :: FrozenSet String
2597
htKvmValidBoTypes =
2598
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2599

    
2600
-- * SPICE lossless image compression options
2601

    
2602
htKvmSpiceLosslessImgComprAutoGlz :: String
2603
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2604

    
2605
htKvmSpiceLosslessImgComprAutoLz :: String
2606
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2607

    
2608
htKvmSpiceLosslessImgComprGlz :: String
2609
htKvmSpiceLosslessImgComprGlz = "glz"
2610

    
2611
htKvmSpiceLosslessImgComprLz :: String
2612
htKvmSpiceLosslessImgComprLz = "lz"
2613

    
2614
htKvmSpiceLosslessImgComprOff :: String
2615
htKvmSpiceLosslessImgComprOff = "off"
2616

    
2617
htKvmSpiceLosslessImgComprQuic :: String
2618
htKvmSpiceLosslessImgComprQuic = "quic"
2619

    
2620
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2621
htKvmSpiceValidLosslessImgComprOptions =
2622
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2623
                       htKvmSpiceLosslessImgComprAutoLz,
2624
                       htKvmSpiceLosslessImgComprGlz,
2625
                       htKvmSpiceLosslessImgComprLz,
2626
                       htKvmSpiceLosslessImgComprOff,
2627
                       htKvmSpiceLosslessImgComprQuic]
2628

    
2629
htKvmSpiceLossyImgComprAlways :: String
2630
htKvmSpiceLossyImgComprAlways = "always"
2631

    
2632
htKvmSpiceLossyImgComprAuto :: String
2633
htKvmSpiceLossyImgComprAuto = "auto"
2634

    
2635
htKvmSpiceLossyImgComprNever :: String
2636
htKvmSpiceLossyImgComprNever = "never"
2637

    
2638
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2639
htKvmSpiceValidLossyImgComprOptions =
2640
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2641
                       htKvmSpiceLossyImgComprAuto,
2642
                       htKvmSpiceLossyImgComprNever]
2643

    
2644
-- * SPICE video stream detection
2645

    
2646
htKvmSpiceVideoStreamDetectionAll :: String
2647
htKvmSpiceVideoStreamDetectionAll = "all"
2648

    
2649
htKvmSpiceVideoStreamDetectionFilter :: String
2650
htKvmSpiceVideoStreamDetectionFilter = "filter"
2651

    
2652
htKvmSpiceVideoStreamDetectionOff :: String
2653
htKvmSpiceVideoStreamDetectionOff = "off"
2654

    
2655
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2656
htKvmSpiceValidVideoStreamDetectionOptions =
2657
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2658
                       htKvmSpiceVideoStreamDetectionFilter,
2659
                       htKvmSpiceVideoStreamDetectionOff]
2660

    
2661
-- * Security models
2662

    
2663
htSmNone :: String
2664
htSmNone = "none"
2665

    
2666
htSmPool :: String
2667
htSmPool = "pool"
2668

    
2669
htSmUser :: String
2670
htSmUser = "user"
2671

    
2672
htKvmValidSmTypes :: FrozenSet String
2673
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2674

    
2675
-- * Kvm flag values
2676

    
2677
htKvmDisabled :: String
2678
htKvmDisabled = "disabled"
2679

    
2680
htKvmEnabled :: String
2681
htKvmEnabled = "enabled"
2682

    
2683
htKvmFlagValues :: FrozenSet String
2684
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2685

    
2686
-- * Migration type
2687

    
2688
htMigrationLive :: String
2689
htMigrationLive = Types.migrationModeToRaw MigrationLive
2690

    
2691
htMigrationNonlive :: String
2692
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2693

    
2694
htMigrationModes :: FrozenSet String
2695
htMigrationModes =
2696
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2697

    
2698
-- * Cluster verify steps
2699

    
2700
verifyNplusoneMem :: String
2701
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2702

    
2703
verifyOptionalChecks :: FrozenSet String
2704
verifyOptionalChecks =
2705
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2706

    
2707
-- * Cluster Verify error classes
2708

    
2709
cvTcluster :: String
2710
cvTcluster = "cluster"
2711

    
2712
cvTgroup :: String
2713
cvTgroup = "group"
2714

    
2715
cvTnode :: String
2716
cvTnode = "node"
2717

    
2718
cvTinstance :: String
2719
cvTinstance = "instance"
2720

    
2721
-- * Cluster Verify error levels
2722

    
2723
cvWarning :: String
2724
cvWarning = "WARNING"
2725

    
2726
cvError :: String
2727
cvError = "ERROR"
2728

    
2729
-- * Cluster Verify error codes and documentation
2730

    
2731
cvEclustercert :: (String, String, String)
2732
cvEclustercert =
2733
  ("cluster",
2734
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2735
   "Cluster certificate files verification failure")
2736

    
2737
cvEclusterclientcert :: (String, String, String)
2738
cvEclusterclientcert =
2739
  ("cluster",
2740
   Types.cVErrorCodeToRaw CvECLUSTERCLIENTCERT,
2741
   "Cluster client certificate files verification failure")
2742

    
2743
cvEclustercfg :: (String, String, String)
2744
cvEclustercfg =
2745
  ("cluster",
2746
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2747
   "Cluster configuration verification failure")
2748

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

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

    
2761
cvEclusterfilecheck :: (String, String, String)
2762
cvEclusterfilecheck =
2763
  ("cluster",
2764
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2765
   "Cluster configuration verification failure")
2766

    
2767
cvEgroupdifferentpvsize :: (String, String, String)
2768
cvEgroupdifferentpvsize =
2769
  ("group",
2770
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2771
   "PVs in the group have different sizes")
2772

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

    
2779
cvEinstancedown :: (String, String, String)
2780
cvEinstancedown =
2781
  ("instance",
2782
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2783
   "Instance not running on its primary node")
2784

    
2785
cvEinstancefaultydisk :: (String, String, String)
2786
cvEinstancefaultydisk =
2787
  ("instance",
2788
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2789
   "Impossible to retrieve status for a disk")
2790

    
2791
cvEinstancelayout :: (String, String, String)
2792
cvEinstancelayout =
2793
  ("instance",
2794
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2795
   "Instance has multiple secondary nodes")
2796

    
2797
cvEinstancemissingcfgparameter :: (String, String, String)
2798
cvEinstancemissingcfgparameter =
2799
  ("instance",
2800
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2801
   "A configuration parameter for an instance is missing")
2802

    
2803
cvEinstancemissingdisk :: (String, String, String)
2804
cvEinstancemissingdisk =
2805
  ("instance",
2806
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2807
   "Missing volume on an instance")
2808

    
2809
cvEinstancepolicy :: (String, String, String)
2810
cvEinstancepolicy =
2811
  ("instance",
2812
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2813
   "Instance does not meet policy")
2814

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

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

    
2827
cvEinstancewrongnode :: (String, String, String)
2828
cvEinstancewrongnode =
2829
  ("instance",
2830
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2831
   "Instance running on the wrong node")
2832

    
2833
cvEnodedrbd :: (String, String, String)
2834
cvEnodedrbd =
2835
  ("node",
2836
   Types.cVErrorCodeToRaw CvENODEDRBD,
2837
   "Error parsing the DRBD status file")
2838

    
2839
cvEnodedrbdhelper :: (String, String, String)
2840
cvEnodedrbdhelper =
2841
  ("node",
2842
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2843
   "Error caused by the DRBD helper")
2844

    
2845
cvEnodedrbdversion :: (String, String, String)
2846
cvEnodedrbdversion =
2847
  ("node",
2848
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2849
   "DRBD version mismatch within a node group")
2850

    
2851
cvEnodefilecheck :: (String, String, String)
2852
cvEnodefilecheck =
2853
  ("node",
2854
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2855
   "Error retrieving the checksum of the node files")
2856

    
2857
cvEnodefilestoragepaths :: (String, String, String)
2858
cvEnodefilestoragepaths =
2859
  ("node",
2860
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2861
   "Detected bad file storage paths")
2862

    
2863
cvEnodefilestoragepathunusable :: (String, String, String)
2864
cvEnodefilestoragepathunusable =
2865
  ("node",
2866
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2867
   "File storage path unusable")
2868

    
2869
cvEnodehooks :: (String, String, String)
2870
cvEnodehooks =
2871
  ("node",
2872
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2873
   "Communication failure in hooks execution")
2874

    
2875
cvEnodehv :: (String, String, String)
2876
cvEnodehv =
2877
  ("node",
2878
   Types.cVErrorCodeToRaw CvENODEHV,
2879
   "Hypervisor parameters verification failure")
2880

    
2881
cvEnodelvm :: (String, String, String)
2882
cvEnodelvm =
2883
  ("node",
2884
   Types.cVErrorCodeToRaw CvENODELVM,
2885
   "LVM-related node error")
2886

    
2887
cvEnoden1 :: (String, String, String)
2888
cvEnoden1 =
2889
  ("node",
2890
   Types.cVErrorCodeToRaw CvENODEN1,
2891
   "Not enough memory to accommodate instance failovers")
2892

    
2893
cvEnodenet :: (String, String, String)
2894
cvEnodenet =
2895
  ("node",
2896
   Types.cVErrorCodeToRaw CvENODENET,
2897
   "Network-related node error")
2898

    
2899
cvEnodeoobpath :: (String, String, String)
2900
cvEnodeoobpath =
2901
  ("node",
2902
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2903
   "Invalid Out Of Band path")
2904

    
2905
cvEnodeorphaninstance :: (String, String, String)
2906
cvEnodeorphaninstance =
2907
  ("node",
2908
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2909
   "Unknown intance running on a node")
2910

    
2911
cvEnodeorphanlv :: (String, String, String)
2912
cvEnodeorphanlv =
2913
  ("node",
2914
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2915
   "Unknown LVM logical volume")
2916

    
2917
cvEnodeos :: (String, String, String)
2918
cvEnodeos =
2919
  ("node",
2920
   Types.cVErrorCodeToRaw CvENODEOS,
2921
   "OS-related node error")
2922

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

    
2929
cvEnodesetup :: (String, String, String)
2930
cvEnodesetup =
2931
  ("node",
2932
   Types.cVErrorCodeToRaw CvENODESETUP,
2933
   "Node setup error")
2934

    
2935
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2936
cvEnodesharedfilestoragepathunusable =
2937
  ("node",
2938
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2939
   "Shared file storage path unusable")
2940

    
2941
cvEnodessh :: (String, String, String)
2942
cvEnodessh =
2943
  ("node",
2944
   Types.cVErrorCodeToRaw CvENODESSH,
2945
   "SSH-related node error")
2946

    
2947
cvEnodetime :: (String, String, String)
2948
cvEnodetime =
2949
  ("node",
2950
   Types.cVErrorCodeToRaw CvENODETIME,
2951
   "Node returned invalid time")
2952

    
2953
cvEnodeuserscripts :: (String, String, String)
2954
cvEnodeuserscripts =
2955
  ("node",
2956
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2957
   "User scripts not present or not executable")
2958

    
2959
cvEnodeversion :: (String, String, String)
2960
cvEnodeversion =
2961
  ("node",
2962
   Types.cVErrorCodeToRaw CvENODEVERSION,
2963
   "Protocol version mismatch or Ganeti version mismatch")
2964

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

    
3007
cvAllEcodesStrings :: FrozenSet String
3008
cvAllEcodesStrings =
3009
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
3010

    
3011
-- * Node verify constants
3012

    
3013
nvBridges :: String
3014
nvBridges = "bridges"
3015

    
3016
nvClientCert :: String
3017
nvClientCert = "client-cert"
3018

    
3019
nvDrbdhelper :: String
3020
nvDrbdhelper = "drbd-helper"
3021

    
3022
nvDrbdversion :: String
3023
nvDrbdversion = "drbd-version"
3024

    
3025
nvDrbdlist :: String
3026
nvDrbdlist = "drbd-list"
3027

    
3028
nvExclusivepvs :: String
3029
nvExclusivepvs = "exclusive-pvs"
3030

    
3031
nvFilelist :: String
3032
nvFilelist = "filelist"
3033

    
3034
nvAcceptedStoragePaths :: String
3035
nvAcceptedStoragePaths = "allowed-file-storage-paths"
3036

    
3037
nvFileStoragePath :: String
3038
nvFileStoragePath = "file-storage-path"
3039

    
3040
nvSharedFileStoragePath :: String
3041
nvSharedFileStoragePath = "shared-file-storage-path"
3042

    
3043
nvHvinfo :: String
3044
nvHvinfo = "hvinfo"
3045

    
3046
nvHvparams :: String
3047
nvHvparams = "hvparms"
3048

    
3049
nvHypervisor :: String
3050
nvHypervisor = "hypervisor"
3051

    
3052
nvInstancelist :: String
3053
nvInstancelist = "instancelist"
3054

    
3055
nvLvlist :: String
3056
nvLvlist = "lvlist"
3057

    
3058
nvMasterip :: String
3059
nvMasterip = "master-ip"
3060

    
3061
nvNodelist :: String
3062
nvNodelist = "nodelist"
3063

    
3064
nvNodenettest :: String
3065
nvNodenettest = "node-net-test"
3066

    
3067
nvNodesetup :: String
3068
nvNodesetup = "nodesetup"
3069

    
3070
nvOobPaths :: String
3071
nvOobPaths = "oob-paths"
3072

    
3073
nvOslist :: String
3074
nvOslist = "oslist"
3075

    
3076
nvPvlist :: String
3077
nvPvlist = "pvlist"
3078

    
3079
nvTime :: String
3080
nvTime = "time"
3081

    
3082
nvUserscripts :: String
3083
nvUserscripts = "user-scripts"
3084

    
3085
nvVersion :: String
3086
nvVersion = "version"
3087

    
3088
nvVglist :: String
3089
nvVglist = "vglist"
3090

    
3091
nvVmnodes :: String
3092
nvVmnodes = "vmnodes"
3093

    
3094
-- * Instance status
3095

    
3096
inststAdmindown :: String
3097
inststAdmindown = Types.instanceStatusToRaw StatusDown
3098

    
3099
inststAdminoffline :: String
3100
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3101

    
3102
inststErrordown :: String
3103
inststErrordown = Types.instanceStatusToRaw ErrorDown
3104

    
3105
inststErrorup :: String
3106
inststErrorup = Types.instanceStatusToRaw ErrorUp
3107

    
3108
inststNodedown :: String
3109
inststNodedown = Types.instanceStatusToRaw NodeDown
3110

    
3111
inststNodeoffline :: String
3112
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3113

    
3114
inststRunning :: String
3115
inststRunning = Types.instanceStatusToRaw Running
3116

    
3117
inststUserdown :: String
3118
inststUserdown = Types.instanceStatusToRaw UserDown
3119

    
3120
inststWrongnode :: String
3121
inststWrongnode = Types.instanceStatusToRaw WrongNode
3122

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

    
3126
-- * Admin states
3127

    
3128
adminstDown :: String
3129
adminstDown = Types.adminStateToRaw AdminDown
3130

    
3131
adminstOffline :: String
3132
adminstOffline = Types.adminStateToRaw AdminOffline
3133

    
3134
adminstUp :: String
3135
adminstUp = Types.adminStateToRaw AdminUp
3136

    
3137
adminstAll :: FrozenSet String
3138
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3139

    
3140
-- * Node roles
3141

    
3142
nrDrained :: String
3143
nrDrained = Types.nodeRoleToRaw NRDrained
3144

    
3145
nrMaster :: String
3146
nrMaster = Types.nodeRoleToRaw NRMaster
3147

    
3148
nrMcandidate :: String
3149
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3150

    
3151
nrOffline :: String
3152
nrOffline = Types.nodeRoleToRaw NROffline
3153

    
3154
nrRegular :: String
3155
nrRegular = Types.nodeRoleToRaw NRRegular
3156

    
3157
nrAll :: FrozenSet String
3158
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3159

    
3160
-- * SSL certificate check constants (in days)
3161

    
3162
sslCertExpirationError :: Int
3163
sslCertExpirationError = 7
3164

    
3165
sslCertExpirationWarn :: Int
3166
sslCertExpirationWarn = 30
3167

    
3168
-- * Allocator framework constants
3169

    
3170
iallocatorVersion :: Int
3171
iallocatorVersion = 2
3172

    
3173
iallocatorDirIn :: String
3174
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3175

    
3176
iallocatorDirOut :: String
3177
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3178

    
3179
validIallocatorDirections :: FrozenSet String
3180
validIallocatorDirections =
3181
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3182

    
3183
iallocatorModeAlloc :: String
3184
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3185

    
3186
iallocatorModeChgGroup :: String
3187
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3188

    
3189
iallocatorModeMultiAlloc :: String
3190
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3191

    
3192
iallocatorModeNodeEvac :: String
3193
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3194

    
3195
iallocatorModeReloc :: String
3196
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3197

    
3198
validIallocatorModes :: FrozenSet String
3199
validIallocatorModes =
3200
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3201

    
3202
iallocatorSearchPath :: [String]
3203
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3204

    
3205
defaultIallocatorShortcut :: String
3206
defaultIallocatorShortcut = "."
3207

    
3208
-- * Node evacuation
3209

    
3210
nodeEvacPri :: String
3211
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3212

    
3213
nodeEvacSec :: String
3214
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3215

    
3216
nodeEvacAll :: String
3217
nodeEvacAll = Types.evacModeToRaw ChangeAll
3218

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

    
3222
-- * Job queue
3223

    
3224
jobQueueVersion :: Int
3225
jobQueueVersion = 1
3226

    
3227
jobQueueSizeHardLimit :: Int
3228
jobQueueSizeHardLimit = 5000
3229

    
3230
jobQueueFilesPerms :: Int
3231
jobQueueFilesPerms = 0o640
3232

    
3233
-- * Unchanged job return
3234

    
3235
jobNotchanged :: String
3236
jobNotchanged = "nochange"
3237

    
3238
-- * Job status
3239

    
3240
jobStatusQueued :: String
3241
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3242

    
3243
jobStatusWaiting :: String
3244
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3245

    
3246
jobStatusCanceling :: String
3247
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3248

    
3249
jobStatusRunning :: String
3250
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3251

    
3252
jobStatusCanceled :: String
3253
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3254

    
3255
jobStatusSuccess :: String
3256
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3257

    
3258
jobStatusError :: String
3259
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3260

    
3261
jobsPending :: FrozenSet String
3262
jobsPending =
3263
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3264

    
3265
jobsFinalized :: FrozenSet String
3266
jobsFinalized =
3267
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3268

    
3269
jobStatusAll :: FrozenSet String
3270
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3271

    
3272
-- * OpCode status
3273

    
3274
-- ** Not yet finalized opcodes
3275

    
3276
opStatusCanceling :: String
3277
opStatusCanceling = "canceling"
3278

    
3279
opStatusQueued :: String
3280
opStatusQueued = "queued"
3281

    
3282
opStatusRunning :: String
3283
opStatusRunning = "running"
3284

    
3285
opStatusWaiting :: String
3286
opStatusWaiting = "waiting"
3287

    
3288
-- ** Finalized opcodes
3289

    
3290
opStatusCanceled :: String
3291
opStatusCanceled = "canceled"
3292

    
3293
opStatusError :: String
3294
opStatusError = "error"
3295

    
3296
opStatusSuccess :: String
3297
opStatusSuccess = "success"
3298

    
3299
opsFinalized :: FrozenSet String
3300
opsFinalized =
3301
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3302

    
3303
-- * OpCode priority
3304

    
3305
opPrioLowest :: Int
3306
opPrioLowest = 19
3307

    
3308
opPrioHighest :: Int
3309
opPrioHighest = -20
3310

    
3311
opPrioLow :: Int
3312
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3313

    
3314
opPrioNormal :: Int
3315
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3316

    
3317
opPrioHigh :: Int
3318
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3319

    
3320
opPrioSubmitValid :: FrozenSet Int
3321
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3322

    
3323
opPrioDefault :: Int
3324
opPrioDefault = opPrioNormal
3325

    
3326
-- * Lock recalculate mode
3327

    
3328
locksAppend :: String
3329
locksAppend = "append"
3330

    
3331
locksReplace :: String
3332
locksReplace = "replace"
3333

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

    
3341
lockAttemptsMaxwait :: Double
3342
lockAttemptsMaxwait = 15.0
3343

    
3344
lockAttemptsMinwait :: Double
3345
lockAttemptsMinwait = 1.0
3346

    
3347
lockAttemptsTimeout :: Int
3348
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3349

    
3350
-- * Execution log types
3351

    
3352
elogMessage :: String
3353
elogMessage = Types.eLogTypeToRaw ELogMessage
3354

    
3355
elogRemoteImport :: String
3356
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3357

    
3358
elogJqueueTest :: String
3359
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3360

    
3361
-- * /etc/hosts modification
3362

    
3363
etcHostsAdd :: String
3364
etcHostsAdd = "add"
3365

    
3366
etcHostsRemove :: String
3367
etcHostsRemove = "remove"
3368

    
3369
-- * Job queue test
3370

    
3371
jqtMsgprefix :: String
3372
jqtMsgprefix = "TESTMSG="
3373

    
3374
jqtExec :: String
3375
jqtExec = "exec"
3376

    
3377
jqtExpandnames :: String
3378
jqtExpandnames = "expandnames"
3379

    
3380
jqtLogmsg :: String
3381
jqtLogmsg = "logmsg"
3382

    
3383
jqtStartmsg :: String
3384
jqtStartmsg = "startmsg"
3385

    
3386
jqtAll :: FrozenSet String
3387
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3388

    
3389
-- * Query resources
3390

    
3391
qrCluster :: String
3392
qrCluster = "cluster"
3393

    
3394
qrExport :: String
3395
qrExport = "export"
3396

    
3397
qrExtstorage :: String
3398
qrExtstorage = "extstorage"
3399

    
3400
qrGroup :: String
3401
qrGroup = "group"
3402

    
3403
qrInstance :: String
3404
qrInstance = "instance"
3405

    
3406
qrJob :: String
3407
qrJob = "job"
3408

    
3409
qrLock :: String
3410
qrLock = "lock"
3411

    
3412
qrNetwork :: String
3413
qrNetwork = "network"
3414

    
3415
qrNode :: String
3416
qrNode = "node"
3417

    
3418
qrOs :: String
3419
qrOs = "os"
3420

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

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

    
3438
-- | List of resources which can be queried using RAPI
3439
qrViaRapi :: FrozenSet String
3440
qrViaRapi = qrViaLuxi
3441

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

    
3446
-- * Query field types
3447

    
3448
qftBool :: String
3449
qftBool = "bool"
3450

    
3451
qftNumber :: String
3452
qftNumber = "number"
3453

    
3454
qftOther :: String
3455
qftOther = "other"
3456

    
3457
qftText :: String
3458
qftText = "text"
3459

    
3460
qftTimestamp :: String
3461
qftTimestamp = "timestamp"
3462

    
3463
qftUnit :: String
3464
qftUnit = "unit"
3465

    
3466
qftUnknown :: String
3467
qftUnknown = "unknown"
3468

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

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

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

    
3489
rsNormal :: Int
3490
rsNormal = 0
3491

    
3492
-- | Resource marked offline
3493
rsOffline :: Int
3494
rsOffline = 4
3495

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

    
3502
rsUnknown :: Int
3503
rsUnknown = 1
3504

    
3505
rsAll :: FrozenSet Int
3506
rsAll =
3507
  ConstantUtils.mkSet [rsNodata,
3508
                       rsNormal,
3509
                       rsOffline,
3510
                       rsUnavail,
3511
                       rsUnknown]
3512

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

    
3521
-- * Max dynamic devices
3522

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

    
3526
maxNics :: Int
3527
maxNics = Types.maxNics
3528

    
3529
-- | SSCONF file prefix
3530
ssconfFileprefix :: String
3531
ssconfFileprefix = "ssconf_"
3532

    
3533
-- * SSCONF keys
3534

    
3535
ssClusterName :: String
3536
ssClusterName = "cluster_name"
3537

    
3538
ssClusterTags :: String
3539
ssClusterTags = "cluster_tags"
3540

    
3541
ssFileStorageDir :: String
3542
ssFileStorageDir = "file_storage_dir"
3543

    
3544
ssSharedFileStorageDir :: String
3545
ssSharedFileStorageDir = "shared_file_storage_dir"
3546

    
3547
ssGlusterStorageDir :: String
3548
ssGlusterStorageDir = "gluster_storage_dir"
3549

    
3550
ssMasterCandidates :: String
3551
ssMasterCandidates = "master_candidates"
3552

    
3553
ssMasterCandidatesIps :: String
3554
ssMasterCandidatesIps = "master_candidates_ips"
3555

    
3556
ssMasterCandidatesCerts :: String
3557
ssMasterCandidatesCerts = "master_candidates_certs"
3558

    
3559
ssMasterIp :: String
3560
ssMasterIp = "master_ip"
3561

    
3562
ssMasterNetdev :: String
3563
ssMasterNetdev = "master_netdev"
3564

    
3565
ssMasterNetmask :: String
3566
ssMasterNetmask = "master_netmask"
3567

    
3568
ssMasterNode :: String
3569
ssMasterNode = "master_node"
3570

    
3571
ssNodeList :: String
3572
ssNodeList = "node_list"
3573

    
3574
ssNodePrimaryIps :: String
3575
ssNodePrimaryIps = "node_primary_ips"
3576

    
3577
ssNodeSecondaryIps :: String
3578
ssNodeSecondaryIps = "node_secondary_ips"
3579

    
3580
ssOfflineNodes :: String
3581
ssOfflineNodes = "offline_nodes"
3582

    
3583
ssOnlineNodes :: String
3584
ssOnlineNodes = "online_nodes"
3585

    
3586
ssPrimaryIpFamily :: String
3587
ssPrimaryIpFamily = "primary_ip_family"
3588

    
3589
ssInstanceList :: String
3590
ssInstanceList = "instance_list"
3591

    
3592
ssReleaseVersion :: String
3593
ssReleaseVersion = "release_version"
3594

    
3595
ssHypervisorList :: String
3596
ssHypervisorList = "hypervisor_list"
3597

    
3598
ssMaintainNodeHealth :: String
3599
ssMaintainNodeHealth = "maintain_node_health"
3600

    
3601
ssUidPool :: String
3602
ssUidPool = "uid_pool"
3603

    
3604
ssNodegroups :: String
3605
ssNodegroups = "nodegroups"
3606

    
3607
ssNetworks :: String
3608
ssNetworks = "networks"
3609

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

    
3615
-- * Hvparams keys
3616

    
3617
ssHvparamsXenChroot :: String
3618
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3619

    
3620
ssHvparamsXenFake :: String
3621
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3622

    
3623
ssHvparamsXenHvm :: String
3624
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3625

    
3626
ssHvparamsXenKvm :: String
3627
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3628

    
3629
ssHvparamsXenLxc :: String
3630
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3631

    
3632
ssHvparamsXenPvm :: String
3633
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3634

    
3635
validSsHvparamsKeys :: FrozenSet String
3636
validSsHvparamsKeys =
3637
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3638
                       ssHvparamsXenLxc,
3639
                       ssHvparamsXenFake,
3640
                       ssHvparamsXenHvm,
3641
                       ssHvparamsXenKvm,
3642
                       ssHvparamsXenPvm]
3643

    
3644
ssFilePerms :: Int
3645
ssFilePerms = 0o444
3646

    
3647
-- | Cluster wide default parameters
3648
defaultEnabledHypervisor :: String
3649
defaultEnabledHypervisor = htXenPvm
3650

    
3651
hvcDefaults :: Map Hypervisor (Map String PyValueEx)
3652
hvcDefaults =
3653
  Map.fromList
3654
  [ (XenPvm, Map.fromList
3655
             [ (hvUseBootloader,  PyValueEx False)
3656
             , (hvBootloaderPath, PyValueEx xenBootloader)
3657
             , (hvBootloaderArgs, PyValueEx "")
3658
             , (hvKernelPath,     PyValueEx xenKernel)
3659
             , (hvInitrdPath,     PyValueEx "")
3660
             , (hvRootPath,       PyValueEx "/dev/xvda1")
3661
             , (hvKernelArgs,     PyValueEx "ro")
3662
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3663
             , (hvMigrationMode,  PyValueEx htMigrationLive)
3664
             , (hvBlockdevPrefix, PyValueEx "sd")
3665
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3666
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3667
             , (hvCpuCap,         PyValueEx (0 :: Int))
3668
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3669
             , (hvVifScript,      PyValueEx "")
3670
             , (hvXenCmd,         PyValueEx xenCmdXm)
3671
             , (hvXenCpuid,       PyValueEx "")
3672
             , (hvSoundhw,        PyValueEx "")
3673
             ])
3674
  , (XenHvm, Map.fromList
3675
             [ (hvBootOrder,      PyValueEx "cd")
3676
             , (hvCdromImagePath, PyValueEx "")
3677
             , (hvNicType,        PyValueEx htNicRtl8139)
3678
             , (hvDiskType,       PyValueEx htDiskParavirtual)
3679
             , (hvVncBindAddress, PyValueEx ip4AddressAny)
3680
             , (hvAcpi,           PyValueEx True)
3681
             , (hvPae,            PyValueEx True)
3682
             , (hvKernelPath,     PyValueEx "/usr/lib/xen/boot/hvmloader")
3683
             , (hvDeviceModel,    PyValueEx "/usr/lib/xen/bin/qemu-dm")
3684
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3685
             , (hvMigrationMode,  PyValueEx htMigrationNonlive)
3686
             , (hvUseLocaltime,   PyValueEx False)
3687
             , (hvBlockdevPrefix, PyValueEx "hd")
3688
             , (hvPassthrough,    PyValueEx "")
3689
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3690
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3691
             , (hvCpuCap,         PyValueEx (0 :: Int))
3692
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3693
             , (hvVifType,        PyValueEx htHvmVifIoemu)
3694
             , (hvVifScript,      PyValueEx "")
3695
             , (hvViridian,       PyValueEx False)
3696
             , (hvXenCmd,         PyValueEx xenCmdXm)
3697
             , (hvXenCpuid,       PyValueEx "")
3698
             , (hvSoundhw,        PyValueEx "")
3699
             ])
3700
  , (Kvm, Map.fromList
3701
          [ (hvKvmPath,                         PyValueEx kvmPath)
3702
          , (hvKernelPath,                      PyValueEx kvmKernel)
3703
          , (hvInitrdPath,                      PyValueEx "")
3704
          , (hvKernelArgs,                      PyValueEx "ro")
3705
          , (hvRootPath,                        PyValueEx "/dev/vda1")
3706
          , (hvAcpi,                            PyValueEx True)
3707
          , (hvSerialConsole,                   PyValueEx True)
3708
          , (hvSerialSpeed,                     PyValueEx (38400 :: Int))
3709
          , (hvVncBindAddress,                  PyValueEx "")
3710
          , (hvVncTls,                          PyValueEx False)
3711
          , (hvVncX509,                         PyValueEx "")
3712
          , (hvVncX509Verify,                   PyValueEx False)
3713
          , (hvVncPasswordFile,                 PyValueEx "")
3714
          , (hvKvmSpiceBind,                    PyValueEx "")
3715
          , (hvKvmSpiceIpVersion,           PyValueEx ifaceNoIpVersionSpecified)
3716
          , (hvKvmSpicePasswordFile,            PyValueEx "")
3717
          , (hvKvmSpiceLosslessImgCompr,        PyValueEx "")
3718
          , (hvKvmSpiceJpegImgCompr,            PyValueEx "")
3719
          , (hvKvmSpiceZlibGlzImgCompr,         PyValueEx "")
3720
          , (hvKvmSpiceStreamingVideoDetection, PyValueEx "")
3721
          , (hvKvmSpiceAudioCompr,              PyValueEx True)
3722
          , (hvKvmSpiceUseTls,                  PyValueEx False)
3723
          , (hvKvmSpiceTlsCiphers,              PyValueEx opensslCiphers)
3724
          , (hvKvmSpiceUseVdagent,              PyValueEx True)
3725
          , (hvKvmFloppyImagePath,              PyValueEx "")
3726
          , (hvCdromImagePath,                  PyValueEx "")
3727
          , (hvKvmCdrom2ImagePath,              PyValueEx "")
3728
          , (hvBootOrder,                       PyValueEx htBoDisk)
3729
          , (hvNicType,                         PyValueEx htNicParavirtual)
3730
          , (hvDiskType,                        PyValueEx htDiskParavirtual)
3731
          , (hvKvmCdromDiskType,                PyValueEx "")
3732
          , (hvUsbMouse,                        PyValueEx "")
3733
          , (hvKeymap,                          PyValueEx "")
3734
          , (hvMigrationPort,                   PyValueEx (8102 :: Int))
3735
          , (hvMigrationBandwidth,              PyValueEx (32 :: Int))
3736
          , (hvMigrationDowntime,               PyValueEx (30 :: Int))
3737
          , (hvMigrationMode,                   PyValueEx htMigrationLive)
3738
          , (hvUseLocaltime,                    PyValueEx False)
3739
          , (hvDiskCache,                       PyValueEx htCacheDefault)
3740
          , (hvSecurityModel,                   PyValueEx htSmNone)
3741
          , (hvSecurityDomain,                  PyValueEx "")
3742
          , (hvKvmFlag,                         PyValueEx "")
3743
          , (hvVhostNet,                        PyValueEx False)
3744
          , (hvKvmUseChroot,                    PyValueEx False)
3745
          , (hvKvmUserShutdown,                 PyValueEx False)
3746
          , (hvMemPath,                         PyValueEx "")
3747
          , (hvRebootBehavior,                  PyValueEx instanceRebootAllowed)
3748
          , (hvCpuMask,                         PyValueEx cpuPinningAll)
3749
          , (hvCpuType,                         PyValueEx "")
3750
          , (hvCpuCores,                        PyValueEx (0 :: Int))
3751
          , (hvCpuThreads,                      PyValueEx (0 :: Int))
3752
          , (hvCpuSockets,                      PyValueEx (0 :: Int))
3753
          , (hvSoundhw,                         PyValueEx "")
3754
          , (hvUsbDevices,                      PyValueEx "")
3755
          , (hvVga,                             PyValueEx "")
3756
          , (hvKvmExtra,                        PyValueEx "")
3757
          , (hvKvmMachineVersion,               PyValueEx "")
3758
          , (hvVnetHdr,                         PyValueEx True)])
3759
  , (Fake, Map.fromList [(hvMigrationMode, PyValueEx htMigrationLive)])
3760
  , (Chroot, Map.fromList [(hvInitScript, PyValueEx "/ganeti-chroot")])
3761
  , (Lxc, Map.fromList [(hvCpuMask, PyValueEx "")])
3762
  ]
3763

    
3764
hvcGlobals :: FrozenSet String
3765
hvcGlobals =
3766
  ConstantUtils.mkSet [hvMigrationBandwidth,
3767
                       hvMigrationMode,
3768
                       hvMigrationPort,
3769
                       hvXenCmd]
3770

    
3771
becDefaults :: Map String PyValueEx
3772
becDefaults =
3773
  Map.fromList
3774
  [ (beMinmem, PyValueEx (128 :: Int))
3775
  , (beMaxmem, PyValueEx (128 :: Int))
3776
  , (beVcpus, PyValueEx (1 :: Int))
3777
  , (beAutoBalance, PyValueEx True)
3778
  , (beAlwaysFailover, PyValueEx False)
3779
  , (beSpindleUse, PyValueEx (1 :: Int))
3780
  ]
3781

    
3782
ndcDefaults :: Map String PyValueEx
3783
ndcDefaults =
3784
  Map.fromList
3785
  [ (ndOobProgram,       PyValueEx "")
3786
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3787
  , (ndExclusiveStorage, PyValueEx False)
3788
  , (ndOvs,              PyValueEx False)
3789
  , (ndOvsName,          PyValueEx defaultOvs)
3790
  , (ndOvsLink,          PyValueEx "")
3791
  , (ndSshPort,          PyValueEx (22 :: Int))
3792
  ]
3793

    
3794
ndcGlobals :: FrozenSet String
3795
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3796

    
3797
-- | Default delay target measured in sectors
3798
defaultDelayTarget :: Int
3799
defaultDelayTarget = 1
3800

    
3801
defaultDiskCustom :: String
3802
defaultDiskCustom = ""
3803

    
3804
defaultDiskResync :: Bool
3805
defaultDiskResync = False
3806

    
3807
-- | Default fill target measured in sectors
3808
defaultFillTarget :: Int
3809
defaultFillTarget = 0
3810

    
3811
-- | Default mininum rate measured in KiB/s
3812
defaultMinRate :: Int
3813
defaultMinRate = 4 * 1024
3814

    
3815
defaultNetCustom :: String
3816
defaultNetCustom = ""
3817

    
3818
-- | Default plan ahead measured in sectors
3819
--
3820
-- The default values for the DRBD dynamic resync speed algorithm are
3821
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3822
-- (that we don't need to set to 0, because we have a separate option
3823
-- to enable it) and for c-max-rate, that we cap to the default value
3824
-- for the static resync rate.
3825
defaultPlanAhead :: Int
3826
defaultPlanAhead = 20
3827

    
3828
defaultRbdPool :: String
3829
defaultRbdPool = "rbd"
3830

    
3831
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3832
diskLdDefaults =
3833
  Map.fromList
3834
  [ (DTBlock, Map.empty)
3835
  , (DTDrbd8, Map.fromList
3836
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3837
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3838
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3839
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3840
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3841
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3842
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3843
              , (ldpMinRate,       PyValueEx defaultMinRate)
3844
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3845
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3846
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3847
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3848
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3849
              ])
3850
  , (DTExt, Map.empty)
3851
  , (DTFile, Map.empty)
3852
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3853
  , (DTRbd, Map.fromList
3854
            [ (ldpPool, PyValueEx defaultRbdPool)
3855
            , (ldpAccess, PyValueEx diskKernelspace)
3856
            ])
3857
  , (DTSharedFile, Map.empty)
3858
  , (DTGluster, Map.fromList
3859
                [ (rbdAccess, PyValueEx diskKernelspace)
3860
                , (glusterHost, PyValueEx glusterHostDefault)
3861
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3862
                , (glusterPort, PyValueEx glusterPortDefault)
3863
                ])
3864
  ]
3865

    
3866
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3867
diskDtDefaults =
3868
  Map.fromList
3869
  [ (DTBlock,      Map.empty)
3870
  , (DTDiskless,   Map.empty)
3871
  , (DTDrbd8,      Map.fromList
3872
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3873
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3874
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3875
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3876
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3877
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3878
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3879
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3880
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3881
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3882
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3883
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3884
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3885
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3886
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3887
                   ])
3888
  , (DTExt,        Map.empty)
3889
  , (DTFile,       Map.empty)
3890
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3891
  , (DTRbd,        Map.fromList
3892
                   [ (rbdPool, PyValueEx defaultRbdPool)
3893
                   , (rbdAccess, PyValueEx diskKernelspace)
3894
                   ])
3895
  , (DTSharedFile, Map.empty)
3896
  , (DTGluster, Map.fromList
3897
                [ (rbdAccess, PyValueEx diskKernelspace)
3898
                , (glusterHost, PyValueEx glusterHostDefault)
3899
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3900
                , (glusterPort, PyValueEx glusterPortDefault)
3901
                ])
3902
  ]
3903

    
3904
niccDefaults :: Map String PyValueEx
3905
niccDefaults =
3906
  Map.fromList
3907
  [ (nicMode, PyValueEx nicModeBridged)
3908
  , (nicLink, PyValueEx defaultBridge)
3909
  , (nicVlan, PyValueEx "")
3910
  ]
3911

    
3912
-- | All of the following values are quite arbitrary - there are no
3913
-- "good" defaults, these must be customised per-site
3914
ispecsMinmaxDefaults :: Map String (Map String Int)
3915
ispecsMinmaxDefaults =
3916
  Map.fromList
3917
  [(ispecsMin,
3918
    Map.fromList
3919
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3920
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3921
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3922
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3923
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3924
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3925
   (ispecsMax,
3926
    Map.fromList
3927
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3928
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3929
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3930
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3931
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3932
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3933

    
3934
ipolicyDefaults :: Map String PyValueEx
3935
ipolicyDefaults =
3936
  Map.fromList
3937
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3938
  , (ispecsStd,           PyValueEx (Map.fromList
3939
                                     [ (ispecMemSize,    128)
3940
                                     , (ispecCpuCount,   1)
3941
                                     , (ispecDiskCount,  1)
3942
                                     , (ispecDiskSize,   1024)
3943
                                     , (ispecNicCount,   1)
3944
                                     , (ispecSpindleUse, 1)
3945
                                     ] :: Map String Int))
3946
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3947
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3948
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3949
  ]
3950

    
3951
masterPoolSizeDefault :: Int
3952
masterPoolSizeDefault = 10
3953

    
3954
-- * Exclusive storage
3955

    
3956
-- | Error margin used to compare physical disks
3957
partMargin :: Double
3958
partMargin = 0.01
3959

    
3960
-- | Space reserved when creating instance disks
3961
partReserved :: Double
3962
partReserved = 0.02
3963

    
3964
-- * Luxid job scheduling
3965

    
3966
-- | Time intervall in seconds for polling updates on the job queue. This
3967
-- intervall is only relevant if the number of running jobs reaches the maximal
3968
-- allowed number, as otherwise new jobs will be started immediately anyway.
3969
-- Also, as jobs are watched via inotify, scheduling usually works independent
3970
-- of polling. Therefore we chose a sufficiently large interval, in the order of
3971
-- 5 minutes. As with the interval for reloading the configuration, we chose a
3972
-- prime number to avoid accidental 'same wakeup' with other processes.
3973
luxidJobqueuePollInterval :: Int
3974
luxidJobqueuePollInterval = 307
3975

    
3976
-- | The default value for the maximal number of jobs to be running at the same
3977
-- time. Once the maximal number is reached, new jobs will just be queued and
3978
-- only started, once some of the other jobs have finished.
3979
luxidMaximalRunningJobsDefault :: Int
3980
luxidMaximalRunningJobsDefault = 20
3981

    
3982
-- * Confd
3983

    
3984
confdProtocolVersion :: Int
3985
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3986

    
3987
-- Confd request type
3988

    
3989
confdReqPing :: Int
3990
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3991

    
3992
confdReqNodeRoleByname :: Int
3993
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3994

    
3995
confdReqNodePipByInstanceIp :: Int
3996
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3997

    
3998
confdReqClusterMaster :: Int
3999
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
4000

    
4001
confdReqNodePipList :: Int
4002
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
4003

    
4004
confdReqMcPipList :: Int
4005
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
4006

    
4007
confdReqInstancesIpsList :: Int
4008
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
4009

    
4010
confdReqNodeDrbd :: Int
4011
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
4012

    
4013
confdReqNodeInstances :: Int
4014
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
4015

    
4016
confdReqs :: FrozenSet Int
4017
confdReqs =
4018
  ConstantUtils.mkSet .
4019
  map Types.confdRequestTypeToRaw $
4020
  [minBound..] \\ [ReqNodeInstances]
4021

    
4022
-- * Confd request type
4023

    
4024
confdReqfieldName :: Int
4025
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
4026

    
4027
confdReqfieldIp :: Int
4028
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
4029

    
4030
confdReqfieldMnodePip :: Int
4031
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
4032

    
4033
-- * Confd repl status
4034

    
4035
confdReplStatusOk :: Int
4036
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
4037

    
4038
confdReplStatusError :: Int
4039
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
4040

    
4041
confdReplStatusNotimplemented :: Int
4042
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
4043

    
4044
confdReplStatuses :: FrozenSet Int
4045
confdReplStatuses =
4046
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
4047

    
4048
-- * Confd node role
4049

    
4050
confdNodeRoleMaster :: Int
4051
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
4052

    
4053
confdNodeRoleCandidate :: Int
4054
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
4055

    
4056
confdNodeRoleOffline :: Int
4057
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
4058

    
4059
confdNodeRoleDrained :: Int
4060
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
4061

    
4062
confdNodeRoleRegular :: Int
4063
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
4064

    
4065
-- * A few common errors for confd
4066

    
4067
confdErrorUnknownEntry :: Int
4068
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
4069

    
4070
confdErrorInternal :: Int
4071
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
4072

    
4073
confdErrorArgument :: Int
4074
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
4075

    
4076
-- * Confd request query fields
4077

    
4078
confdReqqLink :: String
4079
confdReqqLink = ConstantUtils.confdReqqLink
4080

    
4081
confdReqqIp :: String
4082
confdReqqIp = ConstantUtils.confdReqqIp
4083

    
4084
confdReqqIplist :: String
4085
confdReqqIplist = ConstantUtils.confdReqqIplist
4086

    
4087
confdReqqFields :: String
4088
confdReqqFields = ConstantUtils.confdReqqFields
4089

    
4090
-- | Each request is "salted" by the current timestamp.
4091
--
4092
-- This constant decides how many seconds of skew to accept.
4093
--
4094
-- TODO: make this a default and allow the value to be more
4095
-- configurable
4096
confdMaxClockSkew :: Int
4097
confdMaxClockSkew = 2 * nodeMaxClockSkew
4098

    
4099
-- | When we haven't reloaded the config for more than this amount of
4100
-- seconds, we force a test to see if inotify is betraying us. Using a
4101
-- prime number to ensure we get less chance of 'same wakeup' with
4102
-- other processes.
4103
confdConfigReloadTimeout :: Int
4104
confdConfigReloadTimeout = 17
4105

    
4106
-- | If we receive more than one update in this amount of
4107
-- microseconds, we move to polling every RATELIMIT seconds, rather
4108
-- than relying on inotify, to be able to serve more requests.
4109
confdConfigReloadRatelimit :: Int
4110
confdConfigReloadRatelimit = 250000
4111

    
4112
-- | Magic number prepended to all confd queries.
4113
--
4114
-- This allows us to distinguish different types of confd protocols
4115
-- and handle them. For example by changing this we can move the whole
4116
-- payload to be compressed, or move away from json.
4117
confdMagicFourcc :: String
4118
confdMagicFourcc = "plj0"
4119

    
4120
-- | By default a confd request is sent to the minimum between this
4121
-- number and all MCs. 6 was chosen because even in the case of a
4122
-- disastrous 50% response rate, we should have enough answers to be
4123
-- able to compare more than one.
4124
confdDefaultReqCoverage :: Int
4125
confdDefaultReqCoverage = 6
4126

    
4127
-- | Timeout in seconds to expire pending query request in the confd
4128
-- client library. We don't actually expect any answer more than 10
4129
-- seconds after we sent a request.
4130
confdClientExpireTimeout :: Int
4131
confdClientExpireTimeout = 10
4132

    
4133
-- | Maximum UDP datagram size.
4134
--
4135
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4136
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4137
--   (assuming we can't use jumbo frames)
4138
-- We just set this to 60K, which should be enough
4139
maxUdpDataSize :: Int
4140
maxUdpDataSize = 61440
4141

    
4142
-- * User-id pool minimum/maximum acceptable user-ids
4143

    
4144
uidpoolUidMin :: Int
4145
uidpoolUidMin = 0
4146

    
4147
-- | Assuming 32 bit user-ids
4148
uidpoolUidMax :: Integer
4149
uidpoolUidMax = 2 ^ 32 - 1
4150

    
4151
-- | Name or path of the pgrep command
4152
pgrep :: String
4153
pgrep = "pgrep"
4154

    
4155
-- | Name of the node group that gets created at cluster init or
4156
-- upgrade
4157
initialNodeGroupName :: String
4158
initialNodeGroupName = "default"
4159

    
4160
-- * Possible values for NodeGroup.alloc_policy
4161

    
4162
allocPolicyLastResort :: String
4163
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4164

    
4165
allocPolicyPreferred :: String
4166
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4167

    
4168
allocPolicyUnallocable :: String
4169
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4170

    
4171
validAllocPolicies :: [String]
4172
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4173

    
4174
-- | Temporary external/shared storage parameters
4175
blockdevDriverManual :: String
4176
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4177

    
4178
-- | 'qemu-img' path, required for 'ovfconverter'
4179
qemuimgPath :: String
4180
qemuimgPath = AutoConf.qemuimgPath
4181

    
4182
-- | The hail iallocator
4183
iallocHail :: String
4184
iallocHail = "hail"
4185

    
4186
-- * Fake opcodes for functions that have hooks attached to them via
4187
-- backend.RunLocalHooks
4188

    
4189
fakeOpMasterTurndown :: String
4190
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4191

    
4192
fakeOpMasterTurnup :: String
4193
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4194

    
4195

    
4196
-- * Crypto Types
4197
-- Types of cryptographic tokens used in node communication
4198

    
4199
cryptoTypeSslDigest :: String
4200
cryptoTypeSslDigest = "ssl"
4201

    
4202
cryptoTypeSsh :: String
4203
cryptoTypeSsh = "ssh"
4204

    
4205
-- So far only ssl keys are used in the context of this constant
4206
cryptoTypes :: FrozenSet String
4207
cryptoTypes = ConstantUtils.mkSet [cryptoTypeSslDigest]
4208

    
4209
-- * Crypto Actions
4210
-- Actions that can be performed on crypto tokens
4211

    
4212
cryptoActionGet :: String
4213
cryptoActionGet = "get"
4214

    
4215
-- This is 'create and get'
4216
cryptoActionCreate :: String
4217
cryptoActionCreate = "create"
4218

    
4219
cryptoActions :: FrozenSet String
4220
cryptoActions = ConstantUtils.mkSet [cryptoActionGet, cryptoActionCreate]
4221

    
4222
-- * Options for CryptoActions
4223

    
4224
-- Filename of the certificate
4225
cryptoOptionCertFile :: String
4226
cryptoOptionCertFile = "cert_file"
4227

    
4228
-- * SSH key types
4229

    
4230
sshkDsa :: String
4231
sshkDsa = "dsa"
4232

    
4233
sshkRsa :: String
4234
sshkRsa = "rsa"
4235

    
4236
sshkAll :: FrozenSet String
4237
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4238

    
4239
-- * SSH authorized key types
4240

    
4241
sshakDss :: String
4242
sshakDss = "ssh-dss"
4243

    
4244
sshakRsa :: String
4245
sshakRsa = "ssh-rsa"
4246

    
4247
sshakAll :: FrozenSet String
4248
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4249

    
4250
-- * SSH setup
4251

    
4252
sshsClusterName :: String
4253
sshsClusterName = "cluster_name"
4254

    
4255
sshsSshHostKey :: String
4256
sshsSshHostKey = "ssh_host_key"
4257

    
4258
sshsSshRootKey :: String
4259
sshsSshRootKey = "ssh_root_key"
4260

    
4261
sshsNodeDaemonCertificate :: String
4262
sshsNodeDaemonCertificate = "node_daemon_certificate"
4263

    
4264
-- * Key files for SSH daemon
4265

    
4266
sshHostDsaPriv :: String
4267
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4268

    
4269
sshHostDsaPub :: String
4270
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4271

    
4272
sshHostRsaPriv :: String
4273
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4274

    
4275
sshHostRsaPub :: String
4276
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4277

    
4278
sshDaemonKeyfiles :: Map String (String, String)
4279
sshDaemonKeyfiles =
4280
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4281
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4282
               ]
4283

    
4284
-- * Node daemon setup
4285

    
4286
ndsClusterName :: String
4287
ndsClusterName = "cluster_name"
4288

    
4289
ndsNodeDaemonCertificate :: String
4290
ndsNodeDaemonCertificate = "node_daemon_certificate"
4291

    
4292
ndsSsconf :: String
4293
ndsSsconf = "ssconf"
4294

    
4295
ndsStartNodeDaemon :: String
4296
ndsStartNodeDaemon = "start_node_daemon"
4297

    
4298
-- * VCluster related constants
4299

    
4300
vClusterEtcHosts :: String
4301
vClusterEtcHosts = "/etc/hosts"
4302

    
4303
vClusterVirtPathPrefix :: String
4304
vClusterVirtPathPrefix = "/###-VIRTUAL-PATH-###,"
4305

    
4306
vClusterRootdirEnvname :: String
4307
vClusterRootdirEnvname = "GANETI_ROOTDIR"
4308

    
4309
vClusterHostnameEnvname :: String
4310
vClusterHostnameEnvname = "GANETI_HOSTNAME"
4311

    
4312
vClusterVpathWhitelist :: FrozenSet String
4313
vClusterVpathWhitelist = ConstantUtils.mkSet [ vClusterEtcHosts ]
4314

    
4315
-- * The source reasons for the execution of an OpCode
4316

    
4317
opcodeReasonSrcClient :: String
4318
opcodeReasonSrcClient = "gnt:client"
4319

    
4320
opcodeReasonSrcNoded :: String
4321
opcodeReasonSrcNoded = "gnt:daemon:noded"
4322

    
4323
opcodeReasonSrcOpcode :: String
4324
opcodeReasonSrcOpcode = "gnt:opcode"
4325

    
4326
opcodeReasonSrcRlib2 :: String
4327
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4328

    
4329
opcodeReasonSrcUser :: String
4330
opcodeReasonSrcUser = "gnt:user"
4331

    
4332
opcodeReasonSources :: FrozenSet String
4333
opcodeReasonSources =
4334
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4335
                       opcodeReasonSrcNoded,
4336
                       opcodeReasonSrcOpcode,
4337
                       opcodeReasonSrcRlib2,
4338
                       opcodeReasonSrcUser]
4339

    
4340
-- | Path generating random UUID
4341
randomUuidFile :: String
4342
randomUuidFile = ConstantUtils.randomUuidFile
4343

    
4344
-- * Auto-repair tag prefixes
4345

    
4346
autoRepairTagPrefix :: String
4347
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4348

    
4349
autoRepairTagEnabled :: String
4350
autoRepairTagEnabled = autoRepairTagPrefix
4351

    
4352
autoRepairTagPending :: String
4353
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4354

    
4355
autoRepairTagResult :: String
4356
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4357

    
4358
autoRepairTagSuspended :: String
4359
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4360

    
4361
-- * Auto-repair levels
4362

    
4363
autoRepairFailover :: String
4364
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4365

    
4366
autoRepairFixStorage :: String
4367
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4368

    
4369
autoRepairMigrate :: String
4370
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4371

    
4372
autoRepairReinstall :: String
4373
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4374

    
4375
autoRepairAllTypes :: FrozenSet String
4376
autoRepairAllTypes =
4377
  ConstantUtils.mkSet [autoRepairFailover,
4378
                       autoRepairFixStorage,
4379
                       autoRepairMigrate,
4380
                       autoRepairReinstall]
4381

    
4382
-- * Auto-repair results
4383

    
4384
autoRepairEnoperm :: String
4385
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4386

    
4387
autoRepairFailure :: String
4388
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4389

    
4390
autoRepairSuccess :: String
4391
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4392

    
4393
autoRepairAllResults :: FrozenSet String
4394
autoRepairAllResults =
4395
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4396

    
4397
-- | The version identifier for builtin data collectors
4398
builtinDataCollectorVersion :: String
4399
builtinDataCollectorVersion = "B"
4400

    
4401
-- | The reason trail opcode parameter name
4402
opcodeReason :: String
4403
opcodeReason = "reason"
4404

    
4405
diskstatsFile :: String
4406
diskstatsFile = "/proc/diskstats"
4407

    
4408
-- *  CPU load collector
4409

    
4410
statFile :: String
4411
statFile = "/proc/stat"
4412

    
4413
cpuavgloadBufferSize :: Int
4414
cpuavgloadBufferSize = 150
4415

    
4416
cpuavgloadWindowSize :: Int
4417
cpuavgloadWindowSize = 600
4418

    
4419
-- * Monitoring daemon
4420

    
4421
-- | Mond's variable for periodical data collection
4422
mondTimeInterval :: Int
4423
mondTimeInterval = 5
4424

    
4425
-- | Mond's latest API version
4426
mondLatestApiVersion :: Int
4427
mondLatestApiVersion = 1
4428

    
4429
-- * Disk access modes
4430

    
4431
diskUserspace :: String
4432
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4433

    
4434
diskKernelspace :: String
4435
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4436

    
4437
diskValidAccessModes :: FrozenSet String
4438
diskValidAccessModes =
4439
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4440

    
4441
-- | Timeout for queue draining in upgrades
4442
upgradeQueueDrainTimeout :: Int
4443
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4444

    
4445
-- | Intervall at which the queue is polled during upgrades
4446
upgradeQueuePollInterval :: Int
4447
upgradeQueuePollInterval  = 10
4448

    
4449
-- * Hotplug Actions
4450

    
4451
hotplugActionAdd :: String
4452
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4453

    
4454
hotplugActionRemove :: String
4455
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4456

    
4457
hotplugActionModify :: String
4458
hotplugActionModify = Types.hotplugActionToRaw HAMod
4459

    
4460
hotplugAllActions :: FrozenSet String
4461
hotplugAllActions =
4462
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4463

    
4464
-- * Hotplug Device Targets
4465

    
4466
hotplugTargetNic :: String
4467
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4468

    
4469
hotplugTargetDisk :: String
4470
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4471

    
4472
hotplugAllTargets :: FrozenSet String
4473
hotplugAllTargets =
4474
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4475

    
4476
-- | Timeout for disk removal (seconds)
4477
diskRemoveRetryTimeout :: Int
4478
diskRemoveRetryTimeout = 30
4479

    
4480
-- | Interval between disk removal retries (seconds)
4481
diskRemoveRetryInterval :: Int
4482
diskRemoveRetryInterval  = 3
4483

    
4484
-- * UUID regex
4485

    
4486
uuidRegex :: String
4487
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4488

    
4489
-- * Luxi constants
4490

    
4491
luxiSocketPerms :: Int
4492
luxiSocketPerms = 0o660
4493

    
4494
luxiKeyMethod :: String
4495
luxiKeyMethod = "method"
4496

    
4497
luxiKeyArgs :: String
4498
luxiKeyArgs = "args"
4499

    
4500
luxiKeySuccess :: String
4501
luxiKeySuccess = "success"
4502

    
4503
luxiKeyResult :: String
4504
luxiKeyResult = "result"
4505

    
4506
luxiKeyVersion :: String
4507
luxiKeyVersion = "version"
4508

    
4509
luxiReqSubmitJob :: String
4510
luxiReqSubmitJob = "SubmitJob"
4511

    
4512
luxiReqSubmitJobToDrainedQueue :: String
4513
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4514

    
4515
luxiReqSubmitManyJobs :: String
4516
luxiReqSubmitManyJobs = "SubmitManyJobs"
4517

    
4518
luxiReqWaitForJobChange :: String
4519
luxiReqWaitForJobChange = "WaitForJobChange"
4520

    
4521
luxiReqPickupJob :: String
4522
luxiReqPickupJob = "PickupJob"
4523

    
4524
luxiReqCancelJob :: String
4525
luxiReqCancelJob = "CancelJob"
4526

    
4527
luxiReqArchiveJob :: String
4528
luxiReqArchiveJob = "ArchiveJob"
4529

    
4530
luxiReqChangeJobPriority :: String
4531
luxiReqChangeJobPriority = "ChangeJobPriority"
4532

    
4533
luxiReqAutoArchiveJobs :: String
4534
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4535

    
4536
luxiReqQuery :: String
4537
luxiReqQuery = "Query"
4538

    
4539
luxiReqQueryFields :: String
4540
luxiReqQueryFields = "QueryFields"
4541

    
4542
luxiReqQueryJobs :: String
4543
luxiReqQueryJobs = "QueryJobs"
4544

    
4545
luxiReqQueryInstances :: String
4546
luxiReqQueryInstances = "QueryInstances"
4547

    
4548
luxiReqQueryNodes :: String
4549
luxiReqQueryNodes = "QueryNodes"
4550

    
4551
luxiReqQueryGroups :: String
4552
luxiReqQueryGroups = "QueryGroups"
4553

    
4554
luxiReqQueryNetworks :: String
4555
luxiReqQueryNetworks = "QueryNetworks"
4556

    
4557
luxiReqQueryExports :: String
4558
luxiReqQueryExports = "QueryExports"
4559

    
4560
luxiReqQueryConfigValues :: String
4561
luxiReqQueryConfigValues = "QueryConfigValues"
4562

    
4563
luxiReqQueryClusterInfo :: String
4564
luxiReqQueryClusterInfo = "QueryClusterInfo"
4565

    
4566
luxiReqQueryTags :: String
4567
luxiReqQueryTags = "QueryTags"
4568

    
4569
luxiReqSetDrainFlag :: String
4570
luxiReqSetDrainFlag = "SetDrainFlag"
4571

    
4572
luxiReqSetWatcherPause :: String
4573
luxiReqSetWatcherPause = "SetWatcherPause"
4574

    
4575
luxiReqAll :: FrozenSet String
4576
luxiReqAll =
4577
  ConstantUtils.mkSet
4578
  [ luxiReqArchiveJob
4579
  , luxiReqAutoArchiveJobs
4580
  , luxiReqCancelJob
4581
  , luxiReqChangeJobPriority
4582
  , luxiReqQuery
4583
  , luxiReqQueryClusterInfo
4584
  , luxiReqQueryConfigValues
4585
  , luxiReqQueryExports
4586
  , luxiReqQueryFields
4587
  , luxiReqQueryGroups
4588
  , luxiReqQueryInstances
4589
  , luxiReqQueryJobs
4590
  , luxiReqQueryNodes
4591
  , luxiReqQueryNetworks
4592
  , luxiReqQueryTags
4593
  , luxiReqSetDrainFlag
4594
  , luxiReqSetWatcherPause
4595
  , luxiReqSubmitJob
4596
  , luxiReqSubmitJobToDrainedQueue
4597
  , luxiReqSubmitManyJobs
4598
  , luxiReqWaitForJobChange
4599
  , luxiReqPickupJob
4600
  ]
4601

    
4602
luxiDefCtmo :: Int
4603
luxiDefCtmo = 10
4604

    
4605
luxiDefRwto :: Int
4606
luxiDefRwto = 60
4607

    
4608
-- | 'WaitForJobChange' timeout
4609
luxiWfjcTimeout :: Int
4610
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4611

    
4612
-- * Query language constants
4613

    
4614
-- ** Logic operators with one or more operands, each of which is a
4615
-- filter on its own
4616

    
4617
qlangOpAnd :: String
4618
qlangOpAnd = "&"
4619

    
4620
qlangOpOr :: String
4621
qlangOpOr = "|"
4622

    
4623
-- ** Unary operators with exactly one operand
4624

    
4625
qlangOpNot :: String
4626
qlangOpNot = "!"
4627

    
4628
qlangOpTrue :: String
4629
qlangOpTrue = "?"
4630

    
4631
-- ** Binary operators with exactly two operands, the field name and
4632
-- an operator-specific value
4633

    
4634
qlangOpContains :: String
4635
qlangOpContains = "=[]"
4636

    
4637
qlangOpEqual :: String
4638
qlangOpEqual = "="
4639

    
4640
qlangOpGe :: String
4641
qlangOpGe = ">="
4642

    
4643
qlangOpGt :: String
4644
qlangOpGt = ">"
4645

    
4646
qlangOpLe :: String
4647
qlangOpLe = "<="
4648

    
4649
qlangOpLt :: String
4650
qlangOpLt = "<"
4651

    
4652
qlangOpNotEqual :: String
4653
qlangOpNotEqual = "!="
4654

    
4655
qlangOpRegexp :: String
4656
qlangOpRegexp = "=~"
4657

    
4658
-- | Characters used for detecting user-written filters (see
4659
-- L{_CheckFilter})
4660

    
4661
qlangFilterDetectionChars :: FrozenSet String
4662
qlangFilterDetectionChars =
4663
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4664
                       ")", "(", "\x0b", "\n",
4665
                       "\r", "\x0c", "/", "<",
4666
                       "\t", ">", "=", "\\", "~"]
4667

    
4668
-- | Characters used to detect globbing filters
4669
qlangGlobDetectionChars :: FrozenSet String
4670
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4671

    
4672
-- * Error related constants
4673
--
4674
-- 'OpPrereqError' failure types
4675

    
4676
-- | Environment error (e.g. node disk error)
4677
errorsEcodeEnviron :: String
4678
errorsEcodeEnviron = "environment_error"
4679

    
4680
-- | Entity already exists
4681
errorsEcodeExists :: String
4682
errorsEcodeExists = "already_exists"
4683

    
4684
-- | Internal cluster error
4685
errorsEcodeFault :: String
4686
errorsEcodeFault = "internal_error"
4687

    
4688
-- | Wrong arguments (at syntax level)
4689
errorsEcodeInval :: String
4690
errorsEcodeInval = "wrong_input"
4691

    
4692
-- | Entity not found
4693
errorsEcodeNoent :: String
4694
errorsEcodeNoent = "unknown_entity"
4695

    
4696
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4697
errorsEcodeNores :: String
4698
errorsEcodeNores = "insufficient_resources"
4699

    
4700
-- | Resource not unique (e.g. MAC or IP duplication)
4701
errorsEcodeNotunique :: String
4702
errorsEcodeNotunique = "resource_not_unique"
4703

    
4704
-- | Resolver errors
4705
errorsEcodeResolver :: String
4706
errorsEcodeResolver = "resolver_error"
4707

    
4708
-- | Wrong entity state
4709
errorsEcodeState :: String
4710
errorsEcodeState = "wrong_state"
4711

    
4712
-- | Temporarily out of resources; operation can be tried again
4713
errorsEcodeTempNores :: String
4714
errorsEcodeTempNores = "temp_insufficient_resources"
4715

    
4716
errorsEcodeAll :: FrozenSet String
4717
errorsEcodeAll =
4718
  ConstantUtils.mkSet [ errorsEcodeNores
4719
                      , errorsEcodeExists
4720
                      , errorsEcodeState
4721
                      , errorsEcodeNotunique
4722
                      , errorsEcodeTempNores
4723
                      , errorsEcodeNoent
4724
                      , errorsEcodeFault
4725
                      , errorsEcodeResolver
4726
                      , errorsEcodeInval
4727
                      , errorsEcodeEnviron
4728
                      ]
4729

    
4730
-- * Jstore related constants
4731

    
4732
jstoreJobsPerArchiveDirectory :: Int
4733
jstoreJobsPerArchiveDirectory = 10000
4734

    
4735
-- * Gluster settings
4736

    
4737
-- | Name of the Gluster host setting
4738
glusterHost :: String
4739
glusterHost = "host"
4740

    
4741
-- | Default value of the Gluster host setting
4742
glusterHostDefault :: String
4743
glusterHostDefault = "127.0.0.1"
4744

    
4745
-- | Name of the Gluster volume setting
4746
glusterVolume :: String
4747
glusterVolume = "volume"
4748

    
4749
-- | Default value of the Gluster volume setting
4750
glusterVolumeDefault :: String
4751
glusterVolumeDefault = "gv0"
4752

    
4753
-- | Name of the Gluster port setting
4754
glusterPort :: String
4755
glusterPort = "port"
4756

    
4757
-- | Default value of the Gluster port setting
4758
glusterPortDefault :: Int
4759
glusterPortDefault = 24007
4760

    
4761
-- * Instance communication
4762
--
4763
-- The instance communication attaches an additional NIC, named
4764
-- @instanceCommunicationNicPrefix@:@instanceName@ and prefixed by
4765
-- @instanceCommunicationMacPrefix@, to the instances that have
4766
-- instance communication enabled.  This NIC is part of the network
4767
-- @instanceCommunicationNetworkName@, which is in turn created by
4768
-- 'gnt-network'.  This network is defined as
4769
-- @instanceCommunicationNetwork4@ for IPv4 and
4770
-- @instanceCommunicationNetwork6@ for IPv6.
4771

    
4772
instanceCommunicationDoc :: String
4773
instanceCommunicationDoc =
4774
  "Enable or disable the communication mechanism for an instance"
4775

    
4776
instanceCommunicationMacPrefix :: String
4777
instanceCommunicationMacPrefix = "52:54:00"
4778

    
4779
-- | The instance communication network is a link-local IPv4/IPv6
4780
-- network because the communication is meant to be exclusive between
4781
-- the host and the guest and not routed outside the node.
4782
instanceCommunicationNetwork4 :: String
4783
instanceCommunicationNetwork4 = "169.254.0.0/16"
4784

    
4785
-- | See 'instanceCommunicationNetwork4'.
4786
instanceCommunicationNetwork6 :: String
4787
instanceCommunicationNetwork6 = "fe80::/10"
4788

    
4789
instanceCommunicationNetworkLink :: String
4790
instanceCommunicationNetworkLink = "communication_rt"
4791

    
4792
instanceCommunicationNicPrefix :: String
4793
instanceCommunicationNicPrefix = "ganeti:communication:"
4794

    
4795
-- | Parameters that should be protected
4796
--
4797
-- Python does not have a type system and can't automatically infer what should
4798
-- be the resulting type of a JSON request. As a result, it must rely on this
4799
-- list of parameter names to protect values correctly.
4800
--
4801
-- Names ending in _cluster will be treated as dicts of dicts of private values.
4802
-- Otherwise they are considered dicts of private values.
4803
privateParametersBlacklist :: [String]
4804
privateParametersBlacklist = [ "osparams_private"
4805
                             , "osparams_secret"
4806
                             , "osparams_private_cluster"
4807
                             ]
4808

    
4809
-- | Warn the user that the logging level is too low for production use.
4810
debugModeConfidentialityWarning :: String
4811
debugModeConfidentialityWarning =
4812
  "ALERT: %s started in debug mode.\n\
4813
  \ Private and secret parameters WILL be logged!\n"