Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ 9158a1dd

History | View | Annotate | Download (108.5 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
ndsParameterTypes :: Map String VType
1994
ndsParameterTypes =
1995
  Map.fromList
1996
  [(ndExclusiveStorage, VTypeBool),
1997
   (ndOobProgram, VTypeString),
1998
   (ndOvs, VTypeBool),
1999
   (ndOvsLink, VTypeMaybeString),
2000
   (ndOvsName, VTypeMaybeString),
2001
   (ndSpindleCount, VTypeInt)]
2002

    
2003
ndsParameters :: FrozenSet String
2004
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
2005

    
2006
ndsParameterTitles :: Map String String
2007
ndsParameterTitles =
2008
  Map.fromList
2009
  [(ndExclusiveStorage, "ExclusiveStorage"),
2010
   (ndOobProgram, "OutOfBandProgram"),
2011
   (ndOvs, "OpenvSwitch"),
2012
   (ndOvsLink, "OpenvSwitchLink"),
2013
   (ndOvsName, "OpenvSwitchName"),
2014
   (ndSpindleCount, "SpindleCount")]
2015

    
2016
-- * Logical Disks parameters
2017

    
2018
ldpAccess :: String
2019
ldpAccess = "access"
2020

    
2021
ldpBarriers :: String
2022
ldpBarriers = "disabled-barriers"
2023

    
2024
ldpDefaultMetavg :: String
2025
ldpDefaultMetavg = "default-metavg"
2026

    
2027
ldpDelayTarget :: String
2028
ldpDelayTarget = "c-delay-target"
2029

    
2030
ldpDiskCustom :: String
2031
ldpDiskCustom = "disk-custom"
2032

    
2033
ldpDynamicResync :: String
2034
ldpDynamicResync = "dynamic-resync"
2035

    
2036
ldpFillTarget :: String
2037
ldpFillTarget = "c-fill-target"
2038

    
2039
ldpMaxRate :: String
2040
ldpMaxRate = "c-max-rate"
2041

    
2042
ldpMinRate :: String
2043
ldpMinRate = "c-min-rate"
2044

    
2045
ldpNetCustom :: String
2046
ldpNetCustom = "net-custom"
2047

    
2048
ldpNoMetaFlush :: String
2049
ldpNoMetaFlush = "disable-meta-flush"
2050

    
2051
ldpPlanAhead :: String
2052
ldpPlanAhead = "c-plan-ahead"
2053

    
2054
ldpPool :: String
2055
ldpPool = "pool"
2056

    
2057
ldpProtocol :: String
2058
ldpProtocol = "protocol"
2059

    
2060
ldpResyncRate :: String
2061
ldpResyncRate = "resync-rate"
2062

    
2063
ldpStripes :: String
2064
ldpStripes = "stripes"
2065

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

    
2086
diskLdParameters :: FrozenSet String
2087
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2088

    
2089
-- * Disk template parameters
2090
--
2091
-- Disk template parameters can be set/changed by the user via
2092
-- gnt-cluster and gnt-group)
2093

    
2094
drbdResyncRate :: String
2095
drbdResyncRate = "resync-rate"
2096

    
2097
drbdDataStripes :: String
2098
drbdDataStripes = "data-stripes"
2099

    
2100
drbdMetaStripes :: String
2101
drbdMetaStripes = "meta-stripes"
2102

    
2103
drbdDiskBarriers :: String
2104
drbdDiskBarriers = "disk-barriers"
2105

    
2106
drbdMetaBarriers :: String
2107
drbdMetaBarriers = "meta-barriers"
2108

    
2109
drbdDefaultMetavg :: String
2110
drbdDefaultMetavg = "metavg"
2111

    
2112
drbdDiskCustom :: String
2113
drbdDiskCustom = "disk-custom"
2114

    
2115
drbdNetCustom :: String
2116
drbdNetCustom = "net-custom"
2117

    
2118
drbdProtocol :: String
2119
drbdProtocol = "protocol"
2120

    
2121
drbdDynamicResync :: String
2122
drbdDynamicResync = "dynamic-resync"
2123

    
2124
drbdPlanAhead :: String
2125
drbdPlanAhead = "c-plan-ahead"
2126

    
2127
drbdFillTarget :: String
2128
drbdFillTarget = "c-fill-target"
2129

    
2130
drbdDelayTarget :: String
2131
drbdDelayTarget = "c-delay-target"
2132

    
2133
drbdMaxRate :: String
2134
drbdMaxRate = "c-max-rate"
2135

    
2136
drbdMinRate :: String
2137
drbdMinRate = "c-min-rate"
2138

    
2139
lvStripes :: String
2140
lvStripes = "stripes"
2141

    
2142
rbdAccess :: String
2143
rbdAccess = "access"
2144

    
2145
rbdPool :: String
2146
rbdPool = "pool"
2147

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

    
2169
diskDtParameters :: FrozenSet String
2170
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2171

    
2172
-- * Dynamic disk parameters
2173

    
2174
ddpLocalIp :: String
2175
ddpLocalIp = "local-ip"
2176

    
2177
ddpRemoteIp :: String
2178
ddpRemoteIp = "remote-ip"
2179

    
2180
ddpPort :: String
2181
ddpPort = "port"
2182

    
2183
ddpLocalMinor :: String
2184
ddpLocalMinor = "local-minor"
2185

    
2186
ddpRemoteMinor :: String
2187
ddpRemoteMinor = "remote-minor"
2188

    
2189
-- * OOB supported commands
2190

    
2191
oobPowerOn :: String
2192
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2193

    
2194
oobPowerOff :: String
2195
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2196

    
2197
oobPowerCycle :: String
2198
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2199

    
2200
oobPowerStatus :: String
2201
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2202

    
2203
oobHealth :: String
2204
oobHealth = Types.oobCommandToRaw OobHealth
2205

    
2206
oobCommands :: FrozenSet String
2207
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2208

    
2209
oobPowerStatusPowered :: String
2210
oobPowerStatusPowered = "powered"
2211

    
2212
-- | 60 seconds
2213
oobTimeout :: Int
2214
oobTimeout = 60
2215

    
2216
-- | 2 seconds
2217
oobPowerDelay :: Double
2218
oobPowerDelay = 2.0
2219

    
2220
oobStatusCritical :: String
2221
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2222

    
2223
oobStatusOk :: String
2224
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2225

    
2226
oobStatusUnknown :: String
2227
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2228

    
2229
oobStatusWarning :: String
2230
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2231

    
2232
oobStatuses :: FrozenSet String
2233
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2234

    
2235
-- | Instance Parameters Profile
2236
ppDefault :: String
2237
ppDefault = "default"
2238

    
2239
-- * nic* constants are used inside the ganeti config
2240

    
2241
nicLink :: String
2242
nicLink = "link"
2243

    
2244
nicMode :: String
2245
nicMode = "mode"
2246

    
2247
nicVlan :: String
2248
nicVlan = "vlan"
2249

    
2250
nicsParameterTypes :: Map String VType
2251
nicsParameterTypes =
2252
  Map.fromList [(nicMode, vtypeString),
2253
                (nicLink, vtypeString),
2254
                (nicVlan, vtypeMaybeString)]
2255

    
2256
nicsParameters :: FrozenSet String
2257
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2258

    
2259
nicModeBridged :: String
2260
nicModeBridged = Types.nICModeToRaw NMBridged
2261

    
2262
nicModeRouted :: String
2263
nicModeRouted = Types.nICModeToRaw NMRouted
2264

    
2265
nicModeOvs :: String
2266
nicModeOvs = Types.nICModeToRaw NMOvs
2267

    
2268
nicIpPool :: String
2269
nicIpPool = Types.nICModeToRaw NMPool
2270

    
2271
nicValidModes :: FrozenSet String
2272
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2273

    
2274
releaseAction :: String
2275
releaseAction = "release"
2276

    
2277
reserveAction :: String
2278
reserveAction = "reserve"
2279

    
2280
-- * idisk* constants are used in opcodes, to create/change disks
2281

    
2282
idiskAdopt :: String
2283
idiskAdopt = "adopt"
2284

    
2285
idiskMetavg :: String
2286
idiskMetavg = "metavg"
2287

    
2288
idiskMode :: String
2289
idiskMode = "mode"
2290

    
2291
idiskName :: String
2292
idiskName = "name"
2293

    
2294
idiskSize :: String
2295
idiskSize = "size"
2296

    
2297
idiskSpindles :: String
2298
idiskSpindles = "spindles"
2299

    
2300
idiskVg :: String
2301
idiskVg = "vg"
2302

    
2303
idiskProvider :: String
2304
idiskProvider = "provider"
2305

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

    
2317
idiskParams :: FrozenSet String
2318
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2319

    
2320
-- * inic* constants are used in opcodes, to create/change nics
2321

    
2322
inicBridge :: String
2323
inicBridge = "bridge"
2324

    
2325
inicIp :: String
2326
inicIp = "ip"
2327

    
2328
inicLink :: String
2329
inicLink = "link"
2330

    
2331
inicMac :: String
2332
inicMac = "mac"
2333

    
2334
inicMode :: String
2335
inicMode = "mode"
2336

    
2337
inicName :: String
2338
inicName = "name"
2339

    
2340
inicNetwork :: String
2341
inicNetwork = "network"
2342

    
2343
inicVlan :: String
2344
inicVlan = "vlan"
2345

    
2346
inicParamsTypes :: Map String VType
2347
inicParamsTypes =
2348
  Map.fromList [(inicBridge, VTypeMaybeString),
2349
                (inicIp, VTypeMaybeString),
2350
                (inicLink, VTypeString),
2351
                (inicMac, VTypeString),
2352
                (inicMode, VTypeString),
2353
                (inicName, VTypeMaybeString),
2354
                (inicNetwork, VTypeMaybeString),
2355
                (inicVlan, VTypeMaybeString)]
2356

    
2357
inicParams :: FrozenSet String
2358
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2359

    
2360
-- * Hypervisor constants
2361

    
2362
htXenPvm :: String
2363
htXenPvm = Types.hypervisorToRaw XenPvm
2364

    
2365
htFake :: String
2366
htFake = Types.hypervisorToRaw Fake
2367

    
2368
htXenHvm :: String
2369
htXenHvm = Types.hypervisorToRaw XenHvm
2370

    
2371
htKvm :: String
2372
htKvm = Types.hypervisorToRaw Kvm
2373

    
2374
htChroot :: String
2375
htChroot = Types.hypervisorToRaw Chroot
2376

    
2377
htLxc :: String
2378
htLxc = Types.hypervisorToRaw Lxc
2379

    
2380
hyperTypes :: FrozenSet String
2381
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2382

    
2383
htsReqPort :: FrozenSet String
2384
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2385

    
2386
vncBasePort :: Int
2387
vncBasePort = 5900
2388

    
2389
vncDefaultBindAddress :: String
2390
vncDefaultBindAddress = ip4AddressAny
2391

    
2392
-- * NIC types
2393

    
2394
htNicE1000 :: String
2395
htNicE1000 = "e1000"
2396

    
2397
htNicI82551 :: String
2398
htNicI82551 = "i82551"
2399

    
2400
htNicI8259er :: String
2401
htNicI8259er = "i82559er"
2402

    
2403
htNicI85557b :: String
2404
htNicI85557b = "i82557b"
2405

    
2406
htNicNe2kIsa :: String
2407
htNicNe2kIsa = "ne2k_isa"
2408

    
2409
htNicNe2kPci :: String
2410
htNicNe2kPci = "ne2k_pci"
2411

    
2412
htNicParavirtual :: String
2413
htNicParavirtual = "paravirtual"
2414

    
2415
htNicPcnet :: String
2416
htNicPcnet = "pcnet"
2417

    
2418
htNicRtl8139 :: String
2419
htNicRtl8139 = "rtl8139"
2420

    
2421
htHvmValidNicTypes :: FrozenSet String
2422
htHvmValidNicTypes =
2423
  ConstantUtils.mkSet [htNicE1000,
2424
                       htNicNe2kIsa,
2425
                       htNicNe2kPci,
2426
                       htNicParavirtual,
2427
                       htNicRtl8139]
2428

    
2429
htKvmValidNicTypes :: FrozenSet String
2430
htKvmValidNicTypes =
2431
  ConstantUtils.mkSet [htNicE1000,
2432
                       htNicI82551,
2433
                       htNicI8259er,
2434
                       htNicI85557b,
2435
                       htNicNe2kIsa,
2436
                       htNicNe2kPci,
2437
                       htNicParavirtual,
2438
                       htNicPcnet,
2439
                       htNicRtl8139]
2440

    
2441
-- * Vif types
2442

    
2443
-- | Default vif type in xen-hvm
2444
htHvmVifIoemu :: String
2445
htHvmVifIoemu = "ioemu"
2446

    
2447
htHvmVifVif :: String
2448
htHvmVifVif = "vif"
2449

    
2450
htHvmValidVifTypes :: FrozenSet String
2451
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2452

    
2453
-- * Disk types
2454

    
2455
htDiskIde :: String
2456
htDiskIde = "ide"
2457

    
2458
htDiskIoemu :: String
2459
htDiskIoemu = "ioemu"
2460

    
2461
htDiskMtd :: String
2462
htDiskMtd = "mtd"
2463

    
2464
htDiskParavirtual :: String
2465
htDiskParavirtual = "paravirtual"
2466

    
2467
htDiskPflash :: String
2468
htDiskPflash = "pflash"
2469

    
2470
htDiskScsi :: String
2471
htDiskScsi = "scsi"
2472

    
2473
htDiskSd :: String
2474
htDiskSd = "sd"
2475

    
2476
htHvmValidDiskTypes :: FrozenSet String
2477
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2478

    
2479
htKvmValidDiskTypes :: FrozenSet String
2480
htKvmValidDiskTypes =
2481
  ConstantUtils.mkSet [htDiskIde,
2482
                       htDiskMtd,
2483
                       htDiskParavirtual,
2484
                       htDiskPflash,
2485
                       htDiskScsi,
2486
                       htDiskSd]
2487

    
2488
htCacheDefault :: String
2489
htCacheDefault = "default"
2490

    
2491
htCacheNone :: String
2492
htCacheNone = "none"
2493

    
2494
htCacheWback :: String
2495
htCacheWback = "writeback"
2496

    
2497
htCacheWthrough :: String
2498
htCacheWthrough = "writethrough"
2499

    
2500
htValidCacheTypes :: FrozenSet String
2501
htValidCacheTypes =
2502
  ConstantUtils.mkSet [htCacheDefault,
2503
                       htCacheNone,
2504
                       htCacheWback,
2505
                       htCacheWthrough]
2506

    
2507
-- * Mouse types
2508

    
2509
htMouseMouse :: String
2510
htMouseMouse = "mouse"
2511

    
2512
htMouseTablet :: String
2513
htMouseTablet = "tablet"
2514

    
2515
htKvmValidMouseTypes :: FrozenSet String
2516
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2517

    
2518
-- * Boot order
2519

    
2520
htBoCdrom :: String
2521
htBoCdrom = "cdrom"
2522

    
2523
htBoDisk :: String
2524
htBoDisk = "disk"
2525

    
2526
htBoFloppy :: String
2527
htBoFloppy = "floppy"
2528

    
2529
htBoNetwork :: String
2530
htBoNetwork = "network"
2531

    
2532
htKvmValidBoTypes :: FrozenSet String
2533
htKvmValidBoTypes =
2534
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2535

    
2536
-- * SPICE lossless image compression options
2537

    
2538
htKvmSpiceLosslessImgComprAutoGlz :: String
2539
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2540

    
2541
htKvmSpiceLosslessImgComprAutoLz :: String
2542
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2543

    
2544
htKvmSpiceLosslessImgComprGlz :: String
2545
htKvmSpiceLosslessImgComprGlz = "glz"
2546

    
2547
htKvmSpiceLosslessImgComprLz :: String
2548
htKvmSpiceLosslessImgComprLz = "lz"
2549

    
2550
htKvmSpiceLosslessImgComprOff :: String
2551
htKvmSpiceLosslessImgComprOff = "off"
2552

    
2553
htKvmSpiceLosslessImgComprQuic :: String
2554
htKvmSpiceLosslessImgComprQuic = "quic"
2555

    
2556
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2557
htKvmSpiceValidLosslessImgComprOptions =
2558
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2559
                       htKvmSpiceLosslessImgComprAutoLz,
2560
                       htKvmSpiceLosslessImgComprGlz,
2561
                       htKvmSpiceLosslessImgComprLz,
2562
                       htKvmSpiceLosslessImgComprOff,
2563
                       htKvmSpiceLosslessImgComprQuic]
2564

    
2565
htKvmSpiceLossyImgComprAlways :: String
2566
htKvmSpiceLossyImgComprAlways = "always"
2567

    
2568
htKvmSpiceLossyImgComprAuto :: String
2569
htKvmSpiceLossyImgComprAuto = "auto"
2570

    
2571
htKvmSpiceLossyImgComprNever :: String
2572
htKvmSpiceLossyImgComprNever = "never"
2573

    
2574
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2575
htKvmSpiceValidLossyImgComprOptions =
2576
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2577
                       htKvmSpiceLossyImgComprAuto,
2578
                       htKvmSpiceLossyImgComprNever]
2579

    
2580
-- * SPICE video stream detection
2581

    
2582
htKvmSpiceVideoStreamDetectionAll :: String
2583
htKvmSpiceVideoStreamDetectionAll = "all"
2584

    
2585
htKvmSpiceVideoStreamDetectionFilter :: String
2586
htKvmSpiceVideoStreamDetectionFilter = "filter"
2587

    
2588
htKvmSpiceVideoStreamDetectionOff :: String
2589
htKvmSpiceVideoStreamDetectionOff = "off"
2590

    
2591
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2592
htKvmSpiceValidVideoStreamDetectionOptions =
2593
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2594
                       htKvmSpiceVideoStreamDetectionFilter,
2595
                       htKvmSpiceVideoStreamDetectionOff]
2596

    
2597
-- * Security models
2598

    
2599
htSmNone :: String
2600
htSmNone = "none"
2601

    
2602
htSmPool :: String
2603
htSmPool = "pool"
2604

    
2605
htSmUser :: String
2606
htSmUser = "user"
2607

    
2608
htKvmValidSmTypes :: FrozenSet String
2609
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2610

    
2611
-- * Kvm flag values
2612

    
2613
htKvmDisabled :: String
2614
htKvmDisabled = "disabled"
2615

    
2616
htKvmEnabled :: String
2617
htKvmEnabled = "enabled"
2618

    
2619
htKvmFlagValues :: FrozenSet String
2620
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2621

    
2622
-- * Migration type
2623

    
2624
htMigrationLive :: String
2625
htMigrationLive = Types.migrationModeToRaw MigrationLive
2626

    
2627
htMigrationNonlive :: String
2628
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2629

    
2630
htMigrationModes :: FrozenSet String
2631
htMigrationModes =
2632
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2633

    
2634
-- * Cluster verify steps
2635

    
2636
verifyNplusoneMem :: String
2637
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2638

    
2639
verifyOptionalChecks :: FrozenSet String
2640
verifyOptionalChecks =
2641
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2642

    
2643
-- * Cluster Verify error classes
2644

    
2645
cvTcluster :: String
2646
cvTcluster = "cluster"
2647

    
2648
cvTgroup :: String
2649
cvTgroup = "group"
2650

    
2651
cvTnode :: String
2652
cvTnode = "node"
2653

    
2654
cvTinstance :: String
2655
cvTinstance = "instance"
2656

    
2657
-- * Cluster Verify error codes and documentation
2658

    
2659
cvEclustercert :: (String, String, String)
2660
cvEclustercert =
2661
  ("cluster",
2662
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2663
   "Cluster certificate files verification failure")
2664

    
2665
cvEclustercfg :: (String, String, String)
2666
cvEclustercfg =
2667
  ("cluster",
2668
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2669
   "Cluster configuration verification failure")
2670

    
2671
cvEclusterdanglinginst :: (String, String, String)
2672
cvEclusterdanglinginst =
2673
  ("node",
2674
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2675
   "Some instances have a non-existing primary node")
2676

    
2677
cvEclusterdanglingnodes :: (String, String, String)
2678
cvEclusterdanglingnodes =
2679
  ("node",
2680
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2681
   "Some nodes belong to non-existing groups")
2682

    
2683
cvEclusterfilecheck :: (String, String, String)
2684
cvEclusterfilecheck =
2685
  ("cluster",
2686
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2687
   "Cluster configuration verification failure")
2688

    
2689
cvEgroupdifferentpvsize :: (String, String, String)
2690
cvEgroupdifferentpvsize =
2691
  ("group",
2692
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2693
   "PVs in the group have different sizes")
2694

    
2695
cvEinstancebadnode :: (String, String, String)
2696
cvEinstancebadnode =
2697
  ("instance",
2698
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2699
   "Instance marked as running lives on an offline node")
2700

    
2701
cvEinstancedown :: (String, String, String)
2702
cvEinstancedown =
2703
  ("instance",
2704
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2705
   "Instance not running on its primary node")
2706

    
2707
cvEinstancefaultydisk :: (String, String, String)
2708
cvEinstancefaultydisk =
2709
  ("instance",
2710
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2711
   "Impossible to retrieve status for a disk")
2712

    
2713
cvEinstancelayout :: (String, String, String)
2714
cvEinstancelayout =
2715
  ("instance",
2716
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2717
   "Instance has multiple secondary nodes")
2718

    
2719
cvEinstancemissingcfgparameter :: (String, String, String)
2720
cvEinstancemissingcfgparameter =
2721
  ("instance",
2722
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2723
   "A configuration parameter for an instance is missing")
2724

    
2725
cvEinstancemissingdisk :: (String, String, String)
2726
cvEinstancemissingdisk =
2727
  ("instance",
2728
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2729
   "Missing volume on an instance")
2730

    
2731
cvEinstancepolicy :: (String, String, String)
2732
cvEinstancepolicy =
2733
  ("instance",
2734
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2735
   "Instance does not meet policy")
2736

    
2737
cvEinstancesplitgroups :: (String, String, String)
2738
cvEinstancesplitgroups =
2739
  ("instance",
2740
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2741
   "Instance with primary and secondary nodes in different groups")
2742

    
2743
cvEinstanceunsuitablenode :: (String, String, String)
2744
cvEinstanceunsuitablenode =
2745
  ("instance",
2746
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2747
   "Instance running on nodes that are not suitable for it")
2748

    
2749
cvEinstancewrongnode :: (String, String, String)
2750
cvEinstancewrongnode =
2751
  ("instance",
2752
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2753
   "Instance running on the wrong node")
2754

    
2755
cvEnodedrbd :: (String, String, String)
2756
cvEnodedrbd =
2757
  ("node",
2758
   Types.cVErrorCodeToRaw CvENODEDRBD,
2759
   "Error parsing the DRBD status file")
2760

    
2761
cvEnodedrbdhelper :: (String, String, String)
2762
cvEnodedrbdhelper =
2763
  ("node",
2764
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2765
   "Error caused by the DRBD helper")
2766

    
2767
cvEnodedrbdversion :: (String, String, String)
2768
cvEnodedrbdversion =
2769
  ("node",
2770
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2771
   "DRBD version mismatch within a node group")
2772

    
2773
cvEnodefilecheck :: (String, String, String)
2774
cvEnodefilecheck =
2775
  ("node",
2776
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2777
   "Error retrieving the checksum of the node files")
2778

    
2779
cvEnodefilestoragepaths :: (String, String, String)
2780
cvEnodefilestoragepaths =
2781
  ("node",
2782
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2783
   "Detected bad file storage paths")
2784

    
2785
cvEnodefilestoragepathunusable :: (String, String, String)
2786
cvEnodefilestoragepathunusable =
2787
  ("node",
2788
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2789
   "File storage path unusable")
2790

    
2791
cvEnodehooks :: (String, String, String)
2792
cvEnodehooks =
2793
  ("node",
2794
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2795
   "Communication failure in hooks execution")
2796

    
2797
cvEnodehv :: (String, String, String)
2798
cvEnodehv =
2799
  ("node",
2800
   Types.cVErrorCodeToRaw CvENODEHV,
2801
   "Hypervisor parameters verification failure")
2802

    
2803
cvEnodelvm :: (String, String, String)
2804
cvEnodelvm =
2805
  ("node",
2806
   Types.cVErrorCodeToRaw CvENODELVM,
2807
   "LVM-related node error")
2808

    
2809
cvEnoden1 :: (String, String, String)
2810
cvEnoden1 =
2811
  ("node",
2812
   Types.cVErrorCodeToRaw CvENODEN1,
2813
   "Not enough memory to accommodate instance failovers")
2814

    
2815
cvEnodenet :: (String, String, String)
2816
cvEnodenet =
2817
  ("node",
2818
   Types.cVErrorCodeToRaw CvENODENET,
2819
   "Network-related node error")
2820

    
2821
cvEnodeoobpath :: (String, String, String)
2822
cvEnodeoobpath =
2823
  ("node",
2824
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2825
   "Invalid Out Of Band path")
2826

    
2827
cvEnodeorphaninstance :: (String, String, String)
2828
cvEnodeorphaninstance =
2829
  ("node",
2830
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2831
   "Unknown intance running on a node")
2832

    
2833
cvEnodeorphanlv :: (String, String, String)
2834
cvEnodeorphanlv =
2835
  ("node",
2836
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2837
   "Unknown LVM logical volume")
2838

    
2839
cvEnodeos :: (String, String, String)
2840
cvEnodeos =
2841
  ("node",
2842
   Types.cVErrorCodeToRaw CvENODEOS,
2843
   "OS-related node error")
2844

    
2845
cvEnoderpc :: (String, String, String)
2846
cvEnoderpc =
2847
  ("node",
2848
   Types.cVErrorCodeToRaw CvENODERPC,
2849
   "Error during connection to the primary node of an instance")
2850

    
2851
cvEnodesetup :: (String, String, String)
2852
cvEnodesetup =
2853
  ("node",
2854
   Types.cVErrorCodeToRaw CvENODESETUP,
2855
   "Node setup error")
2856

    
2857
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2858
cvEnodesharedfilestoragepathunusable =
2859
  ("node",
2860
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2861
   "Shared file storage path unusable")
2862

    
2863
cvEnodessh :: (String, String, String)
2864
cvEnodessh =
2865
  ("node",
2866
   Types.cVErrorCodeToRaw CvENODESSH,
2867
   "SSH-related node error")
2868

    
2869
cvEnodetime :: (String, String, String)
2870
cvEnodetime =
2871
  ("node",
2872
   Types.cVErrorCodeToRaw CvENODETIME,
2873
   "Node returned invalid time")
2874

    
2875
cvEnodeuserscripts :: (String, String, String)
2876
cvEnodeuserscripts =
2877
  ("node",
2878
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2879
   "User scripts not present or not executable")
2880

    
2881
cvEnodeversion :: (String, String, String)
2882
cvEnodeversion =
2883
  ("node",
2884
   Types.cVErrorCodeToRaw CvENODEVERSION,
2885
   "Protocol version mismatch or Ganeti version mismatch")
2886

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

    
2929
cvAllEcodesStrings :: FrozenSet String
2930
cvAllEcodesStrings =
2931
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2932

    
2933
-- * Node verify constants
2934

    
2935
nvBridges :: String
2936
nvBridges = "bridges"
2937

    
2938
nvDrbdhelper :: String
2939
nvDrbdhelper = "drbd-helper"
2940

    
2941
nvDrbdversion :: String
2942
nvDrbdversion = "drbd-version"
2943

    
2944
nvDrbdlist :: String
2945
nvDrbdlist = "drbd-list"
2946

    
2947
nvExclusivepvs :: String
2948
nvExclusivepvs = "exclusive-pvs"
2949

    
2950
nvFilelist :: String
2951
nvFilelist = "filelist"
2952

    
2953
nvAcceptedStoragePaths :: String
2954
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2955

    
2956
nvFileStoragePath :: String
2957
nvFileStoragePath = "file-storage-path"
2958

    
2959
nvSharedFileStoragePath :: String
2960
nvSharedFileStoragePath = "shared-file-storage-path"
2961

    
2962
nvHvinfo :: String
2963
nvHvinfo = "hvinfo"
2964

    
2965
nvHvparams :: String
2966
nvHvparams = "hvparms"
2967

    
2968
nvHypervisor :: String
2969
nvHypervisor = "hypervisor"
2970

    
2971
nvInstancelist :: String
2972
nvInstancelist = "instancelist"
2973

    
2974
nvLvlist :: String
2975
nvLvlist = "lvlist"
2976

    
2977
nvMasterip :: String
2978
nvMasterip = "master-ip"
2979

    
2980
nvNodelist :: String
2981
nvNodelist = "nodelist"
2982

    
2983
nvNodenettest :: String
2984
nvNodenettest = "node-net-test"
2985

    
2986
nvNodesetup :: String
2987
nvNodesetup = "nodesetup"
2988

    
2989
nvOobPaths :: String
2990
nvOobPaths = "oob-paths"
2991

    
2992
nvOslist :: String
2993
nvOslist = "oslist"
2994

    
2995
nvPvlist :: String
2996
nvPvlist = "pvlist"
2997

    
2998
nvTime :: String
2999
nvTime = "time"
3000

    
3001
nvUserscripts :: String
3002
nvUserscripts = "user-scripts"
3003

    
3004
nvVersion :: String
3005
nvVersion = "version"
3006

    
3007
nvVglist :: String
3008
nvVglist = "vglist"
3009

    
3010
nvVmnodes :: String
3011
nvVmnodes = "vmnodes"
3012

    
3013
-- * Instance status
3014

    
3015
inststAdmindown :: String
3016
inststAdmindown = Types.instanceStatusToRaw StatusDown
3017

    
3018
inststAdminoffline :: String
3019
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3020

    
3021
inststErrordown :: String
3022
inststErrordown = Types.instanceStatusToRaw ErrorDown
3023

    
3024
inststErrorup :: String
3025
inststErrorup = Types.instanceStatusToRaw ErrorUp
3026

    
3027
inststNodedown :: String
3028
inststNodedown = Types.instanceStatusToRaw NodeDown
3029

    
3030
inststNodeoffline :: String
3031
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3032

    
3033
inststRunning :: String
3034
inststRunning = Types.instanceStatusToRaw Running
3035

    
3036
inststUserdown :: String
3037
inststUserdown = Types.instanceStatusToRaw UserDown
3038

    
3039
inststWrongnode :: String
3040
inststWrongnode = Types.instanceStatusToRaw WrongNode
3041

    
3042
inststAll :: FrozenSet String
3043
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3044

    
3045
-- * Admin states
3046

    
3047
adminstDown :: String
3048
adminstDown = Types.adminStateToRaw AdminDown
3049

    
3050
adminstOffline :: String
3051
adminstOffline = Types.adminStateToRaw AdminOffline
3052

    
3053
adminstUp :: String
3054
adminstUp = Types.adminStateToRaw AdminUp
3055

    
3056
adminstAll :: FrozenSet String
3057
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3058

    
3059
-- * Node roles
3060

    
3061
nrDrained :: String
3062
nrDrained = Types.nodeRoleToRaw NRDrained
3063

    
3064
nrMaster :: String
3065
nrMaster = Types.nodeRoleToRaw NRMaster
3066

    
3067
nrMcandidate :: String
3068
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3069

    
3070
nrOffline :: String
3071
nrOffline = Types.nodeRoleToRaw NROffline
3072

    
3073
nrRegular :: String
3074
nrRegular = Types.nodeRoleToRaw NRRegular
3075

    
3076
nrAll :: FrozenSet String
3077
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3078

    
3079
-- * SSL certificate check constants (in days)
3080

    
3081
sslCertExpirationError :: Int
3082
sslCertExpirationError = 7
3083

    
3084
sslCertExpirationWarn :: Int
3085
sslCertExpirationWarn = 30
3086

    
3087
-- * Allocator framework constants
3088

    
3089
iallocatorVersion :: Int
3090
iallocatorVersion = 2
3091

    
3092
iallocatorDirIn :: String
3093
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3094

    
3095
iallocatorDirOut :: String
3096
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3097

    
3098
validIallocatorDirections :: FrozenSet String
3099
validIallocatorDirections =
3100
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3101

    
3102
iallocatorModeAlloc :: String
3103
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3104

    
3105
iallocatorModeChgGroup :: String
3106
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3107

    
3108
iallocatorModeMultiAlloc :: String
3109
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3110

    
3111
iallocatorModeNodeEvac :: String
3112
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3113

    
3114
iallocatorModeReloc :: String
3115
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3116

    
3117
validIallocatorModes :: FrozenSet String
3118
validIallocatorModes =
3119
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3120

    
3121
iallocatorSearchPath :: [String]
3122
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3123

    
3124
defaultIallocatorShortcut :: String
3125
defaultIallocatorShortcut = "."
3126

    
3127
-- * Node evacuation
3128

    
3129
nodeEvacPri :: String
3130
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3131

    
3132
nodeEvacSec :: String
3133
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3134

    
3135
nodeEvacAll :: String
3136
nodeEvacAll = Types.evacModeToRaw ChangeAll
3137

    
3138
nodeEvacModes :: FrozenSet String
3139
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3140

    
3141
-- * Job queue
3142

    
3143
jobQueueVersion :: Int
3144
jobQueueVersion = 1
3145

    
3146
jobQueueSizeHardLimit :: Int
3147
jobQueueSizeHardLimit = 5000
3148

    
3149
jobQueueFilesPerms :: Int
3150
jobQueueFilesPerms = 0o640
3151

    
3152
-- * Unchanged job return
3153

    
3154
jobNotchanged :: String
3155
jobNotchanged = "nochange"
3156

    
3157
-- * Job status
3158

    
3159
jobStatusQueued :: String
3160
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3161

    
3162
jobStatusWaiting :: String
3163
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3164

    
3165
jobStatusCanceling :: String
3166
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3167

    
3168
jobStatusRunning :: String
3169
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3170

    
3171
jobStatusCanceled :: String
3172
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3173

    
3174
jobStatusSuccess :: String
3175
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3176

    
3177
jobStatusError :: String
3178
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3179

    
3180
jobsPending :: FrozenSet String
3181
jobsPending =
3182
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3183

    
3184
jobsFinalized :: FrozenSet String
3185
jobsFinalized =
3186
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3187

    
3188
jobStatusAll :: FrozenSet String
3189
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3190

    
3191
-- * OpCode status
3192

    
3193
-- ** Not yet finalized opcodes
3194

    
3195
opStatusCanceling :: String
3196
opStatusCanceling = "canceling"
3197

    
3198
opStatusQueued :: String
3199
opStatusQueued = "queued"
3200

    
3201
opStatusRunning :: String
3202
opStatusRunning = "running"
3203

    
3204
opStatusWaiting :: String
3205
opStatusWaiting = "waiting"
3206

    
3207
-- ** Finalized opcodes
3208

    
3209
opStatusCanceled :: String
3210
opStatusCanceled = "canceled"
3211

    
3212
opStatusError :: String
3213
opStatusError = "error"
3214

    
3215
opStatusSuccess :: String
3216
opStatusSuccess = "success"
3217

    
3218
opsFinalized :: FrozenSet String
3219
opsFinalized =
3220
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3221

    
3222
-- * OpCode priority
3223

    
3224
opPrioLowest :: Int
3225
opPrioLowest = 19
3226

    
3227
opPrioHighest :: Int
3228
opPrioHighest = -20
3229

    
3230
opPrioLow :: Int
3231
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3232

    
3233
opPrioNormal :: Int
3234
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3235

    
3236
opPrioHigh :: Int
3237
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3238

    
3239
opPrioSubmitValid :: FrozenSet Int
3240
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3241

    
3242
opPrioDefault :: Int
3243
opPrioDefault = opPrioNormal
3244

    
3245
-- * Lock recalculate mode
3246

    
3247
locksAppend :: String
3248
locksAppend = "append"
3249

    
3250
locksReplace :: String
3251
locksReplace = "replace"
3252

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

    
3260
lockAttemptsMaxwait :: Double
3261
lockAttemptsMaxwait = 15.0
3262

    
3263
lockAttemptsMinwait :: Double
3264
lockAttemptsMinwait = 1.0
3265

    
3266
lockAttemptsTimeout :: Int
3267
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3268

    
3269
-- * Execution log types
3270

    
3271
elogMessage :: String
3272
elogMessage = Types.eLogTypeToRaw ELogMessage
3273

    
3274
elogRemoteImport :: String
3275
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3276

    
3277
elogJqueueTest :: String
3278
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3279

    
3280
-- * /etc/hosts modification
3281

    
3282
etcHostsAdd :: String
3283
etcHostsAdd = "add"
3284

    
3285
etcHostsRemove :: String
3286
etcHostsRemove = "remove"
3287

    
3288
-- * Job queue test
3289

    
3290
jqtMsgprefix :: String
3291
jqtMsgprefix = "TESTMSG="
3292

    
3293
jqtExec :: String
3294
jqtExec = "exec"
3295

    
3296
jqtExpandnames :: String
3297
jqtExpandnames = "expandnames"
3298

    
3299
jqtLogmsg :: String
3300
jqtLogmsg = "logmsg"
3301

    
3302
jqtStartmsg :: String
3303
jqtStartmsg = "startmsg"
3304

    
3305
jqtAll :: FrozenSet String
3306
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3307

    
3308
-- * Query resources
3309

    
3310
qrCluster :: String
3311
qrCluster = "cluster"
3312

    
3313
qrExport :: String
3314
qrExport = "export"
3315

    
3316
qrExtstorage :: String
3317
qrExtstorage = "extstorage"
3318

    
3319
qrGroup :: String
3320
qrGroup = "group"
3321

    
3322
qrInstance :: String
3323
qrInstance = "instance"
3324

    
3325
qrJob :: String
3326
qrJob = "job"
3327

    
3328
qrLock :: String
3329
qrLock = "lock"
3330

    
3331
qrNetwork :: String
3332
qrNetwork = "network"
3333

    
3334
qrNode :: String
3335
qrNode = "node"
3336

    
3337
qrOs :: String
3338
qrOs = "os"
3339

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

    
3352
-- | List of resources which can be queried using Local UniX Interface
3353
qrViaLuxi :: FrozenSet String
3354
qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob]
3355

    
3356
-- | List of resources which can be queried using RAPI
3357
qrViaRapi :: FrozenSet String
3358
qrViaRapi = qrViaLuxi
3359

    
3360
-- * Query field types
3361

    
3362
qftBool :: String
3363
qftBool = "bool"
3364

    
3365
qftNumber :: String
3366
qftNumber = "number"
3367

    
3368
qftOther :: String
3369
qftOther = "other"
3370

    
3371
qftText :: String
3372
qftText = "text"
3373

    
3374
qftTimestamp :: String
3375
qftTimestamp = "timestamp"
3376

    
3377
qftUnit :: String
3378
qftUnit = "unit"
3379

    
3380
qftUnknown :: String
3381
qftUnknown = "unknown"
3382

    
3383
qftAll :: FrozenSet String
3384
qftAll =
3385
  ConstantUtils.mkSet [qftBool,
3386
                       qftNumber,
3387
                       qftOther,
3388
                       qftText,
3389
                       qftTimestamp,
3390
                       qftUnit,
3391
                       qftUnknown]
3392

    
3393
-- * Query result field status
3394
--
3395
-- Don't change or reuse values as they're used by clients.
3396
--
3397
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3398

    
3399
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3400
rsNodata :: Int
3401
rsNodata = 2
3402

    
3403
rsNormal :: Int
3404
rsNormal = 0
3405

    
3406
-- | Resource marked offline
3407
rsOffline :: Int
3408
rsOffline = 4
3409

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

    
3416
rsUnknown :: Int
3417
rsUnknown = 1
3418

    
3419
rsAll :: FrozenSet Int
3420
rsAll =
3421
  ConstantUtils.mkSet [rsNodata,
3422
                       rsNormal,
3423
                       rsOffline,
3424
                       rsUnavail,
3425
                       rsUnknown]
3426

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

    
3435
-- * Max dynamic devices
3436

    
3437
maxDisks :: Int
3438
maxDisks = Types.maxDisks
3439

    
3440
maxNics :: Int
3441
maxNics = Types.maxNics
3442

    
3443
-- | SSCONF file prefix
3444
ssconfFileprefix :: String
3445
ssconfFileprefix = "ssconf_"
3446

    
3447
-- * SSCONF keys
3448

    
3449
ssClusterName :: String
3450
ssClusterName = "cluster_name"
3451

    
3452
ssClusterTags :: String
3453
ssClusterTags = "cluster_tags"
3454

    
3455
ssFileStorageDir :: String
3456
ssFileStorageDir = "file_storage_dir"
3457

    
3458
ssSharedFileStorageDir :: String
3459
ssSharedFileStorageDir = "shared_file_storage_dir"
3460

    
3461
ssMasterCandidates :: String
3462
ssMasterCandidates = "master_candidates"
3463

    
3464
ssMasterCandidatesIps :: String
3465
ssMasterCandidatesIps = "master_candidates_ips"
3466

    
3467
ssMasterIp :: String
3468
ssMasterIp = "master_ip"
3469

    
3470
ssMasterNetdev :: String
3471
ssMasterNetdev = "master_netdev"
3472

    
3473
ssMasterNetmask :: String
3474
ssMasterNetmask = "master_netmask"
3475

    
3476
ssMasterNode :: String
3477
ssMasterNode = "master_node"
3478

    
3479
ssNodeList :: String
3480
ssNodeList = "node_list"
3481

    
3482
ssNodePrimaryIps :: String
3483
ssNodePrimaryIps = "node_primary_ips"
3484

    
3485
ssNodeSecondaryIps :: String
3486
ssNodeSecondaryIps = "node_secondary_ips"
3487

    
3488
ssOfflineNodes :: String
3489
ssOfflineNodes = "offline_nodes"
3490

    
3491
ssOnlineNodes :: String
3492
ssOnlineNodes = "online_nodes"
3493

    
3494
ssPrimaryIpFamily :: String
3495
ssPrimaryIpFamily = "primary_ip_family"
3496

    
3497
ssInstanceList :: String
3498
ssInstanceList = "instance_list"
3499

    
3500
ssReleaseVersion :: String
3501
ssReleaseVersion = "release_version"
3502

    
3503
ssHypervisorList :: String
3504
ssHypervisorList = "hypervisor_list"
3505

    
3506
ssMaintainNodeHealth :: String
3507
ssMaintainNodeHealth = "maintain_node_health"
3508

    
3509
ssUidPool :: String
3510
ssUidPool = "uid_pool"
3511

    
3512
ssNodegroups :: String
3513
ssNodegroups = "nodegroups"
3514

    
3515
ssNetworks :: String
3516
ssNetworks = "networks"
3517

    
3518
-- | This is not a complete SSCONF key, but the prefix for the
3519
-- hypervisor keys
3520
ssHvparamsPref :: String
3521
ssHvparamsPref = "hvparams_"
3522

    
3523
-- * Hvparams keys
3524

    
3525
ssHvparamsXenChroot :: String
3526
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3527

    
3528
ssHvparamsXenFake :: String
3529
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3530

    
3531
ssHvparamsXenHvm :: String
3532
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3533

    
3534
ssHvparamsXenKvm :: String
3535
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3536

    
3537
ssHvparamsXenLxc :: String
3538
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3539

    
3540
ssHvparamsXenPvm :: String
3541
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3542

    
3543
validSsHvparamsKeys :: FrozenSet String
3544
validSsHvparamsKeys =
3545
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3546
                       ssHvparamsXenLxc,
3547
                       ssHvparamsXenFake,
3548
                       ssHvparamsXenHvm,
3549
                       ssHvparamsXenKvm,
3550
                       ssHvparamsXenPvm]
3551

    
3552
ssFilePerms :: Int
3553
ssFilePerms = 0o444
3554

    
3555
-- | Cluster wide default parameters
3556
defaultEnabledHypervisor :: String
3557
defaultEnabledHypervisor = htXenPvm
3558

    
3559
hvcDefaults :: Map Hypervisor (Map String PyValueEx)
3560
hvcDefaults =
3561
  Map.fromList
3562
  [ (XenPvm, Map.fromList
3563
             [ (hvUseBootloader,  PyValueEx False)
3564
             , (hvBootloaderPath, PyValueEx xenBootloader)
3565
             , (hvBootloaderArgs, PyValueEx "")
3566
             , (hvKernelPath,     PyValueEx xenKernel)
3567
             , (hvInitrdPath,     PyValueEx "")
3568
             , (hvRootPath,       PyValueEx "/dev/xvda1")
3569
             , (hvKernelArgs,     PyValueEx "ro")
3570
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3571
             , (hvMigrationMode,  PyValueEx htMigrationLive)
3572
             , (hvBlockdevPrefix, PyValueEx "sd")
3573
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3574
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3575
             , (hvCpuCap,         PyValueEx (0 :: Int))
3576
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3577
             , (hvVifScript,      PyValueEx "")
3578
             , (hvXenCmd,         PyValueEx xenCmdXm)
3579
             , (hvXenCpuid,       PyValueEx "")
3580
             , (hvSoundhw,        PyValueEx "")
3581
             ])
3582
  , (XenHvm, Map.fromList
3583
             [ (hvBootOrder,      PyValueEx "cd")
3584
             , (hvCdromImagePath, PyValueEx "")
3585
             , (hvNicType,        PyValueEx htNicRtl8139)
3586
             , (hvDiskType,       PyValueEx htDiskParavirtual)
3587
             , (hvVncBindAddress, PyValueEx ip4AddressAny)
3588
             , (hvAcpi,           PyValueEx True)
3589
             , (hvPae,            PyValueEx True)
3590
             , (hvKernelPath,     PyValueEx "/usr/lib/xen/boot/hvmloader")
3591
             , (hvDeviceModel,    PyValueEx "/usr/lib/xen/bin/qemu-dm")
3592
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3593
             , (hvMigrationMode,  PyValueEx htMigrationNonlive)
3594
             , (hvUseLocaltime,   PyValueEx False)
3595
             , (hvBlockdevPrefix, PyValueEx "hd")
3596
             , (hvPassthrough,    PyValueEx "")
3597
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3598
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3599
             , (hvCpuCap,         PyValueEx (0 :: Int))
3600
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3601
             , (hvVifType,        PyValueEx htHvmVifIoemu)
3602
             , (hvVifScript,      PyValueEx "")
3603
             , (hvViridian,       PyValueEx False)
3604
             , (hvXenCmd,         PyValueEx xenCmdXm)
3605
             , (hvXenCpuid,       PyValueEx "")
3606
             , (hvSoundhw,        PyValueEx "")
3607
             ])
3608
  , (Kvm, Map.fromList
3609
          [ (hvKvmPath,                         PyValueEx kvmPath)
3610
          , (hvKernelPath,                      PyValueEx kvmKernel)
3611
          , (hvInitrdPath,                      PyValueEx "")
3612
          , (hvKernelArgs,                      PyValueEx "ro")
3613
          , (hvRootPath,                        PyValueEx "/dev/vda1")
3614
          , (hvAcpi,                            PyValueEx True)
3615
          , (hvSerialConsole,                   PyValueEx True)
3616
          , (hvSerialSpeed,                     PyValueEx (38400 :: Int))
3617
          , (hvVncBindAddress,                  PyValueEx "")
3618
          , (hvVncTls,                          PyValueEx False)
3619
          , (hvVncX509,                         PyValueEx "")
3620
          , (hvVncX509Verify,                   PyValueEx False)
3621
          , (hvVncPasswordFile,                 PyValueEx "")
3622
          , (hvKvmSpiceBind,                    PyValueEx "")
3623
          , (hvKvmSpiceIpVersion,           PyValueEx ifaceNoIpVersionSpecified)
3624
          , (hvKvmSpicePasswordFile,            PyValueEx "")
3625
          , (hvKvmSpiceLosslessImgCompr,        PyValueEx "")
3626
          , (hvKvmSpiceJpegImgCompr,            PyValueEx "")
3627
          , (hvKvmSpiceZlibGlzImgCompr,         PyValueEx "")
3628
          , (hvKvmSpiceStreamingVideoDetection, PyValueEx "")
3629
          , (hvKvmSpiceAudioCompr,              PyValueEx True)
3630
          , (hvKvmSpiceUseTls,                  PyValueEx False)
3631
          , (hvKvmSpiceTlsCiphers,              PyValueEx opensslCiphers)
3632
          , (hvKvmSpiceUseVdagent,              PyValueEx True)
3633
          , (hvKvmFloppyImagePath,              PyValueEx "")
3634
          , (hvCdromImagePath,                  PyValueEx "")
3635
          , (hvKvmCdrom2ImagePath,              PyValueEx "")
3636
          , (hvBootOrder,                       PyValueEx htBoDisk)
3637
          , (hvNicType,                         PyValueEx htNicParavirtual)
3638
          , (hvDiskType,                        PyValueEx htDiskParavirtual)
3639
          , (hvKvmCdromDiskType,                PyValueEx "")
3640
          , (hvUsbMouse,                        PyValueEx "")
3641
          , (hvKeymap,                          PyValueEx "")
3642
          , (hvMigrationPort,                   PyValueEx (8102 :: Int))
3643
          , (hvMigrationBandwidth,              PyValueEx (32 :: Int))
3644
          , (hvMigrationDowntime,               PyValueEx (30 :: Int))
3645
          , (hvMigrationMode,                   PyValueEx htMigrationLive)
3646
          , (hvUseLocaltime,                    PyValueEx False)
3647
          , (hvDiskCache,                       PyValueEx htCacheDefault)
3648
          , (hvSecurityModel,                   PyValueEx htSmNone)
3649
          , (hvSecurityDomain,                  PyValueEx "")
3650
          , (hvKvmFlag,                         PyValueEx "")
3651
          , (hvVhostNet,                        PyValueEx False)
3652
          , (hvKvmUseChroot,                    PyValueEx False)
3653
          , (hvMemPath,                         PyValueEx "")
3654
          , (hvRebootBehavior,                  PyValueEx instanceRebootAllowed)
3655
          , (hvCpuMask,                         PyValueEx cpuPinningAll)
3656
          , (hvCpuType,                         PyValueEx "")
3657
          , (hvCpuCores,                        PyValueEx (0 :: Int))
3658
          , (hvCpuThreads,                      PyValueEx (0 :: Int))
3659
          , (hvCpuSockets,                      PyValueEx (0 :: Int))
3660
          , (hvSoundhw,                         PyValueEx "")
3661
          , (hvUsbDevices,                      PyValueEx "")
3662
          , (hvVga,                             PyValueEx "")
3663
          , (hvKvmExtra,                        PyValueEx "")
3664
          , (hvKvmMachineVersion,               PyValueEx "")
3665
          , (hvVnetHdr,                         PyValueEx True)])
3666
  , (Fake, Map.fromList [(hvMigrationMode, PyValueEx htMigrationLive)])
3667
  , (Chroot, Map.fromList [(hvInitScript, PyValueEx "/ganeti-chroot")])
3668
  , (Lxc, Map.fromList [(hvCpuMask, PyValueEx "")])
3669
  ]
3670

    
3671
hvcGlobals :: FrozenSet String
3672
hvcGlobals =
3673
  ConstantUtils.mkSet [hvMigrationBandwidth,
3674
                       hvMigrationMode,
3675
                       hvMigrationPort,
3676
                       hvXenCmd]
3677

    
3678
becDefaults :: Map String PyValueEx
3679
becDefaults =
3680
  Map.fromList
3681
  [ (beMinmem, PyValueEx (128 :: Int))
3682
  , (beMaxmem, PyValueEx (128 :: Int))
3683
  , (beVcpus, PyValueEx (1 :: Int))
3684
  , (beAutoBalance, PyValueEx True)
3685
  , (beAlwaysFailover, PyValueEx False)
3686
  , (beSpindleUse, PyValueEx (1 :: Int))
3687
  ]
3688

    
3689
ndcDefaults :: Map String PyValueEx
3690
ndcDefaults =
3691
  Map.fromList
3692
  [ (ndOobProgram,       PyValueEx "")
3693
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3694
  , (ndExclusiveStorage, PyValueEx False)
3695
  , (ndOvs,              PyValueEx False)
3696
  , (ndOvsName,          PyValueEx defaultOvs)
3697
  , (ndOvsLink,          PyValueEx "")
3698
  ]
3699

    
3700
ndcGlobals :: FrozenSet String
3701
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3702

    
3703
-- | Default delay target measured in sectors
3704
defaultDelayTarget :: Int
3705
defaultDelayTarget = 1
3706

    
3707
defaultDiskCustom :: String
3708
defaultDiskCustom = ""
3709

    
3710
defaultDiskResync :: Bool
3711
defaultDiskResync = False
3712

    
3713
-- | Default fill target measured in sectors
3714
defaultFillTarget :: Int
3715
defaultFillTarget = 0
3716

    
3717
-- | Default mininum rate measured in KiB/s
3718
defaultMinRate :: Int
3719
defaultMinRate = 4 * 1024
3720

    
3721
defaultNetCustom :: String
3722
defaultNetCustom = ""
3723

    
3724
-- | Default plan ahead measured in sectors
3725
--
3726
-- The default values for the DRBD dynamic resync speed algorithm are
3727
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3728
-- (that we don't need to set to 0, because we have a separate option
3729
-- to enable it) and for c-max-rate, that we cap to the default value
3730
-- for the static resync rate.
3731
defaultPlanAhead :: Int
3732
defaultPlanAhead = 20
3733

    
3734
defaultRbdPool :: String
3735
defaultRbdPool = "rbd"
3736

    
3737
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3738
diskLdDefaults =
3739
  Map.fromList
3740
  [ (DTBlock, Map.empty)
3741
  , (DTDrbd8, Map.fromList
3742
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3743
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3744
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3745
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3746
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3747
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3748
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3749
              , (ldpMinRate,       PyValueEx defaultMinRate)
3750
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3751
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3752
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3753
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3754
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3755
              ])
3756
  , (DTExt, Map.empty)
3757
  , (DTFile, Map.empty)
3758
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3759
  , (DTRbd, Map.fromList
3760
            [ (ldpPool, PyValueEx defaultRbdPool)
3761
            , (ldpAccess, PyValueEx diskKernelspace)
3762
            ])
3763
  , (DTSharedFile, Map.empty)
3764
  ]
3765

    
3766
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3767
diskDtDefaults =
3768
  Map.fromList
3769
  [ (DTBlock,      Map.empty)
3770
  , (DTDiskless,   Map.empty)
3771
  , (DTDrbd8,      Map.fromList
3772
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3773
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3774
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3775
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3776
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3777
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3778
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3779
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3780
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3781
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3782
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3783
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3784
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3785
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3786
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3787
                   ])
3788
  , (DTExt,        Map.empty)
3789
  , (DTFile,       Map.empty)
3790
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3791
  , (DTRbd,        Map.fromList
3792
                   [ (rbdPool, PyValueEx defaultRbdPool)
3793
                   , (rbdAccess, PyValueEx diskKernelspace)
3794
                   ])
3795
  , (DTSharedFile, Map.empty)
3796
  ]
3797

    
3798
niccDefaults :: Map String PyValueEx
3799
niccDefaults =
3800
  Map.fromList
3801
  [ (nicMode, PyValueEx nicModeBridged)
3802
  , (nicLink, PyValueEx defaultBridge)
3803
  , (nicVlan, PyValueEx valueHsNothing)
3804
  ]
3805

    
3806
-- | All of the following values are quite arbitrary - there are no
3807
-- "good" defaults, these must be customised per-site
3808
ispecsMinmaxDefaults :: Map String (Map String Int)
3809
ispecsMinmaxDefaults =
3810
  Map.fromList
3811
  [(ispecsMin,
3812
    Map.fromList
3813
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3814
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3815
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3816
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3817
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3818
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3819
   (ispecsMax,
3820
    Map.fromList
3821
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3822
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3823
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3824
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3825
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3826
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3827

    
3828
ipolicyDefaults :: Map String PyValueEx
3829
ipolicyDefaults =
3830
  Map.fromList
3831
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3832
  , (ispecsStd,           PyValueEx (Map.fromList
3833
                                     [ (ispecMemSize,    128)
3834
                                     , (ispecCpuCount,   1)
3835
                                     , (ispecDiskCount,  1)
3836
                                     , (ispecDiskSize,   1024)
3837
                                     , (ispecNicCount,   1)
3838
                                     , (ispecSpindleUse, 1)
3839
                                     ] :: Map String Int))
3840
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3841
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3842
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3843
  ]
3844

    
3845
masterPoolSizeDefault :: Int
3846
masterPoolSizeDefault = 10
3847

    
3848
-- * Exclusive storage
3849

    
3850
-- | Error margin used to compare physical disks
3851
partMargin :: Double
3852
partMargin = 0.01
3853

    
3854
-- | Space reserved when creating instance disks
3855
partReserved :: Double
3856
partReserved = 0.02
3857

    
3858
-- * Confd
3859

    
3860
confdProtocolVersion :: Int
3861
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3862

    
3863
-- Confd request type
3864

    
3865
confdReqPing :: Int
3866
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3867

    
3868
confdReqNodeRoleByname :: Int
3869
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3870

    
3871
confdReqNodePipByInstanceIp :: Int
3872
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3873

    
3874
confdReqClusterMaster :: Int
3875
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3876

    
3877
confdReqNodePipList :: Int
3878
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3879

    
3880
confdReqMcPipList :: Int
3881
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3882

    
3883
confdReqInstancesIpsList :: Int
3884
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3885

    
3886
confdReqNodeDrbd :: Int
3887
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3888

    
3889
confdReqNodeInstances :: Int
3890
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3891

    
3892
confdReqs :: FrozenSet Int
3893
confdReqs =
3894
  ConstantUtils.mkSet .
3895
  map Types.confdRequestTypeToRaw $
3896
  [minBound..] \\ [ReqNodeInstances]
3897

    
3898
-- * Confd request type
3899

    
3900
confdReqfieldName :: Int
3901
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3902

    
3903
confdReqfieldIp :: Int
3904
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3905

    
3906
confdReqfieldMnodePip :: Int
3907
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3908

    
3909
-- * Confd repl status
3910

    
3911
confdReplStatusOk :: Int
3912
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3913

    
3914
confdReplStatusError :: Int
3915
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3916

    
3917
confdReplStatusNotimplemented :: Int
3918
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3919

    
3920
confdReplStatuses :: FrozenSet Int
3921
confdReplStatuses =
3922
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3923

    
3924
-- * Confd node role
3925

    
3926
confdNodeRoleMaster :: Int
3927
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3928

    
3929
confdNodeRoleCandidate :: Int
3930
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3931

    
3932
confdNodeRoleOffline :: Int
3933
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3934

    
3935
confdNodeRoleDrained :: Int
3936
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3937

    
3938
confdNodeRoleRegular :: Int
3939
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3940

    
3941
-- * A few common errors for confd
3942

    
3943
confdErrorUnknownEntry :: Int
3944
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3945

    
3946
confdErrorInternal :: Int
3947
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3948

    
3949
confdErrorArgument :: Int
3950
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3951

    
3952
-- * Confd request query fields
3953

    
3954
confdReqqLink :: String
3955
confdReqqLink = ConstantUtils.confdReqqLink
3956

    
3957
confdReqqIp :: String
3958
confdReqqIp = ConstantUtils.confdReqqIp
3959

    
3960
confdReqqIplist :: String
3961
confdReqqIplist = ConstantUtils.confdReqqIplist
3962

    
3963
confdReqqFields :: String
3964
confdReqqFields = ConstantUtils.confdReqqFields
3965

    
3966
-- | Each request is "salted" by the current timestamp.
3967
--
3968
-- This constant decides how many seconds of skew to accept.
3969
--
3970
-- TODO: make this a default and allow the value to be more
3971
-- configurable
3972
confdMaxClockSkew :: Int
3973
confdMaxClockSkew = 2 * nodeMaxClockSkew
3974

    
3975
-- | When we haven't reloaded the config for more than this amount of
3976
-- seconds, we force a test to see if inotify is betraying us. Using a
3977
-- prime number to ensure we get less chance of 'same wakeup' with
3978
-- other processes.
3979
confdConfigReloadTimeout :: Int
3980
confdConfigReloadTimeout = 17
3981

    
3982
-- | If we receive more than one update in this amount of
3983
-- microseconds, we move to polling every RATELIMIT seconds, rather
3984
-- than relying on inotify, to be able to serve more requests.
3985
confdConfigReloadRatelimit :: Int
3986
confdConfigReloadRatelimit = 250000
3987

    
3988
-- | Magic number prepended to all confd queries.
3989
--
3990
-- This allows us to distinguish different types of confd protocols
3991
-- and handle them. For example by changing this we can move the whole
3992
-- payload to be compressed, or move away from json.
3993
confdMagicFourcc :: String
3994
confdMagicFourcc = "plj0"
3995

    
3996
-- | By default a confd request is sent to the minimum between this
3997
-- number and all MCs. 6 was chosen because even in the case of a
3998
-- disastrous 50% response rate, we should have enough answers to be
3999
-- able to compare more than one.
4000
confdDefaultReqCoverage :: Int
4001
confdDefaultReqCoverage = 6
4002

    
4003
-- | Timeout in seconds to expire pending query request in the confd
4004
-- client library. We don't actually expect any answer more than 10
4005
-- seconds after we sent a request.
4006
confdClientExpireTimeout :: Int
4007
confdClientExpireTimeout = 10
4008

    
4009
-- | Maximum UDP datagram size.
4010
--
4011
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4012
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4013
--   (assuming we can't use jumbo frames)
4014
-- We just set this to 60K, which should be enough
4015
maxUdpDataSize :: Int
4016
maxUdpDataSize = 61440
4017

    
4018
-- * User-id pool minimum/maximum acceptable user-ids
4019

    
4020
uidpoolUidMin :: Int
4021
uidpoolUidMin = 0
4022

    
4023
-- | Assuming 32 bit user-ids
4024
uidpoolUidMax :: Integer
4025
uidpoolUidMax = 2 ^ 32 - 1
4026

    
4027
-- | Name or path of the pgrep command
4028
pgrep :: String
4029
pgrep = "pgrep"
4030

    
4031
-- | Name of the node group that gets created at cluster init or
4032
-- upgrade
4033
initialNodeGroupName :: String
4034
initialNodeGroupName = "default"
4035

    
4036
-- * Possible values for NodeGroup.alloc_policy
4037

    
4038
allocPolicyLastResort :: String
4039
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4040

    
4041
allocPolicyPreferred :: String
4042
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4043

    
4044
allocPolicyUnallocable :: String
4045
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4046

    
4047
validAllocPolicies :: [String]
4048
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4049

    
4050
-- | Temporary external/shared storage parameters
4051
blockdevDriverManual :: String
4052
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4053

    
4054
-- | 'qemu-img' path, required for 'ovfconverter'
4055
qemuimgPath :: String
4056
qemuimgPath = AutoConf.qemuimgPath
4057

    
4058
-- | Whether htools was enabled at compilation time
4059
--
4060
-- FIXME: this should be moved next to the other enable constants,
4061
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4062
htools :: Bool
4063
htools = AutoConf.htools
4064

    
4065
-- | The hail iallocator
4066
iallocHail :: String
4067
iallocHail = "hail"
4068

    
4069
-- * Fake opcodes for functions that have hooks attached to them via
4070
-- backend.RunLocalHooks
4071

    
4072
fakeOpMasterTurndown :: String
4073
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4074

    
4075
fakeOpMasterTurnup :: String
4076
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4077

    
4078
-- * SSH key types
4079

    
4080
sshkDsa :: String
4081
sshkDsa = "dsa"
4082

    
4083
sshkRsa :: String
4084
sshkRsa = "rsa"
4085

    
4086
sshkAll :: FrozenSet String
4087
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4088

    
4089
-- * SSH authorized key types
4090

    
4091
sshakDss :: String
4092
sshakDss = "ssh-dss"
4093

    
4094
sshakRsa :: String
4095
sshakRsa = "ssh-rsa"
4096

    
4097
sshakAll :: FrozenSet String
4098
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4099

    
4100
-- * SSH setup
4101

    
4102
sshsClusterName :: String
4103
sshsClusterName = "cluster_name"
4104

    
4105
sshsSshHostKey :: String
4106
sshsSshHostKey = "ssh_host_key"
4107

    
4108
sshsSshRootKey :: String
4109
sshsSshRootKey = "ssh_root_key"
4110

    
4111
sshsNodeDaemonCertificate :: String
4112
sshsNodeDaemonCertificate = "node_daemon_certificate"
4113

    
4114
-- * Key files for SSH daemon
4115

    
4116
sshHostDsaPriv :: String
4117
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4118

    
4119
sshHostDsaPub :: String
4120
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4121

    
4122
sshHostRsaPriv :: String
4123
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4124

    
4125
sshHostRsaPub :: String
4126
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4127

    
4128
sshDaemonKeyfiles :: Map String (String, String)
4129
sshDaemonKeyfiles =
4130
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4131
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4132
               ]
4133

    
4134
-- * Node daemon setup
4135

    
4136
ndsClusterName :: String
4137
ndsClusterName = "cluster_name"
4138

    
4139
ndsNodeDaemonCertificate :: String
4140
ndsNodeDaemonCertificate = "node_daemon_certificate"
4141

    
4142
ndsSsconf :: String
4143
ndsSsconf = "ssconf"
4144

    
4145
ndsStartNodeDaemon :: String
4146
ndsStartNodeDaemon = "start_node_daemon"
4147

    
4148
-- * The source reasons for the execution of an OpCode
4149

    
4150
opcodeReasonSrcClient :: String
4151
opcodeReasonSrcClient = "gnt:client"
4152

    
4153
opcodeReasonSrcNoded :: String
4154
opcodeReasonSrcNoded = "gnt:daemon:noded"
4155

    
4156
opcodeReasonSrcOpcode :: String
4157
opcodeReasonSrcOpcode = "gnt:opcode"
4158

    
4159
opcodeReasonSrcRlib2 :: String
4160
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4161

    
4162
opcodeReasonSrcUser :: String
4163
opcodeReasonSrcUser = "gnt:user"
4164

    
4165
opcodeReasonSources :: FrozenSet String
4166
opcodeReasonSources =
4167
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4168
                       opcodeReasonSrcNoded,
4169
                       opcodeReasonSrcOpcode,
4170
                       opcodeReasonSrcRlib2,
4171
                       opcodeReasonSrcUser]
4172

    
4173
-- | Path generating random UUID
4174
randomUuidFile :: String
4175
randomUuidFile = ConstantUtils.randomUuidFile
4176

    
4177
-- * Auto-repair tag prefixes
4178

    
4179
autoRepairTagPrefix :: String
4180
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4181

    
4182
autoRepairTagEnabled :: String
4183
autoRepairTagEnabled = autoRepairTagPrefix
4184

    
4185
autoRepairTagPending :: String
4186
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4187

    
4188
autoRepairTagResult :: String
4189
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4190

    
4191
autoRepairTagSuspended :: String
4192
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4193

    
4194
-- * Auto-repair levels
4195

    
4196
autoRepairFailover :: String
4197
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4198

    
4199
autoRepairFixStorage :: String
4200
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4201

    
4202
autoRepairMigrate :: String
4203
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4204

    
4205
autoRepairReinstall :: String
4206
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4207

    
4208
autoRepairAllTypes :: FrozenSet String
4209
autoRepairAllTypes =
4210
  ConstantUtils.mkSet [autoRepairFailover,
4211
                       autoRepairFixStorage,
4212
                       autoRepairMigrate,
4213
                       autoRepairReinstall]
4214

    
4215
-- * Auto-repair results
4216

    
4217
autoRepairEnoperm :: String
4218
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4219

    
4220
autoRepairFailure :: String
4221
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4222

    
4223
autoRepairSuccess :: String
4224
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4225

    
4226
autoRepairAllResults :: FrozenSet String
4227
autoRepairAllResults =
4228
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4229

    
4230
-- | The version identifier for builtin data collectors
4231
builtinDataCollectorVersion :: String
4232
builtinDataCollectorVersion = "B"
4233

    
4234
-- | The reason trail opcode parameter name
4235
opcodeReason :: String
4236
opcodeReason = "reason"
4237

    
4238
diskstatsFile :: String
4239
diskstatsFile = "/proc/diskstats"
4240

    
4241
-- *  CPU load collector
4242

    
4243
statFile :: String
4244
statFile = "/proc/stat"
4245

    
4246
cpuavgloadBufferSize :: Int
4247
cpuavgloadBufferSize = 150
4248

    
4249
cpuavgloadWindowSize :: Int
4250
cpuavgloadWindowSize = 600
4251

    
4252
-- * Monitoring daemon
4253

    
4254
-- | Mond's variable for periodical data collection
4255
mondTimeInterval :: Int
4256
mondTimeInterval = 5
4257

    
4258
-- | Mond's latest API version
4259
mondLatestApiVersion :: Int
4260
mondLatestApiVersion = 1
4261

    
4262
-- * Disk access modes
4263

    
4264
diskUserspace :: String
4265
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4266

    
4267
diskKernelspace :: String
4268
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4269

    
4270
diskValidAccessModes :: FrozenSet String
4271
diskValidAccessModes =
4272
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4273

    
4274
-- | Timeout for queue draining in upgrades
4275
upgradeQueueDrainTimeout :: Int
4276
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4277

    
4278
-- | Intervall at which the queue is polled during upgrades
4279
upgradeQueuePollInterval :: Int
4280
upgradeQueuePollInterval  = 10
4281

    
4282
-- * Hotplug Actions
4283

    
4284
hotplugActionAdd :: String
4285
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4286

    
4287
hotplugActionRemove :: String
4288
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4289

    
4290
hotplugActionModify :: String
4291
hotplugActionModify = Types.hotplugActionToRaw HAMod
4292

    
4293
hotplugAllActions :: FrozenSet String
4294
hotplugAllActions =
4295
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4296

    
4297
-- * Hotplug Device Targets
4298

    
4299
hotplugTargetNic :: String
4300
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4301

    
4302
hotplugTargetDisk :: String
4303
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4304

    
4305
hotplugAllTargets :: FrozenSet String
4306
hotplugAllTargets =
4307
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4308

    
4309
-- | Timeout for disk removal (seconds)
4310
diskRemoveRetryTimeout :: Int
4311
diskRemoveRetryTimeout = 30
4312

    
4313
-- | Interval between disk removal retries (seconds)
4314
diskRemoveRetryInterval :: Int
4315
diskRemoveRetryInterval  = 3