Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ f2152285

History | View | Annotate | Download (108.6 kB)

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

    
4
This is a transitional module complementary to 'Ganeti.Constants'.  It
5
is intended to contain the Haskell constants that are meant to be
6
generated in Python.
7

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

    
16
-}
17

    
18
{-
19

    
20
Copyright (C) 2013 Google Inc.
21

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

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

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

    
37
-}
38
module Ganeti.HsConstants where
39

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

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

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

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

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

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

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

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

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

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

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

    
87
-- ** Build-time constants
88

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
136
-- * Various versions
137

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

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

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

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

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

    
153
osApiV10 :: Int
154
osApiV10 = 10
155

    
156
osApiV15 :: Int
157
osApiV15 = 15
158

    
159
osApiV20 :: Int
160
osApiV20 = 20
161

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

    
165
exportVersion :: Int
166
exportVersion = 0
167

    
168
rapiVersion :: Int
169
rapiVersion = 2
170

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

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

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

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

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

    
190
-- * User separation
191

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
240
-- * Cpu pinning separators and constants
241

    
242
cpuPinningSep :: String
243
cpuPinningSep = ":"
244

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

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

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

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

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

    
280
-- * Wipe
281

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

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

    
289
minWipeChunkPercent :: Int
290
minWipeChunkPercent = 10
291

    
292
-- * Directories
293

    
294
runDirsMode :: Int
295
runDirsMode = 0o775
296

    
297
secureDirMode :: Int
298
secureDirMode = 0o700
299

    
300
secureFileMode :: Int
301
secureFileMode = 0o600
302

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

    
306
-- * 'autoconf' enable/disable
307

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

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

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

    
317
enableSplitQuery :: Bool
318
enableSplitQuery = AutoConf.enableSplitQuery
319

    
320
-- * SSH constants
321

    
322
ssh :: String
323
ssh = "ssh"
324

    
325
scp :: String
326
scp = "scp"
327

    
328
-- * Daemons
329

    
330
confd :: String
331
confd = Runtime.daemonName GanetiConfd
332

    
333
masterd :: String
334
masterd = Runtime.daemonName GanetiMasterd
335

    
336
mond :: String
337
mond = Runtime.daemonName GanetiMond
338

    
339
noded :: String
340
noded = Runtime.daemonName GanetiNoded
341

    
342
luxid :: String
343
luxid = Runtime.daemonName GanetiLuxid
344

    
345
rapi :: String
346
rapi = Runtime.daemonName GanetiRapi
347

    
348
daemons :: FrozenSet String
349
daemons =
350
  ConstantUtils.mkSet [confd,
351
                       luxid,
352
                       masterd,
353
                       mond,
354
                       noded,
355
                       rapi]
356

    
357
defaultConfdPort :: Int
358
defaultConfdPort = 1814
359

    
360
defaultMondPort :: Int
361
defaultMondPort = 1815
362

    
363
defaultNodedPort :: Int
364
defaultNodedPort = 1811
365

    
366
defaultRapiPort :: Int
367
defaultRapiPort = 5080
368

    
369
daemonsPorts :: Map String (Protocol, Int)
370
daemonsPorts =
371
  Map.fromList [(confd, (Udp, defaultConfdPort)),
372
                (mond, (Tcp, defaultMondPort)),
373
                (noded, (Tcp, defaultNodedPort)),
374
                (rapi, (Tcp, defaultRapiPort)),
375
                (ssh, (Tcp, 22))]
376

    
377
firstDrbdPort :: Int
378
firstDrbdPort = 11000
379

    
380
lastDrbdPort :: Int
381
lastDrbdPort = 14999
382

    
383
daemonsLogbase :: Map String String
384
daemonsLogbase =
385
  Map.fromList
386
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
387

    
388
daemonsExtraLogbase :: Map String (Map String String)
389
daemonsExtraLogbase =
390
  Map.fromList $
391
  map (Runtime.daemonName *** id)
392
  [ (GanetiMond, Map.fromList
393
                 [ ("access", Runtime.daemonsExtraLogbase GanetiMond AccessLog)
394
                 , ("error", Runtime.daemonsExtraLogbase GanetiMond ErrorLog)
395
                 ])
396
  ]
397

    
398
extraLogreasonAccess :: String
399
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
400

    
401
extraLogreasonError :: String
402
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
403

    
404
devConsole :: String
405
devConsole = ConstantUtils.devConsole
406

    
407
procMounts :: String
408
procMounts = "/proc/mounts"
409

    
410
-- * Luxi (Local UniX Interface) related constants
411

    
412
luxiEom :: PythonChar
413
luxiEom = PythonChar '\x03'
414

    
415
-- | Environment variable for the luxi override socket
416
luxiOverride :: String
417
luxiOverride = "FORCE_LUXI_SOCKET"
418

    
419
luxiOverrideMaster :: String
420
luxiOverrideMaster = "master"
421

    
422
luxiOverrideQuery :: String
423
luxiOverrideQuery = "query"
424

    
425
luxiVersion :: Int
426
luxiVersion = configVersion
427

    
428
-- * Syslog
429

    
430
syslogUsage :: String
431
syslogUsage = AutoConf.syslogUsage
432

    
433
syslogNo :: String
434
syslogNo = Logging.syslogUsageToRaw SyslogNo
435

    
436
syslogYes :: String
437
syslogYes = Logging.syslogUsageToRaw SyslogYes
438

    
439
syslogOnly :: String
440
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
441

    
442
syslogSocket :: String
443
syslogSocket = "/dev/log"
444

    
445
exportConfFile :: String
446
exportConfFile = "config.ini"
447

    
448
-- * Xen
449

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

    
453
xenCmdXl :: String
454
xenCmdXl = "xl"
455

    
456
xenCmdXm :: String
457
xenCmdXm = "xm"
458

    
459
xenInitrd :: String
460
xenInitrd = AutoConf.xenInitrd
461

    
462
xenKernel :: String
463
xenKernel = AutoConf.xenKernel
464

    
465
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
466
-- other constants
467
knownXenCommands :: FrozenSet String
468
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
469

    
470
-- * KVM and socat
471

    
472
kvmPath :: String
473
kvmPath = AutoConf.kvmPath
474

    
475
kvmKernel :: String
476
kvmKernel = AutoConf.kvmKernel
477

    
478
socatEscapeCode :: String
479
socatEscapeCode = "0x1d"
480

    
481
socatPath :: String
482
socatPath = AutoConf.socatPath
483

    
484
socatUseCompress :: Bool
485
socatUseCompress = AutoConf.socatUseCompress
486

    
487
socatUseEscape :: Bool
488
socatUseEscape = AutoConf.socatUseEscape
489

    
490
-- * Console types
491

    
492
-- | Display a message for console access
493
consMessage :: String
494
consMessage = "msg"
495

    
496
-- | Console as SPICE server
497
consSpice :: String
498
consSpice = "spice"
499

    
500
-- | Console as SSH command
501
consSsh :: String
502
consSsh = "ssh"
503

    
504
-- | Console as VNC server
505
consVnc :: String
506
consVnc = "vnc"
507

    
508
consAll :: FrozenSet String
509
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
510

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

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

    
530
-- * X509
531

    
532
-- | commonName (CN) used in certificates
533
x509CertCn :: String
534
x509CertCn = "ganeti.example.com"
535

    
536
-- | Default validity of certificates in days
537
x509CertDefaultValidity :: Int
538
x509CertDefaultValidity = 365 * 5
539

    
540
x509CertSignatureHeader :: String
541
x509CertSignatureHeader = "X-Ganeti-Signature"
542

    
543
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
544
x509CertSignDigest :: String
545
x509CertSignDigest = "SHA1"
546

    
547
-- * Import/export daemon mode
548

    
549
iemExport :: String
550
iemExport = "export"
551

    
552
iemImport :: String
553
iemImport = "import"
554

    
555
-- * Import/export transport compression
556

    
557
iecGzip :: String
558
iecGzip = Types.importExportCompressionToRaw GZip
559

    
560
iecNone :: String
561
iecNone = Types.importExportCompressionToRaw None
562

    
563
iecAll :: FrozenSet String
564
iecAll =
565
  ConstantUtils.mkSet $ map Types.importExportCompressionToRaw [minBound..]
566

    
567
ieCustomSize :: String
568
ieCustomSize = "fd"
569

    
570
-- * Import/export I/O
571

    
572
-- | Direct file I/O, equivalent to a shell's I/O redirection using
573
-- '<' or '>'
574
ieioFile :: String
575
ieioFile = "file"
576

    
577
-- | Raw block device I/O using "dd"
578
ieioRawDisk :: String
579
ieioRawDisk = "raw"
580

    
581
-- | OS definition import/export script
582
ieioScript :: String
583
ieioScript = "script"
584

    
585
-- * Values
586

    
587
valueDefault :: String
588
valueDefault = "default"
589

    
590
valueAuto :: String
591
valueAuto = "auto"
592

    
593
valueGenerate :: String
594
valueGenerate = "generate"
595

    
596
valueNone :: String
597
valueNone = "none"
598

    
599
valueTrue :: String
600
valueTrue = "true"
601

    
602
valueFalse :: String
603
valueFalse = "false"
604

    
605
valueHsNothing :: Map String PythonNone
606
valueHsNothing = Map.fromList [("Nothing", PythonNone)]
607

    
608
-- * Hooks
609

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

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

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

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

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

    
625
hooksVersion :: Int
626
hooksVersion = 2
627

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

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

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

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

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

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

    
645
-- * Hkr
646

    
647
hkrSkip :: Int
648
hkrSkip = 0
649

    
650
hkrFail :: Int
651
hkrFail = 1
652

    
653
hkrSuccess :: Int
654
hkrSuccess = 2
655

    
656
-- * Storage types
657

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

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

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

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

    
670
stLvmPv :: String
671
stLvmPv = Types.storageTypeToRaw StorageLvmPv
672

    
673
stLvmVg :: String
674
stLvmVg = Types.storageTypeToRaw StorageLvmVg
675

    
676
stRados :: String
677
stRados = Types.storageTypeToRaw StorageRados
678

    
679
storageTypes :: FrozenSet String
680
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
681

    
682
-- | The set of storage types for which storage reporting is available
683
--
684
-- FIXME: Remove this, once storage reporting is available for all
685
-- types.
686
stsReport :: FrozenSet String
687
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
688

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

    
692
sfNode :: String
693
sfNode = "node"
694

    
695
sfType :: String
696
sfType = "type"
697

    
698
-- ** and the rest are valid in backend
699

    
700
sfAllocatable :: String
701
sfAllocatable = Types.storageFieldToRaw SFAllocatable
702

    
703
sfFree :: String
704
sfFree = Types.storageFieldToRaw SFFree
705

    
706
sfName :: String
707
sfName = Types.storageFieldToRaw SFName
708

    
709
sfSize :: String
710
sfSize = Types.storageFieldToRaw SFSize
711

    
712
sfUsed :: String
713
sfUsed = Types.storageFieldToRaw SFUsed
714

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

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

    
725
-- * Storage operations
726

    
727
soFixConsistency :: String
728
soFixConsistency = "fix-consistency"
729

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

    
735
-- * Volume fields
736

    
737
vfDev :: String
738
vfDev = "dev"
739

    
740
vfInstance :: String
741
vfInstance = "instance"
742

    
743
vfName :: String
744
vfName = "name"
745

    
746
vfNode :: String
747
vfNode = "node"
748

    
749
vfPhys :: String
750
vfPhys = "phys"
751

    
752
vfSize :: String
753
vfSize = "size"
754

    
755
vfVg :: String
756
vfVg = "vg"
757

    
758
-- * Local disk status
759

    
760
ldsFaulty :: Int
761
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
762

    
763
ldsOkay :: Int
764
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
765

    
766
ldsUnknown :: Int
767
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
768

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

    
774
-- * Disk template types
775

    
776
dtDiskless :: String
777
dtDiskless = Types.diskTemplateToRaw DTDiskless
778

    
779
dtFile :: String
780
dtFile = Types.diskTemplateToRaw DTFile
781

    
782
dtSharedFile :: String
783
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
784

    
785
dtPlain :: String
786
dtPlain = Types.diskTemplateToRaw DTPlain
787

    
788
dtBlock :: String
789
dtBlock = Types.diskTemplateToRaw DTBlock
790

    
791
dtDrbd8 :: String
792
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
793

    
794
dtRbd :: String
795
dtRbd = Types.diskTemplateToRaw DTRbd
796

    
797
dtExt :: String
798
dtExt = Types.diskTemplateToRaw DTExt
799

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

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

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

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

    
831
-- | The set of network-mirrored disk templates
832
dtsIntMirror :: FrozenSet String
833
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
834

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

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

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

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

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

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

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

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

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

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

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

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

    
900
-- * Drbd
901

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

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

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

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

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

    
918
-- * Drbd barrier types
919

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

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

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

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

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

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

    
950
-- * File backend driver
951

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

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

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

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

    
967
-- * Disk access mode
968

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

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

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

    
978
-- * Disk replacement mode
979

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

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

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

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

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

    
996
-- * Instance export mode
997

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

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

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

    
1007
-- * Instance creation modes
1008

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

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

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

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

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

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

    
1027
rieVersion :: Int
1028
rieVersion = 0
1029

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

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

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

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

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

    
1050
-- * Import/export config options
1051

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

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

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

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

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

    
1067
-- * Dynamic device modification
1068

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

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

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

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

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

    
1084
-- * Common exit codes
1085

    
1086
exitSuccess :: Int
1087
exitSuccess = 0
1088

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

    
1092
exitNotcluster :: Int
1093
exitNotcluster = 5
1094

    
1095
exitNotmaster :: Int
1096
exitNotmaster = 11
1097

    
1098
exitNodesetupError :: Int
1099
exitNodesetupError = 12
1100

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

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

    
1109
-- * Tags
1110

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

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

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

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

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

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

    
1129
maxTagLen :: Int
1130
maxTagLen = 128
1131

    
1132
maxTagsPerObj :: Int
1133
maxTagsPerObj = 4096
1134

    
1135
-- * Others
1136

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

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

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

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

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

    
1153
ip6AddressAny :: String
1154
ip6AddressAny = "::"
1155

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

    
1159
ip4Version :: Int
1160
ip4Version = 4
1161

    
1162
ip6Version :: Int
1163
ip6Version = 6
1164

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

    
1168
tcpPingTimeout :: Int
1169
tcpPingTimeout = 10
1170

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

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

    
1177
minVgSize :: Int
1178
minVgSize = 20480
1179

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

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

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

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

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

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

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

    
1206
-- * Runparts results
1207

    
1208
runpartsErr :: Int
1209
runpartsErr = 2
1210

    
1211
runpartsRun :: Int
1212
runpartsRun = 1
1213

    
1214
runpartsSkip :: Int
1215
runpartsSkip = 0
1216

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

    
1220
-- * RPC
1221

    
1222
rpcEncodingNone :: Int
1223
rpcEncodingNone = 0
1224

    
1225
rpcEncodingZlibBase64 :: Int
1226
rpcEncodingZlibBase64 = 1
1227

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

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

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

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

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

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

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

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

    
1260
-- OS
1261

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1319
esScriptCreate :: String
1320
esScriptCreate = esActionCreate
1321

    
1322
esScriptRemove :: String
1323
esScriptRemove = esActionRemove
1324

    
1325
esScriptGrow :: String
1326
esScriptGrow = esActionGrow
1327

    
1328
esScriptAttach :: String
1329
esScriptAttach = esActionAttach
1330

    
1331
esScriptDetach :: String
1332
esScriptDetach = esActionDetach
1333

    
1334
esScriptSetinfo :: String
1335
esScriptSetinfo = esActionSetinfo
1336

    
1337
esScriptVerify :: String
1338
esScriptVerify = esActionVerify
1339

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

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

    
1353
-- * Reboot types
1354

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

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

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

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

    
1367
-- * Instance reboot behaviors
1368

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

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

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

    
1378
-- * VTypes
1379

    
1380
vtypeBool :: VType
1381
vtypeBool = VTypeBool
1382

    
1383
vtypeInt :: VType
1384
vtypeInt = VTypeInt
1385

    
1386
vtypeMaybeString :: VType
1387
vtypeMaybeString = VTypeMaybeString
1388

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

    
1393
vtypeString :: VType
1394
vtypeString = VTypeString
1395

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1736
-- * Migration statuses
1737

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

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

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

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

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

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

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

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

    
1771
-- * Hypervisor state
1772

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

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

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

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

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

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

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

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

    
1813
-- * Disk state
1814

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

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

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

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

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

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

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

    
1844
-- Backend parameter names
1845

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1973
-- | Node parameter names
1974

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

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

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

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

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

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

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

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

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

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

    
2020
-- * Logical Disks parameters
2021

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2176
-- * Dynamic disk parameters
2177

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

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

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

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

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

    
2193
-- * OOB supported commands
2194

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2364
-- * Hypervisor constants
2365

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

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

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

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

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

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

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

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

    
2390
vncBasePort :: Int
2391
vncBasePort = 5900
2392

    
2393
vncDefaultBindAddress :: String
2394
vncDefaultBindAddress = ip4AddressAny
2395

    
2396
-- * NIC types
2397

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

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

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

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

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

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

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

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

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

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

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

    
2445
-- * Vif types
2446

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

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

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

    
2457
-- * Disk types
2458

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2511
-- * Mouse types
2512

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

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

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

    
2522
-- * Boot order
2523

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

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

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

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

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

    
2540
-- * SPICE lossless image compression options
2541

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

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

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

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

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

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

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

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

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

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

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

    
2584
-- * SPICE video stream detection
2585

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

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

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

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

    
2601
-- * Security models
2602

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

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

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

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

    
2615
-- * Kvm flag values
2616

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

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

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

    
2626
-- * Migration type
2627

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

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

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

    
2638
-- * Cluster verify steps
2639

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

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

    
2647
-- * Cluster Verify error classes
2648

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

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

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

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

    
2661
-- * Cluster Verify error codes and documentation
2662

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2937
-- * Node verify constants
2938

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3017
-- * Instance status
3018

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

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

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

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

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

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

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

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

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

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

    
3049
-- * Admin states
3050

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

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

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

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

    
3063
-- * Node roles
3064

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

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

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

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

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

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

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

    
3085
sslCertExpirationError :: Int
3086
sslCertExpirationError = 7
3087

    
3088
sslCertExpirationWarn :: Int
3089
sslCertExpirationWarn = 30
3090

    
3091
-- * Allocator framework constants
3092

    
3093
iallocatorVersion :: Int
3094
iallocatorVersion = 2
3095

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

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

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

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

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

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

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

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

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

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

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

    
3131
-- * Node evacuation
3132

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

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

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

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

    
3145
-- * Job queue
3146

    
3147
jobQueueVersion :: Int
3148
jobQueueVersion = 1
3149

    
3150
jobQueueSizeHardLimit :: Int
3151
jobQueueSizeHardLimit = 5000
3152

    
3153
jobQueueFilesPerms :: Int
3154
jobQueueFilesPerms = 0o640
3155

    
3156
-- * Unchanged job return
3157

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

    
3161
-- * Job status
3162

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

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

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

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

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

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

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

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

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

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

    
3195
-- * OpCode status
3196

    
3197
-- ** Not yet finalized opcodes
3198

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

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

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

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

    
3211
-- ** Finalized opcodes
3212

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

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

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

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

    
3226
-- * OpCode priority
3227

    
3228
opPrioLowest :: Int
3229
opPrioLowest = 19
3230

    
3231
opPrioHighest :: Int
3232
opPrioHighest = -20
3233

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

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

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

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

    
3246
opPrioDefault :: Int
3247
opPrioDefault = opPrioNormal
3248

    
3249
-- * Lock recalculate mode
3250

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

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

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

    
3264
lockAttemptsMaxwait :: Double
3265
lockAttemptsMaxwait = 15.0
3266

    
3267
lockAttemptsMinwait :: Double
3268
lockAttemptsMinwait = 1.0
3269

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

    
3273
-- * Execution log types
3274

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

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

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

    
3284
-- * /etc/hosts modification
3285

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

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

    
3292
-- * Job queue test
3293

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

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

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

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

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

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

    
3312
-- * Query resources
3313

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

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

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

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

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

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

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

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

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

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

    
3344
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3345
qrViaOp :: FrozenSet String
3346
qrViaOp =
3347
  ConstantUtils.mkSet [qrCluster,
3348
                       qrInstance,
3349
                       qrNode,
3350
                       qrGroup,
3351
                       qrOs,
3352
                       qrExport,
3353
                       qrNetwork,
3354
                       qrExtstorage]
3355

    
3356
-- | List of resources which can be queried using Local UniX Interface
3357
qrViaLuxi :: FrozenSet String
3358
qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob]
3359

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

    
3364
-- * Query field types
3365

    
3366
qftBool :: String
3367
qftBool = "bool"
3368

    
3369
qftNumber :: String
3370
qftNumber = "number"
3371

    
3372
qftOther :: String
3373
qftOther = "other"
3374

    
3375
qftText :: String
3376
qftText = "text"
3377

    
3378
qftTimestamp :: String
3379
qftTimestamp = "timestamp"
3380

    
3381
qftUnit :: String
3382
qftUnit = "unit"
3383

    
3384
qftUnknown :: String
3385
qftUnknown = "unknown"
3386

    
3387
qftAll :: FrozenSet String
3388
qftAll =
3389
  ConstantUtils.mkSet [qftBool,
3390
                       qftNumber,
3391
                       qftOther,
3392
                       qftText,
3393
                       qftTimestamp,
3394
                       qftUnit,
3395
                       qftUnknown]
3396

    
3397
-- * Query result field status
3398
--
3399
-- Don't change or reuse values as they're used by clients.
3400
--
3401
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3402

    
3403
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3404
rsNodata :: Int
3405
rsNodata = 2
3406

    
3407
rsNormal :: Int
3408
rsNormal = 0
3409

    
3410
-- | Resource marked offline
3411
rsOffline :: Int
3412
rsOffline = 4
3413

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

    
3420
rsUnknown :: Int
3421
rsUnknown = 1
3422

    
3423
rsAll :: FrozenSet Int
3424
rsAll =
3425
  ConstantUtils.mkSet [rsNodata,
3426
                       rsNormal,
3427
                       rsOffline,
3428
                       rsUnavail,
3429
                       rsUnknown]
3430

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

    
3439
-- * Max dynamic devices
3440

    
3441
maxDisks :: Int
3442
maxDisks = Types.maxDisks
3443

    
3444
maxNics :: Int
3445
maxNics = Types.maxNics
3446

    
3447
-- | SSCONF file prefix
3448
ssconfFileprefix :: String
3449
ssconfFileprefix = "ssconf_"
3450

    
3451
-- * SSCONF keys
3452

    
3453
ssClusterName :: String
3454
ssClusterName = "cluster_name"
3455

    
3456
ssClusterTags :: String
3457
ssClusterTags = "cluster_tags"
3458

    
3459
ssFileStorageDir :: String
3460
ssFileStorageDir = "file_storage_dir"
3461

    
3462
ssSharedFileStorageDir :: String
3463
ssSharedFileStorageDir = "shared_file_storage_dir"
3464

    
3465
ssMasterCandidates :: String
3466
ssMasterCandidates = "master_candidates"
3467

    
3468
ssMasterCandidatesIps :: String
3469
ssMasterCandidatesIps = "master_candidates_ips"
3470

    
3471
ssMasterIp :: String
3472
ssMasterIp = "master_ip"
3473

    
3474
ssMasterNetdev :: String
3475
ssMasterNetdev = "master_netdev"
3476

    
3477
ssMasterNetmask :: String
3478
ssMasterNetmask = "master_netmask"
3479

    
3480
ssMasterNode :: String
3481
ssMasterNode = "master_node"
3482

    
3483
ssNodeList :: String
3484
ssNodeList = "node_list"
3485

    
3486
ssNodePrimaryIps :: String
3487
ssNodePrimaryIps = "node_primary_ips"
3488

    
3489
ssNodeSecondaryIps :: String
3490
ssNodeSecondaryIps = "node_secondary_ips"
3491

    
3492
ssOfflineNodes :: String
3493
ssOfflineNodes = "offline_nodes"
3494

    
3495
ssOnlineNodes :: String
3496
ssOnlineNodes = "online_nodes"
3497

    
3498
ssPrimaryIpFamily :: String
3499
ssPrimaryIpFamily = "primary_ip_family"
3500

    
3501
ssInstanceList :: String
3502
ssInstanceList = "instance_list"
3503

    
3504
ssReleaseVersion :: String
3505
ssReleaseVersion = "release_version"
3506

    
3507
ssHypervisorList :: String
3508
ssHypervisorList = "hypervisor_list"
3509

    
3510
ssMaintainNodeHealth :: String
3511
ssMaintainNodeHealth = "maintain_node_health"
3512

    
3513
ssUidPool :: String
3514
ssUidPool = "uid_pool"
3515

    
3516
ssNodegroups :: String
3517
ssNodegroups = "nodegroups"
3518

    
3519
ssNetworks :: String
3520
ssNetworks = "networks"
3521

    
3522
-- | This is not a complete SSCONF key, but the prefix for the
3523
-- hypervisor keys
3524
ssHvparamsPref :: String
3525
ssHvparamsPref = "hvparams_"
3526

    
3527
-- * Hvparams keys
3528

    
3529
ssHvparamsXenChroot :: String
3530
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3531

    
3532
ssHvparamsXenFake :: String
3533
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3534

    
3535
ssHvparamsXenHvm :: String
3536
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3537

    
3538
ssHvparamsXenKvm :: String
3539
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3540

    
3541
ssHvparamsXenLxc :: String
3542
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3543

    
3544
ssHvparamsXenPvm :: String
3545
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3546

    
3547
validSsHvparamsKeys :: FrozenSet String
3548
validSsHvparamsKeys =
3549
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3550
                       ssHvparamsXenLxc,
3551
                       ssHvparamsXenFake,
3552
                       ssHvparamsXenHvm,
3553
                       ssHvparamsXenKvm,
3554
                       ssHvparamsXenPvm]
3555

    
3556
ssFilePerms :: Int
3557
ssFilePerms = 0o444
3558

    
3559
-- | Cluster wide default parameters
3560
defaultEnabledHypervisor :: String
3561
defaultEnabledHypervisor = htXenPvm
3562

    
3563
hvcDefaults :: Map Hypervisor (Map String PyValueEx)
3564
hvcDefaults =
3565
  Map.fromList
3566
  [ (XenPvm, Map.fromList
3567
             [ (hvUseBootloader,  PyValueEx False)
3568
             , (hvBootloaderPath, PyValueEx xenBootloader)
3569
             , (hvBootloaderArgs, PyValueEx "")
3570
             , (hvKernelPath,     PyValueEx xenKernel)
3571
             , (hvInitrdPath,     PyValueEx "")
3572
             , (hvRootPath,       PyValueEx "/dev/xvda1")
3573
             , (hvKernelArgs,     PyValueEx "ro")
3574
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3575
             , (hvMigrationMode,  PyValueEx htMigrationLive)
3576
             , (hvBlockdevPrefix, PyValueEx "sd")
3577
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3578
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3579
             , (hvCpuCap,         PyValueEx (0 :: Int))
3580
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3581
             , (hvVifScript,      PyValueEx "")
3582
             , (hvXenCmd,         PyValueEx xenCmdXm)
3583
             , (hvXenCpuid,       PyValueEx "")
3584
             , (hvSoundhw,        PyValueEx "")
3585
             ])
3586
  , (XenHvm, Map.fromList
3587
             [ (hvBootOrder,      PyValueEx "cd")
3588
             , (hvCdromImagePath, PyValueEx "")
3589
             , (hvNicType,        PyValueEx htNicRtl8139)
3590
             , (hvDiskType,       PyValueEx htDiskParavirtual)
3591
             , (hvVncBindAddress, PyValueEx ip4AddressAny)
3592
             , (hvAcpi,           PyValueEx True)
3593
             , (hvPae,            PyValueEx True)
3594
             , (hvKernelPath,     PyValueEx "/usr/lib/xen/boot/hvmloader")
3595
             , (hvDeviceModel,    PyValueEx "/usr/lib/xen/bin/qemu-dm")
3596
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3597
             , (hvMigrationMode,  PyValueEx htMigrationNonlive)
3598
             , (hvUseLocaltime,   PyValueEx False)
3599
             , (hvBlockdevPrefix, PyValueEx "hd")
3600
             , (hvPassthrough,    PyValueEx "")
3601
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3602
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3603
             , (hvCpuCap,         PyValueEx (0 :: Int))
3604
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3605
             , (hvVifType,        PyValueEx htHvmVifIoemu)
3606
             , (hvVifScript,      PyValueEx "")
3607
             , (hvViridian,       PyValueEx False)
3608
             , (hvXenCmd,         PyValueEx xenCmdXm)
3609
             , (hvXenCpuid,       PyValueEx "")
3610
             , (hvSoundhw,        PyValueEx "")
3611
             ])
3612
  , (Kvm, Map.fromList
3613
          [ (hvKvmPath,                         PyValueEx kvmPath)
3614
          , (hvKernelPath,                      PyValueEx kvmKernel)
3615
          , (hvInitrdPath,                      PyValueEx "")
3616
          , (hvKernelArgs,                      PyValueEx "ro")
3617
          , (hvRootPath,                        PyValueEx "/dev/vda1")
3618
          , (hvAcpi,                            PyValueEx True)
3619
          , (hvSerialConsole,                   PyValueEx True)
3620
          , (hvSerialSpeed,                     PyValueEx (38400 :: Int))
3621
          , (hvVncBindAddress,                  PyValueEx "")
3622
          , (hvVncTls,                          PyValueEx False)
3623
          , (hvVncX509,                         PyValueEx "")
3624
          , (hvVncX509Verify,                   PyValueEx False)
3625
          , (hvVncPasswordFile,                 PyValueEx "")
3626
          , (hvKvmSpiceBind,                    PyValueEx "")
3627
          , (hvKvmSpiceIpVersion,           PyValueEx ifaceNoIpVersionSpecified)
3628
          , (hvKvmSpicePasswordFile,            PyValueEx "")
3629
          , (hvKvmSpiceLosslessImgCompr,        PyValueEx "")
3630
          , (hvKvmSpiceJpegImgCompr,            PyValueEx "")
3631
          , (hvKvmSpiceZlibGlzImgCompr,         PyValueEx "")
3632
          , (hvKvmSpiceStreamingVideoDetection, PyValueEx "")
3633
          , (hvKvmSpiceAudioCompr,              PyValueEx True)
3634
          , (hvKvmSpiceUseTls,                  PyValueEx False)
3635
          , (hvKvmSpiceTlsCiphers,              PyValueEx opensslCiphers)
3636
          , (hvKvmSpiceUseVdagent,              PyValueEx True)
3637
          , (hvKvmFloppyImagePath,              PyValueEx "")
3638
          , (hvCdromImagePath,                  PyValueEx "")
3639
          , (hvKvmCdrom2ImagePath,              PyValueEx "")
3640
          , (hvBootOrder,                       PyValueEx htBoDisk)
3641
          , (hvNicType,                         PyValueEx htNicParavirtual)
3642
          , (hvDiskType,                        PyValueEx htDiskParavirtual)
3643
          , (hvKvmCdromDiskType,                PyValueEx "")
3644
          , (hvUsbMouse,                        PyValueEx "")
3645
          , (hvKeymap,                          PyValueEx "")
3646
          , (hvMigrationPort,                   PyValueEx (8102 :: Int))
3647
          , (hvMigrationBandwidth,              PyValueEx (32 :: Int))
3648
          , (hvMigrationDowntime,               PyValueEx (30 :: Int))
3649
          , (hvMigrationMode,                   PyValueEx htMigrationLive)
3650
          , (hvUseLocaltime,                    PyValueEx False)
3651
          , (hvDiskCache,                       PyValueEx htCacheDefault)
3652
          , (hvSecurityModel,                   PyValueEx htSmNone)
3653
          , (hvSecurityDomain,                  PyValueEx "")
3654
          , (hvKvmFlag,                         PyValueEx "")
3655
          , (hvVhostNet,                        PyValueEx False)
3656
          , (hvKvmUseChroot,                    PyValueEx False)
3657
          , (hvMemPath,                         PyValueEx "")
3658
          , (hvRebootBehavior,                  PyValueEx instanceRebootAllowed)
3659
          , (hvCpuMask,                         PyValueEx cpuPinningAll)
3660
          , (hvCpuType,                         PyValueEx "")
3661
          , (hvCpuCores,                        PyValueEx (0 :: Int))
3662
          , (hvCpuThreads,                      PyValueEx (0 :: Int))
3663
          , (hvCpuSockets,                      PyValueEx (0 :: Int))
3664
          , (hvSoundhw,                         PyValueEx "")
3665
          , (hvUsbDevices,                      PyValueEx "")
3666
          , (hvVga,                             PyValueEx "")
3667
          , (hvKvmExtra,                        PyValueEx "")
3668
          , (hvKvmMachineVersion,               PyValueEx "")
3669
          , (hvVnetHdr,                         PyValueEx True)])
3670
  , (Fake, Map.fromList [(hvMigrationMode, PyValueEx htMigrationLive)])
3671
  , (Chroot, Map.fromList [(hvInitScript, PyValueEx "/ganeti-chroot")])
3672
  , (Lxc, Map.fromList [(hvCpuMask, PyValueEx "")])
3673
  ]
3674

    
3675
hvcGlobals :: FrozenSet String
3676
hvcGlobals =
3677
  ConstantUtils.mkSet [hvMigrationBandwidth,
3678
                       hvMigrationMode,
3679
                       hvMigrationPort,
3680
                       hvXenCmd]
3681

    
3682
becDefaults :: Map String PyValueEx
3683
becDefaults =
3684
  Map.fromList
3685
  [ (beMinmem, PyValueEx (128 :: Int))
3686
  , (beMaxmem, PyValueEx (128 :: Int))
3687
  , (beVcpus, PyValueEx (1 :: Int))
3688
  , (beAutoBalance, PyValueEx True)
3689
  , (beAlwaysFailover, PyValueEx False)
3690
  , (beSpindleUse, PyValueEx (1 :: Int))
3691
  ]
3692

    
3693
ndcDefaults :: Map String PyValueEx
3694
ndcDefaults =
3695
  Map.fromList
3696
  [ (ndOobProgram,       PyValueEx "")
3697
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3698
  , (ndExclusiveStorage, PyValueEx False)
3699
  , (ndOvs,              PyValueEx False)
3700
  , (ndOvsName,          PyValueEx defaultOvs)
3701
  , (ndOvsLink,          PyValueEx "")
3702
  , (ndSshPort,          PyValueEx (22 :: Int))
3703
  ]
3704

    
3705
ndcGlobals :: FrozenSet String
3706
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3707

    
3708
-- | Default delay target measured in sectors
3709
defaultDelayTarget :: Int
3710
defaultDelayTarget = 1
3711

    
3712
defaultDiskCustom :: String
3713
defaultDiskCustom = ""
3714

    
3715
defaultDiskResync :: Bool
3716
defaultDiskResync = False
3717

    
3718
-- | Default fill target measured in sectors
3719
defaultFillTarget :: Int
3720
defaultFillTarget = 0
3721

    
3722
-- | Default mininum rate measured in KiB/s
3723
defaultMinRate :: Int
3724
defaultMinRate = 4 * 1024
3725

    
3726
defaultNetCustom :: String
3727
defaultNetCustom = ""
3728

    
3729
-- | Default plan ahead measured in sectors
3730
--
3731
-- The default values for the DRBD dynamic resync speed algorithm are
3732
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3733
-- (that we don't need to set to 0, because we have a separate option
3734
-- to enable it) and for c-max-rate, that we cap to the default value
3735
-- for the static resync rate.
3736
defaultPlanAhead :: Int
3737
defaultPlanAhead = 20
3738

    
3739
defaultRbdPool :: String
3740
defaultRbdPool = "rbd"
3741

    
3742
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3743
diskLdDefaults =
3744
  Map.fromList
3745
  [ (DTBlock, Map.empty)
3746
  , (DTDrbd8, Map.fromList
3747
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3748
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3749
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3750
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3751
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3752
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3753
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3754
              , (ldpMinRate,       PyValueEx defaultMinRate)
3755
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3756
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3757
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3758
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3759
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3760
              ])
3761
  , (DTExt, Map.empty)
3762
  , (DTFile, Map.empty)
3763
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3764
  , (DTRbd, Map.fromList
3765
            [ (ldpPool, PyValueEx defaultRbdPool)
3766
            , (ldpAccess, PyValueEx diskKernelspace)
3767
            ])
3768
  , (DTSharedFile, Map.empty)
3769
  ]
3770

    
3771
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3772
diskDtDefaults =
3773
  Map.fromList
3774
  [ (DTBlock,      Map.empty)
3775
  , (DTDiskless,   Map.empty)
3776
  , (DTDrbd8,      Map.fromList
3777
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3778
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3779
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3780
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3781
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3782
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3783
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3784
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3785
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3786
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3787
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3788
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3789
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3790
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3791
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3792
                   ])
3793
  , (DTExt,        Map.empty)
3794
  , (DTFile,       Map.empty)
3795
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3796
  , (DTRbd,        Map.fromList
3797
                   [ (rbdPool, PyValueEx defaultRbdPool)
3798
                   , (rbdAccess, PyValueEx diskKernelspace)
3799
                   ])
3800
  , (DTSharedFile, Map.empty)
3801
  ]
3802

    
3803
niccDefaults :: Map String PyValueEx
3804
niccDefaults =
3805
  Map.fromList
3806
  [ (nicMode, PyValueEx nicModeBridged)
3807
  , (nicLink, PyValueEx defaultBridge)
3808
  , (nicVlan, PyValueEx valueHsNothing)
3809
  ]
3810

    
3811
-- | All of the following values are quite arbitrary - there are no
3812
-- "good" defaults, these must be customised per-site
3813
ispecsMinmaxDefaults :: Map String (Map String Int)
3814
ispecsMinmaxDefaults =
3815
  Map.fromList
3816
  [(ispecsMin,
3817
    Map.fromList
3818
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3819
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3820
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3821
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3822
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3823
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3824
   (ispecsMax,
3825
    Map.fromList
3826
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3827
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3828
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3829
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3830
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3831
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3832

    
3833
ipolicyDefaults :: Map String PyValueEx
3834
ipolicyDefaults =
3835
  Map.fromList
3836
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3837
  , (ispecsStd,           PyValueEx (Map.fromList
3838
                                     [ (ispecMemSize,    128)
3839
                                     , (ispecCpuCount,   1)
3840
                                     , (ispecDiskCount,  1)
3841
                                     , (ispecDiskSize,   1024)
3842
                                     , (ispecNicCount,   1)
3843
                                     , (ispecSpindleUse, 1)
3844
                                     ] :: Map String Int))
3845
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3846
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3847
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3848
  ]
3849

    
3850
masterPoolSizeDefault :: Int
3851
masterPoolSizeDefault = 10
3852

    
3853
-- * Exclusive storage
3854

    
3855
-- | Error margin used to compare physical disks
3856
partMargin :: Double
3857
partMargin = 0.01
3858

    
3859
-- | Space reserved when creating instance disks
3860
partReserved :: Double
3861
partReserved = 0.02
3862

    
3863
-- * Confd
3864

    
3865
confdProtocolVersion :: Int
3866
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3867

    
3868
-- Confd request type
3869

    
3870
confdReqPing :: Int
3871
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3872

    
3873
confdReqNodeRoleByname :: Int
3874
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3875

    
3876
confdReqNodePipByInstanceIp :: Int
3877
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3878

    
3879
confdReqClusterMaster :: Int
3880
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3881

    
3882
confdReqNodePipList :: Int
3883
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3884

    
3885
confdReqMcPipList :: Int
3886
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3887

    
3888
confdReqInstancesIpsList :: Int
3889
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3890

    
3891
confdReqNodeDrbd :: Int
3892
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3893

    
3894
confdReqNodeInstances :: Int
3895
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3896

    
3897
confdReqs :: FrozenSet Int
3898
confdReqs =
3899
  ConstantUtils.mkSet .
3900
  map Types.confdRequestTypeToRaw $
3901
  [minBound..] \\ [ReqNodeInstances]
3902

    
3903
-- * Confd request type
3904

    
3905
confdReqfieldName :: Int
3906
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3907

    
3908
confdReqfieldIp :: Int
3909
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3910

    
3911
confdReqfieldMnodePip :: Int
3912
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3913

    
3914
-- * Confd repl status
3915

    
3916
confdReplStatusOk :: Int
3917
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3918

    
3919
confdReplStatusError :: Int
3920
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3921

    
3922
confdReplStatusNotimplemented :: Int
3923
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3924

    
3925
confdReplStatuses :: FrozenSet Int
3926
confdReplStatuses =
3927
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3928

    
3929
-- * Confd node role
3930

    
3931
confdNodeRoleMaster :: Int
3932
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3933

    
3934
confdNodeRoleCandidate :: Int
3935
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3936

    
3937
confdNodeRoleOffline :: Int
3938
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3939

    
3940
confdNodeRoleDrained :: Int
3941
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3942

    
3943
confdNodeRoleRegular :: Int
3944
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3945

    
3946
-- * A few common errors for confd
3947

    
3948
confdErrorUnknownEntry :: Int
3949
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3950

    
3951
confdErrorInternal :: Int
3952
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3953

    
3954
confdErrorArgument :: Int
3955
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3956

    
3957
-- * Confd request query fields
3958

    
3959
confdReqqLink :: String
3960
confdReqqLink = ConstantUtils.confdReqqLink
3961

    
3962
confdReqqIp :: String
3963
confdReqqIp = ConstantUtils.confdReqqIp
3964

    
3965
confdReqqIplist :: String
3966
confdReqqIplist = ConstantUtils.confdReqqIplist
3967

    
3968
confdReqqFields :: String
3969
confdReqqFields = ConstantUtils.confdReqqFields
3970

    
3971
-- | Each request is "salted" by the current timestamp.
3972
--
3973
-- This constant decides how many seconds of skew to accept.
3974
--
3975
-- TODO: make this a default and allow the value to be more
3976
-- configurable
3977
confdMaxClockSkew :: Int
3978
confdMaxClockSkew = 2 * nodeMaxClockSkew
3979

    
3980
-- | When we haven't reloaded the config for more than this amount of
3981
-- seconds, we force a test to see if inotify is betraying us. Using a
3982
-- prime number to ensure we get less chance of 'same wakeup' with
3983
-- other processes.
3984
confdConfigReloadTimeout :: Int
3985
confdConfigReloadTimeout = 17
3986

    
3987
-- | If we receive more than one update in this amount of
3988
-- microseconds, we move to polling every RATELIMIT seconds, rather
3989
-- than relying on inotify, to be able to serve more requests.
3990
confdConfigReloadRatelimit :: Int
3991
confdConfigReloadRatelimit = 250000
3992

    
3993
-- | Magic number prepended to all confd queries.
3994
--
3995
-- This allows us to distinguish different types of confd protocols
3996
-- and handle them. For example by changing this we can move the whole
3997
-- payload to be compressed, or move away from json.
3998
confdMagicFourcc :: String
3999
confdMagicFourcc = "plj0"
4000

    
4001
-- | By default a confd request is sent to the minimum between this
4002
-- number and all MCs. 6 was chosen because even in the case of a
4003
-- disastrous 50% response rate, we should have enough answers to be
4004
-- able to compare more than one.
4005
confdDefaultReqCoverage :: Int
4006
confdDefaultReqCoverage = 6
4007

    
4008
-- | Timeout in seconds to expire pending query request in the confd
4009
-- client library. We don't actually expect any answer more than 10
4010
-- seconds after we sent a request.
4011
confdClientExpireTimeout :: Int
4012
confdClientExpireTimeout = 10
4013

    
4014
-- | Maximum UDP datagram size.
4015
--
4016
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4017
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4018
--   (assuming we can't use jumbo frames)
4019
-- We just set this to 60K, which should be enough
4020
maxUdpDataSize :: Int
4021
maxUdpDataSize = 61440
4022

    
4023
-- * User-id pool minimum/maximum acceptable user-ids
4024

    
4025
uidpoolUidMin :: Int
4026
uidpoolUidMin = 0
4027

    
4028
-- | Assuming 32 bit user-ids
4029
uidpoolUidMax :: Integer
4030
uidpoolUidMax = 2 ^ 32 - 1
4031

    
4032
-- | Name or path of the pgrep command
4033
pgrep :: String
4034
pgrep = "pgrep"
4035

    
4036
-- | Name of the node group that gets created at cluster init or
4037
-- upgrade
4038
initialNodeGroupName :: String
4039
initialNodeGroupName = "default"
4040

    
4041
-- * Possible values for NodeGroup.alloc_policy
4042

    
4043
allocPolicyLastResort :: String
4044
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4045

    
4046
allocPolicyPreferred :: String
4047
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4048

    
4049
allocPolicyUnallocable :: String
4050
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4051

    
4052
validAllocPolicies :: [String]
4053
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4054

    
4055
-- | Temporary external/shared storage parameters
4056
blockdevDriverManual :: String
4057
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4058

    
4059
-- | 'qemu-img' path, required for 'ovfconverter'
4060
qemuimgPath :: String
4061
qemuimgPath = AutoConf.qemuimgPath
4062

    
4063
-- | Whether htools was enabled at compilation time
4064
--
4065
-- FIXME: this should be moved next to the other enable constants,
4066
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4067
htools :: Bool
4068
htools = AutoConf.htools
4069

    
4070
-- | The hail iallocator
4071
iallocHail :: String
4072
iallocHail = "hail"
4073

    
4074
-- * Fake opcodes for functions that have hooks attached to them via
4075
-- backend.RunLocalHooks
4076

    
4077
fakeOpMasterTurndown :: String
4078
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4079

    
4080
fakeOpMasterTurnup :: String
4081
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4082

    
4083
-- * SSH key types
4084

    
4085
sshkDsa :: String
4086
sshkDsa = "dsa"
4087

    
4088
sshkRsa :: String
4089
sshkRsa = "rsa"
4090

    
4091
sshkAll :: FrozenSet String
4092
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4093

    
4094
-- * SSH authorized key types
4095

    
4096
sshakDss :: String
4097
sshakDss = "ssh-dss"
4098

    
4099
sshakRsa :: String
4100
sshakRsa = "ssh-rsa"
4101

    
4102
sshakAll :: FrozenSet String
4103
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4104

    
4105
-- * SSH setup
4106

    
4107
sshsClusterName :: String
4108
sshsClusterName = "cluster_name"
4109

    
4110
sshsSshHostKey :: String
4111
sshsSshHostKey = "ssh_host_key"
4112

    
4113
sshsSshRootKey :: String
4114
sshsSshRootKey = "ssh_root_key"
4115

    
4116
sshsNodeDaemonCertificate :: String
4117
sshsNodeDaemonCertificate = "node_daemon_certificate"
4118

    
4119
-- * Key files for SSH daemon
4120

    
4121
sshHostDsaPriv :: String
4122
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4123

    
4124
sshHostDsaPub :: String
4125
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4126

    
4127
sshHostRsaPriv :: String
4128
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4129

    
4130
sshHostRsaPub :: String
4131
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4132

    
4133
sshDaemonKeyfiles :: Map String (String, String)
4134
sshDaemonKeyfiles =
4135
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4136
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4137
               ]
4138

    
4139
-- * Node daemon setup
4140

    
4141
ndsClusterName :: String
4142
ndsClusterName = "cluster_name"
4143

    
4144
ndsNodeDaemonCertificate :: String
4145
ndsNodeDaemonCertificate = "node_daemon_certificate"
4146

    
4147
ndsSsconf :: String
4148
ndsSsconf = "ssconf"
4149

    
4150
ndsStartNodeDaemon :: String
4151
ndsStartNodeDaemon = "start_node_daemon"
4152

    
4153
-- * The source reasons for the execution of an OpCode
4154

    
4155
opcodeReasonSrcClient :: String
4156
opcodeReasonSrcClient = "gnt:client"
4157

    
4158
opcodeReasonSrcNoded :: String
4159
opcodeReasonSrcNoded = "gnt:daemon:noded"
4160

    
4161
opcodeReasonSrcOpcode :: String
4162
opcodeReasonSrcOpcode = "gnt:opcode"
4163

    
4164
opcodeReasonSrcRlib2 :: String
4165
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4166

    
4167
opcodeReasonSrcUser :: String
4168
opcodeReasonSrcUser = "gnt:user"
4169

    
4170
opcodeReasonSources :: FrozenSet String
4171
opcodeReasonSources =
4172
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4173
                       opcodeReasonSrcNoded,
4174
                       opcodeReasonSrcOpcode,
4175
                       opcodeReasonSrcRlib2,
4176
                       opcodeReasonSrcUser]
4177

    
4178
-- | Path generating random UUID
4179
randomUuidFile :: String
4180
randomUuidFile = ConstantUtils.randomUuidFile
4181

    
4182
-- * Auto-repair tag prefixes
4183

    
4184
autoRepairTagPrefix :: String
4185
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4186

    
4187
autoRepairTagEnabled :: String
4188
autoRepairTagEnabled = autoRepairTagPrefix
4189

    
4190
autoRepairTagPending :: String
4191
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4192

    
4193
autoRepairTagResult :: String
4194
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4195

    
4196
autoRepairTagSuspended :: String
4197
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4198

    
4199
-- * Auto-repair levels
4200

    
4201
autoRepairFailover :: String
4202
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4203

    
4204
autoRepairFixStorage :: String
4205
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4206

    
4207
autoRepairMigrate :: String
4208
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4209

    
4210
autoRepairReinstall :: String
4211
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4212

    
4213
autoRepairAllTypes :: FrozenSet String
4214
autoRepairAllTypes =
4215
  ConstantUtils.mkSet [autoRepairFailover,
4216
                       autoRepairFixStorage,
4217
                       autoRepairMigrate,
4218
                       autoRepairReinstall]
4219

    
4220
-- * Auto-repair results
4221

    
4222
autoRepairEnoperm :: String
4223
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4224

    
4225
autoRepairFailure :: String
4226
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4227

    
4228
autoRepairSuccess :: String
4229
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4230

    
4231
autoRepairAllResults :: FrozenSet String
4232
autoRepairAllResults =
4233
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4234

    
4235
-- | The version identifier for builtin data collectors
4236
builtinDataCollectorVersion :: String
4237
builtinDataCollectorVersion = "B"
4238

    
4239
-- | The reason trail opcode parameter name
4240
opcodeReason :: String
4241
opcodeReason = "reason"
4242

    
4243
diskstatsFile :: String
4244
diskstatsFile = "/proc/diskstats"
4245

    
4246
-- *  CPU load collector
4247

    
4248
statFile :: String
4249
statFile = "/proc/stat"
4250

    
4251
cpuavgloadBufferSize :: Int
4252
cpuavgloadBufferSize = 150
4253

    
4254
cpuavgloadWindowSize :: Int
4255
cpuavgloadWindowSize = 600
4256

    
4257
-- * Monitoring daemon
4258

    
4259
-- | Mond's variable for periodical data collection
4260
mondTimeInterval :: Int
4261
mondTimeInterval = 5
4262

    
4263
-- | Mond's latest API version
4264
mondLatestApiVersion :: Int
4265
mondLatestApiVersion = 1
4266

    
4267
-- * Disk access modes
4268

    
4269
diskUserspace :: String
4270
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4271

    
4272
diskKernelspace :: String
4273
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4274

    
4275
diskValidAccessModes :: FrozenSet String
4276
diskValidAccessModes =
4277
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4278

    
4279
-- | Timeout for queue draining in upgrades
4280
upgradeQueueDrainTimeout :: Int
4281
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4282

    
4283
-- | Intervall at which the queue is polled during upgrades
4284
upgradeQueuePollInterval :: Int
4285
upgradeQueuePollInterval  = 10
4286

    
4287
-- * Hotplug Actions
4288

    
4289
hotplugActionAdd :: String
4290
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4291

    
4292
hotplugActionRemove :: String
4293
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4294

    
4295
hotplugActionModify :: String
4296
hotplugActionModify = Types.hotplugActionToRaw HAMod
4297

    
4298
hotplugAllActions :: FrozenSet String
4299
hotplugAllActions =
4300
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4301

    
4302
-- * Hotplug Device Targets
4303

    
4304
hotplugTargetNic :: String
4305
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4306

    
4307
hotplugTargetDisk :: String
4308
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4309

    
4310
hotplugAllTargets :: FrozenSet String
4311
hotplugAllTargets =
4312
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4313

    
4314
-- | Timeout for disk removal (seconds)
4315
diskRemoveRetryTimeout :: Int
4316
diskRemoveRetryTimeout = 30
4317

    
4318
-- | Interval between disk removal retries (seconds)
4319
diskRemoveRetryInterval :: Int
4320
diskRemoveRetryInterval  = 3