Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ 53a5f21b

History | View | Annotate | Download (85.9 kB)

1
{-| HsConstants contains the Haskell constants
2

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

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

    
15
-}
16

    
17
{-
18

    
19
Copyright (C) 2013 Google Inc.
20

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

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

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

    
36
-}
37
module Ganeti.HsConstants where
38

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

    
44
import AutoConf
45
import Ganeti.ConstantUtils (PythonChar(..), FrozenSet, Protocol(..),
46
                             buildVersion)
47
import qualified Ganeti.ConstantUtils as ConstantUtils
48
import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..),
49
                       ExtraLogReason(..))
50
import Ganeti.HTools.Types (AutoRepairResult(..), AutoRepairType(..))
51
import qualified Ganeti.HTools.Types as Types
52
import Ganeti.Logging (SyslogUsage(..))
53
import qualified Ganeti.Logging as Logging (syslogUsageToRaw)
54
import qualified Ganeti.Runtime as Runtime
55
import Ganeti.Types
56
import qualified Ganeti.Types as Types
57
import Ganeti.Confd.Types (ConfdRequestType(..), ConfdReqField(..),
58
                           ConfdReplyStatus(..), ConfdNodeRole(..),
59
                           ConfdErrorType(..))
60
import qualified Ganeti.Confd.Types as Types
61

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

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

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

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

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

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

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

    
80
-- * 'autoconf' constants for Python only ('lib/pathutils.py')
81

    
82
-- ** Build-time constants
83

    
84
exportDir :: String
85
exportDir = AutoConf.exportDir
86

    
87
osSearchPath :: [String]
88
osSearchPath = AutoConf.osSearchPath
89

    
90
esSearchPath :: [String]
91
esSearchPath = AutoConf.esSearchPath
92

    
93
sshConfigDir :: String
94
sshConfigDir = AutoConf.sshConfigDir
95

    
96
xenConfigDir :: String
97
xenConfigDir = AutoConf.xenConfigDir
98

    
99
sysconfdir :: String
100
sysconfdir = AutoConf.sysconfdir
101

    
102
toolsdir :: String
103
toolsdir = AutoConf.toolsdir
104

    
105
localstatedir :: String
106
localstatedir = AutoConf.localstatedir
107

    
108
-- ** Paths which don't change for a virtual cluster
109

    
110
pkglibdir :: String
111
pkglibdir = AutoConf.pkglibdir
112

    
113
sharedir :: String
114
sharedir = AutoConf.sharedir
115

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

    
118
manPages :: Map String Int
119
manPages = Map.fromList AutoConf.manPages
120

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

    
123
versionedsharedir :: String
124
versionedsharedir = AutoConf.versionedsharedir
125

    
126
-- * 'autoconf' constants for Python only ('tests/py/docs_unittest.py')
127

    
128
gntScripts :: [String]
129
gntScripts = AutoConf.gntScripts
130

    
131
-- * Various versions
132

    
133
releaseVersion :: String
134
releaseVersion = AutoConf.packageVersion
135

    
136
versionMajor :: Int
137
versionMajor = AutoConf.versionMajor
138

    
139
versionMinor :: Int
140
versionMinor = AutoConf.versionMinor
141

    
142
versionRevision :: Int
143
versionRevision = AutoConf.versionRevision
144

    
145
dirVersion :: String
146
dirVersion = AutoConf.dirVersion
147

    
148
osApiV10 :: Int
149
osApiV10 = 10
150

    
151
osApiV15 :: Int
152
osApiV15 = 15
153

    
154
osApiV20 :: Int
155
osApiV20 = 20
156

    
157
osApiVersions :: FrozenSet Int
158
osApiVersions = ConstantUtils.mkSet [osApiV10, osApiV15, osApiV20]
159

    
160
exportVersion :: Int
161
exportVersion = 0
162

    
163
rapiVersion :: Int
164
rapiVersion = 2
165

    
166
configMajor :: Int
167
configMajor = AutoConf.versionMajor
168

    
169
configMinor :: Int
170
configMinor = AutoConf.versionMinor
171

    
172
-- | The configuration is supposed to remain stable across
173
-- revisions. Therefore, the revision number is cleared to '0'.
174
configRevision :: Int
175
configRevision = 0
176

    
177
configVersion :: Int
178
configVersion = buildVersion configMajor configMinor configRevision
179

    
180
-- | Similarly to the configuration (see 'configRevision'), the
181
-- protocols are supposed to remain stable across revisions.
182
protocolVersion :: Int
183
protocolVersion = buildVersion configMajor configMinor configRevision
184

    
185
-- * User separation
186

    
187
daemonsGroup :: String
188
daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
189

    
190
adminGroup :: String
191
adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
192

    
193
masterdUser :: String
194
masterdUser = Runtime.daemonUser GanetiMasterd
195

    
196
masterdGroup :: String
197
masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
198

    
199
rapiUser :: String
200
rapiUser = Runtime.daemonUser GanetiRapi
201

    
202
rapiGroup :: String
203
rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
204

    
205
confdUser :: String
206
confdUser = Runtime.daemonUser GanetiConfd
207

    
208
confdGroup :: String
209
confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
210

    
211
luxidUser :: String
212
luxidUser = Runtime.daemonUser GanetiLuxid
213

    
214
luxidGroup :: String
215
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
216

    
217
nodedUser :: String
218
nodedUser = Runtime.daemonUser GanetiNoded
219

    
220
nodedGroup :: String
221
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
222

    
223
mondUser :: String
224
mondUser = Runtime.daemonUser GanetiMond
225

    
226
mondGroup :: String
227
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
228

    
229
sshLoginUser :: String
230
sshLoginUser = AutoConf.sshLoginUser
231

    
232
sshConsoleUser :: String
233
sshConsoleUser = AutoConf.sshConsoleUser
234

    
235
-- * Cpu pinning separators and constants
236

    
237
cpuPinningSep :: String
238
cpuPinningSep = ":"
239

    
240
cpuPinningAll :: String
241
cpuPinningAll = "all"
242

    
243
-- | Internal representation of "all"
244
cpuPinningAllVal :: Int
245
cpuPinningAllVal = -1
246

    
247
-- | One "all" entry in a CPU list means CPU pinning is off
248
cpuPinningOff :: [Int]
249
cpuPinningOff = [cpuPinningAllVal]
250

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

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

    
275
-- * Wipe
276

    
277
ddCmd :: String
278
ddCmd = "dd"
279

    
280
-- | 1GB
281
maxWipeChunk :: Int
282
maxWipeChunk = 1024
283

    
284
minWipeChunkPercent :: Int
285
minWipeChunkPercent = 10
286

    
287
-- * Directories
288

    
289
runDirsMode :: Int
290
runDirsMode = 0o775
291

    
292
secureDirMode :: Int
293
secureDirMode = 0o700
294

    
295
secureFileMode :: Int
296
secureFileMode = 0o600
297

    
298
adoptableBlockdevRoot :: String
299
adoptableBlockdevRoot = "/dev/disk/"
300

    
301
-- * 'autoconf' enable/disable
302

    
303
enableConfd :: Bool
304
enableConfd = AutoConf.enableConfd
305

    
306
enableMond :: Bool
307
enableMond = AutoConf.enableMond
308

    
309
enableRestrictedCommands :: Bool
310
enableRestrictedCommands = AutoConf.enableRestrictedCommands
311

    
312
enableSplitQuery :: Bool
313
enableSplitQuery = AutoConf.enableSplitQuery
314

    
315
-- * SSH constants
316

    
317
ssh :: String
318
ssh = "ssh"
319

    
320
scp :: String
321
scp = "scp"
322

    
323
-- * Daemons
324

    
325
confd :: String
326
confd = Runtime.daemonName GanetiConfd
327

    
328
masterd :: String
329
masterd = Runtime.daemonName GanetiMasterd
330

    
331
mond :: String
332
mond = Runtime.daemonName GanetiMond
333

    
334
noded :: String
335
noded = Runtime.daemonName GanetiNoded
336

    
337
luxid :: String
338
luxid = Runtime.daemonName GanetiLuxid
339

    
340
rapi :: String
341
rapi = Runtime.daemonName GanetiRapi
342

    
343
daemons :: FrozenSet String
344
daemons =
345
  ConstantUtils.mkSet [confd,
346
                       luxid,
347
                       masterd,
348
                       mond,
349
                       noded,
350
                       rapi]
351

    
352
defaultConfdPort :: Int
353
defaultConfdPort = 1814
354

    
355
defaultMondPort :: Int
356
defaultMondPort = 1815
357

    
358
defaultNodedPort :: Int
359
defaultNodedPort = 1811
360

    
361
defaultRapiPort :: Int
362
defaultRapiPort = 5080
363

    
364
daemonsPorts :: Map String (Protocol, Int)
365
daemonsPorts =
366
  Map.fromList [(confd, (Udp, defaultConfdPort)),
367
                (mond, (Tcp, defaultMondPort)),
368
                (noded, (Tcp, defaultNodedPort)),
369
                (rapi, (Tcp, defaultRapiPort)),
370
                (ssh, (Tcp, 22))]
371

    
372
firstDrbdPort :: Int
373
firstDrbdPort = 11000
374

    
375
lastDrbdPort :: Int
376
lastDrbdPort = 14999
377

    
378
daemonsLogbase :: Map String String
379
daemonsLogbase =
380
  Map.fromList
381
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
382

    
383
extraLogreasonAccess :: String
384
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
385

    
386
extraLogreasonError :: String
387
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
388

    
389
devConsole :: String
390
devConsole = ConstantUtils.devConsole
391

    
392
procMounts :: String
393
procMounts = "/proc/mounts"
394

    
395
-- * Luxi (Local UniX Interface) related constants
396

    
397
luxiEom :: PythonChar
398
luxiEom = PythonChar '\x03'
399

    
400
-- | Environment variable for the luxi override socket
401
luxiOverride :: String
402
luxiOverride = "FORCE_LUXI_SOCKET"
403

    
404
luxiOverrideMaster :: String
405
luxiOverrideMaster = "master"
406

    
407
luxiOverrideQuery :: String
408
luxiOverrideQuery = "query"
409

    
410
luxiVersion :: Int
411
luxiVersion = configVersion
412

    
413
-- * Syslog
414

    
415
syslogUsage :: String
416
syslogUsage = AutoConf.syslogUsage
417

    
418
syslogNo :: String
419
syslogNo = Logging.syslogUsageToRaw SyslogNo
420

    
421
syslogYes :: String
422
syslogYes = Logging.syslogUsageToRaw SyslogYes
423

    
424
syslogOnly :: String
425
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
426

    
427
syslogSocket :: String
428
syslogSocket = "/dev/log"
429

    
430
exportConfFile :: String
431
exportConfFile = "config.ini"
432

    
433
-- * Xen
434

    
435
xenBootloader :: String
436
xenBootloader = AutoConf.xenBootloader
437

    
438
xenCmdXl :: String
439
xenCmdXl = "xl"
440

    
441
xenCmdXm :: String
442
xenCmdXm = "xm"
443

    
444
xenInitrd :: String
445
xenInitrd = AutoConf.xenInitrd
446

    
447
xenKernel :: String
448
xenKernel = AutoConf.xenKernel
449

    
450
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
451
-- other constants
452
knownXenCommands :: FrozenSet String
453
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
454

    
455
-- * KVM and socat
456

    
457
kvmPath :: String
458
kvmPath = AutoConf.kvmPath
459

    
460
kvmKernel :: String
461
kvmKernel = AutoConf.kvmKernel
462

    
463
socatEscapeCode :: String
464
socatEscapeCode = "0x1d"
465

    
466
socatPath :: String
467
socatPath = AutoConf.socatPath
468

    
469
socatUseCompress :: Bool
470
socatUseCompress = AutoConf.socatUseCompress
471

    
472
socatUseEscape :: Bool
473
socatUseEscape = AutoConf.socatUseEscape
474

    
475
-- * Console types
476

    
477
-- | Display a message for console access
478
consMessage :: String
479
consMessage = "msg"
480

    
481
-- | Console as SPICE server
482
consSpice :: String
483
consSpice = "spice"
484

    
485
-- | Console as SSH command
486
consSsh :: String
487
consSsh = "ssh"
488

    
489
-- | Console as VNC server
490
consVnc :: String
491
consVnc = "vnc"
492

    
493
consAll :: FrozenSet String
494
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
495

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

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

    
515
-- * X509
516

    
517
-- | commonName (CN) used in certificates
518
x509CertCn :: String
519
x509CertCn = "ganeti.example.com"
520

    
521
-- | Default validity of certificates in days
522
x509CertDefaultValidity :: Int
523
x509CertDefaultValidity = 365 * 5
524

    
525
x509CertSignatureHeader :: String
526
x509CertSignatureHeader = "X-Ganeti-Signature"
527

    
528
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
529
x509CertSignDigest :: String
530
x509CertSignDigest = "SHA1"
531

    
532
-- * Import/export daemon mode
533

    
534
iemExport :: String
535
iemExport = "export"
536

    
537
iemImport :: String
538
iemImport = "import"
539

    
540
-- * Import/export transport compression
541

    
542
iecGzip :: String
543
iecGzip = "gzip"
544

    
545
iecNone :: String
546
iecNone = "none"
547

    
548
iecAll :: [String]
549
iecAll = [iecGzip, iecNone]
550

    
551
ieCustomSize :: String
552
ieCustomSize = "fd"
553

    
554
-- * Import/export I/O
555

    
556
-- | Direct file I/O, equivalent to a shell's I/O redirection using
557
-- '<' or '>'
558
ieioFile :: String
559
ieioFile = "file"
560

    
561
-- | Raw block device I/O using "dd"
562
ieioRawDisk :: String
563
ieioRawDisk = "raw"
564

    
565
-- | OS definition import/export script
566
ieioScript :: String
567
ieioScript = "script"
568

    
569
-- * Hooks
570

    
571
hooksNameCfgupdate :: String
572
hooksNameCfgupdate = "config-update"
573

    
574
hooksNameWatcher :: String
575
hooksNameWatcher = "watcher"
576

    
577
hooksPath :: String
578
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
579

    
580
hooksPhasePost :: String
581
hooksPhasePost = "post"
582

    
583
hooksPhasePre :: String
584
hooksPhasePre = "pre"
585

    
586
hooksVersion :: Int
587
hooksVersion = 2
588

    
589
-- * Hooks subject type (what object type does the LU deal with)
590

    
591
htypeCluster :: String
592
htypeCluster = "CLUSTER"
593

    
594
htypeGroup :: String
595
htypeGroup = "GROUP"
596

    
597
htypeInstance :: String
598
htypeInstance = "INSTANCE"
599

    
600
htypeNetwork :: String
601
htypeNetwork = "NETWORK"
602

    
603
htypeNode :: String
604
htypeNode = "NODE"
605

    
606
-- * Hkr
607

    
608
hkrSkip :: Int
609
hkrSkip = 0
610

    
611
hkrFail :: Int
612
hkrFail = 1
613

    
614
hkrSuccess :: Int
615
hkrSuccess = 2
616

    
617
-- * Storage types
618

    
619
stBlock :: String
620
stBlock = Types.storageTypeToRaw StorageBlock
621

    
622
stDiskless :: String
623
stDiskless = Types.storageTypeToRaw StorageDiskless
624

    
625
stExt :: String
626
stExt = Types.storageTypeToRaw StorageExt
627

    
628
stFile :: String
629
stFile = Types.storageTypeToRaw StorageFile
630

    
631
stLvmPv :: String
632
stLvmPv = Types.storageTypeToRaw StorageLvmPv
633

    
634
stLvmVg :: String
635
stLvmVg = Types.storageTypeToRaw StorageLvmVg
636

    
637
stRados :: String
638
stRados = Types.storageTypeToRaw StorageRados
639

    
640
storageTypes :: FrozenSet String
641
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
642

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

    
650
-- * Storage fields
651
-- ** First two are valid in LU context only, not passed to backend
652

    
653
sfNode :: String
654
sfNode = "node"
655

    
656
sfType :: String
657
sfType = "type"
658

    
659
-- ** and the rest are valid in backend
660

    
661
sfAllocatable :: String
662
sfAllocatable = Types.storageFieldToRaw SFAllocatable
663

    
664
sfFree :: String
665
sfFree = Types.storageFieldToRaw SFFree
666

    
667
sfName :: String
668
sfName = Types.storageFieldToRaw SFName
669

    
670
sfSize :: String
671
sfSize = Types.storageFieldToRaw SFSize
672

    
673
sfUsed :: String
674
sfUsed = Types.storageFieldToRaw SFUsed
675

    
676
validStorageFields :: FrozenSet String
677
validStorageFields =
678
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
679
                        [sfNode, sfType]
680

    
681
modifiableStorageFields :: Map String (FrozenSet String)
682
modifiableStorageFields =
683
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
684
                 ConstantUtils.mkSet [sfAllocatable])]
685

    
686
-- * Storage operations
687

    
688
soFixConsistency :: String
689
soFixConsistency = "fix-consistency"
690

    
691
validStorageOperations :: Map String (FrozenSet String)
692
validStorageOperations =
693
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
694
                 ConstantUtils.mkSet [soFixConsistency])]
695

    
696
-- * Volume fields
697

    
698
vfDev :: String
699
vfDev = "dev"
700

    
701
vfInstance :: String
702
vfInstance = "instance"
703

    
704
vfName :: String
705
vfName = "name"
706

    
707
vfNode :: String
708
vfNode = "node"
709

    
710
vfPhys :: String
711
vfPhys = "phys"
712

    
713
vfSize :: String
714
vfSize = "size"
715

    
716
vfVg :: String
717
vfVg = "vg"
718

    
719
-- * Local disk status
720

    
721
ldsFaulty :: Int
722
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
723

    
724
ldsOkay :: Int
725
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
726

    
727
ldsUnknown :: Int
728
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
729

    
730
ldsNames :: Map Int String
731
ldsNames =
732
  Map.fromList [ (Types.localDiskStatusToRaw ds,
733
                  localDiskStatusName ds) | ds <- [minBound..] ]
734

    
735
-- * Disk template types
736

    
737
dtDiskless :: String
738
dtDiskless = Types.diskTemplateToRaw DTDiskless
739

    
740
dtFile :: String
741
dtFile = Types.diskTemplateToRaw DTFile
742

    
743
dtSharedFile :: String
744
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
745

    
746
dtPlain :: String
747
dtPlain = Types.diskTemplateToRaw DTPlain
748

    
749
dtBlock :: String
750
dtBlock = Types.diskTemplateToRaw DTBlock
751

    
752
dtDrbd8 :: String
753
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
754

    
755
dtRbd :: String
756
dtRbd = Types.diskTemplateToRaw DTRbd
757

    
758
dtExt :: String
759
dtExt = Types.diskTemplateToRaw DTExt
760

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

    
771
diskTemplates :: FrozenSet String
772
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
773

    
774
-- | Disk templates that are enabled by default
775
defaultEnabledDiskTemplates :: [String]
776
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
777

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

    
792
-- | The set of network-mirrored disk templates
793
dtsIntMirror :: FrozenSet String
794
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
795

    
796
-- | 'DTDiskless' is 'trivially' externally mirrored
797
dtsExtMirror :: FrozenSet String
798
dtsExtMirror =
799
  ConstantUtils.mkSet $
800
  map Types.diskTemplateToRaw [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd]
801

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

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

    
816
-- | The set of disk templates that allow adoption
817
dtsMayAdopt :: FrozenSet String
818
dtsMayAdopt =
819
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
820

    
821
-- | The set of disk templates that *must* use adoption
822
dtsMustAdopt :: FrozenSet String
823
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
824

    
825
-- | The set of disk templates that allow migrations
826
dtsMirrored :: FrozenSet String
827
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
828

    
829
-- | The set of file based disk templates
830
dtsFilebased :: FrozenSet String
831
dtsFilebased =
832
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTSharedFile, DTFile]
833

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

    
842
-- | The set of disk templates that are supported by exclusive_storage
843
dtsExclStorage :: FrozenSet String
844
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
845

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

    
852
dtsBlock :: FrozenSet String
853
dtsBlock =
854
  ConstantUtils.mkSet $
855
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
856

    
857
-- * Drbd
858

    
859
drbdHmacAlg :: String
860
drbdHmacAlg = "md5"
861

    
862
drbdDefaultNetProtocol :: String
863
drbdDefaultNetProtocol = "C"
864

    
865
drbdMigrationNetProtocol :: String
866
drbdMigrationNetProtocol = "C"
867

    
868
drbdStatusFile :: String
869
drbdStatusFile = "/proc/drbd"
870

    
871
-- | Size of DRBD meta block device
872
drbdMetaSize :: Int
873
drbdMetaSize = 128
874

    
875
-- * Drbd barrier types
876

    
877
drbdBDiskBarriers :: String
878
drbdBDiskBarriers = "b"
879

    
880
drbdBDiskDrain :: String
881
drbdBDiskDrain = "d"
882

    
883
drbdBDiskFlush :: String
884
drbdBDiskFlush = "f"
885

    
886
drbdBNone :: String
887
drbdBNone = "n"
888

    
889
-- | Rbd tool command
890
rbdCmd :: String
891
rbdCmd = "rbd"
892

    
893
-- * File backend driver
894

    
895
fdBlktap :: String
896
fdBlktap = Types.fileDriverToRaw FileBlktap
897

    
898
fdLoop :: String
899
fdLoop = Types.fileDriverToRaw FileLoop
900

    
901
fileDriver :: FrozenSet String
902
fileDriver =
903
  ConstantUtils.mkSet $
904
  map Types.fileDriverToRaw [minBound..]
905

    
906
-- | The set of drbd-like disk types
907
ldsDrbd :: FrozenSet String
908
ldsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
909

    
910
-- * Disk access mode
911

    
912
diskRdonly :: String
913
diskRdonly = Types.diskModeToRaw DiskRdOnly
914

    
915
diskRdwr :: String
916
diskRdwr = Types.diskModeToRaw DiskRdWr
917

    
918
diskAccessSet :: FrozenSet String
919
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
920

    
921
-- * Disk replacement mode
922

    
923
replaceDiskAuto :: String
924
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
925

    
926
replaceDiskChg :: String
927
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
928

    
929
replaceDiskPri :: String
930
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
931

    
932
replaceDiskSec :: String
933
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
934

    
935
replaceModes :: FrozenSet String
936
replaceModes =
937
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
938

    
939
-- * Instance export mode
940

    
941
exportModeLocal :: String
942
exportModeLocal = Types.exportModeToRaw ExportModeLocal
943

    
944
exportModeRemote :: String
945
exportModeRemote = Types.exportModeToRaw ExportModeRemote
946

    
947
exportModes :: FrozenSet String
948
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
949

    
950
-- * Instance creation modes
951

    
952
instanceCreate :: String
953
instanceCreate = Types.instCreateModeToRaw InstCreate
954

    
955
instanceImport :: String
956
instanceImport = Types.instCreateModeToRaw InstImport
957

    
958
instanceRemoteImport :: String
959
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
960

    
961
instanceCreateModes :: FrozenSet String
962
instanceCreateModes =
963
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
964

    
965
-- * Remote import/export handshake message and version
966

    
967
rieHandshake :: String
968
rieHandshake = "Hi, I'm Ganeti"
969

    
970
rieVersion :: Int
971
rieVersion = 0
972

    
973
-- | Remote import/export certificate validity in seconds
974
rieCertValidity :: Int
975
rieCertValidity = 24 * 60 * 60
976

    
977
-- | Export only: how long to wait per connection attempt (seconds)
978
rieConnectAttemptTimeout :: Int
979
rieConnectAttemptTimeout = 20
980

    
981
-- | Export only: number of attempts to connect
982
rieConnectRetries :: Int
983
rieConnectRetries = 10
984

    
985
-- | Overall timeout for establishing connection
986
rieConnectTimeout :: Int
987
rieConnectTimeout = 180
988

    
989
-- | Give child process up to 5 seconds to exit after sending a signal
990
childLingerTimeout :: Double
991
childLingerTimeout = 5.0
992

    
993
-- * Import/export config options
994

    
995
inisectBep :: String
996
inisectBep = "backend"
997

    
998
inisectExp :: String
999
inisectExp = "export"
1000

    
1001
inisectHyp :: String
1002
inisectHyp = "hypervisor"
1003

    
1004
inisectIns :: String
1005
inisectIns = "instance"
1006

    
1007
inisectOsp :: String
1008
inisectOsp = "os"
1009

    
1010
-- * Dynamic device modification
1011

    
1012
ddmAdd :: String
1013
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1014

    
1015
ddmModify :: String
1016
ddmModify = Types.ddmFullToRaw DdmFullModify
1017

    
1018
ddmRemove :: String
1019
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1020

    
1021
ddmsValues :: FrozenSet String
1022
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1023

    
1024
ddmsValuesWithModify :: FrozenSet String
1025
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1026

    
1027
-- * Common exit codes
1028

    
1029
exitSuccess :: Int
1030
exitSuccess = 0
1031

    
1032
exitFailure :: Int
1033
exitFailure = ConstantUtils.exitFailure
1034

    
1035
exitNotcluster :: Int
1036
exitNotcluster = 5
1037

    
1038
exitNotmaster :: Int
1039
exitNotmaster = 11
1040

    
1041
exitNodesetupError :: Int
1042
exitNodesetupError = 12
1043

    
1044
-- | Need user confirmation
1045
exitConfirmation :: Int
1046
exitConfirmation = 13
1047

    
1048
-- | Exit code for query operations with unknown fields
1049
exitUnknownField :: Int
1050
exitUnknownField = 14
1051

    
1052
-- * Tags
1053

    
1054
tagCluster :: String
1055
tagCluster = Types.tagKindToRaw TagKindCluster
1056

    
1057
tagInstance :: String
1058
tagInstance = Types.tagKindToRaw TagKindInstance
1059

    
1060
tagNetwork :: String
1061
tagNetwork = Types.tagKindToRaw TagKindNetwork
1062

    
1063
tagNode :: String
1064
tagNode = Types.tagKindToRaw TagKindNode
1065

    
1066
tagNodegroup :: String
1067
tagNodegroup = Types.tagKindToRaw TagKindGroup
1068

    
1069
validTagTypes :: FrozenSet String
1070
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1071

    
1072
maxTagLen :: Int
1073
maxTagLen = 128
1074

    
1075
maxTagsPerObj :: Int
1076
maxTagsPerObj = 4096
1077

    
1078
-- * Others
1079

    
1080
defaultBridge :: String
1081
defaultBridge = "xen-br0"
1082

    
1083
defaultOvs :: String
1084
defaultOvs = "switch1"
1085

    
1086
-- | 60 MiB, expressed in KiB
1087
classicDrbdSyncSpeed :: Int
1088
classicDrbdSyncSpeed = 60 * 1024
1089

    
1090
ip4AddressAny :: String
1091
ip4AddressAny = "0.0.0.0"
1092

    
1093
ip4AddressLocalhost :: String
1094
ip4AddressLocalhost = "127.0.0.1"
1095

    
1096
ip6AddressAny :: String
1097
ip6AddressAny = "::"
1098

    
1099
ip6AddressLocalhost :: String
1100
ip6AddressLocalhost = "::1"
1101

    
1102
ip4Version :: Int
1103
ip4Version = 4
1104

    
1105
ip6Version :: Int
1106
ip6Version = 6
1107

    
1108
validIpVersions :: FrozenSet Int
1109
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1110

    
1111
tcpPingTimeout :: Int
1112
tcpPingTimeout = 10
1113

    
1114
defaultVg :: String
1115
defaultVg = "xenvg"
1116

    
1117
defaultDrbdHelper :: String
1118
defaultDrbdHelper = "/bin/true"
1119

    
1120
minVgSize :: Int
1121
minVgSize = 20480
1122

    
1123
defaultMacPrefix :: String
1124
defaultMacPrefix = "aa:00:00"
1125

    
1126
-- | Default maximum instance wait time, in seconds.
1127
defaultShutdownTimeout :: Int
1128
defaultShutdownTimeout = 120
1129

    
1130
-- | Node clock skew in seconds
1131
nodeMaxClockSkew :: Int
1132
nodeMaxClockSkew = 150
1133

    
1134
-- | Time for an intra-cluster disk transfer to wait for a connection
1135
diskTransferConnectTimeout :: Int
1136
diskTransferConnectTimeout = 60
1137

    
1138
-- | Disk index separator
1139
diskSeparator :: String
1140
diskSeparator = AutoConf.diskSeparator
1141

    
1142
ipCommandPath :: String
1143
ipCommandPath = AutoConf.ipPath
1144

    
1145
-- | Key for job IDs in opcode result
1146
jobIdsKey :: String
1147
jobIdsKey = "jobs"
1148

    
1149
-- * Runparts results
1150

    
1151
runpartsErr :: Int
1152
runpartsErr = 2
1153

    
1154
runpartsRun :: Int
1155
runpartsRun = 1
1156

    
1157
runpartsSkip :: Int
1158
runpartsSkip = 0
1159

    
1160
runpartsStatus :: [Int]
1161
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1162

    
1163
-- * RPC
1164

    
1165
rpcEncodingNone :: Int
1166
rpcEncodingNone = 0
1167

    
1168
rpcEncodingZlibBase64 :: Int
1169
rpcEncodingZlibBase64 = 1
1170

    
1171
-- * Timeout table
1172
--
1173
-- Various time constants for the timeout table
1174

    
1175
rpcTmoUrgent :: Int
1176
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1177

    
1178
rpcTmoFast :: Int
1179
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1180

    
1181
rpcTmoNormal :: Int
1182
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1183

    
1184
rpcTmoSlow :: Int
1185
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1186

    
1187
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1188
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1189
-- Python name.
1190
rpcTmo_4hrs :: Int
1191
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1192

    
1193
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1194
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1195
-- Python name.
1196
rpcTmo_1day :: Int
1197
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1198

    
1199
-- | Timeout for connecting to nodes (seconds)
1200
rpcConnectTimeout :: Int
1201
rpcConnectTimeout = 5
1202

    
1203
-- OS
1204

    
1205
osScriptCreate :: String
1206
osScriptCreate = "create"
1207

    
1208
osScriptExport :: String
1209
osScriptExport = "export"
1210

    
1211
osScriptImport :: String
1212
osScriptImport = "import"
1213

    
1214
osScriptRename :: String
1215
osScriptRename = "rename"
1216

    
1217
osScriptVerify :: String
1218
osScriptVerify = "verify"
1219

    
1220
osScripts :: [String]
1221
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1222
             osScriptVerify]
1223

    
1224
osApiFile :: String
1225
osApiFile = "ganeti_api_version"
1226

    
1227
osVariantsFile :: String
1228
osVariantsFile = "variants.list"
1229

    
1230
osParametersFile :: String
1231
osParametersFile = "parameters.list"
1232

    
1233
osValidateParameters :: String
1234
osValidateParameters = "parameters"
1235

    
1236
osValidateCalls :: FrozenSet String
1237
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1238

    
1239
-- | External Storage (ES) related constants
1240

    
1241
esActionAttach :: String
1242
esActionAttach = "attach"
1243

    
1244
esActionCreate :: String
1245
esActionCreate = "create"
1246

    
1247
esActionDetach :: String
1248
esActionDetach = "detach"
1249

    
1250
esActionGrow :: String
1251
esActionGrow = "grow"
1252

    
1253
esActionRemove :: String
1254
esActionRemove = "remove"
1255

    
1256
esActionSetinfo :: String
1257
esActionSetinfo = "setinfo"
1258

    
1259
esActionVerify :: String
1260
esActionVerify = "verify"
1261

    
1262
esScriptCreate :: String
1263
esScriptCreate = esActionCreate
1264

    
1265
esScriptRemove :: String
1266
esScriptRemove = esActionRemove
1267

    
1268
esScriptGrow :: String
1269
esScriptGrow = esActionGrow
1270

    
1271
esScriptAttach :: String
1272
esScriptAttach = esActionAttach
1273

    
1274
esScriptDetach :: String
1275
esScriptDetach = esActionDetach
1276

    
1277
esScriptSetinfo :: String
1278
esScriptSetinfo = esActionSetinfo
1279

    
1280
esScriptVerify :: String
1281
esScriptVerify = esActionVerify
1282

    
1283
esScripts :: FrozenSet String
1284
esScripts =
1285
  ConstantUtils.mkSet [esScriptAttach,
1286
                       esScriptCreate,
1287
                       esScriptDetach,
1288
                       esScriptGrow,
1289
                       esScriptRemove,
1290
                       esScriptSetinfo,
1291
                       esScriptVerify]
1292

    
1293
esParametersFile :: String
1294
esParametersFile = "parameters.list"
1295

    
1296
-- * Reboot types
1297

    
1298
instanceRebootSoft :: String
1299
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1300

    
1301
instanceRebootHard :: String
1302
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1303

    
1304
instanceRebootFull :: String
1305
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1306

    
1307
rebootTypes :: FrozenSet String
1308
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1309

    
1310
-- * Instance reboot behaviors
1311

    
1312
instanceRebootAllowed :: String
1313
instanceRebootAllowed = "reboot"
1314

    
1315
instanceRebootExit :: String
1316
instanceRebootExit = "exit"
1317

    
1318
rebootBehaviors :: [String]
1319
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1320

    
1321
-- * VTypes
1322

    
1323
vtypeBool :: VType
1324
vtypeBool = VTypeBool
1325

    
1326
vtypeInt :: VType
1327
vtypeInt = VTypeInt
1328

    
1329
vtypeMaybeString :: VType
1330
vtypeMaybeString = VTypeMaybeString
1331

    
1332
-- | Size in MiBs
1333
vtypeSize :: VType
1334
vtypeSize = VTypeSize
1335

    
1336
vtypeString :: VType
1337
vtypeString = VTypeString
1338

    
1339
enforceableTypes :: FrozenSet VType
1340
enforceableTypes = ConstantUtils.mkSet [minBound..]
1341

    
1342
-- | Constant representing that the user does not specify any IP version
1343
ifaceNoIpVersionSpecified :: Int
1344
ifaceNoIpVersionSpecified = 0
1345

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

    
1367
-- * HV parameter names (global namespace)
1368

    
1369
hvAcpi :: String
1370
hvAcpi = "acpi"
1371

    
1372
hvBlockdevPrefix :: String
1373
hvBlockdevPrefix = "blockdev_prefix"
1374

    
1375
hvBootloaderArgs :: String
1376
hvBootloaderArgs = "bootloader_args"
1377

    
1378
hvBootloaderPath :: String
1379
hvBootloaderPath = "bootloader_path"
1380

    
1381
hvBootOrder :: String
1382
hvBootOrder = "boot_order"
1383

    
1384
hvCdromImagePath :: String
1385
hvCdromImagePath = "cdrom_image_path"
1386

    
1387
hvCpuCap :: String
1388
hvCpuCap = "cpu_cap"
1389

    
1390
hvCpuCores :: String
1391
hvCpuCores = "cpu_cores"
1392

    
1393
hvCpuMask :: String
1394
hvCpuMask = "cpu_mask"
1395

    
1396
hvCpuSockets :: String
1397
hvCpuSockets = "cpu_sockets"
1398

    
1399
hvCpuThreads :: String
1400
hvCpuThreads = "cpu_threads"
1401

    
1402
hvCpuType :: String
1403
hvCpuType = "cpu_type"
1404

    
1405
hvCpuWeight :: String
1406
hvCpuWeight = "cpu_weight"
1407

    
1408
hvDeviceModel :: String
1409
hvDeviceModel = "device_model"
1410

    
1411
hvDiskCache :: String
1412
hvDiskCache = "disk_cache"
1413

    
1414
hvDiskType :: String
1415
hvDiskType = "disk_type"
1416

    
1417
hvInitrdPath :: String
1418
hvInitrdPath = "initrd_path"
1419

    
1420
hvInitScript :: String
1421
hvInitScript = "init_script"
1422

    
1423
hvKernelArgs :: String
1424
hvKernelArgs = "kernel_args"
1425

    
1426
hvKernelPath :: String
1427
hvKernelPath = "kernel_path"
1428

    
1429
hvKeymap :: String
1430
hvKeymap = "keymap"
1431

    
1432
hvKvmCdrom2ImagePath :: String
1433
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1434

    
1435
hvKvmCdromDiskType :: String
1436
hvKvmCdromDiskType = "cdrom_disk_type"
1437

    
1438
hvKvmExtra :: String
1439
hvKvmExtra = "kvm_extra"
1440

    
1441
hvKvmFlag :: String
1442
hvKvmFlag = "kvm_flag"
1443

    
1444
hvKvmFloppyImagePath :: String
1445
hvKvmFloppyImagePath = "floppy_image_path"
1446

    
1447
hvKvmMachineVersion :: String
1448
hvKvmMachineVersion = "machine_version"
1449

    
1450
hvKvmPath :: String
1451
hvKvmPath = "kvm_path"
1452

    
1453
hvKvmSpiceAudioCompr :: String
1454
hvKvmSpiceAudioCompr = "spice_playback_compression"
1455

    
1456
hvKvmSpiceBind :: String
1457
hvKvmSpiceBind = "spice_bind"
1458

    
1459
hvKvmSpiceIpVersion :: String
1460
hvKvmSpiceIpVersion = "spice_ip_version"
1461

    
1462
hvKvmSpiceJpegImgCompr :: String
1463
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1464

    
1465
hvKvmSpiceLosslessImgCompr :: String
1466
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1467

    
1468
hvKvmSpicePasswordFile :: String
1469
hvKvmSpicePasswordFile = "spice_password_file"
1470

    
1471
hvKvmSpiceStreamingVideoDetection :: String
1472
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1473

    
1474
hvKvmSpiceTlsCiphers :: String
1475
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1476

    
1477
hvKvmSpiceUseTls :: String
1478
hvKvmSpiceUseTls = "spice_use_tls"
1479

    
1480
hvKvmSpiceUseVdagent :: String
1481
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1482

    
1483
hvKvmSpiceZlibGlzImgCompr :: String
1484
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1485

    
1486
hvKvmUseChroot :: String
1487
hvKvmUseChroot = "use_chroot"
1488

    
1489
hvMemPath :: String
1490
hvMemPath = "mem_path"
1491

    
1492
hvMigrationBandwidth :: String
1493
hvMigrationBandwidth = "migration_bandwidth"
1494

    
1495
hvMigrationDowntime :: String
1496
hvMigrationDowntime = "migration_downtime"
1497

    
1498
hvMigrationMode :: String
1499
hvMigrationMode = "migration_mode"
1500

    
1501
hvMigrationPort :: String
1502
hvMigrationPort = "migration_port"
1503

    
1504
hvNicType :: String
1505
hvNicType = "nic_type"
1506

    
1507
hvPae :: String
1508
hvPae = "pae"
1509

    
1510
hvPassthrough :: String
1511
hvPassthrough = "pci_pass"
1512

    
1513
hvRebootBehavior :: String
1514
hvRebootBehavior = "reboot_behavior"
1515

    
1516
hvRootPath :: String
1517
hvRootPath = "root_path"
1518

    
1519
hvSecurityDomain :: String
1520
hvSecurityDomain = "security_domain"
1521

    
1522
hvSecurityModel :: String
1523
hvSecurityModel = "security_model"
1524

    
1525
hvSerialConsole :: String
1526
hvSerialConsole = "serial_console"
1527

    
1528
hvSerialSpeed :: String
1529
hvSerialSpeed = "serial_speed"
1530

    
1531
hvSoundhw :: String
1532
hvSoundhw = "soundhw"
1533

    
1534
hvUsbDevices :: String
1535
hvUsbDevices = "usb_devices"
1536

    
1537
hvUsbMouse :: String
1538
hvUsbMouse = "usb_mouse"
1539

    
1540
hvUseBootloader :: String
1541
hvUseBootloader = "use_bootloader"
1542

    
1543
hvUseLocaltime :: String
1544
hvUseLocaltime = "use_localtime"
1545

    
1546
hvVga :: String
1547
hvVga = "vga"
1548

    
1549
hvVhostNet :: String
1550
hvVhostNet = "vhost_net"
1551

    
1552
hvVifScript :: String
1553
hvVifScript = "vif_script"
1554

    
1555
hvVifType :: String
1556
hvVifType = "vif_type"
1557

    
1558
hvViridian :: String
1559
hvViridian = "viridian"
1560

    
1561
hvVncBindAddress :: String
1562
hvVncBindAddress = "vnc_bind_address"
1563

    
1564
hvVncPasswordFile :: String
1565
hvVncPasswordFile = "vnc_password_file"
1566

    
1567
hvVncTls :: String
1568
hvVncTls = "vnc_tls"
1569

    
1570
hvVncX509 :: String
1571
hvVncX509 = "vnc_x509_path"
1572

    
1573
hvVncX509Verify :: String
1574
hvVncX509Verify = "vnc_x509_verify"
1575

    
1576
hvVnetHdr :: String
1577
hvVnetHdr = "vnet_hdr"
1578

    
1579
hvXenCmd :: String
1580
hvXenCmd = "xen_cmd"
1581

    
1582
hvXenCpuid :: String
1583
hvXenCpuid = "cpuid"
1584

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

    
1600
-- * Migration statuses
1601

    
1602
hvMigrationActive :: String
1603
hvMigrationActive = "active"
1604

    
1605
hvMigrationCancelled :: String
1606
hvMigrationCancelled = "cancelled"
1607

    
1608
hvMigrationCompleted :: String
1609
hvMigrationCompleted = "completed"
1610

    
1611
hvMigrationFailed :: String
1612
hvMigrationFailed = "failed"
1613

    
1614
hvMigrationValidStatuses :: FrozenSet String
1615
hvMigrationValidStatuses =
1616
  ConstantUtils.mkSet [hvMigrationActive,
1617
                       hvMigrationCancelled,
1618
                       hvMigrationCompleted,
1619
                       hvMigrationFailed]
1620

    
1621
hvMigrationFailedStatuses :: FrozenSet String
1622
hvMigrationFailedStatuses =
1623
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1624

    
1625
-- | KVM-specific statuses
1626
--
1627
-- FIXME: this constant seems unnecessary
1628
hvKvmMigrationValidStatuses :: FrozenSet String
1629
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1630

    
1631
-- | Node info keys
1632
hvNodeinfoKeyVersion :: String
1633
hvNodeinfoKeyVersion = "hv_version"
1634

    
1635
-- * Hypervisor state
1636

    
1637
hvstCpuNode :: String
1638
hvstCpuNode = "cpu_node"
1639

    
1640
hvstCpuTotal :: String
1641
hvstCpuTotal = "cpu_total"
1642

    
1643
hvstMemoryHv :: String
1644
hvstMemoryHv = "mem_hv"
1645

    
1646
hvstMemoryNode :: String
1647
hvstMemoryNode = "mem_node"
1648

    
1649
hvstMemoryTotal :: String
1650
hvstMemoryTotal = "mem_total"
1651

    
1652
hvstsParameters :: FrozenSet String
1653
hvstsParameters =
1654
  ConstantUtils.mkSet [hvstCpuNode,
1655
                       hvstCpuTotal,
1656
                       hvstMemoryHv,
1657
                       hvstMemoryNode,
1658
                       hvstMemoryTotal]
1659

    
1660
hvstDefaults :: Map String Int
1661
hvstDefaults =
1662
  Map.fromList
1663
  [(hvstCpuNode, 1),
1664
   (hvstCpuTotal, 1),
1665
   (hvstMemoryHv, 0),
1666
   (hvstMemoryTotal, 0),
1667
   (hvstMemoryNode, 0)]
1668

    
1669
hvstsParameterTypes :: Map String VType
1670
hvstsParameterTypes =
1671
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1672
                (hvstMemoryNode, VTypeInt),
1673
                (hvstMemoryHv, VTypeInt),
1674
                (hvstCpuTotal, VTypeInt),
1675
                (hvstCpuNode, VTypeInt)]
1676

    
1677
-- * Disk state
1678

    
1679
dsDiskOverhead :: String
1680
dsDiskOverhead = "disk_overhead"
1681

    
1682
dsDiskReserved :: String
1683
dsDiskReserved = "disk_reserved"
1684

    
1685
dsDiskTotal :: String
1686
dsDiskTotal = "disk_total"
1687

    
1688
dsDefaults :: Map String Int
1689
dsDefaults =
1690
  Map.fromList
1691
  [(dsDiskTotal, 0),
1692
   (dsDiskReserved, 0),
1693
   (dsDiskOverhead, 0)]
1694

    
1695
dssParameterTypes :: Map String VType
1696
dssParameterTypes =
1697
  Map.fromList [(dsDiskTotal, VTypeInt),
1698
                (dsDiskReserved, VTypeInt),
1699
                (dsDiskOverhead, VTypeInt)]
1700

    
1701
dssParameters :: FrozenSet String
1702
dssParameters =
1703
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1704

    
1705
dsValidTypes :: FrozenSet String
1706
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1707

    
1708
-- Backend parameter names
1709

    
1710
beAlwaysFailover :: String
1711
beAlwaysFailover = "always_failover"
1712

    
1713
beAutoBalance :: String
1714
beAutoBalance = "auto_balance"
1715

    
1716
beMaxmem :: String
1717
beMaxmem = "maxmem"
1718

    
1719
-- | Deprecated and replaced by max and min mem
1720
beMemory :: String
1721
beMemory = "memory"
1722

    
1723
beMinmem :: String
1724
beMinmem = "minmem"
1725

    
1726
beSpindleUse :: String
1727
beSpindleUse = "spindle_use"
1728

    
1729
beVcpus :: String
1730
beVcpus = "vcpus"
1731

    
1732
besParameterTypes :: Map String VType
1733
besParameterTypes =
1734
  Map.fromList [(beAlwaysFailover, VTypeBool),
1735
                (beAutoBalance, VTypeBool),
1736
                (beMaxmem, VTypeSize),
1737
                (beMinmem, VTypeSize),
1738
                (beSpindleUse, VTypeInt),
1739
                (beVcpus, VTypeInt)]
1740

    
1741
besParameterTitles :: Map String String
1742
besParameterTitles =
1743
  Map.fromList [(beAutoBalance, "Auto_balance"),
1744
                (beMinmem, "ConfigMinMem"),
1745
                (beVcpus, "ConfigVCPUs"),
1746
                (beMaxmem, "ConfigMaxMem")]
1747

    
1748
besParameterCompat :: Map String VType
1749
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1750

    
1751
besParameters :: FrozenSet String
1752
besParameters =
1753
  ConstantUtils.mkSet [beAlwaysFailover,
1754
                       beAutoBalance,
1755
                       beMaxmem,
1756
                       beMinmem,
1757
                       beSpindleUse,
1758
                       beVcpus]
1759

    
1760
-- | Instance specs
1761
--
1762
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1763

    
1764
ispecMemSize :: String
1765
ispecMemSize = ConstantUtils.ispecMemSize
1766

    
1767
ispecCpuCount :: String
1768
ispecCpuCount = ConstantUtils.ispecCpuCount
1769

    
1770
ispecDiskCount :: String
1771
ispecDiskCount = ConstantUtils.ispecDiskCount
1772

    
1773
ispecDiskSize :: String
1774
ispecDiskSize = ConstantUtils.ispecDiskSize
1775

    
1776
ispecNicCount :: String
1777
ispecNicCount = ConstantUtils.ispecNicCount
1778

    
1779
ispecSpindleUse :: String
1780
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1781

    
1782
ispecsParameterTypes :: Map String VType
1783
ispecsParameterTypes =
1784
  Map.fromList
1785
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1786
   (ConstantUtils.ispecCpuCount, VTypeInt),
1787
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1788
   (ConstantUtils.ispecMemSize, VTypeInt),
1789
   (ConstantUtils.ispecNicCount, VTypeInt),
1790
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1791

    
1792
ispecsParameters :: FrozenSet String
1793
ispecsParameters =
1794
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1795
                       ConstantUtils.ispecDiskCount,
1796
                       ConstantUtils.ispecDiskSize,
1797
                       ConstantUtils.ispecMemSize,
1798
                       ConstantUtils.ispecNicCount,
1799
                       ConstantUtils.ispecSpindleUse]
1800

    
1801
ispecsMinmax :: String
1802
ispecsMinmax = ConstantUtils.ispecsMinmax
1803

    
1804
ispecsMax :: String
1805
ispecsMax = "max"
1806

    
1807
ispecsMin :: String
1808
ispecsMin = "min"
1809

    
1810
ispecsStd :: String
1811
ispecsStd = ConstantUtils.ispecsStd
1812

    
1813
ipolicyDts :: String
1814
ipolicyDts = ConstantUtils.ipolicyDts
1815

    
1816
ipolicyVcpuRatio :: String
1817
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1818

    
1819
ipolicySpindleRatio :: String
1820
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
1821

    
1822
ispecsMinmaxKeys :: FrozenSet String
1823
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1824

    
1825
ipolicyParameters :: FrozenSet String
1826
ipolicyParameters =
1827
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1828
                       ConstantUtils.ipolicySpindleRatio]
1829

    
1830
ipolicyAllKeys :: FrozenSet String
1831
ipolicyAllKeys =
1832
  ConstantUtils.union ipolicyParameters $
1833
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1834
                       ConstantUtils.ispecsMinmax,
1835
                       ispecsStd]
1836

    
1837
-- | Node parameter names
1838

    
1839
ndExclusiveStorage :: String
1840
ndExclusiveStorage = "exclusive_storage"
1841

    
1842
ndOobProgram :: String
1843
ndOobProgram = "oob_program"
1844

    
1845
ndSpindleCount :: String
1846
ndSpindleCount = "spindle_count"
1847

    
1848
ndOvs :: String
1849
ndOvs = "ovs"
1850

    
1851
ndOvsLink :: String
1852
ndOvsLink = "ovs_link"
1853

    
1854
ndOvsName :: String
1855
ndOvsName = "ovs_name"
1856

    
1857
ndsParameterTypes :: Map String VType
1858
ndsParameterTypes =
1859
  Map.fromList
1860
  [(ndExclusiveStorage, VTypeBool),
1861
   (ndOobProgram, VTypeString),
1862
   (ndOvs, VTypeBool),
1863
   (ndOvsLink, VTypeMaybeString),
1864
   (ndOvsName, VTypeMaybeString),
1865
   (ndSpindleCount, VTypeInt)]
1866

    
1867
ndsParameters :: FrozenSet String
1868
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
1869

    
1870
ndsParameterTitles :: Map String String
1871
ndsParameterTitles =
1872
  Map.fromList
1873
  [(ndExclusiveStorage, "ExclusiveStorage"),
1874
   (ndOobProgram, "OutOfBandProgram"),
1875
   (ndOvs, "OpenvSwitch"),
1876
   (ndOvsLink, "OpenvSwitchLink"),
1877
   (ndOvsName, "OpenvSwitchName"),
1878
   (ndSpindleCount, "SpindleCount")]
1879

    
1880
-- * Logical Disks parameters
1881

    
1882
ldpAccess :: String
1883
ldpAccess = "access"
1884

    
1885
ldpBarriers :: String
1886
ldpBarriers = "disabled-barriers"
1887

    
1888
ldpDefaultMetavg :: String
1889
ldpDefaultMetavg = "default-metavg"
1890

    
1891
ldpDelayTarget :: String
1892
ldpDelayTarget = "c-delay-target"
1893

    
1894
ldpDiskCustom :: String
1895
ldpDiskCustom = "disk-custom"
1896

    
1897
ldpDynamicResync :: String
1898
ldpDynamicResync = "dynamic-resync"
1899

    
1900
ldpFillTarget :: String
1901
ldpFillTarget = "c-fill-target"
1902

    
1903
ldpMaxRate :: String
1904
ldpMaxRate = "c-max-rate"
1905

    
1906
ldpMinRate :: String
1907
ldpMinRate = "c-min-rate"
1908

    
1909
ldpNetCustom :: String
1910
ldpNetCustom = "net-custom"
1911

    
1912
ldpNoMetaFlush :: String
1913
ldpNoMetaFlush = "disable-meta-flush"
1914

    
1915
ldpPlanAhead :: String
1916
ldpPlanAhead = "c-plan-ahead"
1917

    
1918
ldpPool :: String
1919
ldpPool = "pool"
1920

    
1921
ldpProtocol :: String
1922
ldpProtocol = "protocol"
1923

    
1924
ldpResyncRate :: String
1925
ldpResyncRate = "resync-rate"
1926

    
1927
ldpStripes :: String
1928
ldpStripes = "stripes"
1929

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

    
1950
diskLdParameters :: FrozenSet String
1951
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
1952

    
1953
-- * Disk template parameters
1954
--
1955
-- Disk template parameters can be set/changed by the user via
1956
-- gnt-cluster and gnt-group)
1957

    
1958
drbdResyncRate :: String
1959
drbdResyncRate = "resync-rate"
1960

    
1961
drbdDataStripes :: String
1962
drbdDataStripes = "data-stripes"
1963

    
1964
drbdMetaStripes :: String
1965
drbdMetaStripes = "meta-stripes"
1966

    
1967
drbdDiskBarriers :: String
1968
drbdDiskBarriers = "disk-barriers"
1969

    
1970
drbdMetaBarriers :: String
1971
drbdMetaBarriers = "meta-barriers"
1972

    
1973
drbdDefaultMetavg :: String
1974
drbdDefaultMetavg = "metavg"
1975

    
1976
drbdDiskCustom :: String
1977
drbdDiskCustom = "disk-custom"
1978

    
1979
drbdNetCustom :: String
1980
drbdNetCustom = "net-custom"
1981

    
1982
drbdProtocol :: String
1983
drbdProtocol = "protocol"
1984

    
1985
drbdDynamicResync :: String
1986
drbdDynamicResync = "dynamic-resync"
1987

    
1988
drbdPlanAhead :: String
1989
drbdPlanAhead = "c-plan-ahead"
1990

    
1991
drbdFillTarget :: String
1992
drbdFillTarget = "c-fill-target"
1993

    
1994
drbdDelayTarget :: String
1995
drbdDelayTarget = "c-delay-target"
1996

    
1997
drbdMaxRate :: String
1998
drbdMaxRate = "c-max-rate"
1999

    
2000
drbdMinRate :: String
2001
drbdMinRate = "c-min-rate"
2002

    
2003
lvStripes :: String
2004
lvStripes = "stripes"
2005

    
2006
rbdAccess :: String
2007
rbdAccess = "access"
2008

    
2009
rbdPool :: String
2010
rbdPool = "pool"
2011

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

    
2033
diskDtParameters :: FrozenSet String
2034
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2035

    
2036
-- * Dynamic disk parameters
2037

    
2038
ddpLocalIp :: String
2039
ddpLocalIp = "local-ip"
2040

    
2041
ddpRemoteIp :: String
2042
ddpRemoteIp = "remote-ip"
2043

    
2044
ddpPort :: String
2045
ddpPort = "port"
2046

    
2047
ddpLocalMinor :: String
2048
ddpLocalMinor = "local-minor"
2049

    
2050
ddpRemoteMinor :: String
2051
ddpRemoteMinor = "remote-minor"
2052

    
2053
-- * OOB supported commands
2054

    
2055
oobPowerOn :: String
2056
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2057

    
2058
oobPowerOff :: String
2059
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2060

    
2061
oobPowerCycle :: String
2062
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2063

    
2064
oobPowerStatus :: String
2065
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2066

    
2067
oobHealth :: String
2068
oobHealth = Types.oobCommandToRaw OobHealth
2069

    
2070
oobCommands :: FrozenSet String
2071
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2072

    
2073
oobPowerStatusPowered :: String
2074
oobPowerStatusPowered = "powered"
2075

    
2076
-- | 60 seconds
2077
oobTimeout :: Int
2078
oobTimeout = 60
2079

    
2080
-- | 2 seconds
2081
oobPowerDelay :: Double
2082
oobPowerDelay = 2.0
2083

    
2084
oobStatusCritical :: String
2085
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2086

    
2087
oobStatusOk :: String
2088
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2089

    
2090
oobStatusUnknown :: String
2091
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2092

    
2093
oobStatusWarning :: String
2094
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2095

    
2096
oobStatuses :: FrozenSet String
2097
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2098

    
2099
-- | Instance Parameters Profile
2100
ppDefault :: String
2101
ppDefault = "default"
2102

    
2103
-- * nic* constants are used inside the ganeti config
2104

    
2105
nicLink :: String
2106
nicLink = "link"
2107

    
2108
nicMode :: String
2109
nicMode = "mode"
2110

    
2111
nicVlan :: String
2112
nicVlan = "vlan"
2113

    
2114
nicsParameterTypes :: Map String VType
2115
nicsParameterTypes =
2116
  Map.fromList [(nicMode, vtypeString),
2117
                (nicLink, vtypeString),
2118
                (nicVlan, vtypeMaybeString)]
2119

    
2120
nicsParameters :: FrozenSet String
2121
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2122

    
2123
nicModeBridged :: String
2124
nicModeBridged = Types.nICModeToRaw NMBridged
2125

    
2126
nicModeRouted :: String
2127
nicModeRouted = Types.nICModeToRaw NMRouted
2128

    
2129
nicModeOvs :: String
2130
nicModeOvs = Types.nICModeToRaw NMOvs
2131

    
2132
nicIpPool :: String
2133
nicIpPool = Types.nICModeToRaw NMPool
2134

    
2135
nicValidModes :: FrozenSet String
2136
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2137

    
2138
releaseAction :: String
2139
releaseAction = "release"
2140

    
2141
reserveAction :: String
2142
reserveAction = "reserve"
2143

    
2144
-- * idisk* constants are used in opcodes, to create/change disks
2145

    
2146
idiskAdopt :: String
2147
idiskAdopt = "adopt"
2148

    
2149
idiskMetavg :: String
2150
idiskMetavg = "metavg"
2151

    
2152
idiskMode :: String
2153
idiskMode = "mode"
2154

    
2155
idiskName :: String
2156
idiskName = "name"
2157

    
2158
idiskSize :: String
2159
idiskSize = "size"
2160

    
2161
idiskSpindles :: String
2162
idiskSpindles = "spindles"
2163

    
2164
idiskVg :: String
2165
idiskVg = "vg"
2166

    
2167
idiskProvider :: String
2168
idiskProvider = "provider"
2169

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

    
2181
idiskParams :: FrozenSet String
2182
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2183

    
2184
-- * inic* constants are used in opcodes, to create/change nics
2185

    
2186
inicBridge :: String
2187
inicBridge = "bridge"
2188

    
2189
inicIp :: String
2190
inicIp = "ip"
2191

    
2192
inicLink :: String
2193
inicLink = "link"
2194

    
2195
inicMac :: String
2196
inicMac = "mac"
2197

    
2198
inicMode :: String
2199
inicMode = "mode"
2200

    
2201
inicName :: String
2202
inicName = "name"
2203

    
2204
inicNetwork :: String
2205
inicNetwork = "network"
2206

    
2207
inicVlan :: String
2208
inicVlan = "vlan"
2209

    
2210
inicParamsTypes :: Map String VType
2211
inicParamsTypes =
2212
  Map.fromList [(inicBridge, VTypeMaybeString),
2213
                (inicIp, VTypeMaybeString),
2214
                (inicLink, VTypeString),
2215
                (inicMac, VTypeString),
2216
                (inicMode, VTypeString),
2217
                (inicName, VTypeMaybeString),
2218
                (inicNetwork, VTypeMaybeString),
2219
                (inicVlan, VTypeMaybeString)]
2220

    
2221
inicParams :: FrozenSet String
2222
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2223

    
2224
-- * Hypervisor constants
2225

    
2226
htXenPvm :: String
2227
htXenPvm = Types.hypervisorToRaw XenPvm
2228

    
2229
htFake :: String
2230
htFake = Types.hypervisorToRaw Fake
2231

    
2232
htXenHvm :: String
2233
htXenHvm = Types.hypervisorToRaw XenHvm
2234

    
2235
htKvm :: String
2236
htKvm = Types.hypervisorToRaw Kvm
2237

    
2238
htChroot :: String
2239
htChroot = Types.hypervisorToRaw Chroot
2240

    
2241
htLxc :: String
2242
htLxc = Types.hypervisorToRaw Lxc
2243

    
2244
hyperTypes :: FrozenSet String
2245
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2246

    
2247
htsReqPort :: FrozenSet String
2248
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2249

    
2250
vncBasePort :: Int
2251
vncBasePort = 5900
2252

    
2253
vncDefaultBindAddress :: String
2254
vncDefaultBindAddress = ip4AddressAny
2255

    
2256
-- * NIC types
2257

    
2258
htNicE1000 :: String
2259
htNicE1000 = "e1000"
2260

    
2261
htNicI82551 :: String
2262
htNicI82551 = "i82551"
2263

    
2264
htNicI8259er :: String
2265
htNicI8259er = "i82559er"
2266

    
2267
htNicI85557b :: String
2268
htNicI85557b = "i82557b"
2269

    
2270
htNicNe2kIsa :: String
2271
htNicNe2kIsa = "ne2k_isa"
2272

    
2273
htNicNe2kPci :: String
2274
htNicNe2kPci = "ne2k_pci"
2275

    
2276
htNicParavirtual :: String
2277
htNicParavirtual = "paravirtual"
2278

    
2279
htNicPcnet :: String
2280
htNicPcnet = "pcnet"
2281

    
2282
htNicRtl8139 :: String
2283
htNicRtl8139 = "rtl8139"
2284

    
2285
htHvmValidNicTypes :: FrozenSet String
2286
htHvmValidNicTypes =
2287
  ConstantUtils.mkSet [htNicE1000,
2288
                       htNicNe2kIsa,
2289
                       htNicNe2kPci,
2290
                       htNicParavirtual,
2291
                       htNicRtl8139]
2292

    
2293
htKvmValidNicTypes :: FrozenSet String
2294
htKvmValidNicTypes =
2295
  ConstantUtils.mkSet [htNicE1000,
2296
                       htNicI82551,
2297
                       htNicI8259er,
2298
                       htNicI85557b,
2299
                       htNicNe2kIsa,
2300
                       htNicNe2kPci,
2301
                       htNicParavirtual,
2302
                       htNicPcnet,
2303
                       htNicRtl8139]
2304

    
2305
-- * Vif types
2306

    
2307
-- | Default vif type in xen-hvm
2308
htHvmVifIoemu :: String
2309
htHvmVifIoemu = "ioemu"
2310

    
2311
htHvmVifVif :: String
2312
htHvmVifVif = "vif"
2313

    
2314
htHvmValidVifTypes :: FrozenSet String
2315
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2316

    
2317
-- * Disk types
2318

    
2319
htDiskIde :: String
2320
htDiskIde = "ide"
2321

    
2322
htDiskIoemu :: String
2323
htDiskIoemu = "ioemu"
2324

    
2325
htDiskMtd :: String
2326
htDiskMtd = "mtd"
2327

    
2328
htDiskParavirtual :: String
2329
htDiskParavirtual = "paravirtual"
2330

    
2331
htDiskPflash :: String
2332
htDiskPflash = "pflash"
2333

    
2334
htDiskScsi :: String
2335
htDiskScsi = "scsi"
2336

    
2337
htDiskSd :: String
2338
htDiskSd = "sd"
2339

    
2340
htHvmValidDiskTypes :: FrozenSet String
2341
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2342

    
2343
htKvmValidDiskTypes :: FrozenSet String
2344
htKvmValidDiskTypes =
2345
  ConstantUtils.mkSet [htDiskIde,
2346
                       htDiskMtd,
2347
                       htDiskParavirtual,
2348
                       htDiskPflash,
2349
                       htDiskScsi,
2350
                       htDiskSd]
2351

    
2352
htCacheDefault :: String
2353
htCacheDefault = "default"
2354

    
2355
htCacheNone :: String
2356
htCacheNone = "none"
2357

    
2358
htCacheWback :: String
2359
htCacheWback = "writeback"
2360

    
2361
htCacheWthrough :: String
2362
htCacheWthrough = "writethrough"
2363

    
2364
htValidCacheTypes :: FrozenSet String
2365
htValidCacheTypes =
2366
  ConstantUtils.mkSet [htCacheDefault,
2367
                       htCacheNone,
2368
                       htCacheWback,
2369
                       htCacheWthrough]
2370

    
2371
-- * Mouse types
2372

    
2373
htMouseMouse :: String
2374
htMouseMouse = "mouse"
2375

    
2376
htMouseTablet :: String
2377
htMouseTablet = "tablet"
2378

    
2379
htKvmValidMouseTypes :: FrozenSet String
2380
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2381

    
2382
-- * Boot order
2383

    
2384
htBoCdrom :: String
2385
htBoCdrom = "cdrom"
2386

    
2387
htBoDisk :: String
2388
htBoDisk = "disk"
2389

    
2390
htBoFloppy :: String
2391
htBoFloppy = "floppy"
2392

    
2393
htBoNetwork :: String
2394
htBoNetwork = "network"
2395

    
2396
htKvmValidBoTypes :: FrozenSet String
2397
htKvmValidBoTypes =
2398
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2399

    
2400
-- * SPICE lossless image compression options
2401

    
2402
htKvmSpiceLosslessImgComprAutoGlz :: String
2403
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2404

    
2405
htKvmSpiceLosslessImgComprAutoLz :: String
2406
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2407

    
2408
htKvmSpiceLosslessImgComprGlz :: String
2409
htKvmSpiceLosslessImgComprGlz = "glz"
2410

    
2411
htKvmSpiceLosslessImgComprLz :: String
2412
htKvmSpiceLosslessImgComprLz = "lz"
2413

    
2414
htKvmSpiceLosslessImgComprOff :: String
2415
htKvmSpiceLosslessImgComprOff = "off"
2416

    
2417
htKvmSpiceLosslessImgComprQuic :: String
2418
htKvmSpiceLosslessImgComprQuic = "quic"
2419

    
2420
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2421
htKvmSpiceValidLosslessImgComprOptions =
2422
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2423
                       htKvmSpiceLosslessImgComprAutoLz,
2424
                       htKvmSpiceLosslessImgComprGlz,
2425
                       htKvmSpiceLosslessImgComprLz,
2426
                       htKvmSpiceLosslessImgComprOff,
2427
                       htKvmSpiceLosslessImgComprQuic]
2428

    
2429
htKvmSpiceLossyImgComprAlways :: String
2430
htKvmSpiceLossyImgComprAlways = "always"
2431

    
2432
htKvmSpiceLossyImgComprAuto :: String
2433
htKvmSpiceLossyImgComprAuto = "auto"
2434

    
2435
htKvmSpiceLossyImgComprNever :: String
2436
htKvmSpiceLossyImgComprNever = "never"
2437

    
2438
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2439
htKvmSpiceValidLossyImgComprOptions =
2440
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2441
                       htKvmSpiceLossyImgComprAuto,
2442
                       htKvmSpiceLossyImgComprNever]
2443

    
2444
-- * SPICE video stream detection
2445

    
2446
htKvmSpiceVideoStreamDetectionAll :: String
2447
htKvmSpiceVideoStreamDetectionAll = "all"
2448

    
2449
htKvmSpiceVideoStreamDetectionFilter :: String
2450
htKvmSpiceVideoStreamDetectionFilter = "filter"
2451

    
2452
htKvmSpiceVideoStreamDetectionOff :: String
2453
htKvmSpiceVideoStreamDetectionOff = "off"
2454

    
2455
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2456
htKvmSpiceValidVideoStreamDetectionOptions =
2457
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2458
                       htKvmSpiceVideoStreamDetectionFilter,
2459
                       htKvmSpiceVideoStreamDetectionOff]
2460

    
2461
-- * Security models
2462

    
2463
htSmNone :: String
2464
htSmNone = "none"
2465

    
2466
htSmPool :: String
2467
htSmPool = "pool"
2468

    
2469
htSmUser :: String
2470
htSmUser = "user"
2471

    
2472
htKvmValidSmTypes :: FrozenSet String
2473
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2474

    
2475
-- * Kvm flag values
2476

    
2477
htKvmDisabled :: String
2478
htKvmDisabled = "disabled"
2479

    
2480
htKvmEnabled :: String
2481
htKvmEnabled = "enabled"
2482

    
2483
htKvmFlagValues :: FrozenSet String
2484
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2485

    
2486
-- * Migration type
2487

    
2488
htMigrationLive :: String
2489
htMigrationLive = Types.migrationModeToRaw MigrationLive
2490

    
2491
htMigrationNonlive :: String
2492
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2493

    
2494
htMigrationModes :: FrozenSet String
2495
htMigrationModes =
2496
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2497

    
2498
-- * Cluster verify steps
2499

    
2500
verifyNplusoneMem :: String
2501
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2502

    
2503
verifyOptionalChecks :: FrozenSet String
2504
verifyOptionalChecks =
2505
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2506

    
2507
-- * Cluster Verify error classes
2508

    
2509
cvTcluster :: String
2510
cvTcluster = "cluster"
2511

    
2512
cvTgroup :: String
2513
cvTgroup = "group"
2514

    
2515
cvTnode :: String
2516
cvTnode = "node"
2517

    
2518
cvTinstance :: String
2519
cvTinstance = "instance"
2520

    
2521
-- * Cluster Verify error codes and documentation
2522

    
2523
cvEclustercert :: (String, String, String)
2524
cvEclustercert =
2525
  ("cluster",
2526
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2527
   "Cluster certificate files verification failure")
2528

    
2529
cvEclustercfg :: (String, String, String)
2530
cvEclustercfg =
2531
  ("cluster",
2532
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2533
   "Cluster configuration verification failure")
2534

    
2535
cvEclusterdanglinginst :: (String, String, String)
2536
cvEclusterdanglinginst =
2537
  ("node",
2538
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2539
   "Some instances have a non-existing primary node")
2540

    
2541
cvEclusterdanglingnodes :: (String, String, String)
2542
cvEclusterdanglingnodes =
2543
  ("node",
2544
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2545
   "Some nodes belong to non-existing groups")
2546

    
2547
cvEclusterfilecheck :: (String, String, String)
2548
cvEclusterfilecheck =
2549
  ("cluster",
2550
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2551
   "Cluster configuration verification failure")
2552

    
2553
cvEgroupdifferentpvsize :: (String, String, String)
2554
cvEgroupdifferentpvsize =
2555
  ("group",
2556
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2557
   "PVs in the group have different sizes")
2558

    
2559
cvEinstancebadnode :: (String, String, String)
2560
cvEinstancebadnode =
2561
  ("instance",
2562
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2563
   "Instance marked as running lives on an offline node")
2564

    
2565
cvEinstancedown :: (String, String, String)
2566
cvEinstancedown =
2567
  ("instance",
2568
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2569
   "Instance not running on its primary node")
2570

    
2571
cvEinstancefaultydisk :: (String, String, String)
2572
cvEinstancefaultydisk =
2573
  ("instance",
2574
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2575
   "Impossible to retrieve status for a disk")
2576

    
2577
cvEinstancelayout :: (String, String, String)
2578
cvEinstancelayout =
2579
  ("instance",
2580
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2581
   "Instance has multiple secondary nodes")
2582

    
2583
cvEinstancemissingcfgparameter :: (String, String, String)
2584
cvEinstancemissingcfgparameter =
2585
  ("instance",
2586
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2587
   "A configuration parameter for an instance is missing")
2588

    
2589
cvEinstancemissingdisk :: (String, String, String)
2590
cvEinstancemissingdisk =
2591
  ("instance",
2592
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2593
   "Missing volume on an instance")
2594

    
2595
cvEinstancepolicy :: (String, String, String)
2596
cvEinstancepolicy =
2597
  ("instance",
2598
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2599
   "Instance does not meet policy")
2600

    
2601
cvEinstancesplitgroups :: (String, String, String)
2602
cvEinstancesplitgroups =
2603
  ("instance",
2604
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2605
   "Instance with primary and secondary nodes in different groups")
2606

    
2607
cvEinstanceunsuitablenode :: (String, String, String)
2608
cvEinstanceunsuitablenode =
2609
  ("instance",
2610
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2611
   "Instance running on nodes that are not suitable for it")
2612

    
2613
cvEinstancewrongnode :: (String, String, String)
2614
cvEinstancewrongnode =
2615
  ("instance",
2616
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2617
   "Instance running on the wrong node")
2618

    
2619
cvEnodedrbd :: (String, String, String)
2620
cvEnodedrbd =
2621
  ("node",
2622
   Types.cVErrorCodeToRaw CvENODEDRBD,
2623
   "Error parsing the DRBD status file")
2624

    
2625
cvEnodedrbdhelper :: (String, String, String)
2626
cvEnodedrbdhelper =
2627
  ("node",
2628
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2629
   "Error caused by the DRBD helper")
2630

    
2631
cvEnodedrbdversion :: (String, String, String)
2632
cvEnodedrbdversion =
2633
  ("node",
2634
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2635
   "DRBD version mismatch within a node group")
2636

    
2637
cvEnodefilecheck :: (String, String, String)
2638
cvEnodefilecheck =
2639
  ("node",
2640
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2641
   "Error retrieving the checksum of the node files")
2642

    
2643
cvEnodefilestoragepaths :: (String, String, String)
2644
cvEnodefilestoragepaths =
2645
  ("node",
2646
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2647
   "Detected bad file storage paths")
2648

    
2649
cvEnodefilestoragepathunusable :: (String, String, String)
2650
cvEnodefilestoragepathunusable =
2651
  ("node",
2652
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2653
   "File storage path unusable")
2654

    
2655
cvEnodehooks :: (String, String, String)
2656
cvEnodehooks =
2657
  ("node",
2658
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2659
   "Communication failure in hooks execution")
2660

    
2661
cvEnodehv :: (String, String, String)
2662
cvEnodehv =
2663
  ("node",
2664
   Types.cVErrorCodeToRaw CvENODEHV,
2665
   "Hypervisor parameters verification failure")
2666

    
2667
cvEnodelvm :: (String, String, String)
2668
cvEnodelvm =
2669
  ("node",
2670
   Types.cVErrorCodeToRaw CvENODELVM,
2671
   "LVM-related node error")
2672

    
2673
cvEnoden1 :: (String, String, String)
2674
cvEnoden1 =
2675
  ("node",
2676
   Types.cVErrorCodeToRaw CvENODEN1,
2677
   "Not enough memory to accommodate instance failovers")
2678

    
2679
cvEnodenet :: (String, String, String)
2680
cvEnodenet =
2681
  ("node",
2682
   Types.cVErrorCodeToRaw CvENODENET,
2683
   "Network-related node error")
2684

    
2685
cvEnodeoobpath :: (String, String, String)
2686
cvEnodeoobpath =
2687
  ("node",
2688
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2689
   "Invalid Out Of Band path")
2690

    
2691
cvEnodeorphaninstance :: (String, String, String)
2692
cvEnodeorphaninstance =
2693
  ("node",
2694
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2695
   "Unknown intance running on a node")
2696

    
2697
cvEnodeorphanlv :: (String, String, String)
2698
cvEnodeorphanlv =
2699
  ("node",
2700
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2701
   "Unknown LVM logical volume")
2702

    
2703
cvEnodeos :: (String, String, String)
2704
cvEnodeos =
2705
  ("node",
2706
   Types.cVErrorCodeToRaw CvENODEOS,
2707
   "OS-related node error")
2708

    
2709
cvEnoderpc :: (String, String, String)
2710
cvEnoderpc =
2711
  ("node",
2712
   Types.cVErrorCodeToRaw CvENODERPC,
2713
   "Error during connection to the primary node of an instance")
2714

    
2715
cvEnodesetup :: (String, String, String)
2716
cvEnodesetup =
2717
  ("node",
2718
   Types.cVErrorCodeToRaw CvENODESETUP,
2719
   "Node setup error")
2720

    
2721
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2722
cvEnodesharedfilestoragepathunusable =
2723
  ("node",
2724
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2725
   "Shared file storage path unusable")
2726

    
2727
cvEnodessh :: (String, String, String)
2728
cvEnodessh =
2729
  ("node",
2730
   Types.cVErrorCodeToRaw CvENODESSH,
2731
   "SSH-related node error")
2732

    
2733
cvEnodetime :: (String, String, String)
2734
cvEnodetime =
2735
  ("node",
2736
   Types.cVErrorCodeToRaw CvENODETIME,
2737
   "Node returned invalid time")
2738

    
2739
cvEnodeuserscripts :: (String, String, String)
2740
cvEnodeuserscripts =
2741
  ("node",
2742
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2743
   "User scripts not present or not executable")
2744

    
2745
cvEnodeversion :: (String, String, String)
2746
cvEnodeversion =
2747
  ("node",
2748
   Types.cVErrorCodeToRaw CvENODEVERSION,
2749
   "Protocol version mismatch or Ganeti version mismatch")
2750

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

    
2793
cvAllEcodesStrings :: FrozenSet String
2794
cvAllEcodesStrings =
2795
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2796

    
2797
-- * Node verify constants
2798

    
2799
nvBridges :: String
2800
nvBridges = "bridges"
2801

    
2802
nvDrbdhelper :: String
2803
nvDrbdhelper = "drbd-helper"
2804

    
2805
nvDrbdversion :: String
2806
nvDrbdversion = "drbd-version"
2807

    
2808
nvDrbdlist :: String
2809
nvDrbdlist = "drbd-list"
2810

    
2811
nvExclusivepvs :: String
2812
nvExclusivepvs = "exclusive-pvs"
2813

    
2814
nvFilelist :: String
2815
nvFilelist = "filelist"
2816

    
2817
nvAcceptedStoragePaths :: String
2818
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2819

    
2820
nvFileStoragePath :: String
2821
nvFileStoragePath = "file-storage-path"
2822

    
2823
nvSharedFileStoragePath :: String
2824
nvSharedFileStoragePath = "shared-file-storage-path"
2825

    
2826
nvHvinfo :: String
2827
nvHvinfo = "hvinfo"
2828

    
2829
nvHvparams :: String
2830
nvHvparams = "hvparms"
2831

    
2832
nvHypervisor :: String
2833
nvHypervisor = "hypervisor"
2834

    
2835
nvInstancelist :: String
2836
nvInstancelist = "instancelist"
2837

    
2838
nvLvlist :: String
2839
nvLvlist = "lvlist"
2840

    
2841
nvMasterip :: String
2842
nvMasterip = "master-ip"
2843

    
2844
nvNodelist :: String
2845
nvNodelist = "nodelist"
2846

    
2847
nvNodenettest :: String
2848
nvNodenettest = "node-net-test"
2849

    
2850
nvNodesetup :: String
2851
nvNodesetup = "nodesetup"
2852

    
2853
nvOobPaths :: String
2854
nvOobPaths = "oob-paths"
2855

    
2856
nvOslist :: String
2857
nvOslist = "oslist"
2858

    
2859
nvPvlist :: String
2860
nvPvlist = "pvlist"
2861

    
2862
nvTime :: String
2863
nvTime = "time"
2864

    
2865
nvUserscripts :: String
2866
nvUserscripts = "user-scripts"
2867

    
2868
nvVersion :: String
2869
nvVersion = "version"
2870

    
2871
nvVglist :: String
2872
nvVglist = "vglist"
2873

    
2874
nvVmnodes :: String
2875
nvVmnodes = "vmnodes"
2876

    
2877
-- * Instance status
2878

    
2879
inststAdmindown :: String
2880
inststAdmindown = Types.instanceStatusToRaw StatusDown
2881

    
2882
inststAdminoffline :: String
2883
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
2884

    
2885
inststErrordown :: String
2886
inststErrordown = Types.instanceStatusToRaw ErrorDown
2887

    
2888
inststErrorup :: String
2889
inststErrorup = Types.instanceStatusToRaw ErrorUp
2890

    
2891
inststNodedown :: String
2892
inststNodedown = Types.instanceStatusToRaw NodeDown
2893

    
2894
inststNodeoffline :: String
2895
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
2896

    
2897
inststRunning :: String
2898
inststRunning = Types.instanceStatusToRaw Running
2899

    
2900
inststWrongnode :: String
2901
inststWrongnode = Types.instanceStatusToRaw WrongNode
2902

    
2903
inststAll :: FrozenSet String
2904
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
2905

    
2906
-- * Admin states
2907

    
2908
adminstDown :: String
2909
adminstDown = Types.adminStateToRaw AdminDown
2910

    
2911
adminstOffline :: String
2912
adminstOffline = Types.adminStateToRaw AdminOffline
2913

    
2914
adminstUp :: String
2915
adminstUp = Types.adminStateToRaw AdminUp
2916

    
2917
adminstAll :: FrozenSet String
2918
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
2919

    
2920
-- * Node roles
2921

    
2922
nrDrained :: String
2923
nrDrained = Types.nodeRoleToRaw NRDrained
2924

    
2925
nrMaster :: String
2926
nrMaster = Types.nodeRoleToRaw NRMaster
2927

    
2928
nrMcandidate :: String
2929
nrMcandidate = Types.nodeRoleToRaw NRCandidate
2930

    
2931
nrOffline :: String
2932
nrOffline = Types.nodeRoleToRaw NROffline
2933

    
2934
nrRegular :: String
2935
nrRegular = Types.nodeRoleToRaw NRRegular
2936

    
2937
nrAll :: FrozenSet String
2938
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
2939

    
2940
-- * SSL certificate check constants (in days)
2941

    
2942
sslCertExpirationError :: Int
2943
sslCertExpirationError = 7
2944

    
2945
sslCertExpirationWarn :: Int
2946
sslCertExpirationWarn = 30
2947

    
2948
-- * Allocator framework constants
2949

    
2950
iallocatorVersion :: Int
2951
iallocatorVersion = 2
2952

    
2953
iallocatorDirIn :: String
2954
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
2955

    
2956
iallocatorDirOut :: String
2957
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
2958

    
2959
validIallocatorDirections :: FrozenSet String
2960
validIallocatorDirections =
2961
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
2962

    
2963
iallocatorModeAlloc :: String
2964
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
2965

    
2966
iallocatorModeChgGroup :: String
2967
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
2968

    
2969
iallocatorModeMultiAlloc :: String
2970
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
2971

    
2972
iallocatorModeNodeEvac :: String
2973
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
2974

    
2975
iallocatorModeReloc :: String
2976
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
2977

    
2978
validIallocatorModes :: FrozenSet String
2979
validIallocatorModes =
2980
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
2981

    
2982
iallocatorSearchPath :: [String]
2983
iallocatorSearchPath = AutoConf.iallocatorSearchPath
2984

    
2985
defaultIallocatorShortcut :: String
2986
defaultIallocatorShortcut = "."
2987

    
2988
-- * Node evacuation
2989

    
2990
nodeEvacPri :: String
2991
nodeEvacPri = Types.evacModeToRaw ChangePrimary
2992

    
2993
nodeEvacSec :: String
2994
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
2995

    
2996
nodeEvacAll :: String
2997
nodeEvacAll = Types.evacModeToRaw ChangeAll
2998

    
2999
nodeEvacModes :: FrozenSet String
3000
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3001

    
3002
-- * Job queue
3003

    
3004
jobQueueVersion :: Int
3005
jobQueueVersion = 1
3006

    
3007
jobQueueSizeHardLimit :: Int
3008
jobQueueSizeHardLimit = 5000
3009

    
3010
jobQueueFilesPerms :: Int
3011
jobQueueFilesPerms = 0o640
3012

    
3013
-- * Unchanged job return
3014

    
3015
jobNotchanged :: String
3016
jobNotchanged = "nochange"
3017

    
3018
-- * Job status
3019

    
3020
jobStatusQueued :: String
3021
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3022

    
3023
jobStatusWaiting :: String
3024
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3025

    
3026
jobStatusCanceling :: String
3027
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3028

    
3029
jobStatusRunning :: String
3030
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3031

    
3032
jobStatusCanceled :: String
3033
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3034

    
3035
jobStatusSuccess :: String
3036
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3037

    
3038
jobStatusError :: String
3039
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3040

    
3041
jobsPending :: FrozenSet String
3042
jobsPending =
3043
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3044

    
3045
jobsFinalized :: FrozenSet String
3046
jobsFinalized =
3047
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3048

    
3049
jobStatusAll :: FrozenSet String
3050
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3051

    
3052
-- * OpCode status
3053

    
3054
-- ** Not yet finalized opcodes
3055

    
3056
opStatusCanceling :: String
3057
opStatusCanceling = "canceling"
3058

    
3059
opStatusQueued :: String
3060
opStatusQueued = "queued"
3061

    
3062
opStatusRunning :: String
3063
opStatusRunning = "running"
3064

    
3065
opStatusWaiting :: String
3066
opStatusWaiting = "waiting"
3067

    
3068
-- ** Finalized opcodes
3069

    
3070
opStatusCanceled :: String
3071
opStatusCanceled = "canceled"
3072

    
3073
opStatusError :: String
3074
opStatusError = "error"
3075

    
3076
opStatusSuccess :: String
3077
opStatusSuccess = "success"
3078

    
3079
opsFinalized :: FrozenSet String
3080
opsFinalized =
3081
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3082

    
3083
-- * OpCode priority
3084

    
3085
opPrioLowest :: Int
3086
opPrioLowest = 19
3087

    
3088
opPrioHighest :: Int
3089
opPrioHighest = -20
3090

    
3091
opPrioLow :: Int
3092
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3093

    
3094
opPrioNormal :: Int
3095
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3096

    
3097
opPrioHigh :: Int
3098
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3099

    
3100
opPrioSubmitValid :: FrozenSet Int
3101
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3102

    
3103
opPrioDefault :: Int
3104
opPrioDefault = opPrioNormal
3105

    
3106
-- * Lock recalculate mode
3107

    
3108
locksAppend :: String
3109
locksAppend = "append"
3110

    
3111
locksReplace :: String
3112
locksReplace = "replace"
3113

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

    
3121
lockAttemptsMaxwait :: Double
3122
lockAttemptsMaxwait = 15.0
3123

    
3124
lockAttemptsMinwait :: Double
3125
lockAttemptsMinwait = 1.0
3126

    
3127
lockAttemptsTimeout :: Int
3128
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3129

    
3130
-- * Execution log types
3131

    
3132
elogMessage :: String
3133
elogMessage = Types.eLogTypeToRaw ELogMessage
3134

    
3135
elogRemoteImport :: String
3136
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3137

    
3138
elogJqueueTest :: String
3139
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3140

    
3141
-- * /etc/hosts modification
3142

    
3143
etcHostsAdd :: String
3144
etcHostsAdd = "add"
3145

    
3146
etcHostsRemove :: String
3147
etcHostsRemove = "remove"
3148

    
3149
-- * Job queue test
3150

    
3151
jqtMsgprefix :: String
3152
jqtMsgprefix = "TESTMSG="
3153

    
3154
jqtExec :: String
3155
jqtExec = "exec"
3156

    
3157
jqtExpandnames :: String
3158
jqtExpandnames = "expandnames"
3159

    
3160
jqtLogmsg :: String
3161
jqtLogmsg = "logmsg"
3162

    
3163
jqtStartmsg :: String
3164
jqtStartmsg = "startmsg"
3165

    
3166
jqtAll :: FrozenSet String
3167
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3168

    
3169
-- * Query resources
3170

    
3171
qrCluster :: String
3172
qrCluster = "cluster"
3173

    
3174
qrExport :: String
3175
qrExport = "export"
3176

    
3177
qrExtstorage :: String
3178
qrExtstorage = "extstorage"
3179

    
3180
qrGroup :: String
3181
qrGroup = "group"
3182

    
3183
qrInstance :: String
3184
qrInstance = "instance"
3185

    
3186
qrJob :: String
3187
qrJob = "job"
3188

    
3189
qrLock :: String
3190
qrLock = "lock"
3191

    
3192
qrNetwork :: String
3193
qrNetwork = "network"
3194

    
3195
qrNode :: String
3196
qrNode = "node"
3197

    
3198
qrOs :: String
3199
qrOs = "os"
3200

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

    
3213
-- | List of resources which can be queried using Local UniX Interface
3214
qrViaLuxi :: FrozenSet String
3215
qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob]
3216

    
3217
-- | List of resources which can be queried using RAPI
3218
qrViaRapi :: FrozenSet String
3219
qrViaRapi = qrViaLuxi
3220

    
3221
-- * Query field types
3222

    
3223
qftBool :: String
3224
qftBool = "bool"
3225

    
3226
qftNumber :: String
3227
qftNumber = "number"
3228

    
3229
qftOther :: String
3230
qftOther = "other"
3231

    
3232
qftText :: String
3233
qftText = "text"
3234

    
3235
qftTimestamp :: String
3236
qftTimestamp = "timestamp"
3237

    
3238
qftUnit :: String
3239
qftUnit = "unit"
3240

    
3241
qftUnknown :: String
3242
qftUnknown = "unknown"
3243

    
3244
qftAll :: FrozenSet String
3245
qftAll =
3246
  ConstantUtils.mkSet [qftBool,
3247
                       qftNumber,
3248
                       qftOther,
3249
                       qftText,
3250
                       qftTimestamp,
3251
                       qftUnit,
3252
                       qftUnknown]
3253

    
3254
-- * Query result field status
3255
--
3256
-- Don't change or reuse values as they're used by clients.
3257
--
3258
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3259

    
3260
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3261
rsNodata :: Int
3262
rsNodata = 2
3263

    
3264
rsNormal :: Int
3265
rsNormal = 0
3266

    
3267
-- | Resource marked offline
3268
rsOffline :: Int
3269
rsOffline = 4
3270

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

    
3277
rsUnknown :: Int
3278
rsUnknown = 1
3279

    
3280
rsAll :: FrozenSet Int
3281
rsAll =
3282
  ConstantUtils.mkSet [rsNodata,
3283
                       rsNormal,
3284
                       rsOffline,
3285
                       rsUnavail,
3286
                       rsUnknown]
3287

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

    
3296
-- * Max dynamic devices
3297

    
3298
maxDisks :: Int
3299
maxDisks = Types.maxDisks
3300

    
3301
maxNics :: Int
3302
maxNics = Types.maxNics
3303

    
3304
-- | SSCONF file prefix
3305
ssconfFileprefix :: String
3306
ssconfFileprefix = "ssconf_"
3307

    
3308
-- * SSCONF keys
3309

    
3310
ssClusterName :: String
3311
ssClusterName = "cluster_name"
3312

    
3313
ssClusterTags :: String
3314
ssClusterTags = "cluster_tags"
3315

    
3316
ssFileStorageDir :: String
3317
ssFileStorageDir = "file_storage_dir"
3318

    
3319
ssSharedFileStorageDir :: String
3320
ssSharedFileStorageDir = "shared_file_storage_dir"
3321

    
3322
ssMasterCandidates :: String
3323
ssMasterCandidates = "master_candidates"
3324

    
3325
ssMasterCandidatesIps :: String
3326
ssMasterCandidatesIps = "master_candidates_ips"
3327

    
3328
ssMasterIp :: String
3329
ssMasterIp = "master_ip"
3330

    
3331
ssMasterNetdev :: String
3332
ssMasterNetdev = "master_netdev"
3333

    
3334
ssMasterNetmask :: String
3335
ssMasterNetmask = "master_netmask"
3336

    
3337
ssMasterNode :: String
3338
ssMasterNode = "master_node"
3339

    
3340
ssNodeList :: String
3341
ssNodeList = "node_list"
3342

    
3343
ssNodePrimaryIps :: String
3344
ssNodePrimaryIps = "node_primary_ips"
3345

    
3346
ssNodeSecondaryIps :: String
3347
ssNodeSecondaryIps = "node_secondary_ips"
3348

    
3349
ssOfflineNodes :: String
3350
ssOfflineNodes = "offline_nodes"
3351

    
3352
ssOnlineNodes :: String
3353
ssOnlineNodes = "online_nodes"
3354

    
3355
ssPrimaryIpFamily :: String
3356
ssPrimaryIpFamily = "primary_ip_family"
3357

    
3358
ssInstanceList :: String
3359
ssInstanceList = "instance_list"
3360

    
3361
ssReleaseVersion :: String
3362
ssReleaseVersion = "release_version"
3363

    
3364
ssHypervisorList :: String
3365
ssHypervisorList = "hypervisor_list"
3366

    
3367
ssMaintainNodeHealth :: String
3368
ssMaintainNodeHealth = "maintain_node_health"
3369

    
3370
ssUidPool :: String
3371
ssUidPool = "uid_pool"
3372

    
3373
ssNodegroups :: String
3374
ssNodegroups = "nodegroups"
3375

    
3376
ssNetworks :: String
3377
ssNetworks = "networks"
3378

    
3379
-- | This is not a complete SSCONF key, but the prefix for the
3380
-- hypervisor keys
3381
ssHvparamsPref :: String
3382
ssHvparamsPref = "hvparams_"
3383

    
3384
-- * Hvparams keys
3385

    
3386
ssHvparamsXenChroot :: String
3387
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3388

    
3389
ssHvparamsXenFake :: String
3390
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3391

    
3392
ssHvparamsXenHvm :: String
3393
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3394

    
3395
ssHvparamsXenKvm :: String
3396
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3397

    
3398
ssHvparamsXenLxc :: String
3399
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3400

    
3401
ssHvparamsXenPvm :: String
3402
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3403

    
3404
validSsHvparamsKeys :: FrozenSet String
3405
validSsHvparamsKeys =
3406
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3407
                       ssHvparamsXenLxc,
3408
                       ssHvparamsXenFake,
3409
                       ssHvparamsXenHvm,
3410
                       ssHvparamsXenKvm,
3411
                       ssHvparamsXenPvm]
3412

    
3413
ssFilePerms :: Int
3414
ssFilePerms = 0o444
3415

    
3416
-- | Cluster wide default parameters
3417
defaultEnabledHypervisor :: String
3418
defaultEnabledHypervisor = htXenPvm
3419

    
3420
hvcGlobals :: FrozenSet String
3421
hvcGlobals =
3422
  ConstantUtils.mkSet [hvMigrationBandwidth,
3423
                       hvMigrationMode,
3424
                       hvMigrationPort,
3425
                       hvXenCmd]
3426

    
3427
ndcGlobals :: FrozenSet String
3428
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3429

    
3430
-- * Confd
3431

    
3432
confdProtocolVersion :: Int
3433
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3434

    
3435
-- Confd request type
3436

    
3437
confdReqPing :: Int
3438
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3439

    
3440
confdReqNodeRoleByname :: Int
3441
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3442

    
3443
confdReqNodePipByInstanceIp :: Int
3444
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3445

    
3446
confdReqClusterMaster :: Int
3447
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3448

    
3449
confdReqNodePipList :: Int
3450
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3451

    
3452
confdReqMcPipList :: Int
3453
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3454

    
3455
confdReqInstancesIpsList :: Int
3456
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3457

    
3458
confdReqNodeDrbd :: Int
3459
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3460

    
3461
confdReqNodeInstances :: Int
3462
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3463

    
3464
confdReqs :: FrozenSet Int
3465
confdReqs =
3466
  ConstantUtils.mkSet .
3467
  map Types.confdRequestTypeToRaw $
3468
  [minBound..] \\ [ReqNodeInstances]
3469

    
3470
-- * Confd request type
3471

    
3472
confdReqfieldName :: Int
3473
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3474

    
3475
confdReqfieldIp :: Int
3476
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3477

    
3478
confdReqfieldMnodePip :: Int
3479
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3480

    
3481
-- * Confd repl status
3482

    
3483
confdReplStatusOk :: Int
3484
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3485

    
3486
confdReplStatusError :: Int
3487
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3488

    
3489
confdReplStatusNotimplemented :: Int
3490
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3491

    
3492
confdReplStatuses :: FrozenSet Int
3493
confdReplStatuses =
3494
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3495

    
3496
-- * Confd node role
3497

    
3498
confdNodeRoleMaster :: Int
3499
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3500

    
3501
confdNodeRoleCandidate :: Int
3502
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3503

    
3504
confdNodeRoleOffline :: Int
3505
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3506

    
3507
confdNodeRoleDrained :: Int
3508
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3509

    
3510
confdNodeRoleRegular :: Int
3511
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3512

    
3513
-- * A few common errors for confd
3514

    
3515
confdErrorUnknownEntry :: Int
3516
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3517

    
3518
confdErrorInternal :: Int
3519
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3520

    
3521
confdErrorArgument :: Int
3522
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3523

    
3524
-- * Confd request query fields
3525

    
3526
confdReqqLink :: String
3527
confdReqqLink = ConstantUtils.confdReqqLink
3528

    
3529
confdReqqIp :: String
3530
confdReqqIp = ConstantUtils.confdReqqIp
3531

    
3532
confdReqqIplist :: String
3533
confdReqqIplist = ConstantUtils.confdReqqIplist
3534

    
3535
confdReqqFields :: String
3536
confdReqqFields = ConstantUtils.confdReqqFields
3537

    
3538
-- | Each request is "salted" by the current timestamp.
3539
--
3540
-- This constant decides how many seconds of skew to accept.
3541
--
3542
-- TODO: make this a default and allow the value to be more
3543
-- configurable
3544
confdMaxClockSkew :: Int
3545
confdMaxClockSkew = 2 * nodeMaxClockSkew
3546

    
3547
-- | When we haven't reloaded the config for more than this amount of
3548
-- seconds, we force a test to see if inotify is betraying us. Using a
3549
-- prime number to ensure we get less chance of 'same wakeup' with
3550
-- other processes.
3551
confdConfigReloadTimeout :: Int
3552
confdConfigReloadTimeout = 17
3553

    
3554
-- | If we receive more than one update in this amount of
3555
-- microseconds, we move to polling every RATELIMIT seconds, rather
3556
-- than relying on inotify, to be able to serve more requests.
3557
confdConfigReloadRatelimit :: Int
3558
confdConfigReloadRatelimit = 250000
3559

    
3560
-- | Magic number prepended to all confd queries.
3561
--
3562
-- This allows us to distinguish different types of confd protocols
3563
-- and handle them. For example by changing this we can move the whole
3564
-- payload to be compressed, or move away from json.
3565
confdMagicFourcc :: String
3566
confdMagicFourcc = "plj0"
3567

    
3568
-- | By default a confd request is sent to the minimum between this
3569
-- number and all MCs. 6 was chosen because even in the case of a
3570
-- disastrous 50% response rate, we should have enough answers to be
3571
-- able to compare more than one.
3572
confdDefaultReqCoverage :: Int
3573
confdDefaultReqCoverage = 6
3574

    
3575
-- | Timeout in seconds to expire pending query request in the confd
3576
-- client library. We don't actually expect any answer more than 10
3577
-- seconds after we sent a request.
3578
confdClientExpireTimeout :: Int
3579
confdClientExpireTimeout = 10
3580

    
3581
-- * Possible values for NodeGroup.alloc_policy
3582

    
3583
allocPolicyLastResort :: String
3584
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
3585

    
3586
allocPolicyPreferred :: String
3587
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
3588

    
3589
allocPolicyUnallocable :: String
3590
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
3591

    
3592
validAllocPolicies :: [String]
3593
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
3594

    
3595
-- | Temporary external/shared storage parameters
3596
blockdevDriverManual :: String
3597
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
3598

    
3599
-- | 'qemu-img' path, required for 'ovfconverter'
3600
qemuimgPath :: String
3601
qemuimgPath = AutoConf.qemuimgPath
3602

    
3603
-- | Whether htools was enabled at compilation time
3604
--
3605
-- FIXME: this should be moved next to the other enable constants,
3606
-- such as, 'enableConfd', and renamed to 'enableHtools'.
3607
htools :: Bool
3608
htools = AutoConf.htools
3609

    
3610
-- * Key files for SSH daemon
3611

    
3612
sshHostDsaPriv :: String
3613
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
3614

    
3615
sshHostDsaPub :: String
3616
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
3617

    
3618
sshHostRsaPriv :: String
3619
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
3620

    
3621
sshHostRsaPub :: String
3622
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
3623

    
3624
-- | Path generating random UUID
3625
randomUuidFile :: String
3626
randomUuidFile = ConstantUtils.randomUuidFile
3627

    
3628
-- * Auto-repair tag prefixes
3629

    
3630
autoRepairTagPrefix :: String
3631
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
3632

    
3633
autoRepairTagEnabled :: String
3634
autoRepairTagEnabled = autoRepairTagPrefix
3635

    
3636
autoRepairTagPending :: String
3637
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
3638

    
3639
autoRepairTagResult :: String
3640
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
3641

    
3642
autoRepairTagSuspended :: String
3643
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
3644

    
3645
-- * Auto-repair levels
3646

    
3647
autoRepairFailover :: String
3648
autoRepairFailover = "failover"
3649

    
3650
autoRepairFixStorage :: String
3651
autoRepairFixStorage = "fix-storage"
3652

    
3653
autoRepairMigrate :: String
3654
autoRepairMigrate = "migrate"
3655

    
3656
autoRepairReinstall :: String
3657
autoRepairReinstall = "reinstall"
3658

    
3659
autoRepairAllTypes :: FrozenSet String
3660
autoRepairAllTypes =
3661
  ConstantUtils.mkSet [autoRepairFailover,
3662
                       autoRepairFixStorage,
3663
                       autoRepairMigrate,
3664
                       autoRepairReinstall]
3665

    
3666
-- * Auto-repair results
3667

    
3668
autoRepairEnoperm :: String
3669
autoRepairEnoperm = "enoperm"
3670

    
3671
autoRepairFailure :: String
3672
autoRepairFailure = "failure"
3673

    
3674
autoRepairSuccess :: String
3675
autoRepairSuccess = "success"
3676

    
3677
autoRepairAllResults :: FrozenSet String
3678
autoRepairAllResults =
3679
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
3680

    
3681
-- | The version identifier for builtin data collectors
3682
builtinDataCollectorVersion :: String
3683
builtinDataCollectorVersion = "B"
3684

    
3685
-- | The reason trail opcode parameter name
3686
opcodeReason :: String
3687
opcodeReason = "reason"
3688

    
3689
diskstatsFile :: String
3690
diskstatsFile = "/proc/diskstats"
3691

    
3692
-- *  CPU load collector
3693

    
3694
statFile :: String
3695
statFile = "/proc/stat"
3696

    
3697
cpuavgloadBufferSize :: Int
3698
cpuavgloadBufferSize = 150
3699

    
3700
cpuavgloadWindowSize :: Int
3701
cpuavgloadWindowSize = 600
3702

    
3703
-- | Mond's variable for periodical data collection
3704
mondTimeInterval :: Int
3705
mondTimeInterval = 5
3706

    
3707
-- * Disk access modes
3708

    
3709
diskUserspace :: String
3710
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
3711

    
3712
diskKernelspace :: String
3713
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
3714

    
3715
diskValidAccessModes :: FrozenSet String
3716
diskValidAccessModes =
3717
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
3718

    
3719
-- | Timeout for queue draining in upgrades
3720
upgradeQueueDrainTimeout :: Int
3721
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
3722

    
3723
-- | Intervall at which the queue is polled during upgrades
3724
upgradeQueuePollInterval :: Int
3725
upgradeQueuePollInterval  = 10