Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ e0007cf1

History | View | Annotate | Download (91.2 kB)

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

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

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

    
16
-}
17

    
18
{-
19

    
20
Copyright (C) 2013 Google Inc.
21

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

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

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

    
37
-}
38
module Ganeti.HsConstants where
39

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

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

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

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

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

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

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

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

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

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

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

    
86
-- ** Build-time constants
87

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
135
-- * Various versions
136

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

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

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

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

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

    
152
osApiV10 :: Int
153
osApiV10 = 10
154

    
155
osApiV15 :: Int
156
osApiV15 = 15
157

    
158
osApiV20 :: Int
159
osApiV20 = 20
160

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

    
164
exportVersion :: Int
165
exportVersion = 0
166

    
167
rapiVersion :: Int
168
rapiVersion = 2
169

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

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

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

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

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

    
189
-- * User separation
190

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
239
-- * Cpu pinning separators and constants
240

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

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

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

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

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

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

    
279
-- * Wipe
280

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

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

    
288
minWipeChunkPercent :: Int
289
minWipeChunkPercent = 10
290

    
291
-- * Directories
292

    
293
runDirsMode :: Int
294
runDirsMode = 0o775
295

    
296
secureDirMode :: Int
297
secureDirMode = 0o700
298

    
299
secureFileMode :: Int
300
secureFileMode = 0o600
301

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

    
305
-- * 'autoconf' enable/disable
306

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

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

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

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

    
319
-- * SSH constants
320

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

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

    
327
-- * Daemons
328

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

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

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

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

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

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

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

    
356
defaultConfdPort :: Int
357
defaultConfdPort = 1814
358

    
359
defaultMondPort :: Int
360
defaultMondPort = 1815
361

    
362
defaultNodedPort :: Int
363
defaultNodedPort = 1811
364

    
365
defaultRapiPort :: Int
366
defaultRapiPort = 5080
367

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

    
376
firstDrbdPort :: Int
377
firstDrbdPort = 11000
378

    
379
lastDrbdPort :: Int
380
lastDrbdPort = 14999
381

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

    
387
daemonsExtraLogbase :: Map String (Map String String)
388
daemonsExtraLogbase =
389
  Map.fromList $
390
  map (Runtime.daemonName *** id)
391
  [ (GanetiMond, Map.fromList
392
                 [ ("access", Runtime.daemonsExtraLogbase GanetiMond AccessLog)
393
                 , ("error", Runtime.daemonsExtraLogbase GanetiMond ErrorLog)
394
                 ])
395
  ]
396

    
397
extraLogreasonAccess :: String
398
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
399

    
400
extraLogreasonError :: String
401
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
402

    
403
devConsole :: String
404
devConsole = ConstantUtils.devConsole
405

    
406
procMounts :: String
407
procMounts = "/proc/mounts"
408

    
409
-- * Luxi (Local UniX Interface) related constants
410

    
411
luxiEom :: PythonChar
412
luxiEom = PythonChar '\x03'
413

    
414
-- | Environment variable for the luxi override socket
415
luxiOverride :: String
416
luxiOverride = "FORCE_LUXI_SOCKET"
417

    
418
luxiOverrideMaster :: String
419
luxiOverrideMaster = "master"
420

    
421
luxiOverrideQuery :: String
422
luxiOverrideQuery = "query"
423

    
424
luxiVersion :: Int
425
luxiVersion = configVersion
426

    
427
-- * Syslog
428

    
429
syslogUsage :: String
430
syslogUsage = AutoConf.syslogUsage
431

    
432
syslogNo :: String
433
syslogNo = Logging.syslogUsageToRaw SyslogNo
434

    
435
syslogYes :: String
436
syslogYes = Logging.syslogUsageToRaw SyslogYes
437

    
438
syslogOnly :: String
439
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
440

    
441
syslogSocket :: String
442
syslogSocket = "/dev/log"
443

    
444
exportConfFile :: String
445
exportConfFile = "config.ini"
446

    
447
-- * Xen
448

    
449
xenBootloader :: String
450
xenBootloader = AutoConf.xenBootloader
451

    
452
xenCmdXl :: String
453
xenCmdXl = "xl"
454

    
455
xenCmdXm :: String
456
xenCmdXm = "xm"
457

    
458
xenInitrd :: String
459
xenInitrd = AutoConf.xenInitrd
460

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

    
464
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
465
-- other constants
466
knownXenCommands :: FrozenSet String
467
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
468

    
469
-- * KVM and socat
470

    
471
kvmPath :: String
472
kvmPath = AutoConf.kvmPath
473

    
474
kvmKernel :: String
475
kvmKernel = AutoConf.kvmKernel
476

    
477
socatEscapeCode :: String
478
socatEscapeCode = "0x1d"
479

    
480
socatPath :: String
481
socatPath = AutoConf.socatPath
482

    
483
socatUseCompress :: Bool
484
socatUseCompress = AutoConf.socatUseCompress
485

    
486
socatUseEscape :: Bool
487
socatUseEscape = AutoConf.socatUseEscape
488

    
489
-- * Console types
490

    
491
-- | Display a message for console access
492
consMessage :: String
493
consMessage = "msg"
494

    
495
-- | Console as SPICE server
496
consSpice :: String
497
consSpice = "spice"
498

    
499
-- | Console as SSH command
500
consSsh :: String
501
consSsh = "ssh"
502

    
503
-- | Console as VNC server
504
consVnc :: String
505
consVnc = "vnc"
506

    
507
consAll :: FrozenSet String
508
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
509

    
510
-- | RSA key bit length
511
--
512
-- For RSA keys more bits are better, but they also make operations
513
-- more expensive. NIST SP 800-131 recommends a minimum of 2048 bits
514
-- from the year 2010 on.
515
rsaKeyBits :: Int
516
rsaKeyBits = 2048
517

    
518
-- | Ciphers allowed for SSL connections.
519
--
520
-- For the format, see ciphers(1). A better way to disable ciphers
521
-- would be to use the exclamation mark (!), but socat versions below
522
-- 1.5 can't parse exclamation marks in options properly. When
523
-- modifying the ciphers, ensure not to accidentially add something
524
-- after it's been removed. Use the "openssl" utility to check the
525
-- allowed ciphers, e.g.  "openssl ciphers -v HIGH:-DES".
526
opensslCiphers :: String
527
opensslCiphers = "HIGH:-DES:-3DES:-EXPORT:-ADH"
528

    
529
-- * X509
530

    
531
-- | commonName (CN) used in certificates
532
x509CertCn :: String
533
x509CertCn = "ganeti.example.com"
534

    
535
-- | Default validity of certificates in days
536
x509CertDefaultValidity :: Int
537
x509CertDefaultValidity = 365 * 5
538

    
539
x509CertSignatureHeader :: String
540
x509CertSignatureHeader = "X-Ganeti-Signature"
541

    
542
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
543
x509CertSignDigest :: String
544
x509CertSignDigest = "SHA1"
545

    
546
-- * Import/export daemon mode
547

    
548
iemExport :: String
549
iemExport = "export"
550

    
551
iemImport :: String
552
iemImport = "import"
553

    
554
-- * Import/export transport compression
555

    
556
iecGzip :: String
557
iecGzip = "gzip"
558

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

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

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

    
568
-- * Import/export I/O
569

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

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

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

    
583
-- * Hooks
584

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

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

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

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

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

    
600
hooksVersion :: Int
601
hooksVersion = 2
602

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

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

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

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

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

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

    
620
-- * Hkr
621

    
622
hkrSkip :: Int
623
hkrSkip = 0
624

    
625
hkrFail :: Int
626
hkrFail = 1
627

    
628
hkrSuccess :: Int
629
hkrSuccess = 2
630

    
631
-- * Storage types
632

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
700
-- * Storage operations
701

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

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

    
710
-- * Volume fields
711

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

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

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

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

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

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

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

    
733
-- * Local disk status
734

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

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

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

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

    
749
-- * Disk template types
750

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
871
-- * Drbd
872

    
873
drbdHmacAlg :: String
874
drbdHmacAlg = "md5"
875

    
876
drbdDefaultNetProtocol :: String
877
drbdDefaultNetProtocol = "C"
878

    
879
drbdMigrationNetProtocol :: String
880
drbdMigrationNetProtocol = "C"
881

    
882
drbdStatusFile :: String
883
drbdStatusFile = "/proc/drbd"
884

    
885
-- | Size of DRBD meta block device
886
drbdMetaSize :: Int
887
drbdMetaSize = 128
888

    
889
-- * Drbd barrier types
890

    
891
drbdBDiskBarriers :: String
892
drbdBDiskBarriers = "b"
893

    
894
drbdBDiskDrain :: String
895
drbdBDiskDrain = "d"
896

    
897
drbdBDiskFlush :: String
898
drbdBDiskFlush = "f"
899

    
900
drbdBNone :: String
901
drbdBNone = "n"
902

    
903
-- | Rbd tool command
904
rbdCmd :: String
905
rbdCmd = "rbd"
906

    
907
-- * File backend driver
908

    
909
fdBlktap :: String
910
fdBlktap = Types.fileDriverToRaw FileBlktap
911

    
912
fdLoop :: String
913
fdLoop = Types.fileDriverToRaw FileLoop
914

    
915
fileDriver :: FrozenSet String
916
fileDriver =
917
  ConstantUtils.mkSet $
918
  map Types.fileDriverToRaw [minBound..]
919

    
920
-- | The set of drbd-like disk types
921
dtsDrbd :: FrozenSet String
922
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
923

    
924
-- * Disk access mode
925

    
926
diskRdonly :: String
927
diskRdonly = Types.diskModeToRaw DiskRdOnly
928

    
929
diskRdwr :: String
930
diskRdwr = Types.diskModeToRaw DiskRdWr
931

    
932
diskAccessSet :: FrozenSet String
933
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
934

    
935
-- * Disk replacement mode
936

    
937
replaceDiskAuto :: String
938
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
939

    
940
replaceDiskChg :: String
941
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
942

    
943
replaceDiskPri :: String
944
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
945

    
946
replaceDiskSec :: String
947
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
948

    
949
replaceModes :: FrozenSet String
950
replaceModes =
951
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
952

    
953
-- * Instance export mode
954

    
955
exportModeLocal :: String
956
exportModeLocal = Types.exportModeToRaw ExportModeLocal
957

    
958
exportModeRemote :: String
959
exportModeRemote = Types.exportModeToRaw ExportModeRemote
960

    
961
exportModes :: FrozenSet String
962
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
963

    
964
-- * Instance creation modes
965

    
966
instanceCreate :: String
967
instanceCreate = Types.instCreateModeToRaw InstCreate
968

    
969
instanceImport :: String
970
instanceImport = Types.instCreateModeToRaw InstImport
971

    
972
instanceRemoteImport :: String
973
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
974

    
975
instanceCreateModes :: FrozenSet String
976
instanceCreateModes =
977
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
978

    
979
-- * Remote import/export handshake message and version
980

    
981
rieHandshake :: String
982
rieHandshake = "Hi, I'm Ganeti"
983

    
984
rieVersion :: Int
985
rieVersion = 0
986

    
987
-- | Remote import/export certificate validity in seconds
988
rieCertValidity :: Int
989
rieCertValidity = 24 * 60 * 60
990

    
991
-- | Export only: how long to wait per connection attempt (seconds)
992
rieConnectAttemptTimeout :: Int
993
rieConnectAttemptTimeout = 20
994

    
995
-- | Export only: number of attempts to connect
996
rieConnectRetries :: Int
997
rieConnectRetries = 10
998

    
999
-- | Overall timeout for establishing connection
1000
rieConnectTimeout :: Int
1001
rieConnectTimeout = 180
1002

    
1003
-- | Give child process up to 5 seconds to exit after sending a signal
1004
childLingerTimeout :: Double
1005
childLingerTimeout = 5.0
1006

    
1007
-- * Import/export config options
1008

    
1009
inisectBep :: String
1010
inisectBep = "backend"
1011

    
1012
inisectExp :: String
1013
inisectExp = "export"
1014

    
1015
inisectHyp :: String
1016
inisectHyp = "hypervisor"
1017

    
1018
inisectIns :: String
1019
inisectIns = "instance"
1020

    
1021
inisectOsp :: String
1022
inisectOsp = "os"
1023

    
1024
-- * Dynamic device modification
1025

    
1026
ddmAdd :: String
1027
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1028

    
1029
ddmModify :: String
1030
ddmModify = Types.ddmFullToRaw DdmFullModify
1031

    
1032
ddmRemove :: String
1033
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1034

    
1035
ddmsValues :: FrozenSet String
1036
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1037

    
1038
ddmsValuesWithModify :: FrozenSet String
1039
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1040

    
1041
-- * Common exit codes
1042

    
1043
exitSuccess :: Int
1044
exitSuccess = 0
1045

    
1046
exitFailure :: Int
1047
exitFailure = ConstantUtils.exitFailure
1048

    
1049
exitNotcluster :: Int
1050
exitNotcluster = 5
1051

    
1052
exitNotmaster :: Int
1053
exitNotmaster = 11
1054

    
1055
exitNodesetupError :: Int
1056
exitNodesetupError = 12
1057

    
1058
-- | Need user confirmation
1059
exitConfirmation :: Int
1060
exitConfirmation = 13
1061

    
1062
-- | Exit code for query operations with unknown fields
1063
exitUnknownField :: Int
1064
exitUnknownField = 14
1065

    
1066
-- * Tags
1067

    
1068
tagCluster :: String
1069
tagCluster = Types.tagKindToRaw TagKindCluster
1070

    
1071
tagInstance :: String
1072
tagInstance = Types.tagKindToRaw TagKindInstance
1073

    
1074
tagNetwork :: String
1075
tagNetwork = Types.tagKindToRaw TagKindNetwork
1076

    
1077
tagNode :: String
1078
tagNode = Types.tagKindToRaw TagKindNode
1079

    
1080
tagNodegroup :: String
1081
tagNodegroup = Types.tagKindToRaw TagKindGroup
1082

    
1083
validTagTypes :: FrozenSet String
1084
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1085

    
1086
maxTagLen :: Int
1087
maxTagLen = 128
1088

    
1089
maxTagsPerObj :: Int
1090
maxTagsPerObj = 4096
1091

    
1092
-- * Others
1093

    
1094
defaultBridge :: String
1095
defaultBridge = "xen-br0"
1096

    
1097
defaultOvs :: String
1098
defaultOvs = "switch1"
1099

    
1100
-- | 60 MiB, expressed in KiB
1101
classicDrbdSyncSpeed :: Int
1102
classicDrbdSyncSpeed = 60 * 1024
1103

    
1104
ip4AddressAny :: String
1105
ip4AddressAny = "0.0.0.0"
1106

    
1107
ip4AddressLocalhost :: String
1108
ip4AddressLocalhost = "127.0.0.1"
1109

    
1110
ip6AddressAny :: String
1111
ip6AddressAny = "::"
1112

    
1113
ip6AddressLocalhost :: String
1114
ip6AddressLocalhost = "::1"
1115

    
1116
ip4Version :: Int
1117
ip4Version = 4
1118

    
1119
ip6Version :: Int
1120
ip6Version = 6
1121

    
1122
validIpVersions :: FrozenSet Int
1123
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1124

    
1125
tcpPingTimeout :: Int
1126
tcpPingTimeout = 10
1127

    
1128
defaultVg :: String
1129
defaultVg = "xenvg"
1130

    
1131
defaultDrbdHelper :: String
1132
defaultDrbdHelper = "/bin/true"
1133

    
1134
minVgSize :: Int
1135
minVgSize = 20480
1136

    
1137
defaultMacPrefix :: String
1138
defaultMacPrefix = "aa:00:00"
1139

    
1140
-- | Default maximum instance wait time, in seconds.
1141
defaultShutdownTimeout :: Int
1142
defaultShutdownTimeout = 120
1143

    
1144
-- | Node clock skew in seconds
1145
nodeMaxClockSkew :: Int
1146
nodeMaxClockSkew = 150
1147

    
1148
-- | Time for an intra-cluster disk transfer to wait for a connection
1149
diskTransferConnectTimeout :: Int
1150
diskTransferConnectTimeout = 60
1151

    
1152
-- | Disk index separator
1153
diskSeparator :: String
1154
diskSeparator = AutoConf.diskSeparator
1155

    
1156
ipCommandPath :: String
1157
ipCommandPath = AutoConf.ipPath
1158

    
1159
-- | Key for job IDs in opcode result
1160
jobIdsKey :: String
1161
jobIdsKey = "jobs"
1162

    
1163
-- * Runparts results
1164

    
1165
runpartsErr :: Int
1166
runpartsErr = 2
1167

    
1168
runpartsRun :: Int
1169
runpartsRun = 1
1170

    
1171
runpartsSkip :: Int
1172
runpartsSkip = 0
1173

    
1174
runpartsStatus :: [Int]
1175
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1176

    
1177
-- * RPC
1178

    
1179
rpcEncodingNone :: Int
1180
rpcEncodingNone = 0
1181

    
1182
rpcEncodingZlibBase64 :: Int
1183
rpcEncodingZlibBase64 = 1
1184

    
1185
-- * Timeout table
1186
--
1187
-- Various time constants for the timeout table
1188

    
1189
rpcTmoUrgent :: Int
1190
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1191

    
1192
rpcTmoFast :: Int
1193
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1194

    
1195
rpcTmoNormal :: Int
1196
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1197

    
1198
rpcTmoSlow :: Int
1199
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1200

    
1201
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1202
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1203
-- Python name.
1204
rpcTmo_4hrs :: Int
1205
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1206

    
1207
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1208
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1209
-- Python name.
1210
rpcTmo_1day :: Int
1211
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1212

    
1213
-- | Timeout for connecting to nodes (seconds)
1214
rpcConnectTimeout :: Int
1215
rpcConnectTimeout = 5
1216

    
1217
-- OS
1218

    
1219
osScriptCreate :: String
1220
osScriptCreate = "create"
1221

    
1222
osScriptExport :: String
1223
osScriptExport = "export"
1224

    
1225
osScriptImport :: String
1226
osScriptImport = "import"
1227

    
1228
osScriptRename :: String
1229
osScriptRename = "rename"
1230

    
1231
osScriptVerify :: String
1232
osScriptVerify = "verify"
1233

    
1234
osScripts :: [String]
1235
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1236
             osScriptVerify]
1237

    
1238
osApiFile :: String
1239
osApiFile = "ganeti_api_version"
1240

    
1241
osVariantsFile :: String
1242
osVariantsFile = "variants.list"
1243

    
1244
osParametersFile :: String
1245
osParametersFile = "parameters.list"
1246

    
1247
osValidateParameters :: String
1248
osValidateParameters = "parameters"
1249

    
1250
osValidateCalls :: FrozenSet String
1251
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1252

    
1253
-- | External Storage (ES) related constants
1254

    
1255
esActionAttach :: String
1256
esActionAttach = "attach"
1257

    
1258
esActionCreate :: String
1259
esActionCreate = "create"
1260

    
1261
esActionDetach :: String
1262
esActionDetach = "detach"
1263

    
1264
esActionGrow :: String
1265
esActionGrow = "grow"
1266

    
1267
esActionRemove :: String
1268
esActionRemove = "remove"
1269

    
1270
esActionSetinfo :: String
1271
esActionSetinfo = "setinfo"
1272

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

    
1276
esScriptCreate :: String
1277
esScriptCreate = esActionCreate
1278

    
1279
esScriptRemove :: String
1280
esScriptRemove = esActionRemove
1281

    
1282
esScriptGrow :: String
1283
esScriptGrow = esActionGrow
1284

    
1285
esScriptAttach :: String
1286
esScriptAttach = esActionAttach
1287

    
1288
esScriptDetach :: String
1289
esScriptDetach = esActionDetach
1290

    
1291
esScriptSetinfo :: String
1292
esScriptSetinfo = esActionSetinfo
1293

    
1294
esScriptVerify :: String
1295
esScriptVerify = esActionVerify
1296

    
1297
esScripts :: FrozenSet String
1298
esScripts =
1299
  ConstantUtils.mkSet [esScriptAttach,
1300
                       esScriptCreate,
1301
                       esScriptDetach,
1302
                       esScriptGrow,
1303
                       esScriptRemove,
1304
                       esScriptSetinfo,
1305
                       esScriptVerify]
1306

    
1307
esParametersFile :: String
1308
esParametersFile = "parameters.list"
1309

    
1310
-- * Reboot types
1311

    
1312
instanceRebootSoft :: String
1313
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1314

    
1315
instanceRebootHard :: String
1316
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1317

    
1318
instanceRebootFull :: String
1319
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1320

    
1321
rebootTypes :: FrozenSet String
1322
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1323

    
1324
-- * Instance reboot behaviors
1325

    
1326
instanceRebootAllowed :: String
1327
instanceRebootAllowed = "reboot"
1328

    
1329
instanceRebootExit :: String
1330
instanceRebootExit = "exit"
1331

    
1332
rebootBehaviors :: [String]
1333
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1334

    
1335
-- * VTypes
1336

    
1337
vtypeBool :: VType
1338
vtypeBool = VTypeBool
1339

    
1340
vtypeInt :: VType
1341
vtypeInt = VTypeInt
1342

    
1343
vtypeMaybeString :: VType
1344
vtypeMaybeString = VTypeMaybeString
1345

    
1346
-- | Size in MiBs
1347
vtypeSize :: VType
1348
vtypeSize = VTypeSize
1349

    
1350
vtypeString :: VType
1351
vtypeString = VTypeString
1352

    
1353
enforceableTypes :: FrozenSet VType
1354
enforceableTypes = ConstantUtils.mkSet [minBound..]
1355

    
1356
-- | Constant representing that the user does not specify any IP version
1357
ifaceNoIpVersionSpecified :: Int
1358
ifaceNoIpVersionSpecified = 0
1359

    
1360
validSerialSpeeds :: [Int]
1361
validSerialSpeeds =
1362
  [75,
1363
   110,
1364
   300,
1365
   600,
1366
   1200,
1367
   1800,
1368
   2400,
1369
   4800,
1370
   9600,
1371
   14400,
1372
   19200,
1373
   28800,
1374
   38400,
1375
   57600,
1376
   115200,
1377
   230400,
1378
   345600,
1379
   460800]
1380

    
1381
-- * HV parameter names (global namespace)
1382

    
1383
hvAcpi :: String
1384
hvAcpi = "acpi"
1385

    
1386
hvBlockdevPrefix :: String
1387
hvBlockdevPrefix = "blockdev_prefix"
1388

    
1389
hvBootloaderArgs :: String
1390
hvBootloaderArgs = "bootloader_args"
1391

    
1392
hvBootloaderPath :: String
1393
hvBootloaderPath = "bootloader_path"
1394

    
1395
hvBootOrder :: String
1396
hvBootOrder = "boot_order"
1397

    
1398
hvCdromImagePath :: String
1399
hvCdromImagePath = "cdrom_image_path"
1400

    
1401
hvCpuCap :: String
1402
hvCpuCap = "cpu_cap"
1403

    
1404
hvCpuCores :: String
1405
hvCpuCores = "cpu_cores"
1406

    
1407
hvCpuMask :: String
1408
hvCpuMask = "cpu_mask"
1409

    
1410
hvCpuSockets :: String
1411
hvCpuSockets = "cpu_sockets"
1412

    
1413
hvCpuThreads :: String
1414
hvCpuThreads = "cpu_threads"
1415

    
1416
hvCpuType :: String
1417
hvCpuType = "cpu_type"
1418

    
1419
hvCpuWeight :: String
1420
hvCpuWeight = "cpu_weight"
1421

    
1422
hvDeviceModel :: String
1423
hvDeviceModel = "device_model"
1424

    
1425
hvDiskCache :: String
1426
hvDiskCache = "disk_cache"
1427

    
1428
hvDiskType :: String
1429
hvDiskType = "disk_type"
1430

    
1431
hvInitrdPath :: String
1432
hvInitrdPath = "initrd_path"
1433

    
1434
hvInitScript :: String
1435
hvInitScript = "init_script"
1436

    
1437
hvKernelArgs :: String
1438
hvKernelArgs = "kernel_args"
1439

    
1440
hvKernelPath :: String
1441
hvKernelPath = "kernel_path"
1442

    
1443
hvKeymap :: String
1444
hvKeymap = "keymap"
1445

    
1446
hvKvmCdrom2ImagePath :: String
1447
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1448

    
1449
hvKvmCdromDiskType :: String
1450
hvKvmCdromDiskType = "cdrom_disk_type"
1451

    
1452
hvKvmExtra :: String
1453
hvKvmExtra = "kvm_extra"
1454

    
1455
hvKvmFlag :: String
1456
hvKvmFlag = "kvm_flag"
1457

    
1458
hvKvmFloppyImagePath :: String
1459
hvKvmFloppyImagePath = "floppy_image_path"
1460

    
1461
hvKvmMachineVersion :: String
1462
hvKvmMachineVersion = "machine_version"
1463

    
1464
hvKvmPath :: String
1465
hvKvmPath = "kvm_path"
1466

    
1467
hvKvmSpiceAudioCompr :: String
1468
hvKvmSpiceAudioCompr = "spice_playback_compression"
1469

    
1470
hvKvmSpiceBind :: String
1471
hvKvmSpiceBind = "spice_bind"
1472

    
1473
hvKvmSpiceIpVersion :: String
1474
hvKvmSpiceIpVersion = "spice_ip_version"
1475

    
1476
hvKvmSpiceJpegImgCompr :: String
1477
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1478

    
1479
hvKvmSpiceLosslessImgCompr :: String
1480
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1481

    
1482
hvKvmSpicePasswordFile :: String
1483
hvKvmSpicePasswordFile = "spice_password_file"
1484

    
1485
hvKvmSpiceStreamingVideoDetection :: String
1486
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1487

    
1488
hvKvmSpiceTlsCiphers :: String
1489
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1490

    
1491
hvKvmSpiceUseTls :: String
1492
hvKvmSpiceUseTls = "spice_use_tls"
1493

    
1494
hvKvmSpiceUseVdagent :: String
1495
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1496

    
1497
hvKvmSpiceZlibGlzImgCompr :: String
1498
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1499

    
1500
hvKvmUseChroot :: String
1501
hvKvmUseChroot = "use_chroot"
1502

    
1503
hvMemPath :: String
1504
hvMemPath = "mem_path"
1505

    
1506
hvMigrationBandwidth :: String
1507
hvMigrationBandwidth = "migration_bandwidth"
1508

    
1509
hvMigrationDowntime :: String
1510
hvMigrationDowntime = "migration_downtime"
1511

    
1512
hvMigrationMode :: String
1513
hvMigrationMode = "migration_mode"
1514

    
1515
hvMigrationPort :: String
1516
hvMigrationPort = "migration_port"
1517

    
1518
hvNicType :: String
1519
hvNicType = "nic_type"
1520

    
1521
hvPae :: String
1522
hvPae = "pae"
1523

    
1524
hvPassthrough :: String
1525
hvPassthrough = "pci_pass"
1526

    
1527
hvRebootBehavior :: String
1528
hvRebootBehavior = "reboot_behavior"
1529

    
1530
hvRootPath :: String
1531
hvRootPath = "root_path"
1532

    
1533
hvSecurityDomain :: String
1534
hvSecurityDomain = "security_domain"
1535

    
1536
hvSecurityModel :: String
1537
hvSecurityModel = "security_model"
1538

    
1539
hvSerialConsole :: String
1540
hvSerialConsole = "serial_console"
1541

    
1542
hvSerialSpeed :: String
1543
hvSerialSpeed = "serial_speed"
1544

    
1545
hvSoundhw :: String
1546
hvSoundhw = "soundhw"
1547

    
1548
hvUsbDevices :: String
1549
hvUsbDevices = "usb_devices"
1550

    
1551
hvUsbMouse :: String
1552
hvUsbMouse = "usb_mouse"
1553

    
1554
hvUseBootloader :: String
1555
hvUseBootloader = "use_bootloader"
1556

    
1557
hvUseLocaltime :: String
1558
hvUseLocaltime = "use_localtime"
1559

    
1560
hvVga :: String
1561
hvVga = "vga"
1562

    
1563
hvVhostNet :: String
1564
hvVhostNet = "vhost_net"
1565

    
1566
hvVifScript :: String
1567
hvVifScript = "vif_script"
1568

    
1569
hvVifType :: String
1570
hvVifType = "vif_type"
1571

    
1572
hvViridian :: String
1573
hvViridian = "viridian"
1574

    
1575
hvVncBindAddress :: String
1576
hvVncBindAddress = "vnc_bind_address"
1577

    
1578
hvVncPasswordFile :: String
1579
hvVncPasswordFile = "vnc_password_file"
1580

    
1581
hvVncTls :: String
1582
hvVncTls = "vnc_tls"
1583

    
1584
hvVncX509 :: String
1585
hvVncX509 = "vnc_x509_path"
1586

    
1587
hvVncX509Verify :: String
1588
hvVncX509Verify = "vnc_x509_verify"
1589

    
1590
hvVnetHdr :: String
1591
hvVnetHdr = "vnet_hdr"
1592

    
1593
hvXenCmd :: String
1594
hvXenCmd = "xen_cmd"
1595

    
1596
hvXenCpuid :: String
1597
hvXenCpuid = "cpuid"
1598

    
1599
hvsParameterTitles :: Map String String
1600
hvsParameterTitles =
1601
  Map.fromList
1602
  [(hvAcpi, "ACPI"),
1603
   (hvBootOrder, "Boot_order"),
1604
   (hvCdromImagePath, "CDROM_image_path"),
1605
   (hvCpuType, "cpu_type"),
1606
   (hvDiskType, "Disk_type"),
1607
   (hvInitrdPath, "Initrd_path"),
1608
   (hvKernelPath, "Kernel_path"),
1609
   (hvNicType, "NIC_type"),
1610
   (hvPae, "PAE"),
1611
   (hvPassthrough, "pci_pass"),
1612
   (hvVncBindAddress, "VNC_bind_address")]
1613

    
1614
-- * Migration statuses
1615

    
1616
hvMigrationActive :: String
1617
hvMigrationActive = "active"
1618

    
1619
hvMigrationCancelled :: String
1620
hvMigrationCancelled = "cancelled"
1621

    
1622
hvMigrationCompleted :: String
1623
hvMigrationCompleted = "completed"
1624

    
1625
hvMigrationFailed :: String
1626
hvMigrationFailed = "failed"
1627

    
1628
hvMigrationValidStatuses :: FrozenSet String
1629
hvMigrationValidStatuses =
1630
  ConstantUtils.mkSet [hvMigrationActive,
1631
                       hvMigrationCancelled,
1632
                       hvMigrationCompleted,
1633
                       hvMigrationFailed]
1634

    
1635
hvMigrationFailedStatuses :: FrozenSet String
1636
hvMigrationFailedStatuses =
1637
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1638

    
1639
-- | KVM-specific statuses
1640
--
1641
-- FIXME: this constant seems unnecessary
1642
hvKvmMigrationValidStatuses :: FrozenSet String
1643
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1644

    
1645
-- | Node info keys
1646
hvNodeinfoKeyVersion :: String
1647
hvNodeinfoKeyVersion = "hv_version"
1648

    
1649
-- * Hypervisor state
1650

    
1651
hvstCpuNode :: String
1652
hvstCpuNode = "cpu_node"
1653

    
1654
hvstCpuTotal :: String
1655
hvstCpuTotal = "cpu_total"
1656

    
1657
hvstMemoryHv :: String
1658
hvstMemoryHv = "mem_hv"
1659

    
1660
hvstMemoryNode :: String
1661
hvstMemoryNode = "mem_node"
1662

    
1663
hvstMemoryTotal :: String
1664
hvstMemoryTotal = "mem_total"
1665

    
1666
hvstsParameters :: FrozenSet String
1667
hvstsParameters =
1668
  ConstantUtils.mkSet [hvstCpuNode,
1669
                       hvstCpuTotal,
1670
                       hvstMemoryHv,
1671
                       hvstMemoryNode,
1672
                       hvstMemoryTotal]
1673

    
1674
hvstDefaults :: Map String Int
1675
hvstDefaults =
1676
  Map.fromList
1677
  [(hvstCpuNode, 1),
1678
   (hvstCpuTotal, 1),
1679
   (hvstMemoryHv, 0),
1680
   (hvstMemoryTotal, 0),
1681
   (hvstMemoryNode, 0)]
1682

    
1683
hvstsParameterTypes :: Map String VType
1684
hvstsParameterTypes =
1685
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1686
                (hvstMemoryNode, VTypeInt),
1687
                (hvstMemoryHv, VTypeInt),
1688
                (hvstCpuTotal, VTypeInt),
1689
                (hvstCpuNode, VTypeInt)]
1690

    
1691
-- * Disk state
1692

    
1693
dsDiskOverhead :: String
1694
dsDiskOverhead = "disk_overhead"
1695

    
1696
dsDiskReserved :: String
1697
dsDiskReserved = "disk_reserved"
1698

    
1699
dsDiskTotal :: String
1700
dsDiskTotal = "disk_total"
1701

    
1702
dsDefaults :: Map String Int
1703
dsDefaults =
1704
  Map.fromList
1705
  [(dsDiskTotal, 0),
1706
   (dsDiskReserved, 0),
1707
   (dsDiskOverhead, 0)]
1708

    
1709
dssParameterTypes :: Map String VType
1710
dssParameterTypes =
1711
  Map.fromList [(dsDiskTotal, VTypeInt),
1712
                (dsDiskReserved, VTypeInt),
1713
                (dsDiskOverhead, VTypeInt)]
1714

    
1715
dssParameters :: FrozenSet String
1716
dssParameters =
1717
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1718

    
1719
dsValidTypes :: FrozenSet String
1720
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1721

    
1722
-- Backend parameter names
1723

    
1724
beAlwaysFailover :: String
1725
beAlwaysFailover = "always_failover"
1726

    
1727
beAutoBalance :: String
1728
beAutoBalance = "auto_balance"
1729

    
1730
beMaxmem :: String
1731
beMaxmem = "maxmem"
1732

    
1733
-- | Deprecated and replaced by max and min mem
1734
beMemory :: String
1735
beMemory = "memory"
1736

    
1737
beMinmem :: String
1738
beMinmem = "minmem"
1739

    
1740
beSpindleUse :: String
1741
beSpindleUse = "spindle_use"
1742

    
1743
beVcpus :: String
1744
beVcpus = "vcpus"
1745

    
1746
besParameterTypes :: Map String VType
1747
besParameterTypes =
1748
  Map.fromList [(beAlwaysFailover, VTypeBool),
1749
                (beAutoBalance, VTypeBool),
1750
                (beMaxmem, VTypeSize),
1751
                (beMinmem, VTypeSize),
1752
                (beSpindleUse, VTypeInt),
1753
                (beVcpus, VTypeInt)]
1754

    
1755
besParameterTitles :: Map String String
1756
besParameterTitles =
1757
  Map.fromList [(beAutoBalance, "Auto_balance"),
1758
                (beMinmem, "ConfigMinMem"),
1759
                (beVcpus, "ConfigVCPUs"),
1760
                (beMaxmem, "ConfigMaxMem")]
1761

    
1762
besParameterCompat :: Map String VType
1763
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1764

    
1765
besParameters :: FrozenSet String
1766
besParameters =
1767
  ConstantUtils.mkSet [beAlwaysFailover,
1768
                       beAutoBalance,
1769
                       beMaxmem,
1770
                       beMinmem,
1771
                       beSpindleUse,
1772
                       beVcpus]
1773

    
1774
-- | Instance specs
1775
--
1776
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1777

    
1778
ispecMemSize :: String
1779
ispecMemSize = ConstantUtils.ispecMemSize
1780

    
1781
ispecCpuCount :: String
1782
ispecCpuCount = ConstantUtils.ispecCpuCount
1783

    
1784
ispecDiskCount :: String
1785
ispecDiskCount = ConstantUtils.ispecDiskCount
1786

    
1787
ispecDiskSize :: String
1788
ispecDiskSize = ConstantUtils.ispecDiskSize
1789

    
1790
ispecNicCount :: String
1791
ispecNicCount = ConstantUtils.ispecNicCount
1792

    
1793
ispecSpindleUse :: String
1794
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1795

    
1796
ispecsParameterTypes :: Map String VType
1797
ispecsParameterTypes =
1798
  Map.fromList
1799
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1800
   (ConstantUtils.ispecCpuCount, VTypeInt),
1801
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1802
   (ConstantUtils.ispecMemSize, VTypeInt),
1803
   (ConstantUtils.ispecNicCount, VTypeInt),
1804
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1805

    
1806
ispecsParameters :: FrozenSet String
1807
ispecsParameters =
1808
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1809
                       ConstantUtils.ispecDiskCount,
1810
                       ConstantUtils.ispecDiskSize,
1811
                       ConstantUtils.ispecMemSize,
1812
                       ConstantUtils.ispecNicCount,
1813
                       ConstantUtils.ispecSpindleUse]
1814

    
1815
ispecsMinmax :: String
1816
ispecsMinmax = ConstantUtils.ispecsMinmax
1817

    
1818
ispecsMax :: String
1819
ispecsMax = "max"
1820

    
1821
ispecsMin :: String
1822
ispecsMin = "min"
1823

    
1824
ispecsStd :: String
1825
ispecsStd = ConstantUtils.ispecsStd
1826

    
1827
ipolicyDts :: String
1828
ipolicyDts = ConstantUtils.ipolicyDts
1829

    
1830
ipolicyVcpuRatio :: String
1831
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1832

    
1833
ipolicySpindleRatio :: String
1834
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
1835

    
1836
ispecsMinmaxKeys :: FrozenSet String
1837
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1838

    
1839
ipolicyParameters :: FrozenSet String
1840
ipolicyParameters =
1841
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1842
                       ConstantUtils.ipolicySpindleRatio]
1843

    
1844
ipolicyAllKeys :: FrozenSet String
1845
ipolicyAllKeys =
1846
  ConstantUtils.union ipolicyParameters $
1847
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1848
                       ConstantUtils.ispecsMinmax,
1849
                       ispecsStd]
1850

    
1851
-- | Node parameter names
1852

    
1853
ndExclusiveStorage :: String
1854
ndExclusiveStorage = "exclusive_storage"
1855

    
1856
ndOobProgram :: String
1857
ndOobProgram = "oob_program"
1858

    
1859
ndSpindleCount :: String
1860
ndSpindleCount = "spindle_count"
1861

    
1862
ndOvs :: String
1863
ndOvs = "ovs"
1864

    
1865
ndOvsLink :: String
1866
ndOvsLink = "ovs_link"
1867

    
1868
ndOvsName :: String
1869
ndOvsName = "ovs_name"
1870

    
1871
ndsParameterTypes :: Map String VType
1872
ndsParameterTypes =
1873
  Map.fromList
1874
  [(ndExclusiveStorage, VTypeBool),
1875
   (ndOobProgram, VTypeString),
1876
   (ndOvs, VTypeBool),
1877
   (ndOvsLink, VTypeMaybeString),
1878
   (ndOvsName, VTypeMaybeString),
1879
   (ndSpindleCount, VTypeInt)]
1880

    
1881
ndsParameters :: FrozenSet String
1882
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
1883

    
1884
ndsParameterTitles :: Map String String
1885
ndsParameterTitles =
1886
  Map.fromList
1887
  [(ndExclusiveStorage, "ExclusiveStorage"),
1888
   (ndOobProgram, "OutOfBandProgram"),
1889
   (ndOvs, "OpenvSwitch"),
1890
   (ndOvsLink, "OpenvSwitchLink"),
1891
   (ndOvsName, "OpenvSwitchName"),
1892
   (ndSpindleCount, "SpindleCount")]
1893

    
1894
-- * Logical Disks parameters
1895

    
1896
ldpAccess :: String
1897
ldpAccess = "access"
1898

    
1899
ldpBarriers :: String
1900
ldpBarriers = "disabled-barriers"
1901

    
1902
ldpDefaultMetavg :: String
1903
ldpDefaultMetavg = "default-metavg"
1904

    
1905
ldpDelayTarget :: String
1906
ldpDelayTarget = "c-delay-target"
1907

    
1908
ldpDiskCustom :: String
1909
ldpDiskCustom = "disk-custom"
1910

    
1911
ldpDynamicResync :: String
1912
ldpDynamicResync = "dynamic-resync"
1913

    
1914
ldpFillTarget :: String
1915
ldpFillTarget = "c-fill-target"
1916

    
1917
ldpMaxRate :: String
1918
ldpMaxRate = "c-max-rate"
1919

    
1920
ldpMinRate :: String
1921
ldpMinRate = "c-min-rate"
1922

    
1923
ldpNetCustom :: String
1924
ldpNetCustom = "net-custom"
1925

    
1926
ldpNoMetaFlush :: String
1927
ldpNoMetaFlush = "disable-meta-flush"
1928

    
1929
ldpPlanAhead :: String
1930
ldpPlanAhead = "c-plan-ahead"
1931

    
1932
ldpPool :: String
1933
ldpPool = "pool"
1934

    
1935
ldpProtocol :: String
1936
ldpProtocol = "protocol"
1937

    
1938
ldpResyncRate :: String
1939
ldpResyncRate = "resync-rate"
1940

    
1941
ldpStripes :: String
1942
ldpStripes = "stripes"
1943

    
1944
diskLdTypes :: Map String VType
1945
diskLdTypes =
1946
  Map.fromList
1947
  [(ldpAccess, VTypeString),
1948
   (ldpResyncRate, VTypeInt),
1949
   (ldpStripes, VTypeInt),
1950
   (ldpBarriers, VTypeString),
1951
   (ldpNoMetaFlush, VTypeBool),
1952
   (ldpDefaultMetavg, VTypeString),
1953
   (ldpDiskCustom, VTypeString),
1954
   (ldpNetCustom, VTypeString),
1955
   (ldpProtocol, VTypeString),
1956
   (ldpDynamicResync, VTypeBool),
1957
   (ldpPlanAhead, VTypeInt),
1958
   (ldpFillTarget, VTypeInt),
1959
   (ldpDelayTarget, VTypeInt),
1960
   (ldpMaxRate, VTypeInt),
1961
   (ldpMinRate, VTypeInt),
1962
   (ldpPool, VTypeString)]
1963

    
1964
diskLdParameters :: FrozenSet String
1965
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
1966

    
1967
-- * Disk template parameters
1968
--
1969
-- Disk template parameters can be set/changed by the user via
1970
-- gnt-cluster and gnt-group)
1971

    
1972
drbdResyncRate :: String
1973
drbdResyncRate = "resync-rate"
1974

    
1975
drbdDataStripes :: String
1976
drbdDataStripes = "data-stripes"
1977

    
1978
drbdMetaStripes :: String
1979
drbdMetaStripes = "meta-stripes"
1980

    
1981
drbdDiskBarriers :: String
1982
drbdDiskBarriers = "disk-barriers"
1983

    
1984
drbdMetaBarriers :: String
1985
drbdMetaBarriers = "meta-barriers"
1986

    
1987
drbdDefaultMetavg :: String
1988
drbdDefaultMetavg = "metavg"
1989

    
1990
drbdDiskCustom :: String
1991
drbdDiskCustom = "disk-custom"
1992

    
1993
drbdNetCustom :: String
1994
drbdNetCustom = "net-custom"
1995

    
1996
drbdProtocol :: String
1997
drbdProtocol = "protocol"
1998

    
1999
drbdDynamicResync :: String
2000
drbdDynamicResync = "dynamic-resync"
2001

    
2002
drbdPlanAhead :: String
2003
drbdPlanAhead = "c-plan-ahead"
2004

    
2005
drbdFillTarget :: String
2006
drbdFillTarget = "c-fill-target"
2007

    
2008
drbdDelayTarget :: String
2009
drbdDelayTarget = "c-delay-target"
2010

    
2011
drbdMaxRate :: String
2012
drbdMaxRate = "c-max-rate"
2013

    
2014
drbdMinRate :: String
2015
drbdMinRate = "c-min-rate"
2016

    
2017
lvStripes :: String
2018
lvStripes = "stripes"
2019

    
2020
rbdAccess :: String
2021
rbdAccess = "access"
2022

    
2023
rbdPool :: String
2024
rbdPool = "pool"
2025

    
2026
diskDtTypes :: Map String VType
2027
diskDtTypes =
2028
  Map.fromList [(drbdResyncRate, VTypeInt),
2029
                (drbdDataStripes, VTypeInt),
2030
                (drbdMetaStripes, VTypeInt),
2031
                (drbdDiskBarriers, VTypeString),
2032
                (drbdMetaBarriers, VTypeBool),
2033
                (drbdDefaultMetavg, VTypeString),
2034
                (drbdDiskCustom, VTypeString),
2035
                (drbdNetCustom, VTypeString),
2036
                (drbdProtocol, VTypeString),
2037
                (drbdDynamicResync, VTypeBool),
2038
                (drbdPlanAhead, VTypeInt),
2039
                (drbdFillTarget, VTypeInt),
2040
                (drbdDelayTarget, VTypeInt),
2041
                (drbdMaxRate, VTypeInt),
2042
                (drbdMinRate, VTypeInt),
2043
                (lvStripes, VTypeInt),
2044
                (rbdAccess, VTypeString),
2045
                (rbdPool, VTypeString)]
2046

    
2047
diskDtParameters :: FrozenSet String
2048
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2049

    
2050
-- * Dynamic disk parameters
2051

    
2052
ddpLocalIp :: String
2053
ddpLocalIp = "local-ip"
2054

    
2055
ddpRemoteIp :: String
2056
ddpRemoteIp = "remote-ip"
2057

    
2058
ddpPort :: String
2059
ddpPort = "port"
2060

    
2061
ddpLocalMinor :: String
2062
ddpLocalMinor = "local-minor"
2063

    
2064
ddpRemoteMinor :: String
2065
ddpRemoteMinor = "remote-minor"
2066

    
2067
-- * OOB supported commands
2068

    
2069
oobPowerOn :: String
2070
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2071

    
2072
oobPowerOff :: String
2073
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2074

    
2075
oobPowerCycle :: String
2076
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2077

    
2078
oobPowerStatus :: String
2079
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2080

    
2081
oobHealth :: String
2082
oobHealth = Types.oobCommandToRaw OobHealth
2083

    
2084
oobCommands :: FrozenSet String
2085
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2086

    
2087
oobPowerStatusPowered :: String
2088
oobPowerStatusPowered = "powered"
2089

    
2090
-- | 60 seconds
2091
oobTimeout :: Int
2092
oobTimeout = 60
2093

    
2094
-- | 2 seconds
2095
oobPowerDelay :: Double
2096
oobPowerDelay = 2.0
2097

    
2098
oobStatusCritical :: String
2099
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2100

    
2101
oobStatusOk :: String
2102
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2103

    
2104
oobStatusUnknown :: String
2105
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2106

    
2107
oobStatusWarning :: String
2108
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2109

    
2110
oobStatuses :: FrozenSet String
2111
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2112

    
2113
-- | Instance Parameters Profile
2114
ppDefault :: String
2115
ppDefault = "default"
2116

    
2117
-- * nic* constants are used inside the ganeti config
2118

    
2119
nicLink :: String
2120
nicLink = "link"
2121

    
2122
nicMode :: String
2123
nicMode = "mode"
2124

    
2125
nicVlan :: String
2126
nicVlan = "vlan"
2127

    
2128
nicsParameterTypes :: Map String VType
2129
nicsParameterTypes =
2130
  Map.fromList [(nicMode, vtypeString),
2131
                (nicLink, vtypeString),
2132
                (nicVlan, vtypeMaybeString)]
2133

    
2134
nicsParameters :: FrozenSet String
2135
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2136

    
2137
nicModeBridged :: String
2138
nicModeBridged = Types.nICModeToRaw NMBridged
2139

    
2140
nicModeRouted :: String
2141
nicModeRouted = Types.nICModeToRaw NMRouted
2142

    
2143
nicModeOvs :: String
2144
nicModeOvs = Types.nICModeToRaw NMOvs
2145

    
2146
nicIpPool :: String
2147
nicIpPool = Types.nICModeToRaw NMPool
2148

    
2149
nicValidModes :: FrozenSet String
2150
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2151

    
2152
releaseAction :: String
2153
releaseAction = "release"
2154

    
2155
reserveAction :: String
2156
reserveAction = "reserve"
2157

    
2158
-- * idisk* constants are used in opcodes, to create/change disks
2159

    
2160
idiskAdopt :: String
2161
idiskAdopt = "adopt"
2162

    
2163
idiskMetavg :: String
2164
idiskMetavg = "metavg"
2165

    
2166
idiskMode :: String
2167
idiskMode = "mode"
2168

    
2169
idiskName :: String
2170
idiskName = "name"
2171

    
2172
idiskSize :: String
2173
idiskSize = "size"
2174

    
2175
idiskSpindles :: String
2176
idiskSpindles = "spindles"
2177

    
2178
idiskVg :: String
2179
idiskVg = "vg"
2180

    
2181
idiskProvider :: String
2182
idiskProvider = "provider"
2183

    
2184
idiskParamsTypes :: Map String VType
2185
idiskParamsTypes =
2186
  Map.fromList [(idiskSize, VTypeSize),
2187
                (idiskSpindles, VTypeInt),
2188
                (idiskMode, VTypeString),
2189
                (idiskAdopt, VTypeString),
2190
                (idiskVg, VTypeString),
2191
                (idiskMetavg, VTypeString),
2192
                (idiskProvider, VTypeString),
2193
                (idiskName, VTypeMaybeString)]
2194

    
2195
idiskParams :: FrozenSet String
2196
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2197

    
2198
-- * inic* constants are used in opcodes, to create/change nics
2199

    
2200
inicBridge :: String
2201
inicBridge = "bridge"
2202

    
2203
inicIp :: String
2204
inicIp = "ip"
2205

    
2206
inicLink :: String
2207
inicLink = "link"
2208

    
2209
inicMac :: String
2210
inicMac = "mac"
2211

    
2212
inicMode :: String
2213
inicMode = "mode"
2214

    
2215
inicName :: String
2216
inicName = "name"
2217

    
2218
inicNetwork :: String
2219
inicNetwork = "network"
2220

    
2221
inicVlan :: String
2222
inicVlan = "vlan"
2223

    
2224
inicParamsTypes :: Map String VType
2225
inicParamsTypes =
2226
  Map.fromList [(inicBridge, VTypeMaybeString),
2227
                (inicIp, VTypeMaybeString),
2228
                (inicLink, VTypeString),
2229
                (inicMac, VTypeString),
2230
                (inicMode, VTypeString),
2231
                (inicName, VTypeMaybeString),
2232
                (inicNetwork, VTypeMaybeString),
2233
                (inicVlan, VTypeMaybeString)]
2234

    
2235
inicParams :: FrozenSet String
2236
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2237

    
2238
-- * Hypervisor constants
2239

    
2240
htXenPvm :: String
2241
htXenPvm = Types.hypervisorToRaw XenPvm
2242

    
2243
htFake :: String
2244
htFake = Types.hypervisorToRaw Fake
2245

    
2246
htXenHvm :: String
2247
htXenHvm = Types.hypervisorToRaw XenHvm
2248

    
2249
htKvm :: String
2250
htKvm = Types.hypervisorToRaw Kvm
2251

    
2252
htChroot :: String
2253
htChroot = Types.hypervisorToRaw Chroot
2254

    
2255
htLxc :: String
2256
htLxc = Types.hypervisorToRaw Lxc
2257

    
2258
hyperTypes :: FrozenSet String
2259
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2260

    
2261
htsReqPort :: FrozenSet String
2262
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2263

    
2264
vncBasePort :: Int
2265
vncBasePort = 5900
2266

    
2267
vncDefaultBindAddress :: String
2268
vncDefaultBindAddress = ip4AddressAny
2269

    
2270
-- * NIC types
2271

    
2272
htNicE1000 :: String
2273
htNicE1000 = "e1000"
2274

    
2275
htNicI82551 :: String
2276
htNicI82551 = "i82551"
2277

    
2278
htNicI8259er :: String
2279
htNicI8259er = "i82559er"
2280

    
2281
htNicI85557b :: String
2282
htNicI85557b = "i82557b"
2283

    
2284
htNicNe2kIsa :: String
2285
htNicNe2kIsa = "ne2k_isa"
2286

    
2287
htNicNe2kPci :: String
2288
htNicNe2kPci = "ne2k_pci"
2289

    
2290
htNicParavirtual :: String
2291
htNicParavirtual = "paravirtual"
2292

    
2293
htNicPcnet :: String
2294
htNicPcnet = "pcnet"
2295

    
2296
htNicRtl8139 :: String
2297
htNicRtl8139 = "rtl8139"
2298

    
2299
htHvmValidNicTypes :: FrozenSet String
2300
htHvmValidNicTypes =
2301
  ConstantUtils.mkSet [htNicE1000,
2302
                       htNicNe2kIsa,
2303
                       htNicNe2kPci,
2304
                       htNicParavirtual,
2305
                       htNicRtl8139]
2306

    
2307
htKvmValidNicTypes :: FrozenSet String
2308
htKvmValidNicTypes =
2309
  ConstantUtils.mkSet [htNicE1000,
2310
                       htNicI82551,
2311
                       htNicI8259er,
2312
                       htNicI85557b,
2313
                       htNicNe2kIsa,
2314
                       htNicNe2kPci,
2315
                       htNicParavirtual,
2316
                       htNicPcnet,
2317
                       htNicRtl8139]
2318

    
2319
-- * Vif types
2320

    
2321
-- | Default vif type in xen-hvm
2322
htHvmVifIoemu :: String
2323
htHvmVifIoemu = "ioemu"
2324

    
2325
htHvmVifVif :: String
2326
htHvmVifVif = "vif"
2327

    
2328
htHvmValidVifTypes :: FrozenSet String
2329
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2330

    
2331
-- * Disk types
2332

    
2333
htDiskIde :: String
2334
htDiskIde = "ide"
2335

    
2336
htDiskIoemu :: String
2337
htDiskIoemu = "ioemu"
2338

    
2339
htDiskMtd :: String
2340
htDiskMtd = "mtd"
2341

    
2342
htDiskParavirtual :: String
2343
htDiskParavirtual = "paravirtual"
2344

    
2345
htDiskPflash :: String
2346
htDiskPflash = "pflash"
2347

    
2348
htDiskScsi :: String
2349
htDiskScsi = "scsi"
2350

    
2351
htDiskSd :: String
2352
htDiskSd = "sd"
2353

    
2354
htHvmValidDiskTypes :: FrozenSet String
2355
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2356

    
2357
htKvmValidDiskTypes :: FrozenSet String
2358
htKvmValidDiskTypes =
2359
  ConstantUtils.mkSet [htDiskIde,
2360
                       htDiskMtd,
2361
                       htDiskParavirtual,
2362
                       htDiskPflash,
2363
                       htDiskScsi,
2364
                       htDiskSd]
2365

    
2366
htCacheDefault :: String
2367
htCacheDefault = "default"
2368

    
2369
htCacheNone :: String
2370
htCacheNone = "none"
2371

    
2372
htCacheWback :: String
2373
htCacheWback = "writeback"
2374

    
2375
htCacheWthrough :: String
2376
htCacheWthrough = "writethrough"
2377

    
2378
htValidCacheTypes :: FrozenSet String
2379
htValidCacheTypes =
2380
  ConstantUtils.mkSet [htCacheDefault,
2381
                       htCacheNone,
2382
                       htCacheWback,
2383
                       htCacheWthrough]
2384

    
2385
-- * Mouse types
2386

    
2387
htMouseMouse :: String
2388
htMouseMouse = "mouse"
2389

    
2390
htMouseTablet :: String
2391
htMouseTablet = "tablet"
2392

    
2393
htKvmValidMouseTypes :: FrozenSet String
2394
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2395

    
2396
-- * Boot order
2397

    
2398
htBoCdrom :: String
2399
htBoCdrom = "cdrom"
2400

    
2401
htBoDisk :: String
2402
htBoDisk = "disk"
2403

    
2404
htBoFloppy :: String
2405
htBoFloppy = "floppy"
2406

    
2407
htBoNetwork :: String
2408
htBoNetwork = "network"
2409

    
2410
htKvmValidBoTypes :: FrozenSet String
2411
htKvmValidBoTypes =
2412
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2413

    
2414
-- * SPICE lossless image compression options
2415

    
2416
htKvmSpiceLosslessImgComprAutoGlz :: String
2417
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2418

    
2419
htKvmSpiceLosslessImgComprAutoLz :: String
2420
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2421

    
2422
htKvmSpiceLosslessImgComprGlz :: String
2423
htKvmSpiceLosslessImgComprGlz = "glz"
2424

    
2425
htKvmSpiceLosslessImgComprLz :: String
2426
htKvmSpiceLosslessImgComprLz = "lz"
2427

    
2428
htKvmSpiceLosslessImgComprOff :: String
2429
htKvmSpiceLosslessImgComprOff = "off"
2430

    
2431
htKvmSpiceLosslessImgComprQuic :: String
2432
htKvmSpiceLosslessImgComprQuic = "quic"
2433

    
2434
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2435
htKvmSpiceValidLosslessImgComprOptions =
2436
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2437
                       htKvmSpiceLosslessImgComprAutoLz,
2438
                       htKvmSpiceLosslessImgComprGlz,
2439
                       htKvmSpiceLosslessImgComprLz,
2440
                       htKvmSpiceLosslessImgComprOff,
2441
                       htKvmSpiceLosslessImgComprQuic]
2442

    
2443
htKvmSpiceLossyImgComprAlways :: String
2444
htKvmSpiceLossyImgComprAlways = "always"
2445

    
2446
htKvmSpiceLossyImgComprAuto :: String
2447
htKvmSpiceLossyImgComprAuto = "auto"
2448

    
2449
htKvmSpiceLossyImgComprNever :: String
2450
htKvmSpiceLossyImgComprNever = "never"
2451

    
2452
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2453
htKvmSpiceValidLossyImgComprOptions =
2454
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2455
                       htKvmSpiceLossyImgComprAuto,
2456
                       htKvmSpiceLossyImgComprNever]
2457

    
2458
-- * SPICE video stream detection
2459

    
2460
htKvmSpiceVideoStreamDetectionAll :: String
2461
htKvmSpiceVideoStreamDetectionAll = "all"
2462

    
2463
htKvmSpiceVideoStreamDetectionFilter :: String
2464
htKvmSpiceVideoStreamDetectionFilter = "filter"
2465

    
2466
htKvmSpiceVideoStreamDetectionOff :: String
2467
htKvmSpiceVideoStreamDetectionOff = "off"
2468

    
2469
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2470
htKvmSpiceValidVideoStreamDetectionOptions =
2471
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2472
                       htKvmSpiceVideoStreamDetectionFilter,
2473
                       htKvmSpiceVideoStreamDetectionOff]
2474

    
2475
-- * Security models
2476

    
2477
htSmNone :: String
2478
htSmNone = "none"
2479

    
2480
htSmPool :: String
2481
htSmPool = "pool"
2482

    
2483
htSmUser :: String
2484
htSmUser = "user"
2485

    
2486
htKvmValidSmTypes :: FrozenSet String
2487
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2488

    
2489
-- * Kvm flag values
2490

    
2491
htKvmDisabled :: String
2492
htKvmDisabled = "disabled"
2493

    
2494
htKvmEnabled :: String
2495
htKvmEnabled = "enabled"
2496

    
2497
htKvmFlagValues :: FrozenSet String
2498
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2499

    
2500
-- * Migration type
2501

    
2502
htMigrationLive :: String
2503
htMigrationLive = Types.migrationModeToRaw MigrationLive
2504

    
2505
htMigrationNonlive :: String
2506
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2507

    
2508
htMigrationModes :: FrozenSet String
2509
htMigrationModes =
2510
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2511

    
2512
-- * Cluster verify steps
2513

    
2514
verifyNplusoneMem :: String
2515
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2516

    
2517
verifyOptionalChecks :: FrozenSet String
2518
verifyOptionalChecks =
2519
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2520

    
2521
-- * Cluster Verify error classes
2522

    
2523
cvTcluster :: String
2524
cvTcluster = "cluster"
2525

    
2526
cvTgroup :: String
2527
cvTgroup = "group"
2528

    
2529
cvTnode :: String
2530
cvTnode = "node"
2531

    
2532
cvTinstance :: String
2533
cvTinstance = "instance"
2534

    
2535
-- * Cluster Verify error codes and documentation
2536

    
2537
cvEclustercert :: (String, String, String)
2538
cvEclustercert =
2539
  ("cluster",
2540
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2541
   "Cluster certificate files verification failure")
2542

    
2543
cvEclustercfg :: (String, String, String)
2544
cvEclustercfg =
2545
  ("cluster",
2546
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2547
   "Cluster configuration verification failure")
2548

    
2549
cvEclusterdanglinginst :: (String, String, String)
2550
cvEclusterdanglinginst =
2551
  ("node",
2552
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2553
   "Some instances have a non-existing primary node")
2554

    
2555
cvEclusterdanglingnodes :: (String, String, String)
2556
cvEclusterdanglingnodes =
2557
  ("node",
2558
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2559
   "Some nodes belong to non-existing groups")
2560

    
2561
cvEclusterfilecheck :: (String, String, String)
2562
cvEclusterfilecheck =
2563
  ("cluster",
2564
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2565
   "Cluster configuration verification failure")
2566

    
2567
cvEgroupdifferentpvsize :: (String, String, String)
2568
cvEgroupdifferentpvsize =
2569
  ("group",
2570
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2571
   "PVs in the group have different sizes")
2572

    
2573
cvEinstancebadnode :: (String, String, String)
2574
cvEinstancebadnode =
2575
  ("instance",
2576
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2577
   "Instance marked as running lives on an offline node")
2578

    
2579
cvEinstancedown :: (String, String, String)
2580
cvEinstancedown =
2581
  ("instance",
2582
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2583
   "Instance not running on its primary node")
2584

    
2585
cvEinstancefaultydisk :: (String, String, String)
2586
cvEinstancefaultydisk =
2587
  ("instance",
2588
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2589
   "Impossible to retrieve status for a disk")
2590

    
2591
cvEinstancelayout :: (String, String, String)
2592
cvEinstancelayout =
2593
  ("instance",
2594
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2595
   "Instance has multiple secondary nodes")
2596

    
2597
cvEinstancemissingcfgparameter :: (String, String, String)
2598
cvEinstancemissingcfgparameter =
2599
  ("instance",
2600
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2601
   "A configuration parameter for an instance is missing")
2602

    
2603
cvEinstancemissingdisk :: (String, String, String)
2604
cvEinstancemissingdisk =
2605
  ("instance",
2606
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2607
   "Missing volume on an instance")
2608

    
2609
cvEinstancepolicy :: (String, String, String)
2610
cvEinstancepolicy =
2611
  ("instance",
2612
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2613
   "Instance does not meet policy")
2614

    
2615
cvEinstancesplitgroups :: (String, String, String)
2616
cvEinstancesplitgroups =
2617
  ("instance",
2618
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2619
   "Instance with primary and secondary nodes in different groups")
2620

    
2621
cvEinstanceunsuitablenode :: (String, String, String)
2622
cvEinstanceunsuitablenode =
2623
  ("instance",
2624
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2625
   "Instance running on nodes that are not suitable for it")
2626

    
2627
cvEinstancewrongnode :: (String, String, String)
2628
cvEinstancewrongnode =
2629
  ("instance",
2630
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2631
   "Instance running on the wrong node")
2632

    
2633
cvEnodedrbd :: (String, String, String)
2634
cvEnodedrbd =
2635
  ("node",
2636
   Types.cVErrorCodeToRaw CvENODEDRBD,
2637
   "Error parsing the DRBD status file")
2638

    
2639
cvEnodedrbdhelper :: (String, String, String)
2640
cvEnodedrbdhelper =
2641
  ("node",
2642
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2643
   "Error caused by the DRBD helper")
2644

    
2645
cvEnodedrbdversion :: (String, String, String)
2646
cvEnodedrbdversion =
2647
  ("node",
2648
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2649
   "DRBD version mismatch within a node group")
2650

    
2651
cvEnodefilecheck :: (String, String, String)
2652
cvEnodefilecheck =
2653
  ("node",
2654
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2655
   "Error retrieving the checksum of the node files")
2656

    
2657
cvEnodefilestoragepaths :: (String, String, String)
2658
cvEnodefilestoragepaths =
2659
  ("node",
2660
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2661
   "Detected bad file storage paths")
2662

    
2663
cvEnodefilestoragepathunusable :: (String, String, String)
2664
cvEnodefilestoragepathunusable =
2665
  ("node",
2666
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2667
   "File storage path unusable")
2668

    
2669
cvEnodehooks :: (String, String, String)
2670
cvEnodehooks =
2671
  ("node",
2672
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2673
   "Communication failure in hooks execution")
2674

    
2675
cvEnodehv :: (String, String, String)
2676
cvEnodehv =
2677
  ("node",
2678
   Types.cVErrorCodeToRaw CvENODEHV,
2679
   "Hypervisor parameters verification failure")
2680

    
2681
cvEnodelvm :: (String, String, String)
2682
cvEnodelvm =
2683
  ("node",
2684
   Types.cVErrorCodeToRaw CvENODELVM,
2685
   "LVM-related node error")
2686

    
2687
cvEnoden1 :: (String, String, String)
2688
cvEnoden1 =
2689
  ("node",
2690
   Types.cVErrorCodeToRaw CvENODEN1,
2691
   "Not enough memory to accommodate instance failovers")
2692

    
2693
cvEnodenet :: (String, String, String)
2694
cvEnodenet =
2695
  ("node",
2696
   Types.cVErrorCodeToRaw CvENODENET,
2697
   "Network-related node error")
2698

    
2699
cvEnodeoobpath :: (String, String, String)
2700
cvEnodeoobpath =
2701
  ("node",
2702
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2703
   "Invalid Out Of Band path")
2704

    
2705
cvEnodeorphaninstance :: (String, String, String)
2706
cvEnodeorphaninstance =
2707
  ("node",
2708
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2709
   "Unknown intance running on a node")
2710

    
2711
cvEnodeorphanlv :: (String, String, String)
2712
cvEnodeorphanlv =
2713
  ("node",
2714
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2715
   "Unknown LVM logical volume")
2716

    
2717
cvEnodeos :: (String, String, String)
2718
cvEnodeos =
2719
  ("node",
2720
   Types.cVErrorCodeToRaw CvENODEOS,
2721
   "OS-related node error")
2722

    
2723
cvEnoderpc :: (String, String, String)
2724
cvEnoderpc =
2725
  ("node",
2726
   Types.cVErrorCodeToRaw CvENODERPC,
2727
   "Error during connection to the primary node of an instance")
2728

    
2729
cvEnodesetup :: (String, String, String)
2730
cvEnodesetup =
2731
  ("node",
2732
   Types.cVErrorCodeToRaw CvENODESETUP,
2733
   "Node setup error")
2734

    
2735
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2736
cvEnodesharedfilestoragepathunusable =
2737
  ("node",
2738
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2739
   "Shared file storage path unusable")
2740

    
2741
cvEnodessh :: (String, String, String)
2742
cvEnodessh =
2743
  ("node",
2744
   Types.cVErrorCodeToRaw CvENODESSH,
2745
   "SSH-related node error")
2746

    
2747
cvEnodetime :: (String, String, String)
2748
cvEnodetime =
2749
  ("node",
2750
   Types.cVErrorCodeToRaw CvENODETIME,
2751
   "Node returned invalid time")
2752

    
2753
cvEnodeuserscripts :: (String, String, String)
2754
cvEnodeuserscripts =
2755
  ("node",
2756
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2757
   "User scripts not present or not executable")
2758

    
2759
cvEnodeversion :: (String, String, String)
2760
cvEnodeversion =
2761
  ("node",
2762
   Types.cVErrorCodeToRaw CvENODEVERSION,
2763
   "Protocol version mismatch or Ganeti version mismatch")
2764

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

    
2807
cvAllEcodesStrings :: FrozenSet String
2808
cvAllEcodesStrings =
2809
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2810

    
2811
-- * Node verify constants
2812

    
2813
nvBridges :: String
2814
nvBridges = "bridges"
2815

    
2816
nvDrbdhelper :: String
2817
nvDrbdhelper = "drbd-helper"
2818

    
2819
nvDrbdversion :: String
2820
nvDrbdversion = "drbd-version"
2821

    
2822
nvDrbdlist :: String
2823
nvDrbdlist = "drbd-list"
2824

    
2825
nvExclusivepvs :: String
2826
nvExclusivepvs = "exclusive-pvs"
2827

    
2828
nvFilelist :: String
2829
nvFilelist = "filelist"
2830

    
2831
nvAcceptedStoragePaths :: String
2832
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2833

    
2834
nvFileStoragePath :: String
2835
nvFileStoragePath = "file-storage-path"
2836

    
2837
nvSharedFileStoragePath :: String
2838
nvSharedFileStoragePath = "shared-file-storage-path"
2839

    
2840
nvHvinfo :: String
2841
nvHvinfo = "hvinfo"
2842

    
2843
nvHvparams :: String
2844
nvHvparams = "hvparms"
2845

    
2846
nvHypervisor :: String
2847
nvHypervisor = "hypervisor"
2848

    
2849
nvInstancelist :: String
2850
nvInstancelist = "instancelist"
2851

    
2852
nvLvlist :: String
2853
nvLvlist = "lvlist"
2854

    
2855
nvMasterip :: String
2856
nvMasterip = "master-ip"
2857

    
2858
nvNodelist :: String
2859
nvNodelist = "nodelist"
2860

    
2861
nvNodenettest :: String
2862
nvNodenettest = "node-net-test"
2863

    
2864
nvNodesetup :: String
2865
nvNodesetup = "nodesetup"
2866

    
2867
nvOobPaths :: String
2868
nvOobPaths = "oob-paths"
2869

    
2870
nvOslist :: String
2871
nvOslist = "oslist"
2872

    
2873
nvPvlist :: String
2874
nvPvlist = "pvlist"
2875

    
2876
nvTime :: String
2877
nvTime = "time"
2878

    
2879
nvUserscripts :: String
2880
nvUserscripts = "user-scripts"
2881

    
2882
nvVersion :: String
2883
nvVersion = "version"
2884

    
2885
nvVglist :: String
2886
nvVglist = "vglist"
2887

    
2888
nvVmnodes :: String
2889
nvVmnodes = "vmnodes"
2890

    
2891
-- * Instance status
2892

    
2893
inststAdmindown :: String
2894
inststAdmindown = Types.instanceStatusToRaw StatusDown
2895

    
2896
inststAdminoffline :: String
2897
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
2898

    
2899
inststErrordown :: String
2900
inststErrordown = Types.instanceStatusToRaw ErrorDown
2901

    
2902
inststErrorup :: String
2903
inststErrorup = Types.instanceStatusToRaw ErrorUp
2904

    
2905
inststNodedown :: String
2906
inststNodedown = Types.instanceStatusToRaw NodeDown
2907

    
2908
inststNodeoffline :: String
2909
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
2910

    
2911
inststRunning :: String
2912
inststRunning = Types.instanceStatusToRaw Running
2913

    
2914
inststWrongnode :: String
2915
inststWrongnode = Types.instanceStatusToRaw WrongNode
2916

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

    
2920
-- * Admin states
2921

    
2922
adminstDown :: String
2923
adminstDown = Types.adminStateToRaw AdminDown
2924

    
2925
adminstOffline :: String
2926
adminstOffline = Types.adminStateToRaw AdminOffline
2927

    
2928
adminstUp :: String
2929
adminstUp = Types.adminStateToRaw AdminUp
2930

    
2931
adminstAll :: FrozenSet String
2932
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
2933

    
2934
-- * Node roles
2935

    
2936
nrDrained :: String
2937
nrDrained = Types.nodeRoleToRaw NRDrained
2938

    
2939
nrMaster :: String
2940
nrMaster = Types.nodeRoleToRaw NRMaster
2941

    
2942
nrMcandidate :: String
2943
nrMcandidate = Types.nodeRoleToRaw NRCandidate
2944

    
2945
nrOffline :: String
2946
nrOffline = Types.nodeRoleToRaw NROffline
2947

    
2948
nrRegular :: String
2949
nrRegular = Types.nodeRoleToRaw NRRegular
2950

    
2951
nrAll :: FrozenSet String
2952
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
2953

    
2954
-- * SSL certificate check constants (in days)
2955

    
2956
sslCertExpirationError :: Int
2957
sslCertExpirationError = 7
2958

    
2959
sslCertExpirationWarn :: Int
2960
sslCertExpirationWarn = 30
2961

    
2962
-- * Allocator framework constants
2963

    
2964
iallocatorVersion :: Int
2965
iallocatorVersion = 2
2966

    
2967
iallocatorDirIn :: String
2968
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
2969

    
2970
iallocatorDirOut :: String
2971
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
2972

    
2973
validIallocatorDirections :: FrozenSet String
2974
validIallocatorDirections =
2975
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
2976

    
2977
iallocatorModeAlloc :: String
2978
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
2979

    
2980
iallocatorModeChgGroup :: String
2981
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
2982

    
2983
iallocatorModeMultiAlloc :: String
2984
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
2985

    
2986
iallocatorModeNodeEvac :: String
2987
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
2988

    
2989
iallocatorModeReloc :: String
2990
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
2991

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

    
2996
iallocatorSearchPath :: [String]
2997
iallocatorSearchPath = AutoConf.iallocatorSearchPath
2998

    
2999
defaultIallocatorShortcut :: String
3000
defaultIallocatorShortcut = "."
3001

    
3002
-- * Node evacuation
3003

    
3004
nodeEvacPri :: String
3005
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3006

    
3007
nodeEvacSec :: String
3008
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3009

    
3010
nodeEvacAll :: String
3011
nodeEvacAll = Types.evacModeToRaw ChangeAll
3012

    
3013
nodeEvacModes :: FrozenSet String
3014
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3015

    
3016
-- * Job queue
3017

    
3018
jobQueueVersion :: Int
3019
jobQueueVersion = 1
3020

    
3021
jobQueueSizeHardLimit :: Int
3022
jobQueueSizeHardLimit = 5000
3023

    
3024
jobQueueFilesPerms :: Int
3025
jobQueueFilesPerms = 0o640
3026

    
3027
-- * Unchanged job return
3028

    
3029
jobNotchanged :: String
3030
jobNotchanged = "nochange"
3031

    
3032
-- * Job status
3033

    
3034
jobStatusQueued :: String
3035
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3036

    
3037
jobStatusWaiting :: String
3038
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3039

    
3040
jobStatusCanceling :: String
3041
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3042

    
3043
jobStatusRunning :: String
3044
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3045

    
3046
jobStatusCanceled :: String
3047
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3048

    
3049
jobStatusSuccess :: String
3050
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3051

    
3052
jobStatusError :: String
3053
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3054

    
3055
jobsPending :: FrozenSet String
3056
jobsPending =
3057
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3058

    
3059
jobsFinalized :: FrozenSet String
3060
jobsFinalized =
3061
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3062

    
3063
jobStatusAll :: FrozenSet String
3064
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3065

    
3066
-- * OpCode status
3067

    
3068
-- ** Not yet finalized opcodes
3069

    
3070
opStatusCanceling :: String
3071
opStatusCanceling = "canceling"
3072

    
3073
opStatusQueued :: String
3074
opStatusQueued = "queued"
3075

    
3076
opStatusRunning :: String
3077
opStatusRunning = "running"
3078

    
3079
opStatusWaiting :: String
3080
opStatusWaiting = "waiting"
3081

    
3082
-- ** Finalized opcodes
3083

    
3084
opStatusCanceled :: String
3085
opStatusCanceled = "canceled"
3086

    
3087
opStatusError :: String
3088
opStatusError = "error"
3089

    
3090
opStatusSuccess :: String
3091
opStatusSuccess = "success"
3092

    
3093
opsFinalized :: FrozenSet String
3094
opsFinalized =
3095
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3096

    
3097
-- * OpCode priority
3098

    
3099
opPrioLowest :: Int
3100
opPrioLowest = 19
3101

    
3102
opPrioHighest :: Int
3103
opPrioHighest = -20
3104

    
3105
opPrioLow :: Int
3106
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3107

    
3108
opPrioNormal :: Int
3109
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3110

    
3111
opPrioHigh :: Int
3112
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3113

    
3114
opPrioSubmitValid :: FrozenSet Int
3115
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3116

    
3117
opPrioDefault :: Int
3118
opPrioDefault = opPrioNormal
3119

    
3120
-- * Lock recalculate mode
3121

    
3122
locksAppend :: String
3123
locksAppend = "append"
3124

    
3125
locksReplace :: String
3126
locksReplace = "replace"
3127

    
3128
-- * Lock timeout
3129
--
3130
-- The lock timeout (sum) before we transition into blocking acquire
3131
-- (this can still be reset by priority change).  Computed as max time
3132
-- (10 hours) before we should actually go into blocking acquire,
3133
-- given that we start from the default priority level.
3134

    
3135
lockAttemptsMaxwait :: Double
3136
lockAttemptsMaxwait = 15.0
3137

    
3138
lockAttemptsMinwait :: Double
3139
lockAttemptsMinwait = 1.0
3140

    
3141
lockAttemptsTimeout :: Int
3142
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3143

    
3144
-- * Execution log types
3145

    
3146
elogMessage :: String
3147
elogMessage = Types.eLogTypeToRaw ELogMessage
3148

    
3149
elogRemoteImport :: String
3150
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3151

    
3152
elogJqueueTest :: String
3153
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3154

    
3155
-- * /etc/hosts modification
3156

    
3157
etcHostsAdd :: String
3158
etcHostsAdd = "add"
3159

    
3160
etcHostsRemove :: String
3161
etcHostsRemove = "remove"
3162

    
3163
-- * Job queue test
3164

    
3165
jqtMsgprefix :: String
3166
jqtMsgprefix = "TESTMSG="
3167

    
3168
jqtExec :: String
3169
jqtExec = "exec"
3170

    
3171
jqtExpandnames :: String
3172
jqtExpandnames = "expandnames"
3173

    
3174
jqtLogmsg :: String
3175
jqtLogmsg = "logmsg"
3176

    
3177
jqtStartmsg :: String
3178
jqtStartmsg = "startmsg"
3179

    
3180
jqtAll :: FrozenSet String
3181
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3182

    
3183
-- * Query resources
3184

    
3185
qrCluster :: String
3186
qrCluster = "cluster"
3187

    
3188
qrExport :: String
3189
qrExport = "export"
3190

    
3191
qrExtstorage :: String
3192
qrExtstorage = "extstorage"
3193

    
3194
qrGroup :: String
3195
qrGroup = "group"
3196

    
3197
qrInstance :: String
3198
qrInstance = "instance"
3199

    
3200
qrJob :: String
3201
qrJob = "job"
3202

    
3203
qrLock :: String
3204
qrLock = "lock"
3205

    
3206
qrNetwork :: String
3207
qrNetwork = "network"
3208

    
3209
qrNode :: String
3210
qrNode = "node"
3211

    
3212
qrOs :: String
3213
qrOs = "os"
3214

    
3215
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3216
qrViaOp :: FrozenSet String
3217
qrViaOp =
3218
  ConstantUtils.mkSet [qrCluster,
3219
                       qrInstance,
3220
                       qrNode,
3221
                       qrGroup,
3222
                       qrOs,
3223
                       qrExport,
3224
                       qrNetwork,
3225
                       qrExtstorage]
3226

    
3227
-- | List of resources which can be queried using Local UniX Interface
3228
qrViaLuxi :: FrozenSet String
3229
qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob]
3230

    
3231
-- | List of resources which can be queried using RAPI
3232
qrViaRapi :: FrozenSet String
3233
qrViaRapi = qrViaLuxi
3234

    
3235
-- * Query field types
3236

    
3237
qftBool :: String
3238
qftBool = "bool"
3239

    
3240
qftNumber :: String
3241
qftNumber = "number"
3242

    
3243
qftOther :: String
3244
qftOther = "other"
3245

    
3246
qftText :: String
3247
qftText = "text"
3248

    
3249
qftTimestamp :: String
3250
qftTimestamp = "timestamp"
3251

    
3252
qftUnit :: String
3253
qftUnit = "unit"
3254

    
3255
qftUnknown :: String
3256
qftUnknown = "unknown"
3257

    
3258
qftAll :: FrozenSet String
3259
qftAll =
3260
  ConstantUtils.mkSet [qftBool,
3261
                       qftNumber,
3262
                       qftOther,
3263
                       qftText,
3264
                       qftTimestamp,
3265
                       qftUnit,
3266
                       qftUnknown]
3267

    
3268
-- * Query result field status
3269
--
3270
-- Don't change or reuse values as they're used by clients.
3271
--
3272
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3273

    
3274
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3275
rsNodata :: Int
3276
rsNodata = 2
3277

    
3278
rsNormal :: Int
3279
rsNormal = 0
3280

    
3281
-- | Resource marked offline
3282
rsOffline :: Int
3283
rsOffline = 4
3284

    
3285
-- | Value unavailable/unsupported for item; if this field is
3286
-- supported but we cannot get the data for the moment, 'rsNodata' or
3287
-- 'rsOffline' should be used
3288
rsUnavail :: Int
3289
rsUnavail = 3
3290

    
3291
rsUnknown :: Int
3292
rsUnknown = 1
3293

    
3294
rsAll :: FrozenSet Int
3295
rsAll =
3296
  ConstantUtils.mkSet [rsNodata,
3297
                       rsNormal,
3298
                       rsOffline,
3299
                       rsUnavail,
3300
                       rsUnknown]
3301

    
3302
-- | Special field cases and their verbose/terse formatting
3303
rssDescription :: Map Int (String, String)
3304
rssDescription =
3305
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3306
                (rsNodata, ("(nodata)", "?")),
3307
                (rsOffline, ("(offline)", "*")),
3308
                (rsUnavail, ("(unavail)", "-"))]
3309

    
3310
-- * Max dynamic devices
3311

    
3312
maxDisks :: Int
3313
maxDisks = Types.maxDisks
3314

    
3315
maxNics :: Int
3316
maxNics = Types.maxNics
3317

    
3318
-- | SSCONF file prefix
3319
ssconfFileprefix :: String
3320
ssconfFileprefix = "ssconf_"
3321

    
3322
-- * SSCONF keys
3323

    
3324
ssClusterName :: String
3325
ssClusterName = "cluster_name"
3326

    
3327
ssClusterTags :: String
3328
ssClusterTags = "cluster_tags"
3329

    
3330
ssFileStorageDir :: String
3331
ssFileStorageDir = "file_storage_dir"
3332

    
3333
ssSharedFileStorageDir :: String
3334
ssSharedFileStorageDir = "shared_file_storage_dir"
3335

    
3336
ssMasterCandidates :: String
3337
ssMasterCandidates = "master_candidates"
3338

    
3339
ssMasterCandidatesIps :: String
3340
ssMasterCandidatesIps = "master_candidates_ips"
3341

    
3342
ssMasterIp :: String
3343
ssMasterIp = "master_ip"
3344

    
3345
ssMasterNetdev :: String
3346
ssMasterNetdev = "master_netdev"
3347

    
3348
ssMasterNetmask :: String
3349
ssMasterNetmask = "master_netmask"
3350

    
3351
ssMasterNode :: String
3352
ssMasterNode = "master_node"
3353

    
3354
ssNodeList :: String
3355
ssNodeList = "node_list"
3356

    
3357
ssNodePrimaryIps :: String
3358
ssNodePrimaryIps = "node_primary_ips"
3359

    
3360
ssNodeSecondaryIps :: String
3361
ssNodeSecondaryIps = "node_secondary_ips"
3362

    
3363
ssOfflineNodes :: String
3364
ssOfflineNodes = "offline_nodes"
3365

    
3366
ssOnlineNodes :: String
3367
ssOnlineNodes = "online_nodes"
3368

    
3369
ssPrimaryIpFamily :: String
3370
ssPrimaryIpFamily = "primary_ip_family"
3371

    
3372
ssInstanceList :: String
3373
ssInstanceList = "instance_list"
3374

    
3375
ssReleaseVersion :: String
3376
ssReleaseVersion = "release_version"
3377

    
3378
ssHypervisorList :: String
3379
ssHypervisorList = "hypervisor_list"
3380

    
3381
ssMaintainNodeHealth :: String
3382
ssMaintainNodeHealth = "maintain_node_health"
3383

    
3384
ssUidPool :: String
3385
ssUidPool = "uid_pool"
3386

    
3387
ssNodegroups :: String
3388
ssNodegroups = "nodegroups"
3389

    
3390
ssNetworks :: String
3391
ssNetworks = "networks"
3392

    
3393
-- | This is not a complete SSCONF key, but the prefix for the
3394
-- hypervisor keys
3395
ssHvparamsPref :: String
3396
ssHvparamsPref = "hvparams_"
3397

    
3398
-- * Hvparams keys
3399

    
3400
ssHvparamsXenChroot :: String
3401
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3402

    
3403
ssHvparamsXenFake :: String
3404
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3405

    
3406
ssHvparamsXenHvm :: String
3407
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3408

    
3409
ssHvparamsXenKvm :: String
3410
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3411

    
3412
ssHvparamsXenLxc :: String
3413
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3414

    
3415
ssHvparamsXenPvm :: String
3416
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3417

    
3418
validSsHvparamsKeys :: FrozenSet String
3419
validSsHvparamsKeys =
3420
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3421
                       ssHvparamsXenLxc,
3422
                       ssHvparamsXenFake,
3423
                       ssHvparamsXenHvm,
3424
                       ssHvparamsXenKvm,
3425
                       ssHvparamsXenPvm]
3426

    
3427
ssFilePerms :: Int
3428
ssFilePerms = 0o444
3429

    
3430
-- | Cluster wide default parameters
3431
defaultEnabledHypervisor :: String
3432
defaultEnabledHypervisor = htXenPvm
3433

    
3434
hvcGlobals :: FrozenSet String
3435
hvcGlobals =
3436
  ConstantUtils.mkSet [hvMigrationBandwidth,
3437
                       hvMigrationMode,
3438
                       hvMigrationPort,
3439
                       hvXenCmd]
3440

    
3441
ndcGlobals :: FrozenSet String
3442
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3443

    
3444
-- | All of the following values are quite arbitrary - there are no
3445
-- "good" defaults, these must be customised per-site
3446
ispecsMinmaxDefaults :: Map String (Map String Int)
3447
ispecsMinmaxDefaults =
3448
  Map.fromList
3449
  [(ispecsMin,
3450
    Map.fromList
3451
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3452
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3453
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3454
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3455
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3456
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3457
   (ispecsMax,
3458
    Map.fromList
3459
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3460
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3461
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3462
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3463
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3464
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3465

    
3466
masterPoolSizeDefault :: Int
3467
masterPoolSizeDefault = 10
3468

    
3469
-- * Exclusive storage
3470

    
3471
-- | Error margin used to compare physical disks
3472
partMargin :: Double
3473
partMargin = 0.01
3474

    
3475
-- | Space reserved when creating instance disks
3476
partReserved :: Double
3477
partReserved = 0.02
3478

    
3479
-- * Confd
3480

    
3481
confdProtocolVersion :: Int
3482
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3483

    
3484
-- Confd request type
3485

    
3486
confdReqPing :: Int
3487
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3488

    
3489
confdReqNodeRoleByname :: Int
3490
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3491

    
3492
confdReqNodePipByInstanceIp :: Int
3493
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3494

    
3495
confdReqClusterMaster :: Int
3496
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3497

    
3498
confdReqNodePipList :: Int
3499
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3500

    
3501
confdReqMcPipList :: Int
3502
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3503

    
3504
confdReqInstancesIpsList :: Int
3505
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3506

    
3507
confdReqNodeDrbd :: Int
3508
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3509

    
3510
confdReqNodeInstances :: Int
3511
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3512

    
3513
confdReqs :: FrozenSet Int
3514
confdReqs =
3515
  ConstantUtils.mkSet .
3516
  map Types.confdRequestTypeToRaw $
3517
  [minBound..] \\ [ReqNodeInstances]
3518

    
3519
-- * Confd request type
3520

    
3521
confdReqfieldName :: Int
3522
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3523

    
3524
confdReqfieldIp :: Int
3525
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3526

    
3527
confdReqfieldMnodePip :: Int
3528
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3529

    
3530
-- * Confd repl status
3531

    
3532
confdReplStatusOk :: Int
3533
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3534

    
3535
confdReplStatusError :: Int
3536
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3537

    
3538
confdReplStatusNotimplemented :: Int
3539
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3540

    
3541
confdReplStatuses :: FrozenSet Int
3542
confdReplStatuses =
3543
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3544

    
3545
-- * Confd node role
3546

    
3547
confdNodeRoleMaster :: Int
3548
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3549

    
3550
confdNodeRoleCandidate :: Int
3551
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3552

    
3553
confdNodeRoleOffline :: Int
3554
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3555

    
3556
confdNodeRoleDrained :: Int
3557
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3558

    
3559
confdNodeRoleRegular :: Int
3560
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3561

    
3562
-- * A few common errors for confd
3563

    
3564
confdErrorUnknownEntry :: Int
3565
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3566

    
3567
confdErrorInternal :: Int
3568
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3569

    
3570
confdErrorArgument :: Int
3571
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3572

    
3573
-- * Confd request query fields
3574

    
3575
confdReqqLink :: String
3576
confdReqqLink = ConstantUtils.confdReqqLink
3577

    
3578
confdReqqIp :: String
3579
confdReqqIp = ConstantUtils.confdReqqIp
3580

    
3581
confdReqqIplist :: String
3582
confdReqqIplist = ConstantUtils.confdReqqIplist
3583

    
3584
confdReqqFields :: String
3585
confdReqqFields = ConstantUtils.confdReqqFields
3586

    
3587
-- | Each request is "salted" by the current timestamp.
3588
--
3589
-- This constant decides how many seconds of skew to accept.
3590
--
3591
-- TODO: make this a default and allow the value to be more
3592
-- configurable
3593
confdMaxClockSkew :: Int
3594
confdMaxClockSkew = 2 * nodeMaxClockSkew
3595

    
3596
-- | When we haven't reloaded the config for more than this amount of
3597
-- seconds, we force a test to see if inotify is betraying us. Using a
3598
-- prime number to ensure we get less chance of 'same wakeup' with
3599
-- other processes.
3600
confdConfigReloadTimeout :: Int
3601
confdConfigReloadTimeout = 17
3602

    
3603
-- | If we receive more than one update in this amount of
3604
-- microseconds, we move to polling every RATELIMIT seconds, rather
3605
-- than relying on inotify, to be able to serve more requests.
3606
confdConfigReloadRatelimit :: Int
3607
confdConfigReloadRatelimit = 250000
3608

    
3609
-- | Magic number prepended to all confd queries.
3610
--
3611
-- This allows us to distinguish different types of confd protocols
3612
-- and handle them. For example by changing this we can move the whole
3613
-- payload to be compressed, or move away from json.
3614
confdMagicFourcc :: String
3615
confdMagicFourcc = "plj0"
3616

    
3617
-- | By default a confd request is sent to the minimum between this
3618
-- number and all MCs. 6 was chosen because even in the case of a
3619
-- disastrous 50% response rate, we should have enough answers to be
3620
-- able to compare more than one.
3621
confdDefaultReqCoverage :: Int
3622
confdDefaultReqCoverage = 6
3623

    
3624
-- | Timeout in seconds to expire pending query request in the confd
3625
-- client library. We don't actually expect any answer more than 10
3626
-- seconds after we sent a request.
3627
confdClientExpireTimeout :: Int
3628
confdClientExpireTimeout = 10
3629

    
3630
-- | Maximum UDP datagram size.
3631
--
3632
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
3633
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
3634
--   (assuming we can't use jumbo frames)
3635
-- We just set this to 60K, which should be enough
3636
maxUdpDataSize :: Int
3637
maxUdpDataSize = 61440
3638

    
3639
-- * User-id pool minimum/maximum acceptable user-ids
3640

    
3641
uidpoolUidMin :: Int
3642
uidpoolUidMin = 0
3643

    
3644
-- | Assuming 32 bit user-ids
3645
uidpoolUidMax :: Integer
3646
uidpoolUidMax = 2 ^ 32 - 1
3647

    
3648
-- | Name or path of the pgrep command
3649
pgrep :: String
3650
pgrep = "pgrep"
3651

    
3652
-- | Name of the node group that gets created at cluster init or
3653
-- upgrade
3654
initialNodeGroupName :: String
3655
initialNodeGroupName = "default"
3656

    
3657
-- * Possible values for NodeGroup.alloc_policy
3658

    
3659
allocPolicyLastResort :: String
3660
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
3661

    
3662
allocPolicyPreferred :: String
3663
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
3664

    
3665
allocPolicyUnallocable :: String
3666
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
3667

    
3668
validAllocPolicies :: [String]
3669
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
3670

    
3671
-- | Temporary external/shared storage parameters
3672
blockdevDriverManual :: String
3673
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
3674

    
3675
-- | 'qemu-img' path, required for 'ovfconverter'
3676
qemuimgPath :: String
3677
qemuimgPath = AutoConf.qemuimgPath
3678

    
3679
-- | Whether htools was enabled at compilation time
3680
--
3681
-- FIXME: this should be moved next to the other enable constants,
3682
-- such as, 'enableConfd', and renamed to 'enableHtools'.
3683
htools :: Bool
3684
htools = AutoConf.htools
3685

    
3686
-- | The hail iallocator
3687
iallocHail :: String
3688
iallocHail = "hail"
3689

    
3690
-- * Fake opcodes for functions that have hooks attached to them via
3691
-- backend.RunLocalHooks
3692

    
3693
fakeOpMasterTurndown :: String
3694
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
3695

    
3696
fakeOpMasterTurnup :: String
3697
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
3698

    
3699
-- * SSH key types
3700

    
3701
sshkDsa :: String
3702
sshkDsa = "dsa"
3703

    
3704
sshkRsa :: String
3705
sshkRsa = "rsa"
3706

    
3707
sshkAll :: FrozenSet String
3708
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
3709

    
3710
-- * SSH authorized key types
3711

    
3712
sshakDss :: String
3713
sshakDss = "ssh-dss"
3714

    
3715
sshakRsa :: String
3716
sshakRsa = "ssh-rsa"
3717

    
3718
sshakAll :: FrozenSet String
3719
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
3720

    
3721
-- * SSH setup
3722

    
3723
sshsClusterName :: String
3724
sshsClusterName = "cluster_name"
3725

    
3726
sshsSshHostKey :: String
3727
sshsSshHostKey = "ssh_host_key"
3728

    
3729
sshsSshRootKey :: String
3730
sshsSshRootKey = "ssh_root_key"
3731

    
3732
sshsNodeDaemonCertificate :: String
3733
sshsNodeDaemonCertificate = "node_daemon_certificate"
3734

    
3735
-- * Key files for SSH daemon
3736

    
3737
sshHostDsaPriv :: String
3738
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
3739

    
3740
sshHostDsaPub :: String
3741
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
3742

    
3743
sshHostRsaPriv :: String
3744
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
3745

    
3746
sshHostRsaPub :: String
3747
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
3748

    
3749
-- * Node daemon setup
3750

    
3751
ndsClusterName :: String
3752
ndsClusterName = "cluster_name"
3753

    
3754
ndsNodeDaemonCertificate :: String
3755
ndsNodeDaemonCertificate = "node_daemon_certificate"
3756

    
3757
ndsSsconf :: String
3758
ndsSsconf = "ssconf"
3759

    
3760
ndsStartNodeDaemon :: String
3761
ndsStartNodeDaemon = "start_node_daemon"
3762

    
3763
-- * The source reasons for the execution of an OpCode
3764

    
3765
opcodeReasonSrcClient :: String
3766
opcodeReasonSrcClient = "gnt:client"
3767

    
3768
opcodeReasonSrcNoded :: String
3769
opcodeReasonSrcNoded = "gnt:daemon:noded"
3770

    
3771
opcodeReasonSrcOpcode :: String
3772
opcodeReasonSrcOpcode = "gnt:opcode"
3773

    
3774
opcodeReasonSrcRlib2 :: String
3775
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
3776

    
3777
opcodeReasonSrcUser :: String
3778
opcodeReasonSrcUser = "gnt:user"
3779

    
3780
opcodeReasonSources :: FrozenSet String
3781
opcodeReasonSources =
3782
  ConstantUtils.mkSet [opcodeReasonSrcClient,
3783
                       opcodeReasonSrcNoded,
3784
                       opcodeReasonSrcOpcode,
3785
                       opcodeReasonSrcRlib2,
3786
                       opcodeReasonSrcUser]
3787

    
3788
-- | Path generating random UUID
3789
randomUuidFile :: String
3790
randomUuidFile = ConstantUtils.randomUuidFile
3791

    
3792
-- * Auto-repair tag prefixes
3793

    
3794
autoRepairTagPrefix :: String
3795
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
3796

    
3797
autoRepairTagEnabled :: String
3798
autoRepairTagEnabled = autoRepairTagPrefix
3799

    
3800
autoRepairTagPending :: String
3801
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
3802

    
3803
autoRepairTagResult :: String
3804
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
3805

    
3806
autoRepairTagSuspended :: String
3807
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
3808

    
3809
-- * Auto-repair levels
3810

    
3811
autoRepairFailover :: String
3812
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
3813

    
3814
autoRepairFixStorage :: String
3815
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
3816

    
3817
autoRepairMigrate :: String
3818
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
3819

    
3820
autoRepairReinstall :: String
3821
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
3822

    
3823
autoRepairAllTypes :: FrozenSet String
3824
autoRepairAllTypes =
3825
  ConstantUtils.mkSet [autoRepairFailover,
3826
                       autoRepairFixStorage,
3827
                       autoRepairMigrate,
3828
                       autoRepairReinstall]
3829

    
3830
-- * Auto-repair results
3831

    
3832
autoRepairEnoperm :: String
3833
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
3834

    
3835
autoRepairFailure :: String
3836
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
3837

    
3838
autoRepairSuccess :: String
3839
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
3840

    
3841
autoRepairAllResults :: FrozenSet String
3842
autoRepairAllResults =
3843
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
3844

    
3845
-- | The version identifier for builtin data collectors
3846
builtinDataCollectorVersion :: String
3847
builtinDataCollectorVersion = "B"
3848

    
3849
-- | The reason trail opcode parameter name
3850
opcodeReason :: String
3851
opcodeReason = "reason"
3852

    
3853
diskstatsFile :: String
3854
diskstatsFile = "/proc/diskstats"
3855

    
3856
-- *  CPU load collector
3857

    
3858
statFile :: String
3859
statFile = "/proc/stat"
3860

    
3861
cpuavgloadBufferSize :: Int
3862
cpuavgloadBufferSize = 150
3863

    
3864
cpuavgloadWindowSize :: Int
3865
cpuavgloadWindowSize = 600
3866

    
3867
-- | Mond's variable for periodical data collection
3868
mondTimeInterval :: Int
3869
mondTimeInterval = 5
3870

    
3871
-- * Disk access modes
3872

    
3873
diskUserspace :: String
3874
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
3875

    
3876
diskKernelspace :: String
3877
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
3878

    
3879
diskValidAccessModes :: FrozenSet String
3880
diskValidAccessModes =
3881
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
3882

    
3883
-- | Timeout for queue draining in upgrades
3884
upgradeQueueDrainTimeout :: Int
3885
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
3886

    
3887
-- | Intervall at which the queue is polled during upgrades
3888
upgradeQueuePollInterval :: Int
3889
upgradeQueuePollInterval  = 10
3890

    
3891
-- * Hotplug Actions
3892

    
3893
hotplugActionAdd :: String
3894
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
3895

    
3896
hotplugActionRemove :: String
3897
hotplugActionRemove = Types.hotplugActionToRaw HARemove
3898

    
3899
hotplugActionModify :: String
3900
hotplugActionModify = Types.hotplugActionToRaw HAMod
3901

    
3902
hotplugAllActions :: FrozenSet String
3903
hotplugAllActions =
3904
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
3905

    
3906
-- * Hotplug Device Targets
3907

    
3908
hotplugTargetNic :: String
3909
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
3910

    
3911
hotplugTargetDisk :: String
3912
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
3913

    
3914
hotplugAllTargets :: FrozenSet String
3915
hotplugAllTargets =
3916
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]