Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ 4c5cb91e

History | View | Annotate | Download (108.3 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 = "gzip"
559

    
560
iecNone :: String
561
iecNone = "none"
562

    
563
iecAll :: [String]
564
iecAll = [iecGzip, iecNone]
565

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

    
569
-- * Import/export I/O
570

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

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

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

    
584
-- * Values
585

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

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

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

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

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

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

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

    
607
-- * Hooks
608

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

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

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

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

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

    
624
hooksVersion :: Int
625
hooksVersion = 2
626

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

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

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

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

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

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

    
644
-- * Hkr
645

    
646
hkrSkip :: Int
647
hkrSkip = 0
648

    
649
hkrFail :: Int
650
hkrFail = 1
651

    
652
hkrSuccess :: Int
653
hkrSuccess = 2
654

    
655
-- * Storage types
656

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
724
-- * Storage operations
725

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

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

    
734
-- * Volume fields
735

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

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

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

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

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

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

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

    
757
-- * Local disk status
758

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

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

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

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

    
773
-- * Disk template types
774

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
899
-- * Drbd
900

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

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

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

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

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

    
917
-- * Drbd barrier types
918

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

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

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

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

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

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

    
949
-- * File backend driver
950

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

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

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

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

    
966
-- * Disk access mode
967

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

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

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

    
977
-- * Disk replacement mode
978

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

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

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

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

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

    
995
-- * Instance export mode
996

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

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

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

    
1006
-- * Instance creation modes
1007

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

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

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

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

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

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

    
1026
rieVersion :: Int
1027
rieVersion = 0
1028

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

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

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

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

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

    
1049
-- * Import/export config options
1050

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

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

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

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

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

    
1066
-- * Dynamic device modification
1067

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

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

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

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

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

    
1083
-- * Common exit codes
1084

    
1085
exitSuccess :: Int
1086
exitSuccess = 0
1087

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

    
1091
exitNotcluster :: Int
1092
exitNotcluster = 5
1093

    
1094
exitNotmaster :: Int
1095
exitNotmaster = 11
1096

    
1097
exitNodesetupError :: Int
1098
exitNodesetupError = 12
1099

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

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

    
1108
-- * Tags
1109

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

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

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

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

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

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

    
1128
maxTagLen :: Int
1129
maxTagLen = 128
1130

    
1131
maxTagsPerObj :: Int
1132
maxTagsPerObj = 4096
1133

    
1134
-- * Others
1135

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

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

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

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

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

    
1152
ip6AddressAny :: String
1153
ip6AddressAny = "::"
1154

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

    
1158
ip4Version :: Int
1159
ip4Version = 4
1160

    
1161
ip6Version :: Int
1162
ip6Version = 6
1163

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

    
1167
tcpPingTimeout :: Int
1168
tcpPingTimeout = 10
1169

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

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

    
1176
minVgSize :: Int
1177
minVgSize = 20480
1178

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

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

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

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

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

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

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

    
1205
-- * Runparts results
1206

    
1207
runpartsErr :: Int
1208
runpartsErr = 2
1209

    
1210
runpartsRun :: Int
1211
runpartsRun = 1
1212

    
1213
runpartsSkip :: Int
1214
runpartsSkip = 0
1215

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

    
1219
-- * RPC
1220

    
1221
rpcEncodingNone :: Int
1222
rpcEncodingNone = 0
1223

    
1224
rpcEncodingZlibBase64 :: Int
1225
rpcEncodingZlibBase64 = 1
1226

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

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

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

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

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

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

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

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

    
1259
-- OS
1260

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1318
esScriptCreate :: String
1319
esScriptCreate = esActionCreate
1320

    
1321
esScriptRemove :: String
1322
esScriptRemove = esActionRemove
1323

    
1324
esScriptGrow :: String
1325
esScriptGrow = esActionGrow
1326

    
1327
esScriptAttach :: String
1328
esScriptAttach = esActionAttach
1329

    
1330
esScriptDetach :: String
1331
esScriptDetach = esActionDetach
1332

    
1333
esScriptSetinfo :: String
1334
esScriptSetinfo = esActionSetinfo
1335

    
1336
esScriptVerify :: String
1337
esScriptVerify = esActionVerify
1338

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

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

    
1352
-- * Reboot types
1353

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

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

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

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

    
1366
-- * Instance reboot behaviors
1367

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

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

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

    
1377
-- * VTypes
1378

    
1379
vtypeBool :: VType
1380
vtypeBool = VTypeBool
1381

    
1382
vtypeInt :: VType
1383
vtypeInt = VTypeInt
1384

    
1385
vtypeMaybeString :: VType
1386
vtypeMaybeString = VTypeMaybeString
1387

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

    
1392
vtypeString :: VType
1393
vtypeString = VTypeString
1394

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1735
-- * Migration statuses
1736

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

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

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

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

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

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

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

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

    
1770
-- * Hypervisor state
1771

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

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

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

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

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

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

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

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

    
1812
-- * Disk state
1813

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

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

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

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

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

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

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

    
1843
-- Backend parameter names
1844

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1972
-- | Node parameter names
1973

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

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

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

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

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

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

    
1992
ndsParameterTypes :: Map String VType
1993
ndsParameterTypes =
1994
  Map.fromList
1995
  [(ndExclusiveStorage, VTypeBool),
1996
   (ndOobProgram, VTypeString),
1997
   (ndOvs, VTypeBool),
1998
   (ndOvsLink, VTypeMaybeString),
1999
   (ndOvsName, VTypeMaybeString),
2000
   (ndSpindleCount, VTypeInt)]
2001

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

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

    
2015
-- * Logical Disks parameters
2016

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2171
-- * Dynamic disk parameters
2172

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

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

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

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

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

    
2188
-- * OOB supported commands
2189

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2359
-- * Hypervisor constants
2360

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

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

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

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

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

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

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

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

    
2385
vncBasePort :: Int
2386
vncBasePort = 5900
2387

    
2388
vncDefaultBindAddress :: String
2389
vncDefaultBindAddress = ip4AddressAny
2390

    
2391
-- * NIC types
2392

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

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

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

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

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

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

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

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

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

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

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

    
2440
-- * Vif types
2441

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

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

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

    
2452
-- * Disk types
2453

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2506
-- * Mouse types
2507

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

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

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

    
2517
-- * Boot order
2518

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

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

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

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

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

    
2535
-- * SPICE lossless image compression options
2536

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

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

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

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

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

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

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

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

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

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

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

    
2579
-- * SPICE video stream detection
2580

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

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

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

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

    
2596
-- * Security models
2597

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

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

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

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

    
2610
-- * Kvm flag values
2611

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

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

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

    
2621
-- * Migration type
2622

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

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

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

    
2633
-- * Cluster verify steps
2634

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

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

    
2642
-- * Cluster Verify error classes
2643

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

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

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

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

    
2656
-- * Cluster Verify error codes and documentation
2657

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2932
-- * Node verify constants
2933

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3012
-- * Instance status
3013

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

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

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

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

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

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

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

    
3035
inststWrongnode :: String
3036
inststWrongnode = Types.instanceStatusToRaw WrongNode
3037

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

    
3041
-- * Admin states
3042

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

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

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

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

    
3055
-- * Node roles
3056

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

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

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

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

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

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

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

    
3077
sslCertExpirationError :: Int
3078
sslCertExpirationError = 7
3079

    
3080
sslCertExpirationWarn :: Int
3081
sslCertExpirationWarn = 30
3082

    
3083
-- * Allocator framework constants
3084

    
3085
iallocatorVersion :: Int
3086
iallocatorVersion = 2
3087

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

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

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

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

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

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

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

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

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

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

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

    
3123
-- * Node evacuation
3124

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

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

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

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

    
3137
-- * Job queue
3138

    
3139
jobQueueVersion :: Int
3140
jobQueueVersion = 1
3141

    
3142
jobQueueSizeHardLimit :: Int
3143
jobQueueSizeHardLimit = 5000
3144

    
3145
jobQueueFilesPerms :: Int
3146
jobQueueFilesPerms = 0o640
3147

    
3148
-- * Unchanged job return
3149

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

    
3153
-- * Job status
3154

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

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

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

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

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

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

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

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

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

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

    
3187
-- * OpCode status
3188

    
3189
-- ** Not yet finalized opcodes
3190

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

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

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

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

    
3203
-- ** Finalized opcodes
3204

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

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

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

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

    
3218
-- * OpCode priority
3219

    
3220
opPrioLowest :: Int
3221
opPrioLowest = 19
3222

    
3223
opPrioHighest :: Int
3224
opPrioHighest = -20
3225

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

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

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

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

    
3238
opPrioDefault :: Int
3239
opPrioDefault = opPrioNormal
3240

    
3241
-- * Lock recalculate mode
3242

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

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

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

    
3256
lockAttemptsMaxwait :: Double
3257
lockAttemptsMaxwait = 15.0
3258

    
3259
lockAttemptsMinwait :: Double
3260
lockAttemptsMinwait = 1.0
3261

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

    
3265
-- * Execution log types
3266

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

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

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

    
3276
-- * /etc/hosts modification
3277

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

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

    
3284
-- * Job queue test
3285

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

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

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

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

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

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

    
3304
-- * Query resources
3305

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3356
-- * Query field types
3357

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

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

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

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

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

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

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

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

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

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

    
3399
rsNormal :: Int
3400
rsNormal = 0
3401

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

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

    
3412
rsUnknown :: Int
3413
rsUnknown = 1
3414

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

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

    
3431
-- * Max dynamic devices
3432

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

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

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

    
3443
-- * SSCONF keys
3444

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3519
-- * Hvparams keys
3520

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

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

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

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

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

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

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

    
3548
ssFilePerms :: Int
3549
ssFilePerms = 0o444
3550

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

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

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

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

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

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

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

    
3703
defaultDiskCustom :: String
3704
defaultDiskCustom = ""
3705

    
3706
defaultDiskResync :: Bool
3707
defaultDiskResync = False
3708

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

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

    
3717
defaultNetCustom :: String
3718
defaultNetCustom = ""
3719

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

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

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

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

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

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

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

    
3841
masterPoolSizeDefault :: Int
3842
masterPoolSizeDefault = 10
3843

    
3844
-- * Exclusive storage
3845

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

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

    
3854
-- * Confd
3855

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

    
3859
-- Confd request type
3860

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

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

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

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

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

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

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

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

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

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

    
3894
-- * Confd request type
3895

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

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

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

    
3905
-- * Confd repl status
3906

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

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

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

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

    
3920
-- * Confd node role
3921

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

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

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

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

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

    
3937
-- * A few common errors for confd
3938

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

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

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

    
3948
-- * Confd request query fields
3949

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

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

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

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

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

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

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

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

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

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

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

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

    
4016
uidpoolUidMin :: Int
4017
uidpoolUidMin = 0
4018

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

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

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

    
4032
-- * Possible values for NodeGroup.alloc_policy
4033

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

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

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

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

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

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

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

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

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

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

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

    
4074
-- * SSH key types
4075

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

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

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

    
4085
-- * SSH authorized key types
4086

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

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

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

    
4096
-- * SSH setup
4097

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

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

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

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

    
4110
-- * Key files for SSH daemon
4111

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

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

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

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

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

    
4130
-- * Node daemon setup
4131

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

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

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

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

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

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

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

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

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

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

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

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

    
4173
-- * Auto-repair tag prefixes
4174

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

    
4178
autoRepairTagEnabled :: String
4179
autoRepairTagEnabled = autoRepairTagPrefix
4180

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

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

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

    
4190
-- * Auto-repair levels
4191

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

    
4195
autoRepairFixStorage :: String
4196
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4197

    
4198
autoRepairMigrate :: String
4199
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4200

    
4201
autoRepairReinstall :: String
4202
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4203

    
4204
autoRepairAllTypes :: FrozenSet String
4205
autoRepairAllTypes =
4206
  ConstantUtils.mkSet [autoRepairFailover,
4207
                       autoRepairFixStorage,
4208
                       autoRepairMigrate,
4209
                       autoRepairReinstall]
4210

    
4211
-- * Auto-repair results
4212

    
4213
autoRepairEnoperm :: String
4214
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4215

    
4216
autoRepairFailure :: String
4217
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4218

    
4219
autoRepairSuccess :: String
4220
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4221

    
4222
autoRepairAllResults :: FrozenSet String
4223
autoRepairAllResults =
4224
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4225

    
4226
-- | The version identifier for builtin data collectors
4227
builtinDataCollectorVersion :: String
4228
builtinDataCollectorVersion = "B"
4229

    
4230
-- | The reason trail opcode parameter name
4231
opcodeReason :: String
4232
opcodeReason = "reason"
4233

    
4234
diskstatsFile :: String
4235
diskstatsFile = "/proc/diskstats"
4236

    
4237
-- *  CPU load collector
4238

    
4239
statFile :: String
4240
statFile = "/proc/stat"
4241

    
4242
cpuavgloadBufferSize :: Int
4243
cpuavgloadBufferSize = 150
4244

    
4245
cpuavgloadWindowSize :: Int
4246
cpuavgloadWindowSize = 600
4247

    
4248
-- * Monitoring daemon
4249

    
4250
-- | Mond's variable for periodical data collection
4251
mondTimeInterval :: Int
4252
mondTimeInterval = 5
4253

    
4254
-- | Mond's latest API version
4255
mondLatestApiVersion :: Int
4256
mondLatestApiVersion = 1
4257

    
4258
-- * Disk access modes
4259

    
4260
diskUserspace :: String
4261
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4262

    
4263
diskKernelspace :: String
4264
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4265

    
4266
diskValidAccessModes :: FrozenSet String
4267
diskValidAccessModes =
4268
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4269

    
4270
-- | Timeout for queue draining in upgrades
4271
upgradeQueueDrainTimeout :: Int
4272
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4273

    
4274
-- | Intervall at which the queue is polled during upgrades
4275
upgradeQueuePollInterval :: Int
4276
upgradeQueuePollInterval  = 10
4277

    
4278
-- * Hotplug Actions
4279

    
4280
hotplugActionAdd :: String
4281
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4282

    
4283
hotplugActionRemove :: String
4284
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4285

    
4286
hotplugActionModify :: String
4287
hotplugActionModify = Types.hotplugActionToRaw HAMod
4288

    
4289
hotplugAllActions :: FrozenSet String
4290
hotplugAllActions =
4291
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4292

    
4293
-- * Hotplug Device Targets
4294

    
4295
hotplugTargetNic :: String
4296
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4297

    
4298
hotplugTargetDisk :: String
4299
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4300

    
4301
hotplugAllTargets :: FrozenSet String
4302
hotplugAllTargets =
4303
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4304

    
4305
-- | Timeout for disk removal (seconds)
4306
diskRemoveRetryTimeout :: Int
4307
diskRemoveRetryTimeout = 30
4308

    
4309
-- | Interval between disk removal retries (seconds)
4310
diskRemoveRetryInterval :: Int
4311
diskRemoveRetryInterval  = 3