Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ cb23d0ca

History | View | Annotate | Download (94.4 kB)

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

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

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

    
16
-}
17

    
18
{-
19

    
20
Copyright (C) 2013 Google Inc.
21

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

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

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

    
37
-}
38
module Ganeti.HsConstants where
39

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

    
45
import qualified AutoConf
46
import Ganeti.ConstantUtils (PythonChar(..), FrozenSet, Protocol(..),
47
                             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
-- * Hooks
585

    
586
hooksNameCfgupdate :: String
587
hooksNameCfgupdate = "config-update"
588

    
589
hooksNameWatcher :: String
590
hooksNameWatcher = "watcher"
591

    
592
hooksPath :: String
593
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
594

    
595
hooksPhasePost :: String
596
hooksPhasePost = "post"
597

    
598
hooksPhasePre :: String
599
hooksPhasePre = "pre"
600

    
601
hooksVersion :: Int
602
hooksVersion = 2
603

    
604
-- * Hooks subject type (what object type does the LU deal with)
605

    
606
htypeCluster :: String
607
htypeCluster = "CLUSTER"
608

    
609
htypeGroup :: String
610
htypeGroup = "GROUP"
611

    
612
htypeInstance :: String
613
htypeInstance = "INSTANCE"
614

    
615
htypeNetwork :: String
616
htypeNetwork = "NETWORK"
617

    
618
htypeNode :: String
619
htypeNode = "NODE"
620

    
621
-- * Hkr
622

    
623
hkrSkip :: Int
624
hkrSkip = 0
625

    
626
hkrFail :: Int
627
hkrFail = 1
628

    
629
hkrSuccess :: Int
630
hkrSuccess = 2
631

    
632
-- * Storage types
633

    
634
stBlock :: String
635
stBlock = Types.storageTypeToRaw StorageBlock
636

    
637
stDiskless :: String
638
stDiskless = Types.storageTypeToRaw StorageDiskless
639

    
640
stExt :: String
641
stExt = Types.storageTypeToRaw StorageExt
642

    
643
stFile :: String
644
stFile = Types.storageTypeToRaw StorageFile
645

    
646
stLvmPv :: String
647
stLvmPv = Types.storageTypeToRaw StorageLvmPv
648

    
649
stLvmVg :: String
650
stLvmVg = Types.storageTypeToRaw StorageLvmVg
651

    
652
stRados :: String
653
stRados = Types.storageTypeToRaw StorageRados
654

    
655
storageTypes :: FrozenSet String
656
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
657

    
658
-- | The set of storage types for which storage reporting is available
659
--
660
-- FIXME: Remove this, once storage reporting is available for all
661
-- types.
662
stsReport :: FrozenSet String
663
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
664

    
665
-- * Storage fields
666
-- ** First two are valid in LU context only, not passed to backend
667

    
668
sfNode :: String
669
sfNode = "node"
670

    
671
sfType :: String
672
sfType = "type"
673

    
674
-- ** and the rest are valid in backend
675

    
676
sfAllocatable :: String
677
sfAllocatable = Types.storageFieldToRaw SFAllocatable
678

    
679
sfFree :: String
680
sfFree = Types.storageFieldToRaw SFFree
681

    
682
sfName :: String
683
sfName = Types.storageFieldToRaw SFName
684

    
685
sfSize :: String
686
sfSize = Types.storageFieldToRaw SFSize
687

    
688
sfUsed :: String
689
sfUsed = Types.storageFieldToRaw SFUsed
690

    
691
validStorageFields :: FrozenSet String
692
validStorageFields =
693
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
694
                        [sfNode, sfType]
695

    
696
modifiableStorageFields :: Map String (FrozenSet String)
697
modifiableStorageFields =
698
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
699
                 ConstantUtils.mkSet [sfAllocatable])]
700

    
701
-- * Storage operations
702

    
703
soFixConsistency :: String
704
soFixConsistency = "fix-consistency"
705

    
706
validStorageOperations :: Map String (FrozenSet String)
707
validStorageOperations =
708
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
709
                 ConstantUtils.mkSet [soFixConsistency])]
710

    
711
-- * Volume fields
712

    
713
vfDev :: String
714
vfDev = "dev"
715

    
716
vfInstance :: String
717
vfInstance = "instance"
718

    
719
vfName :: String
720
vfName = "name"
721

    
722
vfNode :: String
723
vfNode = "node"
724

    
725
vfPhys :: String
726
vfPhys = "phys"
727

    
728
vfSize :: String
729
vfSize = "size"
730

    
731
vfVg :: String
732
vfVg = "vg"
733

    
734
-- * Local disk status
735

    
736
ldsFaulty :: Int
737
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
738

    
739
ldsOkay :: Int
740
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
741

    
742
ldsUnknown :: Int
743
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
744

    
745
ldsNames :: Map Int String
746
ldsNames =
747
  Map.fromList [ (Types.localDiskStatusToRaw ds,
748
                  localDiskStatusName ds) | ds <- [minBound..] ]
749

    
750
-- * Disk template types
751

    
752
dtDiskless :: String
753
dtDiskless = Types.diskTemplateToRaw DTDiskless
754

    
755
dtFile :: String
756
dtFile = Types.diskTemplateToRaw DTFile
757

    
758
dtSharedFile :: String
759
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
760

    
761
dtPlain :: String
762
dtPlain = Types.diskTemplateToRaw DTPlain
763

    
764
dtBlock :: String
765
dtBlock = Types.diskTemplateToRaw DTBlock
766

    
767
dtDrbd8 :: String
768
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
769

    
770
dtRbd :: String
771
dtRbd = Types.diskTemplateToRaw DTRbd
772

    
773
dtExt :: String
774
dtExt = Types.diskTemplateToRaw DTExt
775

    
776
-- | This is used to order determine the default disk template when
777
-- the list of enabled disk templates is inferred from the current
778
-- state of the cluster.  This only happens on an upgrade from a
779
-- version of Ganeti that did not support the 'enabled_disk_templates'
780
-- so far.
781
diskTemplatePreference :: [String]
782
diskTemplatePreference =
783
  map Types.diskTemplateToRaw
784
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile, DTPlain, DTRbd, DTSharedFile]
785

    
786
diskTemplates :: FrozenSet String
787
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
788

    
789
-- | Disk templates that are enabled by default
790
defaultEnabledDiskTemplates :: [String]
791
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
792

    
793
-- | Mapping of disk templates to storage types
794
mapDiskTemplateStorageType :: Map String String
795
mapDiskTemplateStorageType =
796
  Map.fromList $
797
  map (Types.diskTemplateToRaw *** Types.storageTypeToRaw)
798
  [(DTBlock, StorageBlock),
799
   (DTDrbd8, StorageLvmVg),
800
   (DTExt, StorageExt),
801
   (DTSharedFile, StorageFile),
802
   (DTFile, StorageFile),
803
   (DTDiskless, StorageDiskless),
804
   (DTPlain, StorageLvmVg),
805
   (DTRbd, StorageRados)]
806

    
807
-- | The set of network-mirrored disk templates
808
dtsIntMirror :: FrozenSet String
809
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
810

    
811
-- | 'DTDiskless' is 'trivially' externally mirrored
812
dtsExtMirror :: FrozenSet String
813
dtsExtMirror =
814
  ConstantUtils.mkSet $
815
  map Types.diskTemplateToRaw [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd]
816

    
817
-- | The set of non-lvm-based disk templates
818
dtsNotLvm :: FrozenSet String
819
dtsNotLvm =
820
  ConstantUtils.mkSet $
821
  map Types.diskTemplateToRaw
822
  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd]
823

    
824
-- | The set of disk templates which can be grown
825
dtsGrowable :: FrozenSet String
826
dtsGrowable =
827
  ConstantUtils.mkSet $
828
  map Types.diskTemplateToRaw
829
  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd]
830

    
831
-- | The set of disk templates that allow adoption
832
dtsMayAdopt :: FrozenSet String
833
dtsMayAdopt =
834
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
835

    
836
-- | The set of disk templates that *must* use adoption
837
dtsMustAdopt :: FrozenSet String
838
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
839

    
840
-- | The set of disk templates that allow migrations
841
dtsMirrored :: FrozenSet String
842
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
843

    
844
-- | The set of file based disk templates
845
dtsFilebased :: FrozenSet String
846
dtsFilebased =
847
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTSharedFile, DTFile]
848

    
849
-- | The set of disk templates that can be moved by copying
850
--
851
-- Note: a requirement is that they're not accessed externally or
852
-- shared between nodes; in particular, sharedfile is not suitable.
853
dtsCopyable :: FrozenSet String
854
dtsCopyable =
855
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
856

    
857
-- | The set of disk templates that are supported by exclusive_storage
858
dtsExclStorage :: FrozenSet String
859
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
860

    
861
-- | Templates for which we don't perform checks on free space
862
dtsNoFreeSpaceCheck :: FrozenSet String
863
dtsNoFreeSpaceCheck =
864
  ConstantUtils.mkSet $
865
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd]
866

    
867
dtsBlock :: FrozenSet String
868
dtsBlock =
869
  ConstantUtils.mkSet $
870
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
871

    
872
-- | The set of lvm-based disk templates
873
dtsLvm :: FrozenSet String
874
dtsLvm = diskTemplates `ConstantUtils.difference` dtsNotLvm
875

    
876
-- * Drbd
877

    
878
drbdHmacAlg :: String
879
drbdHmacAlg = "md5"
880

    
881
drbdDefaultNetProtocol :: String
882
drbdDefaultNetProtocol = "C"
883

    
884
drbdMigrationNetProtocol :: String
885
drbdMigrationNetProtocol = "C"
886

    
887
drbdStatusFile :: String
888
drbdStatusFile = "/proc/drbd"
889

    
890
-- | Size of DRBD meta block device
891
drbdMetaSize :: Int
892
drbdMetaSize = 128
893

    
894
-- * Drbd barrier types
895

    
896
drbdBDiskBarriers :: String
897
drbdBDiskBarriers = "b"
898

    
899
drbdBDiskDrain :: String
900
drbdBDiskDrain = "d"
901

    
902
drbdBDiskFlush :: String
903
drbdBDiskFlush = "f"
904

    
905
drbdBNone :: String
906
drbdBNone = "n"
907

    
908
-- | Valid barrier combinations: "n" or any non-null subset of "bfd"
909
drbdValidBarrierOpt :: FrozenSet (FrozenSet String)
910
drbdValidBarrierOpt =
911
  ConstantUtils.mkSet
912
  [ ConstantUtils.mkSet [drbdBNone]
913
  , ConstantUtils.mkSet [drbdBDiskBarriers]
914
  , ConstantUtils.mkSet [drbdBDiskDrain]
915
  , ConstantUtils.mkSet [drbdBDiskFlush]
916
  , ConstantUtils.mkSet [drbdBDiskDrain, drbdBDiskFlush]
917
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskDrain]
918
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush]
919
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush, drbdBDiskDrain]
920
  ]
921

    
922
-- | Rbd tool command
923
rbdCmd :: String
924
rbdCmd = "rbd"
925

    
926
-- * File backend driver
927

    
928
fdBlktap :: String
929
fdBlktap = Types.fileDriverToRaw FileBlktap
930

    
931
fdLoop :: String
932
fdLoop = Types.fileDriverToRaw FileLoop
933

    
934
fileDriver :: FrozenSet String
935
fileDriver =
936
  ConstantUtils.mkSet $
937
  map Types.fileDriverToRaw [minBound..]
938

    
939
-- | The set of drbd-like disk types
940
dtsDrbd :: FrozenSet String
941
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
942

    
943
-- * Disk access mode
944

    
945
diskRdonly :: String
946
diskRdonly = Types.diskModeToRaw DiskRdOnly
947

    
948
diskRdwr :: String
949
diskRdwr = Types.diskModeToRaw DiskRdWr
950

    
951
diskAccessSet :: FrozenSet String
952
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
953

    
954
-- * Disk replacement mode
955

    
956
replaceDiskAuto :: String
957
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
958

    
959
replaceDiskChg :: String
960
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
961

    
962
replaceDiskPri :: String
963
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
964

    
965
replaceDiskSec :: String
966
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
967

    
968
replaceModes :: FrozenSet String
969
replaceModes =
970
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
971

    
972
-- * Instance export mode
973

    
974
exportModeLocal :: String
975
exportModeLocal = Types.exportModeToRaw ExportModeLocal
976

    
977
exportModeRemote :: String
978
exportModeRemote = Types.exportModeToRaw ExportModeRemote
979

    
980
exportModes :: FrozenSet String
981
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
982

    
983
-- * Instance creation modes
984

    
985
instanceCreate :: String
986
instanceCreate = Types.instCreateModeToRaw InstCreate
987

    
988
instanceImport :: String
989
instanceImport = Types.instCreateModeToRaw InstImport
990

    
991
instanceRemoteImport :: String
992
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
993

    
994
instanceCreateModes :: FrozenSet String
995
instanceCreateModes =
996
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
997

    
998
-- * Remote import/export handshake message and version
999

    
1000
rieHandshake :: String
1001
rieHandshake = "Hi, I'm Ganeti"
1002

    
1003
rieVersion :: Int
1004
rieVersion = 0
1005

    
1006
-- | Remote import/export certificate validity in seconds
1007
rieCertValidity :: Int
1008
rieCertValidity = 24 * 60 * 60
1009

    
1010
-- | Export only: how long to wait per connection attempt (seconds)
1011
rieConnectAttemptTimeout :: Int
1012
rieConnectAttemptTimeout = 20
1013

    
1014
-- | Export only: number of attempts to connect
1015
rieConnectRetries :: Int
1016
rieConnectRetries = 10
1017

    
1018
-- | Overall timeout for establishing connection
1019
rieConnectTimeout :: Int
1020
rieConnectTimeout = 180
1021

    
1022
-- | Give child process up to 5 seconds to exit after sending a signal
1023
childLingerTimeout :: Double
1024
childLingerTimeout = 5.0
1025

    
1026
-- * Import/export config options
1027

    
1028
inisectBep :: String
1029
inisectBep = "backend"
1030

    
1031
inisectExp :: String
1032
inisectExp = "export"
1033

    
1034
inisectHyp :: String
1035
inisectHyp = "hypervisor"
1036

    
1037
inisectIns :: String
1038
inisectIns = "instance"
1039

    
1040
inisectOsp :: String
1041
inisectOsp = "os"
1042

    
1043
-- * Dynamic device modification
1044

    
1045
ddmAdd :: String
1046
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1047

    
1048
ddmModify :: String
1049
ddmModify = Types.ddmFullToRaw DdmFullModify
1050

    
1051
ddmRemove :: String
1052
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1053

    
1054
ddmsValues :: FrozenSet String
1055
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1056

    
1057
ddmsValuesWithModify :: FrozenSet String
1058
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1059

    
1060
-- * Common exit codes
1061

    
1062
exitSuccess :: Int
1063
exitSuccess = 0
1064

    
1065
exitFailure :: Int
1066
exitFailure = ConstantUtils.exitFailure
1067

    
1068
exitNotcluster :: Int
1069
exitNotcluster = 5
1070

    
1071
exitNotmaster :: Int
1072
exitNotmaster = 11
1073

    
1074
exitNodesetupError :: Int
1075
exitNodesetupError = 12
1076

    
1077
-- | Need user confirmation
1078
exitConfirmation :: Int
1079
exitConfirmation = 13
1080

    
1081
-- | Exit code for query operations with unknown fields
1082
exitUnknownField :: Int
1083
exitUnknownField = 14
1084

    
1085
-- * Tags
1086

    
1087
tagCluster :: String
1088
tagCluster = Types.tagKindToRaw TagKindCluster
1089

    
1090
tagInstance :: String
1091
tagInstance = Types.tagKindToRaw TagKindInstance
1092

    
1093
tagNetwork :: String
1094
tagNetwork = Types.tagKindToRaw TagKindNetwork
1095

    
1096
tagNode :: String
1097
tagNode = Types.tagKindToRaw TagKindNode
1098

    
1099
tagNodegroup :: String
1100
tagNodegroup = Types.tagKindToRaw TagKindGroup
1101

    
1102
validTagTypes :: FrozenSet String
1103
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1104

    
1105
maxTagLen :: Int
1106
maxTagLen = 128
1107

    
1108
maxTagsPerObj :: Int
1109
maxTagsPerObj = 4096
1110

    
1111
-- * Others
1112

    
1113
defaultBridge :: String
1114
defaultBridge = "xen-br0"
1115

    
1116
defaultOvs :: String
1117
defaultOvs = "switch1"
1118

    
1119
-- | 60 MiB, expressed in KiB
1120
classicDrbdSyncSpeed :: Int
1121
classicDrbdSyncSpeed = 60 * 1024
1122

    
1123
ip4AddressAny :: String
1124
ip4AddressAny = "0.0.0.0"
1125

    
1126
ip4AddressLocalhost :: String
1127
ip4AddressLocalhost = "127.0.0.1"
1128

    
1129
ip6AddressAny :: String
1130
ip6AddressAny = "::"
1131

    
1132
ip6AddressLocalhost :: String
1133
ip6AddressLocalhost = "::1"
1134

    
1135
ip4Version :: Int
1136
ip4Version = 4
1137

    
1138
ip6Version :: Int
1139
ip6Version = 6
1140

    
1141
validIpVersions :: FrozenSet Int
1142
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1143

    
1144
tcpPingTimeout :: Int
1145
tcpPingTimeout = 10
1146

    
1147
defaultVg :: String
1148
defaultVg = "xenvg"
1149

    
1150
defaultDrbdHelper :: String
1151
defaultDrbdHelper = "/bin/true"
1152

    
1153
minVgSize :: Int
1154
minVgSize = 20480
1155

    
1156
defaultMacPrefix :: String
1157
defaultMacPrefix = "aa:00:00"
1158

    
1159
-- | Default maximum instance wait time, in seconds.
1160
defaultShutdownTimeout :: Int
1161
defaultShutdownTimeout = 120
1162

    
1163
-- | Node clock skew in seconds
1164
nodeMaxClockSkew :: Int
1165
nodeMaxClockSkew = 150
1166

    
1167
-- | Time for an intra-cluster disk transfer to wait for a connection
1168
diskTransferConnectTimeout :: Int
1169
diskTransferConnectTimeout = 60
1170

    
1171
-- | Disk index separator
1172
diskSeparator :: String
1173
diskSeparator = AutoConf.diskSeparator
1174

    
1175
ipCommandPath :: String
1176
ipCommandPath = AutoConf.ipPath
1177

    
1178
-- | Key for job IDs in opcode result
1179
jobIdsKey :: String
1180
jobIdsKey = "jobs"
1181

    
1182
-- * Runparts results
1183

    
1184
runpartsErr :: Int
1185
runpartsErr = 2
1186

    
1187
runpartsRun :: Int
1188
runpartsRun = 1
1189

    
1190
runpartsSkip :: Int
1191
runpartsSkip = 0
1192

    
1193
runpartsStatus :: [Int]
1194
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1195

    
1196
-- * RPC
1197

    
1198
rpcEncodingNone :: Int
1199
rpcEncodingNone = 0
1200

    
1201
rpcEncodingZlibBase64 :: Int
1202
rpcEncodingZlibBase64 = 1
1203

    
1204
-- * Timeout table
1205
--
1206
-- Various time constants for the timeout table
1207

    
1208
rpcTmoUrgent :: Int
1209
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1210

    
1211
rpcTmoFast :: Int
1212
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1213

    
1214
rpcTmoNormal :: Int
1215
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1216

    
1217
rpcTmoSlow :: Int
1218
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1219

    
1220
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1221
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1222
-- Python name.
1223
rpcTmo_4hrs :: Int
1224
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1225

    
1226
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1227
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1228
-- Python name.
1229
rpcTmo_1day :: Int
1230
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1231

    
1232
-- | Timeout for connecting to nodes (seconds)
1233
rpcConnectTimeout :: Int
1234
rpcConnectTimeout = 5
1235

    
1236
-- OS
1237

    
1238
osScriptCreate :: String
1239
osScriptCreate = "create"
1240

    
1241
osScriptExport :: String
1242
osScriptExport = "export"
1243

    
1244
osScriptImport :: String
1245
osScriptImport = "import"
1246

    
1247
osScriptRename :: String
1248
osScriptRename = "rename"
1249

    
1250
osScriptVerify :: String
1251
osScriptVerify = "verify"
1252

    
1253
osScripts :: [String]
1254
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1255
             osScriptVerify]
1256

    
1257
osApiFile :: String
1258
osApiFile = "ganeti_api_version"
1259

    
1260
osVariantsFile :: String
1261
osVariantsFile = "variants.list"
1262

    
1263
osParametersFile :: String
1264
osParametersFile = "parameters.list"
1265

    
1266
osValidateParameters :: String
1267
osValidateParameters = "parameters"
1268

    
1269
osValidateCalls :: FrozenSet String
1270
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1271

    
1272
-- | External Storage (ES) related constants
1273

    
1274
esActionAttach :: String
1275
esActionAttach = "attach"
1276

    
1277
esActionCreate :: String
1278
esActionCreate = "create"
1279

    
1280
esActionDetach :: String
1281
esActionDetach = "detach"
1282

    
1283
esActionGrow :: String
1284
esActionGrow = "grow"
1285

    
1286
esActionRemove :: String
1287
esActionRemove = "remove"
1288

    
1289
esActionSetinfo :: String
1290
esActionSetinfo = "setinfo"
1291

    
1292
esActionVerify :: String
1293
esActionVerify = "verify"
1294

    
1295
esScriptCreate :: String
1296
esScriptCreate = esActionCreate
1297

    
1298
esScriptRemove :: String
1299
esScriptRemove = esActionRemove
1300

    
1301
esScriptGrow :: String
1302
esScriptGrow = esActionGrow
1303

    
1304
esScriptAttach :: String
1305
esScriptAttach = esActionAttach
1306

    
1307
esScriptDetach :: String
1308
esScriptDetach = esActionDetach
1309

    
1310
esScriptSetinfo :: String
1311
esScriptSetinfo = esActionSetinfo
1312

    
1313
esScriptVerify :: String
1314
esScriptVerify = esActionVerify
1315

    
1316
esScripts :: FrozenSet String
1317
esScripts =
1318
  ConstantUtils.mkSet [esScriptAttach,
1319
                       esScriptCreate,
1320
                       esScriptDetach,
1321
                       esScriptGrow,
1322
                       esScriptRemove,
1323
                       esScriptSetinfo,
1324
                       esScriptVerify]
1325

    
1326
esParametersFile :: String
1327
esParametersFile = "parameters.list"
1328

    
1329
-- * Reboot types
1330

    
1331
instanceRebootSoft :: String
1332
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1333

    
1334
instanceRebootHard :: String
1335
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1336

    
1337
instanceRebootFull :: String
1338
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1339

    
1340
rebootTypes :: FrozenSet String
1341
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1342

    
1343
-- * Instance reboot behaviors
1344

    
1345
instanceRebootAllowed :: String
1346
instanceRebootAllowed = "reboot"
1347

    
1348
instanceRebootExit :: String
1349
instanceRebootExit = "exit"
1350

    
1351
rebootBehaviors :: [String]
1352
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1353

    
1354
-- * VTypes
1355

    
1356
vtypeBool :: VType
1357
vtypeBool = VTypeBool
1358

    
1359
vtypeInt :: VType
1360
vtypeInt = VTypeInt
1361

    
1362
vtypeMaybeString :: VType
1363
vtypeMaybeString = VTypeMaybeString
1364

    
1365
-- | Size in MiBs
1366
vtypeSize :: VType
1367
vtypeSize = VTypeSize
1368

    
1369
vtypeString :: VType
1370
vtypeString = VTypeString
1371

    
1372
enforceableTypes :: FrozenSet VType
1373
enforceableTypes = ConstantUtils.mkSet [minBound..]
1374

    
1375
-- | Constant representing that the user does not specify any IP version
1376
ifaceNoIpVersionSpecified :: Int
1377
ifaceNoIpVersionSpecified = 0
1378

    
1379
validSerialSpeeds :: [Int]
1380
validSerialSpeeds =
1381
  [75,
1382
   110,
1383
   300,
1384
   600,
1385
   1200,
1386
   1800,
1387
   2400,
1388
   4800,
1389
   9600,
1390
   14400,
1391
   19200,
1392
   28800,
1393
   38400,
1394
   57600,
1395
   115200,
1396
   230400,
1397
   345600,
1398
   460800]
1399

    
1400
-- * HV parameter names (global namespace)
1401

    
1402
hvAcpi :: String
1403
hvAcpi = "acpi"
1404

    
1405
hvBlockdevPrefix :: String
1406
hvBlockdevPrefix = "blockdev_prefix"
1407

    
1408
hvBootloaderArgs :: String
1409
hvBootloaderArgs = "bootloader_args"
1410

    
1411
hvBootloaderPath :: String
1412
hvBootloaderPath = "bootloader_path"
1413

    
1414
hvBootOrder :: String
1415
hvBootOrder = "boot_order"
1416

    
1417
hvCdromImagePath :: String
1418
hvCdromImagePath = "cdrom_image_path"
1419

    
1420
hvCpuCap :: String
1421
hvCpuCap = "cpu_cap"
1422

    
1423
hvCpuCores :: String
1424
hvCpuCores = "cpu_cores"
1425

    
1426
hvCpuMask :: String
1427
hvCpuMask = "cpu_mask"
1428

    
1429
hvCpuSockets :: String
1430
hvCpuSockets = "cpu_sockets"
1431

    
1432
hvCpuThreads :: String
1433
hvCpuThreads = "cpu_threads"
1434

    
1435
hvCpuType :: String
1436
hvCpuType = "cpu_type"
1437

    
1438
hvCpuWeight :: String
1439
hvCpuWeight = "cpu_weight"
1440

    
1441
hvDeviceModel :: String
1442
hvDeviceModel = "device_model"
1443

    
1444
hvDiskCache :: String
1445
hvDiskCache = "disk_cache"
1446

    
1447
hvDiskType :: String
1448
hvDiskType = "disk_type"
1449

    
1450
hvInitrdPath :: String
1451
hvInitrdPath = "initrd_path"
1452

    
1453
hvInitScript :: String
1454
hvInitScript = "init_script"
1455

    
1456
hvKernelArgs :: String
1457
hvKernelArgs = "kernel_args"
1458

    
1459
hvKernelPath :: String
1460
hvKernelPath = "kernel_path"
1461

    
1462
hvKeymap :: String
1463
hvKeymap = "keymap"
1464

    
1465
hvKvmCdrom2ImagePath :: String
1466
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1467

    
1468
hvKvmCdromDiskType :: String
1469
hvKvmCdromDiskType = "cdrom_disk_type"
1470

    
1471
hvKvmExtra :: String
1472
hvKvmExtra = "kvm_extra"
1473

    
1474
hvKvmFlag :: String
1475
hvKvmFlag = "kvm_flag"
1476

    
1477
hvKvmFloppyImagePath :: String
1478
hvKvmFloppyImagePath = "floppy_image_path"
1479

    
1480
hvKvmMachineVersion :: String
1481
hvKvmMachineVersion = "machine_version"
1482

    
1483
hvKvmPath :: String
1484
hvKvmPath = "kvm_path"
1485

    
1486
hvKvmSpiceAudioCompr :: String
1487
hvKvmSpiceAudioCompr = "spice_playback_compression"
1488

    
1489
hvKvmSpiceBind :: String
1490
hvKvmSpiceBind = "spice_bind"
1491

    
1492
hvKvmSpiceIpVersion :: String
1493
hvKvmSpiceIpVersion = "spice_ip_version"
1494

    
1495
hvKvmSpiceJpegImgCompr :: String
1496
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1497

    
1498
hvKvmSpiceLosslessImgCompr :: String
1499
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1500

    
1501
hvKvmSpicePasswordFile :: String
1502
hvKvmSpicePasswordFile = "spice_password_file"
1503

    
1504
hvKvmSpiceStreamingVideoDetection :: String
1505
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1506

    
1507
hvKvmSpiceTlsCiphers :: String
1508
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1509

    
1510
hvKvmSpiceUseTls :: String
1511
hvKvmSpiceUseTls = "spice_use_tls"
1512

    
1513
hvKvmSpiceUseVdagent :: String
1514
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1515

    
1516
hvKvmSpiceZlibGlzImgCompr :: String
1517
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1518

    
1519
hvKvmUseChroot :: String
1520
hvKvmUseChroot = "use_chroot"
1521

    
1522
hvMemPath :: String
1523
hvMemPath = "mem_path"
1524

    
1525
hvMigrationBandwidth :: String
1526
hvMigrationBandwidth = "migration_bandwidth"
1527

    
1528
hvMigrationDowntime :: String
1529
hvMigrationDowntime = "migration_downtime"
1530

    
1531
hvMigrationMode :: String
1532
hvMigrationMode = "migration_mode"
1533

    
1534
hvMigrationPort :: String
1535
hvMigrationPort = "migration_port"
1536

    
1537
hvNicType :: String
1538
hvNicType = "nic_type"
1539

    
1540
hvPae :: String
1541
hvPae = "pae"
1542

    
1543
hvPassthrough :: String
1544
hvPassthrough = "pci_pass"
1545

    
1546
hvRebootBehavior :: String
1547
hvRebootBehavior = "reboot_behavior"
1548

    
1549
hvRootPath :: String
1550
hvRootPath = "root_path"
1551

    
1552
hvSecurityDomain :: String
1553
hvSecurityDomain = "security_domain"
1554

    
1555
hvSecurityModel :: String
1556
hvSecurityModel = "security_model"
1557

    
1558
hvSerialConsole :: String
1559
hvSerialConsole = "serial_console"
1560

    
1561
hvSerialSpeed :: String
1562
hvSerialSpeed = "serial_speed"
1563

    
1564
hvSoundhw :: String
1565
hvSoundhw = "soundhw"
1566

    
1567
hvUsbDevices :: String
1568
hvUsbDevices = "usb_devices"
1569

    
1570
hvUsbMouse :: String
1571
hvUsbMouse = "usb_mouse"
1572

    
1573
hvUseBootloader :: String
1574
hvUseBootloader = "use_bootloader"
1575

    
1576
hvUseLocaltime :: String
1577
hvUseLocaltime = "use_localtime"
1578

    
1579
hvVga :: String
1580
hvVga = "vga"
1581

    
1582
hvVhostNet :: String
1583
hvVhostNet = "vhost_net"
1584

    
1585
hvVifScript :: String
1586
hvVifScript = "vif_script"
1587

    
1588
hvVifType :: String
1589
hvVifType = "vif_type"
1590

    
1591
hvViridian :: String
1592
hvViridian = "viridian"
1593

    
1594
hvVncBindAddress :: String
1595
hvVncBindAddress = "vnc_bind_address"
1596

    
1597
hvVncPasswordFile :: String
1598
hvVncPasswordFile = "vnc_password_file"
1599

    
1600
hvVncTls :: String
1601
hvVncTls = "vnc_tls"
1602

    
1603
hvVncX509 :: String
1604
hvVncX509 = "vnc_x509_path"
1605

    
1606
hvVncX509Verify :: String
1607
hvVncX509Verify = "vnc_x509_verify"
1608

    
1609
hvVnetHdr :: String
1610
hvVnetHdr = "vnet_hdr"
1611

    
1612
hvXenCmd :: String
1613
hvXenCmd = "xen_cmd"
1614

    
1615
hvXenCpuid :: String
1616
hvXenCpuid = "cpuid"
1617

    
1618
hvsParameterTitles :: Map String String
1619
hvsParameterTitles =
1620
  Map.fromList
1621
  [(hvAcpi, "ACPI"),
1622
   (hvBootOrder, "Boot_order"),
1623
   (hvCdromImagePath, "CDROM_image_path"),
1624
   (hvCpuType, "cpu_type"),
1625
   (hvDiskType, "Disk_type"),
1626
   (hvInitrdPath, "Initrd_path"),
1627
   (hvKernelPath, "Kernel_path"),
1628
   (hvNicType, "NIC_type"),
1629
   (hvPae, "PAE"),
1630
   (hvPassthrough, "pci_pass"),
1631
   (hvVncBindAddress, "VNC_bind_address")]
1632

    
1633
-- * Migration statuses
1634

    
1635
hvMigrationActive :: String
1636
hvMigrationActive = "active"
1637

    
1638
hvMigrationCancelled :: String
1639
hvMigrationCancelled = "cancelled"
1640

    
1641
hvMigrationCompleted :: String
1642
hvMigrationCompleted = "completed"
1643

    
1644
hvMigrationFailed :: String
1645
hvMigrationFailed = "failed"
1646

    
1647
hvMigrationValidStatuses :: FrozenSet String
1648
hvMigrationValidStatuses =
1649
  ConstantUtils.mkSet [hvMigrationActive,
1650
                       hvMigrationCancelled,
1651
                       hvMigrationCompleted,
1652
                       hvMigrationFailed]
1653

    
1654
hvMigrationFailedStatuses :: FrozenSet String
1655
hvMigrationFailedStatuses =
1656
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1657

    
1658
-- | KVM-specific statuses
1659
--
1660
-- FIXME: this constant seems unnecessary
1661
hvKvmMigrationValidStatuses :: FrozenSet String
1662
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1663

    
1664
-- | Node info keys
1665
hvNodeinfoKeyVersion :: String
1666
hvNodeinfoKeyVersion = "hv_version"
1667

    
1668
-- * Hypervisor state
1669

    
1670
hvstCpuNode :: String
1671
hvstCpuNode = "cpu_node"
1672

    
1673
hvstCpuTotal :: String
1674
hvstCpuTotal = "cpu_total"
1675

    
1676
hvstMemoryHv :: String
1677
hvstMemoryHv = "mem_hv"
1678

    
1679
hvstMemoryNode :: String
1680
hvstMemoryNode = "mem_node"
1681

    
1682
hvstMemoryTotal :: String
1683
hvstMemoryTotal = "mem_total"
1684

    
1685
hvstsParameters :: FrozenSet String
1686
hvstsParameters =
1687
  ConstantUtils.mkSet [hvstCpuNode,
1688
                       hvstCpuTotal,
1689
                       hvstMemoryHv,
1690
                       hvstMemoryNode,
1691
                       hvstMemoryTotal]
1692

    
1693
hvstDefaults :: Map String Int
1694
hvstDefaults =
1695
  Map.fromList
1696
  [(hvstCpuNode, 1),
1697
   (hvstCpuTotal, 1),
1698
   (hvstMemoryHv, 0),
1699
   (hvstMemoryTotal, 0),
1700
   (hvstMemoryNode, 0)]
1701

    
1702
hvstsParameterTypes :: Map String VType
1703
hvstsParameterTypes =
1704
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1705
                (hvstMemoryNode, VTypeInt),
1706
                (hvstMemoryHv, VTypeInt),
1707
                (hvstCpuTotal, VTypeInt),
1708
                (hvstCpuNode, VTypeInt)]
1709

    
1710
-- * Disk state
1711

    
1712
dsDiskOverhead :: String
1713
dsDiskOverhead = "disk_overhead"
1714

    
1715
dsDiskReserved :: String
1716
dsDiskReserved = "disk_reserved"
1717

    
1718
dsDiskTotal :: String
1719
dsDiskTotal = "disk_total"
1720

    
1721
dsDefaults :: Map String Int
1722
dsDefaults =
1723
  Map.fromList
1724
  [(dsDiskTotal, 0),
1725
   (dsDiskReserved, 0),
1726
   (dsDiskOverhead, 0)]
1727

    
1728
dssParameterTypes :: Map String VType
1729
dssParameterTypes =
1730
  Map.fromList [(dsDiskTotal, VTypeInt),
1731
                (dsDiskReserved, VTypeInt),
1732
                (dsDiskOverhead, VTypeInt)]
1733

    
1734
dssParameters :: FrozenSet String
1735
dssParameters =
1736
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1737

    
1738
dsValidTypes :: FrozenSet String
1739
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1740

    
1741
-- Backend parameter names
1742

    
1743
beAlwaysFailover :: String
1744
beAlwaysFailover = "always_failover"
1745

    
1746
beAutoBalance :: String
1747
beAutoBalance = "auto_balance"
1748

    
1749
beMaxmem :: String
1750
beMaxmem = "maxmem"
1751

    
1752
-- | Deprecated and replaced by max and min mem
1753
beMemory :: String
1754
beMemory = "memory"
1755

    
1756
beMinmem :: String
1757
beMinmem = "minmem"
1758

    
1759
beSpindleUse :: String
1760
beSpindleUse = "spindle_use"
1761

    
1762
beVcpus :: String
1763
beVcpus = "vcpus"
1764

    
1765
besParameterTypes :: Map String VType
1766
besParameterTypes =
1767
  Map.fromList [(beAlwaysFailover, VTypeBool),
1768
                (beAutoBalance, VTypeBool),
1769
                (beMaxmem, VTypeSize),
1770
                (beMinmem, VTypeSize),
1771
                (beSpindleUse, VTypeInt),
1772
                (beVcpus, VTypeInt)]
1773

    
1774
besParameterTitles :: Map String String
1775
besParameterTitles =
1776
  Map.fromList [(beAutoBalance, "Auto_balance"),
1777
                (beMinmem, "ConfigMinMem"),
1778
                (beVcpus, "ConfigVCPUs"),
1779
                (beMaxmem, "ConfigMaxMem")]
1780

    
1781
besParameterCompat :: Map String VType
1782
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1783

    
1784
besParameters :: FrozenSet String
1785
besParameters =
1786
  ConstantUtils.mkSet [beAlwaysFailover,
1787
                       beAutoBalance,
1788
                       beMaxmem,
1789
                       beMinmem,
1790
                       beSpindleUse,
1791
                       beVcpus]
1792

    
1793
-- | Instance specs
1794
--
1795
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1796

    
1797
ispecMemSize :: String
1798
ispecMemSize = ConstantUtils.ispecMemSize
1799

    
1800
ispecCpuCount :: String
1801
ispecCpuCount = ConstantUtils.ispecCpuCount
1802

    
1803
ispecDiskCount :: String
1804
ispecDiskCount = ConstantUtils.ispecDiskCount
1805

    
1806
ispecDiskSize :: String
1807
ispecDiskSize = ConstantUtils.ispecDiskSize
1808

    
1809
ispecNicCount :: String
1810
ispecNicCount = ConstantUtils.ispecNicCount
1811

    
1812
ispecSpindleUse :: String
1813
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1814

    
1815
ispecsParameterTypes :: Map String VType
1816
ispecsParameterTypes =
1817
  Map.fromList
1818
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1819
   (ConstantUtils.ispecCpuCount, VTypeInt),
1820
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1821
   (ConstantUtils.ispecMemSize, VTypeInt),
1822
   (ConstantUtils.ispecNicCount, VTypeInt),
1823
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1824

    
1825
ispecsParameters :: FrozenSet String
1826
ispecsParameters =
1827
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1828
                       ConstantUtils.ispecDiskCount,
1829
                       ConstantUtils.ispecDiskSize,
1830
                       ConstantUtils.ispecMemSize,
1831
                       ConstantUtils.ispecNicCount,
1832
                       ConstantUtils.ispecSpindleUse]
1833

    
1834
ispecsMinmax :: String
1835
ispecsMinmax = ConstantUtils.ispecsMinmax
1836

    
1837
ispecsMax :: String
1838
ispecsMax = "max"
1839

    
1840
ispecsMin :: String
1841
ispecsMin = "min"
1842

    
1843
ispecsStd :: String
1844
ispecsStd = ConstantUtils.ispecsStd
1845

    
1846
ipolicyDts :: String
1847
ipolicyDts = ConstantUtils.ipolicyDts
1848

    
1849
ipolicyVcpuRatio :: String
1850
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1851

    
1852
ipolicySpindleRatio :: String
1853
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
1854

    
1855
ispecsMinmaxKeys :: FrozenSet String
1856
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1857

    
1858
ipolicyParameters :: FrozenSet String
1859
ipolicyParameters =
1860
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1861
                       ConstantUtils.ipolicySpindleRatio]
1862

    
1863
ipolicyAllKeys :: FrozenSet String
1864
ipolicyAllKeys =
1865
  ConstantUtils.union ipolicyParameters $
1866
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1867
                       ConstantUtils.ispecsMinmax,
1868
                       ispecsStd]
1869

    
1870
-- | Node parameter names
1871

    
1872
ndExclusiveStorage :: String
1873
ndExclusiveStorage = "exclusive_storage"
1874

    
1875
ndOobProgram :: String
1876
ndOobProgram = "oob_program"
1877

    
1878
ndSpindleCount :: String
1879
ndSpindleCount = "spindle_count"
1880

    
1881
ndOvs :: String
1882
ndOvs = "ovs"
1883

    
1884
ndOvsLink :: String
1885
ndOvsLink = "ovs_link"
1886

    
1887
ndOvsName :: String
1888
ndOvsName = "ovs_name"
1889

    
1890
ndsParameterTypes :: Map String VType
1891
ndsParameterTypes =
1892
  Map.fromList
1893
  [(ndExclusiveStorage, VTypeBool),
1894
   (ndOobProgram, VTypeString),
1895
   (ndOvs, VTypeBool),
1896
   (ndOvsLink, VTypeMaybeString),
1897
   (ndOvsName, VTypeMaybeString),
1898
   (ndSpindleCount, VTypeInt)]
1899

    
1900
ndsParameters :: FrozenSet String
1901
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
1902

    
1903
ndsParameterTitles :: Map String String
1904
ndsParameterTitles =
1905
  Map.fromList
1906
  [(ndExclusiveStorage, "ExclusiveStorage"),
1907
   (ndOobProgram, "OutOfBandProgram"),
1908
   (ndOvs, "OpenvSwitch"),
1909
   (ndOvsLink, "OpenvSwitchLink"),
1910
   (ndOvsName, "OpenvSwitchName"),
1911
   (ndSpindleCount, "SpindleCount")]
1912

    
1913
-- * Logical Disks parameters
1914

    
1915
ldpAccess :: String
1916
ldpAccess = "access"
1917

    
1918
ldpBarriers :: String
1919
ldpBarriers = "disabled-barriers"
1920

    
1921
ldpDefaultMetavg :: String
1922
ldpDefaultMetavg = "default-metavg"
1923

    
1924
ldpDelayTarget :: String
1925
ldpDelayTarget = "c-delay-target"
1926

    
1927
ldpDiskCustom :: String
1928
ldpDiskCustom = "disk-custom"
1929

    
1930
ldpDynamicResync :: String
1931
ldpDynamicResync = "dynamic-resync"
1932

    
1933
ldpFillTarget :: String
1934
ldpFillTarget = "c-fill-target"
1935

    
1936
ldpMaxRate :: String
1937
ldpMaxRate = "c-max-rate"
1938

    
1939
ldpMinRate :: String
1940
ldpMinRate = "c-min-rate"
1941

    
1942
ldpNetCustom :: String
1943
ldpNetCustom = "net-custom"
1944

    
1945
ldpNoMetaFlush :: String
1946
ldpNoMetaFlush = "disable-meta-flush"
1947

    
1948
ldpPlanAhead :: String
1949
ldpPlanAhead = "c-plan-ahead"
1950

    
1951
ldpPool :: String
1952
ldpPool = "pool"
1953

    
1954
ldpProtocol :: String
1955
ldpProtocol = "protocol"
1956

    
1957
ldpResyncRate :: String
1958
ldpResyncRate = "resync-rate"
1959

    
1960
ldpStripes :: String
1961
ldpStripes = "stripes"
1962

    
1963
diskLdTypes :: Map String VType
1964
diskLdTypes =
1965
  Map.fromList
1966
  [(ldpAccess, VTypeString),
1967
   (ldpResyncRate, VTypeInt),
1968
   (ldpStripes, VTypeInt),
1969
   (ldpBarriers, VTypeString),
1970
   (ldpNoMetaFlush, VTypeBool),
1971
   (ldpDefaultMetavg, VTypeString),
1972
   (ldpDiskCustom, VTypeString),
1973
   (ldpNetCustom, VTypeString),
1974
   (ldpProtocol, VTypeString),
1975
   (ldpDynamicResync, VTypeBool),
1976
   (ldpPlanAhead, VTypeInt),
1977
   (ldpFillTarget, VTypeInt),
1978
   (ldpDelayTarget, VTypeInt),
1979
   (ldpMaxRate, VTypeInt),
1980
   (ldpMinRate, VTypeInt),
1981
   (ldpPool, VTypeString)]
1982

    
1983
diskLdParameters :: FrozenSet String
1984
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
1985

    
1986
-- * Disk template parameters
1987
--
1988
-- Disk template parameters can be set/changed by the user via
1989
-- gnt-cluster and gnt-group)
1990

    
1991
drbdResyncRate :: String
1992
drbdResyncRate = "resync-rate"
1993

    
1994
drbdDataStripes :: String
1995
drbdDataStripes = "data-stripes"
1996

    
1997
drbdMetaStripes :: String
1998
drbdMetaStripes = "meta-stripes"
1999

    
2000
drbdDiskBarriers :: String
2001
drbdDiskBarriers = "disk-barriers"
2002

    
2003
drbdMetaBarriers :: String
2004
drbdMetaBarriers = "meta-barriers"
2005

    
2006
drbdDefaultMetavg :: String
2007
drbdDefaultMetavg = "metavg"
2008

    
2009
drbdDiskCustom :: String
2010
drbdDiskCustom = "disk-custom"
2011

    
2012
drbdNetCustom :: String
2013
drbdNetCustom = "net-custom"
2014

    
2015
drbdProtocol :: String
2016
drbdProtocol = "protocol"
2017

    
2018
drbdDynamicResync :: String
2019
drbdDynamicResync = "dynamic-resync"
2020

    
2021
drbdPlanAhead :: String
2022
drbdPlanAhead = "c-plan-ahead"
2023

    
2024
drbdFillTarget :: String
2025
drbdFillTarget = "c-fill-target"
2026

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

    
2030
drbdMaxRate :: String
2031
drbdMaxRate = "c-max-rate"
2032

    
2033
drbdMinRate :: String
2034
drbdMinRate = "c-min-rate"
2035

    
2036
lvStripes :: String
2037
lvStripes = "stripes"
2038

    
2039
rbdAccess :: String
2040
rbdAccess = "access"
2041

    
2042
rbdPool :: String
2043
rbdPool = "pool"
2044

    
2045
diskDtTypes :: Map String VType
2046
diskDtTypes =
2047
  Map.fromList [(drbdResyncRate, VTypeInt),
2048
                (drbdDataStripes, VTypeInt),
2049
                (drbdMetaStripes, VTypeInt),
2050
                (drbdDiskBarriers, VTypeString),
2051
                (drbdMetaBarriers, VTypeBool),
2052
                (drbdDefaultMetavg, VTypeString),
2053
                (drbdDiskCustom, VTypeString),
2054
                (drbdNetCustom, VTypeString),
2055
                (drbdProtocol, VTypeString),
2056
                (drbdDynamicResync, VTypeBool),
2057
                (drbdPlanAhead, VTypeInt),
2058
                (drbdFillTarget, VTypeInt),
2059
                (drbdDelayTarget, VTypeInt),
2060
                (drbdMaxRate, VTypeInt),
2061
                (drbdMinRate, VTypeInt),
2062
                (lvStripes, VTypeInt),
2063
                (rbdAccess, VTypeString),
2064
                (rbdPool, VTypeString)]
2065

    
2066
diskDtParameters :: FrozenSet String
2067
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2068

    
2069
-- * Dynamic disk parameters
2070

    
2071
ddpLocalIp :: String
2072
ddpLocalIp = "local-ip"
2073

    
2074
ddpRemoteIp :: String
2075
ddpRemoteIp = "remote-ip"
2076

    
2077
ddpPort :: String
2078
ddpPort = "port"
2079

    
2080
ddpLocalMinor :: String
2081
ddpLocalMinor = "local-minor"
2082

    
2083
ddpRemoteMinor :: String
2084
ddpRemoteMinor = "remote-minor"
2085

    
2086
-- * OOB supported commands
2087

    
2088
oobPowerOn :: String
2089
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2090

    
2091
oobPowerOff :: String
2092
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2093

    
2094
oobPowerCycle :: String
2095
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2096

    
2097
oobPowerStatus :: String
2098
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2099

    
2100
oobHealth :: String
2101
oobHealth = Types.oobCommandToRaw OobHealth
2102

    
2103
oobCommands :: FrozenSet String
2104
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2105

    
2106
oobPowerStatusPowered :: String
2107
oobPowerStatusPowered = "powered"
2108

    
2109
-- | 60 seconds
2110
oobTimeout :: Int
2111
oobTimeout = 60
2112

    
2113
-- | 2 seconds
2114
oobPowerDelay :: Double
2115
oobPowerDelay = 2.0
2116

    
2117
oobStatusCritical :: String
2118
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2119

    
2120
oobStatusOk :: String
2121
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2122

    
2123
oobStatusUnknown :: String
2124
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2125

    
2126
oobStatusWarning :: String
2127
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2128

    
2129
oobStatuses :: FrozenSet String
2130
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2131

    
2132
-- | Instance Parameters Profile
2133
ppDefault :: String
2134
ppDefault = "default"
2135

    
2136
-- * nic* constants are used inside the ganeti config
2137

    
2138
nicLink :: String
2139
nicLink = "link"
2140

    
2141
nicMode :: String
2142
nicMode = "mode"
2143

    
2144
nicVlan :: String
2145
nicVlan = "vlan"
2146

    
2147
nicsParameterTypes :: Map String VType
2148
nicsParameterTypes =
2149
  Map.fromList [(nicMode, vtypeString),
2150
                (nicLink, vtypeString),
2151
                (nicVlan, vtypeMaybeString)]
2152

    
2153
nicsParameters :: FrozenSet String
2154
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2155

    
2156
nicModeBridged :: String
2157
nicModeBridged = Types.nICModeToRaw NMBridged
2158

    
2159
nicModeRouted :: String
2160
nicModeRouted = Types.nICModeToRaw NMRouted
2161

    
2162
nicModeOvs :: String
2163
nicModeOvs = Types.nICModeToRaw NMOvs
2164

    
2165
nicIpPool :: String
2166
nicIpPool = Types.nICModeToRaw NMPool
2167

    
2168
nicValidModes :: FrozenSet String
2169
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2170

    
2171
releaseAction :: String
2172
releaseAction = "release"
2173

    
2174
reserveAction :: String
2175
reserveAction = "reserve"
2176

    
2177
-- * idisk* constants are used in opcodes, to create/change disks
2178

    
2179
idiskAdopt :: String
2180
idiskAdopt = "adopt"
2181

    
2182
idiskMetavg :: String
2183
idiskMetavg = "metavg"
2184

    
2185
idiskMode :: String
2186
idiskMode = "mode"
2187

    
2188
idiskName :: String
2189
idiskName = "name"
2190

    
2191
idiskSize :: String
2192
idiskSize = "size"
2193

    
2194
idiskSpindles :: String
2195
idiskSpindles = "spindles"
2196

    
2197
idiskVg :: String
2198
idiskVg = "vg"
2199

    
2200
idiskProvider :: String
2201
idiskProvider = "provider"
2202

    
2203
idiskParamsTypes :: Map String VType
2204
idiskParamsTypes =
2205
  Map.fromList [(idiskSize, VTypeSize),
2206
                (idiskSpindles, VTypeInt),
2207
                (idiskMode, VTypeString),
2208
                (idiskAdopt, VTypeString),
2209
                (idiskVg, VTypeString),
2210
                (idiskMetavg, VTypeString),
2211
                (idiskProvider, VTypeString),
2212
                (idiskName, VTypeMaybeString)]
2213

    
2214
idiskParams :: FrozenSet String
2215
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2216

    
2217
-- * inic* constants are used in opcodes, to create/change nics
2218

    
2219
inicBridge :: String
2220
inicBridge = "bridge"
2221

    
2222
inicIp :: String
2223
inicIp = "ip"
2224

    
2225
inicLink :: String
2226
inicLink = "link"
2227

    
2228
inicMac :: String
2229
inicMac = "mac"
2230

    
2231
inicMode :: String
2232
inicMode = "mode"
2233

    
2234
inicName :: String
2235
inicName = "name"
2236

    
2237
inicNetwork :: String
2238
inicNetwork = "network"
2239

    
2240
inicVlan :: String
2241
inicVlan = "vlan"
2242

    
2243
inicParamsTypes :: Map String VType
2244
inicParamsTypes =
2245
  Map.fromList [(inicBridge, VTypeMaybeString),
2246
                (inicIp, VTypeMaybeString),
2247
                (inicLink, VTypeString),
2248
                (inicMac, VTypeString),
2249
                (inicMode, VTypeString),
2250
                (inicName, VTypeMaybeString),
2251
                (inicNetwork, VTypeMaybeString),
2252
                (inicVlan, VTypeMaybeString)]
2253

    
2254
inicParams :: FrozenSet String
2255
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2256

    
2257
-- * Hypervisor constants
2258

    
2259
htXenPvm :: String
2260
htXenPvm = Types.hypervisorToRaw XenPvm
2261

    
2262
htFake :: String
2263
htFake = Types.hypervisorToRaw Fake
2264

    
2265
htXenHvm :: String
2266
htXenHvm = Types.hypervisorToRaw XenHvm
2267

    
2268
htKvm :: String
2269
htKvm = Types.hypervisorToRaw Kvm
2270

    
2271
htChroot :: String
2272
htChroot = Types.hypervisorToRaw Chroot
2273

    
2274
htLxc :: String
2275
htLxc = Types.hypervisorToRaw Lxc
2276

    
2277
hyperTypes :: FrozenSet String
2278
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2279

    
2280
htsReqPort :: FrozenSet String
2281
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2282

    
2283
vncBasePort :: Int
2284
vncBasePort = 5900
2285

    
2286
vncDefaultBindAddress :: String
2287
vncDefaultBindAddress = ip4AddressAny
2288

    
2289
-- * NIC types
2290

    
2291
htNicE1000 :: String
2292
htNicE1000 = "e1000"
2293

    
2294
htNicI82551 :: String
2295
htNicI82551 = "i82551"
2296

    
2297
htNicI8259er :: String
2298
htNicI8259er = "i82559er"
2299

    
2300
htNicI85557b :: String
2301
htNicI85557b = "i82557b"
2302

    
2303
htNicNe2kIsa :: String
2304
htNicNe2kIsa = "ne2k_isa"
2305

    
2306
htNicNe2kPci :: String
2307
htNicNe2kPci = "ne2k_pci"
2308

    
2309
htNicParavirtual :: String
2310
htNicParavirtual = "paravirtual"
2311

    
2312
htNicPcnet :: String
2313
htNicPcnet = "pcnet"
2314

    
2315
htNicRtl8139 :: String
2316
htNicRtl8139 = "rtl8139"
2317

    
2318
htHvmValidNicTypes :: FrozenSet String
2319
htHvmValidNicTypes =
2320
  ConstantUtils.mkSet [htNicE1000,
2321
                       htNicNe2kIsa,
2322
                       htNicNe2kPci,
2323
                       htNicParavirtual,
2324
                       htNicRtl8139]
2325

    
2326
htKvmValidNicTypes :: FrozenSet String
2327
htKvmValidNicTypes =
2328
  ConstantUtils.mkSet [htNicE1000,
2329
                       htNicI82551,
2330
                       htNicI8259er,
2331
                       htNicI85557b,
2332
                       htNicNe2kIsa,
2333
                       htNicNe2kPci,
2334
                       htNicParavirtual,
2335
                       htNicPcnet,
2336
                       htNicRtl8139]
2337

    
2338
-- * Vif types
2339

    
2340
-- | Default vif type in xen-hvm
2341
htHvmVifIoemu :: String
2342
htHvmVifIoemu = "ioemu"
2343

    
2344
htHvmVifVif :: String
2345
htHvmVifVif = "vif"
2346

    
2347
htHvmValidVifTypes :: FrozenSet String
2348
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2349

    
2350
-- * Disk types
2351

    
2352
htDiskIde :: String
2353
htDiskIde = "ide"
2354

    
2355
htDiskIoemu :: String
2356
htDiskIoemu = "ioemu"
2357

    
2358
htDiskMtd :: String
2359
htDiskMtd = "mtd"
2360

    
2361
htDiskParavirtual :: String
2362
htDiskParavirtual = "paravirtual"
2363

    
2364
htDiskPflash :: String
2365
htDiskPflash = "pflash"
2366

    
2367
htDiskScsi :: String
2368
htDiskScsi = "scsi"
2369

    
2370
htDiskSd :: String
2371
htDiskSd = "sd"
2372

    
2373
htHvmValidDiskTypes :: FrozenSet String
2374
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2375

    
2376
htKvmValidDiskTypes :: FrozenSet String
2377
htKvmValidDiskTypes =
2378
  ConstantUtils.mkSet [htDiskIde,
2379
                       htDiskMtd,
2380
                       htDiskParavirtual,
2381
                       htDiskPflash,
2382
                       htDiskScsi,
2383
                       htDiskSd]
2384

    
2385
htCacheDefault :: String
2386
htCacheDefault = "default"
2387

    
2388
htCacheNone :: String
2389
htCacheNone = "none"
2390

    
2391
htCacheWback :: String
2392
htCacheWback = "writeback"
2393

    
2394
htCacheWthrough :: String
2395
htCacheWthrough = "writethrough"
2396

    
2397
htValidCacheTypes :: FrozenSet String
2398
htValidCacheTypes =
2399
  ConstantUtils.mkSet [htCacheDefault,
2400
                       htCacheNone,
2401
                       htCacheWback,
2402
                       htCacheWthrough]
2403

    
2404
-- * Mouse types
2405

    
2406
htMouseMouse :: String
2407
htMouseMouse = "mouse"
2408

    
2409
htMouseTablet :: String
2410
htMouseTablet = "tablet"
2411

    
2412
htKvmValidMouseTypes :: FrozenSet String
2413
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2414

    
2415
-- * Boot order
2416

    
2417
htBoCdrom :: String
2418
htBoCdrom = "cdrom"
2419

    
2420
htBoDisk :: String
2421
htBoDisk = "disk"
2422

    
2423
htBoFloppy :: String
2424
htBoFloppy = "floppy"
2425

    
2426
htBoNetwork :: String
2427
htBoNetwork = "network"
2428

    
2429
htKvmValidBoTypes :: FrozenSet String
2430
htKvmValidBoTypes =
2431
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2432

    
2433
-- * SPICE lossless image compression options
2434

    
2435
htKvmSpiceLosslessImgComprAutoGlz :: String
2436
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2437

    
2438
htKvmSpiceLosslessImgComprAutoLz :: String
2439
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2440

    
2441
htKvmSpiceLosslessImgComprGlz :: String
2442
htKvmSpiceLosslessImgComprGlz = "glz"
2443

    
2444
htKvmSpiceLosslessImgComprLz :: String
2445
htKvmSpiceLosslessImgComprLz = "lz"
2446

    
2447
htKvmSpiceLosslessImgComprOff :: String
2448
htKvmSpiceLosslessImgComprOff = "off"
2449

    
2450
htKvmSpiceLosslessImgComprQuic :: String
2451
htKvmSpiceLosslessImgComprQuic = "quic"
2452

    
2453
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2454
htKvmSpiceValidLosslessImgComprOptions =
2455
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2456
                       htKvmSpiceLosslessImgComprAutoLz,
2457
                       htKvmSpiceLosslessImgComprGlz,
2458
                       htKvmSpiceLosslessImgComprLz,
2459
                       htKvmSpiceLosslessImgComprOff,
2460
                       htKvmSpiceLosslessImgComprQuic]
2461

    
2462
htKvmSpiceLossyImgComprAlways :: String
2463
htKvmSpiceLossyImgComprAlways = "always"
2464

    
2465
htKvmSpiceLossyImgComprAuto :: String
2466
htKvmSpiceLossyImgComprAuto = "auto"
2467

    
2468
htKvmSpiceLossyImgComprNever :: String
2469
htKvmSpiceLossyImgComprNever = "never"
2470

    
2471
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2472
htKvmSpiceValidLossyImgComprOptions =
2473
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2474
                       htKvmSpiceLossyImgComprAuto,
2475
                       htKvmSpiceLossyImgComprNever]
2476

    
2477
-- * SPICE video stream detection
2478

    
2479
htKvmSpiceVideoStreamDetectionAll :: String
2480
htKvmSpiceVideoStreamDetectionAll = "all"
2481

    
2482
htKvmSpiceVideoStreamDetectionFilter :: String
2483
htKvmSpiceVideoStreamDetectionFilter = "filter"
2484

    
2485
htKvmSpiceVideoStreamDetectionOff :: String
2486
htKvmSpiceVideoStreamDetectionOff = "off"
2487

    
2488
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2489
htKvmSpiceValidVideoStreamDetectionOptions =
2490
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2491
                       htKvmSpiceVideoStreamDetectionFilter,
2492
                       htKvmSpiceVideoStreamDetectionOff]
2493

    
2494
-- * Security models
2495

    
2496
htSmNone :: String
2497
htSmNone = "none"
2498

    
2499
htSmPool :: String
2500
htSmPool = "pool"
2501

    
2502
htSmUser :: String
2503
htSmUser = "user"
2504

    
2505
htKvmValidSmTypes :: FrozenSet String
2506
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2507

    
2508
-- * Kvm flag values
2509

    
2510
htKvmDisabled :: String
2511
htKvmDisabled = "disabled"
2512

    
2513
htKvmEnabled :: String
2514
htKvmEnabled = "enabled"
2515

    
2516
htKvmFlagValues :: FrozenSet String
2517
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2518

    
2519
-- * Migration type
2520

    
2521
htMigrationLive :: String
2522
htMigrationLive = Types.migrationModeToRaw MigrationLive
2523

    
2524
htMigrationNonlive :: String
2525
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2526

    
2527
htMigrationModes :: FrozenSet String
2528
htMigrationModes =
2529
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2530

    
2531
-- * Cluster verify steps
2532

    
2533
verifyNplusoneMem :: String
2534
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2535

    
2536
verifyOptionalChecks :: FrozenSet String
2537
verifyOptionalChecks =
2538
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2539

    
2540
-- * Cluster Verify error classes
2541

    
2542
cvTcluster :: String
2543
cvTcluster = "cluster"
2544

    
2545
cvTgroup :: String
2546
cvTgroup = "group"
2547

    
2548
cvTnode :: String
2549
cvTnode = "node"
2550

    
2551
cvTinstance :: String
2552
cvTinstance = "instance"
2553

    
2554
-- * Cluster Verify error codes and documentation
2555

    
2556
cvEclustercert :: (String, String, String)
2557
cvEclustercert =
2558
  ("cluster",
2559
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2560
   "Cluster certificate files verification failure")
2561

    
2562
cvEclustercfg :: (String, String, String)
2563
cvEclustercfg =
2564
  ("cluster",
2565
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2566
   "Cluster configuration verification failure")
2567

    
2568
cvEclusterdanglinginst :: (String, String, String)
2569
cvEclusterdanglinginst =
2570
  ("node",
2571
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2572
   "Some instances have a non-existing primary node")
2573

    
2574
cvEclusterdanglingnodes :: (String, String, String)
2575
cvEclusterdanglingnodes =
2576
  ("node",
2577
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2578
   "Some nodes belong to non-existing groups")
2579

    
2580
cvEclusterfilecheck :: (String, String, String)
2581
cvEclusterfilecheck =
2582
  ("cluster",
2583
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2584
   "Cluster configuration verification failure")
2585

    
2586
cvEgroupdifferentpvsize :: (String, String, String)
2587
cvEgroupdifferentpvsize =
2588
  ("group",
2589
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2590
   "PVs in the group have different sizes")
2591

    
2592
cvEinstancebadnode :: (String, String, String)
2593
cvEinstancebadnode =
2594
  ("instance",
2595
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2596
   "Instance marked as running lives on an offline node")
2597

    
2598
cvEinstancedown :: (String, String, String)
2599
cvEinstancedown =
2600
  ("instance",
2601
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2602
   "Instance not running on its primary node")
2603

    
2604
cvEinstancefaultydisk :: (String, String, String)
2605
cvEinstancefaultydisk =
2606
  ("instance",
2607
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2608
   "Impossible to retrieve status for a disk")
2609

    
2610
cvEinstancelayout :: (String, String, String)
2611
cvEinstancelayout =
2612
  ("instance",
2613
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2614
   "Instance has multiple secondary nodes")
2615

    
2616
cvEinstancemissingcfgparameter :: (String, String, String)
2617
cvEinstancemissingcfgparameter =
2618
  ("instance",
2619
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2620
   "A configuration parameter for an instance is missing")
2621

    
2622
cvEinstancemissingdisk :: (String, String, String)
2623
cvEinstancemissingdisk =
2624
  ("instance",
2625
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2626
   "Missing volume on an instance")
2627

    
2628
cvEinstancepolicy :: (String, String, String)
2629
cvEinstancepolicy =
2630
  ("instance",
2631
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2632
   "Instance does not meet policy")
2633

    
2634
cvEinstancesplitgroups :: (String, String, String)
2635
cvEinstancesplitgroups =
2636
  ("instance",
2637
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2638
   "Instance with primary and secondary nodes in different groups")
2639

    
2640
cvEinstanceunsuitablenode :: (String, String, String)
2641
cvEinstanceunsuitablenode =
2642
  ("instance",
2643
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2644
   "Instance running on nodes that are not suitable for it")
2645

    
2646
cvEinstancewrongnode :: (String, String, String)
2647
cvEinstancewrongnode =
2648
  ("instance",
2649
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2650
   "Instance running on the wrong node")
2651

    
2652
cvEnodedrbd :: (String, String, String)
2653
cvEnodedrbd =
2654
  ("node",
2655
   Types.cVErrorCodeToRaw CvENODEDRBD,
2656
   "Error parsing the DRBD status file")
2657

    
2658
cvEnodedrbdhelper :: (String, String, String)
2659
cvEnodedrbdhelper =
2660
  ("node",
2661
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2662
   "Error caused by the DRBD helper")
2663

    
2664
cvEnodedrbdversion :: (String, String, String)
2665
cvEnodedrbdversion =
2666
  ("node",
2667
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2668
   "DRBD version mismatch within a node group")
2669

    
2670
cvEnodefilecheck :: (String, String, String)
2671
cvEnodefilecheck =
2672
  ("node",
2673
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2674
   "Error retrieving the checksum of the node files")
2675

    
2676
cvEnodefilestoragepaths :: (String, String, String)
2677
cvEnodefilestoragepaths =
2678
  ("node",
2679
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2680
   "Detected bad file storage paths")
2681

    
2682
cvEnodefilestoragepathunusable :: (String, String, String)
2683
cvEnodefilestoragepathunusable =
2684
  ("node",
2685
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2686
   "File storage path unusable")
2687

    
2688
cvEnodehooks :: (String, String, String)
2689
cvEnodehooks =
2690
  ("node",
2691
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2692
   "Communication failure in hooks execution")
2693

    
2694
cvEnodehv :: (String, String, String)
2695
cvEnodehv =
2696
  ("node",
2697
   Types.cVErrorCodeToRaw CvENODEHV,
2698
   "Hypervisor parameters verification failure")
2699

    
2700
cvEnodelvm :: (String, String, String)
2701
cvEnodelvm =
2702
  ("node",
2703
   Types.cVErrorCodeToRaw CvENODELVM,
2704
   "LVM-related node error")
2705

    
2706
cvEnoden1 :: (String, String, String)
2707
cvEnoden1 =
2708
  ("node",
2709
   Types.cVErrorCodeToRaw CvENODEN1,
2710
   "Not enough memory to accommodate instance failovers")
2711

    
2712
cvEnodenet :: (String, String, String)
2713
cvEnodenet =
2714
  ("node",
2715
   Types.cVErrorCodeToRaw CvENODENET,
2716
   "Network-related node error")
2717

    
2718
cvEnodeoobpath :: (String, String, String)
2719
cvEnodeoobpath =
2720
  ("node",
2721
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2722
   "Invalid Out Of Band path")
2723

    
2724
cvEnodeorphaninstance :: (String, String, String)
2725
cvEnodeorphaninstance =
2726
  ("node",
2727
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2728
   "Unknown intance running on a node")
2729

    
2730
cvEnodeorphanlv :: (String, String, String)
2731
cvEnodeorphanlv =
2732
  ("node",
2733
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2734
   "Unknown LVM logical volume")
2735

    
2736
cvEnodeos :: (String, String, String)
2737
cvEnodeos =
2738
  ("node",
2739
   Types.cVErrorCodeToRaw CvENODEOS,
2740
   "OS-related node error")
2741

    
2742
cvEnoderpc :: (String, String, String)
2743
cvEnoderpc =
2744
  ("node",
2745
   Types.cVErrorCodeToRaw CvENODERPC,
2746
   "Error during connection to the primary node of an instance")
2747

    
2748
cvEnodesetup :: (String, String, String)
2749
cvEnodesetup =
2750
  ("node",
2751
   Types.cVErrorCodeToRaw CvENODESETUP,
2752
   "Node setup error")
2753

    
2754
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2755
cvEnodesharedfilestoragepathunusable =
2756
  ("node",
2757
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2758
   "Shared file storage path unusable")
2759

    
2760
cvEnodessh :: (String, String, String)
2761
cvEnodessh =
2762
  ("node",
2763
   Types.cVErrorCodeToRaw CvENODESSH,
2764
   "SSH-related node error")
2765

    
2766
cvEnodetime :: (String, String, String)
2767
cvEnodetime =
2768
  ("node",
2769
   Types.cVErrorCodeToRaw CvENODETIME,
2770
   "Node returned invalid time")
2771

    
2772
cvEnodeuserscripts :: (String, String, String)
2773
cvEnodeuserscripts =
2774
  ("node",
2775
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2776
   "User scripts not present or not executable")
2777

    
2778
cvEnodeversion :: (String, String, String)
2779
cvEnodeversion =
2780
  ("node",
2781
   Types.cVErrorCodeToRaw CvENODEVERSION,
2782
   "Protocol version mismatch or Ganeti version mismatch")
2783

    
2784
cvAllEcodes :: FrozenSet (String, String, String)
2785
cvAllEcodes =
2786
  ConstantUtils.mkSet
2787
  [cvEclustercert,
2788
   cvEclustercfg,
2789
   cvEclusterdanglinginst,
2790
   cvEclusterdanglingnodes,
2791
   cvEclusterfilecheck,
2792
   cvEgroupdifferentpvsize,
2793
   cvEinstancebadnode,
2794
   cvEinstancedown,
2795
   cvEinstancefaultydisk,
2796
   cvEinstancelayout,
2797
   cvEinstancemissingcfgparameter,
2798
   cvEinstancemissingdisk,
2799
   cvEinstancepolicy,
2800
   cvEinstancesplitgroups,
2801
   cvEinstanceunsuitablenode,
2802
   cvEinstancewrongnode,
2803
   cvEnodedrbd,
2804
   cvEnodedrbdhelper,
2805
   cvEnodedrbdversion,
2806
   cvEnodefilecheck,
2807
   cvEnodefilestoragepaths,
2808
   cvEnodefilestoragepathunusable,
2809
   cvEnodehooks,
2810
   cvEnodehv,
2811
   cvEnodelvm,
2812
   cvEnoden1,
2813
   cvEnodenet,
2814
   cvEnodeoobpath,
2815
   cvEnodeorphaninstance,
2816
   cvEnodeorphanlv,
2817
   cvEnodeos,
2818
   cvEnoderpc,
2819
   cvEnodesetup,
2820
   cvEnodesharedfilestoragepathunusable,
2821
   cvEnodessh,
2822
   cvEnodetime,
2823
   cvEnodeuserscripts,
2824
   cvEnodeversion]
2825

    
2826
cvAllEcodesStrings :: FrozenSet String
2827
cvAllEcodesStrings =
2828
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2829

    
2830
-- * Node verify constants
2831

    
2832
nvBridges :: String
2833
nvBridges = "bridges"
2834

    
2835
nvDrbdhelper :: String
2836
nvDrbdhelper = "drbd-helper"
2837

    
2838
nvDrbdversion :: String
2839
nvDrbdversion = "drbd-version"
2840

    
2841
nvDrbdlist :: String
2842
nvDrbdlist = "drbd-list"
2843

    
2844
nvExclusivepvs :: String
2845
nvExclusivepvs = "exclusive-pvs"
2846

    
2847
nvFilelist :: String
2848
nvFilelist = "filelist"
2849

    
2850
nvAcceptedStoragePaths :: String
2851
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2852

    
2853
nvFileStoragePath :: String
2854
nvFileStoragePath = "file-storage-path"
2855

    
2856
nvSharedFileStoragePath :: String
2857
nvSharedFileStoragePath = "shared-file-storage-path"
2858

    
2859
nvHvinfo :: String
2860
nvHvinfo = "hvinfo"
2861

    
2862
nvHvparams :: String
2863
nvHvparams = "hvparms"
2864

    
2865
nvHypervisor :: String
2866
nvHypervisor = "hypervisor"
2867

    
2868
nvInstancelist :: String
2869
nvInstancelist = "instancelist"
2870

    
2871
nvLvlist :: String
2872
nvLvlist = "lvlist"
2873

    
2874
nvMasterip :: String
2875
nvMasterip = "master-ip"
2876

    
2877
nvNodelist :: String
2878
nvNodelist = "nodelist"
2879

    
2880
nvNodenettest :: String
2881
nvNodenettest = "node-net-test"
2882

    
2883
nvNodesetup :: String
2884
nvNodesetup = "nodesetup"
2885

    
2886
nvOobPaths :: String
2887
nvOobPaths = "oob-paths"
2888

    
2889
nvOslist :: String
2890
nvOslist = "oslist"
2891

    
2892
nvPvlist :: String
2893
nvPvlist = "pvlist"
2894

    
2895
nvTime :: String
2896
nvTime = "time"
2897

    
2898
nvUserscripts :: String
2899
nvUserscripts = "user-scripts"
2900

    
2901
nvVersion :: String
2902
nvVersion = "version"
2903

    
2904
nvVglist :: String
2905
nvVglist = "vglist"
2906

    
2907
nvVmnodes :: String
2908
nvVmnodes = "vmnodes"
2909

    
2910
-- * Instance status
2911

    
2912
inststAdmindown :: String
2913
inststAdmindown = Types.instanceStatusToRaw StatusDown
2914

    
2915
inststAdminoffline :: String
2916
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
2917

    
2918
inststErrordown :: String
2919
inststErrordown = Types.instanceStatusToRaw ErrorDown
2920

    
2921
inststErrorup :: String
2922
inststErrorup = Types.instanceStatusToRaw ErrorUp
2923

    
2924
inststNodedown :: String
2925
inststNodedown = Types.instanceStatusToRaw NodeDown
2926

    
2927
inststNodeoffline :: String
2928
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
2929

    
2930
inststRunning :: String
2931
inststRunning = Types.instanceStatusToRaw Running
2932

    
2933
inststWrongnode :: String
2934
inststWrongnode = Types.instanceStatusToRaw WrongNode
2935

    
2936
inststAll :: FrozenSet String
2937
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
2938

    
2939
-- * Admin states
2940

    
2941
adminstDown :: String
2942
adminstDown = Types.adminStateToRaw AdminDown
2943

    
2944
adminstOffline :: String
2945
adminstOffline = Types.adminStateToRaw AdminOffline
2946

    
2947
adminstUp :: String
2948
adminstUp = Types.adminStateToRaw AdminUp
2949

    
2950
adminstAll :: FrozenSet String
2951
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
2952

    
2953
-- * Node roles
2954

    
2955
nrDrained :: String
2956
nrDrained = Types.nodeRoleToRaw NRDrained
2957

    
2958
nrMaster :: String
2959
nrMaster = Types.nodeRoleToRaw NRMaster
2960

    
2961
nrMcandidate :: String
2962
nrMcandidate = Types.nodeRoleToRaw NRCandidate
2963

    
2964
nrOffline :: String
2965
nrOffline = Types.nodeRoleToRaw NROffline
2966

    
2967
nrRegular :: String
2968
nrRegular = Types.nodeRoleToRaw NRRegular
2969

    
2970
nrAll :: FrozenSet String
2971
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
2972

    
2973
-- * SSL certificate check constants (in days)
2974

    
2975
sslCertExpirationError :: Int
2976
sslCertExpirationError = 7
2977

    
2978
sslCertExpirationWarn :: Int
2979
sslCertExpirationWarn = 30
2980

    
2981
-- * Allocator framework constants
2982

    
2983
iallocatorVersion :: Int
2984
iallocatorVersion = 2
2985

    
2986
iallocatorDirIn :: String
2987
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
2988

    
2989
iallocatorDirOut :: String
2990
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
2991

    
2992
validIallocatorDirections :: FrozenSet String
2993
validIallocatorDirections =
2994
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
2995

    
2996
iallocatorModeAlloc :: String
2997
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
2998

    
2999
iallocatorModeChgGroup :: String
3000
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3001

    
3002
iallocatorModeMultiAlloc :: String
3003
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3004

    
3005
iallocatorModeNodeEvac :: String
3006
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3007

    
3008
iallocatorModeReloc :: String
3009
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3010

    
3011
validIallocatorModes :: FrozenSet String
3012
validIallocatorModes =
3013
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3014

    
3015
iallocatorSearchPath :: [String]
3016
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3017

    
3018
defaultIallocatorShortcut :: String
3019
defaultIallocatorShortcut = "."
3020

    
3021
-- * Node evacuation
3022

    
3023
nodeEvacPri :: String
3024
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3025

    
3026
nodeEvacSec :: String
3027
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3028

    
3029
nodeEvacAll :: String
3030
nodeEvacAll = Types.evacModeToRaw ChangeAll
3031

    
3032
nodeEvacModes :: FrozenSet String
3033
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3034

    
3035
-- * Job queue
3036

    
3037
jobQueueVersion :: Int
3038
jobQueueVersion = 1
3039

    
3040
jobQueueSizeHardLimit :: Int
3041
jobQueueSizeHardLimit = 5000
3042

    
3043
jobQueueFilesPerms :: Int
3044
jobQueueFilesPerms = 0o640
3045

    
3046
-- * Unchanged job return
3047

    
3048
jobNotchanged :: String
3049
jobNotchanged = "nochange"
3050

    
3051
-- * Job status
3052

    
3053
jobStatusQueued :: String
3054
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3055

    
3056
jobStatusWaiting :: String
3057
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3058

    
3059
jobStatusCanceling :: String
3060
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3061

    
3062
jobStatusRunning :: String
3063
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3064

    
3065
jobStatusCanceled :: String
3066
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3067

    
3068
jobStatusSuccess :: String
3069
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3070

    
3071
jobStatusError :: String
3072
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3073

    
3074
jobsPending :: FrozenSet String
3075
jobsPending =
3076
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3077

    
3078
jobsFinalized :: FrozenSet String
3079
jobsFinalized =
3080
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3081

    
3082
jobStatusAll :: FrozenSet String
3083
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3084

    
3085
-- * OpCode status
3086

    
3087
-- ** Not yet finalized opcodes
3088

    
3089
opStatusCanceling :: String
3090
opStatusCanceling = "canceling"
3091

    
3092
opStatusQueued :: String
3093
opStatusQueued = "queued"
3094

    
3095
opStatusRunning :: String
3096
opStatusRunning = "running"
3097

    
3098
opStatusWaiting :: String
3099
opStatusWaiting = "waiting"
3100

    
3101
-- ** Finalized opcodes
3102

    
3103
opStatusCanceled :: String
3104
opStatusCanceled = "canceled"
3105

    
3106
opStatusError :: String
3107
opStatusError = "error"
3108

    
3109
opStatusSuccess :: String
3110
opStatusSuccess = "success"
3111

    
3112
opsFinalized :: FrozenSet String
3113
opsFinalized =
3114
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3115

    
3116
-- * OpCode priority
3117

    
3118
opPrioLowest :: Int
3119
opPrioLowest = 19
3120

    
3121
opPrioHighest :: Int
3122
opPrioHighest = -20
3123

    
3124
opPrioLow :: Int
3125
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3126

    
3127
opPrioNormal :: Int
3128
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3129

    
3130
opPrioHigh :: Int
3131
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3132

    
3133
opPrioSubmitValid :: FrozenSet Int
3134
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3135

    
3136
opPrioDefault :: Int
3137
opPrioDefault = opPrioNormal
3138

    
3139
-- * Lock recalculate mode
3140

    
3141
locksAppend :: String
3142
locksAppend = "append"
3143

    
3144
locksReplace :: String
3145
locksReplace = "replace"
3146

    
3147
-- * Lock timeout
3148
--
3149
-- The lock timeout (sum) before we transition into blocking acquire
3150
-- (this can still be reset by priority change).  Computed as max time
3151
-- (10 hours) before we should actually go into blocking acquire,
3152
-- given that we start from the default priority level.
3153

    
3154
lockAttemptsMaxwait :: Double
3155
lockAttemptsMaxwait = 15.0
3156

    
3157
lockAttemptsMinwait :: Double
3158
lockAttemptsMinwait = 1.0
3159

    
3160
lockAttemptsTimeout :: Int
3161
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3162

    
3163
-- * Execution log types
3164

    
3165
elogMessage :: String
3166
elogMessage = Types.eLogTypeToRaw ELogMessage
3167

    
3168
elogRemoteImport :: String
3169
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3170

    
3171
elogJqueueTest :: String
3172
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3173

    
3174
-- * /etc/hosts modification
3175

    
3176
etcHostsAdd :: String
3177
etcHostsAdd = "add"
3178

    
3179
etcHostsRemove :: String
3180
etcHostsRemove = "remove"
3181

    
3182
-- * Job queue test
3183

    
3184
jqtMsgprefix :: String
3185
jqtMsgprefix = "TESTMSG="
3186

    
3187
jqtExec :: String
3188
jqtExec = "exec"
3189

    
3190
jqtExpandnames :: String
3191
jqtExpandnames = "expandnames"
3192

    
3193
jqtLogmsg :: String
3194
jqtLogmsg = "logmsg"
3195

    
3196
jqtStartmsg :: String
3197
jqtStartmsg = "startmsg"
3198

    
3199
jqtAll :: FrozenSet String
3200
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3201

    
3202
-- * Query resources
3203

    
3204
qrCluster :: String
3205
qrCluster = "cluster"
3206

    
3207
qrExport :: String
3208
qrExport = "export"
3209

    
3210
qrExtstorage :: String
3211
qrExtstorage = "extstorage"
3212

    
3213
qrGroup :: String
3214
qrGroup = "group"
3215

    
3216
qrInstance :: String
3217
qrInstance = "instance"
3218

    
3219
qrJob :: String
3220
qrJob = "job"
3221

    
3222
qrLock :: String
3223
qrLock = "lock"
3224

    
3225
qrNetwork :: String
3226
qrNetwork = "network"
3227

    
3228
qrNode :: String
3229
qrNode = "node"
3230

    
3231
qrOs :: String
3232
qrOs = "os"
3233

    
3234
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3235
qrViaOp :: FrozenSet String
3236
qrViaOp =
3237
  ConstantUtils.mkSet [qrCluster,
3238
                       qrInstance,
3239
                       qrNode,
3240
                       qrGroup,
3241
                       qrOs,
3242
                       qrExport,
3243
                       qrNetwork,
3244
                       qrExtstorage]
3245

    
3246
-- | List of resources which can be queried using Local UniX Interface
3247
qrViaLuxi :: FrozenSet String
3248
qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob]
3249

    
3250
-- | List of resources which can be queried using RAPI
3251
qrViaRapi :: FrozenSet String
3252
qrViaRapi = qrViaLuxi
3253

    
3254
-- * Query field types
3255

    
3256
qftBool :: String
3257
qftBool = "bool"
3258

    
3259
qftNumber :: String
3260
qftNumber = "number"
3261

    
3262
qftOther :: String
3263
qftOther = "other"
3264

    
3265
qftText :: String
3266
qftText = "text"
3267

    
3268
qftTimestamp :: String
3269
qftTimestamp = "timestamp"
3270

    
3271
qftUnit :: String
3272
qftUnit = "unit"
3273

    
3274
qftUnknown :: String
3275
qftUnknown = "unknown"
3276

    
3277
qftAll :: FrozenSet String
3278
qftAll =
3279
  ConstantUtils.mkSet [qftBool,
3280
                       qftNumber,
3281
                       qftOther,
3282
                       qftText,
3283
                       qftTimestamp,
3284
                       qftUnit,
3285
                       qftUnknown]
3286

    
3287
-- * Query result field status
3288
--
3289
-- Don't change or reuse values as they're used by clients.
3290
--
3291
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3292

    
3293
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3294
rsNodata :: Int
3295
rsNodata = 2
3296

    
3297
rsNormal :: Int
3298
rsNormal = 0
3299

    
3300
-- | Resource marked offline
3301
rsOffline :: Int
3302
rsOffline = 4
3303

    
3304
-- | Value unavailable/unsupported for item; if this field is
3305
-- supported but we cannot get the data for the moment, 'rsNodata' or
3306
-- 'rsOffline' should be used
3307
rsUnavail :: Int
3308
rsUnavail = 3
3309

    
3310
rsUnknown :: Int
3311
rsUnknown = 1
3312

    
3313
rsAll :: FrozenSet Int
3314
rsAll =
3315
  ConstantUtils.mkSet [rsNodata,
3316
                       rsNormal,
3317
                       rsOffline,
3318
                       rsUnavail,
3319
                       rsUnknown]
3320

    
3321
-- | Special field cases and their verbose/terse formatting
3322
rssDescription :: Map Int (String, String)
3323
rssDescription =
3324
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3325
                (rsNodata, ("(nodata)", "?")),
3326
                (rsOffline, ("(offline)", "*")),
3327
                (rsUnavail, ("(unavail)", "-"))]
3328

    
3329
-- * Max dynamic devices
3330

    
3331
maxDisks :: Int
3332
maxDisks = Types.maxDisks
3333

    
3334
maxNics :: Int
3335
maxNics = Types.maxNics
3336

    
3337
-- | SSCONF file prefix
3338
ssconfFileprefix :: String
3339
ssconfFileprefix = "ssconf_"
3340

    
3341
-- * SSCONF keys
3342

    
3343
ssClusterName :: String
3344
ssClusterName = "cluster_name"
3345

    
3346
ssClusterTags :: String
3347
ssClusterTags = "cluster_tags"
3348

    
3349
ssFileStorageDir :: String
3350
ssFileStorageDir = "file_storage_dir"
3351

    
3352
ssSharedFileStorageDir :: String
3353
ssSharedFileStorageDir = "shared_file_storage_dir"
3354

    
3355
ssMasterCandidates :: String
3356
ssMasterCandidates = "master_candidates"
3357

    
3358
ssMasterCandidatesIps :: String
3359
ssMasterCandidatesIps = "master_candidates_ips"
3360

    
3361
ssMasterIp :: String
3362
ssMasterIp = "master_ip"
3363

    
3364
ssMasterNetdev :: String
3365
ssMasterNetdev = "master_netdev"
3366

    
3367
ssMasterNetmask :: String
3368
ssMasterNetmask = "master_netmask"
3369

    
3370
ssMasterNode :: String
3371
ssMasterNode = "master_node"
3372

    
3373
ssNodeList :: String
3374
ssNodeList = "node_list"
3375

    
3376
ssNodePrimaryIps :: String
3377
ssNodePrimaryIps = "node_primary_ips"
3378

    
3379
ssNodeSecondaryIps :: String
3380
ssNodeSecondaryIps = "node_secondary_ips"
3381

    
3382
ssOfflineNodes :: String
3383
ssOfflineNodes = "offline_nodes"
3384

    
3385
ssOnlineNodes :: String
3386
ssOnlineNodes = "online_nodes"
3387

    
3388
ssPrimaryIpFamily :: String
3389
ssPrimaryIpFamily = "primary_ip_family"
3390

    
3391
ssInstanceList :: String
3392
ssInstanceList = "instance_list"
3393

    
3394
ssReleaseVersion :: String
3395
ssReleaseVersion = "release_version"
3396

    
3397
ssHypervisorList :: String
3398
ssHypervisorList = "hypervisor_list"
3399

    
3400
ssMaintainNodeHealth :: String
3401
ssMaintainNodeHealth = "maintain_node_health"
3402

    
3403
ssUidPool :: String
3404
ssUidPool = "uid_pool"
3405

    
3406
ssNodegroups :: String
3407
ssNodegroups = "nodegroups"
3408

    
3409
ssNetworks :: String
3410
ssNetworks = "networks"
3411

    
3412
-- | This is not a complete SSCONF key, but the prefix for the
3413
-- hypervisor keys
3414
ssHvparamsPref :: String
3415
ssHvparamsPref = "hvparams_"
3416

    
3417
-- * Hvparams keys
3418

    
3419
ssHvparamsXenChroot :: String
3420
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3421

    
3422
ssHvparamsXenFake :: String
3423
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3424

    
3425
ssHvparamsXenHvm :: String
3426
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3427

    
3428
ssHvparamsXenKvm :: String
3429
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3430

    
3431
ssHvparamsXenLxc :: String
3432
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3433

    
3434
ssHvparamsXenPvm :: String
3435
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3436

    
3437
validSsHvparamsKeys :: FrozenSet String
3438
validSsHvparamsKeys =
3439
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3440
                       ssHvparamsXenLxc,
3441
                       ssHvparamsXenFake,
3442
                       ssHvparamsXenHvm,
3443
                       ssHvparamsXenKvm,
3444
                       ssHvparamsXenPvm]
3445

    
3446
ssFilePerms :: Int
3447
ssFilePerms = 0o444
3448

    
3449
-- | Cluster wide default parameters
3450
defaultEnabledHypervisor :: String
3451
defaultEnabledHypervisor = htXenPvm
3452

    
3453
hvcGlobals :: FrozenSet String
3454
hvcGlobals =
3455
  ConstantUtils.mkSet [hvMigrationBandwidth,
3456
                       hvMigrationMode,
3457
                       hvMigrationPort,
3458
                       hvXenCmd]
3459

    
3460
becDefaults :: Map String PyValueEx
3461
becDefaults =
3462
  Map.fromList
3463
  [ (beMinmem, PyValueEx (128 :: Int))
3464
  , (beMaxmem, PyValueEx (128 :: Int))
3465
  , (beVcpus, PyValueEx (1 :: Int))
3466
  , (beAutoBalance, PyValueEx True)
3467
  , (beAlwaysFailover, PyValueEx False)
3468
  , (beSpindleUse, PyValueEx (1 :: Int))
3469
  ]
3470

    
3471
ndcDefaults :: Map String PyValueEx
3472
ndcDefaults =
3473
  Map.fromList
3474
  [ (ndOobProgram,       PyValueEx "")
3475
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3476
  , (ndExclusiveStorage, PyValueEx False)
3477
  , (ndOvs,              PyValueEx False)
3478
  , (ndOvsName,          PyValueEx defaultOvs)
3479
  , (ndOvsLink,          PyValueEx "")
3480
  ]
3481

    
3482
ndcGlobals :: FrozenSet String
3483
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3484

    
3485
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3486
diskLdDefaults =
3487
  Map.fromList
3488
  [ (DTDrbd8, Map.fromList
3489
              [ (ldpBarriers, PyValueEx drbdBarriers)
3490
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3491
              , (ldpDelayTarget, PyValueEx (1 :: Int)) -- ds
3492
              , (ldpDiskCustom, PyValueEx "")
3493
              , (ldpDynamicResync, PyValueEx False)
3494
              , (ldpFillTarget, PyValueEx (0 :: Int)) -- sectors
3495
              , (ldpMaxRate, PyValueEx (classicDrbdSyncSpeed :: Int)) -- KiB/s
3496
              , (ldpMinRate, PyValueEx (4 * 1024 :: Int)) -- KiB/s
3497
              , (ldpNetCustom, PyValueEx "")
3498
              , (ldpNoMetaFlush, PyValueEx drbdNoMetaFlush)
3499
                -- The default values for the DRBD dynamic resync
3500
                -- speed algorithm are taken from the drbsetup 8.3.11
3501
                -- man page, except for c-plan-ahead (that we don't
3502
                -- need to set to 0, because we have a separate option
3503
                -- to enable it) and for c-max-rate, that we cap to
3504
                -- the default value for the static resync rate.
3505
              , (ldpPlanAhead, PyValueEx (20 :: Int)) -- ds
3506
              , (ldpProtocol, PyValueEx drbdDefaultNetProtocol)
3507
              , (ldpResyncRate, PyValueEx classicDrbdSyncSpeed)
3508
              ])
3509
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3510
  , (DTFile, Map.empty)
3511
  , (DTSharedFile, Map.empty)
3512
  , (DTBlock, Map.empty)
3513
  , (DTRbd, Map.fromList
3514
            [ (ldpPool, PyValueEx "rbd")
3515
            , (ldpAccess, PyValueEx diskKernelspace)
3516
            ])
3517
  , (DTExt, Map.empty)
3518
  ]
3519

    
3520
-- | All of the following values are quite arbitrary - there are no
3521
-- "good" defaults, these must be customised per-site
3522
ispecsMinmaxDefaults :: Map String (Map String Int)
3523
ispecsMinmaxDefaults =
3524
  Map.fromList
3525
  [(ispecsMin,
3526
    Map.fromList
3527
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3528
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3529
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3530
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3531
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3532
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3533
   (ispecsMax,
3534
    Map.fromList
3535
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3536
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3537
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3538
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3539
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3540
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3541

    
3542
masterPoolSizeDefault :: Int
3543
masterPoolSizeDefault = 10
3544

    
3545
-- * Exclusive storage
3546

    
3547
-- | Error margin used to compare physical disks
3548
partMargin :: Double
3549
partMargin = 0.01
3550

    
3551
-- | Space reserved when creating instance disks
3552
partReserved :: Double
3553
partReserved = 0.02
3554

    
3555
-- * Confd
3556

    
3557
confdProtocolVersion :: Int
3558
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3559

    
3560
-- Confd request type
3561

    
3562
confdReqPing :: Int
3563
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3564

    
3565
confdReqNodeRoleByname :: Int
3566
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3567

    
3568
confdReqNodePipByInstanceIp :: Int
3569
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3570

    
3571
confdReqClusterMaster :: Int
3572
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3573

    
3574
confdReqNodePipList :: Int
3575
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3576

    
3577
confdReqMcPipList :: Int
3578
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3579

    
3580
confdReqInstancesIpsList :: Int
3581
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3582

    
3583
confdReqNodeDrbd :: Int
3584
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3585

    
3586
confdReqNodeInstances :: Int
3587
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3588

    
3589
confdReqs :: FrozenSet Int
3590
confdReqs =
3591
  ConstantUtils.mkSet .
3592
  map Types.confdRequestTypeToRaw $
3593
  [minBound..] \\ [ReqNodeInstances]
3594

    
3595
-- * Confd request type
3596

    
3597
confdReqfieldName :: Int
3598
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3599

    
3600
confdReqfieldIp :: Int
3601
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3602

    
3603
confdReqfieldMnodePip :: Int
3604
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3605

    
3606
-- * Confd repl status
3607

    
3608
confdReplStatusOk :: Int
3609
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3610

    
3611
confdReplStatusError :: Int
3612
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3613

    
3614
confdReplStatusNotimplemented :: Int
3615
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3616

    
3617
confdReplStatuses :: FrozenSet Int
3618
confdReplStatuses =
3619
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3620

    
3621
-- * Confd node role
3622

    
3623
confdNodeRoleMaster :: Int
3624
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3625

    
3626
confdNodeRoleCandidate :: Int
3627
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3628

    
3629
confdNodeRoleOffline :: Int
3630
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3631

    
3632
confdNodeRoleDrained :: Int
3633
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3634

    
3635
confdNodeRoleRegular :: Int
3636
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3637

    
3638
-- * A few common errors for confd
3639

    
3640
confdErrorUnknownEntry :: Int
3641
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3642

    
3643
confdErrorInternal :: Int
3644
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3645

    
3646
confdErrorArgument :: Int
3647
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3648

    
3649
-- * Confd request query fields
3650

    
3651
confdReqqLink :: String
3652
confdReqqLink = ConstantUtils.confdReqqLink
3653

    
3654
confdReqqIp :: String
3655
confdReqqIp = ConstantUtils.confdReqqIp
3656

    
3657
confdReqqIplist :: String
3658
confdReqqIplist = ConstantUtils.confdReqqIplist
3659

    
3660
confdReqqFields :: String
3661
confdReqqFields = ConstantUtils.confdReqqFields
3662

    
3663
-- | Each request is "salted" by the current timestamp.
3664
--
3665
-- This constant decides how many seconds of skew to accept.
3666
--
3667
-- TODO: make this a default and allow the value to be more
3668
-- configurable
3669
confdMaxClockSkew :: Int
3670
confdMaxClockSkew = 2 * nodeMaxClockSkew
3671

    
3672
-- | When we haven't reloaded the config for more than this amount of
3673
-- seconds, we force a test to see if inotify is betraying us. Using a
3674
-- prime number to ensure we get less chance of 'same wakeup' with
3675
-- other processes.
3676
confdConfigReloadTimeout :: Int
3677
confdConfigReloadTimeout = 17
3678

    
3679
-- | If we receive more than one update in this amount of
3680
-- microseconds, we move to polling every RATELIMIT seconds, rather
3681
-- than relying on inotify, to be able to serve more requests.
3682
confdConfigReloadRatelimit :: Int
3683
confdConfigReloadRatelimit = 250000
3684

    
3685
-- | Magic number prepended to all confd queries.
3686
--
3687
-- This allows us to distinguish different types of confd protocols
3688
-- and handle them. For example by changing this we can move the whole
3689
-- payload to be compressed, or move away from json.
3690
confdMagicFourcc :: String
3691
confdMagicFourcc = "plj0"
3692

    
3693
-- | By default a confd request is sent to the minimum between this
3694
-- number and all MCs. 6 was chosen because even in the case of a
3695
-- disastrous 50% response rate, we should have enough answers to be
3696
-- able to compare more than one.
3697
confdDefaultReqCoverage :: Int
3698
confdDefaultReqCoverage = 6
3699

    
3700
-- | Timeout in seconds to expire pending query request in the confd
3701
-- client library. We don't actually expect any answer more than 10
3702
-- seconds after we sent a request.
3703
confdClientExpireTimeout :: Int
3704
confdClientExpireTimeout = 10
3705

    
3706
-- | Maximum UDP datagram size.
3707
--
3708
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
3709
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
3710
--   (assuming we can't use jumbo frames)
3711
-- We just set this to 60K, which should be enough
3712
maxUdpDataSize :: Int
3713
maxUdpDataSize = 61440
3714

    
3715
-- * User-id pool minimum/maximum acceptable user-ids
3716

    
3717
uidpoolUidMin :: Int
3718
uidpoolUidMin = 0
3719

    
3720
-- | Assuming 32 bit user-ids
3721
uidpoolUidMax :: Integer
3722
uidpoolUidMax = 2 ^ 32 - 1
3723

    
3724
-- | Name or path of the pgrep command
3725
pgrep :: String
3726
pgrep = "pgrep"
3727

    
3728
-- | Name of the node group that gets created at cluster init or
3729
-- upgrade
3730
initialNodeGroupName :: String
3731
initialNodeGroupName = "default"
3732

    
3733
-- * Possible values for NodeGroup.alloc_policy
3734

    
3735
allocPolicyLastResort :: String
3736
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
3737

    
3738
allocPolicyPreferred :: String
3739
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
3740

    
3741
allocPolicyUnallocable :: String
3742
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
3743

    
3744
validAllocPolicies :: [String]
3745
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
3746

    
3747
-- | Temporary external/shared storage parameters
3748
blockdevDriverManual :: String
3749
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
3750

    
3751
-- | 'qemu-img' path, required for 'ovfconverter'
3752
qemuimgPath :: String
3753
qemuimgPath = AutoConf.qemuimgPath
3754

    
3755
-- | Whether htools was enabled at compilation time
3756
--
3757
-- FIXME: this should be moved next to the other enable constants,
3758
-- such as, 'enableConfd', and renamed to 'enableHtools'.
3759
htools :: Bool
3760
htools = AutoConf.htools
3761

    
3762
-- | The hail iallocator
3763
iallocHail :: String
3764
iallocHail = "hail"
3765

    
3766
-- * Fake opcodes for functions that have hooks attached to them via
3767
-- backend.RunLocalHooks
3768

    
3769
fakeOpMasterTurndown :: String
3770
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
3771

    
3772
fakeOpMasterTurnup :: String
3773
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
3774

    
3775
-- * SSH key types
3776

    
3777
sshkDsa :: String
3778
sshkDsa = "dsa"
3779

    
3780
sshkRsa :: String
3781
sshkRsa = "rsa"
3782

    
3783
sshkAll :: FrozenSet String
3784
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
3785

    
3786
-- * SSH authorized key types
3787

    
3788
sshakDss :: String
3789
sshakDss = "ssh-dss"
3790

    
3791
sshakRsa :: String
3792
sshakRsa = "ssh-rsa"
3793

    
3794
sshakAll :: FrozenSet String
3795
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
3796

    
3797
-- * SSH setup
3798

    
3799
sshsClusterName :: String
3800
sshsClusterName = "cluster_name"
3801

    
3802
sshsSshHostKey :: String
3803
sshsSshHostKey = "ssh_host_key"
3804

    
3805
sshsSshRootKey :: String
3806
sshsSshRootKey = "ssh_root_key"
3807

    
3808
sshsNodeDaemonCertificate :: String
3809
sshsNodeDaemonCertificate = "node_daemon_certificate"
3810

    
3811
-- * Key files for SSH daemon
3812

    
3813
sshHostDsaPriv :: String
3814
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
3815

    
3816
sshHostDsaPub :: String
3817
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
3818

    
3819
sshHostRsaPriv :: String
3820
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
3821

    
3822
sshHostRsaPub :: String
3823
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
3824

    
3825
sshDaemonKeyfiles :: Map String (String, String)
3826
sshDaemonKeyfiles =
3827
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
3828
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
3829
               ]
3830

    
3831
-- * Node daemon setup
3832

    
3833
ndsClusterName :: String
3834
ndsClusterName = "cluster_name"
3835

    
3836
ndsNodeDaemonCertificate :: String
3837
ndsNodeDaemonCertificate = "node_daemon_certificate"
3838

    
3839
ndsSsconf :: String
3840
ndsSsconf = "ssconf"
3841

    
3842
ndsStartNodeDaemon :: String
3843
ndsStartNodeDaemon = "start_node_daemon"
3844

    
3845
-- * The source reasons for the execution of an OpCode
3846

    
3847
opcodeReasonSrcClient :: String
3848
opcodeReasonSrcClient = "gnt:client"
3849

    
3850
opcodeReasonSrcNoded :: String
3851
opcodeReasonSrcNoded = "gnt:daemon:noded"
3852

    
3853
opcodeReasonSrcOpcode :: String
3854
opcodeReasonSrcOpcode = "gnt:opcode"
3855

    
3856
opcodeReasonSrcRlib2 :: String
3857
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
3858

    
3859
opcodeReasonSrcUser :: String
3860
opcodeReasonSrcUser = "gnt:user"
3861

    
3862
opcodeReasonSources :: FrozenSet String
3863
opcodeReasonSources =
3864
  ConstantUtils.mkSet [opcodeReasonSrcClient,
3865
                       opcodeReasonSrcNoded,
3866
                       opcodeReasonSrcOpcode,
3867
                       opcodeReasonSrcRlib2,
3868
                       opcodeReasonSrcUser]
3869

    
3870
-- | Path generating random UUID
3871
randomUuidFile :: String
3872
randomUuidFile = ConstantUtils.randomUuidFile
3873

    
3874
-- * Auto-repair tag prefixes
3875

    
3876
autoRepairTagPrefix :: String
3877
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
3878

    
3879
autoRepairTagEnabled :: String
3880
autoRepairTagEnabled = autoRepairTagPrefix
3881

    
3882
autoRepairTagPending :: String
3883
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
3884

    
3885
autoRepairTagResult :: String
3886
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
3887

    
3888
autoRepairTagSuspended :: String
3889
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
3890

    
3891
-- * Auto-repair levels
3892

    
3893
autoRepairFailover :: String
3894
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
3895

    
3896
autoRepairFixStorage :: String
3897
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
3898

    
3899
autoRepairMigrate :: String
3900
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
3901

    
3902
autoRepairReinstall :: String
3903
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
3904

    
3905
autoRepairAllTypes :: FrozenSet String
3906
autoRepairAllTypes =
3907
  ConstantUtils.mkSet [autoRepairFailover,
3908
                       autoRepairFixStorage,
3909
                       autoRepairMigrate,
3910
                       autoRepairReinstall]
3911

    
3912
-- * Auto-repair results
3913

    
3914
autoRepairEnoperm :: String
3915
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
3916

    
3917
autoRepairFailure :: String
3918
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
3919

    
3920
autoRepairSuccess :: String
3921
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
3922

    
3923
autoRepairAllResults :: FrozenSet String
3924
autoRepairAllResults =
3925
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
3926

    
3927
-- | The version identifier for builtin data collectors
3928
builtinDataCollectorVersion :: String
3929
builtinDataCollectorVersion = "B"
3930

    
3931
-- | The reason trail opcode parameter name
3932
opcodeReason :: String
3933
opcodeReason = "reason"
3934

    
3935
diskstatsFile :: String
3936
diskstatsFile = "/proc/diskstats"
3937

    
3938
-- *  CPU load collector
3939

    
3940
statFile :: String
3941
statFile = "/proc/stat"
3942

    
3943
cpuavgloadBufferSize :: Int
3944
cpuavgloadBufferSize = 150
3945

    
3946
cpuavgloadWindowSize :: Int
3947
cpuavgloadWindowSize = 600
3948

    
3949
-- * Monitoring daemon
3950

    
3951
-- | Mond's variable for periodical data collection
3952
mondTimeInterval :: Int
3953
mondTimeInterval = 5
3954

    
3955
-- | Mond's latest API version
3956
mondLatestApiVersion :: Int
3957
mondLatestApiVersion = 1
3958

    
3959
-- * Disk access modes
3960

    
3961
diskUserspace :: String
3962
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
3963

    
3964
diskKernelspace :: String
3965
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
3966

    
3967
diskValidAccessModes :: FrozenSet String
3968
diskValidAccessModes =
3969
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
3970

    
3971
-- | Timeout for queue draining in upgrades
3972
upgradeQueueDrainTimeout :: Int
3973
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
3974

    
3975
-- | Intervall at which the queue is polled during upgrades
3976
upgradeQueuePollInterval :: Int
3977
upgradeQueuePollInterval  = 10
3978

    
3979
-- * Hotplug Actions
3980

    
3981
hotplugActionAdd :: String
3982
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
3983

    
3984
hotplugActionRemove :: String
3985
hotplugActionRemove = Types.hotplugActionToRaw HARemove
3986

    
3987
hotplugActionModify :: String
3988
hotplugActionModify = Types.hotplugActionToRaw HAMod
3989

    
3990
hotplugAllActions :: FrozenSet String
3991
hotplugAllActions =
3992
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
3993

    
3994
-- * Hotplug Device Targets
3995

    
3996
hotplugTargetNic :: String
3997
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
3998

    
3999
hotplugTargetDisk :: String
4000
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4001

    
4002
hotplugAllTargets :: FrozenSet String
4003
hotplugAllTargets =
4004
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]