Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 2c4ec08e

History | View | Annotate | Download (122.8 kB)

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

    
4
The constants in this module are used in Haskell and are also
5
converted to Python.
6

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

    
15
-}
16

    
17
{-
18

    
19
Copyright (C) 2013, 2014 Google Inc.
20

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

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

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

    
36
-}
37
module Ganeti.Constants where
38

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

    
44
import qualified AutoConf
45
import Ganeti.ConstantUtils (PythonChar(..), FrozenSet, Protocol(..),
46
                             buildVersion)
47
import qualified Ganeti.ConstantUtils as ConstantUtils
48
import Ganeti.HTools.Types (AutoRepairResult(..), AutoRepairType(..))
49
import qualified Ganeti.HTools.Types as Types
50
import Ganeti.Logging (SyslogUsage(..))
51
import qualified Ganeti.Logging as Logging (syslogUsageToRaw)
52
import qualified Ganeti.Runtime as Runtime
53
import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..),
54
                       ExtraLogReason(..))
55
import Ganeti.THH (PyValueEx(..))
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
metadUser :: String
204
metadUser = Runtime.daemonUser GanetiMetad
205

    
206
metadGroup :: String
207
metadGroup = Runtime.daemonGroup (DaemonGroup GanetiMetad)
208

    
209
rapiUser :: String
210
rapiUser = Runtime.daemonUser GanetiRapi
211

    
212
rapiGroup :: String
213
rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
214

    
215
confdUser :: String
216
confdUser = Runtime.daemonUser GanetiConfd
217

    
218
confdGroup :: String
219
confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
220

    
221
wconfdUser :: String
222
wconfdUser = Runtime.daemonUser GanetiWConfd
223

    
224
wconfdGroup :: String
225
wconfdGroup = Runtime.daemonGroup (DaemonGroup GanetiWConfd)
226

    
227
kvmdUser :: String
228
kvmdUser = Runtime.daemonUser GanetiKvmd
229

    
230
kvmdGroup :: String
231
kvmdGroup = Runtime.daemonGroup (DaemonGroup GanetiKvmd)
232

    
233
luxidUser :: String
234
luxidUser = Runtime.daemonUser GanetiLuxid
235

    
236
luxidGroup :: String
237
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
238

    
239
nodedUser :: String
240
nodedUser = Runtime.daemonUser GanetiNoded
241

    
242
nodedGroup :: String
243
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
244

    
245
mondUser :: String
246
mondUser = Runtime.daemonUser GanetiMond
247

    
248
mondGroup :: String
249
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
250

    
251
sshLoginUser :: String
252
sshLoginUser = AutoConf.sshLoginUser
253

    
254
sshConsoleUser :: String
255
sshConsoleUser = AutoConf.sshConsoleUser
256

    
257
-- * Cpu pinning separators and constants
258

    
259
cpuPinningSep :: String
260
cpuPinningSep = ":"
261

    
262
cpuPinningAll :: String
263
cpuPinningAll = "all"
264

    
265
-- | Internal representation of "all"
266
cpuPinningAllVal :: Int
267
cpuPinningAllVal = -1
268

    
269
-- | One "all" entry in a CPU list means CPU pinning is off
270
cpuPinningOff :: [Int]
271
cpuPinningOff = [cpuPinningAllVal]
272

    
273
-- | A Xen-specific implementation detail is that there is no way to
274
-- actually say "use any cpu for pinning" in a Xen configuration file,
275
-- as opposed to the command line, where you can say
276
-- @
277
-- xm vcpu-pin <domain> <vcpu> all
278
-- @
279
--
280
-- The workaround used in Xen is "0-63" (see source code function
281
-- "xm_vcpu_pin" in @<xen-source>/tools/python/xen/xm/main.py@).
282
--
283
-- To support future changes, the following constant is treated as a
284
-- blackbox string that simply means "use any cpu for pinning under
285
-- xen".
286
cpuPinningAllXen :: String
287
cpuPinningAllXen = "0-63"
288

    
289
-- | A KVM-specific implementation detail - the following value is
290
-- used to set CPU affinity to all processors (--0 through --31), per
291
-- taskset man page.
292
--
293
-- FIXME: This only works for machines with up to 32 CPU cores
294
cpuPinningAllKvm :: Int
295
cpuPinningAllKvm = 0xFFFFFFFF
296

    
297
-- * Wipe
298

    
299
ddCmd :: String
300
ddCmd = "dd"
301

    
302
-- | 1GB
303
maxWipeChunk :: Int
304
maxWipeChunk = 1024
305

    
306
minWipeChunkPercent :: Int
307
minWipeChunkPercent = 10
308

    
309
-- * Directories
310

    
311
runDirsMode :: Int
312
runDirsMode = 0o775
313

    
314
secureDirMode :: Int
315
secureDirMode = 0o700
316

    
317
secureFileMode :: Int
318
secureFileMode = 0o600
319

    
320
adoptableBlockdevRoot :: String
321
adoptableBlockdevRoot = "/dev/disk/"
322

    
323
-- * 'autoconf' enable/disable
324

    
325
enableConfd :: Bool
326
enableConfd = AutoConf.enableConfd
327

    
328
enableMond :: Bool
329
enableMond = AutoConf.enableMond
330

    
331
enableRestrictedCommands :: Bool
332
enableRestrictedCommands = AutoConf.enableRestrictedCommands
333

    
334
-- * SSH constants
335

    
336
ssh :: String
337
ssh = "ssh"
338

    
339
scp :: String
340
scp = "scp"
341

    
342
-- * Daemons
343

    
344
confd :: String
345
confd = Runtime.daemonName GanetiConfd
346

    
347
masterd :: String
348
masterd = Runtime.daemonName GanetiMasterd
349

    
350
metad :: String
351
metad = Runtime.daemonName GanetiMetad
352

    
353
mond :: String
354
mond = Runtime.daemonName GanetiMond
355

    
356
noded :: String
357
noded = Runtime.daemonName GanetiNoded
358

    
359
wconfd :: String
360
wconfd = Runtime.daemonName GanetiWConfd
361

    
362
luxid :: String
363
luxid = Runtime.daemonName GanetiLuxid
364

    
365
rapi :: String
366
rapi = Runtime.daemonName GanetiRapi
367

    
368
kvmd :: String
369
kvmd = Runtime.daemonName GanetiKvmd
370

    
371
daemons :: FrozenSet String
372
daemons =
373
  ConstantUtils.mkSet [confd,
374
                       luxid,
375
                       masterd,
376
                       mond,
377
                       noded,
378
                       rapi]
379

    
380
defaultConfdPort :: Int
381
defaultConfdPort = 1814
382

    
383
defaultMondPort :: Int
384
defaultMondPort = 1815
385

    
386
defaultMetadPort :: Int
387
defaultMetadPort = 8080
388

    
389
defaultNodedPort :: Int
390
defaultNodedPort = 1811
391

    
392
defaultRapiPort :: Int
393
defaultRapiPort = 5080
394

    
395
daemonsPorts :: Map String (Protocol, Int)
396
daemonsPorts =
397
  Map.fromList
398
  [ (confd, (Udp, defaultConfdPort))
399
  , (metad, (Tcp, defaultMetadPort))
400
  , (mond, (Tcp, defaultMondPort))
401
  , (noded, (Tcp, defaultNodedPort))
402
  , (rapi, (Tcp, defaultRapiPort))
403
  , (ssh, (Tcp, 22))
404
  ]
405

    
406
firstDrbdPort :: Int
407
firstDrbdPort = 11000
408

    
409
lastDrbdPort :: Int
410
lastDrbdPort = 14999
411

    
412
daemonsLogbase :: Map String String
413
daemonsLogbase =
414
  Map.fromList
415
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
416

    
417
daemonsExtraLogbase :: Map String (Map String String)
418
daemonsExtraLogbase =
419
  Map.fromList $
420
  map (Runtime.daemonName *** id)
421
  [ (GanetiMond, Map.fromList
422
                 [ ("access", Runtime.daemonsExtraLogbase GanetiMond AccessLog)
423
                 , ("error", Runtime.daemonsExtraLogbase GanetiMond ErrorLog)
424
                 ])
425
  ]
426

    
427
extraLogreasonAccess :: String
428
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
429

    
430
extraLogreasonError :: String
431
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
432

    
433
devConsole :: String
434
devConsole = ConstantUtils.devConsole
435

    
436
procMounts :: String
437
procMounts = "/proc/mounts"
438

    
439
-- * Luxi (Local UniX Interface) related constants
440

    
441
luxiEom :: PythonChar
442
luxiEom = PythonChar '\x03'
443

    
444
-- | Environment variable for the luxi override socket
445
luxiOverride :: String
446
luxiOverride = "FORCE_LUXI_SOCKET"
447

    
448
luxiOverrideMaster :: String
449
luxiOverrideMaster = "master"
450

    
451
luxiOverrideQuery :: String
452
luxiOverrideQuery = "query"
453

    
454
luxiVersion :: Int
455
luxiVersion = configVersion
456

    
457
-- * Syslog
458

    
459
syslogUsage :: String
460
syslogUsage = AutoConf.syslogUsage
461

    
462
syslogNo :: String
463
syslogNo = Logging.syslogUsageToRaw SyslogNo
464

    
465
syslogYes :: String
466
syslogYes = Logging.syslogUsageToRaw SyslogYes
467

    
468
syslogOnly :: String
469
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
470

    
471
syslogSocket :: String
472
syslogSocket = "/dev/log"
473

    
474
exportConfFile :: String
475
exportConfFile = "config.ini"
476

    
477
-- * Xen
478

    
479
xenBootloader :: String
480
xenBootloader = AutoConf.xenBootloader
481

    
482
xenCmdXl :: String
483
xenCmdXl = "xl"
484

    
485
xenCmdXm :: String
486
xenCmdXm = "xm"
487

    
488
xenInitrd :: String
489
xenInitrd = AutoConf.xenInitrd
490

    
491
xenKernel :: String
492
xenKernel = AutoConf.xenKernel
493

    
494
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
495
-- other constants
496
knownXenCommands :: FrozenSet String
497
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
498

    
499
-- * KVM and socat
500

    
501
kvmPath :: String
502
kvmPath = AutoConf.kvmPath
503

    
504
kvmKernel :: String
505
kvmKernel = AutoConf.kvmKernel
506

    
507
socatEscapeCode :: String
508
socatEscapeCode = "0x1d"
509

    
510
socatPath :: String
511
socatPath = AutoConf.socatPath
512

    
513
socatUseCompress :: Bool
514
socatUseCompress = AutoConf.socatUseCompress
515

    
516
socatUseEscape :: Bool
517
socatUseEscape = AutoConf.socatUseEscape
518

    
519
-- * Console types
520

    
521
-- | Display a message for console access
522
consMessage :: String
523
consMessage = "msg"
524

    
525
-- | Console as SPICE server
526
consSpice :: String
527
consSpice = "spice"
528

    
529
-- | Console as SSH command
530
consSsh :: String
531
consSsh = "ssh"
532

    
533
-- | Console as VNC server
534
consVnc :: String
535
consVnc = "vnc"
536

    
537
consAll :: FrozenSet String
538
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
539

    
540
-- | RSA key bit length
541
--
542
-- For RSA keys more bits are better, but they also make operations
543
-- more expensive. NIST SP 800-131 recommends a minimum of 2048 bits
544
-- from the year 2010 on.
545
rsaKeyBits :: Int
546
rsaKeyBits = 2048
547

    
548
-- | Ciphers allowed for SSL connections.
549
--
550
-- For the format, see ciphers(1). A better way to disable ciphers
551
-- would be to use the exclamation mark (!), but socat versions below
552
-- 1.5 can't parse exclamation marks in options properly. When
553
-- modifying the ciphers, ensure not to accidentially add something
554
-- after it's been removed. Use the "openssl" utility to check the
555
-- allowed ciphers, e.g.  "openssl ciphers -v HIGH:-DES".
556
opensslCiphers :: String
557
opensslCiphers = "HIGH:-DES:-3DES:-EXPORT:-ADH"
558

    
559
-- * X509
560

    
561
-- | commonName (CN) used in certificates
562
x509CertCn :: String
563
x509CertCn = "ganeti.example.com"
564

    
565
-- | Default validity of certificates in days
566
x509CertDefaultValidity :: Int
567
x509CertDefaultValidity = 365 * 5
568

    
569
x509CertSignatureHeader :: String
570
x509CertSignatureHeader = "X-Ganeti-Signature"
571

    
572
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
573
x509CertSignDigest :: String
574
x509CertSignDigest = "SHA1"
575

    
576
-- * Import/export daemon mode
577

    
578
iemExport :: String
579
iemExport = "export"
580

    
581
iemImport :: String
582
iemImport = "import"
583

    
584
-- * Import/export transport compression
585

    
586
iecGzip :: String
587
iecGzip = "gzip"
588

    
589
iecNone :: String
590
iecNone = "none"
591

    
592
iecAll :: [String]
593
iecAll = [iecGzip, iecNone]
594

    
595
ieCustomSize :: String
596
ieCustomSize = "fd"
597

    
598
-- * Import/export I/O
599

    
600
-- | Direct file I/O, equivalent to a shell's I/O redirection using
601
-- '<' or '>'
602
ieioFile :: String
603
ieioFile = "file"
604

    
605
-- | Raw block device I/O using "dd"
606
ieioRawDisk :: String
607
ieioRawDisk = "raw"
608

    
609
-- | OS definition import/export script
610
ieioScript :: String
611
ieioScript = "script"
612

    
613
-- * Values
614

    
615
valueDefault :: String
616
valueDefault = "default"
617

    
618
valueAuto :: String
619
valueAuto = "auto"
620

    
621
valueGenerate :: String
622
valueGenerate = "generate"
623

    
624
valueNone :: String
625
valueNone = "none"
626

    
627
valueTrue :: String
628
valueTrue = "true"
629

    
630
valueFalse :: String
631
valueFalse = "false"
632

    
633
-- * Hooks
634

    
635
hooksNameCfgupdate :: String
636
hooksNameCfgupdate = "config-update"
637

    
638
hooksNameWatcher :: String
639
hooksNameWatcher = "watcher"
640

    
641
hooksPath :: String
642
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
643

    
644
hooksPhasePost :: String
645
hooksPhasePost = "post"
646

    
647
hooksPhasePre :: String
648
hooksPhasePre = "pre"
649

    
650
hooksVersion :: Int
651
hooksVersion = 2
652

    
653
-- * Hooks subject type (what object type does the LU deal with)
654

    
655
htypeCluster :: String
656
htypeCluster = "CLUSTER"
657

    
658
htypeGroup :: String
659
htypeGroup = "GROUP"
660

    
661
htypeInstance :: String
662
htypeInstance = "INSTANCE"
663

    
664
htypeNetwork :: String
665
htypeNetwork = "NETWORK"
666

    
667
htypeNode :: String
668
htypeNode = "NODE"
669

    
670
-- * Hkr
671

    
672
hkrSkip :: Int
673
hkrSkip = 0
674

    
675
hkrFail :: Int
676
hkrFail = 1
677

    
678
hkrSuccess :: Int
679
hkrSuccess = 2
680

    
681
-- * Storage types
682

    
683
stBlock :: String
684
stBlock = Types.storageTypeToRaw StorageBlock
685

    
686
stDiskless :: String
687
stDiskless = Types.storageTypeToRaw StorageDiskless
688

    
689
stExt :: String
690
stExt = Types.storageTypeToRaw StorageExt
691

    
692
stFile :: String
693
stFile = Types.storageTypeToRaw StorageFile
694

    
695
stSharedFile :: String
696
stSharedFile = Types.storageTypeToRaw StorageSharedFile
697

    
698
stLvmPv :: String
699
stLvmPv = Types.storageTypeToRaw StorageLvmPv
700

    
701
stLvmVg :: String
702
stLvmVg = Types.storageTypeToRaw StorageLvmVg
703

    
704
stRados :: String
705
stRados = Types.storageTypeToRaw StorageRados
706

    
707
storageTypes :: FrozenSet String
708
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
709

    
710
-- | The set of storage types for which full storage reporting is available
711
stsReport :: FrozenSet String
712
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
713

    
714
-- | The set of storage types for which node storage reporting is available
715
-- | (as used by LUQueryNodeStorage)
716
stsReportNodeStorage :: FrozenSet String
717
stsReportNodeStorage = ConstantUtils.union stsReport $
718
                                           ConstantUtils.mkSet [stSharedFile]
719

    
720
-- * Storage fields
721
-- ** First two are valid in LU context only, not passed to backend
722

    
723
sfNode :: String
724
sfNode = "node"
725

    
726
sfType :: String
727
sfType = "type"
728

    
729
-- ** and the rest are valid in backend
730

    
731
sfAllocatable :: String
732
sfAllocatable = Types.storageFieldToRaw SFAllocatable
733

    
734
sfFree :: String
735
sfFree = Types.storageFieldToRaw SFFree
736

    
737
sfName :: String
738
sfName = Types.storageFieldToRaw SFName
739

    
740
sfSize :: String
741
sfSize = Types.storageFieldToRaw SFSize
742

    
743
sfUsed :: String
744
sfUsed = Types.storageFieldToRaw SFUsed
745

    
746
validStorageFields :: FrozenSet String
747
validStorageFields =
748
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
749
                        [sfNode, sfType]
750

    
751
modifiableStorageFields :: Map String (FrozenSet String)
752
modifiableStorageFields =
753
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
754
                 ConstantUtils.mkSet [sfAllocatable])]
755

    
756
-- * Storage operations
757

    
758
soFixConsistency :: String
759
soFixConsistency = "fix-consistency"
760

    
761
validStorageOperations :: Map String (FrozenSet String)
762
validStorageOperations =
763
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
764
                 ConstantUtils.mkSet [soFixConsistency])]
765

    
766
-- * Volume fields
767

    
768
vfDev :: String
769
vfDev = "dev"
770

    
771
vfInstance :: String
772
vfInstance = "instance"
773

    
774
vfName :: String
775
vfName = "name"
776

    
777
vfNode :: String
778
vfNode = "node"
779

    
780
vfPhys :: String
781
vfPhys = "phys"
782

    
783
vfSize :: String
784
vfSize = "size"
785

    
786
vfVg :: String
787
vfVg = "vg"
788

    
789
-- * Local disk status
790

    
791
ldsFaulty :: Int
792
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
793

    
794
ldsOkay :: Int
795
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
796

    
797
ldsUnknown :: Int
798
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
799

    
800
ldsNames :: Map Int String
801
ldsNames =
802
  Map.fromList [ (Types.localDiskStatusToRaw ds,
803
                  localDiskStatusName ds) | ds <- [minBound..] ]
804

    
805
-- * Disk template types
806

    
807
dtDiskless :: String
808
dtDiskless = Types.diskTemplateToRaw DTDiskless
809

    
810
dtFile :: String
811
dtFile = Types.diskTemplateToRaw DTFile
812

    
813
dtSharedFile :: String
814
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
815

    
816
dtPlain :: String
817
dtPlain = Types.diskTemplateToRaw DTPlain
818

    
819
dtBlock :: String
820
dtBlock = Types.diskTemplateToRaw DTBlock
821

    
822
dtDrbd8 :: String
823
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
824

    
825
dtRbd :: String
826
dtRbd = Types.diskTemplateToRaw DTRbd
827

    
828
dtExt :: String
829
dtExt = Types.diskTemplateToRaw DTExt
830

    
831
dtGluster :: String
832
dtGluster = Types.diskTemplateToRaw DTGluster
833

    
834
-- | This is used to order determine the default disk template when
835
-- the list of enabled disk templates is inferred from the current
836
-- state of the cluster.  This only happens on an upgrade from a
837
-- version of Ganeti that did not support the 'enabled_disk_templates'
838
-- so far.
839
diskTemplatePreference :: [String]
840
diskTemplatePreference =
841
  map Types.diskTemplateToRaw
842
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile,
843
   DTPlain, DTRbd, DTSharedFile, DTGluster]
844

    
845
diskTemplates :: FrozenSet String
846
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
847

    
848
-- | Disk templates that are enabled by default
849
defaultEnabledDiskTemplates :: [String]
850
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
851

    
852
-- | Mapping of disk templates to storage types
853
mapDiskTemplateStorageType :: Map String String
854
mapDiskTemplateStorageType =
855
  Map.fromList $
856
  map (Types.diskTemplateToRaw *** Types.storageTypeToRaw)
857
  [(DTBlock, StorageBlock),
858
   (DTDrbd8, StorageLvmVg),
859
   (DTExt, StorageExt),
860
   (DTSharedFile, StorageSharedFile),
861
   (DTFile, StorageFile),
862
   (DTDiskless, StorageDiskless),
863
   (DTPlain, StorageLvmVg),
864
   (DTRbd, StorageRados),
865
   (DTGluster, StorageSharedFile)]
866

    
867
-- | The set of network-mirrored disk templates
868
dtsIntMirror :: FrozenSet String
869
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
870

    
871
-- | 'DTDiskless' is 'trivially' externally mirrored
872
dtsExtMirror :: FrozenSet String
873
dtsExtMirror =
874
  ConstantUtils.mkSet $
875
  map Types.diskTemplateToRaw
876
  [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd, DTGluster]
877

    
878
-- | The set of non-lvm-based disk templates
879
dtsNotLvm :: FrozenSet String
880
dtsNotLvm =
881
  ConstantUtils.mkSet $
882
  map Types.diskTemplateToRaw
883
  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd, DTGluster]
884

    
885
-- | The set of disk templates which can be grown
886
dtsGrowable :: FrozenSet String
887
dtsGrowable =
888
  ConstantUtils.mkSet $
889
  map Types.diskTemplateToRaw
890
  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd, DTGluster]
891

    
892
-- | The set of disk templates that allow adoption
893
dtsMayAdopt :: FrozenSet String
894
dtsMayAdopt =
895
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
896

    
897
-- | The set of disk templates that *must* use adoption
898
dtsMustAdopt :: FrozenSet String
899
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
900

    
901
-- | The set of disk templates that allow migrations
902
dtsMirrored :: FrozenSet String
903
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
904

    
905
-- | The set of file based disk templates
906
dtsFilebased :: FrozenSet String
907
dtsFilebased =
908
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw
909
  [DTSharedFile, DTFile, DTGluster]
910

    
911
-- | The set of disk templates that can be moved by copying
912
--
913
-- Note: a requirement is that they're not accessed externally or
914
-- shared between nodes; in particular, sharedfile is not suitable.
915
dtsCopyable :: FrozenSet String
916
dtsCopyable =
917
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
918

    
919
-- | The set of disk templates that are supported by exclusive_storage
920
dtsExclStorage :: FrozenSet String
921
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
922

    
923
-- | Templates for which we don't perform checks on free space
924
dtsNoFreeSpaceCheck :: FrozenSet String
925
dtsNoFreeSpaceCheck =
926
  ConstantUtils.mkSet $
927
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd, DTGluster]
928

    
929
dtsBlock :: FrozenSet String
930
dtsBlock =
931
  ConstantUtils.mkSet $
932
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
933

    
934
-- | The set of lvm-based disk templates
935
dtsLvm :: FrozenSet String
936
dtsLvm = diskTemplates `ConstantUtils.difference` dtsNotLvm
937

    
938
-- | The set of lvm-based disk templates
939
dtsHaveAccess :: FrozenSet String
940
dtsHaveAccess = ConstantUtils.mkSet $
941
  map Types.diskTemplateToRaw [DTRbd, DTGluster]
942

    
943
-- * Drbd
944

    
945
drbdHmacAlg :: String
946
drbdHmacAlg = "md5"
947

    
948
drbdDefaultNetProtocol :: String
949
drbdDefaultNetProtocol = "C"
950

    
951
drbdMigrationNetProtocol :: String
952
drbdMigrationNetProtocol = "C"
953

    
954
drbdStatusFile :: String
955
drbdStatusFile = "/proc/drbd"
956

    
957
-- | Size of DRBD meta block device
958
drbdMetaSize :: Int
959
drbdMetaSize = 128
960

    
961
-- * Drbd barrier types
962

    
963
drbdBDiskBarriers :: String
964
drbdBDiskBarriers = "b"
965

    
966
drbdBDiskDrain :: String
967
drbdBDiskDrain = "d"
968

    
969
drbdBDiskFlush :: String
970
drbdBDiskFlush = "f"
971

    
972
drbdBNone :: String
973
drbdBNone = "n"
974

    
975
-- | Valid barrier combinations: "n" or any non-null subset of "bfd"
976
drbdValidBarrierOpt :: FrozenSet (FrozenSet String)
977
drbdValidBarrierOpt =
978
  ConstantUtils.mkSet
979
  [ ConstantUtils.mkSet [drbdBNone]
980
  , ConstantUtils.mkSet [drbdBDiskBarriers]
981
  , ConstantUtils.mkSet [drbdBDiskDrain]
982
  , ConstantUtils.mkSet [drbdBDiskFlush]
983
  , ConstantUtils.mkSet [drbdBDiskDrain, drbdBDiskFlush]
984
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskDrain]
985
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush]
986
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush, drbdBDiskDrain]
987
  ]
988

    
989
-- | Rbd tool command
990
rbdCmd :: String
991
rbdCmd = "rbd"
992

    
993
-- * File backend driver
994

    
995
fdBlktap :: String
996
fdBlktap = Types.fileDriverToRaw FileBlktap
997

    
998
fdBlktap2 :: String
999
fdBlktap2 = Types.fileDriverToRaw FileBlktap2
1000

    
1001
fdLoop :: String
1002
fdLoop = Types.fileDriverToRaw FileLoop
1003

    
1004
fdDefault :: String
1005
fdDefault = fdLoop
1006

    
1007
fileDriver :: FrozenSet String
1008
fileDriver =
1009
  ConstantUtils.mkSet $
1010
  map Types.fileDriverToRaw [minBound..]
1011

    
1012
-- | The set of drbd-like disk types
1013
dtsDrbd :: FrozenSet String
1014
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
1015

    
1016
-- * Disk access mode
1017

    
1018
diskRdonly :: String
1019
diskRdonly = Types.diskModeToRaw DiskRdOnly
1020

    
1021
diskRdwr :: String
1022
diskRdwr = Types.diskModeToRaw DiskRdWr
1023

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

    
1027
-- * Disk replacement mode
1028

    
1029
replaceDiskAuto :: String
1030
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
1031

    
1032
replaceDiskChg :: String
1033
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
1034

    
1035
replaceDiskPri :: String
1036
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
1037

    
1038
replaceDiskSec :: String
1039
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
1040

    
1041
replaceModes :: FrozenSet String
1042
replaceModes =
1043
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
1044

    
1045
-- * Instance export mode
1046

    
1047
exportModeLocal :: String
1048
exportModeLocal = Types.exportModeToRaw ExportModeLocal
1049

    
1050
exportModeRemote :: String
1051
exportModeRemote = Types.exportModeToRaw ExportModeRemote
1052

    
1053
exportModes :: FrozenSet String
1054
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
1055

    
1056
-- * Instance creation modes
1057

    
1058
instanceCreate :: String
1059
instanceCreate = Types.instCreateModeToRaw InstCreate
1060

    
1061
instanceImport :: String
1062
instanceImport = Types.instCreateModeToRaw InstImport
1063

    
1064
instanceRemoteImport :: String
1065
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1066

    
1067
instanceCreateModes :: FrozenSet String
1068
instanceCreateModes =
1069
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1070

    
1071
-- * Remote import/export handshake message and version
1072

    
1073
rieHandshake :: String
1074
rieHandshake = "Hi, I'm Ganeti"
1075

    
1076
rieVersion :: Int
1077
rieVersion = 0
1078

    
1079
-- | Remote import/export certificate validity (seconds)
1080
rieCertValidity :: Int
1081
rieCertValidity = 24 * 60 * 60
1082

    
1083
-- | Export only: how long to wait per connection attempt (seconds)
1084
rieConnectAttemptTimeout :: Int
1085
rieConnectAttemptTimeout = 20
1086

    
1087
-- | Export only: number of attempts to connect
1088
rieConnectRetries :: Int
1089
rieConnectRetries = 10
1090

    
1091
-- | Overall timeout for establishing connection
1092
rieConnectTimeout :: Int
1093
rieConnectTimeout = 180
1094

    
1095
-- | Give child process up to 5 seconds to exit after sending a signal
1096
childLingerTimeout :: Double
1097
childLingerTimeout = 5.0
1098

    
1099
-- * Import/export config options
1100

    
1101
inisectBep :: String
1102
inisectBep = "backend"
1103

    
1104
inisectExp :: String
1105
inisectExp = "export"
1106

    
1107
inisectHyp :: String
1108
inisectHyp = "hypervisor"
1109

    
1110
inisectIns :: String
1111
inisectIns = "instance"
1112

    
1113
inisectOsp :: String
1114
inisectOsp = "os"
1115

    
1116
inisectOspPrivate :: String
1117
inisectOspPrivate = "os_private"
1118

    
1119
-- * Dynamic device modification
1120

    
1121
ddmAdd :: String
1122
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1123

    
1124
ddmModify :: String
1125
ddmModify = Types.ddmFullToRaw DdmFullModify
1126

    
1127
ddmRemove :: String
1128
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1129

    
1130
ddmsValues :: FrozenSet String
1131
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1132

    
1133
ddmsValuesWithModify :: FrozenSet String
1134
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1135

    
1136
-- * Common exit codes
1137

    
1138
exitSuccess :: Int
1139
exitSuccess = 0
1140

    
1141
exitFailure :: Int
1142
exitFailure = ConstantUtils.exitFailure
1143

    
1144
exitNotcluster :: Int
1145
exitNotcluster = 5
1146

    
1147
exitNotmaster :: Int
1148
exitNotmaster = 11
1149

    
1150
exitNodesetupError :: Int
1151
exitNodesetupError = 12
1152

    
1153
-- | Need user confirmation
1154
exitConfirmation :: Int
1155
exitConfirmation = 13
1156

    
1157
-- | Exit code for query operations with unknown fields
1158
exitUnknownField :: Int
1159
exitUnknownField = 14
1160

    
1161
-- * Tags
1162

    
1163
tagCluster :: String
1164
tagCluster = Types.tagKindToRaw TagKindCluster
1165

    
1166
tagInstance :: String
1167
tagInstance = Types.tagKindToRaw TagKindInstance
1168

    
1169
tagNetwork :: String
1170
tagNetwork = Types.tagKindToRaw TagKindNetwork
1171

    
1172
tagNode :: String
1173
tagNode = Types.tagKindToRaw TagKindNode
1174

    
1175
tagNodegroup :: String
1176
tagNodegroup = Types.tagKindToRaw TagKindGroup
1177

    
1178
validTagTypes :: FrozenSet String
1179
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1180

    
1181
maxTagLen :: Int
1182
maxTagLen = 128
1183

    
1184
maxTagsPerObj :: Int
1185
maxTagsPerObj = 4096
1186

    
1187
-- * Others
1188

    
1189
defaultBridge :: String
1190
defaultBridge = "xen-br0"
1191

    
1192
defaultOvs :: String
1193
defaultOvs = "switch1"
1194

    
1195
-- | 60 MiB/s, expressed in KiB/s
1196
classicDrbdSyncSpeed :: Int
1197
classicDrbdSyncSpeed = 60 * 1024
1198

    
1199
ip4AddressAny :: String
1200
ip4AddressAny = "0.0.0.0"
1201

    
1202
ip4AddressLocalhost :: String
1203
ip4AddressLocalhost = "127.0.0.1"
1204

    
1205
ip6AddressAny :: String
1206
ip6AddressAny = "::"
1207

    
1208
ip6AddressLocalhost :: String
1209
ip6AddressLocalhost = "::1"
1210

    
1211
ip4Version :: Int
1212
ip4Version = 4
1213

    
1214
ip6Version :: Int
1215
ip6Version = 6
1216

    
1217
validIpVersions :: FrozenSet Int
1218
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1219

    
1220
tcpPingTimeout :: Int
1221
tcpPingTimeout = 10
1222

    
1223
defaultVg :: String
1224
defaultVg = "xenvg"
1225

    
1226
defaultDrbdHelper :: String
1227
defaultDrbdHelper = "/bin/true"
1228

    
1229
minVgSize :: Int
1230
minVgSize = 20480
1231

    
1232
defaultMacPrefix :: String
1233
defaultMacPrefix = "aa:00:00"
1234

    
1235
-- | Default maximum instance wait time (seconds)
1236
defaultShutdownTimeout :: Int
1237
defaultShutdownTimeout = 120
1238

    
1239
-- | Node clock skew (seconds)
1240
nodeMaxClockSkew :: Int
1241
nodeMaxClockSkew = 150
1242

    
1243
-- | Time for an intra-cluster disk transfer to wait for a connection
1244
diskTransferConnectTimeout :: Int
1245
diskTransferConnectTimeout = 60
1246

    
1247
-- | Disk index separator
1248
diskSeparator :: String
1249
diskSeparator = AutoConf.diskSeparator
1250

    
1251
ipCommandPath :: String
1252
ipCommandPath = AutoConf.ipPath
1253

    
1254
-- | Key for job IDs in opcode result
1255
jobIdsKey :: String
1256
jobIdsKey = "jobs"
1257

    
1258
-- * Runparts results
1259

    
1260
runpartsErr :: Int
1261
runpartsErr = 2
1262

    
1263
runpartsRun :: Int
1264
runpartsRun = 1
1265

    
1266
runpartsSkip :: Int
1267
runpartsSkip = 0
1268

    
1269
runpartsStatus :: [Int]
1270
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1271

    
1272
-- * RPC
1273

    
1274
rpcEncodingNone :: Int
1275
rpcEncodingNone = 0
1276

    
1277
rpcEncodingZlibBase64 :: Int
1278
rpcEncodingZlibBase64 = 1
1279

    
1280
-- * Timeout table
1281
--
1282
-- Various time constants for the timeout table
1283

    
1284
rpcTmoUrgent :: Int
1285
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1286

    
1287
rpcTmoFast :: Int
1288
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1289

    
1290
rpcTmoNormal :: Int
1291
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1292

    
1293
rpcTmoSlow :: Int
1294
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1295

    
1296
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1297
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1298
-- Python name.
1299
rpcTmo_4hrs :: Int
1300
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1301

    
1302
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1303
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1304
-- Python name.
1305
rpcTmo_1day :: Int
1306
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1307

    
1308
-- | Timeout for connecting to nodes (seconds)
1309
rpcConnectTimeout :: Int
1310
rpcConnectTimeout = 5
1311

    
1312
-- OS
1313

    
1314
osScriptCreate :: String
1315
osScriptCreate = "create"
1316

    
1317
osScriptExport :: String
1318
osScriptExport = "export"
1319

    
1320
osScriptImport :: String
1321
osScriptImport = "import"
1322

    
1323
osScriptRename :: String
1324
osScriptRename = "rename"
1325

    
1326
osScriptVerify :: String
1327
osScriptVerify = "verify"
1328

    
1329
osScripts :: [String]
1330
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1331
             osScriptVerify]
1332

    
1333
osApiFile :: String
1334
osApiFile = "ganeti_api_version"
1335

    
1336
osVariantsFile :: String
1337
osVariantsFile = "variants.list"
1338

    
1339
osParametersFile :: String
1340
osParametersFile = "parameters.list"
1341

    
1342
osValidateParameters :: String
1343
osValidateParameters = "parameters"
1344

    
1345
osValidateCalls :: FrozenSet String
1346
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1347

    
1348
-- | External Storage (ES) related constants
1349

    
1350
esActionAttach :: String
1351
esActionAttach = "attach"
1352

    
1353
esActionCreate :: String
1354
esActionCreate = "create"
1355

    
1356
esActionDetach :: String
1357
esActionDetach = "detach"
1358

    
1359
esActionGrow :: String
1360
esActionGrow = "grow"
1361

    
1362
esActionRemove :: String
1363
esActionRemove = "remove"
1364

    
1365
esActionSetinfo :: String
1366
esActionSetinfo = "setinfo"
1367

    
1368
esActionVerify :: String
1369
esActionVerify = "verify"
1370

    
1371
esScriptCreate :: String
1372
esScriptCreate = esActionCreate
1373

    
1374
esScriptRemove :: String
1375
esScriptRemove = esActionRemove
1376

    
1377
esScriptGrow :: String
1378
esScriptGrow = esActionGrow
1379

    
1380
esScriptAttach :: String
1381
esScriptAttach = esActionAttach
1382

    
1383
esScriptDetach :: String
1384
esScriptDetach = esActionDetach
1385

    
1386
esScriptSetinfo :: String
1387
esScriptSetinfo = esActionSetinfo
1388

    
1389
esScriptVerify :: String
1390
esScriptVerify = esActionVerify
1391

    
1392
esScripts :: FrozenSet String
1393
esScripts =
1394
  ConstantUtils.mkSet [esScriptAttach,
1395
                       esScriptCreate,
1396
                       esScriptDetach,
1397
                       esScriptGrow,
1398
                       esScriptRemove,
1399
                       esScriptSetinfo,
1400
                       esScriptVerify]
1401

    
1402
esParametersFile :: String
1403
esParametersFile = "parameters.list"
1404

    
1405
-- * Reboot types
1406

    
1407
instanceRebootSoft :: String
1408
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1409

    
1410
instanceRebootHard :: String
1411
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1412

    
1413
instanceRebootFull :: String
1414
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1415

    
1416
rebootTypes :: FrozenSet String
1417
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1418

    
1419
-- * Instance reboot behaviors
1420

    
1421
instanceRebootAllowed :: String
1422
instanceRebootAllowed = "reboot"
1423

    
1424
instanceRebootExit :: String
1425
instanceRebootExit = "exit"
1426

    
1427
rebootBehaviors :: [String]
1428
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1429

    
1430
-- * VTypes
1431

    
1432
vtypeBool :: VType
1433
vtypeBool = VTypeBool
1434

    
1435
vtypeInt :: VType
1436
vtypeInt = VTypeInt
1437

    
1438
vtypeMaybeString :: VType
1439
vtypeMaybeString = VTypeMaybeString
1440

    
1441
-- | Size in MiBs
1442
vtypeSize :: VType
1443
vtypeSize = VTypeSize
1444

    
1445
vtypeString :: VType
1446
vtypeString = VTypeString
1447

    
1448
enforceableTypes :: FrozenSet VType
1449
enforceableTypes = ConstantUtils.mkSet [minBound..]
1450

    
1451
-- | Constant representing that the user does not specify any IP version
1452
ifaceNoIpVersionSpecified :: Int
1453
ifaceNoIpVersionSpecified = 0
1454

    
1455
validSerialSpeeds :: [Int]
1456
validSerialSpeeds =
1457
  [75,
1458
   110,
1459
   300,
1460
   600,
1461
   1200,
1462
   1800,
1463
   2400,
1464
   4800,
1465
   9600,
1466
   14400,
1467
   19200,
1468
   28800,
1469
   38400,
1470
   57600,
1471
   115200,
1472
   230400,
1473
   345600,
1474
   460800]
1475

    
1476
-- * HV parameter names (global namespace)
1477

    
1478
hvAcpi :: String
1479
hvAcpi = "acpi"
1480

    
1481
hvBlockdevPrefix :: String
1482
hvBlockdevPrefix = "blockdev_prefix"
1483

    
1484
hvBootloaderArgs :: String
1485
hvBootloaderArgs = "bootloader_args"
1486

    
1487
hvBootloaderPath :: String
1488
hvBootloaderPath = "bootloader_path"
1489

    
1490
hvBootOrder :: String
1491
hvBootOrder = "boot_order"
1492

    
1493
hvCdromImagePath :: String
1494
hvCdromImagePath = "cdrom_image_path"
1495

    
1496
hvCpuCap :: String
1497
hvCpuCap = "cpu_cap"
1498

    
1499
hvCpuCores :: String
1500
hvCpuCores = "cpu_cores"
1501

    
1502
hvCpuMask :: String
1503
hvCpuMask = "cpu_mask"
1504

    
1505
hvCpuSockets :: String
1506
hvCpuSockets = "cpu_sockets"
1507

    
1508
hvCpuThreads :: String
1509
hvCpuThreads = "cpu_threads"
1510

    
1511
hvCpuType :: String
1512
hvCpuType = "cpu_type"
1513

    
1514
hvCpuWeight :: String
1515
hvCpuWeight = "cpu_weight"
1516

    
1517
hvDeviceModel :: String
1518
hvDeviceModel = "device_model"
1519

    
1520
hvDiskCache :: String
1521
hvDiskCache = "disk_cache"
1522

    
1523
hvDiskType :: String
1524
hvDiskType = "disk_type"
1525

    
1526
hvInitrdPath :: String
1527
hvInitrdPath = "initrd_path"
1528

    
1529
hvInitScript :: String
1530
hvInitScript = "init_script"
1531

    
1532
hvKernelArgs :: String
1533
hvKernelArgs = "kernel_args"
1534

    
1535
hvKernelPath :: String
1536
hvKernelPath = "kernel_path"
1537

    
1538
hvKeymap :: String
1539
hvKeymap = "keymap"
1540

    
1541
hvKvmCdrom2ImagePath :: String
1542
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1543

    
1544
hvKvmCdromDiskType :: String
1545
hvKvmCdromDiskType = "cdrom_disk_type"
1546

    
1547
hvKvmExtra :: String
1548
hvKvmExtra = "kvm_extra"
1549

    
1550
hvKvmFlag :: String
1551
hvKvmFlag = "kvm_flag"
1552

    
1553
hvKvmFloppyImagePath :: String
1554
hvKvmFloppyImagePath = "floppy_image_path"
1555

    
1556
hvKvmMachineVersion :: String
1557
hvKvmMachineVersion = "machine_version"
1558

    
1559
hvKvmPath :: String
1560
hvKvmPath = "kvm_path"
1561

    
1562
hvKvmSpiceAudioCompr :: String
1563
hvKvmSpiceAudioCompr = "spice_playback_compression"
1564

    
1565
hvKvmSpiceBind :: String
1566
hvKvmSpiceBind = "spice_bind"
1567

    
1568
hvKvmSpiceIpVersion :: String
1569
hvKvmSpiceIpVersion = "spice_ip_version"
1570

    
1571
hvKvmSpiceJpegImgCompr :: String
1572
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1573

    
1574
hvKvmSpiceLosslessImgCompr :: String
1575
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1576

    
1577
hvKvmSpicePasswordFile :: String
1578
hvKvmSpicePasswordFile = "spice_password_file"
1579

    
1580
hvKvmSpiceStreamingVideoDetection :: String
1581
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1582

    
1583
hvKvmSpiceTlsCiphers :: String
1584
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1585

    
1586
hvKvmSpiceUseTls :: String
1587
hvKvmSpiceUseTls = "spice_use_tls"
1588

    
1589
hvKvmSpiceUseVdagent :: String
1590
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1591

    
1592
hvKvmSpiceZlibGlzImgCompr :: String
1593
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1594

    
1595
hvKvmUseChroot :: String
1596
hvKvmUseChroot = "use_chroot"
1597

    
1598
hvKvmUserShutdown :: String
1599
hvKvmUserShutdown = "user_shutdown"
1600

    
1601
hvMemPath :: String
1602
hvMemPath = "mem_path"
1603

    
1604
hvMigrationBandwidth :: String
1605
hvMigrationBandwidth = "migration_bandwidth"
1606

    
1607
hvMigrationDowntime :: String
1608
hvMigrationDowntime = "migration_downtime"
1609

    
1610
hvMigrationMode :: String
1611
hvMigrationMode = "migration_mode"
1612

    
1613
hvMigrationPort :: String
1614
hvMigrationPort = "migration_port"
1615

    
1616
hvNicType :: String
1617
hvNicType = "nic_type"
1618

    
1619
hvPae :: String
1620
hvPae = "pae"
1621

    
1622
hvPassthrough :: String
1623
hvPassthrough = "pci_pass"
1624

    
1625
hvRebootBehavior :: String
1626
hvRebootBehavior = "reboot_behavior"
1627

    
1628
hvRootPath :: String
1629
hvRootPath = "root_path"
1630

    
1631
hvSecurityDomain :: String
1632
hvSecurityDomain = "security_domain"
1633

    
1634
hvSecurityModel :: String
1635
hvSecurityModel = "security_model"
1636

    
1637
hvSerialConsole :: String
1638
hvSerialConsole = "serial_console"
1639

    
1640
hvSerialSpeed :: String
1641
hvSerialSpeed = "serial_speed"
1642

    
1643
hvSoundhw :: String
1644
hvSoundhw = "soundhw"
1645

    
1646
hvUsbDevices :: String
1647
hvUsbDevices = "usb_devices"
1648

    
1649
hvUsbMouse :: String
1650
hvUsbMouse = "usb_mouse"
1651

    
1652
hvUseBootloader :: String
1653
hvUseBootloader = "use_bootloader"
1654

    
1655
hvUseLocaltime :: String
1656
hvUseLocaltime = "use_localtime"
1657

    
1658
hvVga :: String
1659
hvVga = "vga"
1660

    
1661
hvVhostNet :: String
1662
hvVhostNet = "vhost_net"
1663

    
1664
hvVifScript :: String
1665
hvVifScript = "vif_script"
1666

    
1667
hvVifType :: String
1668
hvVifType = "vif_type"
1669

    
1670
hvViridian :: String
1671
hvViridian = "viridian"
1672

    
1673
hvVncBindAddress :: String
1674
hvVncBindAddress = "vnc_bind_address"
1675

    
1676
hvVncPasswordFile :: String
1677
hvVncPasswordFile = "vnc_password_file"
1678

    
1679
hvVncTls :: String
1680
hvVncTls = "vnc_tls"
1681

    
1682
hvVncX509 :: String
1683
hvVncX509 = "vnc_x509_path"
1684

    
1685
hvVncX509Verify :: String
1686
hvVncX509Verify = "vnc_x509_verify"
1687

    
1688
hvVnetHdr :: String
1689
hvVnetHdr = "vnet_hdr"
1690

    
1691
hvXenCmd :: String
1692
hvXenCmd = "xen_cmd"
1693

    
1694
hvXenCpuid :: String
1695
hvXenCpuid = "cpuid"
1696

    
1697
hvsParameterTitles :: Map String String
1698
hvsParameterTitles =
1699
  Map.fromList
1700
  [(hvAcpi, "ACPI"),
1701
   (hvBootOrder, "Boot_order"),
1702
   (hvCdromImagePath, "CDROM_image_path"),
1703
   (hvCpuType, "cpu_type"),
1704
   (hvDiskType, "Disk_type"),
1705
   (hvInitrdPath, "Initrd_path"),
1706
   (hvKernelPath, "Kernel_path"),
1707
   (hvNicType, "NIC_type"),
1708
   (hvPae, "PAE"),
1709
   (hvPassthrough, "pci_pass"),
1710
   (hvVncBindAddress, "VNC_bind_address")]
1711

    
1712
hvsParameters :: FrozenSet String
1713
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1714

    
1715
hvsParameterTypes :: Map String VType
1716
hvsParameterTypes = Map.fromList
1717
  [ (hvAcpi,                            VTypeBool)
1718
  , (hvBlockdevPrefix,                  VTypeString)
1719
  , (hvBootloaderArgs,                  VTypeString)
1720
  , (hvBootloaderPath,                  VTypeString)
1721
  , (hvBootOrder,                       VTypeString)
1722
  , (hvCdromImagePath,                  VTypeString)
1723
  , (hvCpuCap,                          VTypeInt)
1724
  , (hvCpuCores,                        VTypeInt)
1725
  , (hvCpuMask,                         VTypeString)
1726
  , (hvCpuSockets,                      VTypeInt)
1727
  , (hvCpuThreads,                      VTypeInt)
1728
  , (hvCpuType,                         VTypeString)
1729
  , (hvCpuWeight,                       VTypeInt)
1730
  , (hvDeviceModel,                     VTypeString)
1731
  , (hvDiskCache,                       VTypeString)
1732
  , (hvDiskType,                        VTypeString)
1733
  , (hvInitrdPath,                      VTypeString)
1734
  , (hvInitScript,                      VTypeString)
1735
  , (hvKernelArgs,                      VTypeString)
1736
  , (hvKernelPath,                      VTypeString)
1737
  , (hvKeymap,                          VTypeString)
1738
  , (hvKvmCdrom2ImagePath,              VTypeString)
1739
  , (hvKvmCdromDiskType,                VTypeString)
1740
  , (hvKvmExtra,                        VTypeString)
1741
  , (hvKvmFlag,                         VTypeString)
1742
  , (hvKvmFloppyImagePath,              VTypeString)
1743
  , (hvKvmMachineVersion,               VTypeString)
1744
  , (hvKvmPath,                         VTypeString)
1745
  , (hvKvmSpiceAudioCompr,              VTypeBool)
1746
  , (hvKvmSpiceBind,                    VTypeString)
1747
  , (hvKvmSpiceIpVersion,               VTypeInt)
1748
  , (hvKvmSpiceJpegImgCompr,            VTypeString)
1749
  , (hvKvmSpiceLosslessImgCompr,        VTypeString)
1750
  , (hvKvmSpicePasswordFile,            VTypeString)
1751
  , (hvKvmSpiceStreamingVideoDetection, VTypeString)
1752
  , (hvKvmSpiceTlsCiphers,              VTypeString)
1753
  , (hvKvmSpiceUseTls,                  VTypeBool)
1754
  , (hvKvmSpiceUseVdagent,              VTypeBool)
1755
  , (hvKvmSpiceZlibGlzImgCompr,         VTypeString)
1756
  , (hvKvmUseChroot,                    VTypeBool)
1757
  , (hvKvmUserShutdown,                 VTypeBool)
1758
  , (hvMemPath,                         VTypeString)
1759
  , (hvMigrationBandwidth,              VTypeInt)
1760
  , (hvMigrationDowntime,               VTypeInt)
1761
  , (hvMigrationMode,                   VTypeString)
1762
  , (hvMigrationPort,                   VTypeInt)
1763
  , (hvNicType,                         VTypeString)
1764
  , (hvPae,                             VTypeBool)
1765
  , (hvPassthrough,                     VTypeString)
1766
  , (hvRebootBehavior,                  VTypeString)
1767
  , (hvRootPath,                        VTypeMaybeString)
1768
  , (hvSecurityDomain,                  VTypeString)
1769
  , (hvSecurityModel,                   VTypeString)
1770
  , (hvSerialConsole,                   VTypeBool)
1771
  , (hvSerialSpeed,                     VTypeInt)
1772
  , (hvSoundhw,                         VTypeString)
1773
  , (hvUsbDevices,                      VTypeString)
1774
  , (hvUsbMouse,                        VTypeString)
1775
  , (hvUseBootloader,                   VTypeBool)
1776
  , (hvUseLocaltime,                    VTypeBool)
1777
  , (hvVga,                             VTypeString)
1778
  , (hvVhostNet,                        VTypeBool)
1779
  , (hvVifScript,                       VTypeString)
1780
  , (hvVifType,                         VTypeString)
1781
  , (hvViridian,                        VTypeBool)
1782
  , (hvVncBindAddress,                  VTypeString)
1783
  , (hvVncPasswordFile,                 VTypeString)
1784
  , (hvVncTls,                          VTypeBool)
1785
  , (hvVncX509,                         VTypeString)
1786
  , (hvVncX509Verify,                   VTypeBool)
1787
  , (hvVnetHdr,                         VTypeBool)
1788
  , (hvXenCmd,                          VTypeString)
1789
  , (hvXenCpuid,                        VTypeString)
1790
  ]
1791

    
1792
-- * Migration statuses
1793

    
1794
hvMigrationActive :: String
1795
hvMigrationActive = "active"
1796

    
1797
hvMigrationCancelled :: String
1798
hvMigrationCancelled = "cancelled"
1799

    
1800
hvMigrationCompleted :: String
1801
hvMigrationCompleted = "completed"
1802

    
1803
hvMigrationFailed :: String
1804
hvMigrationFailed = "failed"
1805

    
1806
hvMigrationValidStatuses :: FrozenSet String
1807
hvMigrationValidStatuses =
1808
  ConstantUtils.mkSet [hvMigrationActive,
1809
                       hvMigrationCancelled,
1810
                       hvMigrationCompleted,
1811
                       hvMigrationFailed]
1812

    
1813
hvMigrationFailedStatuses :: FrozenSet String
1814
hvMigrationFailedStatuses =
1815
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1816

    
1817
-- | KVM-specific statuses
1818
--
1819
-- FIXME: this constant seems unnecessary
1820
hvKvmMigrationValidStatuses :: FrozenSet String
1821
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1822

    
1823
-- | Node info keys
1824
hvNodeinfoKeyVersion :: String
1825
hvNodeinfoKeyVersion = "hv_version"
1826

    
1827
-- * Hypervisor state
1828

    
1829
hvstCpuNode :: String
1830
hvstCpuNode = "cpu_node"
1831

    
1832
hvstCpuTotal :: String
1833
hvstCpuTotal = "cpu_total"
1834

    
1835
hvstMemoryHv :: String
1836
hvstMemoryHv = "mem_hv"
1837

    
1838
hvstMemoryNode :: String
1839
hvstMemoryNode = "mem_node"
1840

    
1841
hvstMemoryTotal :: String
1842
hvstMemoryTotal = "mem_total"
1843

    
1844
hvstsParameters :: FrozenSet String
1845
hvstsParameters =
1846
  ConstantUtils.mkSet [hvstCpuNode,
1847
                       hvstCpuTotal,
1848
                       hvstMemoryHv,
1849
                       hvstMemoryNode,
1850
                       hvstMemoryTotal]
1851

    
1852
hvstDefaults :: Map String Int
1853
hvstDefaults =
1854
  Map.fromList
1855
  [(hvstCpuNode, 1),
1856
   (hvstCpuTotal, 1),
1857
   (hvstMemoryHv, 0),
1858
   (hvstMemoryTotal, 0),
1859
   (hvstMemoryNode, 0)]
1860

    
1861
hvstsParameterTypes :: Map String VType
1862
hvstsParameterTypes =
1863
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1864
                (hvstMemoryNode, VTypeInt),
1865
                (hvstMemoryHv, VTypeInt),
1866
                (hvstCpuTotal, VTypeInt),
1867
                (hvstCpuNode, VTypeInt)]
1868

    
1869
-- * Disk state
1870

    
1871
dsDiskOverhead :: String
1872
dsDiskOverhead = "disk_overhead"
1873

    
1874
dsDiskReserved :: String
1875
dsDiskReserved = "disk_reserved"
1876

    
1877
dsDiskTotal :: String
1878
dsDiskTotal = "disk_total"
1879

    
1880
dsDefaults :: Map String Int
1881
dsDefaults =
1882
  Map.fromList
1883
  [(dsDiskTotal, 0),
1884
   (dsDiskReserved, 0),
1885
   (dsDiskOverhead, 0)]
1886

    
1887
dssParameterTypes :: Map String VType
1888
dssParameterTypes =
1889
  Map.fromList [(dsDiskTotal, VTypeInt),
1890
                (dsDiskReserved, VTypeInt),
1891
                (dsDiskOverhead, VTypeInt)]
1892

    
1893
dssParameters :: FrozenSet String
1894
dssParameters =
1895
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1896

    
1897
dsValidTypes :: FrozenSet String
1898
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1899

    
1900
-- Backend parameter names
1901

    
1902
beAlwaysFailover :: String
1903
beAlwaysFailover = "always_failover"
1904

    
1905
beAutoBalance :: String
1906
beAutoBalance = "auto_balance"
1907

    
1908
beMaxmem :: String
1909
beMaxmem = "maxmem"
1910

    
1911
-- | Deprecated and replaced by max and min mem
1912
beMemory :: String
1913
beMemory = "memory"
1914

    
1915
beMinmem :: String
1916
beMinmem = "minmem"
1917

    
1918
beSpindleUse :: String
1919
beSpindleUse = "spindle_use"
1920

    
1921
beVcpus :: String
1922
beVcpus = "vcpus"
1923

    
1924
besParameterTypes :: Map String VType
1925
besParameterTypes =
1926
  Map.fromList [(beAlwaysFailover, VTypeBool),
1927
                (beAutoBalance, VTypeBool),
1928
                (beMaxmem, VTypeSize),
1929
                (beMinmem, VTypeSize),
1930
                (beSpindleUse, VTypeInt),
1931
                (beVcpus, VTypeInt)]
1932

    
1933
besParameterTitles :: Map String String
1934
besParameterTitles =
1935
  Map.fromList [(beAutoBalance, "Auto_balance"),
1936
                (beMinmem, "ConfigMinMem"),
1937
                (beVcpus, "ConfigVCPUs"),
1938
                (beMaxmem, "ConfigMaxMem")]
1939

    
1940
besParameterCompat :: Map String VType
1941
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1942

    
1943
besParameters :: FrozenSet String
1944
besParameters =
1945
  ConstantUtils.mkSet [beAlwaysFailover,
1946
                       beAutoBalance,
1947
                       beMaxmem,
1948
                       beMinmem,
1949
                       beSpindleUse,
1950
                       beVcpus]
1951

    
1952
-- | Instance specs
1953
--
1954
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1955

    
1956
ispecMemSize :: String
1957
ispecMemSize = ConstantUtils.ispecMemSize
1958

    
1959
ispecCpuCount :: String
1960
ispecCpuCount = ConstantUtils.ispecCpuCount
1961

    
1962
ispecDiskCount :: String
1963
ispecDiskCount = ConstantUtils.ispecDiskCount
1964

    
1965
ispecDiskSize :: String
1966
ispecDiskSize = ConstantUtils.ispecDiskSize
1967

    
1968
ispecNicCount :: String
1969
ispecNicCount = ConstantUtils.ispecNicCount
1970

    
1971
ispecSpindleUse :: String
1972
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1973

    
1974
ispecsParameterTypes :: Map String VType
1975
ispecsParameterTypes =
1976
  Map.fromList
1977
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1978
   (ConstantUtils.ispecCpuCount, VTypeInt),
1979
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1980
   (ConstantUtils.ispecMemSize, VTypeInt),
1981
   (ConstantUtils.ispecNicCount, VTypeInt),
1982
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1983

    
1984
ispecsParameters :: FrozenSet String
1985
ispecsParameters =
1986
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1987
                       ConstantUtils.ispecDiskCount,
1988
                       ConstantUtils.ispecDiskSize,
1989
                       ConstantUtils.ispecMemSize,
1990
                       ConstantUtils.ispecNicCount,
1991
                       ConstantUtils.ispecSpindleUse]
1992

    
1993
ispecsMinmax :: String
1994
ispecsMinmax = ConstantUtils.ispecsMinmax
1995

    
1996
ispecsMax :: String
1997
ispecsMax = "max"
1998

    
1999
ispecsMin :: String
2000
ispecsMin = "min"
2001

    
2002
ispecsStd :: String
2003
ispecsStd = ConstantUtils.ispecsStd
2004

    
2005
ipolicyDts :: String
2006
ipolicyDts = ConstantUtils.ipolicyDts
2007

    
2008
ipolicyVcpuRatio :: String
2009
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
2010

    
2011
ipolicySpindleRatio :: String
2012
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
2013

    
2014
ispecsMinmaxKeys :: FrozenSet String
2015
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
2016

    
2017
ipolicyParameters :: FrozenSet String
2018
ipolicyParameters =
2019
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
2020
                       ConstantUtils.ipolicySpindleRatio]
2021

    
2022
ipolicyAllKeys :: FrozenSet String
2023
ipolicyAllKeys =
2024
  ConstantUtils.union ipolicyParameters $
2025
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
2026
                       ConstantUtils.ispecsMinmax,
2027
                       ispecsStd]
2028

    
2029
-- | Node parameter names
2030

    
2031
ndExclusiveStorage :: String
2032
ndExclusiveStorage = "exclusive_storage"
2033

    
2034
ndOobProgram :: String
2035
ndOobProgram = "oob_program"
2036

    
2037
ndSpindleCount :: String
2038
ndSpindleCount = "spindle_count"
2039

    
2040
ndOvs :: String
2041
ndOvs = "ovs"
2042

    
2043
ndOvsLink :: String
2044
ndOvsLink = "ovs_link"
2045

    
2046
ndOvsName :: String
2047
ndOvsName = "ovs_name"
2048

    
2049
ndSshPort :: String
2050
ndSshPort = "ssh_port"
2051

    
2052
ndsParameterTypes :: Map String VType
2053
ndsParameterTypes =
2054
  Map.fromList
2055
  [(ndExclusiveStorage, VTypeBool),
2056
   (ndOobProgram, VTypeString),
2057
   (ndOvs, VTypeBool),
2058
   (ndOvsLink, VTypeMaybeString),
2059
   (ndOvsName, VTypeMaybeString),
2060
   (ndSpindleCount, VTypeInt),
2061
   (ndSshPort, VTypeInt)]
2062

    
2063
ndsParameters :: FrozenSet String
2064
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
2065

    
2066
ndsParameterTitles :: Map String String
2067
ndsParameterTitles =
2068
  Map.fromList
2069
  [(ndExclusiveStorage, "ExclusiveStorage"),
2070
   (ndOobProgram, "OutOfBandProgram"),
2071
   (ndOvs, "OpenvSwitch"),
2072
   (ndOvsLink, "OpenvSwitchLink"),
2073
   (ndOvsName, "OpenvSwitchName"),
2074
   (ndSpindleCount, "SpindleCount")]
2075

    
2076
-- * Logical Disks parameters
2077

    
2078
ldpAccess :: String
2079
ldpAccess = "access"
2080

    
2081
ldpBarriers :: String
2082
ldpBarriers = "disabled-barriers"
2083

    
2084
ldpDefaultMetavg :: String
2085
ldpDefaultMetavg = "default-metavg"
2086

    
2087
ldpDelayTarget :: String
2088
ldpDelayTarget = "c-delay-target"
2089

    
2090
ldpDiskCustom :: String
2091
ldpDiskCustom = "disk-custom"
2092

    
2093
ldpDynamicResync :: String
2094
ldpDynamicResync = "dynamic-resync"
2095

    
2096
ldpFillTarget :: String
2097
ldpFillTarget = "c-fill-target"
2098

    
2099
ldpMaxRate :: String
2100
ldpMaxRate = "c-max-rate"
2101

    
2102
ldpMinRate :: String
2103
ldpMinRate = "c-min-rate"
2104

    
2105
ldpNetCustom :: String
2106
ldpNetCustom = "net-custom"
2107

    
2108
ldpNoMetaFlush :: String
2109
ldpNoMetaFlush = "disable-meta-flush"
2110

    
2111
ldpPlanAhead :: String
2112
ldpPlanAhead = "c-plan-ahead"
2113

    
2114
ldpPool :: String
2115
ldpPool = "pool"
2116

    
2117
ldpProtocol :: String
2118
ldpProtocol = "protocol"
2119

    
2120
ldpResyncRate :: String
2121
ldpResyncRate = "resync-rate"
2122

    
2123
ldpStripes :: String
2124
ldpStripes = "stripes"
2125

    
2126
diskLdTypes :: Map String VType
2127
diskLdTypes =
2128
  Map.fromList
2129
  [(ldpAccess, VTypeString),
2130
   (ldpResyncRate, VTypeInt),
2131
   (ldpStripes, VTypeInt),
2132
   (ldpBarriers, VTypeString),
2133
   (ldpNoMetaFlush, VTypeBool),
2134
   (ldpDefaultMetavg, VTypeString),
2135
   (ldpDiskCustom, VTypeString),
2136
   (ldpNetCustom, VTypeString),
2137
   (ldpProtocol, VTypeString),
2138
   (ldpDynamicResync, VTypeBool),
2139
   (ldpPlanAhead, VTypeInt),
2140
   (ldpFillTarget, VTypeInt),
2141
   (ldpDelayTarget, VTypeInt),
2142
   (ldpMaxRate, VTypeInt),
2143
   (ldpMinRate, VTypeInt),
2144
   (ldpPool, VTypeString)]
2145

    
2146
diskLdParameters :: FrozenSet String
2147
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2148

    
2149
-- * Disk template parameters
2150
--
2151
-- Disk template parameters can be set/changed by the user via
2152
-- gnt-cluster and gnt-group)
2153

    
2154
drbdResyncRate :: String
2155
drbdResyncRate = "resync-rate"
2156

    
2157
drbdDataStripes :: String
2158
drbdDataStripes = "data-stripes"
2159

    
2160
drbdMetaStripes :: String
2161
drbdMetaStripes = "meta-stripes"
2162

    
2163
drbdDiskBarriers :: String
2164
drbdDiskBarriers = "disk-barriers"
2165

    
2166
drbdMetaBarriers :: String
2167
drbdMetaBarriers = "meta-barriers"
2168

    
2169
drbdDefaultMetavg :: String
2170
drbdDefaultMetavg = "metavg"
2171

    
2172
drbdDiskCustom :: String
2173
drbdDiskCustom = "disk-custom"
2174

    
2175
drbdNetCustom :: String
2176
drbdNetCustom = "net-custom"
2177

    
2178
drbdProtocol :: String
2179
drbdProtocol = "protocol"
2180

    
2181
drbdDynamicResync :: String
2182
drbdDynamicResync = "dynamic-resync"
2183

    
2184
drbdPlanAhead :: String
2185
drbdPlanAhead = "c-plan-ahead"
2186

    
2187
drbdFillTarget :: String
2188
drbdFillTarget = "c-fill-target"
2189

    
2190
drbdDelayTarget :: String
2191
drbdDelayTarget = "c-delay-target"
2192

    
2193
drbdMaxRate :: String
2194
drbdMaxRate = "c-max-rate"
2195

    
2196
drbdMinRate :: String
2197
drbdMinRate = "c-min-rate"
2198

    
2199
lvStripes :: String
2200
lvStripes = "stripes"
2201

    
2202
rbdAccess :: String
2203
rbdAccess = "access"
2204

    
2205
rbdPool :: String
2206
rbdPool = "pool"
2207

    
2208
diskDtTypes :: Map String VType
2209
diskDtTypes =
2210
  Map.fromList [(drbdResyncRate, VTypeInt),
2211
                (drbdDataStripes, VTypeInt),
2212
                (drbdMetaStripes, VTypeInt),
2213
                (drbdDiskBarriers, VTypeString),
2214
                (drbdMetaBarriers, VTypeBool),
2215
                (drbdDefaultMetavg, VTypeString),
2216
                (drbdDiskCustom, VTypeString),
2217
                (drbdNetCustom, VTypeString),
2218
                (drbdProtocol, VTypeString),
2219
                (drbdDynamicResync, VTypeBool),
2220
                (drbdPlanAhead, VTypeInt),
2221
                (drbdFillTarget, VTypeInt),
2222
                (drbdDelayTarget, VTypeInt),
2223
                (drbdMaxRate, VTypeInt),
2224
                (drbdMinRate, VTypeInt),
2225
                (lvStripes, VTypeInt),
2226
                (rbdAccess, VTypeString),
2227
                (rbdPool, VTypeString),
2228
                (glusterHost, VTypeString),
2229
                (glusterVolume, VTypeString),
2230
                (glusterPort, VTypeInt)
2231
               ]
2232

    
2233
diskDtParameters :: FrozenSet String
2234
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2235

    
2236
-- * Dynamic disk parameters
2237

    
2238
ddpLocalIp :: String
2239
ddpLocalIp = "local-ip"
2240

    
2241
ddpRemoteIp :: String
2242
ddpRemoteIp = "remote-ip"
2243

    
2244
ddpPort :: String
2245
ddpPort = "port"
2246

    
2247
ddpLocalMinor :: String
2248
ddpLocalMinor = "local-minor"
2249

    
2250
ddpRemoteMinor :: String
2251
ddpRemoteMinor = "remote-minor"
2252

    
2253
-- * OOB supported commands
2254

    
2255
oobPowerOn :: String
2256
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2257

    
2258
oobPowerOff :: String
2259
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2260

    
2261
oobPowerCycle :: String
2262
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2263

    
2264
oobPowerStatus :: String
2265
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2266

    
2267
oobHealth :: String
2268
oobHealth = Types.oobCommandToRaw OobHealth
2269

    
2270
oobCommands :: FrozenSet String
2271
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2272

    
2273
oobPowerStatusPowered :: String
2274
oobPowerStatusPowered = "powered"
2275

    
2276
-- | 60 seconds
2277
oobTimeout :: Int
2278
oobTimeout = 60
2279

    
2280
-- | 2 seconds
2281
oobPowerDelay :: Double
2282
oobPowerDelay = 2.0
2283

    
2284
oobStatusCritical :: String
2285
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2286

    
2287
oobStatusOk :: String
2288
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2289

    
2290
oobStatusUnknown :: String
2291
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2292

    
2293
oobStatusWarning :: String
2294
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2295

    
2296
oobStatuses :: FrozenSet String
2297
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2298

    
2299
-- | Instance Parameters Profile
2300
ppDefault :: String
2301
ppDefault = "default"
2302

    
2303
-- * nic* constants are used inside the ganeti config
2304

    
2305
nicLink :: String
2306
nicLink = "link"
2307

    
2308
nicMode :: String
2309
nicMode = "mode"
2310

    
2311
nicVlan :: String
2312
nicVlan = "vlan"
2313

    
2314
nicsParameterTypes :: Map String VType
2315
nicsParameterTypes =
2316
  Map.fromList [(nicMode, vtypeString),
2317
                (nicLink, vtypeString),
2318
                (nicVlan, vtypeString)]
2319

    
2320
nicsParameters :: FrozenSet String
2321
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2322

    
2323
nicModeBridged :: String
2324
nicModeBridged = Types.nICModeToRaw NMBridged
2325

    
2326
nicModeRouted :: String
2327
nicModeRouted = Types.nICModeToRaw NMRouted
2328

    
2329
nicModeOvs :: String
2330
nicModeOvs = Types.nICModeToRaw NMOvs
2331

    
2332
nicIpPool :: String
2333
nicIpPool = Types.nICModeToRaw NMPool
2334

    
2335
nicValidModes :: FrozenSet String
2336
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2337

    
2338
releaseAction :: String
2339
releaseAction = "release"
2340

    
2341
reserveAction :: String
2342
reserveAction = "reserve"
2343

    
2344
-- * idisk* constants are used in opcodes, to create/change disks
2345

    
2346
idiskAdopt :: String
2347
idiskAdopt = "adopt"
2348

    
2349
idiskMetavg :: String
2350
idiskMetavg = "metavg"
2351

    
2352
idiskMode :: String
2353
idiskMode = "mode"
2354

    
2355
idiskName :: String
2356
idiskName = "name"
2357

    
2358
idiskSize :: String
2359
idiskSize = "size"
2360

    
2361
idiskSpindles :: String
2362
idiskSpindles = "spindles"
2363

    
2364
idiskVg :: String
2365
idiskVg = "vg"
2366

    
2367
idiskProvider :: String
2368
idiskProvider = "provider"
2369

    
2370
idiskParamsTypes :: Map String VType
2371
idiskParamsTypes =
2372
  Map.fromList [(idiskSize, VTypeSize),
2373
                (idiskSpindles, VTypeInt),
2374
                (idiskMode, VTypeString),
2375
                (idiskAdopt, VTypeString),
2376
                (idiskVg, VTypeString),
2377
                (idiskMetavg, VTypeString),
2378
                (idiskProvider, VTypeString),
2379
                (idiskName, VTypeMaybeString)]
2380

    
2381
idiskParams :: FrozenSet String
2382
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2383

    
2384
modifiableIdiskParamsTypes :: Map String VType
2385
modifiableIdiskParamsTypes =
2386
  Map.fromList [(idiskMode, VTypeString),
2387
                (idiskName, VTypeString)]
2388

    
2389
modifiableIdiskParams :: FrozenSet String
2390
modifiableIdiskParams =
2391
  ConstantUtils.mkSet (Map.keys modifiableIdiskParamsTypes)
2392

    
2393
-- * inic* constants are used in opcodes, to create/change nics
2394

    
2395
inicBridge :: String
2396
inicBridge = "bridge"
2397

    
2398
inicIp :: String
2399
inicIp = "ip"
2400

    
2401
inicLink :: String
2402
inicLink = "link"
2403

    
2404
inicMac :: String
2405
inicMac = "mac"
2406

    
2407
inicMode :: String
2408
inicMode = "mode"
2409

    
2410
inicName :: String
2411
inicName = "name"
2412

    
2413
inicNetwork :: String
2414
inicNetwork = "network"
2415

    
2416
inicVlan :: String
2417
inicVlan = "vlan"
2418

    
2419
inicParamsTypes :: Map String VType
2420
inicParamsTypes =
2421
  Map.fromList [(inicBridge, VTypeMaybeString),
2422
                (inicIp, VTypeMaybeString),
2423
                (inicLink, VTypeString),
2424
                (inicMac, VTypeString),
2425
                (inicMode, VTypeString),
2426
                (inicName, VTypeMaybeString),
2427
                (inicNetwork, VTypeMaybeString),
2428
                (inicVlan, VTypeMaybeString)]
2429

    
2430
inicParams :: FrozenSet String
2431
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2432

    
2433
-- * Hypervisor constants
2434

    
2435
htXenPvm :: String
2436
htXenPvm = Types.hypervisorToRaw XenPvm
2437

    
2438
htFake :: String
2439
htFake = Types.hypervisorToRaw Fake
2440

    
2441
htXenHvm :: String
2442
htXenHvm = Types.hypervisorToRaw XenHvm
2443

    
2444
htKvm :: String
2445
htKvm = Types.hypervisorToRaw Kvm
2446

    
2447
htChroot :: String
2448
htChroot = Types.hypervisorToRaw Chroot
2449

    
2450
htLxc :: String
2451
htLxc = Types.hypervisorToRaw Lxc
2452

    
2453
hyperTypes :: FrozenSet String
2454
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2455

    
2456
htsReqPort :: FrozenSet String
2457
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2458

    
2459
vncBasePort :: Int
2460
vncBasePort = 5900
2461

    
2462
vncDefaultBindAddress :: String
2463
vncDefaultBindAddress = ip4AddressAny
2464

    
2465
-- * NIC types
2466

    
2467
htNicE1000 :: String
2468
htNicE1000 = "e1000"
2469

    
2470
htNicI82551 :: String
2471
htNicI82551 = "i82551"
2472

    
2473
htNicI8259er :: String
2474
htNicI8259er = "i82559er"
2475

    
2476
htNicI85557b :: String
2477
htNicI85557b = "i82557b"
2478

    
2479
htNicNe2kIsa :: String
2480
htNicNe2kIsa = "ne2k_isa"
2481

    
2482
htNicNe2kPci :: String
2483
htNicNe2kPci = "ne2k_pci"
2484

    
2485
htNicParavirtual :: String
2486
htNicParavirtual = "paravirtual"
2487

    
2488
htNicPcnet :: String
2489
htNicPcnet = "pcnet"
2490

    
2491
htNicRtl8139 :: String
2492
htNicRtl8139 = "rtl8139"
2493

    
2494
htHvmValidNicTypes :: FrozenSet String
2495
htHvmValidNicTypes =
2496
  ConstantUtils.mkSet [htNicE1000,
2497
                       htNicNe2kIsa,
2498
                       htNicNe2kPci,
2499
                       htNicParavirtual,
2500
                       htNicRtl8139]
2501

    
2502
htKvmValidNicTypes :: FrozenSet String
2503
htKvmValidNicTypes =
2504
  ConstantUtils.mkSet [htNicE1000,
2505
                       htNicI82551,
2506
                       htNicI8259er,
2507
                       htNicI85557b,
2508
                       htNicNe2kIsa,
2509
                       htNicNe2kPci,
2510
                       htNicParavirtual,
2511
                       htNicPcnet,
2512
                       htNicRtl8139]
2513

    
2514
-- * Vif types
2515

    
2516
-- | Default vif type in xen-hvm
2517
htHvmVifIoemu :: String
2518
htHvmVifIoemu = "ioemu"
2519

    
2520
htHvmVifVif :: String
2521
htHvmVifVif = "vif"
2522

    
2523
htHvmValidVifTypes :: FrozenSet String
2524
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2525

    
2526
-- * Disk types
2527

    
2528
htDiskIde :: String
2529
htDiskIde = "ide"
2530

    
2531
htDiskIoemu :: String
2532
htDiskIoemu = "ioemu"
2533

    
2534
htDiskMtd :: String
2535
htDiskMtd = "mtd"
2536

    
2537
htDiskParavirtual :: String
2538
htDiskParavirtual = "paravirtual"
2539

    
2540
htDiskPflash :: String
2541
htDiskPflash = "pflash"
2542

    
2543
htDiskScsi :: String
2544
htDiskScsi = "scsi"
2545

    
2546
htDiskSd :: String
2547
htDiskSd = "sd"
2548

    
2549
htHvmValidDiskTypes :: FrozenSet String
2550
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2551

    
2552
htKvmValidDiskTypes :: FrozenSet String
2553
htKvmValidDiskTypes =
2554
  ConstantUtils.mkSet [htDiskIde,
2555
                       htDiskMtd,
2556
                       htDiskParavirtual,
2557
                       htDiskPflash,
2558
                       htDiskScsi,
2559
                       htDiskSd]
2560

    
2561
htCacheDefault :: String
2562
htCacheDefault = "default"
2563

    
2564
htCacheNone :: String
2565
htCacheNone = "none"
2566

    
2567
htCacheWback :: String
2568
htCacheWback = "writeback"
2569

    
2570
htCacheWthrough :: String
2571
htCacheWthrough = "writethrough"
2572

    
2573
htValidCacheTypes :: FrozenSet String
2574
htValidCacheTypes =
2575
  ConstantUtils.mkSet [htCacheDefault,
2576
                       htCacheNone,
2577
                       htCacheWback,
2578
                       htCacheWthrough]
2579

    
2580
-- * Mouse types
2581

    
2582
htMouseMouse :: String
2583
htMouseMouse = "mouse"
2584

    
2585
htMouseTablet :: String
2586
htMouseTablet = "tablet"
2587

    
2588
htKvmValidMouseTypes :: FrozenSet String
2589
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2590

    
2591
-- * Boot order
2592

    
2593
htBoCdrom :: String
2594
htBoCdrom = "cdrom"
2595

    
2596
htBoDisk :: String
2597
htBoDisk = "disk"
2598

    
2599
htBoFloppy :: String
2600
htBoFloppy = "floppy"
2601

    
2602
htBoNetwork :: String
2603
htBoNetwork = "network"
2604

    
2605
htKvmValidBoTypes :: FrozenSet String
2606
htKvmValidBoTypes =
2607
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2608

    
2609
-- * SPICE lossless image compression options
2610

    
2611
htKvmSpiceLosslessImgComprAutoGlz :: String
2612
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2613

    
2614
htKvmSpiceLosslessImgComprAutoLz :: String
2615
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2616

    
2617
htKvmSpiceLosslessImgComprGlz :: String
2618
htKvmSpiceLosslessImgComprGlz = "glz"
2619

    
2620
htKvmSpiceLosslessImgComprLz :: String
2621
htKvmSpiceLosslessImgComprLz = "lz"
2622

    
2623
htKvmSpiceLosslessImgComprOff :: String
2624
htKvmSpiceLosslessImgComprOff = "off"
2625

    
2626
htKvmSpiceLosslessImgComprQuic :: String
2627
htKvmSpiceLosslessImgComprQuic = "quic"
2628

    
2629
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2630
htKvmSpiceValidLosslessImgComprOptions =
2631
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2632
                       htKvmSpiceLosslessImgComprAutoLz,
2633
                       htKvmSpiceLosslessImgComprGlz,
2634
                       htKvmSpiceLosslessImgComprLz,
2635
                       htKvmSpiceLosslessImgComprOff,
2636
                       htKvmSpiceLosslessImgComprQuic]
2637

    
2638
htKvmSpiceLossyImgComprAlways :: String
2639
htKvmSpiceLossyImgComprAlways = "always"
2640

    
2641
htKvmSpiceLossyImgComprAuto :: String
2642
htKvmSpiceLossyImgComprAuto = "auto"
2643

    
2644
htKvmSpiceLossyImgComprNever :: String
2645
htKvmSpiceLossyImgComprNever = "never"
2646

    
2647
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2648
htKvmSpiceValidLossyImgComprOptions =
2649
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2650
                       htKvmSpiceLossyImgComprAuto,
2651
                       htKvmSpiceLossyImgComprNever]
2652

    
2653
-- * SPICE video stream detection
2654

    
2655
htKvmSpiceVideoStreamDetectionAll :: String
2656
htKvmSpiceVideoStreamDetectionAll = "all"
2657

    
2658
htKvmSpiceVideoStreamDetectionFilter :: String
2659
htKvmSpiceVideoStreamDetectionFilter = "filter"
2660

    
2661
htKvmSpiceVideoStreamDetectionOff :: String
2662
htKvmSpiceVideoStreamDetectionOff = "off"
2663

    
2664
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2665
htKvmSpiceValidVideoStreamDetectionOptions =
2666
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2667
                       htKvmSpiceVideoStreamDetectionFilter,
2668
                       htKvmSpiceVideoStreamDetectionOff]
2669

    
2670
-- * Security models
2671

    
2672
htSmNone :: String
2673
htSmNone = "none"
2674

    
2675
htSmPool :: String
2676
htSmPool = "pool"
2677

    
2678
htSmUser :: String
2679
htSmUser = "user"
2680

    
2681
htKvmValidSmTypes :: FrozenSet String
2682
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2683

    
2684
-- * Kvm flag values
2685

    
2686
htKvmDisabled :: String
2687
htKvmDisabled = "disabled"
2688

    
2689
htKvmEnabled :: String
2690
htKvmEnabled = "enabled"
2691

    
2692
htKvmFlagValues :: FrozenSet String
2693
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2694

    
2695
-- * Migration type
2696

    
2697
htMigrationLive :: String
2698
htMigrationLive = Types.migrationModeToRaw MigrationLive
2699

    
2700
htMigrationNonlive :: String
2701
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2702

    
2703
htMigrationModes :: FrozenSet String
2704
htMigrationModes =
2705
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2706

    
2707
-- * Cluster verify steps
2708

    
2709
verifyNplusoneMem :: String
2710
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2711

    
2712
verifyOptionalChecks :: FrozenSet String
2713
verifyOptionalChecks =
2714
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2715

    
2716
-- * Cluster Verify error classes
2717

    
2718
cvTcluster :: String
2719
cvTcluster = "cluster"
2720

    
2721
cvTgroup :: String
2722
cvTgroup = "group"
2723

    
2724
cvTnode :: String
2725
cvTnode = "node"
2726

    
2727
cvTinstance :: String
2728
cvTinstance = "instance"
2729

    
2730
-- * Cluster Verify error levels
2731

    
2732
cvWarning :: String
2733
cvWarning = "WARNING"
2734

    
2735
cvError :: String
2736
cvError = "ERROR"
2737

    
2738
-- * Cluster Verify error codes and documentation
2739

    
2740
cvEclustercert :: (String, String, String)
2741
cvEclustercert =
2742
  ("cluster",
2743
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2744
   "Cluster certificate files verification failure")
2745

    
2746
cvEclusterclientcert :: (String, String, String)
2747
cvEclusterclientcert =
2748
  ("cluster",
2749
   Types.cVErrorCodeToRaw CvECLUSTERCLIENTCERT,
2750
   "Cluster client certificate files verification failure")
2751

    
2752
cvEclustercfg :: (String, String, String)
2753
cvEclustercfg =
2754
  ("cluster",
2755
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2756
   "Cluster configuration verification failure")
2757

    
2758
cvEclusterdanglinginst :: (String, String, String)
2759
cvEclusterdanglinginst =
2760
  ("node",
2761
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2762
   "Some instances have a non-existing primary node")
2763

    
2764
cvEclusterdanglingnodes :: (String, String, String)
2765
cvEclusterdanglingnodes =
2766
  ("node",
2767
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2768
   "Some nodes belong to non-existing groups")
2769

    
2770
cvEclusterfilecheck :: (String, String, String)
2771
cvEclusterfilecheck =
2772
  ("cluster",
2773
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2774
   "Cluster configuration verification failure")
2775

    
2776
cvEgroupdifferentpvsize :: (String, String, String)
2777
cvEgroupdifferentpvsize =
2778
  ("group",
2779
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2780
   "PVs in the group have different sizes")
2781

    
2782
cvEinstancebadnode :: (String, String, String)
2783
cvEinstancebadnode =
2784
  ("instance",
2785
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2786
   "Instance marked as running lives on an offline node")
2787

    
2788
cvEinstancedown :: (String, String, String)
2789
cvEinstancedown =
2790
  ("instance",
2791
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2792
   "Instance not running on its primary node")
2793

    
2794
cvEinstancefaultydisk :: (String, String, String)
2795
cvEinstancefaultydisk =
2796
  ("instance",
2797
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2798
   "Impossible to retrieve status for a disk")
2799

    
2800
cvEinstancelayout :: (String, String, String)
2801
cvEinstancelayout =
2802
  ("instance",
2803
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2804
   "Instance has multiple secondary nodes")
2805

    
2806
cvEinstancemissingcfgparameter :: (String, String, String)
2807
cvEinstancemissingcfgparameter =
2808
  ("instance",
2809
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2810
   "A configuration parameter for an instance is missing")
2811

    
2812
cvEinstancemissingdisk :: (String, String, String)
2813
cvEinstancemissingdisk =
2814
  ("instance",
2815
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2816
   "Missing volume on an instance")
2817

    
2818
cvEinstancepolicy :: (String, String, String)
2819
cvEinstancepolicy =
2820
  ("instance",
2821
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2822
   "Instance does not meet policy")
2823

    
2824
cvEinstancesplitgroups :: (String, String, String)
2825
cvEinstancesplitgroups =
2826
  ("instance",
2827
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2828
   "Instance with primary and secondary nodes in different groups")
2829

    
2830
cvEinstanceunsuitablenode :: (String, String, String)
2831
cvEinstanceunsuitablenode =
2832
  ("instance",
2833
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2834
   "Instance running on nodes that are not suitable for it")
2835

    
2836
cvEinstancewrongnode :: (String, String, String)
2837
cvEinstancewrongnode =
2838
  ("instance",
2839
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2840
   "Instance running on the wrong node")
2841

    
2842
cvEnodedrbd :: (String, String, String)
2843
cvEnodedrbd =
2844
  ("node",
2845
   Types.cVErrorCodeToRaw CvENODEDRBD,
2846
   "Error parsing the DRBD status file")
2847

    
2848
cvEnodedrbdhelper :: (String, String, String)
2849
cvEnodedrbdhelper =
2850
  ("node",
2851
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2852
   "Error caused by the DRBD helper")
2853

    
2854
cvEnodedrbdversion :: (String, String, String)
2855
cvEnodedrbdversion =
2856
  ("node",
2857
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2858
   "DRBD version mismatch within a node group")
2859

    
2860
cvEnodefilecheck :: (String, String, String)
2861
cvEnodefilecheck =
2862
  ("node",
2863
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2864
   "Error retrieving the checksum of the node files")
2865

    
2866
cvEnodefilestoragepaths :: (String, String, String)
2867
cvEnodefilestoragepaths =
2868
  ("node",
2869
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2870
   "Detected bad file storage paths")
2871

    
2872
cvEnodefilestoragepathunusable :: (String, String, String)
2873
cvEnodefilestoragepathunusable =
2874
  ("node",
2875
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2876
   "File storage path unusable")
2877

    
2878
cvEnodehooks :: (String, String, String)
2879
cvEnodehooks =
2880
  ("node",
2881
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2882
   "Communication failure in hooks execution")
2883

    
2884
cvEnodehv :: (String, String, String)
2885
cvEnodehv =
2886
  ("node",
2887
   Types.cVErrorCodeToRaw CvENODEHV,
2888
   "Hypervisor parameters verification failure")
2889

    
2890
cvEnodelvm :: (String, String, String)
2891
cvEnodelvm =
2892
  ("node",
2893
   Types.cVErrorCodeToRaw CvENODELVM,
2894
   "LVM-related node error")
2895

    
2896
cvEnoden1 :: (String, String, String)
2897
cvEnoden1 =
2898
  ("node",
2899
   Types.cVErrorCodeToRaw CvENODEN1,
2900
   "Not enough memory to accommodate instance failovers")
2901

    
2902
cvEnodenet :: (String, String, String)
2903
cvEnodenet =
2904
  ("node",
2905
   Types.cVErrorCodeToRaw CvENODENET,
2906
   "Network-related node error")
2907

    
2908
cvEnodeoobpath :: (String, String, String)
2909
cvEnodeoobpath =
2910
  ("node",
2911
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2912
   "Invalid Out Of Band path")
2913

    
2914
cvEnodeorphaninstance :: (String, String, String)
2915
cvEnodeorphaninstance =
2916
  ("node",
2917
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2918
   "Unknown intance running on a node")
2919

    
2920
cvEnodeorphanlv :: (String, String, String)
2921
cvEnodeorphanlv =
2922
  ("node",
2923
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2924
   "Unknown LVM logical volume")
2925

    
2926
cvEnodeos :: (String, String, String)
2927
cvEnodeos =
2928
  ("node",
2929
   Types.cVErrorCodeToRaw CvENODEOS,
2930
   "OS-related node error")
2931

    
2932
cvEnoderpc :: (String, String, String)
2933
cvEnoderpc =
2934
  ("node",
2935
   Types.cVErrorCodeToRaw CvENODERPC,
2936
   "Error during connection to the primary node of an instance")
2937

    
2938
cvEnodesetup :: (String, String, String)
2939
cvEnodesetup =
2940
  ("node",
2941
   Types.cVErrorCodeToRaw CvENODESETUP,
2942
   "Node setup error")
2943

    
2944
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2945
cvEnodesharedfilestoragepathunusable =
2946
  ("node",
2947
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2948
   "Shared file storage path unusable")
2949

    
2950
cvEnodessh :: (String, String, String)
2951
cvEnodessh =
2952
  ("node",
2953
   Types.cVErrorCodeToRaw CvENODESSH,
2954
   "SSH-related node error")
2955

    
2956
cvEnodetime :: (String, String, String)
2957
cvEnodetime =
2958
  ("node",
2959
   Types.cVErrorCodeToRaw CvENODETIME,
2960
   "Node returned invalid time")
2961

    
2962
cvEnodeuserscripts :: (String, String, String)
2963
cvEnodeuserscripts =
2964
  ("node",
2965
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2966
   "User scripts not present or not executable")
2967

    
2968
cvEnodeversion :: (String, String, String)
2969
cvEnodeversion =
2970
  ("node",
2971
   Types.cVErrorCodeToRaw CvENODEVERSION,
2972
   "Protocol version mismatch or Ganeti version mismatch")
2973

    
2974
cvAllEcodes :: FrozenSet (String, String, String)
2975
cvAllEcodes =
2976
  ConstantUtils.mkSet
2977
  [cvEclustercert,
2978
   cvEclustercfg,
2979
   cvEclusterdanglinginst,
2980
   cvEclusterdanglingnodes,
2981
   cvEclusterfilecheck,
2982
   cvEgroupdifferentpvsize,
2983
   cvEinstancebadnode,
2984
   cvEinstancedown,
2985
   cvEinstancefaultydisk,
2986
   cvEinstancelayout,
2987
   cvEinstancemissingcfgparameter,
2988
   cvEinstancemissingdisk,
2989
   cvEinstancepolicy,
2990
   cvEinstancesplitgroups,
2991
   cvEinstanceunsuitablenode,
2992
   cvEinstancewrongnode,
2993
   cvEnodedrbd,
2994
   cvEnodedrbdhelper,
2995
   cvEnodedrbdversion,
2996
   cvEnodefilecheck,
2997
   cvEnodefilestoragepaths,
2998
   cvEnodefilestoragepathunusable,
2999
   cvEnodehooks,
3000
   cvEnodehv,
3001
   cvEnodelvm,
3002
   cvEnoden1,
3003
   cvEnodenet,
3004
   cvEnodeoobpath,
3005
   cvEnodeorphaninstance,
3006
   cvEnodeorphanlv,
3007
   cvEnodeos,
3008
   cvEnoderpc,
3009
   cvEnodesetup,
3010
   cvEnodesharedfilestoragepathunusable,
3011
   cvEnodessh,
3012
   cvEnodetime,
3013
   cvEnodeuserscripts,
3014
   cvEnodeversion]
3015

    
3016
cvAllEcodesStrings :: FrozenSet String
3017
cvAllEcodesStrings =
3018
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
3019

    
3020
-- * Node verify constants
3021

    
3022
nvBridges :: String
3023
nvBridges = "bridges"
3024

    
3025
nvClientCert :: String
3026
nvClientCert = "client-cert"
3027

    
3028
nvDrbdhelper :: String
3029
nvDrbdhelper = "drbd-helper"
3030

    
3031
nvDrbdversion :: String
3032
nvDrbdversion = "drbd-version"
3033

    
3034
nvDrbdlist :: String
3035
nvDrbdlist = "drbd-list"
3036

    
3037
nvExclusivepvs :: String
3038
nvExclusivepvs = "exclusive-pvs"
3039

    
3040
nvFilelist :: String
3041
nvFilelist = "filelist"
3042

    
3043
nvAcceptedStoragePaths :: String
3044
nvAcceptedStoragePaths = "allowed-file-storage-paths"
3045

    
3046
nvFileStoragePath :: String
3047
nvFileStoragePath = "file-storage-path"
3048

    
3049
nvSharedFileStoragePath :: String
3050
nvSharedFileStoragePath = "shared-file-storage-path"
3051

    
3052
nvHvinfo :: String
3053
nvHvinfo = "hvinfo"
3054

    
3055
nvHvparams :: String
3056
nvHvparams = "hvparms"
3057

    
3058
nvHypervisor :: String
3059
nvHypervisor = "hypervisor"
3060

    
3061
nvInstancelist :: String
3062
nvInstancelist = "instancelist"
3063

    
3064
nvLvlist :: String
3065
nvLvlist = "lvlist"
3066

    
3067
nvMasterip :: String
3068
nvMasterip = "master-ip"
3069

    
3070
nvNodelist :: String
3071
nvNodelist = "nodelist"
3072

    
3073
nvNodenettest :: String
3074
nvNodenettest = "node-net-test"
3075

    
3076
nvNodesetup :: String
3077
nvNodesetup = "nodesetup"
3078

    
3079
nvOobPaths :: String
3080
nvOobPaths = "oob-paths"
3081

    
3082
nvOslist :: String
3083
nvOslist = "oslist"
3084

    
3085
nvPvlist :: String
3086
nvPvlist = "pvlist"
3087

    
3088
nvTime :: String
3089
nvTime = "time"
3090

    
3091
nvUserscripts :: String
3092
nvUserscripts = "user-scripts"
3093

    
3094
nvVersion :: String
3095
nvVersion = "version"
3096

    
3097
nvVglist :: String
3098
nvVglist = "vglist"
3099

    
3100
nvVmnodes :: String
3101
nvVmnodes = "vmnodes"
3102

    
3103
-- * Instance status
3104

    
3105
inststAdmindown :: String
3106
inststAdmindown = Types.instanceStatusToRaw StatusDown
3107

    
3108
inststAdminoffline :: String
3109
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3110

    
3111
inststErrordown :: String
3112
inststErrordown = Types.instanceStatusToRaw ErrorDown
3113

    
3114
inststErrorup :: String
3115
inststErrorup = Types.instanceStatusToRaw ErrorUp
3116

    
3117
inststNodedown :: String
3118
inststNodedown = Types.instanceStatusToRaw NodeDown
3119

    
3120
inststNodeoffline :: String
3121
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3122

    
3123
inststRunning :: String
3124
inststRunning = Types.instanceStatusToRaw Running
3125

    
3126
inststUserdown :: String
3127
inststUserdown = Types.instanceStatusToRaw UserDown
3128

    
3129
inststWrongnode :: String
3130
inststWrongnode = Types.instanceStatusToRaw WrongNode
3131

    
3132
inststAll :: FrozenSet String
3133
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3134

    
3135
-- * Admin states
3136

    
3137
adminstDown :: String
3138
adminstDown = Types.adminStateToRaw AdminDown
3139

    
3140
adminstOffline :: String
3141
adminstOffline = Types.adminStateToRaw AdminOffline
3142

    
3143
adminstUp :: String
3144
adminstUp = Types.adminStateToRaw AdminUp
3145

    
3146
adminstAll :: FrozenSet String
3147
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3148

    
3149
-- * Node roles
3150

    
3151
nrDrained :: String
3152
nrDrained = Types.nodeRoleToRaw NRDrained
3153

    
3154
nrMaster :: String
3155
nrMaster = Types.nodeRoleToRaw NRMaster
3156

    
3157
nrMcandidate :: String
3158
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3159

    
3160
nrOffline :: String
3161
nrOffline = Types.nodeRoleToRaw NROffline
3162

    
3163
nrRegular :: String
3164
nrRegular = Types.nodeRoleToRaw NRRegular
3165

    
3166
nrAll :: FrozenSet String
3167
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3168

    
3169
-- * SSL certificate check constants (in days)
3170

    
3171
sslCertExpirationError :: Int
3172
sslCertExpirationError = 7
3173

    
3174
sslCertExpirationWarn :: Int
3175
sslCertExpirationWarn = 30
3176

    
3177
-- * Allocator framework constants
3178

    
3179
iallocatorVersion :: Int
3180
iallocatorVersion = 2
3181

    
3182
iallocatorDirIn :: String
3183
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3184

    
3185
iallocatorDirOut :: String
3186
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3187

    
3188
validIallocatorDirections :: FrozenSet String
3189
validIallocatorDirections =
3190
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3191

    
3192
iallocatorModeAlloc :: String
3193
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3194

    
3195
iallocatorModeChgGroup :: String
3196
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3197

    
3198
iallocatorModeMultiAlloc :: String
3199
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3200

    
3201
iallocatorModeNodeEvac :: String
3202
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3203

    
3204
iallocatorModeReloc :: String
3205
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3206

    
3207
validIallocatorModes :: FrozenSet String
3208
validIallocatorModes =
3209
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3210

    
3211
iallocatorSearchPath :: [String]
3212
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3213

    
3214
defaultIallocatorShortcut :: String
3215
defaultIallocatorShortcut = "."
3216

    
3217
-- * Opportunistic allocator usage
3218

    
3219
-- | Time delay in seconds between repeated opportunistic instance creations.
3220
-- Rather than failing with an informative error message if the opportunistic
3221
-- creation cannot grab enough nodes, for some uses it is better to retry the
3222
-- creation with an interval between attempts. This is a reasonable default.
3223
defaultOpportunisticRetryInterval :: Int
3224
defaultOpportunisticRetryInterval = 30
3225

    
3226
-- * Node evacuation
3227

    
3228
nodeEvacPri :: String
3229
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3230

    
3231
nodeEvacSec :: String
3232
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3233

    
3234
nodeEvacAll :: String
3235
nodeEvacAll = Types.evacModeToRaw ChangeAll
3236

    
3237
nodeEvacModes :: FrozenSet String
3238
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3239

    
3240
-- * Job queue
3241

    
3242
jobQueueVersion :: Int
3243
jobQueueVersion = 1
3244

    
3245
jobQueueSizeHardLimit :: Int
3246
jobQueueSizeHardLimit = 5000
3247

    
3248
jobQueueFilesPerms :: Int
3249
jobQueueFilesPerms = 0o640
3250

    
3251
-- * Unchanged job return
3252

    
3253
jobNotchanged :: String
3254
jobNotchanged = "nochange"
3255

    
3256
-- * Job status
3257

    
3258
jobStatusQueued :: String
3259
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3260

    
3261
jobStatusWaiting :: String
3262
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3263

    
3264
jobStatusCanceling :: String
3265
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3266

    
3267
jobStatusRunning :: String
3268
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3269

    
3270
jobStatusCanceled :: String
3271
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3272

    
3273
jobStatusSuccess :: String
3274
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3275

    
3276
jobStatusError :: String
3277
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3278

    
3279
jobsPending :: FrozenSet String
3280
jobsPending =
3281
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3282

    
3283
jobsFinalized :: FrozenSet String
3284
jobsFinalized =
3285
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3286

    
3287
jobStatusAll :: FrozenSet String
3288
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3289

    
3290
-- * OpCode status
3291

    
3292
-- ** Not yet finalized opcodes
3293

    
3294
opStatusCanceling :: String
3295
opStatusCanceling = "canceling"
3296

    
3297
opStatusQueued :: String
3298
opStatusQueued = "queued"
3299

    
3300
opStatusRunning :: String
3301
opStatusRunning = "running"
3302

    
3303
opStatusWaiting :: String
3304
opStatusWaiting = "waiting"
3305

    
3306
-- ** Finalized opcodes
3307

    
3308
opStatusCanceled :: String
3309
opStatusCanceled = "canceled"
3310

    
3311
opStatusError :: String
3312
opStatusError = "error"
3313

    
3314
opStatusSuccess :: String
3315
opStatusSuccess = "success"
3316

    
3317
opsFinalized :: FrozenSet String
3318
opsFinalized =
3319
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3320

    
3321
-- * OpCode priority
3322

    
3323
opPrioLowest :: Int
3324
opPrioLowest = 19
3325

    
3326
opPrioHighest :: Int
3327
opPrioHighest = -20
3328

    
3329
opPrioLow :: Int
3330
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3331

    
3332
opPrioNormal :: Int
3333
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3334

    
3335
opPrioHigh :: Int
3336
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3337

    
3338
opPrioSubmitValid :: FrozenSet Int
3339
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3340

    
3341
opPrioDefault :: Int
3342
opPrioDefault = opPrioNormal
3343

    
3344
-- * Lock recalculate mode
3345

    
3346
locksAppend :: String
3347
locksAppend = "append"
3348

    
3349
locksReplace :: String
3350
locksReplace = "replace"
3351

    
3352
-- * Lock timeout
3353
--
3354
-- The lock timeout (sum) before we transition into blocking acquire
3355
-- (this can still be reset by priority change).  Computed as max time
3356
-- (10 hours) before we should actually go into blocking acquire,
3357
-- given that we start from the default priority level.
3358

    
3359
lockAttemptsMaxwait :: Double
3360
lockAttemptsMaxwait = 15.0
3361

    
3362
lockAttemptsMinwait :: Double
3363
lockAttemptsMinwait = 1.0
3364

    
3365
lockAttemptsTimeout :: Int
3366
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3367

    
3368
-- * Execution log types
3369

    
3370
elogMessage :: String
3371
elogMessage = Types.eLogTypeToRaw ELogMessage
3372

    
3373
elogRemoteImport :: String
3374
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3375

    
3376
elogJqueueTest :: String
3377
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3378

    
3379
-- * /etc/hosts modification
3380

    
3381
etcHostsAdd :: String
3382
etcHostsAdd = "add"
3383

    
3384
etcHostsRemove :: String
3385
etcHostsRemove = "remove"
3386

    
3387
-- * Job queue test
3388

    
3389
jqtMsgprefix :: String
3390
jqtMsgprefix = "TESTMSG="
3391

    
3392
jqtExec :: String
3393
jqtExec = "exec"
3394

    
3395
jqtExpandnames :: String
3396
jqtExpandnames = "expandnames"
3397

    
3398
jqtLogmsg :: String
3399
jqtLogmsg = "logmsg"
3400

    
3401
jqtStartmsg :: String
3402
jqtStartmsg = "startmsg"
3403

    
3404
jqtAll :: FrozenSet String
3405
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3406

    
3407
-- * Query resources
3408

    
3409
qrCluster :: String
3410
qrCluster = "cluster"
3411

    
3412
qrExport :: String
3413
qrExport = "export"
3414

    
3415
qrExtstorage :: String
3416
qrExtstorage = "extstorage"
3417

    
3418
qrGroup :: String
3419
qrGroup = "group"
3420

    
3421
qrInstance :: String
3422
qrInstance = "instance"
3423

    
3424
qrJob :: String
3425
qrJob = "job"
3426

    
3427
qrLock :: String
3428
qrLock = "lock"
3429

    
3430
qrNetwork :: String
3431
qrNetwork = "network"
3432

    
3433
qrNode :: String
3434
qrNode = "node"
3435

    
3436
qrOs :: String
3437
qrOs = "os"
3438

    
3439
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3440
qrViaOp :: FrozenSet String
3441
qrViaOp =
3442
  ConstantUtils.mkSet [qrCluster,
3443
                       qrOs,
3444
                       qrExtstorage]
3445

    
3446
-- | List of resources which can be queried using Local UniX Interface
3447
qrViaLuxi :: FrozenSet String
3448
qrViaLuxi = ConstantUtils.mkSet [qrGroup,
3449
                                 qrExport,
3450
                                 qrInstance,
3451
                                 qrJob,
3452
                                 qrLock,
3453
                                 qrNetwork,
3454
                                 qrNode]
3455

    
3456
-- | List of resources which can be queried using RAPI
3457
qrViaRapi :: FrozenSet String
3458
qrViaRapi = qrViaLuxi
3459

    
3460
-- | List of resources which can be queried via RAPI including PUT requests
3461
qrViaRapiPut :: FrozenSet String
3462
qrViaRapiPut = ConstantUtils.mkSet [qrLock, qrJob]
3463

    
3464
-- * Query field types
3465

    
3466
qftBool :: String
3467
qftBool = "bool"
3468

    
3469
qftNumber :: String
3470
qftNumber = "number"
3471

    
3472
qftOther :: String
3473
qftOther = "other"
3474

    
3475
qftText :: String
3476
qftText = "text"
3477

    
3478
qftTimestamp :: String
3479
qftTimestamp = "timestamp"
3480

    
3481
qftUnit :: String
3482
qftUnit = "unit"
3483

    
3484
qftUnknown :: String
3485
qftUnknown = "unknown"
3486

    
3487
qftAll :: FrozenSet String
3488
qftAll =
3489
  ConstantUtils.mkSet [qftBool,
3490
                       qftNumber,
3491
                       qftOther,
3492
                       qftText,
3493
                       qftTimestamp,
3494
                       qftUnit,
3495
                       qftUnknown]
3496

    
3497
-- * Query result field status
3498
--
3499
-- Don't change or reuse values as they're used by clients.
3500
--
3501
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3502

    
3503
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3504
rsNodata :: Int
3505
rsNodata = 2
3506

    
3507
rsNormal :: Int
3508
rsNormal = 0
3509

    
3510
-- | Resource marked offline
3511
rsOffline :: Int
3512
rsOffline = 4
3513

    
3514
-- | Value unavailable/unsupported for item; if this field is
3515
-- supported but we cannot get the data for the moment, 'rsNodata' or
3516
-- 'rsOffline' should be used
3517
rsUnavail :: Int
3518
rsUnavail = 3
3519

    
3520
rsUnknown :: Int
3521
rsUnknown = 1
3522

    
3523
rsAll :: FrozenSet Int
3524
rsAll =
3525
  ConstantUtils.mkSet [rsNodata,
3526
                       rsNormal,
3527
                       rsOffline,
3528
                       rsUnavail,
3529
                       rsUnknown]
3530

    
3531
-- | Special field cases and their verbose/terse formatting
3532
rssDescription :: Map Int (String, String)
3533
rssDescription =
3534
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3535
                (rsNodata, ("(nodata)", "?")),
3536
                (rsOffline, ("(offline)", "*")),
3537
                (rsUnavail, ("(unavail)", "-"))]
3538

    
3539
-- * Max dynamic devices
3540

    
3541
maxDisks :: Int
3542
maxDisks = Types.maxDisks
3543

    
3544
maxNics :: Int
3545
maxNics = Types.maxNics
3546

    
3547
-- | SSCONF file prefix
3548
ssconfFileprefix :: String
3549
ssconfFileprefix = "ssconf_"
3550

    
3551
-- * SSCONF keys
3552

    
3553
ssClusterName :: String
3554
ssClusterName = "cluster_name"
3555

    
3556
ssClusterTags :: String
3557
ssClusterTags = "cluster_tags"
3558

    
3559
ssFileStorageDir :: String
3560
ssFileStorageDir = "file_storage_dir"
3561

    
3562
ssSharedFileStorageDir :: String
3563
ssSharedFileStorageDir = "shared_file_storage_dir"
3564

    
3565
ssGlusterStorageDir :: String
3566
ssGlusterStorageDir = "gluster_storage_dir"
3567

    
3568
ssMasterCandidates :: String
3569
ssMasterCandidates = "master_candidates"
3570

    
3571
ssMasterCandidatesIps :: String
3572
ssMasterCandidatesIps = "master_candidates_ips"
3573

    
3574
ssMasterCandidatesCerts :: String
3575
ssMasterCandidatesCerts = "master_candidates_certs"
3576

    
3577
ssMasterIp :: String
3578
ssMasterIp = "master_ip"
3579

    
3580
ssMasterNetdev :: String
3581
ssMasterNetdev = "master_netdev"
3582

    
3583
ssMasterNetmask :: String
3584
ssMasterNetmask = "master_netmask"
3585

    
3586
ssMasterNode :: String
3587
ssMasterNode = "master_node"
3588

    
3589
ssNodeList :: String
3590
ssNodeList = "node_list"
3591

    
3592
ssNodePrimaryIps :: String
3593
ssNodePrimaryIps = "node_primary_ips"
3594

    
3595
ssNodeSecondaryIps :: String
3596
ssNodeSecondaryIps = "node_secondary_ips"
3597

    
3598
ssOfflineNodes :: String
3599
ssOfflineNodes = "offline_nodes"
3600

    
3601
ssOnlineNodes :: String
3602
ssOnlineNodes = "online_nodes"
3603

    
3604
ssPrimaryIpFamily :: String
3605
ssPrimaryIpFamily = "primary_ip_family"
3606

    
3607
ssInstanceList :: String
3608
ssInstanceList = "instance_list"
3609

    
3610
ssReleaseVersion :: String
3611
ssReleaseVersion = "release_version"
3612

    
3613
ssHypervisorList :: String
3614
ssHypervisorList = "hypervisor_list"
3615

    
3616
ssMaintainNodeHealth :: String
3617
ssMaintainNodeHealth = "maintain_node_health"
3618

    
3619
ssUidPool :: String
3620
ssUidPool = "uid_pool"
3621

    
3622
ssNodegroups :: String
3623
ssNodegroups = "nodegroups"
3624

    
3625
ssNetworks :: String
3626
ssNetworks = "networks"
3627

    
3628
-- | This is not a complete SSCONF key, but the prefix for the
3629
-- hypervisor keys
3630
ssHvparamsPref :: String
3631
ssHvparamsPref = "hvparams_"
3632

    
3633
-- * Hvparams keys
3634

    
3635
ssHvparamsXenChroot :: String
3636
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3637

    
3638
ssHvparamsXenFake :: String
3639
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3640

    
3641
ssHvparamsXenHvm :: String
3642
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3643

    
3644
ssHvparamsXenKvm :: String
3645
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3646

    
3647
ssHvparamsXenLxc :: String
3648
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3649

    
3650
ssHvparamsXenPvm :: String
3651
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3652

    
3653
validSsHvparamsKeys :: FrozenSet String
3654
validSsHvparamsKeys =
3655
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3656
                       ssHvparamsXenLxc,
3657
                       ssHvparamsXenFake,
3658
                       ssHvparamsXenHvm,
3659
                       ssHvparamsXenKvm,
3660
                       ssHvparamsXenPvm]
3661

    
3662
ssFilePerms :: Int
3663
ssFilePerms = 0o444
3664

    
3665
-- | Cluster wide default parameters
3666
defaultEnabledHypervisor :: String
3667
defaultEnabledHypervisor = htXenPvm
3668

    
3669
hvcDefaults :: Map Hypervisor (Map String PyValueEx)
3670
hvcDefaults =
3671
  Map.fromList
3672
  [ (XenPvm, Map.fromList
3673
             [ (hvUseBootloader,  PyValueEx False)
3674
             , (hvBootloaderPath, PyValueEx xenBootloader)
3675
             , (hvBootloaderArgs, PyValueEx "")
3676
             , (hvKernelPath,     PyValueEx xenKernel)
3677
             , (hvInitrdPath,     PyValueEx "")
3678
             , (hvRootPath,       PyValueEx "/dev/xvda1")
3679
             , (hvKernelArgs,     PyValueEx "ro")
3680
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3681
             , (hvMigrationMode,  PyValueEx htMigrationLive)
3682
             , (hvBlockdevPrefix, PyValueEx "sd")
3683
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3684
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3685
             , (hvCpuCap,         PyValueEx (0 :: Int))
3686
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3687
             , (hvVifScript,      PyValueEx "")
3688
             , (hvXenCmd,         PyValueEx xenCmdXm)
3689
             , (hvXenCpuid,       PyValueEx "")
3690
             , (hvSoundhw,        PyValueEx "")
3691
             ])
3692
  , (XenHvm, Map.fromList
3693
             [ (hvBootOrder,      PyValueEx "cd")
3694
             , (hvCdromImagePath, PyValueEx "")
3695
             , (hvNicType,        PyValueEx htNicRtl8139)
3696
             , (hvDiskType,       PyValueEx htDiskParavirtual)
3697
             , (hvVncBindAddress, PyValueEx ip4AddressAny)
3698
             , (hvAcpi,           PyValueEx True)
3699
             , (hvPae,            PyValueEx True)
3700
             , (hvKernelPath,     PyValueEx "/usr/lib/xen/boot/hvmloader")
3701
             , (hvDeviceModel,    PyValueEx "/usr/lib/xen/bin/qemu-dm")
3702
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3703
             , (hvMigrationMode,  PyValueEx htMigrationNonlive)
3704
             , (hvUseLocaltime,   PyValueEx False)
3705
             , (hvBlockdevPrefix, PyValueEx "hd")
3706
             , (hvPassthrough,    PyValueEx "")
3707
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3708
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3709
             , (hvCpuCap,         PyValueEx (0 :: Int))
3710
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3711
             , (hvVifType,        PyValueEx htHvmVifIoemu)
3712
             , (hvVifScript,      PyValueEx "")
3713
             , (hvViridian,       PyValueEx False)
3714
             , (hvXenCmd,         PyValueEx xenCmdXm)
3715
             , (hvXenCpuid,       PyValueEx "")
3716
             , (hvSoundhw,        PyValueEx "")
3717
             ])
3718
  , (Kvm, Map.fromList
3719
          [ (hvKvmPath,                         PyValueEx kvmPath)
3720
          , (hvKernelPath,                      PyValueEx kvmKernel)
3721
          , (hvInitrdPath,                      PyValueEx "")
3722
          , (hvKernelArgs,                      PyValueEx "ro")
3723
          , (hvRootPath,                        PyValueEx "/dev/vda1")
3724
          , (hvAcpi,                            PyValueEx True)
3725
          , (hvSerialConsole,                   PyValueEx True)
3726
          , (hvSerialSpeed,                     PyValueEx (38400 :: Int))
3727
          , (hvVncBindAddress,                  PyValueEx "")
3728
          , (hvVncTls,                          PyValueEx False)
3729
          , (hvVncX509,                         PyValueEx "")
3730
          , (hvVncX509Verify,                   PyValueEx False)
3731
          , (hvVncPasswordFile,                 PyValueEx "")
3732
          , (hvKvmSpiceBind,                    PyValueEx "")
3733
          , (hvKvmSpiceIpVersion,           PyValueEx ifaceNoIpVersionSpecified)
3734
          , (hvKvmSpicePasswordFile,            PyValueEx "")
3735
          , (hvKvmSpiceLosslessImgCompr,        PyValueEx "")
3736
          , (hvKvmSpiceJpegImgCompr,            PyValueEx "")
3737
          , (hvKvmSpiceZlibGlzImgCompr,         PyValueEx "")
3738
          , (hvKvmSpiceStreamingVideoDetection, PyValueEx "")
3739
          , (hvKvmSpiceAudioCompr,              PyValueEx True)
3740
          , (hvKvmSpiceUseTls,                  PyValueEx False)
3741
          , (hvKvmSpiceTlsCiphers,              PyValueEx opensslCiphers)
3742
          , (hvKvmSpiceUseVdagent,              PyValueEx True)
3743
          , (hvKvmFloppyImagePath,              PyValueEx "")
3744
          , (hvCdromImagePath,                  PyValueEx "")
3745
          , (hvKvmCdrom2ImagePath,              PyValueEx "")
3746
          , (hvBootOrder,                       PyValueEx htBoDisk)
3747
          , (hvNicType,                         PyValueEx htNicParavirtual)
3748
          , (hvDiskType,                        PyValueEx htDiskParavirtual)
3749
          , (hvKvmCdromDiskType,                PyValueEx "")
3750
          , (hvUsbMouse,                        PyValueEx "")
3751
          , (hvKeymap,                          PyValueEx "")
3752
          , (hvMigrationPort,                   PyValueEx (8102 :: Int))
3753
          , (hvMigrationBandwidth,              PyValueEx (32 :: Int))
3754
          , (hvMigrationDowntime,               PyValueEx (30 :: Int))
3755
          , (hvMigrationMode,                   PyValueEx htMigrationLive)
3756
          , (hvUseLocaltime,                    PyValueEx False)
3757
          , (hvDiskCache,                       PyValueEx htCacheDefault)
3758
          , (hvSecurityModel,                   PyValueEx htSmNone)
3759
          , (hvSecurityDomain,                  PyValueEx "")
3760
          , (hvKvmFlag,                         PyValueEx "")
3761
          , (hvVhostNet,                        PyValueEx False)
3762
          , (hvKvmUseChroot,                    PyValueEx False)
3763
          , (hvKvmUserShutdown,                 PyValueEx False)
3764
          , (hvMemPath,                         PyValueEx "")
3765
          , (hvRebootBehavior,                  PyValueEx instanceRebootAllowed)
3766
          , (hvCpuMask,                         PyValueEx cpuPinningAll)
3767
          , (hvCpuType,                         PyValueEx "")
3768
          , (hvCpuCores,                        PyValueEx (0 :: Int))
3769
          , (hvCpuThreads,                      PyValueEx (0 :: Int))
3770
          , (hvCpuSockets,                      PyValueEx (0 :: Int))
3771
          , (hvSoundhw,                         PyValueEx "")
3772
          , (hvUsbDevices,                      PyValueEx "")
3773
          , (hvVga,                             PyValueEx "")
3774
          , (hvKvmExtra,                        PyValueEx "")
3775
          , (hvKvmMachineVersion,               PyValueEx "")
3776
          , (hvVnetHdr,                         PyValueEx True)])
3777
  , (Fake, Map.fromList [(hvMigrationMode, PyValueEx htMigrationLive)])
3778
  , (Chroot, Map.fromList [(hvInitScript, PyValueEx "/ganeti-chroot")])
3779
  , (Lxc, Map.fromList [(hvCpuMask, PyValueEx "")])
3780
  ]
3781

    
3782
hvcGlobals :: FrozenSet String
3783
hvcGlobals =
3784
  ConstantUtils.mkSet [hvMigrationBandwidth,
3785
                       hvMigrationMode,
3786
                       hvMigrationPort,
3787
                       hvXenCmd]
3788

    
3789
becDefaults :: Map String PyValueEx
3790
becDefaults =
3791
  Map.fromList
3792
  [ (beMinmem, PyValueEx (128 :: Int))
3793
  , (beMaxmem, PyValueEx (128 :: Int))
3794
  , (beVcpus, PyValueEx (1 :: Int))
3795
  , (beAutoBalance, PyValueEx True)
3796
  , (beAlwaysFailover, PyValueEx False)
3797
  , (beSpindleUse, PyValueEx (1 :: Int))
3798
  ]
3799

    
3800
ndcDefaults :: Map String PyValueEx
3801
ndcDefaults =
3802
  Map.fromList
3803
  [ (ndOobProgram,       PyValueEx "")
3804
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3805
  , (ndExclusiveStorage, PyValueEx False)
3806
  , (ndOvs,              PyValueEx False)
3807
  , (ndOvsName,          PyValueEx defaultOvs)
3808
  , (ndOvsLink,          PyValueEx "")
3809
  , (ndSshPort,          PyValueEx (22 :: Int))
3810
  ]
3811

    
3812
ndcGlobals :: FrozenSet String
3813
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3814

    
3815
-- | Default delay target measured in sectors
3816
defaultDelayTarget :: Int
3817
defaultDelayTarget = 1
3818

    
3819
defaultDiskCustom :: String
3820
defaultDiskCustom = ""
3821

    
3822
defaultDiskResync :: Bool
3823
defaultDiskResync = False
3824

    
3825
-- | Default fill target measured in sectors
3826
defaultFillTarget :: Int
3827
defaultFillTarget = 0
3828

    
3829
-- | Default mininum rate measured in KiB/s
3830
defaultMinRate :: Int
3831
defaultMinRate = 4 * 1024
3832

    
3833
defaultNetCustom :: String
3834
defaultNetCustom = ""
3835

    
3836
-- | Default plan ahead measured in sectors
3837
--
3838
-- The default values for the DRBD dynamic resync speed algorithm are
3839
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3840
-- (that we don't need to set to 0, because we have a separate option
3841
-- to enable it) and for c-max-rate, that we cap to the default value
3842
-- for the static resync rate.
3843
defaultPlanAhead :: Int
3844
defaultPlanAhead = 20
3845

    
3846
defaultRbdPool :: String
3847
defaultRbdPool = "rbd"
3848

    
3849
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3850
diskLdDefaults =
3851
  Map.fromList
3852
  [ (DTBlock, Map.empty)
3853
  , (DTDrbd8, Map.fromList
3854
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3855
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3856
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3857
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3858
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3859
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3860
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3861
              , (ldpMinRate,       PyValueEx defaultMinRate)
3862
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3863
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3864
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3865
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3866
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3867
              ])
3868
  , (DTExt, Map.empty)
3869
  , (DTFile, Map.empty)
3870
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3871
  , (DTRbd, Map.fromList
3872
            [ (ldpPool, PyValueEx defaultRbdPool)
3873
            , (ldpAccess, PyValueEx diskKernelspace)
3874
            ])
3875
  , (DTSharedFile, Map.empty)
3876
  , (DTGluster, Map.fromList
3877
                [ (rbdAccess, PyValueEx diskKernelspace)
3878
                , (glusterHost, PyValueEx glusterHostDefault)
3879
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3880
                , (glusterPort, PyValueEx glusterPortDefault)
3881
                ])
3882
  ]
3883

    
3884
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3885
diskDtDefaults =
3886
  Map.fromList
3887
  [ (DTBlock,      Map.empty)
3888
  , (DTDiskless,   Map.empty)
3889
  , (DTDrbd8,      Map.fromList
3890
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3891
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3892
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3893
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3894
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3895
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3896
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3897
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3898
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3899
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3900
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3901
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3902
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3903
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3904
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3905
                   ])
3906
  , (DTExt,        Map.empty)
3907
  , (DTFile,       Map.empty)
3908
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3909
  , (DTRbd,        Map.fromList
3910
                   [ (rbdPool, PyValueEx defaultRbdPool)
3911
                   , (rbdAccess, PyValueEx diskKernelspace)
3912
                   ])
3913
  , (DTSharedFile, Map.empty)
3914
  , (DTGluster, Map.fromList
3915
                [ (rbdAccess, PyValueEx diskKernelspace)
3916
                , (glusterHost, PyValueEx glusterHostDefault)
3917
                , (glusterVolume, PyValueEx glusterVolumeDefault)
3918
                , (glusterPort, PyValueEx glusterPortDefault)
3919
                ])
3920
  ]
3921

    
3922
niccDefaults :: Map String PyValueEx
3923
niccDefaults =
3924
  Map.fromList
3925
  [ (nicMode, PyValueEx nicModeBridged)
3926
  , (nicLink, PyValueEx defaultBridge)
3927
  , (nicVlan, PyValueEx "")
3928
  ]
3929

    
3930
-- | All of the following values are quite arbitrary - there are no
3931
-- "good" defaults, these must be customised per-site
3932
ispecsMinmaxDefaults :: Map String (Map String Int)
3933
ispecsMinmaxDefaults =
3934
  Map.fromList
3935
  [(ispecsMin,
3936
    Map.fromList
3937
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3938
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3939
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3940
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3941
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3942
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3943
   (ispecsMax,
3944
    Map.fromList
3945
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3946
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3947
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3948
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3949
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3950
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3951

    
3952
ipolicyDefaults :: Map String PyValueEx
3953
ipolicyDefaults =
3954
  Map.fromList
3955
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3956
  , (ispecsStd,           PyValueEx (Map.fromList
3957
                                     [ (ispecMemSize,    128)
3958
                                     , (ispecCpuCount,   1)
3959
                                     , (ispecDiskCount,  1)
3960
                                     , (ispecDiskSize,   1024)
3961
                                     , (ispecNicCount,   1)
3962
                                     , (ispecSpindleUse, 1)
3963
                                     ] :: Map String Int))
3964
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3965
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3966
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3967
  ]
3968

    
3969
masterPoolSizeDefault :: Int
3970
masterPoolSizeDefault = 10
3971

    
3972
-- * Exclusive storage
3973

    
3974
-- | Error margin used to compare physical disks
3975
partMargin :: Double
3976
partMargin = 0.01
3977

    
3978
-- | Space reserved when creating instance disks
3979
partReserved :: Double
3980
partReserved = 0.02
3981

    
3982
-- * Luxid job scheduling
3983

    
3984
-- | Time intervall in seconds for polling updates on the job queue. This
3985
-- intervall is only relevant if the number of running jobs reaches the maximal
3986
-- allowed number, as otherwise new jobs will be started immediately anyway.
3987
-- Also, as jobs are watched via inotify, scheduling usually works independent
3988
-- of polling. Therefore we chose a sufficiently large interval, in the order of
3989
-- 5 minutes. As with the interval for reloading the configuration, we chose a
3990
-- prime number to avoid accidental 'same wakeup' with other processes.
3991
luxidJobqueuePollInterval :: Int
3992
luxidJobqueuePollInterval = 307
3993

    
3994
-- | The default value for the maximal number of jobs to be running at the same
3995
-- time. Once the maximal number is reached, new jobs will just be queued and
3996
-- only started, once some of the other jobs have finished.
3997
luxidMaximalRunningJobsDefault :: Int
3998
luxidMaximalRunningJobsDefault = 20
3999

    
4000
-- * Confd
4001

    
4002
confdProtocolVersion :: Int
4003
confdProtocolVersion = ConstantUtils.confdProtocolVersion
4004

    
4005
-- Confd request type
4006

    
4007
confdReqPing :: Int
4008
confdReqPing = Types.confdRequestTypeToRaw ReqPing
4009

    
4010
confdReqNodeRoleByname :: Int
4011
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
4012

    
4013
confdReqNodePipByInstanceIp :: Int
4014
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
4015

    
4016
confdReqClusterMaster :: Int
4017
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
4018

    
4019
confdReqNodePipList :: Int
4020
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
4021

    
4022
confdReqMcPipList :: Int
4023
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
4024

    
4025
confdReqInstancesIpsList :: Int
4026
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
4027

    
4028
confdReqNodeDrbd :: Int
4029
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
4030

    
4031
confdReqNodeInstances :: Int
4032
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
4033

    
4034
confdReqs :: FrozenSet Int
4035
confdReqs =
4036
  ConstantUtils.mkSet .
4037
  map Types.confdRequestTypeToRaw $
4038
  [minBound..] \\ [ReqNodeInstances]
4039

    
4040
-- * Confd request type
4041

    
4042
confdReqfieldName :: Int
4043
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
4044

    
4045
confdReqfieldIp :: Int
4046
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
4047

    
4048
confdReqfieldMnodePip :: Int
4049
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
4050

    
4051
-- * Confd repl status
4052

    
4053
confdReplStatusOk :: Int
4054
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
4055

    
4056
confdReplStatusError :: Int
4057
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
4058

    
4059
confdReplStatusNotimplemented :: Int
4060
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
4061

    
4062
confdReplStatuses :: FrozenSet Int
4063
confdReplStatuses =
4064
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
4065

    
4066
-- * Confd node role
4067

    
4068
confdNodeRoleMaster :: Int
4069
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
4070

    
4071
confdNodeRoleCandidate :: Int
4072
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
4073

    
4074
confdNodeRoleOffline :: Int
4075
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
4076

    
4077
confdNodeRoleDrained :: Int
4078
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
4079

    
4080
confdNodeRoleRegular :: Int
4081
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
4082

    
4083
-- * A few common errors for confd
4084

    
4085
confdErrorUnknownEntry :: Int
4086
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
4087

    
4088
confdErrorInternal :: Int
4089
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
4090

    
4091
confdErrorArgument :: Int
4092
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
4093

    
4094
-- * Confd request query fields
4095

    
4096
confdReqqLink :: String
4097
confdReqqLink = ConstantUtils.confdReqqLink
4098

    
4099
confdReqqIp :: String
4100
confdReqqIp = ConstantUtils.confdReqqIp
4101

    
4102
confdReqqIplist :: String
4103
confdReqqIplist = ConstantUtils.confdReqqIplist
4104

    
4105
confdReqqFields :: String
4106
confdReqqFields = ConstantUtils.confdReqqFields
4107

    
4108
-- | Each request is "salted" by the current timestamp.
4109
--
4110
-- This constant decides how many seconds of skew to accept.
4111
--
4112
-- TODO: make this a default and allow the value to be more
4113
-- configurable
4114
confdMaxClockSkew :: Int
4115
confdMaxClockSkew = 2 * nodeMaxClockSkew
4116

    
4117
-- | When we haven't reloaded the config for more than this amount of
4118
-- seconds, we force a test to see if inotify is betraying us. Using a
4119
-- prime number to ensure we get less chance of 'same wakeup' with
4120
-- other processes.
4121
confdConfigReloadTimeout :: Int
4122
confdConfigReloadTimeout = 17
4123

    
4124
-- | If we receive more than one update in this amount of
4125
-- microseconds, we move to polling every RATELIMIT seconds, rather
4126
-- than relying on inotify, to be able to serve more requests.
4127
confdConfigReloadRatelimit :: Int
4128
confdConfigReloadRatelimit = 250000
4129

    
4130
-- | Magic number prepended to all confd queries.
4131
--
4132
-- This allows us to distinguish different types of confd protocols
4133
-- and handle them. For example by changing this we can move the whole
4134
-- payload to be compressed, or move away from json.
4135
confdMagicFourcc :: String
4136
confdMagicFourcc = "plj0"
4137

    
4138
-- | By default a confd request is sent to the minimum between this
4139
-- number and all MCs. 6 was chosen because even in the case of a
4140
-- disastrous 50% response rate, we should have enough answers to be
4141
-- able to compare more than one.
4142
confdDefaultReqCoverage :: Int
4143
confdDefaultReqCoverage = 6
4144

    
4145
-- | Timeout in seconds to expire pending query request in the confd
4146
-- client library. We don't actually expect any answer more than 10
4147
-- seconds after we sent a request.
4148
confdClientExpireTimeout :: Int
4149
confdClientExpireTimeout = 10
4150

    
4151
-- | Maximum UDP datagram size.
4152
--
4153
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4154
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4155
--   (assuming we can't use jumbo frames)
4156
-- We just set this to 60K, which should be enough
4157
maxUdpDataSize :: Int
4158
maxUdpDataSize = 61440
4159

    
4160
-- * User-id pool minimum/maximum acceptable user-ids
4161

    
4162
uidpoolUidMin :: Int
4163
uidpoolUidMin = 0
4164

    
4165
-- | Assuming 32 bit user-ids
4166
uidpoolUidMax :: Integer
4167
uidpoolUidMax = 2 ^ 32 - 1
4168

    
4169
-- | Name or path of the pgrep command
4170
pgrep :: String
4171
pgrep = "pgrep"
4172

    
4173
-- | Name of the node group that gets created at cluster init or
4174
-- upgrade
4175
initialNodeGroupName :: String
4176
initialNodeGroupName = "default"
4177

    
4178
-- * Possible values for NodeGroup.alloc_policy
4179

    
4180
allocPolicyLastResort :: String
4181
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4182

    
4183
allocPolicyPreferred :: String
4184
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4185

    
4186
allocPolicyUnallocable :: String
4187
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4188

    
4189
validAllocPolicies :: [String]
4190
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4191

    
4192
-- | Temporary external/shared storage parameters
4193
blockdevDriverManual :: String
4194
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4195

    
4196
-- | 'qemu-img' path, required for 'ovfconverter'
4197
qemuimgPath :: String
4198
qemuimgPath = AutoConf.qemuimgPath
4199

    
4200
-- | The hail iallocator
4201
iallocHail :: String
4202
iallocHail = "hail"
4203

    
4204
-- * Fake opcodes for functions that have hooks attached to them via
4205
-- backend.RunLocalHooks
4206

    
4207
fakeOpMasterTurndown :: String
4208
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4209

    
4210
fakeOpMasterTurnup :: String
4211
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4212

    
4213

    
4214
-- * Crypto Types
4215
-- Types of cryptographic tokens used in node communication
4216

    
4217
cryptoTypeSslDigest :: String
4218
cryptoTypeSslDigest = "ssl"
4219

    
4220
cryptoTypeSsh :: String
4221
cryptoTypeSsh = "ssh"
4222

    
4223
-- So far only ssl keys are used in the context of this constant
4224
cryptoTypes :: FrozenSet String
4225
cryptoTypes = ConstantUtils.mkSet [cryptoTypeSslDigest]
4226

    
4227
-- * Crypto Actions
4228
-- Actions that can be performed on crypto tokens
4229

    
4230
cryptoActionGet :: String
4231
cryptoActionGet = "get"
4232

    
4233
-- This is 'create and get'
4234
cryptoActionCreate :: String
4235
cryptoActionCreate = "create"
4236

    
4237
cryptoActions :: FrozenSet String
4238
cryptoActions = ConstantUtils.mkSet [cryptoActionGet, cryptoActionCreate]
4239

    
4240
-- * Options for CryptoActions
4241

    
4242
-- Filename of the certificate
4243
cryptoOptionCertFile :: String
4244
cryptoOptionCertFile = "cert_file"
4245

    
4246
-- Serial number of the certificate
4247
cryptoOptionSerialNo :: String
4248
cryptoOptionSerialNo = "serial_no"
4249

    
4250
-- * SSH key types
4251

    
4252
sshkDsa :: String
4253
sshkDsa = "dsa"
4254

    
4255
sshkRsa :: String
4256
sshkRsa = "rsa"
4257

    
4258
sshkAll :: FrozenSet String
4259
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4260

    
4261
-- * SSH authorized key types
4262

    
4263
sshakDss :: String
4264
sshakDss = "ssh-dss"
4265

    
4266
sshakRsa :: String
4267
sshakRsa = "ssh-rsa"
4268

    
4269
sshakAll :: FrozenSet String
4270
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4271

    
4272
-- * SSH setup
4273

    
4274
sshsClusterName :: String
4275
sshsClusterName = "cluster_name"
4276

    
4277
sshsSshHostKey :: String
4278
sshsSshHostKey = "ssh_host_key"
4279

    
4280
sshsSshRootKey :: String
4281
sshsSshRootKey = "ssh_root_key"
4282

    
4283
sshsNodeDaemonCertificate :: String
4284
sshsNodeDaemonCertificate = "node_daemon_certificate"
4285

    
4286
-- * Key files for SSH daemon
4287

    
4288
sshHostDsaPriv :: String
4289
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4290

    
4291
sshHostDsaPub :: String
4292
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4293

    
4294
sshHostRsaPriv :: String
4295
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4296

    
4297
sshHostRsaPub :: String
4298
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4299

    
4300
sshDaemonKeyfiles :: Map String (String, String)
4301
sshDaemonKeyfiles =
4302
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4303
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4304
               ]
4305

    
4306
-- * Node daemon setup
4307

    
4308
ndsClusterName :: String
4309
ndsClusterName = "cluster_name"
4310

    
4311
ndsNodeDaemonCertificate :: String
4312
ndsNodeDaemonCertificate = "node_daemon_certificate"
4313

    
4314
ndsSsconf :: String
4315
ndsSsconf = "ssconf"
4316

    
4317
ndsStartNodeDaemon :: String
4318
ndsStartNodeDaemon = "start_node_daemon"
4319

    
4320
-- * VCluster related constants
4321

    
4322
vClusterEtcHosts :: String
4323
vClusterEtcHosts = "/etc/hosts"
4324

    
4325
vClusterVirtPathPrefix :: String
4326
vClusterVirtPathPrefix = "/###-VIRTUAL-PATH-###,"
4327

    
4328
vClusterRootdirEnvname :: String
4329
vClusterRootdirEnvname = "GANETI_ROOTDIR"
4330

    
4331
vClusterHostnameEnvname :: String
4332
vClusterHostnameEnvname = "GANETI_HOSTNAME"
4333

    
4334
vClusterVpathWhitelist :: FrozenSet String
4335
vClusterVpathWhitelist = ConstantUtils.mkSet [ vClusterEtcHosts ]
4336

    
4337
-- * The source reasons for the execution of an OpCode
4338

    
4339
opcodeReasonSrcClient :: String
4340
opcodeReasonSrcClient = "gnt:client"
4341

    
4342
_opcodeReasonSrcDaemon :: String
4343
_opcodeReasonSrcDaemon = "gnt:daemon"
4344

    
4345
_opcodeReasonSrcMasterd :: String
4346
_opcodeReasonSrcMasterd = _opcodeReasonSrcDaemon ++ ":masterd"
4347

    
4348
opcodeReasonSrcNoded :: String
4349
opcodeReasonSrcNoded = _opcodeReasonSrcDaemon ++ ":noded"
4350

    
4351
opcodeReasonSrcOpcode :: String
4352
opcodeReasonSrcOpcode = "gnt:opcode"
4353

    
4354
opcodeReasonSrcPickup :: String
4355
opcodeReasonSrcPickup = _opcodeReasonSrcMasterd ++ ":pickup"
4356

    
4357
opcodeReasonSrcRlib2 :: String
4358
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4359

    
4360
opcodeReasonSrcUser :: String
4361
opcodeReasonSrcUser = "gnt:user"
4362

    
4363
opcodeReasonSources :: FrozenSet String
4364
opcodeReasonSources =
4365
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4366
                       opcodeReasonSrcNoded,
4367
                       opcodeReasonSrcOpcode,
4368
                       opcodeReasonSrcPickup,
4369
                       opcodeReasonSrcRlib2,
4370
                       opcodeReasonSrcUser]
4371

    
4372
-- | Path generating random UUID
4373
randomUuidFile :: String
4374
randomUuidFile = ConstantUtils.randomUuidFile
4375

    
4376
-- * Auto-repair tag prefixes
4377

    
4378
autoRepairTagPrefix :: String
4379
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4380

    
4381
autoRepairTagEnabled :: String
4382
autoRepairTagEnabled = autoRepairTagPrefix
4383

    
4384
autoRepairTagPending :: String
4385
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4386

    
4387
autoRepairTagResult :: String
4388
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4389

    
4390
autoRepairTagSuspended :: String
4391
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4392

    
4393
-- * Auto-repair levels
4394

    
4395
autoRepairFailover :: String
4396
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4397

    
4398
autoRepairFixStorage :: String
4399
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4400

    
4401
autoRepairMigrate :: String
4402
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4403

    
4404
autoRepairReinstall :: String
4405
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4406

    
4407
autoRepairAllTypes :: FrozenSet String
4408
autoRepairAllTypes =
4409
  ConstantUtils.mkSet [autoRepairFailover,
4410
                       autoRepairFixStorage,
4411
                       autoRepairMigrate,
4412
                       autoRepairReinstall]
4413

    
4414
-- * Auto-repair results
4415

    
4416
autoRepairEnoperm :: String
4417
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4418

    
4419
autoRepairFailure :: String
4420
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4421

    
4422
autoRepairSuccess :: String
4423
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4424

    
4425
autoRepairAllResults :: FrozenSet String
4426
autoRepairAllResults =
4427
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4428

    
4429
-- | The version identifier for builtin data collectors
4430
builtinDataCollectorVersion :: String
4431
builtinDataCollectorVersion = "B"
4432

    
4433
-- | The reason trail opcode parameter name
4434
opcodeReason :: String
4435
opcodeReason = "reason"
4436

    
4437
diskstatsFile :: String
4438
diskstatsFile = "/proc/diskstats"
4439

    
4440
-- *  CPU load collector
4441

    
4442
statFile :: String
4443
statFile = "/proc/stat"
4444

    
4445
cpuavgloadBufferSize :: Int
4446
cpuavgloadBufferSize = 150
4447

    
4448
cpuavgloadWindowSize :: Int
4449
cpuavgloadWindowSize = 600
4450

    
4451
-- * Monitoring daemon
4452

    
4453
-- | Mond's variable for periodical data collection
4454
mondTimeInterval :: Int
4455
mondTimeInterval = 5
4456

    
4457
-- | Mond's latest API version
4458
mondLatestApiVersion :: Int
4459
mondLatestApiVersion = 1
4460

    
4461
-- * Disk access modes
4462

    
4463
diskUserspace :: String
4464
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4465

    
4466
diskKernelspace :: String
4467
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4468

    
4469
diskValidAccessModes :: FrozenSet String
4470
diskValidAccessModes =
4471
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4472

    
4473
-- | Timeout for queue draining in upgrades
4474
upgradeQueueDrainTimeout :: Int
4475
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4476

    
4477
-- | Intervall at which the queue is polled during upgrades
4478
upgradeQueuePollInterval :: Int
4479
upgradeQueuePollInterval  = 10
4480

    
4481
-- * Hotplug Actions
4482

    
4483
hotplugActionAdd :: String
4484
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4485

    
4486
hotplugActionRemove :: String
4487
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4488

    
4489
hotplugActionModify :: String
4490
hotplugActionModify = Types.hotplugActionToRaw HAMod
4491

    
4492
hotplugAllActions :: FrozenSet String
4493
hotplugAllActions =
4494
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4495

    
4496
-- * Hotplug Device Targets
4497

    
4498
hotplugTargetNic :: String
4499
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4500

    
4501
hotplugTargetDisk :: String
4502
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4503

    
4504
hotplugAllTargets :: FrozenSet String
4505
hotplugAllTargets =
4506
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4507

    
4508
-- | Timeout for disk removal (seconds)
4509
diskRemoveRetryTimeout :: Int
4510
diskRemoveRetryTimeout = 30
4511

    
4512
-- | Interval between disk removal retries (seconds)
4513
diskRemoveRetryInterval :: Int
4514
diskRemoveRetryInterval  = 3
4515

    
4516
-- * UUID regex
4517

    
4518
uuidRegex :: String
4519
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4520

    
4521
-- * Luxi constants
4522

    
4523
luxiSocketPerms :: Int
4524
luxiSocketPerms = 0o660
4525

    
4526
luxiKeyMethod :: String
4527
luxiKeyMethod = "method"
4528

    
4529
luxiKeyArgs :: String
4530
luxiKeyArgs = "args"
4531

    
4532
luxiKeySuccess :: String
4533
luxiKeySuccess = "success"
4534

    
4535
luxiKeyResult :: String
4536
luxiKeyResult = "result"
4537

    
4538
luxiKeyVersion :: String
4539
luxiKeyVersion = "version"
4540

    
4541
luxiReqSubmitJob :: String
4542
luxiReqSubmitJob = "SubmitJob"
4543

    
4544
luxiReqSubmitJobToDrainedQueue :: String
4545
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4546

    
4547
luxiReqSubmitManyJobs :: String
4548
luxiReqSubmitManyJobs = "SubmitManyJobs"
4549

    
4550
luxiReqWaitForJobChange :: String
4551
luxiReqWaitForJobChange = "WaitForJobChange"
4552

    
4553
luxiReqPickupJob :: String
4554
luxiReqPickupJob = "PickupJob"
4555

    
4556
luxiReqCancelJob :: String
4557
luxiReqCancelJob = "CancelJob"
4558

    
4559
luxiReqArchiveJob :: String
4560
luxiReqArchiveJob = "ArchiveJob"
4561

    
4562
luxiReqChangeJobPriority :: String
4563
luxiReqChangeJobPriority = "ChangeJobPriority"
4564

    
4565
luxiReqAutoArchiveJobs :: String
4566
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4567

    
4568
luxiReqQuery :: String
4569
luxiReqQuery = "Query"
4570

    
4571
luxiReqQueryFields :: String
4572
luxiReqQueryFields = "QueryFields"
4573

    
4574
luxiReqQueryJobs :: String
4575
luxiReqQueryJobs = "QueryJobs"
4576

    
4577
luxiReqQueryInstances :: String
4578
luxiReqQueryInstances = "QueryInstances"
4579

    
4580
luxiReqQueryNodes :: String
4581
luxiReqQueryNodes = "QueryNodes"
4582

    
4583
luxiReqQueryGroups :: String
4584
luxiReqQueryGroups = "QueryGroups"
4585

    
4586
luxiReqQueryNetworks :: String
4587
luxiReqQueryNetworks = "QueryNetworks"
4588

    
4589
luxiReqQueryExports :: String
4590
luxiReqQueryExports = "QueryExports"
4591

    
4592
luxiReqQueryConfigValues :: String
4593
luxiReqQueryConfigValues = "QueryConfigValues"
4594

    
4595
luxiReqQueryClusterInfo :: String
4596
luxiReqQueryClusterInfo = "QueryClusterInfo"
4597

    
4598
luxiReqQueryTags :: String
4599
luxiReqQueryTags = "QueryTags"
4600

    
4601
luxiReqSetDrainFlag :: String
4602
luxiReqSetDrainFlag = "SetDrainFlag"
4603

    
4604
luxiReqSetWatcherPause :: String
4605
luxiReqSetWatcherPause = "SetWatcherPause"
4606

    
4607
luxiReqAll :: FrozenSet String
4608
luxiReqAll =
4609
  ConstantUtils.mkSet
4610
  [ luxiReqArchiveJob
4611
  , luxiReqAutoArchiveJobs
4612
  , luxiReqCancelJob
4613
  , luxiReqChangeJobPriority
4614
  , luxiReqQuery
4615
  , luxiReqQueryClusterInfo
4616
  , luxiReqQueryConfigValues
4617
  , luxiReqQueryExports
4618
  , luxiReqQueryFields
4619
  , luxiReqQueryGroups
4620
  , luxiReqQueryInstances
4621
  , luxiReqQueryJobs
4622
  , luxiReqQueryNodes
4623
  , luxiReqQueryNetworks
4624
  , luxiReqQueryTags
4625
  , luxiReqSetDrainFlag
4626
  , luxiReqSetWatcherPause
4627
  , luxiReqSubmitJob
4628
  , luxiReqSubmitJobToDrainedQueue
4629
  , luxiReqSubmitManyJobs
4630
  , luxiReqWaitForJobChange
4631
  , luxiReqPickupJob
4632
  ]
4633

    
4634
luxiDefCtmo :: Int
4635
luxiDefCtmo = 10
4636

    
4637
luxiDefRwto :: Int
4638
luxiDefRwto = 60
4639

    
4640
-- | 'WaitForJobChange' timeout
4641
luxiWfjcTimeout :: Int
4642
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4643

    
4644
-- * Query language constants
4645

    
4646
-- ** Logic operators with one or more operands, each of which is a
4647
-- filter on its own
4648

    
4649
qlangOpAnd :: String
4650
qlangOpAnd = "&"
4651

    
4652
qlangOpOr :: String
4653
qlangOpOr = "|"
4654

    
4655
-- ** Unary operators with exactly one operand
4656

    
4657
qlangOpNot :: String
4658
qlangOpNot = "!"
4659

    
4660
qlangOpTrue :: String
4661
qlangOpTrue = "?"
4662

    
4663
-- ** Binary operators with exactly two operands, the field name and
4664
-- an operator-specific value
4665

    
4666
qlangOpContains :: String
4667
qlangOpContains = "=[]"
4668

    
4669
qlangOpEqual :: String
4670
qlangOpEqual = "="
4671

    
4672
qlangOpGe :: String
4673
qlangOpGe = ">="
4674

    
4675
qlangOpGt :: String
4676
qlangOpGt = ">"
4677

    
4678
qlangOpLe :: String
4679
qlangOpLe = "<="
4680

    
4681
qlangOpLt :: String
4682
qlangOpLt = "<"
4683

    
4684
qlangOpNotEqual :: String
4685
qlangOpNotEqual = "!="
4686

    
4687
qlangOpRegexp :: String
4688
qlangOpRegexp = "=~"
4689

    
4690
-- | Characters used for detecting user-written filters (see
4691
-- L{_CheckFilter})
4692

    
4693
qlangFilterDetectionChars :: FrozenSet String
4694
qlangFilterDetectionChars =
4695
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4696
                       ")", "(", "\x0b", "\n",
4697
                       "\r", "\x0c", "/", "<",
4698
                       "\t", ">", "=", "\\", "~"]
4699

    
4700
-- | Characters used to detect globbing filters
4701
qlangGlobDetectionChars :: FrozenSet String
4702
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4703

    
4704
-- * Error related constants
4705
--
4706
-- 'OpPrereqError' failure types
4707

    
4708
-- | Environment error (e.g. node disk error)
4709
errorsEcodeEnviron :: String
4710
errorsEcodeEnviron = "environment_error"
4711

    
4712
-- | Entity already exists
4713
errorsEcodeExists :: String
4714
errorsEcodeExists = "already_exists"
4715

    
4716
-- | Internal cluster error
4717
errorsEcodeFault :: String
4718
errorsEcodeFault = "internal_error"
4719

    
4720
-- | Wrong arguments (at syntax level)
4721
errorsEcodeInval :: String
4722
errorsEcodeInval = "wrong_input"
4723

    
4724
-- | Entity not found
4725
errorsEcodeNoent :: String
4726
errorsEcodeNoent = "unknown_entity"
4727

    
4728
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4729
errorsEcodeNores :: String
4730
errorsEcodeNores = "insufficient_resources"
4731

    
4732
-- | Resource not unique (e.g. MAC or IP duplication)
4733
errorsEcodeNotunique :: String
4734
errorsEcodeNotunique = "resource_not_unique"
4735

    
4736
-- | Resolver errors
4737
errorsEcodeResolver :: String
4738
errorsEcodeResolver = "resolver_error"
4739

    
4740
-- | Wrong entity state
4741
errorsEcodeState :: String
4742
errorsEcodeState = "wrong_state"
4743

    
4744
-- | Temporarily out of resources; operation can be tried again
4745
errorsEcodeTempNores :: String
4746
errorsEcodeTempNores = "temp_insufficient_resources"
4747

    
4748
errorsEcodeAll :: FrozenSet String
4749
errorsEcodeAll =
4750
  ConstantUtils.mkSet [ errorsEcodeNores
4751
                      , errorsEcodeExists
4752
                      , errorsEcodeState
4753
                      , errorsEcodeNotunique
4754
                      , errorsEcodeTempNores
4755
                      , errorsEcodeNoent
4756
                      , errorsEcodeFault
4757
                      , errorsEcodeResolver
4758
                      , errorsEcodeInval
4759
                      , errorsEcodeEnviron
4760
                      ]
4761

    
4762
-- * Jstore related constants
4763

    
4764
jstoreJobsPerArchiveDirectory :: Int
4765
jstoreJobsPerArchiveDirectory = 10000
4766

    
4767
-- * Gluster settings
4768

    
4769
-- | Name of the Gluster host setting
4770
glusterHost :: String
4771
glusterHost = "host"
4772

    
4773
-- | Default value of the Gluster host setting
4774
glusterHostDefault :: String
4775
glusterHostDefault = "127.0.0.1"
4776

    
4777
-- | Name of the Gluster volume setting
4778
glusterVolume :: String
4779
glusterVolume = "volume"
4780

    
4781
-- | Default value of the Gluster volume setting
4782
glusterVolumeDefault :: String
4783
glusterVolumeDefault = "gv0"
4784

    
4785
-- | Name of the Gluster port setting
4786
glusterPort :: String
4787
glusterPort = "port"
4788

    
4789
-- | Default value of the Gluster port setting
4790
glusterPortDefault :: Int
4791
glusterPortDefault = 24007
4792

    
4793
-- * Instance communication
4794
--
4795
-- The instance communication attaches an additional NIC, named
4796
-- @instanceCommunicationNicPrefix@:@instanceName@ with MAC address
4797
-- prefixed by @instanceCommunicationMacPrefix@, to the instances that
4798
-- have instance communication enabled.  This NIC is part of the
4799
-- instance communication network which is supplied by the user via
4800
--
4801
--   gnt-cluster modify --instance-communication=mynetwork
4802
--
4803
-- This network is defined as @instanceCommunicationNetwork4@ for IPv4
4804
-- and @instanceCommunicationNetwork6@ for IPv6.
4805

    
4806
instanceCommunicationDoc :: String
4807
instanceCommunicationDoc =
4808
  "Enable or disable the communication mechanism for an instance"
4809

    
4810
instanceCommunicationMacPrefix :: String
4811
instanceCommunicationMacPrefix = "52:54:00"
4812

    
4813
-- | The instance communication network is a link-local IPv4/IPv6
4814
-- network because the communication is meant to be exclusive between
4815
-- the host and the guest and not routed outside the node.
4816
instanceCommunicationNetwork4 :: String
4817
instanceCommunicationNetwork4 = "169.254.0.0/16"
4818

    
4819
-- | See 'instanceCommunicationNetwork4'.
4820
instanceCommunicationNetwork6 :: String
4821
instanceCommunicationNetwork6 = "fe80::/10"
4822

    
4823
instanceCommunicationNetworkLink :: String
4824
instanceCommunicationNetworkLink = "communication_rt"
4825

    
4826
instanceCommunicationNetworkMode :: String
4827
instanceCommunicationNetworkMode = nicModeRouted
4828

    
4829
instanceCommunicationNicPrefix :: String
4830
instanceCommunicationNicPrefix = "ganeti:communication:"
4831

    
4832
-- | Parameters that should be protected
4833
--
4834
-- Python does not have a type system and can't automatically infer what should
4835
-- be the resulting type of a JSON request. As a result, it must rely on this
4836
-- list of parameter names to protect values correctly.
4837
--
4838
-- Names ending in _cluster will be treated as dicts of dicts of private values.
4839
-- Otherwise they are considered dicts of private values.
4840
privateParametersBlacklist :: [String]
4841
privateParametersBlacklist = [ "osparams_private"
4842
                             , "osparams_secret"
4843
                             , "osparams_private_cluster"
4844
                             ]
4845

    
4846
-- | Warn the user that the logging level is too low for production use.
4847
debugModeConfidentialityWarning :: String
4848
debugModeConfidentialityWarning =
4849
  "ALERT: %s started in debug mode.\n\
4850
  \ Private and secret parameters WILL be logged!\n"