Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ 9569d877

History | View | Annotate | Download (90.9 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 (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.Types
57
import qualified Ganeti.Types as Types
58
import Ganeti.Confd.Types (ConfdRequestType(..), ConfdReqField(..),
59
                           ConfdReplyStatus(..), ConfdNodeRole(..),
60
                           ConfdErrorType(..))
61
import qualified Ganeti.Confd.Types as Types
62

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

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

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

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

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

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

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

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

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

    
86
-- ** Build-time constants
87

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
135
-- * Various versions
136

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

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

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

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

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

    
152
osApiV10 :: Int
153
osApiV10 = 10
154

    
155
osApiV15 :: Int
156
osApiV15 = 15
157

    
158
osApiV20 :: Int
159
osApiV20 = 20
160

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

    
164
exportVersion :: Int
165
exportVersion = 0
166

    
167
rapiVersion :: Int
168
rapiVersion = 2
169

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

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

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

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

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

    
189
-- * User separation
190

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
239
-- * Cpu pinning separators and constants
240

    
241
cpuPinningSep :: String
242
cpuPinningSep = ":"
243

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

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

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

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

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

    
279
-- * Wipe
280

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

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

    
288
minWipeChunkPercent :: Int
289
minWipeChunkPercent = 10
290

    
291
-- * Directories
292

    
293
runDirsMode :: Int
294
runDirsMode = 0o775
295

    
296
secureDirMode :: Int
297
secureDirMode = 0o700
298

    
299
secureFileMode :: Int
300
secureFileMode = 0o600
301

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

    
305
-- * 'autoconf' enable/disable
306

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

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

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

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

    
319
-- * SSH constants
320

    
321
ssh :: String
322
ssh = "ssh"
323

    
324
scp :: String
325
scp = "scp"
326

    
327
-- * Daemons
328

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

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

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

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

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

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

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

    
356
defaultConfdPort :: Int
357
defaultConfdPort = 1814
358

    
359
defaultMondPort :: Int
360
defaultMondPort = 1815
361

    
362
defaultNodedPort :: Int
363
defaultNodedPort = 1811
364

    
365
defaultRapiPort :: Int
366
defaultRapiPort = 5080
367

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

    
376
firstDrbdPort :: Int
377
firstDrbdPort = 11000
378

    
379
lastDrbdPort :: Int
380
lastDrbdPort = 14999
381

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

    
387
extraLogreasonAccess :: String
388
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
389

    
390
extraLogreasonError :: String
391
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
392

    
393
devConsole :: String
394
devConsole = ConstantUtils.devConsole
395

    
396
procMounts :: String
397
procMounts = "/proc/mounts"
398

    
399
-- * Luxi (Local UniX Interface) related constants
400

    
401
luxiEom :: PythonChar
402
luxiEom = PythonChar '\x03'
403

    
404
-- | Environment variable for the luxi override socket
405
luxiOverride :: String
406
luxiOverride = "FORCE_LUXI_SOCKET"
407

    
408
luxiOverrideMaster :: String
409
luxiOverrideMaster = "master"
410

    
411
luxiOverrideQuery :: String
412
luxiOverrideQuery = "query"
413

    
414
luxiVersion :: Int
415
luxiVersion = configVersion
416

    
417
-- * Syslog
418

    
419
syslogUsage :: String
420
syslogUsage = AutoConf.syslogUsage
421

    
422
syslogNo :: String
423
syslogNo = Logging.syslogUsageToRaw SyslogNo
424

    
425
syslogYes :: String
426
syslogYes = Logging.syslogUsageToRaw SyslogYes
427

    
428
syslogOnly :: String
429
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
430

    
431
syslogSocket :: String
432
syslogSocket = "/dev/log"
433

    
434
exportConfFile :: String
435
exportConfFile = "config.ini"
436

    
437
-- * Xen
438

    
439
xenBootloader :: String
440
xenBootloader = AutoConf.xenBootloader
441

    
442
xenCmdXl :: String
443
xenCmdXl = "xl"
444

    
445
xenCmdXm :: String
446
xenCmdXm = "xm"
447

    
448
xenInitrd :: String
449
xenInitrd = AutoConf.xenInitrd
450

    
451
xenKernel :: String
452
xenKernel = AutoConf.xenKernel
453

    
454
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
455
-- other constants
456
knownXenCommands :: FrozenSet String
457
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
458

    
459
-- * KVM and socat
460

    
461
kvmPath :: String
462
kvmPath = AutoConf.kvmPath
463

    
464
kvmKernel :: String
465
kvmKernel = AutoConf.kvmKernel
466

    
467
socatEscapeCode :: String
468
socatEscapeCode = "0x1d"
469

    
470
socatPath :: String
471
socatPath = AutoConf.socatPath
472

    
473
socatUseCompress :: Bool
474
socatUseCompress = AutoConf.socatUseCompress
475

    
476
socatUseEscape :: Bool
477
socatUseEscape = AutoConf.socatUseEscape
478

    
479
-- * Console types
480

    
481
-- | Display a message for console access
482
consMessage :: String
483
consMessage = "msg"
484

    
485
-- | Console as SPICE server
486
consSpice :: String
487
consSpice = "spice"
488

    
489
-- | Console as SSH command
490
consSsh :: String
491
consSsh = "ssh"
492

    
493
-- | Console as VNC server
494
consVnc :: String
495
consVnc = "vnc"
496

    
497
consAll :: FrozenSet String
498
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
499

    
500
-- | RSA key bit length
501
--
502
-- For RSA keys more bits are better, but they also make operations
503
-- more expensive. NIST SP 800-131 recommends a minimum of 2048 bits
504
-- from the year 2010 on.
505
rsaKeyBits :: Int
506
rsaKeyBits = 2048
507

    
508
-- | Ciphers allowed for SSL connections.
509
--
510
-- For the format, see ciphers(1). A better way to disable ciphers
511
-- would be to use the exclamation mark (!), but socat versions below
512
-- 1.5 can't parse exclamation marks in options properly. When
513
-- modifying the ciphers, ensure not to accidentially add something
514
-- after it's been removed. Use the "openssl" utility to check the
515
-- allowed ciphers, e.g.  "openssl ciphers -v HIGH:-DES".
516
opensslCiphers :: String
517
opensslCiphers = "HIGH:-DES:-3DES:-EXPORT:-ADH"
518

    
519
-- * X509
520

    
521
-- | commonName (CN) used in certificates
522
x509CertCn :: String
523
x509CertCn = "ganeti.example.com"
524

    
525
-- | Default validity of certificates in days
526
x509CertDefaultValidity :: Int
527
x509CertDefaultValidity = 365 * 5
528

    
529
x509CertSignatureHeader :: String
530
x509CertSignatureHeader = "X-Ganeti-Signature"
531

    
532
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
533
x509CertSignDigest :: String
534
x509CertSignDigest = "SHA1"
535

    
536
-- * Import/export daemon mode
537

    
538
iemExport :: String
539
iemExport = "export"
540

    
541
iemImport :: String
542
iemImport = "import"
543

    
544
-- * Import/export transport compression
545

    
546
iecGzip :: String
547
iecGzip = "gzip"
548

    
549
iecNone :: String
550
iecNone = "none"
551

    
552
iecAll :: [String]
553
iecAll = [iecGzip, iecNone]
554

    
555
ieCustomSize :: String
556
ieCustomSize = "fd"
557

    
558
-- * Import/export I/O
559

    
560
-- | Direct file I/O, equivalent to a shell's I/O redirection using
561
-- '<' or '>'
562
ieioFile :: String
563
ieioFile = "file"
564

    
565
-- | Raw block device I/O using "dd"
566
ieioRawDisk :: String
567
ieioRawDisk = "raw"
568

    
569
-- | OS definition import/export script
570
ieioScript :: String
571
ieioScript = "script"
572

    
573
-- * Hooks
574

    
575
hooksNameCfgupdate :: String
576
hooksNameCfgupdate = "config-update"
577

    
578
hooksNameWatcher :: String
579
hooksNameWatcher = "watcher"
580

    
581
hooksPath :: String
582
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
583

    
584
hooksPhasePost :: String
585
hooksPhasePost = "post"
586

    
587
hooksPhasePre :: String
588
hooksPhasePre = "pre"
589

    
590
hooksVersion :: Int
591
hooksVersion = 2
592

    
593
-- * Hooks subject type (what object type does the LU deal with)
594

    
595
htypeCluster :: String
596
htypeCluster = "CLUSTER"
597

    
598
htypeGroup :: String
599
htypeGroup = "GROUP"
600

    
601
htypeInstance :: String
602
htypeInstance = "INSTANCE"
603

    
604
htypeNetwork :: String
605
htypeNetwork = "NETWORK"
606

    
607
htypeNode :: String
608
htypeNode = "NODE"
609

    
610
-- * Hkr
611

    
612
hkrSkip :: Int
613
hkrSkip = 0
614

    
615
hkrFail :: Int
616
hkrFail = 1
617

    
618
hkrSuccess :: Int
619
hkrSuccess = 2
620

    
621
-- * Storage types
622

    
623
stBlock :: String
624
stBlock = Types.storageTypeToRaw StorageBlock
625

    
626
stDiskless :: String
627
stDiskless = Types.storageTypeToRaw StorageDiskless
628

    
629
stExt :: String
630
stExt = Types.storageTypeToRaw StorageExt
631

    
632
stFile :: String
633
stFile = Types.storageTypeToRaw StorageFile
634

    
635
stLvmPv :: String
636
stLvmPv = Types.storageTypeToRaw StorageLvmPv
637

    
638
stLvmVg :: String
639
stLvmVg = Types.storageTypeToRaw StorageLvmVg
640

    
641
stRados :: String
642
stRados = Types.storageTypeToRaw StorageRados
643

    
644
storageTypes :: FrozenSet String
645
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
646

    
647
-- | The set of storage types for which storage reporting is available
648
--
649
-- FIXME: Remove this, once storage reporting is available for all
650
-- types.
651
stsReport :: FrozenSet String
652
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
653

    
654
-- * Storage fields
655
-- ** First two are valid in LU context only, not passed to backend
656

    
657
sfNode :: String
658
sfNode = "node"
659

    
660
sfType :: String
661
sfType = "type"
662

    
663
-- ** and the rest are valid in backend
664

    
665
sfAllocatable :: String
666
sfAllocatable = Types.storageFieldToRaw SFAllocatable
667

    
668
sfFree :: String
669
sfFree = Types.storageFieldToRaw SFFree
670

    
671
sfName :: String
672
sfName = Types.storageFieldToRaw SFName
673

    
674
sfSize :: String
675
sfSize = Types.storageFieldToRaw SFSize
676

    
677
sfUsed :: String
678
sfUsed = Types.storageFieldToRaw SFUsed
679

    
680
validStorageFields :: FrozenSet String
681
validStorageFields =
682
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
683
                        [sfNode, sfType]
684

    
685
modifiableStorageFields :: Map String (FrozenSet String)
686
modifiableStorageFields =
687
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
688
                 ConstantUtils.mkSet [sfAllocatable])]
689

    
690
-- * Storage operations
691

    
692
soFixConsistency :: String
693
soFixConsistency = "fix-consistency"
694

    
695
validStorageOperations :: Map String (FrozenSet String)
696
validStorageOperations =
697
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
698
                 ConstantUtils.mkSet [soFixConsistency])]
699

    
700
-- * Volume fields
701

    
702
vfDev :: String
703
vfDev = "dev"
704

    
705
vfInstance :: String
706
vfInstance = "instance"
707

    
708
vfName :: String
709
vfName = "name"
710

    
711
vfNode :: String
712
vfNode = "node"
713

    
714
vfPhys :: String
715
vfPhys = "phys"
716

    
717
vfSize :: String
718
vfSize = "size"
719

    
720
vfVg :: String
721
vfVg = "vg"
722

    
723
-- * Local disk status
724

    
725
ldsFaulty :: Int
726
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
727

    
728
ldsOkay :: Int
729
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
730

    
731
ldsUnknown :: Int
732
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
733

    
734
ldsNames :: Map Int String
735
ldsNames =
736
  Map.fromList [ (Types.localDiskStatusToRaw ds,
737
                  localDiskStatusName ds) | ds <- [minBound..] ]
738

    
739
-- * Disk template types
740

    
741
dtDiskless :: String
742
dtDiskless = Types.diskTemplateToRaw DTDiskless
743

    
744
dtFile :: String
745
dtFile = Types.diskTemplateToRaw DTFile
746

    
747
dtSharedFile :: String
748
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
749

    
750
dtPlain :: String
751
dtPlain = Types.diskTemplateToRaw DTPlain
752

    
753
dtBlock :: String
754
dtBlock = Types.diskTemplateToRaw DTBlock
755

    
756
dtDrbd8 :: String
757
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
758

    
759
dtRbd :: String
760
dtRbd = Types.diskTemplateToRaw DTRbd
761

    
762
dtExt :: String
763
dtExt = Types.diskTemplateToRaw DTExt
764

    
765
-- | This is used to order determine the default disk template when
766
-- the list of enabled disk templates is inferred from the current
767
-- state of the cluster.  This only happens on an upgrade from a
768
-- version of Ganeti that did not support the 'enabled_disk_templates'
769
-- so far.
770
diskTemplatePreference :: [String]
771
diskTemplatePreference =
772
  map Types.diskTemplateToRaw
773
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile, DTPlain, DTRbd, DTSharedFile]
774

    
775
diskTemplates :: FrozenSet String
776
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
777

    
778
-- | Disk templates that are enabled by default
779
defaultEnabledDiskTemplates :: [String]
780
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
781

    
782
-- | Mapping of disk templates to storage types
783
mapDiskTemplateStorageType :: Map String String
784
mapDiskTemplateStorageType =
785
  Map.fromList $
786
  map (Types.diskTemplateToRaw *** Types.storageTypeToRaw)
787
  [(DTBlock, StorageBlock),
788
   (DTDrbd8, StorageLvmVg),
789
   (DTExt, StorageExt),
790
   (DTSharedFile, StorageFile),
791
   (DTFile, StorageFile),
792
   (DTDiskless, StorageDiskless),
793
   (DTPlain, StorageLvmVg),
794
   (DTRbd, StorageRados)]
795

    
796
-- | The set of network-mirrored disk templates
797
dtsIntMirror :: FrozenSet String
798
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
799

    
800
-- | 'DTDiskless' is 'trivially' externally mirrored
801
dtsExtMirror :: FrozenSet String
802
dtsExtMirror =
803
  ConstantUtils.mkSet $
804
  map Types.diskTemplateToRaw [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd]
805

    
806
-- | The set of non-lvm-based disk templates
807
dtsNotLvm :: FrozenSet String
808
dtsNotLvm =
809
  ConstantUtils.mkSet $
810
  map Types.diskTemplateToRaw
811
  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd]
812

    
813
-- | The set of disk templates which can be grown
814
dtsGrowable :: FrozenSet String
815
dtsGrowable =
816
  ConstantUtils.mkSet $
817
  map Types.diskTemplateToRaw
818
  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd]
819

    
820
-- | The set of disk templates that allow adoption
821
dtsMayAdopt :: FrozenSet String
822
dtsMayAdopt =
823
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
824

    
825
-- | The set of disk templates that *must* use adoption
826
dtsMustAdopt :: FrozenSet String
827
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
828

    
829
-- | The set of disk templates that allow migrations
830
dtsMirrored :: FrozenSet String
831
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
832

    
833
-- | The set of file based disk templates
834
dtsFilebased :: FrozenSet String
835
dtsFilebased =
836
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTSharedFile, DTFile]
837

    
838
-- | The set of disk templates that can be moved by copying
839
--
840
-- Note: a requirement is that they're not accessed externally or
841
-- shared between nodes; in particular, sharedfile is not suitable.
842
dtsCopyable :: FrozenSet String
843
dtsCopyable =
844
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
845

    
846
-- | The set of disk templates that are supported by exclusive_storage
847
dtsExclStorage :: FrozenSet String
848
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
849

    
850
-- | Templates for which we don't perform checks on free space
851
dtsNoFreeSpaceCheck :: FrozenSet String
852
dtsNoFreeSpaceCheck =
853
  ConstantUtils.mkSet $
854
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd]
855

    
856
dtsBlock :: FrozenSet String
857
dtsBlock =
858
  ConstantUtils.mkSet $
859
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
860

    
861
-- * Drbd
862

    
863
drbdHmacAlg :: String
864
drbdHmacAlg = "md5"
865

    
866
drbdDefaultNetProtocol :: String
867
drbdDefaultNetProtocol = "C"
868

    
869
drbdMigrationNetProtocol :: String
870
drbdMigrationNetProtocol = "C"
871

    
872
drbdStatusFile :: String
873
drbdStatusFile = "/proc/drbd"
874

    
875
-- | Size of DRBD meta block device
876
drbdMetaSize :: Int
877
drbdMetaSize = 128
878

    
879
-- * Drbd barrier types
880

    
881
drbdBDiskBarriers :: String
882
drbdBDiskBarriers = "b"
883

    
884
drbdBDiskDrain :: String
885
drbdBDiskDrain = "d"
886

    
887
drbdBDiskFlush :: String
888
drbdBDiskFlush = "f"
889

    
890
drbdBNone :: String
891
drbdBNone = "n"
892

    
893
-- | Rbd tool command
894
rbdCmd :: String
895
rbdCmd = "rbd"
896

    
897
-- * File backend driver
898

    
899
fdBlktap :: String
900
fdBlktap = Types.fileDriverToRaw FileBlktap
901

    
902
fdLoop :: String
903
fdLoop = Types.fileDriverToRaw FileLoop
904

    
905
fileDriver :: FrozenSet String
906
fileDriver =
907
  ConstantUtils.mkSet $
908
  map Types.fileDriverToRaw [minBound..]
909

    
910
-- | The set of drbd-like disk types
911
dtsDrbd :: FrozenSet String
912
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
913

    
914
-- * Disk access mode
915

    
916
diskRdonly :: String
917
diskRdonly = Types.diskModeToRaw DiskRdOnly
918

    
919
diskRdwr :: String
920
diskRdwr = Types.diskModeToRaw DiskRdWr
921

    
922
diskAccessSet :: FrozenSet String
923
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
924

    
925
-- * Disk replacement mode
926

    
927
replaceDiskAuto :: String
928
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
929

    
930
replaceDiskChg :: String
931
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
932

    
933
replaceDiskPri :: String
934
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
935

    
936
replaceDiskSec :: String
937
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
938

    
939
replaceModes :: FrozenSet String
940
replaceModes =
941
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
942

    
943
-- * Instance export mode
944

    
945
exportModeLocal :: String
946
exportModeLocal = Types.exportModeToRaw ExportModeLocal
947

    
948
exportModeRemote :: String
949
exportModeRemote = Types.exportModeToRaw ExportModeRemote
950

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

    
954
-- * Instance creation modes
955

    
956
instanceCreate :: String
957
instanceCreate = Types.instCreateModeToRaw InstCreate
958

    
959
instanceImport :: String
960
instanceImport = Types.instCreateModeToRaw InstImport
961

    
962
instanceRemoteImport :: String
963
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
964

    
965
instanceCreateModes :: FrozenSet String
966
instanceCreateModes =
967
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
968

    
969
-- * Remote import/export handshake message and version
970

    
971
rieHandshake :: String
972
rieHandshake = "Hi, I'm Ganeti"
973

    
974
rieVersion :: Int
975
rieVersion = 0
976

    
977
-- | Remote import/export certificate validity in seconds
978
rieCertValidity :: Int
979
rieCertValidity = 24 * 60 * 60
980

    
981
-- | Export only: how long to wait per connection attempt (seconds)
982
rieConnectAttemptTimeout :: Int
983
rieConnectAttemptTimeout = 20
984

    
985
-- | Export only: number of attempts to connect
986
rieConnectRetries :: Int
987
rieConnectRetries = 10
988

    
989
-- | Overall timeout for establishing connection
990
rieConnectTimeout :: Int
991
rieConnectTimeout = 180
992

    
993
-- | Give child process up to 5 seconds to exit after sending a signal
994
childLingerTimeout :: Double
995
childLingerTimeout = 5.0
996

    
997
-- * Import/export config options
998

    
999
inisectBep :: String
1000
inisectBep = "backend"
1001

    
1002
inisectExp :: String
1003
inisectExp = "export"
1004

    
1005
inisectHyp :: String
1006
inisectHyp = "hypervisor"
1007

    
1008
inisectIns :: String
1009
inisectIns = "instance"
1010

    
1011
inisectOsp :: String
1012
inisectOsp = "os"
1013

    
1014
-- * Dynamic device modification
1015

    
1016
ddmAdd :: String
1017
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1018

    
1019
ddmModify :: String
1020
ddmModify = Types.ddmFullToRaw DdmFullModify
1021

    
1022
ddmRemove :: String
1023
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1024

    
1025
ddmsValues :: FrozenSet String
1026
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1027

    
1028
ddmsValuesWithModify :: FrozenSet String
1029
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1030

    
1031
-- * Common exit codes
1032

    
1033
exitSuccess :: Int
1034
exitSuccess = 0
1035

    
1036
exitFailure :: Int
1037
exitFailure = ConstantUtils.exitFailure
1038

    
1039
exitNotcluster :: Int
1040
exitNotcluster = 5
1041

    
1042
exitNotmaster :: Int
1043
exitNotmaster = 11
1044

    
1045
exitNodesetupError :: Int
1046
exitNodesetupError = 12
1047

    
1048
-- | Need user confirmation
1049
exitConfirmation :: Int
1050
exitConfirmation = 13
1051

    
1052
-- | Exit code for query operations with unknown fields
1053
exitUnknownField :: Int
1054
exitUnknownField = 14
1055

    
1056
-- * Tags
1057

    
1058
tagCluster :: String
1059
tagCluster = Types.tagKindToRaw TagKindCluster
1060

    
1061
tagInstance :: String
1062
tagInstance = Types.tagKindToRaw TagKindInstance
1063

    
1064
tagNetwork :: String
1065
tagNetwork = Types.tagKindToRaw TagKindNetwork
1066

    
1067
tagNode :: String
1068
tagNode = Types.tagKindToRaw TagKindNode
1069

    
1070
tagNodegroup :: String
1071
tagNodegroup = Types.tagKindToRaw TagKindGroup
1072

    
1073
validTagTypes :: FrozenSet String
1074
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1075

    
1076
maxTagLen :: Int
1077
maxTagLen = 128
1078

    
1079
maxTagsPerObj :: Int
1080
maxTagsPerObj = 4096
1081

    
1082
-- * Others
1083

    
1084
defaultBridge :: String
1085
defaultBridge = "xen-br0"
1086

    
1087
defaultOvs :: String
1088
defaultOvs = "switch1"
1089

    
1090
-- | 60 MiB, expressed in KiB
1091
classicDrbdSyncSpeed :: Int
1092
classicDrbdSyncSpeed = 60 * 1024
1093

    
1094
ip4AddressAny :: String
1095
ip4AddressAny = "0.0.0.0"
1096

    
1097
ip4AddressLocalhost :: String
1098
ip4AddressLocalhost = "127.0.0.1"
1099

    
1100
ip6AddressAny :: String
1101
ip6AddressAny = "::"
1102

    
1103
ip6AddressLocalhost :: String
1104
ip6AddressLocalhost = "::1"
1105

    
1106
ip4Version :: Int
1107
ip4Version = 4
1108

    
1109
ip6Version :: Int
1110
ip6Version = 6
1111

    
1112
validIpVersions :: FrozenSet Int
1113
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1114

    
1115
tcpPingTimeout :: Int
1116
tcpPingTimeout = 10
1117

    
1118
defaultVg :: String
1119
defaultVg = "xenvg"
1120

    
1121
defaultDrbdHelper :: String
1122
defaultDrbdHelper = "/bin/true"
1123

    
1124
minVgSize :: Int
1125
minVgSize = 20480
1126

    
1127
defaultMacPrefix :: String
1128
defaultMacPrefix = "aa:00:00"
1129

    
1130
-- | Default maximum instance wait time, in seconds.
1131
defaultShutdownTimeout :: Int
1132
defaultShutdownTimeout = 120
1133

    
1134
-- | Node clock skew in seconds
1135
nodeMaxClockSkew :: Int
1136
nodeMaxClockSkew = 150
1137

    
1138
-- | Time for an intra-cluster disk transfer to wait for a connection
1139
diskTransferConnectTimeout :: Int
1140
diskTransferConnectTimeout = 60
1141

    
1142
-- | Disk index separator
1143
diskSeparator :: String
1144
diskSeparator = AutoConf.diskSeparator
1145

    
1146
ipCommandPath :: String
1147
ipCommandPath = AutoConf.ipPath
1148

    
1149
-- | Key for job IDs in opcode result
1150
jobIdsKey :: String
1151
jobIdsKey = "jobs"
1152

    
1153
-- * Runparts results
1154

    
1155
runpartsErr :: Int
1156
runpartsErr = 2
1157

    
1158
runpartsRun :: Int
1159
runpartsRun = 1
1160

    
1161
runpartsSkip :: Int
1162
runpartsSkip = 0
1163

    
1164
runpartsStatus :: [Int]
1165
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1166

    
1167
-- * RPC
1168

    
1169
rpcEncodingNone :: Int
1170
rpcEncodingNone = 0
1171

    
1172
rpcEncodingZlibBase64 :: Int
1173
rpcEncodingZlibBase64 = 1
1174

    
1175
-- * Timeout table
1176
--
1177
-- Various time constants for the timeout table
1178

    
1179
rpcTmoUrgent :: Int
1180
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1181

    
1182
rpcTmoFast :: Int
1183
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1184

    
1185
rpcTmoNormal :: Int
1186
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1187

    
1188
rpcTmoSlow :: Int
1189
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1190

    
1191
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1192
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1193
-- Python name.
1194
rpcTmo_4hrs :: Int
1195
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1196

    
1197
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1198
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1199
-- Python name.
1200
rpcTmo_1day :: Int
1201
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1202

    
1203
-- | Timeout for connecting to nodes (seconds)
1204
rpcConnectTimeout :: Int
1205
rpcConnectTimeout = 5
1206

    
1207
-- OS
1208

    
1209
osScriptCreate :: String
1210
osScriptCreate = "create"
1211

    
1212
osScriptExport :: String
1213
osScriptExport = "export"
1214

    
1215
osScriptImport :: String
1216
osScriptImport = "import"
1217

    
1218
osScriptRename :: String
1219
osScriptRename = "rename"
1220

    
1221
osScriptVerify :: String
1222
osScriptVerify = "verify"
1223

    
1224
osScripts :: [String]
1225
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1226
             osScriptVerify]
1227

    
1228
osApiFile :: String
1229
osApiFile = "ganeti_api_version"
1230

    
1231
osVariantsFile :: String
1232
osVariantsFile = "variants.list"
1233

    
1234
osParametersFile :: String
1235
osParametersFile = "parameters.list"
1236

    
1237
osValidateParameters :: String
1238
osValidateParameters = "parameters"
1239

    
1240
osValidateCalls :: FrozenSet String
1241
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1242

    
1243
-- | External Storage (ES) related constants
1244

    
1245
esActionAttach :: String
1246
esActionAttach = "attach"
1247

    
1248
esActionCreate :: String
1249
esActionCreate = "create"
1250

    
1251
esActionDetach :: String
1252
esActionDetach = "detach"
1253

    
1254
esActionGrow :: String
1255
esActionGrow = "grow"
1256

    
1257
esActionRemove :: String
1258
esActionRemove = "remove"
1259

    
1260
esActionSetinfo :: String
1261
esActionSetinfo = "setinfo"
1262

    
1263
esActionVerify :: String
1264
esActionVerify = "verify"
1265

    
1266
esScriptCreate :: String
1267
esScriptCreate = esActionCreate
1268

    
1269
esScriptRemove :: String
1270
esScriptRemove = esActionRemove
1271

    
1272
esScriptGrow :: String
1273
esScriptGrow = esActionGrow
1274

    
1275
esScriptAttach :: String
1276
esScriptAttach = esActionAttach
1277

    
1278
esScriptDetach :: String
1279
esScriptDetach = esActionDetach
1280

    
1281
esScriptSetinfo :: String
1282
esScriptSetinfo = esActionSetinfo
1283

    
1284
esScriptVerify :: String
1285
esScriptVerify = esActionVerify
1286

    
1287
esScripts :: FrozenSet String
1288
esScripts =
1289
  ConstantUtils.mkSet [esScriptAttach,
1290
                       esScriptCreate,
1291
                       esScriptDetach,
1292
                       esScriptGrow,
1293
                       esScriptRemove,
1294
                       esScriptSetinfo,
1295
                       esScriptVerify]
1296

    
1297
esParametersFile :: String
1298
esParametersFile = "parameters.list"
1299

    
1300
-- * Reboot types
1301

    
1302
instanceRebootSoft :: String
1303
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1304

    
1305
instanceRebootHard :: String
1306
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1307

    
1308
instanceRebootFull :: String
1309
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1310

    
1311
rebootTypes :: FrozenSet String
1312
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1313

    
1314
-- * Instance reboot behaviors
1315

    
1316
instanceRebootAllowed :: String
1317
instanceRebootAllowed = "reboot"
1318

    
1319
instanceRebootExit :: String
1320
instanceRebootExit = "exit"
1321

    
1322
rebootBehaviors :: [String]
1323
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1324

    
1325
-- * VTypes
1326

    
1327
vtypeBool :: VType
1328
vtypeBool = VTypeBool
1329

    
1330
vtypeInt :: VType
1331
vtypeInt = VTypeInt
1332

    
1333
vtypeMaybeString :: VType
1334
vtypeMaybeString = VTypeMaybeString
1335

    
1336
-- | Size in MiBs
1337
vtypeSize :: VType
1338
vtypeSize = VTypeSize
1339

    
1340
vtypeString :: VType
1341
vtypeString = VTypeString
1342

    
1343
enforceableTypes :: FrozenSet VType
1344
enforceableTypes = ConstantUtils.mkSet [minBound..]
1345

    
1346
-- | Constant representing that the user does not specify any IP version
1347
ifaceNoIpVersionSpecified :: Int
1348
ifaceNoIpVersionSpecified = 0
1349

    
1350
validSerialSpeeds :: [Int]
1351
validSerialSpeeds =
1352
  [75,
1353
   110,
1354
   300,
1355
   600,
1356
   1200,
1357
   1800,
1358
   2400,
1359
   4800,
1360
   9600,
1361
   14400,
1362
   19200,
1363
   28800,
1364
   38400,
1365
   57600,
1366
   115200,
1367
   230400,
1368
   345600,
1369
   460800]
1370

    
1371
-- * HV parameter names (global namespace)
1372

    
1373
hvAcpi :: String
1374
hvAcpi = "acpi"
1375

    
1376
hvBlockdevPrefix :: String
1377
hvBlockdevPrefix = "blockdev_prefix"
1378

    
1379
hvBootloaderArgs :: String
1380
hvBootloaderArgs = "bootloader_args"
1381

    
1382
hvBootloaderPath :: String
1383
hvBootloaderPath = "bootloader_path"
1384

    
1385
hvBootOrder :: String
1386
hvBootOrder = "boot_order"
1387

    
1388
hvCdromImagePath :: String
1389
hvCdromImagePath = "cdrom_image_path"
1390

    
1391
hvCpuCap :: String
1392
hvCpuCap = "cpu_cap"
1393

    
1394
hvCpuCores :: String
1395
hvCpuCores = "cpu_cores"
1396

    
1397
hvCpuMask :: String
1398
hvCpuMask = "cpu_mask"
1399

    
1400
hvCpuSockets :: String
1401
hvCpuSockets = "cpu_sockets"
1402

    
1403
hvCpuThreads :: String
1404
hvCpuThreads = "cpu_threads"
1405

    
1406
hvCpuType :: String
1407
hvCpuType = "cpu_type"
1408

    
1409
hvCpuWeight :: String
1410
hvCpuWeight = "cpu_weight"
1411

    
1412
hvDeviceModel :: String
1413
hvDeviceModel = "device_model"
1414

    
1415
hvDiskCache :: String
1416
hvDiskCache = "disk_cache"
1417

    
1418
hvDiskType :: String
1419
hvDiskType = "disk_type"
1420

    
1421
hvInitrdPath :: String
1422
hvInitrdPath = "initrd_path"
1423

    
1424
hvInitScript :: String
1425
hvInitScript = "init_script"
1426

    
1427
hvKernelArgs :: String
1428
hvKernelArgs = "kernel_args"
1429

    
1430
hvKernelPath :: String
1431
hvKernelPath = "kernel_path"
1432

    
1433
hvKeymap :: String
1434
hvKeymap = "keymap"
1435

    
1436
hvKvmCdrom2ImagePath :: String
1437
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1438

    
1439
hvKvmCdromDiskType :: String
1440
hvKvmCdromDiskType = "cdrom_disk_type"
1441

    
1442
hvKvmExtra :: String
1443
hvKvmExtra = "kvm_extra"
1444

    
1445
hvKvmFlag :: String
1446
hvKvmFlag = "kvm_flag"
1447

    
1448
hvKvmFloppyImagePath :: String
1449
hvKvmFloppyImagePath = "floppy_image_path"
1450

    
1451
hvKvmMachineVersion :: String
1452
hvKvmMachineVersion = "machine_version"
1453

    
1454
hvKvmPath :: String
1455
hvKvmPath = "kvm_path"
1456

    
1457
hvKvmSpiceAudioCompr :: String
1458
hvKvmSpiceAudioCompr = "spice_playback_compression"
1459

    
1460
hvKvmSpiceBind :: String
1461
hvKvmSpiceBind = "spice_bind"
1462

    
1463
hvKvmSpiceIpVersion :: String
1464
hvKvmSpiceIpVersion = "spice_ip_version"
1465

    
1466
hvKvmSpiceJpegImgCompr :: String
1467
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1468

    
1469
hvKvmSpiceLosslessImgCompr :: String
1470
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1471

    
1472
hvKvmSpicePasswordFile :: String
1473
hvKvmSpicePasswordFile = "spice_password_file"
1474

    
1475
hvKvmSpiceStreamingVideoDetection :: String
1476
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1477

    
1478
hvKvmSpiceTlsCiphers :: String
1479
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1480

    
1481
hvKvmSpiceUseTls :: String
1482
hvKvmSpiceUseTls = "spice_use_tls"
1483

    
1484
hvKvmSpiceUseVdagent :: String
1485
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1486

    
1487
hvKvmSpiceZlibGlzImgCompr :: String
1488
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1489

    
1490
hvKvmUseChroot :: String
1491
hvKvmUseChroot = "use_chroot"
1492

    
1493
hvMemPath :: String
1494
hvMemPath = "mem_path"
1495

    
1496
hvMigrationBandwidth :: String
1497
hvMigrationBandwidth = "migration_bandwidth"
1498

    
1499
hvMigrationDowntime :: String
1500
hvMigrationDowntime = "migration_downtime"
1501

    
1502
hvMigrationMode :: String
1503
hvMigrationMode = "migration_mode"
1504

    
1505
hvMigrationPort :: String
1506
hvMigrationPort = "migration_port"
1507

    
1508
hvNicType :: String
1509
hvNicType = "nic_type"
1510

    
1511
hvPae :: String
1512
hvPae = "pae"
1513

    
1514
hvPassthrough :: String
1515
hvPassthrough = "pci_pass"
1516

    
1517
hvRebootBehavior :: String
1518
hvRebootBehavior = "reboot_behavior"
1519

    
1520
hvRootPath :: String
1521
hvRootPath = "root_path"
1522

    
1523
hvSecurityDomain :: String
1524
hvSecurityDomain = "security_domain"
1525

    
1526
hvSecurityModel :: String
1527
hvSecurityModel = "security_model"
1528

    
1529
hvSerialConsole :: String
1530
hvSerialConsole = "serial_console"
1531

    
1532
hvSerialSpeed :: String
1533
hvSerialSpeed = "serial_speed"
1534

    
1535
hvSoundhw :: String
1536
hvSoundhw = "soundhw"
1537

    
1538
hvUsbDevices :: String
1539
hvUsbDevices = "usb_devices"
1540

    
1541
hvUsbMouse :: String
1542
hvUsbMouse = "usb_mouse"
1543

    
1544
hvUseBootloader :: String
1545
hvUseBootloader = "use_bootloader"
1546

    
1547
hvUseLocaltime :: String
1548
hvUseLocaltime = "use_localtime"
1549

    
1550
hvVga :: String
1551
hvVga = "vga"
1552

    
1553
hvVhostNet :: String
1554
hvVhostNet = "vhost_net"
1555

    
1556
hvVifScript :: String
1557
hvVifScript = "vif_script"
1558

    
1559
hvVifType :: String
1560
hvVifType = "vif_type"
1561

    
1562
hvViridian :: String
1563
hvViridian = "viridian"
1564

    
1565
hvVncBindAddress :: String
1566
hvVncBindAddress = "vnc_bind_address"
1567

    
1568
hvVncPasswordFile :: String
1569
hvVncPasswordFile = "vnc_password_file"
1570

    
1571
hvVncTls :: String
1572
hvVncTls = "vnc_tls"
1573

    
1574
hvVncX509 :: String
1575
hvVncX509 = "vnc_x509_path"
1576

    
1577
hvVncX509Verify :: String
1578
hvVncX509Verify = "vnc_x509_verify"
1579

    
1580
hvVnetHdr :: String
1581
hvVnetHdr = "vnet_hdr"
1582

    
1583
hvXenCmd :: String
1584
hvXenCmd = "xen_cmd"
1585

    
1586
hvXenCpuid :: String
1587
hvXenCpuid = "cpuid"
1588

    
1589
hvsParameterTitles :: Map String String
1590
hvsParameterTitles =
1591
  Map.fromList
1592
  [(hvAcpi, "ACPI"),
1593
   (hvBootOrder, "Boot_order"),
1594
   (hvCdromImagePath, "CDROM_image_path"),
1595
   (hvCpuType, "cpu_type"),
1596
   (hvDiskType, "Disk_type"),
1597
   (hvInitrdPath, "Initrd_path"),
1598
   (hvKernelPath, "Kernel_path"),
1599
   (hvNicType, "NIC_type"),
1600
   (hvPae, "PAE"),
1601
   (hvPassthrough, "pci_pass"),
1602
   (hvVncBindAddress, "VNC_bind_address")]
1603

    
1604
-- * Migration statuses
1605

    
1606
hvMigrationActive :: String
1607
hvMigrationActive = "active"
1608

    
1609
hvMigrationCancelled :: String
1610
hvMigrationCancelled = "cancelled"
1611

    
1612
hvMigrationCompleted :: String
1613
hvMigrationCompleted = "completed"
1614

    
1615
hvMigrationFailed :: String
1616
hvMigrationFailed = "failed"
1617

    
1618
hvMigrationValidStatuses :: FrozenSet String
1619
hvMigrationValidStatuses =
1620
  ConstantUtils.mkSet [hvMigrationActive,
1621
                       hvMigrationCancelled,
1622
                       hvMigrationCompleted,
1623
                       hvMigrationFailed]
1624

    
1625
hvMigrationFailedStatuses :: FrozenSet String
1626
hvMigrationFailedStatuses =
1627
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1628

    
1629
-- | KVM-specific statuses
1630
--
1631
-- FIXME: this constant seems unnecessary
1632
hvKvmMigrationValidStatuses :: FrozenSet String
1633
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1634

    
1635
-- | Node info keys
1636
hvNodeinfoKeyVersion :: String
1637
hvNodeinfoKeyVersion = "hv_version"
1638

    
1639
-- * Hypervisor state
1640

    
1641
hvstCpuNode :: String
1642
hvstCpuNode = "cpu_node"
1643

    
1644
hvstCpuTotal :: String
1645
hvstCpuTotal = "cpu_total"
1646

    
1647
hvstMemoryHv :: String
1648
hvstMemoryHv = "mem_hv"
1649

    
1650
hvstMemoryNode :: String
1651
hvstMemoryNode = "mem_node"
1652

    
1653
hvstMemoryTotal :: String
1654
hvstMemoryTotal = "mem_total"
1655

    
1656
hvstsParameters :: FrozenSet String
1657
hvstsParameters =
1658
  ConstantUtils.mkSet [hvstCpuNode,
1659
                       hvstCpuTotal,
1660
                       hvstMemoryHv,
1661
                       hvstMemoryNode,
1662
                       hvstMemoryTotal]
1663

    
1664
hvstDefaults :: Map String Int
1665
hvstDefaults =
1666
  Map.fromList
1667
  [(hvstCpuNode, 1),
1668
   (hvstCpuTotal, 1),
1669
   (hvstMemoryHv, 0),
1670
   (hvstMemoryTotal, 0),
1671
   (hvstMemoryNode, 0)]
1672

    
1673
hvstsParameterTypes :: Map String VType
1674
hvstsParameterTypes =
1675
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1676
                (hvstMemoryNode, VTypeInt),
1677
                (hvstMemoryHv, VTypeInt),
1678
                (hvstCpuTotal, VTypeInt),
1679
                (hvstCpuNode, VTypeInt)]
1680

    
1681
-- * Disk state
1682

    
1683
dsDiskOverhead :: String
1684
dsDiskOverhead = "disk_overhead"
1685

    
1686
dsDiskReserved :: String
1687
dsDiskReserved = "disk_reserved"
1688

    
1689
dsDiskTotal :: String
1690
dsDiskTotal = "disk_total"
1691

    
1692
dsDefaults :: Map String Int
1693
dsDefaults =
1694
  Map.fromList
1695
  [(dsDiskTotal, 0),
1696
   (dsDiskReserved, 0),
1697
   (dsDiskOverhead, 0)]
1698

    
1699
dssParameterTypes :: Map String VType
1700
dssParameterTypes =
1701
  Map.fromList [(dsDiskTotal, VTypeInt),
1702
                (dsDiskReserved, VTypeInt),
1703
                (dsDiskOverhead, VTypeInt)]
1704

    
1705
dssParameters :: FrozenSet String
1706
dssParameters =
1707
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1708

    
1709
dsValidTypes :: FrozenSet String
1710
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1711

    
1712
-- Backend parameter names
1713

    
1714
beAlwaysFailover :: String
1715
beAlwaysFailover = "always_failover"
1716

    
1717
beAutoBalance :: String
1718
beAutoBalance = "auto_balance"
1719

    
1720
beMaxmem :: String
1721
beMaxmem = "maxmem"
1722

    
1723
-- | Deprecated and replaced by max and min mem
1724
beMemory :: String
1725
beMemory = "memory"
1726

    
1727
beMinmem :: String
1728
beMinmem = "minmem"
1729

    
1730
beSpindleUse :: String
1731
beSpindleUse = "spindle_use"
1732

    
1733
beVcpus :: String
1734
beVcpus = "vcpus"
1735

    
1736
besParameterTypes :: Map String VType
1737
besParameterTypes =
1738
  Map.fromList [(beAlwaysFailover, VTypeBool),
1739
                (beAutoBalance, VTypeBool),
1740
                (beMaxmem, VTypeSize),
1741
                (beMinmem, VTypeSize),
1742
                (beSpindleUse, VTypeInt),
1743
                (beVcpus, VTypeInt)]
1744

    
1745
besParameterTitles :: Map String String
1746
besParameterTitles =
1747
  Map.fromList [(beAutoBalance, "Auto_balance"),
1748
                (beMinmem, "ConfigMinMem"),
1749
                (beVcpus, "ConfigVCPUs"),
1750
                (beMaxmem, "ConfigMaxMem")]
1751

    
1752
besParameterCompat :: Map String VType
1753
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1754

    
1755
besParameters :: FrozenSet String
1756
besParameters =
1757
  ConstantUtils.mkSet [beAlwaysFailover,
1758
                       beAutoBalance,
1759
                       beMaxmem,
1760
                       beMinmem,
1761
                       beSpindleUse,
1762
                       beVcpus]
1763

    
1764
-- | Instance specs
1765
--
1766
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1767

    
1768
ispecMemSize :: String
1769
ispecMemSize = ConstantUtils.ispecMemSize
1770

    
1771
ispecCpuCount :: String
1772
ispecCpuCount = ConstantUtils.ispecCpuCount
1773

    
1774
ispecDiskCount :: String
1775
ispecDiskCount = ConstantUtils.ispecDiskCount
1776

    
1777
ispecDiskSize :: String
1778
ispecDiskSize = ConstantUtils.ispecDiskSize
1779

    
1780
ispecNicCount :: String
1781
ispecNicCount = ConstantUtils.ispecNicCount
1782

    
1783
ispecSpindleUse :: String
1784
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1785

    
1786
ispecsParameterTypes :: Map String VType
1787
ispecsParameterTypes =
1788
  Map.fromList
1789
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1790
   (ConstantUtils.ispecCpuCount, VTypeInt),
1791
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1792
   (ConstantUtils.ispecMemSize, VTypeInt),
1793
   (ConstantUtils.ispecNicCount, VTypeInt),
1794
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1795

    
1796
ispecsParameters :: FrozenSet String
1797
ispecsParameters =
1798
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1799
                       ConstantUtils.ispecDiskCount,
1800
                       ConstantUtils.ispecDiskSize,
1801
                       ConstantUtils.ispecMemSize,
1802
                       ConstantUtils.ispecNicCount,
1803
                       ConstantUtils.ispecSpindleUse]
1804

    
1805
ispecsMinmax :: String
1806
ispecsMinmax = ConstantUtils.ispecsMinmax
1807

    
1808
ispecsMax :: String
1809
ispecsMax = "max"
1810

    
1811
ispecsMin :: String
1812
ispecsMin = "min"
1813

    
1814
ispecsStd :: String
1815
ispecsStd = ConstantUtils.ispecsStd
1816

    
1817
ipolicyDts :: String
1818
ipolicyDts = ConstantUtils.ipolicyDts
1819

    
1820
ipolicyVcpuRatio :: String
1821
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1822

    
1823
ipolicySpindleRatio :: String
1824
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
1825

    
1826
ispecsMinmaxKeys :: FrozenSet String
1827
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1828

    
1829
ipolicyParameters :: FrozenSet String
1830
ipolicyParameters =
1831
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1832
                       ConstantUtils.ipolicySpindleRatio]
1833

    
1834
ipolicyAllKeys :: FrozenSet String
1835
ipolicyAllKeys =
1836
  ConstantUtils.union ipolicyParameters $
1837
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1838
                       ConstantUtils.ispecsMinmax,
1839
                       ispecsStd]
1840

    
1841
-- | Node parameter names
1842

    
1843
ndExclusiveStorage :: String
1844
ndExclusiveStorage = "exclusive_storage"
1845

    
1846
ndOobProgram :: String
1847
ndOobProgram = "oob_program"
1848

    
1849
ndSpindleCount :: String
1850
ndSpindleCount = "spindle_count"
1851

    
1852
ndOvs :: String
1853
ndOvs = "ovs"
1854

    
1855
ndOvsLink :: String
1856
ndOvsLink = "ovs_link"
1857

    
1858
ndOvsName :: String
1859
ndOvsName = "ovs_name"
1860

    
1861
ndsParameterTypes :: Map String VType
1862
ndsParameterTypes =
1863
  Map.fromList
1864
  [(ndExclusiveStorage, VTypeBool),
1865
   (ndOobProgram, VTypeString),
1866
   (ndOvs, VTypeBool),
1867
   (ndOvsLink, VTypeMaybeString),
1868
   (ndOvsName, VTypeMaybeString),
1869
   (ndSpindleCount, VTypeInt)]
1870

    
1871
ndsParameters :: FrozenSet String
1872
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
1873

    
1874
ndsParameterTitles :: Map String String
1875
ndsParameterTitles =
1876
  Map.fromList
1877
  [(ndExclusiveStorage, "ExclusiveStorage"),
1878
   (ndOobProgram, "OutOfBandProgram"),
1879
   (ndOvs, "OpenvSwitch"),
1880
   (ndOvsLink, "OpenvSwitchLink"),
1881
   (ndOvsName, "OpenvSwitchName"),
1882
   (ndSpindleCount, "SpindleCount")]
1883

    
1884
-- * Logical Disks parameters
1885

    
1886
ldpAccess :: String
1887
ldpAccess = "access"
1888

    
1889
ldpBarriers :: String
1890
ldpBarriers = "disabled-barriers"
1891

    
1892
ldpDefaultMetavg :: String
1893
ldpDefaultMetavg = "default-metavg"
1894

    
1895
ldpDelayTarget :: String
1896
ldpDelayTarget = "c-delay-target"
1897

    
1898
ldpDiskCustom :: String
1899
ldpDiskCustom = "disk-custom"
1900

    
1901
ldpDynamicResync :: String
1902
ldpDynamicResync = "dynamic-resync"
1903

    
1904
ldpFillTarget :: String
1905
ldpFillTarget = "c-fill-target"
1906

    
1907
ldpMaxRate :: String
1908
ldpMaxRate = "c-max-rate"
1909

    
1910
ldpMinRate :: String
1911
ldpMinRate = "c-min-rate"
1912

    
1913
ldpNetCustom :: String
1914
ldpNetCustom = "net-custom"
1915

    
1916
ldpNoMetaFlush :: String
1917
ldpNoMetaFlush = "disable-meta-flush"
1918

    
1919
ldpPlanAhead :: String
1920
ldpPlanAhead = "c-plan-ahead"
1921

    
1922
ldpPool :: String
1923
ldpPool = "pool"
1924

    
1925
ldpProtocol :: String
1926
ldpProtocol = "protocol"
1927

    
1928
ldpResyncRate :: String
1929
ldpResyncRate = "resync-rate"
1930

    
1931
ldpStripes :: String
1932
ldpStripes = "stripes"
1933

    
1934
diskLdTypes :: Map String VType
1935
diskLdTypes =
1936
  Map.fromList
1937
  [(ldpAccess, VTypeString),
1938
   (ldpResyncRate, VTypeInt),
1939
   (ldpStripes, VTypeInt),
1940
   (ldpBarriers, VTypeString),
1941
   (ldpNoMetaFlush, VTypeBool),
1942
   (ldpDefaultMetavg, VTypeString),
1943
   (ldpDiskCustom, VTypeString),
1944
   (ldpNetCustom, VTypeString),
1945
   (ldpProtocol, VTypeString),
1946
   (ldpDynamicResync, VTypeBool),
1947
   (ldpPlanAhead, VTypeInt),
1948
   (ldpFillTarget, VTypeInt),
1949
   (ldpDelayTarget, VTypeInt),
1950
   (ldpMaxRate, VTypeInt),
1951
   (ldpMinRate, VTypeInt),
1952
   (ldpPool, VTypeString)]
1953

    
1954
diskLdParameters :: FrozenSet String
1955
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
1956

    
1957
-- * Disk template parameters
1958
--
1959
-- Disk template parameters can be set/changed by the user via
1960
-- gnt-cluster and gnt-group)
1961

    
1962
drbdResyncRate :: String
1963
drbdResyncRate = "resync-rate"
1964

    
1965
drbdDataStripes :: String
1966
drbdDataStripes = "data-stripes"
1967

    
1968
drbdMetaStripes :: String
1969
drbdMetaStripes = "meta-stripes"
1970

    
1971
drbdDiskBarriers :: String
1972
drbdDiskBarriers = "disk-barriers"
1973

    
1974
drbdMetaBarriers :: String
1975
drbdMetaBarriers = "meta-barriers"
1976

    
1977
drbdDefaultMetavg :: String
1978
drbdDefaultMetavg = "metavg"
1979

    
1980
drbdDiskCustom :: String
1981
drbdDiskCustom = "disk-custom"
1982

    
1983
drbdNetCustom :: String
1984
drbdNetCustom = "net-custom"
1985

    
1986
drbdProtocol :: String
1987
drbdProtocol = "protocol"
1988

    
1989
drbdDynamicResync :: String
1990
drbdDynamicResync = "dynamic-resync"
1991

    
1992
drbdPlanAhead :: String
1993
drbdPlanAhead = "c-plan-ahead"
1994

    
1995
drbdFillTarget :: String
1996
drbdFillTarget = "c-fill-target"
1997

    
1998
drbdDelayTarget :: String
1999
drbdDelayTarget = "c-delay-target"
2000

    
2001
drbdMaxRate :: String
2002
drbdMaxRate = "c-max-rate"
2003

    
2004
drbdMinRate :: String
2005
drbdMinRate = "c-min-rate"
2006

    
2007
lvStripes :: String
2008
lvStripes = "stripes"
2009

    
2010
rbdAccess :: String
2011
rbdAccess = "access"
2012

    
2013
rbdPool :: String
2014
rbdPool = "pool"
2015

    
2016
diskDtTypes :: Map String VType
2017
diskDtTypes =
2018
  Map.fromList [(drbdResyncRate, VTypeInt),
2019
                (drbdDataStripes, VTypeInt),
2020
                (drbdMetaStripes, VTypeInt),
2021
                (drbdDiskBarriers, VTypeString),
2022
                (drbdMetaBarriers, VTypeBool),
2023
                (drbdDefaultMetavg, VTypeString),
2024
                (drbdDiskCustom, VTypeString),
2025
                (drbdNetCustom, VTypeString),
2026
                (drbdProtocol, VTypeString),
2027
                (drbdDynamicResync, VTypeBool),
2028
                (drbdPlanAhead, VTypeInt),
2029
                (drbdFillTarget, VTypeInt),
2030
                (drbdDelayTarget, VTypeInt),
2031
                (drbdMaxRate, VTypeInt),
2032
                (drbdMinRate, VTypeInt),
2033
                (lvStripes, VTypeInt),
2034
                (rbdAccess, VTypeString),
2035
                (rbdPool, VTypeString)]
2036

    
2037
diskDtParameters :: FrozenSet String
2038
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2039

    
2040
-- * Dynamic disk parameters
2041

    
2042
ddpLocalIp :: String
2043
ddpLocalIp = "local-ip"
2044

    
2045
ddpRemoteIp :: String
2046
ddpRemoteIp = "remote-ip"
2047

    
2048
ddpPort :: String
2049
ddpPort = "port"
2050

    
2051
ddpLocalMinor :: String
2052
ddpLocalMinor = "local-minor"
2053

    
2054
ddpRemoteMinor :: String
2055
ddpRemoteMinor = "remote-minor"
2056

    
2057
-- * OOB supported commands
2058

    
2059
oobPowerOn :: String
2060
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2061

    
2062
oobPowerOff :: String
2063
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2064

    
2065
oobPowerCycle :: String
2066
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2067

    
2068
oobPowerStatus :: String
2069
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2070

    
2071
oobHealth :: String
2072
oobHealth = Types.oobCommandToRaw OobHealth
2073

    
2074
oobCommands :: FrozenSet String
2075
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2076

    
2077
oobPowerStatusPowered :: String
2078
oobPowerStatusPowered = "powered"
2079

    
2080
-- | 60 seconds
2081
oobTimeout :: Int
2082
oobTimeout = 60
2083

    
2084
-- | 2 seconds
2085
oobPowerDelay :: Double
2086
oobPowerDelay = 2.0
2087

    
2088
oobStatusCritical :: String
2089
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2090

    
2091
oobStatusOk :: String
2092
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2093

    
2094
oobStatusUnknown :: String
2095
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2096

    
2097
oobStatusWarning :: String
2098
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2099

    
2100
oobStatuses :: FrozenSet String
2101
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2102

    
2103
-- | Instance Parameters Profile
2104
ppDefault :: String
2105
ppDefault = "default"
2106

    
2107
-- * nic* constants are used inside the ganeti config
2108

    
2109
nicLink :: String
2110
nicLink = "link"
2111

    
2112
nicMode :: String
2113
nicMode = "mode"
2114

    
2115
nicVlan :: String
2116
nicVlan = "vlan"
2117

    
2118
nicsParameterTypes :: Map String VType
2119
nicsParameterTypes =
2120
  Map.fromList [(nicMode, vtypeString),
2121
                (nicLink, vtypeString),
2122
                (nicVlan, vtypeMaybeString)]
2123

    
2124
nicsParameters :: FrozenSet String
2125
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2126

    
2127
nicModeBridged :: String
2128
nicModeBridged = Types.nICModeToRaw NMBridged
2129

    
2130
nicModeRouted :: String
2131
nicModeRouted = Types.nICModeToRaw NMRouted
2132

    
2133
nicModeOvs :: String
2134
nicModeOvs = Types.nICModeToRaw NMOvs
2135

    
2136
nicIpPool :: String
2137
nicIpPool = Types.nICModeToRaw NMPool
2138

    
2139
nicValidModes :: FrozenSet String
2140
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2141

    
2142
releaseAction :: String
2143
releaseAction = "release"
2144

    
2145
reserveAction :: String
2146
reserveAction = "reserve"
2147

    
2148
-- * idisk* constants are used in opcodes, to create/change disks
2149

    
2150
idiskAdopt :: String
2151
idiskAdopt = "adopt"
2152

    
2153
idiskMetavg :: String
2154
idiskMetavg = "metavg"
2155

    
2156
idiskMode :: String
2157
idiskMode = "mode"
2158

    
2159
idiskName :: String
2160
idiskName = "name"
2161

    
2162
idiskSize :: String
2163
idiskSize = "size"
2164

    
2165
idiskSpindles :: String
2166
idiskSpindles = "spindles"
2167

    
2168
idiskVg :: String
2169
idiskVg = "vg"
2170

    
2171
idiskProvider :: String
2172
idiskProvider = "provider"
2173

    
2174
idiskParamsTypes :: Map String VType
2175
idiskParamsTypes =
2176
  Map.fromList [(idiskSize, VTypeSize),
2177
                (idiskSpindles, VTypeInt),
2178
                (idiskMode, VTypeString),
2179
                (idiskAdopt, VTypeString),
2180
                (idiskVg, VTypeString),
2181
                (idiskMetavg, VTypeString),
2182
                (idiskProvider, VTypeString),
2183
                (idiskName, VTypeMaybeString)]
2184

    
2185
idiskParams :: FrozenSet String
2186
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2187

    
2188
-- * inic* constants are used in opcodes, to create/change nics
2189

    
2190
inicBridge :: String
2191
inicBridge = "bridge"
2192

    
2193
inicIp :: String
2194
inicIp = "ip"
2195

    
2196
inicLink :: String
2197
inicLink = "link"
2198

    
2199
inicMac :: String
2200
inicMac = "mac"
2201

    
2202
inicMode :: String
2203
inicMode = "mode"
2204

    
2205
inicName :: String
2206
inicName = "name"
2207

    
2208
inicNetwork :: String
2209
inicNetwork = "network"
2210

    
2211
inicVlan :: String
2212
inicVlan = "vlan"
2213

    
2214
inicParamsTypes :: Map String VType
2215
inicParamsTypes =
2216
  Map.fromList [(inicBridge, VTypeMaybeString),
2217
                (inicIp, VTypeMaybeString),
2218
                (inicLink, VTypeString),
2219
                (inicMac, VTypeString),
2220
                (inicMode, VTypeString),
2221
                (inicName, VTypeMaybeString),
2222
                (inicNetwork, VTypeMaybeString),
2223
                (inicVlan, VTypeMaybeString)]
2224

    
2225
inicParams :: FrozenSet String
2226
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2227

    
2228
-- * Hypervisor constants
2229

    
2230
htXenPvm :: String
2231
htXenPvm = Types.hypervisorToRaw XenPvm
2232

    
2233
htFake :: String
2234
htFake = Types.hypervisorToRaw Fake
2235

    
2236
htXenHvm :: String
2237
htXenHvm = Types.hypervisorToRaw XenHvm
2238

    
2239
htKvm :: String
2240
htKvm = Types.hypervisorToRaw Kvm
2241

    
2242
htChroot :: String
2243
htChroot = Types.hypervisorToRaw Chroot
2244

    
2245
htLxc :: String
2246
htLxc = Types.hypervisorToRaw Lxc
2247

    
2248
hyperTypes :: FrozenSet String
2249
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2250

    
2251
htsReqPort :: FrozenSet String
2252
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2253

    
2254
vncBasePort :: Int
2255
vncBasePort = 5900
2256

    
2257
vncDefaultBindAddress :: String
2258
vncDefaultBindAddress = ip4AddressAny
2259

    
2260
-- * NIC types
2261

    
2262
htNicE1000 :: String
2263
htNicE1000 = "e1000"
2264

    
2265
htNicI82551 :: String
2266
htNicI82551 = "i82551"
2267

    
2268
htNicI8259er :: String
2269
htNicI8259er = "i82559er"
2270

    
2271
htNicI85557b :: String
2272
htNicI85557b = "i82557b"
2273

    
2274
htNicNe2kIsa :: String
2275
htNicNe2kIsa = "ne2k_isa"
2276

    
2277
htNicNe2kPci :: String
2278
htNicNe2kPci = "ne2k_pci"
2279

    
2280
htNicParavirtual :: String
2281
htNicParavirtual = "paravirtual"
2282

    
2283
htNicPcnet :: String
2284
htNicPcnet = "pcnet"
2285

    
2286
htNicRtl8139 :: String
2287
htNicRtl8139 = "rtl8139"
2288

    
2289
htHvmValidNicTypes :: FrozenSet String
2290
htHvmValidNicTypes =
2291
  ConstantUtils.mkSet [htNicE1000,
2292
                       htNicNe2kIsa,
2293
                       htNicNe2kPci,
2294
                       htNicParavirtual,
2295
                       htNicRtl8139]
2296

    
2297
htKvmValidNicTypes :: FrozenSet String
2298
htKvmValidNicTypes =
2299
  ConstantUtils.mkSet [htNicE1000,
2300
                       htNicI82551,
2301
                       htNicI8259er,
2302
                       htNicI85557b,
2303
                       htNicNe2kIsa,
2304
                       htNicNe2kPci,
2305
                       htNicParavirtual,
2306
                       htNicPcnet,
2307
                       htNicRtl8139]
2308

    
2309
-- * Vif types
2310

    
2311
-- | Default vif type in xen-hvm
2312
htHvmVifIoemu :: String
2313
htHvmVifIoemu = "ioemu"
2314

    
2315
htHvmVifVif :: String
2316
htHvmVifVif = "vif"
2317

    
2318
htHvmValidVifTypes :: FrozenSet String
2319
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2320

    
2321
-- * Disk types
2322

    
2323
htDiskIde :: String
2324
htDiskIde = "ide"
2325

    
2326
htDiskIoemu :: String
2327
htDiskIoemu = "ioemu"
2328

    
2329
htDiskMtd :: String
2330
htDiskMtd = "mtd"
2331

    
2332
htDiskParavirtual :: String
2333
htDiskParavirtual = "paravirtual"
2334

    
2335
htDiskPflash :: String
2336
htDiskPflash = "pflash"
2337

    
2338
htDiskScsi :: String
2339
htDiskScsi = "scsi"
2340

    
2341
htDiskSd :: String
2342
htDiskSd = "sd"
2343

    
2344
htHvmValidDiskTypes :: FrozenSet String
2345
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2346

    
2347
htKvmValidDiskTypes :: FrozenSet String
2348
htKvmValidDiskTypes =
2349
  ConstantUtils.mkSet [htDiskIde,
2350
                       htDiskMtd,
2351
                       htDiskParavirtual,
2352
                       htDiskPflash,
2353
                       htDiskScsi,
2354
                       htDiskSd]
2355

    
2356
htCacheDefault :: String
2357
htCacheDefault = "default"
2358

    
2359
htCacheNone :: String
2360
htCacheNone = "none"
2361

    
2362
htCacheWback :: String
2363
htCacheWback = "writeback"
2364

    
2365
htCacheWthrough :: String
2366
htCacheWthrough = "writethrough"
2367

    
2368
htValidCacheTypes :: FrozenSet String
2369
htValidCacheTypes =
2370
  ConstantUtils.mkSet [htCacheDefault,
2371
                       htCacheNone,
2372
                       htCacheWback,
2373
                       htCacheWthrough]
2374

    
2375
-- * Mouse types
2376

    
2377
htMouseMouse :: String
2378
htMouseMouse = "mouse"
2379

    
2380
htMouseTablet :: String
2381
htMouseTablet = "tablet"
2382

    
2383
htKvmValidMouseTypes :: FrozenSet String
2384
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2385

    
2386
-- * Boot order
2387

    
2388
htBoCdrom :: String
2389
htBoCdrom = "cdrom"
2390

    
2391
htBoDisk :: String
2392
htBoDisk = "disk"
2393

    
2394
htBoFloppy :: String
2395
htBoFloppy = "floppy"
2396

    
2397
htBoNetwork :: String
2398
htBoNetwork = "network"
2399

    
2400
htKvmValidBoTypes :: FrozenSet String
2401
htKvmValidBoTypes =
2402
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2403

    
2404
-- * SPICE lossless image compression options
2405

    
2406
htKvmSpiceLosslessImgComprAutoGlz :: String
2407
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2408

    
2409
htKvmSpiceLosslessImgComprAutoLz :: String
2410
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2411

    
2412
htKvmSpiceLosslessImgComprGlz :: String
2413
htKvmSpiceLosslessImgComprGlz = "glz"
2414

    
2415
htKvmSpiceLosslessImgComprLz :: String
2416
htKvmSpiceLosslessImgComprLz = "lz"
2417

    
2418
htKvmSpiceLosslessImgComprOff :: String
2419
htKvmSpiceLosslessImgComprOff = "off"
2420

    
2421
htKvmSpiceLosslessImgComprQuic :: String
2422
htKvmSpiceLosslessImgComprQuic = "quic"
2423

    
2424
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2425
htKvmSpiceValidLosslessImgComprOptions =
2426
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2427
                       htKvmSpiceLosslessImgComprAutoLz,
2428
                       htKvmSpiceLosslessImgComprGlz,
2429
                       htKvmSpiceLosslessImgComprLz,
2430
                       htKvmSpiceLosslessImgComprOff,
2431
                       htKvmSpiceLosslessImgComprQuic]
2432

    
2433
htKvmSpiceLossyImgComprAlways :: String
2434
htKvmSpiceLossyImgComprAlways = "always"
2435

    
2436
htKvmSpiceLossyImgComprAuto :: String
2437
htKvmSpiceLossyImgComprAuto = "auto"
2438

    
2439
htKvmSpiceLossyImgComprNever :: String
2440
htKvmSpiceLossyImgComprNever = "never"
2441

    
2442
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2443
htKvmSpiceValidLossyImgComprOptions =
2444
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2445
                       htKvmSpiceLossyImgComprAuto,
2446
                       htKvmSpiceLossyImgComprNever]
2447

    
2448
-- * SPICE video stream detection
2449

    
2450
htKvmSpiceVideoStreamDetectionAll :: String
2451
htKvmSpiceVideoStreamDetectionAll = "all"
2452

    
2453
htKvmSpiceVideoStreamDetectionFilter :: String
2454
htKvmSpiceVideoStreamDetectionFilter = "filter"
2455

    
2456
htKvmSpiceVideoStreamDetectionOff :: String
2457
htKvmSpiceVideoStreamDetectionOff = "off"
2458

    
2459
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2460
htKvmSpiceValidVideoStreamDetectionOptions =
2461
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2462
                       htKvmSpiceVideoStreamDetectionFilter,
2463
                       htKvmSpiceVideoStreamDetectionOff]
2464

    
2465
-- * Security models
2466

    
2467
htSmNone :: String
2468
htSmNone = "none"
2469

    
2470
htSmPool :: String
2471
htSmPool = "pool"
2472

    
2473
htSmUser :: String
2474
htSmUser = "user"
2475

    
2476
htKvmValidSmTypes :: FrozenSet String
2477
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2478

    
2479
-- * Kvm flag values
2480

    
2481
htKvmDisabled :: String
2482
htKvmDisabled = "disabled"
2483

    
2484
htKvmEnabled :: String
2485
htKvmEnabled = "enabled"
2486

    
2487
htKvmFlagValues :: FrozenSet String
2488
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2489

    
2490
-- * Migration type
2491

    
2492
htMigrationLive :: String
2493
htMigrationLive = Types.migrationModeToRaw MigrationLive
2494

    
2495
htMigrationNonlive :: String
2496
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2497

    
2498
htMigrationModes :: FrozenSet String
2499
htMigrationModes =
2500
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2501

    
2502
-- * Cluster verify steps
2503

    
2504
verifyNplusoneMem :: String
2505
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2506

    
2507
verifyOptionalChecks :: FrozenSet String
2508
verifyOptionalChecks =
2509
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2510

    
2511
-- * Cluster Verify error classes
2512

    
2513
cvTcluster :: String
2514
cvTcluster = "cluster"
2515

    
2516
cvTgroup :: String
2517
cvTgroup = "group"
2518

    
2519
cvTnode :: String
2520
cvTnode = "node"
2521

    
2522
cvTinstance :: String
2523
cvTinstance = "instance"
2524

    
2525
-- * Cluster Verify error codes and documentation
2526

    
2527
cvEclustercert :: (String, String, String)
2528
cvEclustercert =
2529
  ("cluster",
2530
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2531
   "Cluster certificate files verification failure")
2532

    
2533
cvEclustercfg :: (String, String, String)
2534
cvEclustercfg =
2535
  ("cluster",
2536
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2537
   "Cluster configuration verification failure")
2538

    
2539
cvEclusterdanglinginst :: (String, String, String)
2540
cvEclusterdanglinginst =
2541
  ("node",
2542
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2543
   "Some instances have a non-existing primary node")
2544

    
2545
cvEclusterdanglingnodes :: (String, String, String)
2546
cvEclusterdanglingnodes =
2547
  ("node",
2548
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2549
   "Some nodes belong to non-existing groups")
2550

    
2551
cvEclusterfilecheck :: (String, String, String)
2552
cvEclusterfilecheck =
2553
  ("cluster",
2554
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2555
   "Cluster configuration verification failure")
2556

    
2557
cvEgroupdifferentpvsize :: (String, String, String)
2558
cvEgroupdifferentpvsize =
2559
  ("group",
2560
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2561
   "PVs in the group have different sizes")
2562

    
2563
cvEinstancebadnode :: (String, String, String)
2564
cvEinstancebadnode =
2565
  ("instance",
2566
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2567
   "Instance marked as running lives on an offline node")
2568

    
2569
cvEinstancedown :: (String, String, String)
2570
cvEinstancedown =
2571
  ("instance",
2572
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2573
   "Instance not running on its primary node")
2574

    
2575
cvEinstancefaultydisk :: (String, String, String)
2576
cvEinstancefaultydisk =
2577
  ("instance",
2578
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2579
   "Impossible to retrieve status for a disk")
2580

    
2581
cvEinstancelayout :: (String, String, String)
2582
cvEinstancelayout =
2583
  ("instance",
2584
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2585
   "Instance has multiple secondary nodes")
2586

    
2587
cvEinstancemissingcfgparameter :: (String, String, String)
2588
cvEinstancemissingcfgparameter =
2589
  ("instance",
2590
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2591
   "A configuration parameter for an instance is missing")
2592

    
2593
cvEinstancemissingdisk :: (String, String, String)
2594
cvEinstancemissingdisk =
2595
  ("instance",
2596
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2597
   "Missing volume on an instance")
2598

    
2599
cvEinstancepolicy :: (String, String, String)
2600
cvEinstancepolicy =
2601
  ("instance",
2602
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2603
   "Instance does not meet policy")
2604

    
2605
cvEinstancesplitgroups :: (String, String, String)
2606
cvEinstancesplitgroups =
2607
  ("instance",
2608
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2609
   "Instance with primary and secondary nodes in different groups")
2610

    
2611
cvEinstanceunsuitablenode :: (String, String, String)
2612
cvEinstanceunsuitablenode =
2613
  ("instance",
2614
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2615
   "Instance running on nodes that are not suitable for it")
2616

    
2617
cvEinstancewrongnode :: (String, String, String)
2618
cvEinstancewrongnode =
2619
  ("instance",
2620
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2621
   "Instance running on the wrong node")
2622

    
2623
cvEnodedrbd :: (String, String, String)
2624
cvEnodedrbd =
2625
  ("node",
2626
   Types.cVErrorCodeToRaw CvENODEDRBD,
2627
   "Error parsing the DRBD status file")
2628

    
2629
cvEnodedrbdhelper :: (String, String, String)
2630
cvEnodedrbdhelper =
2631
  ("node",
2632
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2633
   "Error caused by the DRBD helper")
2634

    
2635
cvEnodedrbdversion :: (String, String, String)
2636
cvEnodedrbdversion =
2637
  ("node",
2638
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2639
   "DRBD version mismatch within a node group")
2640

    
2641
cvEnodefilecheck :: (String, String, String)
2642
cvEnodefilecheck =
2643
  ("node",
2644
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2645
   "Error retrieving the checksum of the node files")
2646

    
2647
cvEnodefilestoragepaths :: (String, String, String)
2648
cvEnodefilestoragepaths =
2649
  ("node",
2650
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2651
   "Detected bad file storage paths")
2652

    
2653
cvEnodefilestoragepathunusable :: (String, String, String)
2654
cvEnodefilestoragepathunusable =
2655
  ("node",
2656
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2657
   "File storage path unusable")
2658

    
2659
cvEnodehooks :: (String, String, String)
2660
cvEnodehooks =
2661
  ("node",
2662
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2663
   "Communication failure in hooks execution")
2664

    
2665
cvEnodehv :: (String, String, String)
2666
cvEnodehv =
2667
  ("node",
2668
   Types.cVErrorCodeToRaw CvENODEHV,
2669
   "Hypervisor parameters verification failure")
2670

    
2671
cvEnodelvm :: (String, String, String)
2672
cvEnodelvm =
2673
  ("node",
2674
   Types.cVErrorCodeToRaw CvENODELVM,
2675
   "LVM-related node error")
2676

    
2677
cvEnoden1 :: (String, String, String)
2678
cvEnoden1 =
2679
  ("node",
2680
   Types.cVErrorCodeToRaw CvENODEN1,
2681
   "Not enough memory to accommodate instance failovers")
2682

    
2683
cvEnodenet :: (String, String, String)
2684
cvEnodenet =
2685
  ("node",
2686
   Types.cVErrorCodeToRaw CvENODENET,
2687
   "Network-related node error")
2688

    
2689
cvEnodeoobpath :: (String, String, String)
2690
cvEnodeoobpath =
2691
  ("node",
2692
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2693
   "Invalid Out Of Band path")
2694

    
2695
cvEnodeorphaninstance :: (String, String, String)
2696
cvEnodeorphaninstance =
2697
  ("node",
2698
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2699
   "Unknown intance running on a node")
2700

    
2701
cvEnodeorphanlv :: (String, String, String)
2702
cvEnodeorphanlv =
2703
  ("node",
2704
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2705
   "Unknown LVM logical volume")
2706

    
2707
cvEnodeos :: (String, String, String)
2708
cvEnodeos =
2709
  ("node",
2710
   Types.cVErrorCodeToRaw CvENODEOS,
2711
   "OS-related node error")
2712

    
2713
cvEnoderpc :: (String, String, String)
2714
cvEnoderpc =
2715
  ("node",
2716
   Types.cVErrorCodeToRaw CvENODERPC,
2717
   "Error during connection to the primary node of an instance")
2718

    
2719
cvEnodesetup :: (String, String, String)
2720
cvEnodesetup =
2721
  ("node",
2722
   Types.cVErrorCodeToRaw CvENODESETUP,
2723
   "Node setup error")
2724

    
2725
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2726
cvEnodesharedfilestoragepathunusable =
2727
  ("node",
2728
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2729
   "Shared file storage path unusable")
2730

    
2731
cvEnodessh :: (String, String, String)
2732
cvEnodessh =
2733
  ("node",
2734
   Types.cVErrorCodeToRaw CvENODESSH,
2735
   "SSH-related node error")
2736

    
2737
cvEnodetime :: (String, String, String)
2738
cvEnodetime =
2739
  ("node",
2740
   Types.cVErrorCodeToRaw CvENODETIME,
2741
   "Node returned invalid time")
2742

    
2743
cvEnodeuserscripts :: (String, String, String)
2744
cvEnodeuserscripts =
2745
  ("node",
2746
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2747
   "User scripts not present or not executable")
2748

    
2749
cvEnodeversion :: (String, String, String)
2750
cvEnodeversion =
2751
  ("node",
2752
   Types.cVErrorCodeToRaw CvENODEVERSION,
2753
   "Protocol version mismatch or Ganeti version mismatch")
2754

    
2755
cvAllEcodes :: FrozenSet (String, String, String)
2756
cvAllEcodes =
2757
  ConstantUtils.mkSet
2758
  [cvEclustercert,
2759
   cvEclustercfg,
2760
   cvEclusterdanglinginst,
2761
   cvEclusterdanglingnodes,
2762
   cvEclusterfilecheck,
2763
   cvEgroupdifferentpvsize,
2764
   cvEinstancebadnode,
2765
   cvEinstancedown,
2766
   cvEinstancefaultydisk,
2767
   cvEinstancelayout,
2768
   cvEinstancemissingcfgparameter,
2769
   cvEinstancemissingdisk,
2770
   cvEinstancepolicy,
2771
   cvEinstancesplitgroups,
2772
   cvEinstanceunsuitablenode,
2773
   cvEinstancewrongnode,
2774
   cvEnodedrbd,
2775
   cvEnodedrbdhelper,
2776
   cvEnodedrbdversion,
2777
   cvEnodefilecheck,
2778
   cvEnodefilestoragepaths,
2779
   cvEnodefilestoragepathunusable,
2780
   cvEnodehooks,
2781
   cvEnodehv,
2782
   cvEnodelvm,
2783
   cvEnoden1,
2784
   cvEnodenet,
2785
   cvEnodeoobpath,
2786
   cvEnodeorphaninstance,
2787
   cvEnodeorphanlv,
2788
   cvEnodeos,
2789
   cvEnoderpc,
2790
   cvEnodesetup,
2791
   cvEnodesharedfilestoragepathunusable,
2792
   cvEnodessh,
2793
   cvEnodetime,
2794
   cvEnodeuserscripts,
2795
   cvEnodeversion]
2796

    
2797
cvAllEcodesStrings :: FrozenSet String
2798
cvAllEcodesStrings =
2799
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2800

    
2801
-- * Node verify constants
2802

    
2803
nvBridges :: String
2804
nvBridges = "bridges"
2805

    
2806
nvDrbdhelper :: String
2807
nvDrbdhelper = "drbd-helper"
2808

    
2809
nvDrbdversion :: String
2810
nvDrbdversion = "drbd-version"
2811

    
2812
nvDrbdlist :: String
2813
nvDrbdlist = "drbd-list"
2814

    
2815
nvExclusivepvs :: String
2816
nvExclusivepvs = "exclusive-pvs"
2817

    
2818
nvFilelist :: String
2819
nvFilelist = "filelist"
2820

    
2821
nvAcceptedStoragePaths :: String
2822
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2823

    
2824
nvFileStoragePath :: String
2825
nvFileStoragePath = "file-storage-path"
2826

    
2827
nvSharedFileStoragePath :: String
2828
nvSharedFileStoragePath = "shared-file-storage-path"
2829

    
2830
nvHvinfo :: String
2831
nvHvinfo = "hvinfo"
2832

    
2833
nvHvparams :: String
2834
nvHvparams = "hvparms"
2835

    
2836
nvHypervisor :: String
2837
nvHypervisor = "hypervisor"
2838

    
2839
nvInstancelist :: String
2840
nvInstancelist = "instancelist"
2841

    
2842
nvLvlist :: String
2843
nvLvlist = "lvlist"
2844

    
2845
nvMasterip :: String
2846
nvMasterip = "master-ip"
2847

    
2848
nvNodelist :: String
2849
nvNodelist = "nodelist"
2850

    
2851
nvNodenettest :: String
2852
nvNodenettest = "node-net-test"
2853

    
2854
nvNodesetup :: String
2855
nvNodesetup = "nodesetup"
2856

    
2857
nvOobPaths :: String
2858
nvOobPaths = "oob-paths"
2859

    
2860
nvOslist :: String
2861
nvOslist = "oslist"
2862

    
2863
nvPvlist :: String
2864
nvPvlist = "pvlist"
2865

    
2866
nvTime :: String
2867
nvTime = "time"
2868

    
2869
nvUserscripts :: String
2870
nvUserscripts = "user-scripts"
2871

    
2872
nvVersion :: String
2873
nvVersion = "version"
2874

    
2875
nvVglist :: String
2876
nvVglist = "vglist"
2877

    
2878
nvVmnodes :: String
2879
nvVmnodes = "vmnodes"
2880

    
2881
-- * Instance status
2882

    
2883
inststAdmindown :: String
2884
inststAdmindown = Types.instanceStatusToRaw StatusDown
2885

    
2886
inststAdminoffline :: String
2887
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
2888

    
2889
inststErrordown :: String
2890
inststErrordown = Types.instanceStatusToRaw ErrorDown
2891

    
2892
inststErrorup :: String
2893
inststErrorup = Types.instanceStatusToRaw ErrorUp
2894

    
2895
inststNodedown :: String
2896
inststNodedown = Types.instanceStatusToRaw NodeDown
2897

    
2898
inststNodeoffline :: String
2899
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
2900

    
2901
inststRunning :: String
2902
inststRunning = Types.instanceStatusToRaw Running
2903

    
2904
inststWrongnode :: String
2905
inststWrongnode = Types.instanceStatusToRaw WrongNode
2906

    
2907
inststAll :: FrozenSet String
2908
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
2909

    
2910
-- * Admin states
2911

    
2912
adminstDown :: String
2913
adminstDown = Types.adminStateToRaw AdminDown
2914

    
2915
adminstOffline :: String
2916
adminstOffline = Types.adminStateToRaw AdminOffline
2917

    
2918
adminstUp :: String
2919
adminstUp = Types.adminStateToRaw AdminUp
2920

    
2921
adminstAll :: FrozenSet String
2922
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
2923

    
2924
-- * Node roles
2925

    
2926
nrDrained :: String
2927
nrDrained = Types.nodeRoleToRaw NRDrained
2928

    
2929
nrMaster :: String
2930
nrMaster = Types.nodeRoleToRaw NRMaster
2931

    
2932
nrMcandidate :: String
2933
nrMcandidate = Types.nodeRoleToRaw NRCandidate
2934

    
2935
nrOffline :: String
2936
nrOffline = Types.nodeRoleToRaw NROffline
2937

    
2938
nrRegular :: String
2939
nrRegular = Types.nodeRoleToRaw NRRegular
2940

    
2941
nrAll :: FrozenSet String
2942
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
2943

    
2944
-- * SSL certificate check constants (in days)
2945

    
2946
sslCertExpirationError :: Int
2947
sslCertExpirationError = 7
2948

    
2949
sslCertExpirationWarn :: Int
2950
sslCertExpirationWarn = 30
2951

    
2952
-- * Allocator framework constants
2953

    
2954
iallocatorVersion :: Int
2955
iallocatorVersion = 2
2956

    
2957
iallocatorDirIn :: String
2958
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
2959

    
2960
iallocatorDirOut :: String
2961
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
2962

    
2963
validIallocatorDirections :: FrozenSet String
2964
validIallocatorDirections =
2965
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
2966

    
2967
iallocatorModeAlloc :: String
2968
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
2969

    
2970
iallocatorModeChgGroup :: String
2971
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
2972

    
2973
iallocatorModeMultiAlloc :: String
2974
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
2975

    
2976
iallocatorModeNodeEvac :: String
2977
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
2978

    
2979
iallocatorModeReloc :: String
2980
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
2981

    
2982
validIallocatorModes :: FrozenSet String
2983
validIallocatorModes =
2984
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
2985

    
2986
iallocatorSearchPath :: [String]
2987
iallocatorSearchPath = AutoConf.iallocatorSearchPath
2988

    
2989
defaultIallocatorShortcut :: String
2990
defaultIallocatorShortcut = "."
2991

    
2992
-- * Node evacuation
2993

    
2994
nodeEvacPri :: String
2995
nodeEvacPri = Types.evacModeToRaw ChangePrimary
2996

    
2997
nodeEvacSec :: String
2998
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
2999

    
3000
nodeEvacAll :: String
3001
nodeEvacAll = Types.evacModeToRaw ChangeAll
3002

    
3003
nodeEvacModes :: FrozenSet String
3004
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3005

    
3006
-- * Job queue
3007

    
3008
jobQueueVersion :: Int
3009
jobQueueVersion = 1
3010

    
3011
jobQueueSizeHardLimit :: Int
3012
jobQueueSizeHardLimit = 5000
3013

    
3014
jobQueueFilesPerms :: Int
3015
jobQueueFilesPerms = 0o640
3016

    
3017
-- * Unchanged job return
3018

    
3019
jobNotchanged :: String
3020
jobNotchanged = "nochange"
3021

    
3022
-- * Job status
3023

    
3024
jobStatusQueued :: String
3025
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3026

    
3027
jobStatusWaiting :: String
3028
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3029

    
3030
jobStatusCanceling :: String
3031
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3032

    
3033
jobStatusRunning :: String
3034
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3035

    
3036
jobStatusCanceled :: String
3037
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3038

    
3039
jobStatusSuccess :: String
3040
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3041

    
3042
jobStatusError :: String
3043
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3044

    
3045
jobsPending :: FrozenSet String
3046
jobsPending =
3047
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3048

    
3049
jobsFinalized :: FrozenSet String
3050
jobsFinalized =
3051
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3052

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

    
3056
-- * OpCode status
3057

    
3058
-- ** Not yet finalized opcodes
3059

    
3060
opStatusCanceling :: String
3061
opStatusCanceling = "canceling"
3062

    
3063
opStatusQueued :: String
3064
opStatusQueued = "queued"
3065

    
3066
opStatusRunning :: String
3067
opStatusRunning = "running"
3068

    
3069
opStatusWaiting :: String
3070
opStatusWaiting = "waiting"
3071

    
3072
-- ** Finalized opcodes
3073

    
3074
opStatusCanceled :: String
3075
opStatusCanceled = "canceled"
3076

    
3077
opStatusError :: String
3078
opStatusError = "error"
3079

    
3080
opStatusSuccess :: String
3081
opStatusSuccess = "success"
3082

    
3083
opsFinalized :: FrozenSet String
3084
opsFinalized =
3085
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3086

    
3087
-- * OpCode priority
3088

    
3089
opPrioLowest :: Int
3090
opPrioLowest = 19
3091

    
3092
opPrioHighest :: Int
3093
opPrioHighest = -20
3094

    
3095
opPrioLow :: Int
3096
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3097

    
3098
opPrioNormal :: Int
3099
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3100

    
3101
opPrioHigh :: Int
3102
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3103

    
3104
opPrioSubmitValid :: FrozenSet Int
3105
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3106

    
3107
opPrioDefault :: Int
3108
opPrioDefault = opPrioNormal
3109

    
3110
-- * Lock recalculate mode
3111

    
3112
locksAppend :: String
3113
locksAppend = "append"
3114

    
3115
locksReplace :: String
3116
locksReplace = "replace"
3117

    
3118
-- * Lock timeout
3119
--
3120
-- The lock timeout (sum) before we transition into blocking acquire
3121
-- (this can still be reset by priority change).  Computed as max time
3122
-- (10 hours) before we should actually go into blocking acquire,
3123
-- given that we start from the default priority level.
3124

    
3125
lockAttemptsMaxwait :: Double
3126
lockAttemptsMaxwait = 15.0
3127

    
3128
lockAttemptsMinwait :: Double
3129
lockAttemptsMinwait = 1.0
3130

    
3131
lockAttemptsTimeout :: Int
3132
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3133

    
3134
-- * Execution log types
3135

    
3136
elogMessage :: String
3137
elogMessage = Types.eLogTypeToRaw ELogMessage
3138

    
3139
elogRemoteImport :: String
3140
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3141

    
3142
elogJqueueTest :: String
3143
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3144

    
3145
-- * /etc/hosts modification
3146

    
3147
etcHostsAdd :: String
3148
etcHostsAdd = "add"
3149

    
3150
etcHostsRemove :: String
3151
etcHostsRemove = "remove"
3152

    
3153
-- * Job queue test
3154

    
3155
jqtMsgprefix :: String
3156
jqtMsgprefix = "TESTMSG="
3157

    
3158
jqtExec :: String
3159
jqtExec = "exec"
3160

    
3161
jqtExpandnames :: String
3162
jqtExpandnames = "expandnames"
3163

    
3164
jqtLogmsg :: String
3165
jqtLogmsg = "logmsg"
3166

    
3167
jqtStartmsg :: String
3168
jqtStartmsg = "startmsg"
3169

    
3170
jqtAll :: FrozenSet String
3171
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3172

    
3173
-- * Query resources
3174

    
3175
qrCluster :: String
3176
qrCluster = "cluster"
3177

    
3178
qrExport :: String
3179
qrExport = "export"
3180

    
3181
qrExtstorage :: String
3182
qrExtstorage = "extstorage"
3183

    
3184
qrGroup :: String
3185
qrGroup = "group"
3186

    
3187
qrInstance :: String
3188
qrInstance = "instance"
3189

    
3190
qrJob :: String
3191
qrJob = "job"
3192

    
3193
qrLock :: String
3194
qrLock = "lock"
3195

    
3196
qrNetwork :: String
3197
qrNetwork = "network"
3198

    
3199
qrNode :: String
3200
qrNode = "node"
3201

    
3202
qrOs :: String
3203
qrOs = "os"
3204

    
3205
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3206
qrViaOp :: FrozenSet String
3207
qrViaOp =
3208
  ConstantUtils.mkSet [qrCluster,
3209
                       qrInstance,
3210
                       qrNode,
3211
                       qrGroup,
3212
                       qrOs,
3213
                       qrExport,
3214
                       qrNetwork,
3215
                       qrExtstorage]
3216

    
3217
-- | List of resources which can be queried using Local UniX Interface
3218
qrViaLuxi :: FrozenSet String
3219
qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob]
3220

    
3221
-- | List of resources which can be queried using RAPI
3222
qrViaRapi :: FrozenSet String
3223
qrViaRapi = qrViaLuxi
3224

    
3225
-- * Query field types
3226

    
3227
qftBool :: String
3228
qftBool = "bool"
3229

    
3230
qftNumber :: String
3231
qftNumber = "number"
3232

    
3233
qftOther :: String
3234
qftOther = "other"
3235

    
3236
qftText :: String
3237
qftText = "text"
3238

    
3239
qftTimestamp :: String
3240
qftTimestamp = "timestamp"
3241

    
3242
qftUnit :: String
3243
qftUnit = "unit"
3244

    
3245
qftUnknown :: String
3246
qftUnknown = "unknown"
3247

    
3248
qftAll :: FrozenSet String
3249
qftAll =
3250
  ConstantUtils.mkSet [qftBool,
3251
                       qftNumber,
3252
                       qftOther,
3253
                       qftText,
3254
                       qftTimestamp,
3255
                       qftUnit,
3256
                       qftUnknown]
3257

    
3258
-- * Query result field status
3259
--
3260
-- Don't change or reuse values as they're used by clients.
3261
--
3262
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3263

    
3264
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3265
rsNodata :: Int
3266
rsNodata = 2
3267

    
3268
rsNormal :: Int
3269
rsNormal = 0
3270

    
3271
-- | Resource marked offline
3272
rsOffline :: Int
3273
rsOffline = 4
3274

    
3275
-- | Value unavailable/unsupported for item; if this field is
3276
-- supported but we cannot get the data for the moment, 'rsNodata' or
3277
-- 'rsOffline' should be used
3278
rsUnavail :: Int
3279
rsUnavail = 3
3280

    
3281
rsUnknown :: Int
3282
rsUnknown = 1
3283

    
3284
rsAll :: FrozenSet Int
3285
rsAll =
3286
  ConstantUtils.mkSet [rsNodata,
3287
                       rsNormal,
3288
                       rsOffline,
3289
                       rsUnavail,
3290
                       rsUnknown]
3291

    
3292
-- | Special field cases and their verbose/terse formatting
3293
rssDescription :: Map Int (String, String)
3294
rssDescription =
3295
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3296
                (rsNodata, ("(nodata)", "?")),
3297
                (rsOffline, ("(offline)", "*")),
3298
                (rsUnavail, ("(unavail)", "-"))]
3299

    
3300
-- * Max dynamic devices
3301

    
3302
maxDisks :: Int
3303
maxDisks = Types.maxDisks
3304

    
3305
maxNics :: Int
3306
maxNics = Types.maxNics
3307

    
3308
-- | SSCONF file prefix
3309
ssconfFileprefix :: String
3310
ssconfFileprefix = "ssconf_"
3311

    
3312
-- * SSCONF keys
3313

    
3314
ssClusterName :: String
3315
ssClusterName = "cluster_name"
3316

    
3317
ssClusterTags :: String
3318
ssClusterTags = "cluster_tags"
3319

    
3320
ssFileStorageDir :: String
3321
ssFileStorageDir = "file_storage_dir"
3322

    
3323
ssSharedFileStorageDir :: String
3324
ssSharedFileStorageDir = "shared_file_storage_dir"
3325

    
3326
ssMasterCandidates :: String
3327
ssMasterCandidates = "master_candidates"
3328

    
3329
ssMasterCandidatesIps :: String
3330
ssMasterCandidatesIps = "master_candidates_ips"
3331

    
3332
ssMasterIp :: String
3333
ssMasterIp = "master_ip"
3334

    
3335
ssMasterNetdev :: String
3336
ssMasterNetdev = "master_netdev"
3337

    
3338
ssMasterNetmask :: String
3339
ssMasterNetmask = "master_netmask"
3340

    
3341
ssMasterNode :: String
3342
ssMasterNode = "master_node"
3343

    
3344
ssNodeList :: String
3345
ssNodeList = "node_list"
3346

    
3347
ssNodePrimaryIps :: String
3348
ssNodePrimaryIps = "node_primary_ips"
3349

    
3350
ssNodeSecondaryIps :: String
3351
ssNodeSecondaryIps = "node_secondary_ips"
3352

    
3353
ssOfflineNodes :: String
3354
ssOfflineNodes = "offline_nodes"
3355

    
3356
ssOnlineNodes :: String
3357
ssOnlineNodes = "online_nodes"
3358

    
3359
ssPrimaryIpFamily :: String
3360
ssPrimaryIpFamily = "primary_ip_family"
3361

    
3362
ssInstanceList :: String
3363
ssInstanceList = "instance_list"
3364

    
3365
ssReleaseVersion :: String
3366
ssReleaseVersion = "release_version"
3367

    
3368
ssHypervisorList :: String
3369
ssHypervisorList = "hypervisor_list"
3370

    
3371
ssMaintainNodeHealth :: String
3372
ssMaintainNodeHealth = "maintain_node_health"
3373

    
3374
ssUidPool :: String
3375
ssUidPool = "uid_pool"
3376

    
3377
ssNodegroups :: String
3378
ssNodegroups = "nodegroups"
3379

    
3380
ssNetworks :: String
3381
ssNetworks = "networks"
3382

    
3383
-- | This is not a complete SSCONF key, but the prefix for the
3384
-- hypervisor keys
3385
ssHvparamsPref :: String
3386
ssHvparamsPref = "hvparams_"
3387

    
3388
-- * Hvparams keys
3389

    
3390
ssHvparamsXenChroot :: String
3391
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3392

    
3393
ssHvparamsXenFake :: String
3394
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3395

    
3396
ssHvparamsXenHvm :: String
3397
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3398

    
3399
ssHvparamsXenKvm :: String
3400
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3401

    
3402
ssHvparamsXenLxc :: String
3403
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3404

    
3405
ssHvparamsXenPvm :: String
3406
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3407

    
3408
validSsHvparamsKeys :: FrozenSet String
3409
validSsHvparamsKeys =
3410
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3411
                       ssHvparamsXenLxc,
3412
                       ssHvparamsXenFake,
3413
                       ssHvparamsXenHvm,
3414
                       ssHvparamsXenKvm,
3415
                       ssHvparamsXenPvm]
3416

    
3417
ssFilePerms :: Int
3418
ssFilePerms = 0o444
3419

    
3420
-- | Cluster wide default parameters
3421
defaultEnabledHypervisor :: String
3422
defaultEnabledHypervisor = htXenPvm
3423

    
3424
hvcGlobals :: FrozenSet String
3425
hvcGlobals =
3426
  ConstantUtils.mkSet [hvMigrationBandwidth,
3427
                       hvMigrationMode,
3428
                       hvMigrationPort,
3429
                       hvXenCmd]
3430

    
3431
ndcGlobals :: FrozenSet String
3432
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3433

    
3434
-- | All of the following values are quite arbitrary - there are no
3435
-- "good" defaults, these must be customised per-site
3436
ispecsMinmaxDefaults :: Map String (Map String Int)
3437
ispecsMinmaxDefaults =
3438
  Map.fromList
3439
  [(ispecsMin,
3440
    Map.fromList
3441
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3442
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3443
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3444
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3445
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3446
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3447
   (ispecsMax,
3448
    Map.fromList
3449
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3450
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3451
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3452
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3453
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3454
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3455

    
3456
masterPoolSizeDefault :: Int
3457
masterPoolSizeDefault = 10
3458

    
3459
-- * Exclusive storage
3460

    
3461
-- | Error margin used to compare physical disks
3462
partMargin :: Double
3463
partMargin = 0.01
3464

    
3465
-- | Space reserved when creating instance disks
3466
partReserved :: Double
3467
partReserved = 0.02
3468

    
3469
-- * Confd
3470

    
3471
confdProtocolVersion :: Int
3472
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3473

    
3474
-- Confd request type
3475

    
3476
confdReqPing :: Int
3477
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3478

    
3479
confdReqNodeRoleByname :: Int
3480
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3481

    
3482
confdReqNodePipByInstanceIp :: Int
3483
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3484

    
3485
confdReqClusterMaster :: Int
3486
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3487

    
3488
confdReqNodePipList :: Int
3489
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3490

    
3491
confdReqMcPipList :: Int
3492
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3493

    
3494
confdReqInstancesIpsList :: Int
3495
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3496

    
3497
confdReqNodeDrbd :: Int
3498
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3499

    
3500
confdReqNodeInstances :: Int
3501
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3502

    
3503
confdReqs :: FrozenSet Int
3504
confdReqs =
3505
  ConstantUtils.mkSet .
3506
  map Types.confdRequestTypeToRaw $
3507
  [minBound..] \\ [ReqNodeInstances]
3508

    
3509
-- * Confd request type
3510

    
3511
confdReqfieldName :: Int
3512
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3513

    
3514
confdReqfieldIp :: Int
3515
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3516

    
3517
confdReqfieldMnodePip :: Int
3518
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3519

    
3520
-- * Confd repl status
3521

    
3522
confdReplStatusOk :: Int
3523
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3524

    
3525
confdReplStatusError :: Int
3526
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3527

    
3528
confdReplStatusNotimplemented :: Int
3529
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3530

    
3531
confdReplStatuses :: FrozenSet Int
3532
confdReplStatuses =
3533
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3534

    
3535
-- * Confd node role
3536

    
3537
confdNodeRoleMaster :: Int
3538
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3539

    
3540
confdNodeRoleCandidate :: Int
3541
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3542

    
3543
confdNodeRoleOffline :: Int
3544
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3545

    
3546
confdNodeRoleDrained :: Int
3547
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3548

    
3549
confdNodeRoleRegular :: Int
3550
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3551

    
3552
-- * A few common errors for confd
3553

    
3554
confdErrorUnknownEntry :: Int
3555
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3556

    
3557
confdErrorInternal :: Int
3558
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3559

    
3560
confdErrorArgument :: Int
3561
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3562

    
3563
-- * Confd request query fields
3564

    
3565
confdReqqLink :: String
3566
confdReqqLink = ConstantUtils.confdReqqLink
3567

    
3568
confdReqqIp :: String
3569
confdReqqIp = ConstantUtils.confdReqqIp
3570

    
3571
confdReqqIplist :: String
3572
confdReqqIplist = ConstantUtils.confdReqqIplist
3573

    
3574
confdReqqFields :: String
3575
confdReqqFields = ConstantUtils.confdReqqFields
3576

    
3577
-- | Each request is "salted" by the current timestamp.
3578
--
3579
-- This constant decides how many seconds of skew to accept.
3580
--
3581
-- TODO: make this a default and allow the value to be more
3582
-- configurable
3583
confdMaxClockSkew :: Int
3584
confdMaxClockSkew = 2 * nodeMaxClockSkew
3585

    
3586
-- | When we haven't reloaded the config for more than this amount of
3587
-- seconds, we force a test to see if inotify is betraying us. Using a
3588
-- prime number to ensure we get less chance of 'same wakeup' with
3589
-- other processes.
3590
confdConfigReloadTimeout :: Int
3591
confdConfigReloadTimeout = 17
3592

    
3593
-- | If we receive more than one update in this amount of
3594
-- microseconds, we move to polling every RATELIMIT seconds, rather
3595
-- than relying on inotify, to be able to serve more requests.
3596
confdConfigReloadRatelimit :: Int
3597
confdConfigReloadRatelimit = 250000
3598

    
3599
-- | Magic number prepended to all confd queries.
3600
--
3601
-- This allows us to distinguish different types of confd protocols
3602
-- and handle them. For example by changing this we can move the whole
3603
-- payload to be compressed, or move away from json.
3604
confdMagicFourcc :: String
3605
confdMagicFourcc = "plj0"
3606

    
3607
-- | By default a confd request is sent to the minimum between this
3608
-- number and all MCs. 6 was chosen because even in the case of a
3609
-- disastrous 50% response rate, we should have enough answers to be
3610
-- able to compare more than one.
3611
confdDefaultReqCoverage :: Int
3612
confdDefaultReqCoverage = 6
3613

    
3614
-- | Timeout in seconds to expire pending query request in the confd
3615
-- client library. We don't actually expect any answer more than 10
3616
-- seconds after we sent a request.
3617
confdClientExpireTimeout :: Int
3618
confdClientExpireTimeout = 10
3619

    
3620
-- | Maximum UDP datagram size.
3621
--
3622
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
3623
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
3624
--   (assuming we can't use jumbo frames)
3625
-- We just set this to 60K, which should be enough
3626
maxUdpDataSize :: Int
3627
maxUdpDataSize = 61440
3628

    
3629
-- * User-id pool minimum/maximum acceptable user-ids
3630

    
3631
uidpoolUidMin :: Int
3632
uidpoolUidMin = 0
3633

    
3634
-- | Assuming 32 bit user-ids
3635
uidpoolUidMax :: Integer
3636
uidpoolUidMax = 2 ^ 32 - 1
3637

    
3638
-- | Name or path of the pgrep command
3639
pgrep :: String
3640
pgrep = "pgrep"
3641

    
3642
-- | Name of the node group that gets created at cluster init or
3643
-- upgrade
3644
initialNodeGroupName :: String
3645
initialNodeGroupName = "default"
3646

    
3647
-- * Possible values for NodeGroup.alloc_policy
3648

    
3649
allocPolicyLastResort :: String
3650
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
3651

    
3652
allocPolicyPreferred :: String
3653
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
3654

    
3655
allocPolicyUnallocable :: String
3656
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
3657

    
3658
validAllocPolicies :: [String]
3659
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
3660

    
3661
-- | Temporary external/shared storage parameters
3662
blockdevDriverManual :: String
3663
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
3664

    
3665
-- | 'qemu-img' path, required for 'ovfconverter'
3666
qemuimgPath :: String
3667
qemuimgPath = AutoConf.qemuimgPath
3668

    
3669
-- | Whether htools was enabled at compilation time
3670
--
3671
-- FIXME: this should be moved next to the other enable constants,
3672
-- such as, 'enableConfd', and renamed to 'enableHtools'.
3673
htools :: Bool
3674
htools = AutoConf.htools
3675

    
3676
-- | The hail iallocator
3677
iallocHail :: String
3678
iallocHail = "hail"
3679

    
3680
-- * Fake opcodes for functions that have hooks attached to them via
3681
-- backend.RunLocalHooks
3682

    
3683
fakeOpMasterTurndown :: String
3684
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
3685

    
3686
fakeOpMasterTurnup :: String
3687
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
3688

    
3689
-- * SSH key types
3690

    
3691
sshkDsa :: String
3692
sshkDsa = "dsa"
3693

    
3694
sshkRsa :: String
3695
sshkRsa = "rsa"
3696

    
3697
sshkAll :: FrozenSet String
3698
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
3699

    
3700
-- * SSH authorized key types
3701

    
3702
sshakDss :: String
3703
sshakDss = "ssh-dss"
3704

    
3705
sshakRsa :: String
3706
sshakRsa = "ssh-rsa"
3707

    
3708
sshakAll :: FrozenSet String
3709
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
3710

    
3711
-- * SSH setup
3712

    
3713
sshsClusterName :: String
3714
sshsClusterName = "cluster_name"
3715

    
3716
sshsSshHostKey :: String
3717
sshsSshHostKey = "ssh_host_key"
3718

    
3719
sshsSshRootKey :: String
3720
sshsSshRootKey = "ssh_root_key"
3721

    
3722
sshsNodeDaemonCertificate :: String
3723
sshsNodeDaemonCertificate = "node_daemon_certificate"
3724

    
3725
-- * Key files for SSH daemon
3726

    
3727
sshHostDsaPriv :: String
3728
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
3729

    
3730
sshHostDsaPub :: String
3731
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
3732

    
3733
sshHostRsaPriv :: String
3734
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
3735

    
3736
sshHostRsaPub :: String
3737
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
3738

    
3739
-- * Node daemon setup
3740

    
3741
ndsClusterName :: String
3742
ndsClusterName = "cluster_name"
3743

    
3744
ndsNodeDaemonCertificate :: String
3745
ndsNodeDaemonCertificate = "node_daemon_certificate"
3746

    
3747
ndsSsconf :: String
3748
ndsSsconf = "ssconf"
3749

    
3750
ndsStartNodeDaemon :: String
3751
ndsStartNodeDaemon = "start_node_daemon"
3752

    
3753
-- * The source reasons for the execution of an OpCode
3754

    
3755
opcodeReasonSrcClient :: String
3756
opcodeReasonSrcClient = "gnt:client"
3757

    
3758
opcodeReasonSrcNoded :: String
3759
opcodeReasonSrcNoded = "gnt:daemon:noded"
3760

    
3761
opcodeReasonSrcOpcode :: String
3762
opcodeReasonSrcOpcode = "gnt:opcode"
3763

    
3764
opcodeReasonSrcRlib2 :: String
3765
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
3766

    
3767
opcodeReasonSrcUser :: String
3768
opcodeReasonSrcUser = "gnt:user"
3769

    
3770
opcodeReasonSources :: FrozenSet String
3771
opcodeReasonSources =
3772
  ConstantUtils.mkSet [opcodeReasonSrcClient,
3773
                       opcodeReasonSrcNoded,
3774
                       opcodeReasonSrcOpcode,
3775
                       opcodeReasonSrcRlib2,
3776
                       opcodeReasonSrcUser]
3777

    
3778
-- | Path generating random UUID
3779
randomUuidFile :: String
3780
randomUuidFile = ConstantUtils.randomUuidFile
3781

    
3782
-- * Auto-repair tag prefixes
3783

    
3784
autoRepairTagPrefix :: String
3785
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
3786

    
3787
autoRepairTagEnabled :: String
3788
autoRepairTagEnabled = autoRepairTagPrefix
3789

    
3790
autoRepairTagPending :: String
3791
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
3792

    
3793
autoRepairTagResult :: String
3794
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
3795

    
3796
autoRepairTagSuspended :: String
3797
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
3798

    
3799
-- * Auto-repair levels
3800

    
3801
autoRepairFailover :: String
3802
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
3803

    
3804
autoRepairFixStorage :: String
3805
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
3806

    
3807
autoRepairMigrate :: String
3808
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
3809

    
3810
autoRepairReinstall :: String
3811
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
3812

    
3813
autoRepairAllTypes :: FrozenSet String
3814
autoRepairAllTypes =
3815
  ConstantUtils.mkSet [autoRepairFailover,
3816
                       autoRepairFixStorage,
3817
                       autoRepairMigrate,
3818
                       autoRepairReinstall]
3819

    
3820
-- * Auto-repair results
3821

    
3822
autoRepairEnoperm :: String
3823
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
3824

    
3825
autoRepairFailure :: String
3826
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
3827

    
3828
autoRepairSuccess :: String
3829
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
3830

    
3831
autoRepairAllResults :: FrozenSet String
3832
autoRepairAllResults =
3833
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
3834

    
3835
-- | The version identifier for builtin data collectors
3836
builtinDataCollectorVersion :: String
3837
builtinDataCollectorVersion = "B"
3838

    
3839
-- | The reason trail opcode parameter name
3840
opcodeReason :: String
3841
opcodeReason = "reason"
3842

    
3843
diskstatsFile :: String
3844
diskstatsFile = "/proc/diskstats"
3845

    
3846
-- *  CPU load collector
3847

    
3848
statFile :: String
3849
statFile = "/proc/stat"
3850

    
3851
cpuavgloadBufferSize :: Int
3852
cpuavgloadBufferSize = 150
3853

    
3854
cpuavgloadWindowSize :: Int
3855
cpuavgloadWindowSize = 600
3856

    
3857
-- | Mond's variable for periodical data collection
3858
mondTimeInterval :: Int
3859
mondTimeInterval = 5
3860

    
3861
-- * Disk access modes
3862

    
3863
diskUserspace :: String
3864
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
3865

    
3866
diskKernelspace :: String
3867
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
3868

    
3869
diskValidAccessModes :: FrozenSet String
3870
diskValidAccessModes =
3871
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
3872

    
3873
-- | Timeout for queue draining in upgrades
3874
upgradeQueueDrainTimeout :: Int
3875
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
3876

    
3877
-- | Intervall at which the queue is polled during upgrades
3878
upgradeQueuePollInterval :: Int
3879
upgradeQueuePollInterval  = 10
3880

    
3881
-- * Hotplug Actions
3882

    
3883
hotplugActionAdd :: String
3884
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
3885

    
3886
hotplugActionRemove :: String
3887
hotplugActionRemove = Types.hotplugActionToRaw HARemove
3888

    
3889
hotplugActionModify :: String
3890
hotplugActionModify = Types.hotplugActionToRaw HAMod
3891

    
3892
hotplugAllActions :: FrozenSet String
3893
hotplugAllActions =
3894
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
3895

    
3896
-- * Hotplug Device Targets
3897

    
3898
hotplugTargetNic :: String
3899
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
3900

    
3901
hotplugTargetDisk :: String
3902
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
3903

    
3904
hotplugAllTargets :: FrozenSet String
3905
hotplugAllTargets =
3906
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]