Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ ae858516

History | View | Annotate | Download (108.4 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
inststWrongnode :: String
3037
inststWrongnode = Types.instanceStatusToRaw WrongNode
3038

    
3039
inststAll :: FrozenSet String
3040
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3041

    
3042
-- * Admin states
3043

    
3044
adminstDown :: String
3045
adminstDown = Types.adminStateToRaw AdminDown
3046

    
3047
adminstOffline :: String
3048
adminstOffline = Types.adminStateToRaw AdminOffline
3049

    
3050
adminstUp :: String
3051
adminstUp = Types.adminStateToRaw AdminUp
3052

    
3053
adminstAll :: FrozenSet String
3054
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3055

    
3056
-- * Node roles
3057

    
3058
nrDrained :: String
3059
nrDrained = Types.nodeRoleToRaw NRDrained
3060

    
3061
nrMaster :: String
3062
nrMaster = Types.nodeRoleToRaw NRMaster
3063

    
3064
nrMcandidate :: String
3065
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3066

    
3067
nrOffline :: String
3068
nrOffline = Types.nodeRoleToRaw NROffline
3069

    
3070
nrRegular :: String
3071
nrRegular = Types.nodeRoleToRaw NRRegular
3072

    
3073
nrAll :: FrozenSet String
3074
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3075

    
3076
-- * SSL certificate check constants (in days)
3077

    
3078
sslCertExpirationError :: Int
3079
sslCertExpirationError = 7
3080

    
3081
sslCertExpirationWarn :: Int
3082
sslCertExpirationWarn = 30
3083

    
3084
-- * Allocator framework constants
3085

    
3086
iallocatorVersion :: Int
3087
iallocatorVersion = 2
3088

    
3089
iallocatorDirIn :: String
3090
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3091

    
3092
iallocatorDirOut :: String
3093
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3094

    
3095
validIallocatorDirections :: FrozenSet String
3096
validIallocatorDirections =
3097
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3098

    
3099
iallocatorModeAlloc :: String
3100
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3101

    
3102
iallocatorModeChgGroup :: String
3103
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3104

    
3105
iallocatorModeMultiAlloc :: String
3106
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3107

    
3108
iallocatorModeNodeEvac :: String
3109
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3110

    
3111
iallocatorModeReloc :: String
3112
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3113

    
3114
validIallocatorModes :: FrozenSet String
3115
validIallocatorModes =
3116
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3117

    
3118
iallocatorSearchPath :: [String]
3119
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3120

    
3121
defaultIallocatorShortcut :: String
3122
defaultIallocatorShortcut = "."
3123

    
3124
-- * Node evacuation
3125

    
3126
nodeEvacPri :: String
3127
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3128

    
3129
nodeEvacSec :: String
3130
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3131

    
3132
nodeEvacAll :: String
3133
nodeEvacAll = Types.evacModeToRaw ChangeAll
3134

    
3135
nodeEvacModes :: FrozenSet String
3136
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3137

    
3138
-- * Job queue
3139

    
3140
jobQueueVersion :: Int
3141
jobQueueVersion = 1
3142

    
3143
jobQueueSizeHardLimit :: Int
3144
jobQueueSizeHardLimit = 5000
3145

    
3146
jobQueueFilesPerms :: Int
3147
jobQueueFilesPerms = 0o640
3148

    
3149
-- * Unchanged job return
3150

    
3151
jobNotchanged :: String
3152
jobNotchanged = "nochange"
3153

    
3154
-- * Job status
3155

    
3156
jobStatusQueued :: String
3157
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3158

    
3159
jobStatusWaiting :: String
3160
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3161

    
3162
jobStatusCanceling :: String
3163
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3164

    
3165
jobStatusRunning :: String
3166
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3167

    
3168
jobStatusCanceled :: String
3169
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3170

    
3171
jobStatusSuccess :: String
3172
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3173

    
3174
jobStatusError :: String
3175
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3176

    
3177
jobsPending :: FrozenSet String
3178
jobsPending =
3179
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3180

    
3181
jobsFinalized :: FrozenSet String
3182
jobsFinalized =
3183
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3184

    
3185
jobStatusAll :: FrozenSet String
3186
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3187

    
3188
-- * OpCode status
3189

    
3190
-- ** Not yet finalized opcodes
3191

    
3192
opStatusCanceling :: String
3193
opStatusCanceling = "canceling"
3194

    
3195
opStatusQueued :: String
3196
opStatusQueued = "queued"
3197

    
3198
opStatusRunning :: String
3199
opStatusRunning = "running"
3200

    
3201
opStatusWaiting :: String
3202
opStatusWaiting = "waiting"
3203

    
3204
-- ** Finalized opcodes
3205

    
3206
opStatusCanceled :: String
3207
opStatusCanceled = "canceled"
3208

    
3209
opStatusError :: String
3210
opStatusError = "error"
3211

    
3212
opStatusSuccess :: String
3213
opStatusSuccess = "success"
3214

    
3215
opsFinalized :: FrozenSet String
3216
opsFinalized =
3217
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3218

    
3219
-- * OpCode priority
3220

    
3221
opPrioLowest :: Int
3222
opPrioLowest = 19
3223

    
3224
opPrioHighest :: Int
3225
opPrioHighest = -20
3226

    
3227
opPrioLow :: Int
3228
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3229

    
3230
opPrioNormal :: Int
3231
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3232

    
3233
opPrioHigh :: Int
3234
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3235

    
3236
opPrioSubmitValid :: FrozenSet Int
3237
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3238

    
3239
opPrioDefault :: Int
3240
opPrioDefault = opPrioNormal
3241

    
3242
-- * Lock recalculate mode
3243

    
3244
locksAppend :: String
3245
locksAppend = "append"
3246

    
3247
locksReplace :: String
3248
locksReplace = "replace"
3249

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

    
3257
lockAttemptsMaxwait :: Double
3258
lockAttemptsMaxwait = 15.0
3259

    
3260
lockAttemptsMinwait :: Double
3261
lockAttemptsMinwait = 1.0
3262

    
3263
lockAttemptsTimeout :: Int
3264
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3265

    
3266
-- * Execution log types
3267

    
3268
elogMessage :: String
3269
elogMessage = Types.eLogTypeToRaw ELogMessage
3270

    
3271
elogRemoteImport :: String
3272
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3273

    
3274
elogJqueueTest :: String
3275
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3276

    
3277
-- * /etc/hosts modification
3278

    
3279
etcHostsAdd :: String
3280
etcHostsAdd = "add"
3281

    
3282
etcHostsRemove :: String
3283
etcHostsRemove = "remove"
3284

    
3285
-- * Job queue test
3286

    
3287
jqtMsgprefix :: String
3288
jqtMsgprefix = "TESTMSG="
3289

    
3290
jqtExec :: String
3291
jqtExec = "exec"
3292

    
3293
jqtExpandnames :: String
3294
jqtExpandnames = "expandnames"
3295

    
3296
jqtLogmsg :: String
3297
jqtLogmsg = "logmsg"
3298

    
3299
jqtStartmsg :: String
3300
jqtStartmsg = "startmsg"
3301

    
3302
jqtAll :: FrozenSet String
3303
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3304

    
3305
-- * Query resources
3306

    
3307
qrCluster :: String
3308
qrCluster = "cluster"
3309

    
3310
qrExport :: String
3311
qrExport = "export"
3312

    
3313
qrExtstorage :: String
3314
qrExtstorage = "extstorage"
3315

    
3316
qrGroup :: String
3317
qrGroup = "group"
3318

    
3319
qrInstance :: String
3320
qrInstance = "instance"
3321

    
3322
qrJob :: String
3323
qrJob = "job"
3324

    
3325
qrLock :: String
3326
qrLock = "lock"
3327

    
3328
qrNetwork :: String
3329
qrNetwork = "network"
3330

    
3331
qrNode :: String
3332
qrNode = "node"
3333

    
3334
qrOs :: String
3335
qrOs = "os"
3336

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

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

    
3353
-- | List of resources which can be queried using RAPI
3354
qrViaRapi :: FrozenSet String
3355
qrViaRapi = qrViaLuxi
3356

    
3357
-- * Query field types
3358

    
3359
qftBool :: String
3360
qftBool = "bool"
3361

    
3362
qftNumber :: String
3363
qftNumber = "number"
3364

    
3365
qftOther :: String
3366
qftOther = "other"
3367

    
3368
qftText :: String
3369
qftText = "text"
3370

    
3371
qftTimestamp :: String
3372
qftTimestamp = "timestamp"
3373

    
3374
qftUnit :: String
3375
qftUnit = "unit"
3376

    
3377
qftUnknown :: String
3378
qftUnknown = "unknown"
3379

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

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

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

    
3400
rsNormal :: Int
3401
rsNormal = 0
3402

    
3403
-- | Resource marked offline
3404
rsOffline :: Int
3405
rsOffline = 4
3406

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

    
3413
rsUnknown :: Int
3414
rsUnknown = 1
3415

    
3416
rsAll :: FrozenSet Int
3417
rsAll =
3418
  ConstantUtils.mkSet [rsNodata,
3419
                       rsNormal,
3420
                       rsOffline,
3421
                       rsUnavail,
3422
                       rsUnknown]
3423

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

    
3432
-- * Max dynamic devices
3433

    
3434
maxDisks :: Int
3435
maxDisks = Types.maxDisks
3436

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

    
3440
-- | SSCONF file prefix
3441
ssconfFileprefix :: String
3442
ssconfFileprefix = "ssconf_"
3443

    
3444
-- * SSCONF keys
3445

    
3446
ssClusterName :: String
3447
ssClusterName = "cluster_name"
3448

    
3449
ssClusterTags :: String
3450
ssClusterTags = "cluster_tags"
3451

    
3452
ssFileStorageDir :: String
3453
ssFileStorageDir = "file_storage_dir"
3454

    
3455
ssSharedFileStorageDir :: String
3456
ssSharedFileStorageDir = "shared_file_storage_dir"
3457

    
3458
ssMasterCandidates :: String
3459
ssMasterCandidates = "master_candidates"
3460

    
3461
ssMasterCandidatesIps :: String
3462
ssMasterCandidatesIps = "master_candidates_ips"
3463

    
3464
ssMasterIp :: String
3465
ssMasterIp = "master_ip"
3466

    
3467
ssMasterNetdev :: String
3468
ssMasterNetdev = "master_netdev"
3469

    
3470
ssMasterNetmask :: String
3471
ssMasterNetmask = "master_netmask"
3472

    
3473
ssMasterNode :: String
3474
ssMasterNode = "master_node"
3475

    
3476
ssNodeList :: String
3477
ssNodeList = "node_list"
3478

    
3479
ssNodePrimaryIps :: String
3480
ssNodePrimaryIps = "node_primary_ips"
3481

    
3482
ssNodeSecondaryIps :: String
3483
ssNodeSecondaryIps = "node_secondary_ips"
3484

    
3485
ssOfflineNodes :: String
3486
ssOfflineNodes = "offline_nodes"
3487

    
3488
ssOnlineNodes :: String
3489
ssOnlineNodes = "online_nodes"
3490

    
3491
ssPrimaryIpFamily :: String
3492
ssPrimaryIpFamily = "primary_ip_family"
3493

    
3494
ssInstanceList :: String
3495
ssInstanceList = "instance_list"
3496

    
3497
ssReleaseVersion :: String
3498
ssReleaseVersion = "release_version"
3499

    
3500
ssHypervisorList :: String
3501
ssHypervisorList = "hypervisor_list"
3502

    
3503
ssMaintainNodeHealth :: String
3504
ssMaintainNodeHealth = "maintain_node_health"
3505

    
3506
ssUidPool :: String
3507
ssUidPool = "uid_pool"
3508

    
3509
ssNodegroups :: String
3510
ssNodegroups = "nodegroups"
3511

    
3512
ssNetworks :: String
3513
ssNetworks = "networks"
3514

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

    
3520
-- * Hvparams keys
3521

    
3522
ssHvparamsXenChroot :: String
3523
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3524

    
3525
ssHvparamsXenFake :: String
3526
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3527

    
3528
ssHvparamsXenHvm :: String
3529
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3530

    
3531
ssHvparamsXenKvm :: String
3532
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3533

    
3534
ssHvparamsXenLxc :: String
3535
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3536

    
3537
ssHvparamsXenPvm :: String
3538
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3539

    
3540
validSsHvparamsKeys :: FrozenSet String
3541
validSsHvparamsKeys =
3542
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3543
                       ssHvparamsXenLxc,
3544
                       ssHvparamsXenFake,
3545
                       ssHvparamsXenHvm,
3546
                       ssHvparamsXenKvm,
3547
                       ssHvparamsXenPvm]
3548

    
3549
ssFilePerms :: Int
3550
ssFilePerms = 0o444
3551

    
3552
-- | Cluster wide default parameters
3553
defaultEnabledHypervisor :: String
3554
defaultEnabledHypervisor = htXenPvm
3555

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

    
3668
hvcGlobals :: FrozenSet String
3669
hvcGlobals =
3670
  ConstantUtils.mkSet [hvMigrationBandwidth,
3671
                       hvMigrationMode,
3672
                       hvMigrationPort,
3673
                       hvXenCmd]
3674

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

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

    
3697
ndcGlobals :: FrozenSet String
3698
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3699

    
3700
-- | Default delay target measured in sectors
3701
defaultDelayTarget :: Int
3702
defaultDelayTarget = 1
3703

    
3704
defaultDiskCustom :: String
3705
defaultDiskCustom = ""
3706

    
3707
defaultDiskResync :: Bool
3708
defaultDiskResync = False
3709

    
3710
-- | Default fill target measured in sectors
3711
defaultFillTarget :: Int
3712
defaultFillTarget = 0
3713

    
3714
-- | Default mininum rate measured in KiB/s
3715
defaultMinRate :: Int
3716
defaultMinRate = 4 * 1024
3717

    
3718
defaultNetCustom :: String
3719
defaultNetCustom = ""
3720

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

    
3731
defaultRbdPool :: String
3732
defaultRbdPool = "rbd"
3733

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

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

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

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

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

    
3842
masterPoolSizeDefault :: Int
3843
masterPoolSizeDefault = 10
3844

    
3845
-- * Exclusive storage
3846

    
3847
-- | Error margin used to compare physical disks
3848
partMargin :: Double
3849
partMargin = 0.01
3850

    
3851
-- | Space reserved when creating instance disks
3852
partReserved :: Double
3853
partReserved = 0.02
3854

    
3855
-- * Confd
3856

    
3857
confdProtocolVersion :: Int
3858
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3859

    
3860
-- Confd request type
3861

    
3862
confdReqPing :: Int
3863
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3864

    
3865
confdReqNodeRoleByname :: Int
3866
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3867

    
3868
confdReqNodePipByInstanceIp :: Int
3869
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3870

    
3871
confdReqClusterMaster :: Int
3872
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3873

    
3874
confdReqNodePipList :: Int
3875
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3876

    
3877
confdReqMcPipList :: Int
3878
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3879

    
3880
confdReqInstancesIpsList :: Int
3881
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3882

    
3883
confdReqNodeDrbd :: Int
3884
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3885

    
3886
confdReqNodeInstances :: Int
3887
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3888

    
3889
confdReqs :: FrozenSet Int
3890
confdReqs =
3891
  ConstantUtils.mkSet .
3892
  map Types.confdRequestTypeToRaw $
3893
  [minBound..] \\ [ReqNodeInstances]
3894

    
3895
-- * Confd request type
3896

    
3897
confdReqfieldName :: Int
3898
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3899

    
3900
confdReqfieldIp :: Int
3901
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3902

    
3903
confdReqfieldMnodePip :: Int
3904
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3905

    
3906
-- * Confd repl status
3907

    
3908
confdReplStatusOk :: Int
3909
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3910

    
3911
confdReplStatusError :: Int
3912
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3913

    
3914
confdReplStatusNotimplemented :: Int
3915
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3916

    
3917
confdReplStatuses :: FrozenSet Int
3918
confdReplStatuses =
3919
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3920

    
3921
-- * Confd node role
3922

    
3923
confdNodeRoleMaster :: Int
3924
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3925

    
3926
confdNodeRoleCandidate :: Int
3927
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3928

    
3929
confdNodeRoleOffline :: Int
3930
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3931

    
3932
confdNodeRoleDrained :: Int
3933
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3934

    
3935
confdNodeRoleRegular :: Int
3936
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3937

    
3938
-- * A few common errors for confd
3939

    
3940
confdErrorUnknownEntry :: Int
3941
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3942

    
3943
confdErrorInternal :: Int
3944
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3945

    
3946
confdErrorArgument :: Int
3947
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3948

    
3949
-- * Confd request query fields
3950

    
3951
confdReqqLink :: String
3952
confdReqqLink = ConstantUtils.confdReqqLink
3953

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

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

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

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

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

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

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

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

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

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

    
4015
-- * User-id pool minimum/maximum acceptable user-ids
4016

    
4017
uidpoolUidMin :: Int
4018
uidpoolUidMin = 0
4019

    
4020
-- | Assuming 32 bit user-ids
4021
uidpoolUidMax :: Integer
4022
uidpoolUidMax = 2 ^ 32 - 1
4023

    
4024
-- | Name or path of the pgrep command
4025
pgrep :: String
4026
pgrep = "pgrep"
4027

    
4028
-- | Name of the node group that gets created at cluster init or
4029
-- upgrade
4030
initialNodeGroupName :: String
4031
initialNodeGroupName = "default"
4032

    
4033
-- * Possible values for NodeGroup.alloc_policy
4034

    
4035
allocPolicyLastResort :: String
4036
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4037

    
4038
allocPolicyPreferred :: String
4039
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4040

    
4041
allocPolicyUnallocable :: String
4042
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4043

    
4044
validAllocPolicies :: [String]
4045
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4046

    
4047
-- | Temporary external/shared storage parameters
4048
blockdevDriverManual :: String
4049
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4050

    
4051
-- | 'qemu-img' path, required for 'ovfconverter'
4052
qemuimgPath :: String
4053
qemuimgPath = AutoConf.qemuimgPath
4054

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

    
4062
-- | The hail iallocator
4063
iallocHail :: String
4064
iallocHail = "hail"
4065

    
4066
-- * Fake opcodes for functions that have hooks attached to them via
4067
-- backend.RunLocalHooks
4068

    
4069
fakeOpMasterTurndown :: String
4070
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4071

    
4072
fakeOpMasterTurnup :: String
4073
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4074

    
4075
-- * SSH key types
4076

    
4077
sshkDsa :: String
4078
sshkDsa = "dsa"
4079

    
4080
sshkRsa :: String
4081
sshkRsa = "rsa"
4082

    
4083
sshkAll :: FrozenSet String
4084
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4085

    
4086
-- * SSH authorized key types
4087

    
4088
sshakDss :: String
4089
sshakDss = "ssh-dss"
4090

    
4091
sshakRsa :: String
4092
sshakRsa = "ssh-rsa"
4093

    
4094
sshakAll :: FrozenSet String
4095
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4096

    
4097
-- * SSH setup
4098

    
4099
sshsClusterName :: String
4100
sshsClusterName = "cluster_name"
4101

    
4102
sshsSshHostKey :: String
4103
sshsSshHostKey = "ssh_host_key"
4104

    
4105
sshsSshRootKey :: String
4106
sshsSshRootKey = "ssh_root_key"
4107

    
4108
sshsNodeDaemonCertificate :: String
4109
sshsNodeDaemonCertificate = "node_daemon_certificate"
4110

    
4111
-- * Key files for SSH daemon
4112

    
4113
sshHostDsaPriv :: String
4114
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4115

    
4116
sshHostDsaPub :: String
4117
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4118

    
4119
sshHostRsaPriv :: String
4120
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4121

    
4122
sshHostRsaPub :: String
4123
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4124

    
4125
sshDaemonKeyfiles :: Map String (String, String)
4126
sshDaemonKeyfiles =
4127
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4128
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4129
               ]
4130

    
4131
-- * Node daemon setup
4132

    
4133
ndsClusterName :: String
4134
ndsClusterName = "cluster_name"
4135

    
4136
ndsNodeDaemonCertificate :: String
4137
ndsNodeDaemonCertificate = "node_daemon_certificate"
4138

    
4139
ndsSsconf :: String
4140
ndsSsconf = "ssconf"
4141

    
4142
ndsStartNodeDaemon :: String
4143
ndsStartNodeDaemon = "start_node_daemon"
4144

    
4145
-- * The source reasons for the execution of an OpCode
4146

    
4147
opcodeReasonSrcClient :: String
4148
opcodeReasonSrcClient = "gnt:client"
4149

    
4150
opcodeReasonSrcNoded :: String
4151
opcodeReasonSrcNoded = "gnt:daemon:noded"
4152

    
4153
opcodeReasonSrcOpcode :: String
4154
opcodeReasonSrcOpcode = "gnt:opcode"
4155

    
4156
opcodeReasonSrcRlib2 :: String
4157
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4158

    
4159
opcodeReasonSrcUser :: String
4160
opcodeReasonSrcUser = "gnt:user"
4161

    
4162
opcodeReasonSources :: FrozenSet String
4163
opcodeReasonSources =
4164
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4165
                       opcodeReasonSrcNoded,
4166
                       opcodeReasonSrcOpcode,
4167
                       opcodeReasonSrcRlib2,
4168
                       opcodeReasonSrcUser]
4169

    
4170
-- | Path generating random UUID
4171
randomUuidFile :: String
4172
randomUuidFile = ConstantUtils.randomUuidFile
4173

    
4174
-- * Auto-repair tag prefixes
4175

    
4176
autoRepairTagPrefix :: String
4177
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4178

    
4179
autoRepairTagEnabled :: String
4180
autoRepairTagEnabled = autoRepairTagPrefix
4181

    
4182
autoRepairTagPending :: String
4183
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4184

    
4185
autoRepairTagResult :: String
4186
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4187

    
4188
autoRepairTagSuspended :: String
4189
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4190

    
4191
-- * Auto-repair levels
4192

    
4193
autoRepairFailover :: String
4194
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4195

    
4196
autoRepairFixStorage :: String
4197
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4198

    
4199
autoRepairMigrate :: String
4200
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4201

    
4202
autoRepairReinstall :: String
4203
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4204

    
4205
autoRepairAllTypes :: FrozenSet String
4206
autoRepairAllTypes =
4207
  ConstantUtils.mkSet [autoRepairFailover,
4208
                       autoRepairFixStorage,
4209
                       autoRepairMigrate,
4210
                       autoRepairReinstall]
4211

    
4212
-- * Auto-repair results
4213

    
4214
autoRepairEnoperm :: String
4215
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4216

    
4217
autoRepairFailure :: String
4218
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4219

    
4220
autoRepairSuccess :: String
4221
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4222

    
4223
autoRepairAllResults :: FrozenSet String
4224
autoRepairAllResults =
4225
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4226

    
4227
-- | The version identifier for builtin data collectors
4228
builtinDataCollectorVersion :: String
4229
builtinDataCollectorVersion = "B"
4230

    
4231
-- | The reason trail opcode parameter name
4232
opcodeReason :: String
4233
opcodeReason = "reason"
4234

    
4235
diskstatsFile :: String
4236
diskstatsFile = "/proc/diskstats"
4237

    
4238
-- *  CPU load collector
4239

    
4240
statFile :: String
4241
statFile = "/proc/stat"
4242

    
4243
cpuavgloadBufferSize :: Int
4244
cpuavgloadBufferSize = 150
4245

    
4246
cpuavgloadWindowSize :: Int
4247
cpuavgloadWindowSize = 600
4248

    
4249
-- * Monitoring daemon
4250

    
4251
-- | Mond's variable for periodical data collection
4252
mondTimeInterval :: Int
4253
mondTimeInterval = 5
4254

    
4255
-- | Mond's latest API version
4256
mondLatestApiVersion :: Int
4257
mondLatestApiVersion = 1
4258

    
4259
-- * Disk access modes
4260

    
4261
diskUserspace :: String
4262
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4263

    
4264
diskKernelspace :: String
4265
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4266

    
4267
diskValidAccessModes :: FrozenSet String
4268
diskValidAccessModes =
4269
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4270

    
4271
-- | Timeout for queue draining in upgrades
4272
upgradeQueueDrainTimeout :: Int
4273
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4274

    
4275
-- | Intervall at which the queue is polled during upgrades
4276
upgradeQueuePollInterval :: Int
4277
upgradeQueuePollInterval  = 10
4278

    
4279
-- * Hotplug Actions
4280

    
4281
hotplugActionAdd :: String
4282
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4283

    
4284
hotplugActionRemove :: String
4285
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4286

    
4287
hotplugActionModify :: String
4288
hotplugActionModify = Types.hotplugActionToRaw HAMod
4289

    
4290
hotplugAllActions :: FrozenSet String
4291
hotplugAllActions =
4292
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4293

    
4294
-- * Hotplug Device Targets
4295

    
4296
hotplugTargetNic :: String
4297
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4298

    
4299
hotplugTargetDisk :: String
4300
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4301

    
4302
hotplugAllTargets :: FrozenSet String
4303
hotplugAllTargets =
4304
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4305

    
4306
-- | Timeout for disk removal (seconds)
4307
diskRemoveRetryTimeout :: Int
4308
diskRemoveRetryTimeout = 30
4309

    
4310
-- | Interval between disk removal retries (seconds)
4311
diskRemoveRetryInterval :: Int
4312
diskRemoveRetryInterval  = 3