Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ 3a715da0

History | View | Annotate | Download (91.9 kB)

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

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

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

    
16
-}
17

    
18
{-
19

    
20
Copyright (C) 2013 Google Inc.
21

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

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

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

    
37
-}
38
module Ganeti.HsConstants where
39

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

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

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

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

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

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

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

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

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

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

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

    
86
-- ** Build-time constants
87

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
135
-- * Various versions
136

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

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

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

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

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

    
152
osApiV10 :: Int
153
osApiV10 = 10
154

    
155
osApiV15 :: Int
156
osApiV15 = 15
157

    
158
osApiV20 :: Int
159
osApiV20 = 20
160

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

    
164
exportVersion :: Int
165
exportVersion = 0
166

    
167
rapiVersion :: Int
168
rapiVersion = 2
169

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

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

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

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

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

    
189
-- * User separation
190

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
239
-- * Cpu pinning separators and constants
240

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

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

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

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

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

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

    
279
-- * Wipe
280

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

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

    
288
minWipeChunkPercent :: Int
289
minWipeChunkPercent = 10
290

    
291
-- * Directories
292

    
293
runDirsMode :: Int
294
runDirsMode = 0o775
295

    
296
secureDirMode :: Int
297
secureDirMode = 0o700
298

    
299
secureFileMode :: Int
300
secureFileMode = 0o600
301

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

    
305
-- * 'autoconf' enable/disable
306

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

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

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

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

    
319
-- * SSH constants
320

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

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

    
327
-- * Daemons
328

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

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

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

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

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

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

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

    
356
defaultConfdPort :: Int
357
defaultConfdPort = 1814
358

    
359
defaultMondPort :: Int
360
defaultMondPort = 1815
361

    
362
defaultNodedPort :: Int
363
defaultNodedPort = 1811
364

    
365
defaultRapiPort :: Int
366
defaultRapiPort = 5080
367

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

    
376
firstDrbdPort :: Int
377
firstDrbdPort = 11000
378

    
379
lastDrbdPort :: Int
380
lastDrbdPort = 14999
381

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

    
387
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
-- | The set of lvm-based disk templates
872
dtsLvm :: FrozenSet String
873
dtsLvm = diskTemplates `ConstantUtils.difference` dtsNotLvm
874

    
875
-- * Drbd
876

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

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

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

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

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

    
893
-- * Drbd barrier types
894

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

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

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

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

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

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

    
925
-- * File backend driver
926

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

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

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

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

    
942
-- * Disk access mode
943

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

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

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

    
953
-- * Disk replacement mode
954

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

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

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

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

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

    
971
-- * Instance export mode
972

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

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

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

    
982
-- * Instance creation modes
983

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

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

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

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

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

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

    
1002
rieVersion :: Int
1003
rieVersion = 0
1004

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

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

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

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

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

    
1025
-- * Import/export config options
1026

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

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

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

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

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

    
1042
-- * Dynamic device modification
1043

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

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

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

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

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

    
1059
-- * Common exit codes
1060

    
1061
exitSuccess :: Int
1062
exitSuccess = 0
1063

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

    
1067
exitNotcluster :: Int
1068
exitNotcluster = 5
1069

    
1070
exitNotmaster :: Int
1071
exitNotmaster = 11
1072

    
1073
exitNodesetupError :: Int
1074
exitNodesetupError = 12
1075

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

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

    
1084
-- * Tags
1085

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

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

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

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

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

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

    
1104
maxTagLen :: Int
1105
maxTagLen = 128
1106

    
1107
maxTagsPerObj :: Int
1108
maxTagsPerObj = 4096
1109

    
1110
-- * Others
1111

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

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

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

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

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

    
1128
ip6AddressAny :: String
1129
ip6AddressAny = "::"
1130

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

    
1134
ip4Version :: Int
1135
ip4Version = 4
1136

    
1137
ip6Version :: Int
1138
ip6Version = 6
1139

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

    
1143
tcpPingTimeout :: Int
1144
tcpPingTimeout = 10
1145

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

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

    
1152
minVgSize :: Int
1153
minVgSize = 20480
1154

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

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

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

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

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

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

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

    
1181
-- * Runparts results
1182

    
1183
runpartsErr :: Int
1184
runpartsErr = 2
1185

    
1186
runpartsRun :: Int
1187
runpartsRun = 1
1188

    
1189
runpartsSkip :: Int
1190
runpartsSkip = 0
1191

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

    
1195
-- * RPC
1196

    
1197
rpcEncodingNone :: Int
1198
rpcEncodingNone = 0
1199

    
1200
rpcEncodingZlibBase64 :: Int
1201
rpcEncodingZlibBase64 = 1
1202

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

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

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

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

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

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

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

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

    
1235
-- OS
1236

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1294
esScriptCreate :: String
1295
esScriptCreate = esActionCreate
1296

    
1297
esScriptRemove :: String
1298
esScriptRemove = esActionRemove
1299

    
1300
esScriptGrow :: String
1301
esScriptGrow = esActionGrow
1302

    
1303
esScriptAttach :: String
1304
esScriptAttach = esActionAttach
1305

    
1306
esScriptDetach :: String
1307
esScriptDetach = esActionDetach
1308

    
1309
esScriptSetinfo :: String
1310
esScriptSetinfo = esActionSetinfo
1311

    
1312
esScriptVerify :: String
1313
esScriptVerify = esActionVerify
1314

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

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

    
1328
-- * Reboot types
1329

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

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

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

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

    
1342
-- * Instance reboot behaviors
1343

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

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

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

    
1353
-- * VTypes
1354

    
1355
vtypeBool :: VType
1356
vtypeBool = VTypeBool
1357

    
1358
vtypeInt :: VType
1359
vtypeInt = VTypeInt
1360

    
1361
vtypeMaybeString :: VType
1362
vtypeMaybeString = VTypeMaybeString
1363

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

    
1368
vtypeString :: VType
1369
vtypeString = VTypeString
1370

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1632
-- * Migration statuses
1633

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

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

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

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

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

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

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

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

    
1667
-- * Hypervisor state
1668

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

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

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

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

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

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

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

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

    
1709
-- * Disk state
1710

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

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

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

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

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

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

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

    
1740
-- Backend parameter names
1741

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1869
-- | Node parameter names
1870

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

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

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

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

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

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

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

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

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

    
1912
-- * Logical Disks parameters
1913

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2068
-- * Dynamic disk parameters
2069

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

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

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

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

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

    
2085
-- * OOB supported commands
2086

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2256
-- * Hypervisor constants
2257

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

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

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

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

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

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

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

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

    
2282
vncBasePort :: Int
2283
vncBasePort = 5900
2284

    
2285
vncDefaultBindAddress :: String
2286
vncDefaultBindAddress = ip4AddressAny
2287

    
2288
-- * NIC types
2289

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

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

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

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

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

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

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

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

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

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

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

    
2337
-- * Vif types
2338

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

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

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

    
2349
-- * Disk types
2350

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2403
-- * Mouse types
2404

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

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

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

    
2414
-- * Boot order
2415

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

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

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

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

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

    
2432
-- * SPICE lossless image compression options
2433

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

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

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

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

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

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

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

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

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

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

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

    
2476
-- * SPICE video stream detection
2477

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

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

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

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

    
2493
-- * Security models
2494

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

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

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

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

    
2507
-- * Kvm flag values
2508

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

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

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

    
2518
-- * Migration type
2519

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

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

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

    
2530
-- * Cluster verify steps
2531

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

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

    
2539
-- * Cluster Verify error classes
2540

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

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

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

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

    
2553
-- * Cluster Verify error codes and documentation
2554

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2829
-- * Node verify constants
2830

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2909
-- * Instance status
2910

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

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

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

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

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

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

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

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

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

    
2938
-- * Admin states
2939

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

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

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

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

    
2952
-- * Node roles
2953

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

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

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

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

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

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

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

    
2974
sslCertExpirationError :: Int
2975
sslCertExpirationError = 7
2976

    
2977
sslCertExpirationWarn :: Int
2978
sslCertExpirationWarn = 30
2979

    
2980
-- * Allocator framework constants
2981

    
2982
iallocatorVersion :: Int
2983
iallocatorVersion = 2
2984

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

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

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

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

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

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

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

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

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

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

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

    
3020
-- * Node evacuation
3021

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

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

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

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

    
3034
-- * Job queue
3035

    
3036
jobQueueVersion :: Int
3037
jobQueueVersion = 1
3038

    
3039
jobQueueSizeHardLimit :: Int
3040
jobQueueSizeHardLimit = 5000
3041

    
3042
jobQueueFilesPerms :: Int
3043
jobQueueFilesPerms = 0o640
3044

    
3045
-- * Unchanged job return
3046

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

    
3050
-- * Job status
3051

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

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

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

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

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

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

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

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

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

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

    
3084
-- * OpCode status
3085

    
3086
-- ** Not yet finalized opcodes
3087

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

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

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

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

    
3100
-- ** Finalized opcodes
3101

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

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

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

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

    
3115
-- * OpCode priority
3116

    
3117
opPrioLowest :: Int
3118
opPrioLowest = 19
3119

    
3120
opPrioHighest :: Int
3121
opPrioHighest = -20
3122

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

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

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

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

    
3135
opPrioDefault :: Int
3136
opPrioDefault = opPrioNormal
3137

    
3138
-- * Lock recalculate mode
3139

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

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

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

    
3153
lockAttemptsMaxwait :: Double
3154
lockAttemptsMaxwait = 15.0
3155

    
3156
lockAttemptsMinwait :: Double
3157
lockAttemptsMinwait = 1.0
3158

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

    
3162
-- * Execution log types
3163

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

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

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

    
3173
-- * /etc/hosts modification
3174

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

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

    
3181
-- * Job queue test
3182

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

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

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

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

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

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

    
3201
-- * Query resources
3202

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3253
-- * Query field types
3254

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

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

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

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

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

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

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

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

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

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

    
3296
rsNormal :: Int
3297
rsNormal = 0
3298

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

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

    
3309
rsUnknown :: Int
3310
rsUnknown = 1
3311

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

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

    
3328
-- * Max dynamic devices
3329

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

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

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

    
3340
-- * SSCONF keys
3341

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3416
-- * Hvparams keys
3417

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

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

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

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

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

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

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

    
3445
ssFilePerms :: Int
3446
ssFilePerms = 0o444
3447

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

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

    
3459
ndcGlobals :: FrozenSet String
3460
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3461

    
3462
-- | All of the following values are quite arbitrary - there are no
3463
-- "good" defaults, these must be customised per-site
3464
ispecsMinmaxDefaults :: Map String (Map String Int)
3465
ispecsMinmaxDefaults =
3466
  Map.fromList
3467
  [(ispecsMin,
3468
    Map.fromList
3469
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3470
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3471
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3472
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3473
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3474
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3475
   (ispecsMax,
3476
    Map.fromList
3477
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3478
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3479
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3480
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3481
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3482
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3483

    
3484
masterPoolSizeDefault :: Int
3485
masterPoolSizeDefault = 10
3486

    
3487
-- * Exclusive storage
3488

    
3489
-- | Error margin used to compare physical disks
3490
partMargin :: Double
3491
partMargin = 0.01
3492

    
3493
-- | Space reserved when creating instance disks
3494
partReserved :: Double
3495
partReserved = 0.02
3496

    
3497
-- * Confd
3498

    
3499
confdProtocolVersion :: Int
3500
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3501

    
3502
-- Confd request type
3503

    
3504
confdReqPing :: Int
3505
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3506

    
3507
confdReqNodeRoleByname :: Int
3508
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3509

    
3510
confdReqNodePipByInstanceIp :: Int
3511
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3512

    
3513
confdReqClusterMaster :: Int
3514
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3515

    
3516
confdReqNodePipList :: Int
3517
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3518

    
3519
confdReqMcPipList :: Int
3520
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3521

    
3522
confdReqInstancesIpsList :: Int
3523
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3524

    
3525
confdReqNodeDrbd :: Int
3526
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3527

    
3528
confdReqNodeInstances :: Int
3529
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3530

    
3531
confdReqs :: FrozenSet Int
3532
confdReqs =
3533
  ConstantUtils.mkSet .
3534
  map Types.confdRequestTypeToRaw $
3535
  [minBound..] \\ [ReqNodeInstances]
3536

    
3537
-- * Confd request type
3538

    
3539
confdReqfieldName :: Int
3540
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3541

    
3542
confdReqfieldIp :: Int
3543
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3544

    
3545
confdReqfieldMnodePip :: Int
3546
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3547

    
3548
-- * Confd repl status
3549

    
3550
confdReplStatusOk :: Int
3551
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3552

    
3553
confdReplStatusError :: Int
3554
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3555

    
3556
confdReplStatusNotimplemented :: Int
3557
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3558

    
3559
confdReplStatuses :: FrozenSet Int
3560
confdReplStatuses =
3561
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3562

    
3563
-- * Confd node role
3564

    
3565
confdNodeRoleMaster :: Int
3566
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3567

    
3568
confdNodeRoleCandidate :: Int
3569
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3570

    
3571
confdNodeRoleOffline :: Int
3572
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3573

    
3574
confdNodeRoleDrained :: Int
3575
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3576

    
3577
confdNodeRoleRegular :: Int
3578
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3579

    
3580
-- * A few common errors for confd
3581

    
3582
confdErrorUnknownEntry :: Int
3583
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3584

    
3585
confdErrorInternal :: Int
3586
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3587

    
3588
confdErrorArgument :: Int
3589
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3590

    
3591
-- * Confd request query fields
3592

    
3593
confdReqqLink :: String
3594
confdReqqLink = ConstantUtils.confdReqqLink
3595

    
3596
confdReqqIp :: String
3597
confdReqqIp = ConstantUtils.confdReqqIp
3598

    
3599
confdReqqIplist :: String
3600
confdReqqIplist = ConstantUtils.confdReqqIplist
3601

    
3602
confdReqqFields :: String
3603
confdReqqFields = ConstantUtils.confdReqqFields
3604

    
3605
-- | Each request is "salted" by the current timestamp.
3606
--
3607
-- This constant decides how many seconds of skew to accept.
3608
--
3609
-- TODO: make this a default and allow the value to be more
3610
-- configurable
3611
confdMaxClockSkew :: Int
3612
confdMaxClockSkew = 2 * nodeMaxClockSkew
3613

    
3614
-- | When we haven't reloaded the config for more than this amount of
3615
-- seconds, we force a test to see if inotify is betraying us. Using a
3616
-- prime number to ensure we get less chance of 'same wakeup' with
3617
-- other processes.
3618
confdConfigReloadTimeout :: Int
3619
confdConfigReloadTimeout = 17
3620

    
3621
-- | If we receive more than one update in this amount of
3622
-- microseconds, we move to polling every RATELIMIT seconds, rather
3623
-- than relying on inotify, to be able to serve more requests.
3624
confdConfigReloadRatelimit :: Int
3625
confdConfigReloadRatelimit = 250000
3626

    
3627
-- | Magic number prepended to all confd queries.
3628
--
3629
-- This allows us to distinguish different types of confd protocols
3630
-- and handle them. For example by changing this we can move the whole
3631
-- payload to be compressed, or move away from json.
3632
confdMagicFourcc :: String
3633
confdMagicFourcc = "plj0"
3634

    
3635
-- | By default a confd request is sent to the minimum between this
3636
-- number and all MCs. 6 was chosen because even in the case of a
3637
-- disastrous 50% response rate, we should have enough answers to be
3638
-- able to compare more than one.
3639
confdDefaultReqCoverage :: Int
3640
confdDefaultReqCoverage = 6
3641

    
3642
-- | Timeout in seconds to expire pending query request in the confd
3643
-- client library. We don't actually expect any answer more than 10
3644
-- seconds after we sent a request.
3645
confdClientExpireTimeout :: Int
3646
confdClientExpireTimeout = 10
3647

    
3648
-- | Maximum UDP datagram size.
3649
--
3650
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
3651
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
3652
--   (assuming we can't use jumbo frames)
3653
-- We just set this to 60K, which should be enough
3654
maxUdpDataSize :: Int
3655
maxUdpDataSize = 61440
3656

    
3657
-- * User-id pool minimum/maximum acceptable user-ids
3658

    
3659
uidpoolUidMin :: Int
3660
uidpoolUidMin = 0
3661

    
3662
-- | Assuming 32 bit user-ids
3663
uidpoolUidMax :: Integer
3664
uidpoolUidMax = 2 ^ 32 - 1
3665

    
3666
-- | Name or path of the pgrep command
3667
pgrep :: String
3668
pgrep = "pgrep"
3669

    
3670
-- | Name of the node group that gets created at cluster init or
3671
-- upgrade
3672
initialNodeGroupName :: String
3673
initialNodeGroupName = "default"
3674

    
3675
-- * Possible values for NodeGroup.alloc_policy
3676

    
3677
allocPolicyLastResort :: String
3678
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
3679

    
3680
allocPolicyPreferred :: String
3681
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
3682

    
3683
allocPolicyUnallocable :: String
3684
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
3685

    
3686
validAllocPolicies :: [String]
3687
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
3688

    
3689
-- | Temporary external/shared storage parameters
3690
blockdevDriverManual :: String
3691
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
3692

    
3693
-- | 'qemu-img' path, required for 'ovfconverter'
3694
qemuimgPath :: String
3695
qemuimgPath = AutoConf.qemuimgPath
3696

    
3697
-- | Whether htools was enabled at compilation time
3698
--
3699
-- FIXME: this should be moved next to the other enable constants,
3700
-- such as, 'enableConfd', and renamed to 'enableHtools'.
3701
htools :: Bool
3702
htools = AutoConf.htools
3703

    
3704
-- | The hail iallocator
3705
iallocHail :: String
3706
iallocHail = "hail"
3707

    
3708
-- * Fake opcodes for functions that have hooks attached to them via
3709
-- backend.RunLocalHooks
3710

    
3711
fakeOpMasterTurndown :: String
3712
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
3713

    
3714
fakeOpMasterTurnup :: String
3715
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
3716

    
3717
-- * SSH key types
3718

    
3719
sshkDsa :: String
3720
sshkDsa = "dsa"
3721

    
3722
sshkRsa :: String
3723
sshkRsa = "rsa"
3724

    
3725
sshkAll :: FrozenSet String
3726
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
3727

    
3728
-- * SSH authorized key types
3729

    
3730
sshakDss :: String
3731
sshakDss = "ssh-dss"
3732

    
3733
sshakRsa :: String
3734
sshakRsa = "ssh-rsa"
3735

    
3736
sshakAll :: FrozenSet String
3737
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
3738

    
3739
-- * SSH setup
3740

    
3741
sshsClusterName :: String
3742
sshsClusterName = "cluster_name"
3743

    
3744
sshsSshHostKey :: String
3745
sshsSshHostKey = "ssh_host_key"
3746

    
3747
sshsSshRootKey :: String
3748
sshsSshRootKey = "ssh_root_key"
3749

    
3750
sshsNodeDaemonCertificate :: String
3751
sshsNodeDaemonCertificate = "node_daemon_certificate"
3752

    
3753
-- * Key files for SSH daemon
3754

    
3755
sshHostDsaPriv :: String
3756
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
3757

    
3758
sshHostDsaPub :: String
3759
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
3760

    
3761
sshHostRsaPriv :: String
3762
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
3763

    
3764
sshHostRsaPub :: String
3765
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
3766

    
3767
-- * Node daemon setup
3768

    
3769
ndsClusterName :: String
3770
ndsClusterName = "cluster_name"
3771

    
3772
ndsNodeDaemonCertificate :: String
3773
ndsNodeDaemonCertificate = "node_daemon_certificate"
3774

    
3775
ndsSsconf :: String
3776
ndsSsconf = "ssconf"
3777

    
3778
ndsStartNodeDaemon :: String
3779
ndsStartNodeDaemon = "start_node_daemon"
3780

    
3781
-- * The source reasons for the execution of an OpCode
3782

    
3783
opcodeReasonSrcClient :: String
3784
opcodeReasonSrcClient = "gnt:client"
3785

    
3786
opcodeReasonSrcNoded :: String
3787
opcodeReasonSrcNoded = "gnt:daemon:noded"
3788

    
3789
opcodeReasonSrcOpcode :: String
3790
opcodeReasonSrcOpcode = "gnt:opcode"
3791

    
3792
opcodeReasonSrcRlib2 :: String
3793
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
3794

    
3795
opcodeReasonSrcUser :: String
3796
opcodeReasonSrcUser = "gnt:user"
3797

    
3798
opcodeReasonSources :: FrozenSet String
3799
opcodeReasonSources =
3800
  ConstantUtils.mkSet [opcodeReasonSrcClient,
3801
                       opcodeReasonSrcNoded,
3802
                       opcodeReasonSrcOpcode,
3803
                       opcodeReasonSrcRlib2,
3804
                       opcodeReasonSrcUser]
3805

    
3806
-- | Path generating random UUID
3807
randomUuidFile :: String
3808
randomUuidFile = ConstantUtils.randomUuidFile
3809

    
3810
-- * Auto-repair tag prefixes
3811

    
3812
autoRepairTagPrefix :: String
3813
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
3814

    
3815
autoRepairTagEnabled :: String
3816
autoRepairTagEnabled = autoRepairTagPrefix
3817

    
3818
autoRepairTagPending :: String
3819
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
3820

    
3821
autoRepairTagResult :: String
3822
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
3823

    
3824
autoRepairTagSuspended :: String
3825
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
3826

    
3827
-- * Auto-repair levels
3828

    
3829
autoRepairFailover :: String
3830
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
3831

    
3832
autoRepairFixStorage :: String
3833
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
3834

    
3835
autoRepairMigrate :: String
3836
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
3837

    
3838
autoRepairReinstall :: String
3839
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
3840

    
3841
autoRepairAllTypes :: FrozenSet String
3842
autoRepairAllTypes =
3843
  ConstantUtils.mkSet [autoRepairFailover,
3844
                       autoRepairFixStorage,
3845
                       autoRepairMigrate,
3846
                       autoRepairReinstall]
3847

    
3848
-- * Auto-repair results
3849

    
3850
autoRepairEnoperm :: String
3851
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
3852

    
3853
autoRepairFailure :: String
3854
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
3855

    
3856
autoRepairSuccess :: String
3857
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
3858

    
3859
autoRepairAllResults :: FrozenSet String
3860
autoRepairAllResults =
3861
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
3862

    
3863
-- | The version identifier for builtin data collectors
3864
builtinDataCollectorVersion :: String
3865
builtinDataCollectorVersion = "B"
3866

    
3867
-- | The reason trail opcode parameter name
3868
opcodeReason :: String
3869
opcodeReason = "reason"
3870

    
3871
diskstatsFile :: String
3872
diskstatsFile = "/proc/diskstats"
3873

    
3874
-- *  CPU load collector
3875

    
3876
statFile :: String
3877
statFile = "/proc/stat"
3878

    
3879
cpuavgloadBufferSize :: Int
3880
cpuavgloadBufferSize = 150
3881

    
3882
cpuavgloadWindowSize :: Int
3883
cpuavgloadWindowSize = 600
3884

    
3885
-- | Mond's variable for periodical data collection
3886
mondTimeInterval :: Int
3887
mondTimeInterval = 5
3888

    
3889
-- * Disk access modes
3890

    
3891
diskUserspace :: String
3892
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
3893

    
3894
diskKernelspace :: String
3895
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
3896

    
3897
diskValidAccessModes :: FrozenSet String
3898
diskValidAccessModes =
3899
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
3900

    
3901
-- | Timeout for queue draining in upgrades
3902
upgradeQueueDrainTimeout :: Int
3903
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
3904

    
3905
-- | Intervall at which the queue is polled during upgrades
3906
upgradeQueuePollInterval :: Int
3907
upgradeQueuePollInterval  = 10
3908

    
3909
-- * Hotplug Actions
3910

    
3911
hotplugActionAdd :: String
3912
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
3913

    
3914
hotplugActionRemove :: String
3915
hotplugActionRemove = Types.hotplugActionToRaw HARemove
3916

    
3917
hotplugActionModify :: String
3918
hotplugActionModify = Types.hotplugActionToRaw HAMod
3919

    
3920
hotplugAllActions :: FrozenSet String
3921
hotplugAllActions =
3922
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
3923

    
3924
-- * Hotplug Device Targets
3925

    
3926
hotplugTargetNic :: String
3927
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
3928

    
3929
hotplugTargetDisk :: String
3930
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
3931

    
3932
hotplugAllTargets :: FrozenSet String
3933
hotplugAllTargets =
3934
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]