Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 8106dd64

History | View | Annotate | Download (114.9 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 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
rapiUser :: String
204
rapiUser = Runtime.daemonUser GanetiRapi
205

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

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

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

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

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

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

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

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

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

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

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

    
239
-- * Cpu pinning separators and constants
240

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

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

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

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

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

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

    
279
-- * Wipe
280

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

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

    
288
minWipeChunkPercent :: Int
289
minWipeChunkPercent = 10
290

    
291
-- * Directories
292

    
293
runDirsMode :: Int
294
runDirsMode = 0o775
295

    
296
secureDirMode :: Int
297
secureDirMode = 0o700
298

    
299
secureFileMode :: Int
300
secureFileMode = 0o600
301

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

    
305
-- * 'autoconf' enable/disable
306

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

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

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

    
316
-- * SSH constants
317

    
318
ssh :: String
319
ssh = "ssh"
320

    
321
scp :: String
322
scp = "scp"
323

    
324
-- * Daemons
325

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

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

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

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

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

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

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

    
353
defaultConfdPort :: Int
354
defaultConfdPort = 1814
355

    
356
defaultMondPort :: Int
357
defaultMondPort = 1815
358

    
359
defaultNodedPort :: Int
360
defaultNodedPort = 1811
361

    
362
defaultRapiPort :: Int
363
defaultRapiPort = 5080
364

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

    
373
firstDrbdPort :: Int
374
firstDrbdPort = 11000
375

    
376
lastDrbdPort :: Int
377
lastDrbdPort = 14999
378

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

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

    
394
extraLogreasonAccess :: String
395
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
396

    
397
extraLogreasonError :: String
398
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
399

    
400
devConsole :: String
401
devConsole = ConstantUtils.devConsole
402

    
403
procMounts :: String
404
procMounts = "/proc/mounts"
405

    
406
-- * Luxi (Local UniX Interface) related constants
407

    
408
luxiEom :: PythonChar
409
luxiEom = PythonChar '\x03'
410

    
411
-- | Environment variable for the luxi override socket
412
luxiOverride :: String
413
luxiOverride = "FORCE_LUXI_SOCKET"
414

    
415
luxiOverrideMaster :: String
416
luxiOverrideMaster = "master"
417

    
418
luxiOverrideQuery :: String
419
luxiOverrideQuery = "query"
420

    
421
luxiVersion :: Int
422
luxiVersion = configVersion
423

    
424
-- * Syslog
425

    
426
syslogUsage :: String
427
syslogUsage = AutoConf.syslogUsage
428

    
429
syslogNo :: String
430
syslogNo = Logging.syslogUsageToRaw SyslogNo
431

    
432
syslogYes :: String
433
syslogYes = Logging.syslogUsageToRaw SyslogYes
434

    
435
syslogOnly :: String
436
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
437

    
438
syslogSocket :: String
439
syslogSocket = "/dev/log"
440

    
441
exportConfFile :: String
442
exportConfFile = "config.ini"
443

    
444
-- * Xen
445

    
446
xenBootloader :: String
447
xenBootloader = AutoConf.xenBootloader
448

    
449
xenCmdXl :: String
450
xenCmdXl = "xl"
451

    
452
xenCmdXm :: String
453
xenCmdXm = "xm"
454

    
455
xenInitrd :: String
456
xenInitrd = AutoConf.xenInitrd
457

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

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

    
466
-- * KVM and socat
467

    
468
kvmPath :: String
469
kvmPath = AutoConf.kvmPath
470

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

    
474
socatEscapeCode :: String
475
socatEscapeCode = "0x1d"
476

    
477
socatPath :: String
478
socatPath = AutoConf.socatPath
479

    
480
socatUseCompress :: Bool
481
socatUseCompress = AutoConf.socatUseCompress
482

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

    
486
-- * Console types
487

    
488
-- | Display a message for console access
489
consMessage :: String
490
consMessage = "msg"
491

    
492
-- | Console as SPICE server
493
consSpice :: String
494
consSpice = "spice"
495

    
496
-- | Console as SSH command
497
consSsh :: String
498
consSsh = "ssh"
499

    
500
-- | Console as VNC server
501
consVnc :: String
502
consVnc = "vnc"
503

    
504
consAll :: FrozenSet String
505
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
506

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

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

    
526
-- * X509
527

    
528
-- | commonName (CN) used in certificates
529
x509CertCn :: String
530
x509CertCn = "ganeti.example.com"
531

    
532
-- | Default validity of certificates in days
533
x509CertDefaultValidity :: Int
534
x509CertDefaultValidity = 365 * 5
535

    
536
x509CertSignatureHeader :: String
537
x509CertSignatureHeader = "X-Ganeti-Signature"
538

    
539
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
540
x509CertSignDigest :: String
541
x509CertSignDigest = "SHA1"
542

    
543
-- * Import/export daemon mode
544

    
545
iemExport :: String
546
iemExport = "export"
547

    
548
iemImport :: String
549
iemImport = "import"
550

    
551
-- * Import/export transport compression
552

    
553
iecGzip :: String
554
iecGzip = "gzip"
555

    
556
iecNone :: String
557
iecNone = "none"
558

    
559
iecAll :: [String]
560
iecAll = [iecGzip, iecNone]
561

    
562
ieCustomSize :: String
563
ieCustomSize = "fd"
564

    
565
-- * Import/export I/O
566

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

    
572
-- | Raw block device I/O using "dd"
573
ieioRawDisk :: String
574
ieioRawDisk = "raw"
575

    
576
-- | OS definition import/export script
577
ieioScript :: String
578
ieioScript = "script"
579

    
580
-- * Values
581

    
582
valueDefault :: String
583
valueDefault = "default"
584

    
585
valueAuto :: String
586
valueAuto = "auto"
587

    
588
valueGenerate :: String
589
valueGenerate = "generate"
590

    
591
valueNone :: String
592
valueNone = "none"
593

    
594
valueTrue :: String
595
valueTrue = "true"
596

    
597
valueFalse :: String
598
valueFalse = "false"
599

    
600
-- * Hooks
601

    
602
hooksNameCfgupdate :: String
603
hooksNameCfgupdate = "config-update"
604

    
605
hooksNameWatcher :: String
606
hooksNameWatcher = "watcher"
607

    
608
hooksPath :: String
609
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
610

    
611
hooksPhasePost :: String
612
hooksPhasePost = "post"
613

    
614
hooksPhasePre :: String
615
hooksPhasePre = "pre"
616

    
617
hooksVersion :: Int
618
hooksVersion = 2
619

    
620
-- * Hooks subject type (what object type does the LU deal with)
621

    
622
htypeCluster :: String
623
htypeCluster = "CLUSTER"
624

    
625
htypeGroup :: String
626
htypeGroup = "GROUP"
627

    
628
htypeInstance :: String
629
htypeInstance = "INSTANCE"
630

    
631
htypeNetwork :: String
632
htypeNetwork = "NETWORK"
633

    
634
htypeNode :: String
635
htypeNode = "NODE"
636

    
637
-- * Hkr
638

    
639
hkrSkip :: Int
640
hkrSkip = 0
641

    
642
hkrFail :: Int
643
hkrFail = 1
644

    
645
hkrSuccess :: Int
646
hkrSuccess = 2
647

    
648
-- * Storage types
649

    
650
stBlock :: String
651
stBlock = Types.storageTypeToRaw StorageBlock
652

    
653
stDiskless :: String
654
stDiskless = Types.storageTypeToRaw StorageDiskless
655

    
656
stExt :: String
657
stExt = Types.storageTypeToRaw StorageExt
658

    
659
stFile :: String
660
stFile = Types.storageTypeToRaw StorageFile
661

    
662
stLvmPv :: String
663
stLvmPv = Types.storageTypeToRaw StorageLvmPv
664

    
665
stLvmVg :: String
666
stLvmVg = Types.storageTypeToRaw StorageLvmVg
667

    
668
stRados :: String
669
stRados = Types.storageTypeToRaw StorageRados
670

    
671
storageTypes :: FrozenSet String
672
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
673

    
674
-- | The set of storage types for which storage reporting is available
675
--
676
-- FIXME: Remove this, once storage reporting is available for all
677
-- types.
678
stsReport :: FrozenSet String
679
stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg]
680

    
681
-- * Storage fields
682
-- ** First two are valid in LU context only, not passed to backend
683

    
684
sfNode :: String
685
sfNode = "node"
686

    
687
sfType :: String
688
sfType = "type"
689

    
690
-- ** and the rest are valid in backend
691

    
692
sfAllocatable :: String
693
sfAllocatable = Types.storageFieldToRaw SFAllocatable
694

    
695
sfFree :: String
696
sfFree = Types.storageFieldToRaw SFFree
697

    
698
sfName :: String
699
sfName = Types.storageFieldToRaw SFName
700

    
701
sfSize :: String
702
sfSize = Types.storageFieldToRaw SFSize
703

    
704
sfUsed :: String
705
sfUsed = Types.storageFieldToRaw SFUsed
706

    
707
validStorageFields :: FrozenSet String
708
validStorageFields =
709
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
710
                        [sfNode, sfType]
711

    
712
modifiableStorageFields :: Map String (FrozenSet String)
713
modifiableStorageFields =
714
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
715
                 ConstantUtils.mkSet [sfAllocatable])]
716

    
717
-- * Storage operations
718

    
719
soFixConsistency :: String
720
soFixConsistency = "fix-consistency"
721

    
722
validStorageOperations :: Map String (FrozenSet String)
723
validStorageOperations =
724
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
725
                 ConstantUtils.mkSet [soFixConsistency])]
726

    
727
-- * Volume fields
728

    
729
vfDev :: String
730
vfDev = "dev"
731

    
732
vfInstance :: String
733
vfInstance = "instance"
734

    
735
vfName :: String
736
vfName = "name"
737

    
738
vfNode :: String
739
vfNode = "node"
740

    
741
vfPhys :: String
742
vfPhys = "phys"
743

    
744
vfSize :: String
745
vfSize = "size"
746

    
747
vfVg :: String
748
vfVg = "vg"
749

    
750
-- * Local disk status
751

    
752
ldsFaulty :: Int
753
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
754

    
755
ldsOkay :: Int
756
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
757

    
758
ldsUnknown :: Int
759
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
760

    
761
ldsNames :: Map Int String
762
ldsNames =
763
  Map.fromList [ (Types.localDiskStatusToRaw ds,
764
                  localDiskStatusName ds) | ds <- [minBound..] ]
765

    
766
-- * Disk template types
767

    
768
dtDiskless :: String
769
dtDiskless = Types.diskTemplateToRaw DTDiskless
770

    
771
dtFile :: String
772
dtFile = Types.diskTemplateToRaw DTFile
773

    
774
dtSharedFile :: String
775
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
776

    
777
dtPlain :: String
778
dtPlain = Types.diskTemplateToRaw DTPlain
779

    
780
dtBlock :: String
781
dtBlock = Types.diskTemplateToRaw DTBlock
782

    
783
dtDrbd8 :: String
784
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
785

    
786
dtRbd :: String
787
dtRbd = Types.diskTemplateToRaw DTRbd
788

    
789
dtExt :: String
790
dtExt = Types.diskTemplateToRaw DTExt
791

    
792
dtGluster :: String
793
dtGluster = Types.diskTemplateToRaw DTGluster
794

    
795
-- | This is used to order determine the default disk template when
796
-- the list of enabled disk templates is inferred from the current
797
-- state of the cluster.  This only happens on an upgrade from a
798
-- version of Ganeti that did not support the 'enabled_disk_templates'
799
-- so far.
800
diskTemplatePreference :: [String]
801
diskTemplatePreference =
802
  map Types.diskTemplateToRaw
803
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile,
804
   DTPlain, DTRbd, DTSharedFile, DTGluster]
805

    
806
diskTemplates :: FrozenSet String
807
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
808

    
809
-- | Disk templates that are enabled by default
810
defaultEnabledDiskTemplates :: [String]
811
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
812

    
813
-- | Mapping of disk templates to storage types
814
mapDiskTemplateStorageType :: Map String String
815
mapDiskTemplateStorageType =
816
  Map.fromList $
817
  map (Types.diskTemplateToRaw *** Types.storageTypeToRaw)
818
  [(DTBlock, StorageBlock),
819
   (DTDrbd8, StorageLvmVg),
820
   (DTExt, StorageExt),
821
   (DTSharedFile, StorageFile),
822
   (DTFile, StorageFile),
823
   (DTDiskless, StorageDiskless),
824
   (DTPlain, StorageLvmVg),
825
   (DTRbd, StorageRados),
826
   (DTGluster, StorageFile)]
827

    
828
-- | The set of network-mirrored disk templates
829
dtsIntMirror :: FrozenSet String
830
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
831

    
832
-- | 'DTDiskless' is 'trivially' externally mirrored
833
dtsExtMirror :: FrozenSet String
834
dtsExtMirror =
835
  ConstantUtils.mkSet $
836
  map Types.diskTemplateToRaw
837
  [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd, DTGluster]
838

    
839
-- | The set of non-lvm-based disk templates
840
dtsNotLvm :: FrozenSet String
841
dtsNotLvm =
842
  ConstantUtils.mkSet $
843
  map Types.diskTemplateToRaw
844
  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd, DTGluster]
845

    
846
-- | The set of disk templates which can be grown
847
dtsGrowable :: FrozenSet String
848
dtsGrowable =
849
  ConstantUtils.mkSet $
850
  map Types.diskTemplateToRaw
851
  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd, DTGluster]
852

    
853
-- | The set of disk templates that allow adoption
854
dtsMayAdopt :: FrozenSet String
855
dtsMayAdopt =
856
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
857

    
858
-- | The set of disk templates that *must* use adoption
859
dtsMustAdopt :: FrozenSet String
860
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
861

    
862
-- | The set of disk templates that allow migrations
863
dtsMirrored :: FrozenSet String
864
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
865

    
866
-- | The set of file based disk templates
867
dtsFilebased :: FrozenSet String
868
dtsFilebased =
869
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw
870
  [DTSharedFile, DTFile, DTGluster]
871

    
872
-- | The set of disk templates that can be moved by copying
873
--
874
-- Note: a requirement is that they're not accessed externally or
875
-- shared between nodes; in particular, sharedfile is not suitable.
876
dtsCopyable :: FrozenSet String
877
dtsCopyable =
878
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
879

    
880
-- | The set of disk templates that are supported by exclusive_storage
881
dtsExclStorage :: FrozenSet String
882
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
883

    
884
-- | Templates for which we don't perform checks on free space
885
dtsNoFreeSpaceCheck :: FrozenSet String
886
dtsNoFreeSpaceCheck =
887
  ConstantUtils.mkSet $
888
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd, DTGluster]
889

    
890
dtsBlock :: FrozenSet String
891
dtsBlock =
892
  ConstantUtils.mkSet $
893
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
894

    
895
-- | The set of lvm-based disk templates
896
dtsLvm :: FrozenSet String
897
dtsLvm = diskTemplates `ConstantUtils.difference` dtsNotLvm
898

    
899
-- * Drbd
900

    
901
drbdHmacAlg :: String
902
drbdHmacAlg = "md5"
903

    
904
drbdDefaultNetProtocol :: String
905
drbdDefaultNetProtocol = "C"
906

    
907
drbdMigrationNetProtocol :: String
908
drbdMigrationNetProtocol = "C"
909

    
910
drbdStatusFile :: String
911
drbdStatusFile = "/proc/drbd"
912

    
913
-- | Size of DRBD meta block device
914
drbdMetaSize :: Int
915
drbdMetaSize = 128
916

    
917
-- * Drbd barrier types
918

    
919
drbdBDiskBarriers :: String
920
drbdBDiskBarriers = "b"
921

    
922
drbdBDiskDrain :: String
923
drbdBDiskDrain = "d"
924

    
925
drbdBDiskFlush :: String
926
drbdBDiskFlush = "f"
927

    
928
drbdBNone :: String
929
drbdBNone = "n"
930

    
931
-- | Valid barrier combinations: "n" or any non-null subset of "bfd"
932
drbdValidBarrierOpt :: FrozenSet (FrozenSet String)
933
drbdValidBarrierOpt =
934
  ConstantUtils.mkSet
935
  [ ConstantUtils.mkSet [drbdBNone]
936
  , ConstantUtils.mkSet [drbdBDiskBarriers]
937
  , ConstantUtils.mkSet [drbdBDiskDrain]
938
  , ConstantUtils.mkSet [drbdBDiskFlush]
939
  , ConstantUtils.mkSet [drbdBDiskDrain, drbdBDiskFlush]
940
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskDrain]
941
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush]
942
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush, drbdBDiskDrain]
943
  ]
944

    
945
-- | Rbd tool command
946
rbdCmd :: String
947
rbdCmd = "rbd"
948

    
949
-- * File backend driver
950

    
951
fdBlktap :: String
952
fdBlktap = Types.fileDriverToRaw FileBlktap
953

    
954
fdLoop :: String
955
fdLoop = Types.fileDriverToRaw FileLoop
956

    
957
fileDriver :: FrozenSet String
958
fileDriver =
959
  ConstantUtils.mkSet $
960
  map Types.fileDriverToRaw [minBound..]
961

    
962
-- | The set of drbd-like disk types
963
dtsDrbd :: FrozenSet String
964
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
965

    
966
-- * Disk access mode
967

    
968
diskRdonly :: String
969
diskRdonly = Types.diskModeToRaw DiskRdOnly
970

    
971
diskRdwr :: String
972
diskRdwr = Types.diskModeToRaw DiskRdWr
973

    
974
diskAccessSet :: FrozenSet String
975
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
976

    
977
-- * Disk replacement mode
978

    
979
replaceDiskAuto :: String
980
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
981

    
982
replaceDiskChg :: String
983
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
984

    
985
replaceDiskPri :: String
986
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
987

    
988
replaceDiskSec :: String
989
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
990

    
991
replaceModes :: FrozenSet String
992
replaceModes =
993
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
994

    
995
-- * Instance export mode
996

    
997
exportModeLocal :: String
998
exportModeLocal = Types.exportModeToRaw ExportModeLocal
999

    
1000
exportModeRemote :: String
1001
exportModeRemote = Types.exportModeToRaw ExportModeRemote
1002

    
1003
exportModes :: FrozenSet String
1004
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
1005

    
1006
-- * Instance creation modes
1007

    
1008
instanceCreate :: String
1009
instanceCreate = Types.instCreateModeToRaw InstCreate
1010

    
1011
instanceImport :: String
1012
instanceImport = Types.instCreateModeToRaw InstImport
1013

    
1014
instanceRemoteImport :: String
1015
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1016

    
1017
instanceCreateModes :: FrozenSet String
1018
instanceCreateModes =
1019
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1020

    
1021
-- * Remote import/export handshake message and version
1022

    
1023
rieHandshake :: String
1024
rieHandshake = "Hi, I'm Ganeti"
1025

    
1026
rieVersion :: Int
1027
rieVersion = 0
1028

    
1029
-- | Remote import/export certificate validity (seconds)
1030
rieCertValidity :: Int
1031
rieCertValidity = 24 * 60 * 60
1032

    
1033
-- | Export only: how long to wait per connection attempt (seconds)
1034
rieConnectAttemptTimeout :: Int
1035
rieConnectAttemptTimeout = 20
1036

    
1037
-- | Export only: number of attempts to connect
1038
rieConnectRetries :: Int
1039
rieConnectRetries = 10
1040

    
1041
-- | Overall timeout for establishing connection
1042
rieConnectTimeout :: Int
1043
rieConnectTimeout = 180
1044

    
1045
-- | Give child process up to 5 seconds to exit after sending a signal
1046
childLingerTimeout :: Double
1047
childLingerTimeout = 5.0
1048

    
1049
-- * Import/export config options
1050

    
1051
inisectBep :: String
1052
inisectBep = "backend"
1053

    
1054
inisectExp :: String
1055
inisectExp = "export"
1056

    
1057
inisectHyp :: String
1058
inisectHyp = "hypervisor"
1059

    
1060
inisectIns :: String
1061
inisectIns = "instance"
1062

    
1063
inisectOsp :: String
1064
inisectOsp = "os"
1065

    
1066
-- * Dynamic device modification
1067

    
1068
ddmAdd :: String
1069
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1070

    
1071
ddmModify :: String
1072
ddmModify = Types.ddmFullToRaw DdmFullModify
1073

    
1074
ddmRemove :: String
1075
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1076

    
1077
ddmsValues :: FrozenSet String
1078
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1079

    
1080
ddmsValuesWithModify :: FrozenSet String
1081
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1082

    
1083
-- * Common exit codes
1084

    
1085
exitSuccess :: Int
1086
exitSuccess = 0
1087

    
1088
exitFailure :: Int
1089
exitFailure = ConstantUtils.exitFailure
1090

    
1091
exitNotcluster :: Int
1092
exitNotcluster = 5
1093

    
1094
exitNotmaster :: Int
1095
exitNotmaster = 11
1096

    
1097
exitNodesetupError :: Int
1098
exitNodesetupError = 12
1099

    
1100
-- | Need user confirmation
1101
exitConfirmation :: Int
1102
exitConfirmation = 13
1103

    
1104
-- | Exit code for query operations with unknown fields
1105
exitUnknownField :: Int
1106
exitUnknownField = 14
1107

    
1108
-- * Tags
1109

    
1110
tagCluster :: String
1111
tagCluster = Types.tagKindToRaw TagKindCluster
1112

    
1113
tagInstance :: String
1114
tagInstance = Types.tagKindToRaw TagKindInstance
1115

    
1116
tagNetwork :: String
1117
tagNetwork = Types.tagKindToRaw TagKindNetwork
1118

    
1119
tagNode :: String
1120
tagNode = Types.tagKindToRaw TagKindNode
1121

    
1122
tagNodegroup :: String
1123
tagNodegroup = Types.tagKindToRaw TagKindGroup
1124

    
1125
validTagTypes :: FrozenSet String
1126
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1127

    
1128
maxTagLen :: Int
1129
maxTagLen = 128
1130

    
1131
maxTagsPerObj :: Int
1132
maxTagsPerObj = 4096
1133

    
1134
-- * Others
1135

    
1136
defaultBridge :: String
1137
defaultBridge = "xen-br0"
1138

    
1139
defaultOvs :: String
1140
defaultOvs = "switch1"
1141

    
1142
-- | 60 MiB/s, expressed in KiB/s
1143
classicDrbdSyncSpeed :: Int
1144
classicDrbdSyncSpeed = 60 * 1024
1145

    
1146
ip4AddressAny :: String
1147
ip4AddressAny = "0.0.0.0"
1148

    
1149
ip4AddressLocalhost :: String
1150
ip4AddressLocalhost = "127.0.0.1"
1151

    
1152
ip6AddressAny :: String
1153
ip6AddressAny = "::"
1154

    
1155
ip6AddressLocalhost :: String
1156
ip6AddressLocalhost = "::1"
1157

    
1158
ip4Version :: Int
1159
ip4Version = 4
1160

    
1161
ip6Version :: Int
1162
ip6Version = 6
1163

    
1164
validIpVersions :: FrozenSet Int
1165
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1166

    
1167
tcpPingTimeout :: Int
1168
tcpPingTimeout = 10
1169

    
1170
defaultVg :: String
1171
defaultVg = "xenvg"
1172

    
1173
defaultDrbdHelper :: String
1174
defaultDrbdHelper = "/bin/true"
1175

    
1176
minVgSize :: Int
1177
minVgSize = 20480
1178

    
1179
defaultMacPrefix :: String
1180
defaultMacPrefix = "aa:00:00"
1181

    
1182
-- | Default maximum instance wait time (seconds)
1183
defaultShutdownTimeout :: Int
1184
defaultShutdownTimeout = 120
1185

    
1186
-- | Node clock skew (seconds)
1187
nodeMaxClockSkew :: Int
1188
nodeMaxClockSkew = 150
1189

    
1190
-- | Time for an intra-cluster disk transfer to wait for a connection
1191
diskTransferConnectTimeout :: Int
1192
diskTransferConnectTimeout = 60
1193

    
1194
-- | Disk index separator
1195
diskSeparator :: String
1196
diskSeparator = AutoConf.diskSeparator
1197

    
1198
ipCommandPath :: String
1199
ipCommandPath = AutoConf.ipPath
1200

    
1201
-- | Key for job IDs in opcode result
1202
jobIdsKey :: String
1203
jobIdsKey = "jobs"
1204

    
1205
-- * Runparts results
1206

    
1207
runpartsErr :: Int
1208
runpartsErr = 2
1209

    
1210
runpartsRun :: Int
1211
runpartsRun = 1
1212

    
1213
runpartsSkip :: Int
1214
runpartsSkip = 0
1215

    
1216
runpartsStatus :: [Int]
1217
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1218

    
1219
-- * RPC
1220

    
1221
rpcEncodingNone :: Int
1222
rpcEncodingNone = 0
1223

    
1224
rpcEncodingZlibBase64 :: Int
1225
rpcEncodingZlibBase64 = 1
1226

    
1227
-- * Timeout table
1228
--
1229
-- Various time constants for the timeout table
1230

    
1231
rpcTmoUrgent :: Int
1232
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1233

    
1234
rpcTmoFast :: Int
1235
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1236

    
1237
rpcTmoNormal :: Int
1238
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1239

    
1240
rpcTmoSlow :: Int
1241
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1242

    
1243
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1244
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1245
-- Python name.
1246
rpcTmo_4hrs :: Int
1247
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1248

    
1249
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1250
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1251
-- Python name.
1252
rpcTmo_1day :: Int
1253
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1254

    
1255
-- | Timeout for connecting to nodes (seconds)
1256
rpcConnectTimeout :: Int
1257
rpcConnectTimeout = 5
1258

    
1259
-- OS
1260

    
1261
osScriptCreate :: String
1262
osScriptCreate = "create"
1263

    
1264
osScriptExport :: String
1265
osScriptExport = "export"
1266

    
1267
osScriptImport :: String
1268
osScriptImport = "import"
1269

    
1270
osScriptRename :: String
1271
osScriptRename = "rename"
1272

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

    
1276
osScripts :: [String]
1277
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1278
             osScriptVerify]
1279

    
1280
osApiFile :: String
1281
osApiFile = "ganeti_api_version"
1282

    
1283
osVariantsFile :: String
1284
osVariantsFile = "variants.list"
1285

    
1286
osParametersFile :: String
1287
osParametersFile = "parameters.list"
1288

    
1289
osValidateParameters :: String
1290
osValidateParameters = "parameters"
1291

    
1292
osValidateCalls :: FrozenSet String
1293
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1294

    
1295
-- | External Storage (ES) related constants
1296

    
1297
esActionAttach :: String
1298
esActionAttach = "attach"
1299

    
1300
esActionCreate :: String
1301
esActionCreate = "create"
1302

    
1303
esActionDetach :: String
1304
esActionDetach = "detach"
1305

    
1306
esActionGrow :: String
1307
esActionGrow = "grow"
1308

    
1309
esActionRemove :: String
1310
esActionRemove = "remove"
1311

    
1312
esActionSetinfo :: String
1313
esActionSetinfo = "setinfo"
1314

    
1315
esActionVerify :: String
1316
esActionVerify = "verify"
1317

    
1318
esScriptCreate :: String
1319
esScriptCreate = esActionCreate
1320

    
1321
esScriptRemove :: String
1322
esScriptRemove = esActionRemove
1323

    
1324
esScriptGrow :: String
1325
esScriptGrow = esActionGrow
1326

    
1327
esScriptAttach :: String
1328
esScriptAttach = esActionAttach
1329

    
1330
esScriptDetach :: String
1331
esScriptDetach = esActionDetach
1332

    
1333
esScriptSetinfo :: String
1334
esScriptSetinfo = esActionSetinfo
1335

    
1336
esScriptVerify :: String
1337
esScriptVerify = esActionVerify
1338

    
1339
esScripts :: FrozenSet String
1340
esScripts =
1341
  ConstantUtils.mkSet [esScriptAttach,
1342
                       esScriptCreate,
1343
                       esScriptDetach,
1344
                       esScriptGrow,
1345
                       esScriptRemove,
1346
                       esScriptSetinfo,
1347
                       esScriptVerify]
1348

    
1349
esParametersFile :: String
1350
esParametersFile = "parameters.list"
1351

    
1352
-- * Reboot types
1353

    
1354
instanceRebootSoft :: String
1355
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1356

    
1357
instanceRebootHard :: String
1358
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1359

    
1360
instanceRebootFull :: String
1361
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1362

    
1363
rebootTypes :: FrozenSet String
1364
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1365

    
1366
-- * Instance reboot behaviors
1367

    
1368
instanceRebootAllowed :: String
1369
instanceRebootAllowed = "reboot"
1370

    
1371
instanceRebootExit :: String
1372
instanceRebootExit = "exit"
1373

    
1374
rebootBehaviors :: [String]
1375
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1376

    
1377
-- * VTypes
1378

    
1379
vtypeBool :: VType
1380
vtypeBool = VTypeBool
1381

    
1382
vtypeInt :: VType
1383
vtypeInt = VTypeInt
1384

    
1385
vtypeMaybeString :: VType
1386
vtypeMaybeString = VTypeMaybeString
1387

    
1388
-- | Size in MiBs
1389
vtypeSize :: VType
1390
vtypeSize = VTypeSize
1391

    
1392
vtypeString :: VType
1393
vtypeString = VTypeString
1394

    
1395
enforceableTypes :: FrozenSet VType
1396
enforceableTypes = ConstantUtils.mkSet [minBound..]
1397

    
1398
-- | Constant representing that the user does not specify any IP version
1399
ifaceNoIpVersionSpecified :: Int
1400
ifaceNoIpVersionSpecified = 0
1401

    
1402
validSerialSpeeds :: [Int]
1403
validSerialSpeeds =
1404
  [75,
1405
   110,
1406
   300,
1407
   600,
1408
   1200,
1409
   1800,
1410
   2400,
1411
   4800,
1412
   9600,
1413
   14400,
1414
   19200,
1415
   28800,
1416
   38400,
1417
   57600,
1418
   115200,
1419
   230400,
1420
   345600,
1421
   460800]
1422

    
1423
-- * HV parameter names (global namespace)
1424

    
1425
hvAcpi :: String
1426
hvAcpi = "acpi"
1427

    
1428
hvBlockdevPrefix :: String
1429
hvBlockdevPrefix = "blockdev_prefix"
1430

    
1431
hvBootloaderArgs :: String
1432
hvBootloaderArgs = "bootloader_args"
1433

    
1434
hvBootloaderPath :: String
1435
hvBootloaderPath = "bootloader_path"
1436

    
1437
hvBootOrder :: String
1438
hvBootOrder = "boot_order"
1439

    
1440
hvCdromImagePath :: String
1441
hvCdromImagePath = "cdrom_image_path"
1442

    
1443
hvCpuCap :: String
1444
hvCpuCap = "cpu_cap"
1445

    
1446
hvCpuCores :: String
1447
hvCpuCores = "cpu_cores"
1448

    
1449
hvCpuMask :: String
1450
hvCpuMask = "cpu_mask"
1451

    
1452
hvCpuSockets :: String
1453
hvCpuSockets = "cpu_sockets"
1454

    
1455
hvCpuThreads :: String
1456
hvCpuThreads = "cpu_threads"
1457

    
1458
hvCpuType :: String
1459
hvCpuType = "cpu_type"
1460

    
1461
hvCpuWeight :: String
1462
hvCpuWeight = "cpu_weight"
1463

    
1464
hvDeviceModel :: String
1465
hvDeviceModel = "device_model"
1466

    
1467
hvDiskCache :: String
1468
hvDiskCache = "disk_cache"
1469

    
1470
hvDiskType :: String
1471
hvDiskType = "disk_type"
1472

    
1473
hvInitrdPath :: String
1474
hvInitrdPath = "initrd_path"
1475

    
1476
hvInitScript :: String
1477
hvInitScript = "init_script"
1478

    
1479
hvKernelArgs :: String
1480
hvKernelArgs = "kernel_args"
1481

    
1482
hvKernelPath :: String
1483
hvKernelPath = "kernel_path"
1484

    
1485
hvKeymap :: String
1486
hvKeymap = "keymap"
1487

    
1488
hvKvmCdrom2ImagePath :: String
1489
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1490

    
1491
hvKvmCdromDiskType :: String
1492
hvKvmCdromDiskType = "cdrom_disk_type"
1493

    
1494
hvKvmExtra :: String
1495
hvKvmExtra = "kvm_extra"
1496

    
1497
hvKvmFlag :: String
1498
hvKvmFlag = "kvm_flag"
1499

    
1500
hvKvmFloppyImagePath :: String
1501
hvKvmFloppyImagePath = "floppy_image_path"
1502

    
1503
hvKvmMachineVersion :: String
1504
hvKvmMachineVersion = "machine_version"
1505

    
1506
hvKvmPath :: String
1507
hvKvmPath = "kvm_path"
1508

    
1509
hvKvmSpiceAudioCompr :: String
1510
hvKvmSpiceAudioCompr = "spice_playback_compression"
1511

    
1512
hvKvmSpiceBind :: String
1513
hvKvmSpiceBind = "spice_bind"
1514

    
1515
hvKvmSpiceIpVersion :: String
1516
hvKvmSpiceIpVersion = "spice_ip_version"
1517

    
1518
hvKvmSpiceJpegImgCompr :: String
1519
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1520

    
1521
hvKvmSpiceLosslessImgCompr :: String
1522
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1523

    
1524
hvKvmSpicePasswordFile :: String
1525
hvKvmSpicePasswordFile = "spice_password_file"
1526

    
1527
hvKvmSpiceStreamingVideoDetection :: String
1528
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1529

    
1530
hvKvmSpiceTlsCiphers :: String
1531
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1532

    
1533
hvKvmSpiceUseTls :: String
1534
hvKvmSpiceUseTls = "spice_use_tls"
1535

    
1536
hvKvmSpiceUseVdagent :: String
1537
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1538

    
1539
hvKvmSpiceZlibGlzImgCompr :: String
1540
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1541

    
1542
hvKvmUseChroot :: String
1543
hvKvmUseChroot = "use_chroot"
1544

    
1545
hvMemPath :: String
1546
hvMemPath = "mem_path"
1547

    
1548
hvMigrationBandwidth :: String
1549
hvMigrationBandwidth = "migration_bandwidth"
1550

    
1551
hvMigrationDowntime :: String
1552
hvMigrationDowntime = "migration_downtime"
1553

    
1554
hvMigrationMode :: String
1555
hvMigrationMode = "migration_mode"
1556

    
1557
hvMigrationPort :: String
1558
hvMigrationPort = "migration_port"
1559

    
1560
hvNicType :: String
1561
hvNicType = "nic_type"
1562

    
1563
hvPae :: String
1564
hvPae = "pae"
1565

    
1566
hvPassthrough :: String
1567
hvPassthrough = "pci_pass"
1568

    
1569
hvRebootBehavior :: String
1570
hvRebootBehavior = "reboot_behavior"
1571

    
1572
hvRootPath :: String
1573
hvRootPath = "root_path"
1574

    
1575
hvSecurityDomain :: String
1576
hvSecurityDomain = "security_domain"
1577

    
1578
hvSecurityModel :: String
1579
hvSecurityModel = "security_model"
1580

    
1581
hvSerialConsole :: String
1582
hvSerialConsole = "serial_console"
1583

    
1584
hvSerialSpeed :: String
1585
hvSerialSpeed = "serial_speed"
1586

    
1587
hvSoundhw :: String
1588
hvSoundhw = "soundhw"
1589

    
1590
hvUsbDevices :: String
1591
hvUsbDevices = "usb_devices"
1592

    
1593
hvUsbMouse :: String
1594
hvUsbMouse = "usb_mouse"
1595

    
1596
hvUseBootloader :: String
1597
hvUseBootloader = "use_bootloader"
1598

    
1599
hvUseLocaltime :: String
1600
hvUseLocaltime = "use_localtime"
1601

    
1602
hvVga :: String
1603
hvVga = "vga"
1604

    
1605
hvVhostNet :: String
1606
hvVhostNet = "vhost_net"
1607

    
1608
hvVifScript :: String
1609
hvVifScript = "vif_script"
1610

    
1611
hvVifType :: String
1612
hvVifType = "vif_type"
1613

    
1614
hvViridian :: String
1615
hvViridian = "viridian"
1616

    
1617
hvVncBindAddress :: String
1618
hvVncBindAddress = "vnc_bind_address"
1619

    
1620
hvVncPasswordFile :: String
1621
hvVncPasswordFile = "vnc_password_file"
1622

    
1623
hvVncTls :: String
1624
hvVncTls = "vnc_tls"
1625

    
1626
hvVncX509 :: String
1627
hvVncX509 = "vnc_x509_path"
1628

    
1629
hvVncX509Verify :: String
1630
hvVncX509Verify = "vnc_x509_verify"
1631

    
1632
hvVnetHdr :: String
1633
hvVnetHdr = "vnet_hdr"
1634

    
1635
hvXenCmd :: String
1636
hvXenCmd = "xen_cmd"
1637

    
1638
hvXenCpuid :: String
1639
hvXenCpuid = "cpuid"
1640

    
1641
hvsParameterTitles :: Map String String
1642
hvsParameterTitles =
1643
  Map.fromList
1644
  [(hvAcpi, "ACPI"),
1645
   (hvBootOrder, "Boot_order"),
1646
   (hvCdromImagePath, "CDROM_image_path"),
1647
   (hvCpuType, "cpu_type"),
1648
   (hvDiskType, "Disk_type"),
1649
   (hvInitrdPath, "Initrd_path"),
1650
   (hvKernelPath, "Kernel_path"),
1651
   (hvNicType, "NIC_type"),
1652
   (hvPae, "PAE"),
1653
   (hvPassthrough, "pci_pass"),
1654
   (hvVncBindAddress, "VNC_bind_address")]
1655

    
1656
hvsParameters :: FrozenSet String
1657
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1658

    
1659
hvsParameterTypes :: Map String VType
1660
hvsParameterTypes = Map.fromList
1661
  [ (hvAcpi,                            VTypeBool)
1662
  , (hvBlockdevPrefix,                  VTypeString)
1663
  , (hvBootloaderArgs,                  VTypeString)
1664
  , (hvBootloaderPath,                  VTypeString)
1665
  , (hvBootOrder,                       VTypeString)
1666
  , (hvCdromImagePath,                  VTypeString)
1667
  , (hvCpuCap,                          VTypeInt)
1668
  , (hvCpuCores,                        VTypeInt)
1669
  , (hvCpuMask,                         VTypeString)
1670
  , (hvCpuSockets,                      VTypeInt)
1671
  , (hvCpuThreads,                      VTypeInt)
1672
  , (hvCpuType,                         VTypeString)
1673
  , (hvCpuWeight,                       VTypeInt)
1674
  , (hvDeviceModel,                     VTypeString)
1675
  , (hvDiskCache,                       VTypeString)
1676
  , (hvDiskType,                        VTypeString)
1677
  , (hvInitrdPath,                      VTypeString)
1678
  , (hvInitScript,                      VTypeString)
1679
  , (hvKernelArgs,                      VTypeString)
1680
  , (hvKernelPath,                      VTypeString)
1681
  , (hvKeymap,                          VTypeString)
1682
  , (hvKvmCdrom2ImagePath,              VTypeString)
1683
  , (hvKvmCdromDiskType,                VTypeString)
1684
  , (hvKvmExtra,                        VTypeString)
1685
  , (hvKvmFlag,                         VTypeString)
1686
  , (hvKvmFloppyImagePath,              VTypeString)
1687
  , (hvKvmMachineVersion,               VTypeString)
1688
  , (hvKvmPath,                         VTypeString)
1689
  , (hvKvmSpiceAudioCompr,              VTypeBool)
1690
  , (hvKvmSpiceBind,                    VTypeString)
1691
  , (hvKvmSpiceIpVersion,               VTypeInt)
1692
  , (hvKvmSpiceJpegImgCompr,            VTypeString)
1693
  , (hvKvmSpiceLosslessImgCompr,        VTypeString)
1694
  , (hvKvmSpicePasswordFile,            VTypeString)
1695
  , (hvKvmSpiceStreamingVideoDetection, VTypeString)
1696
  , (hvKvmSpiceTlsCiphers,              VTypeString)
1697
  , (hvKvmSpiceUseTls,                  VTypeBool)
1698
  , (hvKvmSpiceUseVdagent,              VTypeBool)
1699
  , (hvKvmSpiceZlibGlzImgCompr,         VTypeString)
1700
  , (hvKvmUseChroot,                    VTypeBool)
1701
  , (hvMemPath,                         VTypeString)
1702
  , (hvMigrationBandwidth,              VTypeInt)
1703
  , (hvMigrationDowntime,               VTypeInt)
1704
  , (hvMigrationMode,                   VTypeString)
1705
  , (hvMigrationPort,                   VTypeInt)
1706
  , (hvNicType,                         VTypeString)
1707
  , (hvPae,                             VTypeBool)
1708
  , (hvPassthrough,                     VTypeString)
1709
  , (hvRebootBehavior,                  VTypeString)
1710
  , (hvRootPath,                        VTypeMaybeString)
1711
  , (hvSecurityDomain,                  VTypeString)
1712
  , (hvSecurityModel,                   VTypeString)
1713
  , (hvSerialConsole,                   VTypeBool)
1714
  , (hvSerialSpeed,                     VTypeInt)
1715
  , (hvSoundhw,                         VTypeString)
1716
  , (hvUsbDevices,                      VTypeString)
1717
  , (hvUsbMouse,                        VTypeString)
1718
  , (hvUseBootloader,                   VTypeBool)
1719
  , (hvUseLocaltime,                    VTypeBool)
1720
  , (hvVga,                             VTypeString)
1721
  , (hvVhostNet,                        VTypeBool)
1722
  , (hvVifScript,                       VTypeString)
1723
  , (hvVifType,                         VTypeString)
1724
  , (hvViridian,                        VTypeBool)
1725
  , (hvVncBindAddress,                  VTypeString)
1726
  , (hvVncPasswordFile,                 VTypeString)
1727
  , (hvVncTls,                          VTypeBool)
1728
  , (hvVncX509,                         VTypeString)
1729
  , (hvVncX509Verify,                   VTypeBool)
1730
  , (hvVnetHdr,                         VTypeBool)
1731
  , (hvXenCmd,                          VTypeString)
1732
  , (hvXenCpuid,                        VTypeString)
1733
  ]
1734

    
1735
-- * Migration statuses
1736

    
1737
hvMigrationActive :: String
1738
hvMigrationActive = "active"
1739

    
1740
hvMigrationCancelled :: String
1741
hvMigrationCancelled = "cancelled"
1742

    
1743
hvMigrationCompleted :: String
1744
hvMigrationCompleted = "completed"
1745

    
1746
hvMigrationFailed :: String
1747
hvMigrationFailed = "failed"
1748

    
1749
hvMigrationValidStatuses :: FrozenSet String
1750
hvMigrationValidStatuses =
1751
  ConstantUtils.mkSet [hvMigrationActive,
1752
                       hvMigrationCancelled,
1753
                       hvMigrationCompleted,
1754
                       hvMigrationFailed]
1755

    
1756
hvMigrationFailedStatuses :: FrozenSet String
1757
hvMigrationFailedStatuses =
1758
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1759

    
1760
-- | KVM-specific statuses
1761
--
1762
-- FIXME: this constant seems unnecessary
1763
hvKvmMigrationValidStatuses :: FrozenSet String
1764
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1765

    
1766
-- | Node info keys
1767
hvNodeinfoKeyVersion :: String
1768
hvNodeinfoKeyVersion = "hv_version"
1769

    
1770
-- * Hypervisor state
1771

    
1772
hvstCpuNode :: String
1773
hvstCpuNode = "cpu_node"
1774

    
1775
hvstCpuTotal :: String
1776
hvstCpuTotal = "cpu_total"
1777

    
1778
hvstMemoryHv :: String
1779
hvstMemoryHv = "mem_hv"
1780

    
1781
hvstMemoryNode :: String
1782
hvstMemoryNode = "mem_node"
1783

    
1784
hvstMemoryTotal :: String
1785
hvstMemoryTotal = "mem_total"
1786

    
1787
hvstsParameters :: FrozenSet String
1788
hvstsParameters =
1789
  ConstantUtils.mkSet [hvstCpuNode,
1790
                       hvstCpuTotal,
1791
                       hvstMemoryHv,
1792
                       hvstMemoryNode,
1793
                       hvstMemoryTotal]
1794

    
1795
hvstDefaults :: Map String Int
1796
hvstDefaults =
1797
  Map.fromList
1798
  [(hvstCpuNode, 1),
1799
   (hvstCpuTotal, 1),
1800
   (hvstMemoryHv, 0),
1801
   (hvstMemoryTotal, 0),
1802
   (hvstMemoryNode, 0)]
1803

    
1804
hvstsParameterTypes :: Map String VType
1805
hvstsParameterTypes =
1806
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1807
                (hvstMemoryNode, VTypeInt),
1808
                (hvstMemoryHv, VTypeInt),
1809
                (hvstCpuTotal, VTypeInt),
1810
                (hvstCpuNode, VTypeInt)]
1811

    
1812
-- * Disk state
1813

    
1814
dsDiskOverhead :: String
1815
dsDiskOverhead = "disk_overhead"
1816

    
1817
dsDiskReserved :: String
1818
dsDiskReserved = "disk_reserved"
1819

    
1820
dsDiskTotal :: String
1821
dsDiskTotal = "disk_total"
1822

    
1823
dsDefaults :: Map String Int
1824
dsDefaults =
1825
  Map.fromList
1826
  [(dsDiskTotal, 0),
1827
   (dsDiskReserved, 0),
1828
   (dsDiskOverhead, 0)]
1829

    
1830
dssParameterTypes :: Map String VType
1831
dssParameterTypes =
1832
  Map.fromList [(dsDiskTotal, VTypeInt),
1833
                (dsDiskReserved, VTypeInt),
1834
                (dsDiskOverhead, VTypeInt)]
1835

    
1836
dssParameters :: FrozenSet String
1837
dssParameters =
1838
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1839

    
1840
dsValidTypes :: FrozenSet String
1841
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1842

    
1843
-- Backend parameter names
1844

    
1845
beAlwaysFailover :: String
1846
beAlwaysFailover = "always_failover"
1847

    
1848
beAutoBalance :: String
1849
beAutoBalance = "auto_balance"
1850

    
1851
beMaxmem :: String
1852
beMaxmem = "maxmem"
1853

    
1854
-- | Deprecated and replaced by max and min mem
1855
beMemory :: String
1856
beMemory = "memory"
1857

    
1858
beMinmem :: String
1859
beMinmem = "minmem"
1860

    
1861
beSpindleUse :: String
1862
beSpindleUse = "spindle_use"
1863

    
1864
beVcpus :: String
1865
beVcpus = "vcpus"
1866

    
1867
besParameterTypes :: Map String VType
1868
besParameterTypes =
1869
  Map.fromList [(beAlwaysFailover, VTypeBool),
1870
                (beAutoBalance, VTypeBool),
1871
                (beMaxmem, VTypeSize),
1872
                (beMinmem, VTypeSize),
1873
                (beSpindleUse, VTypeInt),
1874
                (beVcpus, VTypeInt)]
1875

    
1876
besParameterTitles :: Map String String
1877
besParameterTitles =
1878
  Map.fromList [(beAutoBalance, "Auto_balance"),
1879
                (beMinmem, "ConfigMinMem"),
1880
                (beVcpus, "ConfigVCPUs"),
1881
                (beMaxmem, "ConfigMaxMem")]
1882

    
1883
besParameterCompat :: Map String VType
1884
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1885

    
1886
besParameters :: FrozenSet String
1887
besParameters =
1888
  ConstantUtils.mkSet [beAlwaysFailover,
1889
                       beAutoBalance,
1890
                       beMaxmem,
1891
                       beMinmem,
1892
                       beSpindleUse,
1893
                       beVcpus]
1894

    
1895
-- | Instance specs
1896
--
1897
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1898

    
1899
ispecMemSize :: String
1900
ispecMemSize = ConstantUtils.ispecMemSize
1901

    
1902
ispecCpuCount :: String
1903
ispecCpuCount = ConstantUtils.ispecCpuCount
1904

    
1905
ispecDiskCount :: String
1906
ispecDiskCount = ConstantUtils.ispecDiskCount
1907

    
1908
ispecDiskSize :: String
1909
ispecDiskSize = ConstantUtils.ispecDiskSize
1910

    
1911
ispecNicCount :: String
1912
ispecNicCount = ConstantUtils.ispecNicCount
1913

    
1914
ispecSpindleUse :: String
1915
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1916

    
1917
ispecsParameterTypes :: Map String VType
1918
ispecsParameterTypes =
1919
  Map.fromList
1920
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1921
   (ConstantUtils.ispecCpuCount, VTypeInt),
1922
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1923
   (ConstantUtils.ispecMemSize, VTypeInt),
1924
   (ConstantUtils.ispecNicCount, VTypeInt),
1925
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1926

    
1927
ispecsParameters :: FrozenSet String
1928
ispecsParameters =
1929
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1930
                       ConstantUtils.ispecDiskCount,
1931
                       ConstantUtils.ispecDiskSize,
1932
                       ConstantUtils.ispecMemSize,
1933
                       ConstantUtils.ispecNicCount,
1934
                       ConstantUtils.ispecSpindleUse]
1935

    
1936
ispecsMinmax :: String
1937
ispecsMinmax = ConstantUtils.ispecsMinmax
1938

    
1939
ispecsMax :: String
1940
ispecsMax = "max"
1941

    
1942
ispecsMin :: String
1943
ispecsMin = "min"
1944

    
1945
ispecsStd :: String
1946
ispecsStd = ConstantUtils.ispecsStd
1947

    
1948
ipolicyDts :: String
1949
ipolicyDts = ConstantUtils.ipolicyDts
1950

    
1951
ipolicyVcpuRatio :: String
1952
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1953

    
1954
ipolicySpindleRatio :: String
1955
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
1956

    
1957
ispecsMinmaxKeys :: FrozenSet String
1958
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1959

    
1960
ipolicyParameters :: FrozenSet String
1961
ipolicyParameters =
1962
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1963
                       ConstantUtils.ipolicySpindleRatio]
1964

    
1965
ipolicyAllKeys :: FrozenSet String
1966
ipolicyAllKeys =
1967
  ConstantUtils.union ipolicyParameters $
1968
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1969
                       ConstantUtils.ispecsMinmax,
1970
                       ispecsStd]
1971

    
1972
-- | Node parameter names
1973

    
1974
ndExclusiveStorage :: String
1975
ndExclusiveStorage = "exclusive_storage"
1976

    
1977
ndOobProgram :: String
1978
ndOobProgram = "oob_program"
1979

    
1980
ndSpindleCount :: String
1981
ndSpindleCount = "spindle_count"
1982

    
1983
ndOvs :: String
1984
ndOvs = "ovs"
1985

    
1986
ndOvsLink :: String
1987
ndOvsLink = "ovs_link"
1988

    
1989
ndOvsName :: String
1990
ndOvsName = "ovs_name"
1991

    
1992
ndSshPort :: String
1993
ndSshPort = "ssh_port"
1994

    
1995
ndsParameterTypes :: Map String VType
1996
ndsParameterTypes =
1997
  Map.fromList
1998
  [(ndExclusiveStorage, VTypeBool),
1999
   (ndOobProgram, VTypeString),
2000
   (ndOvs, VTypeBool),
2001
   (ndOvsLink, VTypeMaybeString),
2002
   (ndOvsName, VTypeMaybeString),
2003
   (ndSpindleCount, VTypeInt),
2004
   (ndSshPort, VTypeInt)]
2005

    
2006
ndsParameters :: FrozenSet String
2007
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
2008

    
2009
ndsParameterTitles :: Map String String
2010
ndsParameterTitles =
2011
  Map.fromList
2012
  [(ndExclusiveStorage, "ExclusiveStorage"),
2013
   (ndOobProgram, "OutOfBandProgram"),
2014
   (ndOvs, "OpenvSwitch"),
2015
   (ndOvsLink, "OpenvSwitchLink"),
2016
   (ndOvsName, "OpenvSwitchName"),
2017
   (ndSpindleCount, "SpindleCount")]
2018

    
2019
-- * Logical Disks parameters
2020

    
2021
ldpAccess :: String
2022
ldpAccess = "access"
2023

    
2024
ldpBarriers :: String
2025
ldpBarriers = "disabled-barriers"
2026

    
2027
ldpDefaultMetavg :: String
2028
ldpDefaultMetavg = "default-metavg"
2029

    
2030
ldpDelayTarget :: String
2031
ldpDelayTarget = "c-delay-target"
2032

    
2033
ldpDiskCustom :: String
2034
ldpDiskCustom = "disk-custom"
2035

    
2036
ldpDynamicResync :: String
2037
ldpDynamicResync = "dynamic-resync"
2038

    
2039
ldpFillTarget :: String
2040
ldpFillTarget = "c-fill-target"
2041

    
2042
ldpMaxRate :: String
2043
ldpMaxRate = "c-max-rate"
2044

    
2045
ldpMinRate :: String
2046
ldpMinRate = "c-min-rate"
2047

    
2048
ldpNetCustom :: String
2049
ldpNetCustom = "net-custom"
2050

    
2051
ldpNoMetaFlush :: String
2052
ldpNoMetaFlush = "disable-meta-flush"
2053

    
2054
ldpPlanAhead :: String
2055
ldpPlanAhead = "c-plan-ahead"
2056

    
2057
ldpPool :: String
2058
ldpPool = "pool"
2059

    
2060
ldpProtocol :: String
2061
ldpProtocol = "protocol"
2062

    
2063
ldpResyncRate :: String
2064
ldpResyncRate = "resync-rate"
2065

    
2066
ldpStripes :: String
2067
ldpStripes = "stripes"
2068

    
2069
diskLdTypes :: Map String VType
2070
diskLdTypes =
2071
  Map.fromList
2072
  [(ldpAccess, VTypeString),
2073
   (ldpResyncRate, VTypeInt),
2074
   (ldpStripes, VTypeInt),
2075
   (ldpBarriers, VTypeString),
2076
   (ldpNoMetaFlush, VTypeBool),
2077
   (ldpDefaultMetavg, VTypeString),
2078
   (ldpDiskCustom, VTypeString),
2079
   (ldpNetCustom, VTypeString),
2080
   (ldpProtocol, VTypeString),
2081
   (ldpDynamicResync, VTypeBool),
2082
   (ldpPlanAhead, VTypeInt),
2083
   (ldpFillTarget, VTypeInt),
2084
   (ldpDelayTarget, VTypeInt),
2085
   (ldpMaxRate, VTypeInt),
2086
   (ldpMinRate, VTypeInt),
2087
   (ldpPool, VTypeString)]
2088

    
2089
diskLdParameters :: FrozenSet String
2090
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2091

    
2092
-- * Disk template parameters
2093
--
2094
-- Disk template parameters can be set/changed by the user via
2095
-- gnt-cluster and gnt-group)
2096

    
2097
drbdResyncRate :: String
2098
drbdResyncRate = "resync-rate"
2099

    
2100
drbdDataStripes :: String
2101
drbdDataStripes = "data-stripes"
2102

    
2103
drbdMetaStripes :: String
2104
drbdMetaStripes = "meta-stripes"
2105

    
2106
drbdDiskBarriers :: String
2107
drbdDiskBarriers = "disk-barriers"
2108

    
2109
drbdMetaBarriers :: String
2110
drbdMetaBarriers = "meta-barriers"
2111

    
2112
drbdDefaultMetavg :: String
2113
drbdDefaultMetavg = "metavg"
2114

    
2115
drbdDiskCustom :: String
2116
drbdDiskCustom = "disk-custom"
2117

    
2118
drbdNetCustom :: String
2119
drbdNetCustom = "net-custom"
2120

    
2121
drbdProtocol :: String
2122
drbdProtocol = "protocol"
2123

    
2124
drbdDynamicResync :: String
2125
drbdDynamicResync = "dynamic-resync"
2126

    
2127
drbdPlanAhead :: String
2128
drbdPlanAhead = "c-plan-ahead"
2129

    
2130
drbdFillTarget :: String
2131
drbdFillTarget = "c-fill-target"
2132

    
2133
drbdDelayTarget :: String
2134
drbdDelayTarget = "c-delay-target"
2135

    
2136
drbdMaxRate :: String
2137
drbdMaxRate = "c-max-rate"
2138

    
2139
drbdMinRate :: String
2140
drbdMinRate = "c-min-rate"
2141

    
2142
lvStripes :: String
2143
lvStripes = "stripes"
2144

    
2145
rbdAccess :: String
2146
rbdAccess = "access"
2147

    
2148
rbdPool :: String
2149
rbdPool = "pool"
2150

    
2151
diskDtTypes :: Map String VType
2152
diskDtTypes =
2153
  Map.fromList [(drbdResyncRate, VTypeInt),
2154
                (drbdDataStripes, VTypeInt),
2155
                (drbdMetaStripes, VTypeInt),
2156
                (drbdDiskBarriers, VTypeString),
2157
                (drbdMetaBarriers, VTypeBool),
2158
                (drbdDefaultMetavg, VTypeString),
2159
                (drbdDiskCustom, VTypeString),
2160
                (drbdNetCustom, VTypeString),
2161
                (drbdProtocol, VTypeString),
2162
                (drbdDynamicResync, VTypeBool),
2163
                (drbdPlanAhead, VTypeInt),
2164
                (drbdFillTarget, VTypeInt),
2165
                (drbdDelayTarget, VTypeInt),
2166
                (drbdMaxRate, VTypeInt),
2167
                (drbdMinRate, VTypeInt),
2168
                (lvStripes, VTypeInt),
2169
                (rbdAccess, VTypeString),
2170
                (rbdPool, VTypeString)]
2171

    
2172
diskDtParameters :: FrozenSet String
2173
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2174

    
2175
-- * Dynamic disk parameters
2176

    
2177
ddpLocalIp :: String
2178
ddpLocalIp = "local-ip"
2179

    
2180
ddpRemoteIp :: String
2181
ddpRemoteIp = "remote-ip"
2182

    
2183
ddpPort :: String
2184
ddpPort = "port"
2185

    
2186
ddpLocalMinor :: String
2187
ddpLocalMinor = "local-minor"
2188

    
2189
ddpRemoteMinor :: String
2190
ddpRemoteMinor = "remote-minor"
2191

    
2192
-- * OOB supported commands
2193

    
2194
oobPowerOn :: String
2195
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2196

    
2197
oobPowerOff :: String
2198
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2199

    
2200
oobPowerCycle :: String
2201
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2202

    
2203
oobPowerStatus :: String
2204
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2205

    
2206
oobHealth :: String
2207
oobHealth = Types.oobCommandToRaw OobHealth
2208

    
2209
oobCommands :: FrozenSet String
2210
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2211

    
2212
oobPowerStatusPowered :: String
2213
oobPowerStatusPowered = "powered"
2214

    
2215
-- | 60 seconds
2216
oobTimeout :: Int
2217
oobTimeout = 60
2218

    
2219
-- | 2 seconds
2220
oobPowerDelay :: Double
2221
oobPowerDelay = 2.0
2222

    
2223
oobStatusCritical :: String
2224
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2225

    
2226
oobStatusOk :: String
2227
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2228

    
2229
oobStatusUnknown :: String
2230
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2231

    
2232
oobStatusWarning :: String
2233
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2234

    
2235
oobStatuses :: FrozenSet String
2236
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2237

    
2238
-- | Instance Parameters Profile
2239
ppDefault :: String
2240
ppDefault = "default"
2241

    
2242
-- * nic* constants are used inside the ganeti config
2243

    
2244
nicLink :: String
2245
nicLink = "link"
2246

    
2247
nicMode :: String
2248
nicMode = "mode"
2249

    
2250
nicVlan :: String
2251
nicVlan = "vlan"
2252

    
2253
nicsParameterTypes :: Map String VType
2254
nicsParameterTypes =
2255
  Map.fromList [(nicMode, vtypeString),
2256
                (nicLink, vtypeString),
2257
                (nicVlan, vtypeString)]
2258

    
2259
nicsParameters :: FrozenSet String
2260
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2261

    
2262
nicModeBridged :: String
2263
nicModeBridged = Types.nICModeToRaw NMBridged
2264

    
2265
nicModeRouted :: String
2266
nicModeRouted = Types.nICModeToRaw NMRouted
2267

    
2268
nicModeOvs :: String
2269
nicModeOvs = Types.nICModeToRaw NMOvs
2270

    
2271
nicIpPool :: String
2272
nicIpPool = Types.nICModeToRaw NMPool
2273

    
2274
nicValidModes :: FrozenSet String
2275
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2276

    
2277
releaseAction :: String
2278
releaseAction = "release"
2279

    
2280
reserveAction :: String
2281
reserveAction = "reserve"
2282

    
2283
-- * idisk* constants are used in opcodes, to create/change disks
2284

    
2285
idiskAdopt :: String
2286
idiskAdopt = "adopt"
2287

    
2288
idiskMetavg :: String
2289
idiskMetavg = "metavg"
2290

    
2291
idiskMode :: String
2292
idiskMode = "mode"
2293

    
2294
idiskName :: String
2295
idiskName = "name"
2296

    
2297
idiskSize :: String
2298
idiskSize = "size"
2299

    
2300
idiskSpindles :: String
2301
idiskSpindles = "spindles"
2302

    
2303
idiskVg :: String
2304
idiskVg = "vg"
2305

    
2306
idiskProvider :: String
2307
idiskProvider = "provider"
2308

    
2309
idiskParamsTypes :: Map String VType
2310
idiskParamsTypes =
2311
  Map.fromList [(idiskSize, VTypeSize),
2312
                (idiskSpindles, VTypeInt),
2313
                (idiskMode, VTypeString),
2314
                (idiskAdopt, VTypeString),
2315
                (idiskVg, VTypeString),
2316
                (idiskMetavg, VTypeString),
2317
                (idiskProvider, VTypeString),
2318
                (idiskName, VTypeMaybeString)]
2319

    
2320
idiskParams :: FrozenSet String
2321
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2322

    
2323
-- * inic* constants are used in opcodes, to create/change nics
2324

    
2325
inicBridge :: String
2326
inicBridge = "bridge"
2327

    
2328
inicIp :: String
2329
inicIp = "ip"
2330

    
2331
inicLink :: String
2332
inicLink = "link"
2333

    
2334
inicMac :: String
2335
inicMac = "mac"
2336

    
2337
inicMode :: String
2338
inicMode = "mode"
2339

    
2340
inicName :: String
2341
inicName = "name"
2342

    
2343
inicNetwork :: String
2344
inicNetwork = "network"
2345

    
2346
inicVlan :: String
2347
inicVlan = "vlan"
2348

    
2349
inicParamsTypes :: Map String VType
2350
inicParamsTypes =
2351
  Map.fromList [(inicBridge, VTypeMaybeString),
2352
                (inicIp, VTypeMaybeString),
2353
                (inicLink, VTypeString),
2354
                (inicMac, VTypeString),
2355
                (inicMode, VTypeString),
2356
                (inicName, VTypeMaybeString),
2357
                (inicNetwork, VTypeMaybeString),
2358
                (inicVlan, VTypeMaybeString)]
2359

    
2360
inicParams :: FrozenSet String
2361
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2362

    
2363
-- * Hypervisor constants
2364

    
2365
htXenPvm :: String
2366
htXenPvm = Types.hypervisorToRaw XenPvm
2367

    
2368
htFake :: String
2369
htFake = Types.hypervisorToRaw Fake
2370

    
2371
htXenHvm :: String
2372
htXenHvm = Types.hypervisorToRaw XenHvm
2373

    
2374
htKvm :: String
2375
htKvm = Types.hypervisorToRaw Kvm
2376

    
2377
htChroot :: String
2378
htChroot = Types.hypervisorToRaw Chroot
2379

    
2380
htLxc :: String
2381
htLxc = Types.hypervisorToRaw Lxc
2382

    
2383
hyperTypes :: FrozenSet String
2384
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2385

    
2386
htsReqPort :: FrozenSet String
2387
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2388

    
2389
vncBasePort :: Int
2390
vncBasePort = 5900
2391

    
2392
vncDefaultBindAddress :: String
2393
vncDefaultBindAddress = ip4AddressAny
2394

    
2395
-- * NIC types
2396

    
2397
htNicE1000 :: String
2398
htNicE1000 = "e1000"
2399

    
2400
htNicI82551 :: String
2401
htNicI82551 = "i82551"
2402

    
2403
htNicI8259er :: String
2404
htNicI8259er = "i82559er"
2405

    
2406
htNicI85557b :: String
2407
htNicI85557b = "i82557b"
2408

    
2409
htNicNe2kIsa :: String
2410
htNicNe2kIsa = "ne2k_isa"
2411

    
2412
htNicNe2kPci :: String
2413
htNicNe2kPci = "ne2k_pci"
2414

    
2415
htNicParavirtual :: String
2416
htNicParavirtual = "paravirtual"
2417

    
2418
htNicPcnet :: String
2419
htNicPcnet = "pcnet"
2420

    
2421
htNicRtl8139 :: String
2422
htNicRtl8139 = "rtl8139"
2423

    
2424
htHvmValidNicTypes :: FrozenSet String
2425
htHvmValidNicTypes =
2426
  ConstantUtils.mkSet [htNicE1000,
2427
                       htNicNe2kIsa,
2428
                       htNicNe2kPci,
2429
                       htNicParavirtual,
2430
                       htNicRtl8139]
2431

    
2432
htKvmValidNicTypes :: FrozenSet String
2433
htKvmValidNicTypes =
2434
  ConstantUtils.mkSet [htNicE1000,
2435
                       htNicI82551,
2436
                       htNicI8259er,
2437
                       htNicI85557b,
2438
                       htNicNe2kIsa,
2439
                       htNicNe2kPci,
2440
                       htNicParavirtual,
2441
                       htNicPcnet,
2442
                       htNicRtl8139]
2443

    
2444
-- * Vif types
2445

    
2446
-- | Default vif type in xen-hvm
2447
htHvmVifIoemu :: String
2448
htHvmVifIoemu = "ioemu"
2449

    
2450
htHvmVifVif :: String
2451
htHvmVifVif = "vif"
2452

    
2453
htHvmValidVifTypes :: FrozenSet String
2454
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2455

    
2456
-- * Disk types
2457

    
2458
htDiskIde :: String
2459
htDiskIde = "ide"
2460

    
2461
htDiskIoemu :: String
2462
htDiskIoemu = "ioemu"
2463

    
2464
htDiskMtd :: String
2465
htDiskMtd = "mtd"
2466

    
2467
htDiskParavirtual :: String
2468
htDiskParavirtual = "paravirtual"
2469

    
2470
htDiskPflash :: String
2471
htDiskPflash = "pflash"
2472

    
2473
htDiskScsi :: String
2474
htDiskScsi = "scsi"
2475

    
2476
htDiskSd :: String
2477
htDiskSd = "sd"
2478

    
2479
htHvmValidDiskTypes :: FrozenSet String
2480
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2481

    
2482
htKvmValidDiskTypes :: FrozenSet String
2483
htKvmValidDiskTypes =
2484
  ConstantUtils.mkSet [htDiskIde,
2485
                       htDiskMtd,
2486
                       htDiskParavirtual,
2487
                       htDiskPflash,
2488
                       htDiskScsi,
2489
                       htDiskSd]
2490

    
2491
htCacheDefault :: String
2492
htCacheDefault = "default"
2493

    
2494
htCacheNone :: String
2495
htCacheNone = "none"
2496

    
2497
htCacheWback :: String
2498
htCacheWback = "writeback"
2499

    
2500
htCacheWthrough :: String
2501
htCacheWthrough = "writethrough"
2502

    
2503
htValidCacheTypes :: FrozenSet String
2504
htValidCacheTypes =
2505
  ConstantUtils.mkSet [htCacheDefault,
2506
                       htCacheNone,
2507
                       htCacheWback,
2508
                       htCacheWthrough]
2509

    
2510
-- * Mouse types
2511

    
2512
htMouseMouse :: String
2513
htMouseMouse = "mouse"
2514

    
2515
htMouseTablet :: String
2516
htMouseTablet = "tablet"
2517

    
2518
htKvmValidMouseTypes :: FrozenSet String
2519
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2520

    
2521
-- * Boot order
2522

    
2523
htBoCdrom :: String
2524
htBoCdrom = "cdrom"
2525

    
2526
htBoDisk :: String
2527
htBoDisk = "disk"
2528

    
2529
htBoFloppy :: String
2530
htBoFloppy = "floppy"
2531

    
2532
htBoNetwork :: String
2533
htBoNetwork = "network"
2534

    
2535
htKvmValidBoTypes :: FrozenSet String
2536
htKvmValidBoTypes =
2537
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2538

    
2539
-- * SPICE lossless image compression options
2540

    
2541
htKvmSpiceLosslessImgComprAutoGlz :: String
2542
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2543

    
2544
htKvmSpiceLosslessImgComprAutoLz :: String
2545
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2546

    
2547
htKvmSpiceLosslessImgComprGlz :: String
2548
htKvmSpiceLosslessImgComprGlz = "glz"
2549

    
2550
htKvmSpiceLosslessImgComprLz :: String
2551
htKvmSpiceLosslessImgComprLz = "lz"
2552

    
2553
htKvmSpiceLosslessImgComprOff :: String
2554
htKvmSpiceLosslessImgComprOff = "off"
2555

    
2556
htKvmSpiceLosslessImgComprQuic :: String
2557
htKvmSpiceLosslessImgComprQuic = "quic"
2558

    
2559
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2560
htKvmSpiceValidLosslessImgComprOptions =
2561
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2562
                       htKvmSpiceLosslessImgComprAutoLz,
2563
                       htKvmSpiceLosslessImgComprGlz,
2564
                       htKvmSpiceLosslessImgComprLz,
2565
                       htKvmSpiceLosslessImgComprOff,
2566
                       htKvmSpiceLosslessImgComprQuic]
2567

    
2568
htKvmSpiceLossyImgComprAlways :: String
2569
htKvmSpiceLossyImgComprAlways = "always"
2570

    
2571
htKvmSpiceLossyImgComprAuto :: String
2572
htKvmSpiceLossyImgComprAuto = "auto"
2573

    
2574
htKvmSpiceLossyImgComprNever :: String
2575
htKvmSpiceLossyImgComprNever = "never"
2576

    
2577
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2578
htKvmSpiceValidLossyImgComprOptions =
2579
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2580
                       htKvmSpiceLossyImgComprAuto,
2581
                       htKvmSpiceLossyImgComprNever]
2582

    
2583
-- * SPICE video stream detection
2584

    
2585
htKvmSpiceVideoStreamDetectionAll :: String
2586
htKvmSpiceVideoStreamDetectionAll = "all"
2587

    
2588
htKvmSpiceVideoStreamDetectionFilter :: String
2589
htKvmSpiceVideoStreamDetectionFilter = "filter"
2590

    
2591
htKvmSpiceVideoStreamDetectionOff :: String
2592
htKvmSpiceVideoStreamDetectionOff = "off"
2593

    
2594
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2595
htKvmSpiceValidVideoStreamDetectionOptions =
2596
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2597
                       htKvmSpiceVideoStreamDetectionFilter,
2598
                       htKvmSpiceVideoStreamDetectionOff]
2599

    
2600
-- * Security models
2601

    
2602
htSmNone :: String
2603
htSmNone = "none"
2604

    
2605
htSmPool :: String
2606
htSmPool = "pool"
2607

    
2608
htSmUser :: String
2609
htSmUser = "user"
2610

    
2611
htKvmValidSmTypes :: FrozenSet String
2612
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2613

    
2614
-- * Kvm flag values
2615

    
2616
htKvmDisabled :: String
2617
htKvmDisabled = "disabled"
2618

    
2619
htKvmEnabled :: String
2620
htKvmEnabled = "enabled"
2621

    
2622
htKvmFlagValues :: FrozenSet String
2623
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2624

    
2625
-- * Migration type
2626

    
2627
htMigrationLive :: String
2628
htMigrationLive = Types.migrationModeToRaw MigrationLive
2629

    
2630
htMigrationNonlive :: String
2631
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2632

    
2633
htMigrationModes :: FrozenSet String
2634
htMigrationModes =
2635
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2636

    
2637
-- * Cluster verify steps
2638

    
2639
verifyNplusoneMem :: String
2640
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2641

    
2642
verifyOptionalChecks :: FrozenSet String
2643
verifyOptionalChecks =
2644
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2645

    
2646
-- * Cluster Verify error classes
2647

    
2648
cvTcluster :: String
2649
cvTcluster = "cluster"
2650

    
2651
cvTgroup :: String
2652
cvTgroup = "group"
2653

    
2654
cvTnode :: String
2655
cvTnode = "node"
2656

    
2657
cvTinstance :: String
2658
cvTinstance = "instance"
2659

    
2660
-- * Cluster Verify error codes and documentation
2661

    
2662
cvEclustercert :: (String, String, String)
2663
cvEclustercert =
2664
  ("cluster",
2665
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2666
   "Cluster certificate files verification failure")
2667

    
2668
cvEclustercfg :: (String, String, String)
2669
cvEclustercfg =
2670
  ("cluster",
2671
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2672
   "Cluster configuration verification failure")
2673

    
2674
cvEclusterdanglinginst :: (String, String, String)
2675
cvEclusterdanglinginst =
2676
  ("node",
2677
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2678
   "Some instances have a non-existing primary node")
2679

    
2680
cvEclusterdanglingnodes :: (String, String, String)
2681
cvEclusterdanglingnodes =
2682
  ("node",
2683
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2684
   "Some nodes belong to non-existing groups")
2685

    
2686
cvEclusterfilecheck :: (String, String, String)
2687
cvEclusterfilecheck =
2688
  ("cluster",
2689
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2690
   "Cluster configuration verification failure")
2691

    
2692
cvEgroupdifferentpvsize :: (String, String, String)
2693
cvEgroupdifferentpvsize =
2694
  ("group",
2695
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2696
   "PVs in the group have different sizes")
2697

    
2698
cvEinstancebadnode :: (String, String, String)
2699
cvEinstancebadnode =
2700
  ("instance",
2701
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2702
   "Instance marked as running lives on an offline node")
2703

    
2704
cvEinstancedown :: (String, String, String)
2705
cvEinstancedown =
2706
  ("instance",
2707
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2708
   "Instance not running on its primary node")
2709

    
2710
cvEinstancefaultydisk :: (String, String, String)
2711
cvEinstancefaultydisk =
2712
  ("instance",
2713
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2714
   "Impossible to retrieve status for a disk")
2715

    
2716
cvEinstancelayout :: (String, String, String)
2717
cvEinstancelayout =
2718
  ("instance",
2719
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2720
   "Instance has multiple secondary nodes")
2721

    
2722
cvEinstancemissingcfgparameter :: (String, String, String)
2723
cvEinstancemissingcfgparameter =
2724
  ("instance",
2725
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2726
   "A configuration parameter for an instance is missing")
2727

    
2728
cvEinstancemissingdisk :: (String, String, String)
2729
cvEinstancemissingdisk =
2730
  ("instance",
2731
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2732
   "Missing volume on an instance")
2733

    
2734
cvEinstancepolicy :: (String, String, String)
2735
cvEinstancepolicy =
2736
  ("instance",
2737
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2738
   "Instance does not meet policy")
2739

    
2740
cvEinstancesplitgroups :: (String, String, String)
2741
cvEinstancesplitgroups =
2742
  ("instance",
2743
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2744
   "Instance with primary and secondary nodes in different groups")
2745

    
2746
cvEinstanceunsuitablenode :: (String, String, String)
2747
cvEinstanceunsuitablenode =
2748
  ("instance",
2749
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2750
   "Instance running on nodes that are not suitable for it")
2751

    
2752
cvEinstancewrongnode :: (String, String, String)
2753
cvEinstancewrongnode =
2754
  ("instance",
2755
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2756
   "Instance running on the wrong node")
2757

    
2758
cvEnodedrbd :: (String, String, String)
2759
cvEnodedrbd =
2760
  ("node",
2761
   Types.cVErrorCodeToRaw CvENODEDRBD,
2762
   "Error parsing the DRBD status file")
2763

    
2764
cvEnodedrbdhelper :: (String, String, String)
2765
cvEnodedrbdhelper =
2766
  ("node",
2767
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2768
   "Error caused by the DRBD helper")
2769

    
2770
cvEnodedrbdversion :: (String, String, String)
2771
cvEnodedrbdversion =
2772
  ("node",
2773
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2774
   "DRBD version mismatch within a node group")
2775

    
2776
cvEnodefilecheck :: (String, String, String)
2777
cvEnodefilecheck =
2778
  ("node",
2779
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2780
   "Error retrieving the checksum of the node files")
2781

    
2782
cvEnodefilestoragepaths :: (String, String, String)
2783
cvEnodefilestoragepaths =
2784
  ("node",
2785
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2786
   "Detected bad file storage paths")
2787

    
2788
cvEnodefilestoragepathunusable :: (String, String, String)
2789
cvEnodefilestoragepathunusable =
2790
  ("node",
2791
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2792
   "File storage path unusable")
2793

    
2794
cvEnodehooks :: (String, String, String)
2795
cvEnodehooks =
2796
  ("node",
2797
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2798
   "Communication failure in hooks execution")
2799

    
2800
cvEnodehv :: (String, String, String)
2801
cvEnodehv =
2802
  ("node",
2803
   Types.cVErrorCodeToRaw CvENODEHV,
2804
   "Hypervisor parameters verification failure")
2805

    
2806
cvEnodelvm :: (String, String, String)
2807
cvEnodelvm =
2808
  ("node",
2809
   Types.cVErrorCodeToRaw CvENODELVM,
2810
   "LVM-related node error")
2811

    
2812
cvEnoden1 :: (String, String, String)
2813
cvEnoden1 =
2814
  ("node",
2815
   Types.cVErrorCodeToRaw CvENODEN1,
2816
   "Not enough memory to accommodate instance failovers")
2817

    
2818
cvEnodenet :: (String, String, String)
2819
cvEnodenet =
2820
  ("node",
2821
   Types.cVErrorCodeToRaw CvENODENET,
2822
   "Network-related node error")
2823

    
2824
cvEnodeoobpath :: (String, String, String)
2825
cvEnodeoobpath =
2826
  ("node",
2827
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2828
   "Invalid Out Of Band path")
2829

    
2830
cvEnodeorphaninstance :: (String, String, String)
2831
cvEnodeorphaninstance =
2832
  ("node",
2833
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2834
   "Unknown intance running on a node")
2835

    
2836
cvEnodeorphanlv :: (String, String, String)
2837
cvEnodeorphanlv =
2838
  ("node",
2839
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2840
   "Unknown LVM logical volume")
2841

    
2842
cvEnodeos :: (String, String, String)
2843
cvEnodeos =
2844
  ("node",
2845
   Types.cVErrorCodeToRaw CvENODEOS,
2846
   "OS-related node error")
2847

    
2848
cvEnoderpc :: (String, String, String)
2849
cvEnoderpc =
2850
  ("node",
2851
   Types.cVErrorCodeToRaw CvENODERPC,
2852
   "Error during connection to the primary node of an instance")
2853

    
2854
cvEnodesetup :: (String, String, String)
2855
cvEnodesetup =
2856
  ("node",
2857
   Types.cVErrorCodeToRaw CvENODESETUP,
2858
   "Node setup error")
2859

    
2860
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2861
cvEnodesharedfilestoragepathunusable =
2862
  ("node",
2863
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2864
   "Shared file storage path unusable")
2865

    
2866
cvEnodessh :: (String, String, String)
2867
cvEnodessh =
2868
  ("node",
2869
   Types.cVErrorCodeToRaw CvENODESSH,
2870
   "SSH-related node error")
2871

    
2872
cvEnodetime :: (String, String, String)
2873
cvEnodetime =
2874
  ("node",
2875
   Types.cVErrorCodeToRaw CvENODETIME,
2876
   "Node returned invalid time")
2877

    
2878
cvEnodeuserscripts :: (String, String, String)
2879
cvEnodeuserscripts =
2880
  ("node",
2881
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2882
   "User scripts not present or not executable")
2883

    
2884
cvEnodeversion :: (String, String, String)
2885
cvEnodeversion =
2886
  ("node",
2887
   Types.cVErrorCodeToRaw CvENODEVERSION,
2888
   "Protocol version mismatch or Ganeti version mismatch")
2889

    
2890
cvAllEcodes :: FrozenSet (String, String, String)
2891
cvAllEcodes =
2892
  ConstantUtils.mkSet
2893
  [cvEclustercert,
2894
   cvEclustercfg,
2895
   cvEclusterdanglinginst,
2896
   cvEclusterdanglingnodes,
2897
   cvEclusterfilecheck,
2898
   cvEgroupdifferentpvsize,
2899
   cvEinstancebadnode,
2900
   cvEinstancedown,
2901
   cvEinstancefaultydisk,
2902
   cvEinstancelayout,
2903
   cvEinstancemissingcfgparameter,
2904
   cvEinstancemissingdisk,
2905
   cvEinstancepolicy,
2906
   cvEinstancesplitgroups,
2907
   cvEinstanceunsuitablenode,
2908
   cvEinstancewrongnode,
2909
   cvEnodedrbd,
2910
   cvEnodedrbdhelper,
2911
   cvEnodedrbdversion,
2912
   cvEnodefilecheck,
2913
   cvEnodefilestoragepaths,
2914
   cvEnodefilestoragepathunusable,
2915
   cvEnodehooks,
2916
   cvEnodehv,
2917
   cvEnodelvm,
2918
   cvEnoden1,
2919
   cvEnodenet,
2920
   cvEnodeoobpath,
2921
   cvEnodeorphaninstance,
2922
   cvEnodeorphanlv,
2923
   cvEnodeos,
2924
   cvEnoderpc,
2925
   cvEnodesetup,
2926
   cvEnodesharedfilestoragepathunusable,
2927
   cvEnodessh,
2928
   cvEnodetime,
2929
   cvEnodeuserscripts,
2930
   cvEnodeversion]
2931

    
2932
cvAllEcodesStrings :: FrozenSet String
2933
cvAllEcodesStrings =
2934
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2935

    
2936
-- * Node verify constants
2937

    
2938
nvBridges :: String
2939
nvBridges = "bridges"
2940

    
2941
nvDrbdhelper :: String
2942
nvDrbdhelper = "drbd-helper"
2943

    
2944
nvDrbdversion :: String
2945
nvDrbdversion = "drbd-version"
2946

    
2947
nvDrbdlist :: String
2948
nvDrbdlist = "drbd-list"
2949

    
2950
nvExclusivepvs :: String
2951
nvExclusivepvs = "exclusive-pvs"
2952

    
2953
nvFilelist :: String
2954
nvFilelist = "filelist"
2955

    
2956
nvAcceptedStoragePaths :: String
2957
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2958

    
2959
nvFileStoragePath :: String
2960
nvFileStoragePath = "file-storage-path"
2961

    
2962
nvSharedFileStoragePath :: String
2963
nvSharedFileStoragePath = "shared-file-storage-path"
2964

    
2965
nvHvinfo :: String
2966
nvHvinfo = "hvinfo"
2967

    
2968
nvHvparams :: String
2969
nvHvparams = "hvparms"
2970

    
2971
nvHypervisor :: String
2972
nvHypervisor = "hypervisor"
2973

    
2974
nvInstancelist :: String
2975
nvInstancelist = "instancelist"
2976

    
2977
nvLvlist :: String
2978
nvLvlist = "lvlist"
2979

    
2980
nvMasterip :: String
2981
nvMasterip = "master-ip"
2982

    
2983
nvNodelist :: String
2984
nvNodelist = "nodelist"
2985

    
2986
nvNodenettest :: String
2987
nvNodenettest = "node-net-test"
2988

    
2989
nvNodesetup :: String
2990
nvNodesetup = "nodesetup"
2991

    
2992
nvOobPaths :: String
2993
nvOobPaths = "oob-paths"
2994

    
2995
nvOslist :: String
2996
nvOslist = "oslist"
2997

    
2998
nvPvlist :: String
2999
nvPvlist = "pvlist"
3000

    
3001
nvTime :: String
3002
nvTime = "time"
3003

    
3004
nvUserscripts :: String
3005
nvUserscripts = "user-scripts"
3006

    
3007
nvVersion :: String
3008
nvVersion = "version"
3009

    
3010
nvVglist :: String
3011
nvVglist = "vglist"
3012

    
3013
nvVmnodes :: String
3014
nvVmnodes = "vmnodes"
3015

    
3016
-- * Instance status
3017

    
3018
inststAdmindown :: String
3019
inststAdmindown = Types.instanceStatusToRaw StatusDown
3020

    
3021
inststAdminoffline :: String
3022
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3023

    
3024
inststErrordown :: String
3025
inststErrordown = Types.instanceStatusToRaw ErrorDown
3026

    
3027
inststErrorup :: String
3028
inststErrorup = Types.instanceStatusToRaw ErrorUp
3029

    
3030
inststNodedown :: String
3031
inststNodedown = Types.instanceStatusToRaw NodeDown
3032

    
3033
inststNodeoffline :: String
3034
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3035

    
3036
inststRunning :: String
3037
inststRunning = Types.instanceStatusToRaw Running
3038

    
3039
inststUserdown :: String
3040
inststUserdown = Types.instanceStatusToRaw UserDown
3041

    
3042
inststWrongnode :: String
3043
inststWrongnode = Types.instanceStatusToRaw WrongNode
3044

    
3045
inststAll :: FrozenSet String
3046
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3047

    
3048
-- * Admin states
3049

    
3050
adminstDown :: String
3051
adminstDown = Types.adminStateToRaw AdminDown
3052

    
3053
adminstOffline :: String
3054
adminstOffline = Types.adminStateToRaw AdminOffline
3055

    
3056
adminstUp :: String
3057
adminstUp = Types.adminStateToRaw AdminUp
3058

    
3059
adminstAll :: FrozenSet String
3060
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3061

    
3062
-- * Node roles
3063

    
3064
nrDrained :: String
3065
nrDrained = Types.nodeRoleToRaw NRDrained
3066

    
3067
nrMaster :: String
3068
nrMaster = Types.nodeRoleToRaw NRMaster
3069

    
3070
nrMcandidate :: String
3071
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3072

    
3073
nrOffline :: String
3074
nrOffline = Types.nodeRoleToRaw NROffline
3075

    
3076
nrRegular :: String
3077
nrRegular = Types.nodeRoleToRaw NRRegular
3078

    
3079
nrAll :: FrozenSet String
3080
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3081

    
3082
-- * SSL certificate check constants (in days)
3083

    
3084
sslCertExpirationError :: Int
3085
sslCertExpirationError = 7
3086

    
3087
sslCertExpirationWarn :: Int
3088
sslCertExpirationWarn = 30
3089

    
3090
-- * Allocator framework constants
3091

    
3092
iallocatorVersion :: Int
3093
iallocatorVersion = 2
3094

    
3095
iallocatorDirIn :: String
3096
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3097

    
3098
iallocatorDirOut :: String
3099
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3100

    
3101
validIallocatorDirections :: FrozenSet String
3102
validIallocatorDirections =
3103
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3104

    
3105
iallocatorModeAlloc :: String
3106
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3107

    
3108
iallocatorModeChgGroup :: String
3109
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3110

    
3111
iallocatorModeMultiAlloc :: String
3112
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3113

    
3114
iallocatorModeNodeEvac :: String
3115
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3116

    
3117
iallocatorModeReloc :: String
3118
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3119

    
3120
validIallocatorModes :: FrozenSet String
3121
validIallocatorModes =
3122
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3123

    
3124
iallocatorSearchPath :: [String]
3125
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3126

    
3127
defaultIallocatorShortcut :: String
3128
defaultIallocatorShortcut = "."
3129

    
3130
-- * Node evacuation
3131

    
3132
nodeEvacPri :: String
3133
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3134

    
3135
nodeEvacSec :: String
3136
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3137

    
3138
nodeEvacAll :: String
3139
nodeEvacAll = Types.evacModeToRaw ChangeAll
3140

    
3141
nodeEvacModes :: FrozenSet String
3142
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3143

    
3144
-- * Job queue
3145

    
3146
jobQueueVersion :: Int
3147
jobQueueVersion = 1
3148

    
3149
jobQueueSizeHardLimit :: Int
3150
jobQueueSizeHardLimit = 5000
3151

    
3152
jobQueueFilesPerms :: Int
3153
jobQueueFilesPerms = 0o640
3154

    
3155
-- * Unchanged job return
3156

    
3157
jobNotchanged :: String
3158
jobNotchanged = "nochange"
3159

    
3160
-- * Job status
3161

    
3162
jobStatusQueued :: String
3163
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3164

    
3165
jobStatusWaiting :: String
3166
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3167

    
3168
jobStatusCanceling :: String
3169
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3170

    
3171
jobStatusRunning :: String
3172
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3173

    
3174
jobStatusCanceled :: String
3175
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3176

    
3177
jobStatusSuccess :: String
3178
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3179

    
3180
jobStatusError :: String
3181
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3182

    
3183
jobsPending :: FrozenSet String
3184
jobsPending =
3185
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3186

    
3187
jobsFinalized :: FrozenSet String
3188
jobsFinalized =
3189
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3190

    
3191
jobStatusAll :: FrozenSet String
3192
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3193

    
3194
-- * OpCode status
3195

    
3196
-- ** Not yet finalized opcodes
3197

    
3198
opStatusCanceling :: String
3199
opStatusCanceling = "canceling"
3200

    
3201
opStatusQueued :: String
3202
opStatusQueued = "queued"
3203

    
3204
opStatusRunning :: String
3205
opStatusRunning = "running"
3206

    
3207
opStatusWaiting :: String
3208
opStatusWaiting = "waiting"
3209

    
3210
-- ** Finalized opcodes
3211

    
3212
opStatusCanceled :: String
3213
opStatusCanceled = "canceled"
3214

    
3215
opStatusError :: String
3216
opStatusError = "error"
3217

    
3218
opStatusSuccess :: String
3219
opStatusSuccess = "success"
3220

    
3221
opsFinalized :: FrozenSet String
3222
opsFinalized =
3223
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3224

    
3225
-- * OpCode priority
3226

    
3227
opPrioLowest :: Int
3228
opPrioLowest = 19
3229

    
3230
opPrioHighest :: Int
3231
opPrioHighest = -20
3232

    
3233
opPrioLow :: Int
3234
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3235

    
3236
opPrioNormal :: Int
3237
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3238

    
3239
opPrioHigh :: Int
3240
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3241

    
3242
opPrioSubmitValid :: FrozenSet Int
3243
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3244

    
3245
opPrioDefault :: Int
3246
opPrioDefault = opPrioNormal
3247

    
3248
-- * Lock recalculate mode
3249

    
3250
locksAppend :: String
3251
locksAppend = "append"
3252

    
3253
locksReplace :: String
3254
locksReplace = "replace"
3255

    
3256
-- * Lock timeout
3257
--
3258
-- The lock timeout (sum) before we transition into blocking acquire
3259
-- (this can still be reset by priority change).  Computed as max time
3260
-- (10 hours) before we should actually go into blocking acquire,
3261
-- given that we start from the default priority level.
3262

    
3263
lockAttemptsMaxwait :: Double
3264
lockAttemptsMaxwait = 15.0
3265

    
3266
lockAttemptsMinwait :: Double
3267
lockAttemptsMinwait = 1.0
3268

    
3269
lockAttemptsTimeout :: Int
3270
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3271

    
3272
-- * Execution log types
3273

    
3274
elogMessage :: String
3275
elogMessage = Types.eLogTypeToRaw ELogMessage
3276

    
3277
elogRemoteImport :: String
3278
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3279

    
3280
elogJqueueTest :: String
3281
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3282

    
3283
-- * /etc/hosts modification
3284

    
3285
etcHostsAdd :: String
3286
etcHostsAdd = "add"
3287

    
3288
etcHostsRemove :: String
3289
etcHostsRemove = "remove"
3290

    
3291
-- * Job queue test
3292

    
3293
jqtMsgprefix :: String
3294
jqtMsgprefix = "TESTMSG="
3295

    
3296
jqtExec :: String
3297
jqtExec = "exec"
3298

    
3299
jqtExpandnames :: String
3300
jqtExpandnames = "expandnames"
3301

    
3302
jqtLogmsg :: String
3303
jqtLogmsg = "logmsg"
3304

    
3305
jqtStartmsg :: String
3306
jqtStartmsg = "startmsg"
3307

    
3308
jqtAll :: FrozenSet String
3309
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3310

    
3311
-- * Query resources
3312

    
3313
qrCluster :: String
3314
qrCluster = "cluster"
3315

    
3316
qrExport :: String
3317
qrExport = "export"
3318

    
3319
qrExtstorage :: String
3320
qrExtstorage = "extstorage"
3321

    
3322
qrGroup :: String
3323
qrGroup = "group"
3324

    
3325
qrInstance :: String
3326
qrInstance = "instance"
3327

    
3328
qrJob :: String
3329
qrJob = "job"
3330

    
3331
qrLock :: String
3332
qrLock = "lock"
3333

    
3334
qrNetwork :: String
3335
qrNetwork = "network"
3336

    
3337
qrNode :: String
3338
qrNode = "node"
3339

    
3340
qrOs :: String
3341
qrOs = "os"
3342

    
3343
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3344
qrViaOp :: FrozenSet String
3345
qrViaOp =
3346
  ConstantUtils.mkSet [qrCluster,
3347
                       qrOs,
3348
                       qrExtstorage]
3349

    
3350
-- | List of resources which can be queried using Local UniX Interface
3351
qrViaLuxi :: FrozenSet String
3352
qrViaLuxi = ConstantUtils.mkSet [qrGroup,
3353
                                 qrExport,
3354
                                 qrInstance,
3355
                                 qrJob,
3356
                                 qrLock,
3357
                                 qrNetwork,
3358
                                 qrNode]
3359

    
3360
-- | List of resources which can be queried using RAPI
3361
qrViaRapi :: FrozenSet String
3362
qrViaRapi = qrViaLuxi
3363

    
3364
-- | List of resources which can be queried via RAPI including PUT requests
3365
qrViaRapiPut :: FrozenSet String
3366
qrViaRapiPut = ConstantUtils.mkSet [qrLock, qrJob]
3367

    
3368
-- * Query field types
3369

    
3370
qftBool :: String
3371
qftBool = "bool"
3372

    
3373
qftNumber :: String
3374
qftNumber = "number"
3375

    
3376
qftOther :: String
3377
qftOther = "other"
3378

    
3379
qftText :: String
3380
qftText = "text"
3381

    
3382
qftTimestamp :: String
3383
qftTimestamp = "timestamp"
3384

    
3385
qftUnit :: String
3386
qftUnit = "unit"
3387

    
3388
qftUnknown :: String
3389
qftUnknown = "unknown"
3390

    
3391
qftAll :: FrozenSet String
3392
qftAll =
3393
  ConstantUtils.mkSet [qftBool,
3394
                       qftNumber,
3395
                       qftOther,
3396
                       qftText,
3397
                       qftTimestamp,
3398
                       qftUnit,
3399
                       qftUnknown]
3400

    
3401
-- * Query result field status
3402
--
3403
-- Don't change or reuse values as they're used by clients.
3404
--
3405
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3406

    
3407
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3408
rsNodata :: Int
3409
rsNodata = 2
3410

    
3411
rsNormal :: Int
3412
rsNormal = 0
3413

    
3414
-- | Resource marked offline
3415
rsOffline :: Int
3416
rsOffline = 4
3417

    
3418
-- | Value unavailable/unsupported for item; if this field is
3419
-- supported but we cannot get the data for the moment, 'rsNodata' or
3420
-- 'rsOffline' should be used
3421
rsUnavail :: Int
3422
rsUnavail = 3
3423

    
3424
rsUnknown :: Int
3425
rsUnknown = 1
3426

    
3427
rsAll :: FrozenSet Int
3428
rsAll =
3429
  ConstantUtils.mkSet [rsNodata,
3430
                       rsNormal,
3431
                       rsOffline,
3432
                       rsUnavail,
3433
                       rsUnknown]
3434

    
3435
-- | Special field cases and their verbose/terse formatting
3436
rssDescription :: Map Int (String, String)
3437
rssDescription =
3438
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3439
                (rsNodata, ("(nodata)", "?")),
3440
                (rsOffline, ("(offline)", "*")),
3441
                (rsUnavail, ("(unavail)", "-"))]
3442

    
3443
-- * Max dynamic devices
3444

    
3445
maxDisks :: Int
3446
maxDisks = Types.maxDisks
3447

    
3448
maxNics :: Int
3449
maxNics = Types.maxNics
3450

    
3451
-- | SSCONF file prefix
3452
ssconfFileprefix :: String
3453
ssconfFileprefix = "ssconf_"
3454

    
3455
-- * SSCONF keys
3456

    
3457
ssClusterName :: String
3458
ssClusterName = "cluster_name"
3459

    
3460
ssClusterTags :: String
3461
ssClusterTags = "cluster_tags"
3462

    
3463
ssFileStorageDir :: String
3464
ssFileStorageDir = "file_storage_dir"
3465

    
3466
ssSharedFileStorageDir :: String
3467
ssSharedFileStorageDir = "shared_file_storage_dir"
3468

    
3469
ssMasterCandidates :: String
3470
ssMasterCandidates = "master_candidates"
3471

    
3472
ssMasterCandidatesIps :: String
3473
ssMasterCandidatesIps = "master_candidates_ips"
3474

    
3475
ssMasterIp :: String
3476
ssMasterIp = "master_ip"
3477

    
3478
ssMasterNetdev :: String
3479
ssMasterNetdev = "master_netdev"
3480

    
3481
ssMasterNetmask :: String
3482
ssMasterNetmask = "master_netmask"
3483

    
3484
ssMasterNode :: String
3485
ssMasterNode = "master_node"
3486

    
3487
ssNodeList :: String
3488
ssNodeList = "node_list"
3489

    
3490
ssNodePrimaryIps :: String
3491
ssNodePrimaryIps = "node_primary_ips"
3492

    
3493
ssNodeSecondaryIps :: String
3494
ssNodeSecondaryIps = "node_secondary_ips"
3495

    
3496
ssOfflineNodes :: String
3497
ssOfflineNodes = "offline_nodes"
3498

    
3499
ssOnlineNodes :: String
3500
ssOnlineNodes = "online_nodes"
3501

    
3502
ssPrimaryIpFamily :: String
3503
ssPrimaryIpFamily = "primary_ip_family"
3504

    
3505
ssInstanceList :: String
3506
ssInstanceList = "instance_list"
3507

    
3508
ssReleaseVersion :: String
3509
ssReleaseVersion = "release_version"
3510

    
3511
ssHypervisorList :: String
3512
ssHypervisorList = "hypervisor_list"
3513

    
3514
ssMaintainNodeHealth :: String
3515
ssMaintainNodeHealth = "maintain_node_health"
3516

    
3517
ssUidPool :: String
3518
ssUidPool = "uid_pool"
3519

    
3520
ssNodegroups :: String
3521
ssNodegroups = "nodegroups"
3522

    
3523
ssNetworks :: String
3524
ssNetworks = "networks"
3525

    
3526
-- | This is not a complete SSCONF key, but the prefix for the
3527
-- hypervisor keys
3528
ssHvparamsPref :: String
3529
ssHvparamsPref = "hvparams_"
3530

    
3531
-- * Hvparams keys
3532

    
3533
ssHvparamsXenChroot :: String
3534
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3535

    
3536
ssHvparamsXenFake :: String
3537
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3538

    
3539
ssHvparamsXenHvm :: String
3540
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3541

    
3542
ssHvparamsXenKvm :: String
3543
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3544

    
3545
ssHvparamsXenLxc :: String
3546
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3547

    
3548
ssHvparamsXenPvm :: String
3549
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3550

    
3551
validSsHvparamsKeys :: FrozenSet String
3552
validSsHvparamsKeys =
3553
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3554
                       ssHvparamsXenLxc,
3555
                       ssHvparamsXenFake,
3556
                       ssHvparamsXenHvm,
3557
                       ssHvparamsXenKvm,
3558
                       ssHvparamsXenPvm]
3559

    
3560
ssFilePerms :: Int
3561
ssFilePerms = 0o444
3562

    
3563
-- | Cluster wide default parameters
3564
defaultEnabledHypervisor :: String
3565
defaultEnabledHypervisor = htXenPvm
3566

    
3567
hvcDefaults :: Map Hypervisor (Map String PyValueEx)
3568
hvcDefaults =
3569
  Map.fromList
3570
  [ (XenPvm, Map.fromList
3571
             [ (hvUseBootloader,  PyValueEx False)
3572
             , (hvBootloaderPath, PyValueEx xenBootloader)
3573
             , (hvBootloaderArgs, PyValueEx "")
3574
             , (hvKernelPath,     PyValueEx xenKernel)
3575
             , (hvInitrdPath,     PyValueEx "")
3576
             , (hvRootPath,       PyValueEx "/dev/xvda1")
3577
             , (hvKernelArgs,     PyValueEx "ro")
3578
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3579
             , (hvMigrationMode,  PyValueEx htMigrationLive)
3580
             , (hvBlockdevPrefix, PyValueEx "sd")
3581
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3582
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3583
             , (hvCpuCap,         PyValueEx (0 :: Int))
3584
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3585
             , (hvVifScript,      PyValueEx "")
3586
             , (hvXenCmd,         PyValueEx xenCmdXm)
3587
             , (hvXenCpuid,       PyValueEx "")
3588
             , (hvSoundhw,        PyValueEx "")
3589
             ])
3590
  , (XenHvm, Map.fromList
3591
             [ (hvBootOrder,      PyValueEx "cd")
3592
             , (hvCdromImagePath, PyValueEx "")
3593
             , (hvNicType,        PyValueEx htNicRtl8139)
3594
             , (hvDiskType,       PyValueEx htDiskParavirtual)
3595
             , (hvVncBindAddress, PyValueEx ip4AddressAny)
3596
             , (hvAcpi,           PyValueEx True)
3597
             , (hvPae,            PyValueEx True)
3598
             , (hvKernelPath,     PyValueEx "/usr/lib/xen/boot/hvmloader")
3599
             , (hvDeviceModel,    PyValueEx "/usr/lib/xen/bin/qemu-dm")
3600
             , (hvMigrationPort,  PyValueEx (8002 :: Int))
3601
             , (hvMigrationMode,  PyValueEx htMigrationNonlive)
3602
             , (hvUseLocaltime,   PyValueEx False)
3603
             , (hvBlockdevPrefix, PyValueEx "hd")
3604
             , (hvPassthrough,    PyValueEx "")
3605
             , (hvRebootBehavior, PyValueEx instanceRebootAllowed)
3606
             , (hvCpuMask,        PyValueEx cpuPinningAll)
3607
             , (hvCpuCap,         PyValueEx (0 :: Int))
3608
             , (hvCpuWeight,      PyValueEx (256 :: Int))
3609
             , (hvVifType,        PyValueEx htHvmVifIoemu)
3610
             , (hvVifScript,      PyValueEx "")
3611
             , (hvViridian,       PyValueEx False)
3612
             , (hvXenCmd,         PyValueEx xenCmdXm)
3613
             , (hvXenCpuid,       PyValueEx "")
3614
             , (hvSoundhw,        PyValueEx "")
3615
             ])
3616
  , (Kvm, Map.fromList
3617
          [ (hvKvmPath,                         PyValueEx kvmPath)
3618
          , (hvKernelPath,                      PyValueEx kvmKernel)
3619
          , (hvInitrdPath,                      PyValueEx "")
3620
          , (hvKernelArgs,                      PyValueEx "ro")
3621
          , (hvRootPath,                        PyValueEx "/dev/vda1")
3622
          , (hvAcpi,                            PyValueEx True)
3623
          , (hvSerialConsole,                   PyValueEx True)
3624
          , (hvSerialSpeed,                     PyValueEx (38400 :: Int))
3625
          , (hvVncBindAddress,                  PyValueEx "")
3626
          , (hvVncTls,                          PyValueEx False)
3627
          , (hvVncX509,                         PyValueEx "")
3628
          , (hvVncX509Verify,                   PyValueEx False)
3629
          , (hvVncPasswordFile,                 PyValueEx "")
3630
          , (hvKvmSpiceBind,                    PyValueEx "")
3631
          , (hvKvmSpiceIpVersion,           PyValueEx ifaceNoIpVersionSpecified)
3632
          , (hvKvmSpicePasswordFile,            PyValueEx "")
3633
          , (hvKvmSpiceLosslessImgCompr,        PyValueEx "")
3634
          , (hvKvmSpiceJpegImgCompr,            PyValueEx "")
3635
          , (hvKvmSpiceZlibGlzImgCompr,         PyValueEx "")
3636
          , (hvKvmSpiceStreamingVideoDetection, PyValueEx "")
3637
          , (hvKvmSpiceAudioCompr,              PyValueEx True)
3638
          , (hvKvmSpiceUseTls,                  PyValueEx False)
3639
          , (hvKvmSpiceTlsCiphers,              PyValueEx opensslCiphers)
3640
          , (hvKvmSpiceUseVdagent,              PyValueEx True)
3641
          , (hvKvmFloppyImagePath,              PyValueEx "")
3642
          , (hvCdromImagePath,                  PyValueEx "")
3643
          , (hvKvmCdrom2ImagePath,              PyValueEx "")
3644
          , (hvBootOrder,                       PyValueEx htBoDisk)
3645
          , (hvNicType,                         PyValueEx htNicParavirtual)
3646
          , (hvDiskType,                        PyValueEx htDiskParavirtual)
3647
          , (hvKvmCdromDiskType,                PyValueEx "")
3648
          , (hvUsbMouse,                        PyValueEx "")
3649
          , (hvKeymap,                          PyValueEx "")
3650
          , (hvMigrationPort,                   PyValueEx (8102 :: Int))
3651
          , (hvMigrationBandwidth,              PyValueEx (32 :: Int))
3652
          , (hvMigrationDowntime,               PyValueEx (30 :: Int))
3653
          , (hvMigrationMode,                   PyValueEx htMigrationLive)
3654
          , (hvUseLocaltime,                    PyValueEx False)
3655
          , (hvDiskCache,                       PyValueEx htCacheDefault)
3656
          , (hvSecurityModel,                   PyValueEx htSmNone)
3657
          , (hvSecurityDomain,                  PyValueEx "")
3658
          , (hvKvmFlag,                         PyValueEx "")
3659
          , (hvVhostNet,                        PyValueEx False)
3660
          , (hvKvmUseChroot,                    PyValueEx False)
3661
          , (hvMemPath,                         PyValueEx "")
3662
          , (hvRebootBehavior,                  PyValueEx instanceRebootAllowed)
3663
          , (hvCpuMask,                         PyValueEx cpuPinningAll)
3664
          , (hvCpuType,                         PyValueEx "")
3665
          , (hvCpuCores,                        PyValueEx (0 :: Int))
3666
          , (hvCpuThreads,                      PyValueEx (0 :: Int))
3667
          , (hvCpuSockets,                      PyValueEx (0 :: Int))
3668
          , (hvSoundhw,                         PyValueEx "")
3669
          , (hvUsbDevices,                      PyValueEx "")
3670
          , (hvVga,                             PyValueEx "")
3671
          , (hvKvmExtra,                        PyValueEx "")
3672
          , (hvKvmMachineVersion,               PyValueEx "")
3673
          , (hvVnetHdr,                         PyValueEx True)])
3674
  , (Fake, Map.fromList [(hvMigrationMode, PyValueEx htMigrationLive)])
3675
  , (Chroot, Map.fromList [(hvInitScript, PyValueEx "/ganeti-chroot")])
3676
  , (Lxc, Map.fromList [(hvCpuMask, PyValueEx "")])
3677
  ]
3678

    
3679
hvcGlobals :: FrozenSet String
3680
hvcGlobals =
3681
  ConstantUtils.mkSet [hvMigrationBandwidth,
3682
                       hvMigrationMode,
3683
                       hvMigrationPort,
3684
                       hvXenCmd]
3685

    
3686
becDefaults :: Map String PyValueEx
3687
becDefaults =
3688
  Map.fromList
3689
  [ (beMinmem, PyValueEx (128 :: Int))
3690
  , (beMaxmem, PyValueEx (128 :: Int))
3691
  , (beVcpus, PyValueEx (1 :: Int))
3692
  , (beAutoBalance, PyValueEx True)
3693
  , (beAlwaysFailover, PyValueEx False)
3694
  , (beSpindleUse, PyValueEx (1 :: Int))
3695
  ]
3696

    
3697
ndcDefaults :: Map String PyValueEx
3698
ndcDefaults =
3699
  Map.fromList
3700
  [ (ndOobProgram,       PyValueEx "")
3701
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3702
  , (ndExclusiveStorage, PyValueEx False)
3703
  , (ndOvs,              PyValueEx False)
3704
  , (ndOvsName,          PyValueEx defaultOvs)
3705
  , (ndOvsLink,          PyValueEx "")
3706
  , (ndSshPort,          PyValueEx (22 :: Int))
3707
  ]
3708

    
3709
ndcGlobals :: FrozenSet String
3710
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3711

    
3712
-- | Default delay target measured in sectors
3713
defaultDelayTarget :: Int
3714
defaultDelayTarget = 1
3715

    
3716
defaultDiskCustom :: String
3717
defaultDiskCustom = ""
3718

    
3719
defaultDiskResync :: Bool
3720
defaultDiskResync = False
3721

    
3722
-- | Default fill target measured in sectors
3723
defaultFillTarget :: Int
3724
defaultFillTarget = 0
3725

    
3726
-- | Default mininum rate measured in KiB/s
3727
defaultMinRate :: Int
3728
defaultMinRate = 4 * 1024
3729

    
3730
defaultNetCustom :: String
3731
defaultNetCustom = ""
3732

    
3733
-- | Default plan ahead measured in sectors
3734
--
3735
-- The default values for the DRBD dynamic resync speed algorithm are
3736
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3737
-- (that we don't need to set to 0, because we have a separate option
3738
-- to enable it) and for c-max-rate, that we cap to the default value
3739
-- for the static resync rate.
3740
defaultPlanAhead :: Int
3741
defaultPlanAhead = 20
3742

    
3743
defaultRbdPool :: String
3744
defaultRbdPool = "rbd"
3745

    
3746
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3747
diskLdDefaults =
3748
  Map.fromList
3749
  [ (DTBlock, Map.empty)
3750
  , (DTDrbd8, Map.fromList
3751
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3752
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3753
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3754
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3755
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3756
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3757
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3758
              , (ldpMinRate,       PyValueEx defaultMinRate)
3759
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3760
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3761
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3762
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3763
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3764
              ])
3765
  , (DTExt, Map.empty)
3766
  , (DTFile, Map.empty)
3767
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3768
  , (DTRbd, Map.fromList
3769
            [ (ldpPool, PyValueEx defaultRbdPool)
3770
            , (ldpAccess, PyValueEx diskKernelspace)
3771
            ])
3772
  , (DTSharedFile, Map.empty)
3773
  , (DTGluster, Map.empty)
3774
  ]
3775

    
3776
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3777
diskDtDefaults =
3778
  Map.fromList
3779
  [ (DTBlock,      Map.empty)
3780
  , (DTDiskless,   Map.empty)
3781
  , (DTDrbd8,      Map.fromList
3782
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3783
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3784
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3785
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3786
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3787
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3788
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3789
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3790
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3791
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3792
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3793
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3794
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3795
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3796
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3797
                   ])
3798
  , (DTExt,        Map.empty)
3799
  , (DTFile,       Map.empty)
3800
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3801
  , (DTRbd,        Map.fromList
3802
                   [ (rbdPool, PyValueEx defaultRbdPool)
3803
                   , (rbdAccess, PyValueEx diskKernelspace)
3804
                   ])
3805
  , (DTSharedFile, Map.empty)
3806
  , (DTGluster, Map.empty)
3807
  ]
3808

    
3809
niccDefaults :: Map String PyValueEx
3810
niccDefaults =
3811
  Map.fromList
3812
  [ (nicMode, PyValueEx nicModeBridged)
3813
  , (nicLink, PyValueEx defaultBridge)
3814
  , (nicVlan, PyValueEx "")
3815
  ]
3816

    
3817
-- | All of the following values are quite arbitrary - there are no
3818
-- "good" defaults, these must be customised per-site
3819
ispecsMinmaxDefaults :: Map String (Map String Int)
3820
ispecsMinmaxDefaults =
3821
  Map.fromList
3822
  [(ispecsMin,
3823
    Map.fromList
3824
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3825
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3826
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3827
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3828
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3829
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3830
   (ispecsMax,
3831
    Map.fromList
3832
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3833
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3834
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3835
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3836
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3837
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3838

    
3839
ipolicyDefaults :: Map String PyValueEx
3840
ipolicyDefaults =
3841
  Map.fromList
3842
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3843
  , (ispecsStd,           PyValueEx (Map.fromList
3844
                                     [ (ispecMemSize,    128)
3845
                                     , (ispecCpuCount,   1)
3846
                                     , (ispecDiskCount,  1)
3847
                                     , (ispecDiskSize,   1024)
3848
                                     , (ispecNicCount,   1)
3849
                                     , (ispecSpindleUse, 1)
3850
                                     ] :: Map String Int))
3851
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3852
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3853
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3854
  ]
3855

    
3856
masterPoolSizeDefault :: Int
3857
masterPoolSizeDefault = 10
3858

    
3859
-- * Exclusive storage
3860

    
3861
-- | Error margin used to compare physical disks
3862
partMargin :: Double
3863
partMargin = 0.01
3864

    
3865
-- | Space reserved when creating instance disks
3866
partReserved :: Double
3867
partReserved = 0.02
3868

    
3869
-- * Luxid job scheduling
3870

    
3871
-- | Time intervall in seconds for polling updates on the job queue. This
3872
-- intervall is only relevant if the number of running jobs reaches the maximal
3873
-- allowed number, as otherwise new jobs will be started immediately anyway.
3874
luxidJobqueuePollInterval :: Int
3875
luxidJobqueuePollInterval = 3
3876

    
3877
-- | Maximal number of jobs to be running at the same time. Once this number is
3878
-- reached, new jobs will just be queued and only started, once some of the
3879
-- other jobs have finished.
3880
luxidMaximalRunningJobs :: Int
3881
luxidMaximalRunningJobs = 20
3882

    
3883
-- * Confd
3884

    
3885
confdProtocolVersion :: Int
3886
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3887

    
3888
-- Confd request type
3889

    
3890
confdReqPing :: Int
3891
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3892

    
3893
confdReqNodeRoleByname :: Int
3894
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3895

    
3896
confdReqNodePipByInstanceIp :: Int
3897
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3898

    
3899
confdReqClusterMaster :: Int
3900
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3901

    
3902
confdReqNodePipList :: Int
3903
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3904

    
3905
confdReqMcPipList :: Int
3906
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3907

    
3908
confdReqInstancesIpsList :: Int
3909
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3910

    
3911
confdReqNodeDrbd :: Int
3912
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3913

    
3914
confdReqNodeInstances :: Int
3915
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3916

    
3917
confdReqs :: FrozenSet Int
3918
confdReqs =
3919
  ConstantUtils.mkSet .
3920
  map Types.confdRequestTypeToRaw $
3921
  [minBound..] \\ [ReqNodeInstances]
3922

    
3923
-- * Confd request type
3924

    
3925
confdReqfieldName :: Int
3926
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3927

    
3928
confdReqfieldIp :: Int
3929
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3930

    
3931
confdReqfieldMnodePip :: Int
3932
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3933

    
3934
-- * Confd repl status
3935

    
3936
confdReplStatusOk :: Int
3937
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3938

    
3939
confdReplStatusError :: Int
3940
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3941

    
3942
confdReplStatusNotimplemented :: Int
3943
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3944

    
3945
confdReplStatuses :: FrozenSet Int
3946
confdReplStatuses =
3947
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3948

    
3949
-- * Confd node role
3950

    
3951
confdNodeRoleMaster :: Int
3952
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3953

    
3954
confdNodeRoleCandidate :: Int
3955
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3956

    
3957
confdNodeRoleOffline :: Int
3958
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3959

    
3960
confdNodeRoleDrained :: Int
3961
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3962

    
3963
confdNodeRoleRegular :: Int
3964
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3965

    
3966
-- * A few common errors for confd
3967

    
3968
confdErrorUnknownEntry :: Int
3969
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3970

    
3971
confdErrorInternal :: Int
3972
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3973

    
3974
confdErrorArgument :: Int
3975
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3976

    
3977
-- * Confd request query fields
3978

    
3979
confdReqqLink :: String
3980
confdReqqLink = ConstantUtils.confdReqqLink
3981

    
3982
confdReqqIp :: String
3983
confdReqqIp = ConstantUtils.confdReqqIp
3984

    
3985
confdReqqIplist :: String
3986
confdReqqIplist = ConstantUtils.confdReqqIplist
3987

    
3988
confdReqqFields :: String
3989
confdReqqFields = ConstantUtils.confdReqqFields
3990

    
3991
-- | Each request is "salted" by the current timestamp.
3992
--
3993
-- This constant decides how many seconds of skew to accept.
3994
--
3995
-- TODO: make this a default and allow the value to be more
3996
-- configurable
3997
confdMaxClockSkew :: Int
3998
confdMaxClockSkew = 2 * nodeMaxClockSkew
3999

    
4000
-- | When we haven't reloaded the config for more than this amount of
4001
-- seconds, we force a test to see if inotify is betraying us. Using a
4002
-- prime number to ensure we get less chance of 'same wakeup' with
4003
-- other processes.
4004
confdConfigReloadTimeout :: Int
4005
confdConfigReloadTimeout = 17
4006

    
4007
-- | If we receive more than one update in this amount of
4008
-- microseconds, we move to polling every RATELIMIT seconds, rather
4009
-- than relying on inotify, to be able to serve more requests.
4010
confdConfigReloadRatelimit :: Int
4011
confdConfigReloadRatelimit = 250000
4012

    
4013
-- | Magic number prepended to all confd queries.
4014
--
4015
-- This allows us to distinguish different types of confd protocols
4016
-- and handle them. For example by changing this we can move the whole
4017
-- payload to be compressed, or move away from json.
4018
confdMagicFourcc :: String
4019
confdMagicFourcc = "plj0"
4020

    
4021
-- | By default a confd request is sent to the minimum between this
4022
-- number and all MCs. 6 was chosen because even in the case of a
4023
-- disastrous 50% response rate, we should have enough answers to be
4024
-- able to compare more than one.
4025
confdDefaultReqCoverage :: Int
4026
confdDefaultReqCoverage = 6
4027

    
4028
-- | Timeout in seconds to expire pending query request in the confd
4029
-- client library. We don't actually expect any answer more than 10
4030
-- seconds after we sent a request.
4031
confdClientExpireTimeout :: Int
4032
confdClientExpireTimeout = 10
4033

    
4034
-- | Maximum UDP datagram size.
4035
--
4036
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4037
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4038
--   (assuming we can't use jumbo frames)
4039
-- We just set this to 60K, which should be enough
4040
maxUdpDataSize :: Int
4041
maxUdpDataSize = 61440
4042

    
4043
-- * User-id pool minimum/maximum acceptable user-ids
4044

    
4045
uidpoolUidMin :: Int
4046
uidpoolUidMin = 0
4047

    
4048
-- | Assuming 32 bit user-ids
4049
uidpoolUidMax :: Integer
4050
uidpoolUidMax = 2 ^ 32 - 1
4051

    
4052
-- | Name or path of the pgrep command
4053
pgrep :: String
4054
pgrep = "pgrep"
4055

    
4056
-- | Name of the node group that gets created at cluster init or
4057
-- upgrade
4058
initialNodeGroupName :: String
4059
initialNodeGroupName = "default"
4060

    
4061
-- * Possible values for NodeGroup.alloc_policy
4062

    
4063
allocPolicyLastResort :: String
4064
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4065

    
4066
allocPolicyPreferred :: String
4067
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4068

    
4069
allocPolicyUnallocable :: String
4070
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4071

    
4072
validAllocPolicies :: [String]
4073
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4074

    
4075
-- | Temporary external/shared storage parameters
4076
blockdevDriverManual :: String
4077
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4078

    
4079
-- | 'qemu-img' path, required for 'ovfconverter'
4080
qemuimgPath :: String
4081
qemuimgPath = AutoConf.qemuimgPath
4082

    
4083
-- | Whether htools was enabled at compilation time
4084
--
4085
-- FIXME: this should be moved next to the other enable constants,
4086
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4087
htools :: Bool
4088
htools = AutoConf.htools
4089

    
4090
-- | The hail iallocator
4091
iallocHail :: String
4092
iallocHail = "hail"
4093

    
4094
-- * Fake opcodes for functions that have hooks attached to them via
4095
-- backend.RunLocalHooks
4096

    
4097
fakeOpMasterTurndown :: String
4098
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4099

    
4100
fakeOpMasterTurnup :: String
4101
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4102

    
4103
-- * SSH key types
4104

    
4105
sshkDsa :: String
4106
sshkDsa = "dsa"
4107

    
4108
sshkRsa :: String
4109
sshkRsa = "rsa"
4110

    
4111
sshkAll :: FrozenSet String
4112
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4113

    
4114
-- * SSH authorized key types
4115

    
4116
sshakDss :: String
4117
sshakDss = "ssh-dss"
4118

    
4119
sshakRsa :: String
4120
sshakRsa = "ssh-rsa"
4121

    
4122
sshakAll :: FrozenSet String
4123
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4124

    
4125
-- * SSH setup
4126

    
4127
sshsClusterName :: String
4128
sshsClusterName = "cluster_name"
4129

    
4130
sshsSshHostKey :: String
4131
sshsSshHostKey = "ssh_host_key"
4132

    
4133
sshsSshRootKey :: String
4134
sshsSshRootKey = "ssh_root_key"
4135

    
4136
sshsNodeDaemonCertificate :: String
4137
sshsNodeDaemonCertificate = "node_daemon_certificate"
4138

    
4139
-- * Key files for SSH daemon
4140

    
4141
sshHostDsaPriv :: String
4142
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4143

    
4144
sshHostDsaPub :: String
4145
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4146

    
4147
sshHostRsaPriv :: String
4148
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4149

    
4150
sshHostRsaPub :: String
4151
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4152

    
4153
sshDaemonKeyfiles :: Map String (String, String)
4154
sshDaemonKeyfiles =
4155
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4156
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4157
               ]
4158

    
4159
-- * Node daemon setup
4160

    
4161
ndsClusterName :: String
4162
ndsClusterName = "cluster_name"
4163

    
4164
ndsNodeDaemonCertificate :: String
4165
ndsNodeDaemonCertificate = "node_daemon_certificate"
4166

    
4167
ndsSsconf :: String
4168
ndsSsconf = "ssconf"
4169

    
4170
ndsStartNodeDaemon :: String
4171
ndsStartNodeDaemon = "start_node_daemon"
4172

    
4173
-- * The source reasons for the execution of an OpCode
4174

    
4175
opcodeReasonSrcClient :: String
4176
opcodeReasonSrcClient = "gnt:client"
4177

    
4178
opcodeReasonSrcNoded :: String
4179
opcodeReasonSrcNoded = "gnt:daemon:noded"
4180

    
4181
opcodeReasonSrcOpcode :: String
4182
opcodeReasonSrcOpcode = "gnt:opcode"
4183

    
4184
opcodeReasonSrcRlib2 :: String
4185
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4186

    
4187
opcodeReasonSrcUser :: String
4188
opcodeReasonSrcUser = "gnt:user"
4189

    
4190
opcodeReasonSources :: FrozenSet String
4191
opcodeReasonSources =
4192
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4193
                       opcodeReasonSrcNoded,
4194
                       opcodeReasonSrcOpcode,
4195
                       opcodeReasonSrcRlib2,
4196
                       opcodeReasonSrcUser]
4197

    
4198
-- | Path generating random UUID
4199
randomUuidFile :: String
4200
randomUuidFile = ConstantUtils.randomUuidFile
4201

    
4202
-- * Auto-repair tag prefixes
4203

    
4204
autoRepairTagPrefix :: String
4205
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4206

    
4207
autoRepairTagEnabled :: String
4208
autoRepairTagEnabled = autoRepairTagPrefix
4209

    
4210
autoRepairTagPending :: String
4211
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4212

    
4213
autoRepairTagResult :: String
4214
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4215

    
4216
autoRepairTagSuspended :: String
4217
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4218

    
4219
-- * Auto-repair levels
4220

    
4221
autoRepairFailover :: String
4222
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4223

    
4224
autoRepairFixStorage :: String
4225
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4226

    
4227
autoRepairMigrate :: String
4228
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4229

    
4230
autoRepairReinstall :: String
4231
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4232

    
4233
autoRepairAllTypes :: FrozenSet String
4234
autoRepairAllTypes =
4235
  ConstantUtils.mkSet [autoRepairFailover,
4236
                       autoRepairFixStorage,
4237
                       autoRepairMigrate,
4238
                       autoRepairReinstall]
4239

    
4240
-- * Auto-repair results
4241

    
4242
autoRepairEnoperm :: String
4243
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4244

    
4245
autoRepairFailure :: String
4246
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4247

    
4248
autoRepairSuccess :: String
4249
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4250

    
4251
autoRepairAllResults :: FrozenSet String
4252
autoRepairAllResults =
4253
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4254

    
4255
-- | The version identifier for builtin data collectors
4256
builtinDataCollectorVersion :: String
4257
builtinDataCollectorVersion = "B"
4258

    
4259
-- | The reason trail opcode parameter name
4260
opcodeReason :: String
4261
opcodeReason = "reason"
4262

    
4263
diskstatsFile :: String
4264
diskstatsFile = "/proc/diskstats"
4265

    
4266
-- *  CPU load collector
4267

    
4268
statFile :: String
4269
statFile = "/proc/stat"
4270

    
4271
cpuavgloadBufferSize :: Int
4272
cpuavgloadBufferSize = 150
4273

    
4274
cpuavgloadWindowSize :: Int
4275
cpuavgloadWindowSize = 600
4276

    
4277
-- * Monitoring daemon
4278

    
4279
-- | Mond's variable for periodical data collection
4280
mondTimeInterval :: Int
4281
mondTimeInterval = 5
4282

    
4283
-- | Mond's latest API version
4284
mondLatestApiVersion :: Int
4285
mondLatestApiVersion = 1
4286

    
4287
-- * Disk access modes
4288

    
4289
diskUserspace :: String
4290
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4291

    
4292
diskKernelspace :: String
4293
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4294

    
4295
diskValidAccessModes :: FrozenSet String
4296
diskValidAccessModes =
4297
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4298

    
4299
-- | Timeout for queue draining in upgrades
4300
upgradeQueueDrainTimeout :: Int
4301
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4302

    
4303
-- | Intervall at which the queue is polled during upgrades
4304
upgradeQueuePollInterval :: Int
4305
upgradeQueuePollInterval  = 10
4306

    
4307
-- * Hotplug Actions
4308

    
4309
hotplugActionAdd :: String
4310
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4311

    
4312
hotplugActionRemove :: String
4313
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4314

    
4315
hotplugActionModify :: String
4316
hotplugActionModify = Types.hotplugActionToRaw HAMod
4317

    
4318
hotplugAllActions :: FrozenSet String
4319
hotplugAllActions =
4320
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4321

    
4322
-- * Hotplug Device Targets
4323

    
4324
hotplugTargetNic :: String
4325
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4326

    
4327
hotplugTargetDisk :: String
4328
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4329

    
4330
hotplugAllTargets :: FrozenSet String
4331
hotplugAllTargets =
4332
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4333

    
4334
-- | Timeout for disk removal (seconds)
4335
diskRemoveRetryTimeout :: Int
4336
diskRemoveRetryTimeout = 30
4337

    
4338
-- | Interval between disk removal retries (seconds)
4339
diskRemoveRetryInterval :: Int
4340
diskRemoveRetryInterval  = 3
4341

    
4342
-- * UUID regex
4343

    
4344
uuidRegex :: String
4345
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4346

    
4347
-- * Luxi constants
4348

    
4349
luxiKeyMethod :: String
4350
luxiKeyMethod = "method"
4351

    
4352
luxiKeyArgs :: String
4353
luxiKeyArgs = "args"
4354

    
4355
luxiKeySuccess :: String
4356
luxiKeySuccess = "success"
4357

    
4358
luxiKeyResult :: String
4359
luxiKeyResult = "result"
4360

    
4361
luxiKeyVersion :: String
4362
luxiKeyVersion = "version"
4363

    
4364
luxiReqSubmitJob :: String
4365
luxiReqSubmitJob = "SubmitJob"
4366

    
4367
luxiReqSubmitJobToDrainedQueue :: String
4368
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4369

    
4370
luxiReqSubmitManyJobs :: String
4371
luxiReqSubmitManyJobs = "SubmitManyJobs"
4372

    
4373
luxiReqWaitForJobChange :: String
4374
luxiReqWaitForJobChange = "WaitForJobChange"
4375

    
4376
luxiReqPickupJob :: String
4377
luxiReqPickupJob = "PickupJob"
4378

    
4379
luxiReqCancelJob :: String
4380
luxiReqCancelJob = "CancelJob"
4381

    
4382
luxiReqArchiveJob :: String
4383
luxiReqArchiveJob = "ArchiveJob"
4384

    
4385
luxiReqChangeJobPriority :: String
4386
luxiReqChangeJobPriority = "ChangeJobPriority"
4387

    
4388
luxiReqAutoArchiveJobs :: String
4389
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4390

    
4391
luxiReqQuery :: String
4392
luxiReqQuery = "Query"
4393

    
4394
luxiReqQueryFields :: String
4395
luxiReqQueryFields = "QueryFields"
4396

    
4397
luxiReqQueryJobs :: String
4398
luxiReqQueryJobs = "QueryJobs"
4399

    
4400
luxiReqQueryInstances :: String
4401
luxiReqQueryInstances = "QueryInstances"
4402

    
4403
luxiReqQueryNodes :: String
4404
luxiReqQueryNodes = "QueryNodes"
4405

    
4406
luxiReqQueryGroups :: String
4407
luxiReqQueryGroups = "QueryGroups"
4408

    
4409
luxiReqQueryNetworks :: String
4410
luxiReqQueryNetworks = "QueryNetworks"
4411

    
4412
luxiReqQueryExports :: String
4413
luxiReqQueryExports = "QueryExports"
4414

    
4415
luxiReqQueryConfigValues :: String
4416
luxiReqQueryConfigValues = "QueryConfigValues"
4417

    
4418
luxiReqQueryClusterInfo :: String
4419
luxiReqQueryClusterInfo = "QueryClusterInfo"
4420

    
4421
luxiReqQueryTags :: String
4422
luxiReqQueryTags = "QueryTags"
4423

    
4424
luxiReqSetDrainFlag :: String
4425
luxiReqSetDrainFlag = "SetDrainFlag"
4426

    
4427
luxiReqSetWatcherPause :: String
4428
luxiReqSetWatcherPause = "SetWatcherPause"
4429

    
4430
luxiReqAll :: FrozenSet String
4431
luxiReqAll =
4432
  ConstantUtils.mkSet
4433
  [ luxiReqArchiveJob
4434
  , luxiReqAutoArchiveJobs
4435
  , luxiReqCancelJob
4436
  , luxiReqChangeJobPriority
4437
  , luxiReqQuery
4438
  , luxiReqQueryClusterInfo
4439
  , luxiReqQueryConfigValues
4440
  , luxiReqQueryExports
4441
  , luxiReqQueryFields
4442
  , luxiReqQueryGroups
4443
  , luxiReqQueryInstances
4444
  , luxiReqQueryJobs
4445
  , luxiReqQueryNodes
4446
  , luxiReqQueryNetworks
4447
  , luxiReqQueryTags
4448
  , luxiReqSetDrainFlag
4449
  , luxiReqSetWatcherPause
4450
  , luxiReqSubmitJob
4451
  , luxiReqSubmitJobToDrainedQueue
4452
  , luxiReqSubmitManyJobs
4453
  , luxiReqWaitForJobChange
4454
  , luxiReqPickupJob
4455
  ]
4456

    
4457
luxiDefCtmo :: Int
4458
luxiDefCtmo = 10
4459

    
4460
luxiDefRwto :: Int
4461
luxiDefRwto = 60
4462

    
4463
-- | 'WaitForJobChange' timeout
4464
luxiWfjcTimeout :: Int
4465
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4466

    
4467
-- * Query language constants
4468

    
4469
-- ** Logic operators with one or more operands, each of which is a
4470
-- filter on its own
4471

    
4472
qlangOpAnd :: String
4473
qlangOpAnd = "&"
4474

    
4475
qlangOpOr :: String
4476
qlangOpOr = "|"
4477

    
4478
-- ** Unary operators with exactly one operand
4479

    
4480
qlangOpNot :: String
4481
qlangOpNot = "!"
4482

    
4483
qlangOpTrue :: String
4484
qlangOpTrue = "?"
4485

    
4486
-- ** Binary operators with exactly two operands, the field name and
4487
-- an operator-specific value
4488

    
4489
qlangOpContains :: String
4490
qlangOpContains = "=[]"
4491

    
4492
qlangOpEqual :: String
4493
qlangOpEqual = "="
4494

    
4495
qlangOpGe :: String
4496
qlangOpGe = ">="
4497

    
4498
qlangOpGt :: String
4499
qlangOpGt = ">"
4500

    
4501
qlangOpLe :: String
4502
qlangOpLe = "<="
4503

    
4504
qlangOpLt :: String
4505
qlangOpLt = "<"
4506

    
4507
qlangOpNotEqual :: String
4508
qlangOpNotEqual = "!="
4509

    
4510
qlangOpRegexp :: String
4511
qlangOpRegexp = "=~"
4512

    
4513
-- | Characters used for detecting user-written filters (see
4514
-- L{_CheckFilter})
4515

    
4516
qlangFilterDetectionChars :: FrozenSet String
4517
qlangFilterDetectionChars =
4518
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4519
                       ")", "(", "\x0b", "\n",
4520
                       "\r", "\x0c", "/", "<",
4521
                       "\t", ">", "=", "\\", "~"]
4522

    
4523
-- | Characters used to detect globbing filters
4524
qlangGlobDetectionChars :: FrozenSet String
4525
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4526

    
4527
-- * Error related constants
4528
--
4529
-- 'OpPrereqError' failure types
4530

    
4531
-- | Environment error (e.g. node disk error)
4532
errorsEcodeEnviron :: String
4533
errorsEcodeEnviron = "environment_error"
4534

    
4535
-- | Entity already exists
4536
errorsEcodeExists :: String
4537
errorsEcodeExists = "already_exists"
4538

    
4539
-- | Internal cluster error
4540
errorsEcodeFault :: String
4541
errorsEcodeFault = "internal_error"
4542

    
4543
-- | Wrong arguments (at syntax level)
4544
errorsEcodeInval :: String
4545
errorsEcodeInval = "wrong_input"
4546

    
4547
-- | Entity not found
4548
errorsEcodeNoent :: String
4549
errorsEcodeNoent = "unknown_entity"
4550

    
4551
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4552
errorsEcodeNores :: String
4553
errorsEcodeNores = "insufficient_resources"
4554

    
4555
-- | Resource not unique (e.g. MAC or IP duplication)
4556
errorsEcodeNotunique :: String
4557
errorsEcodeNotunique = "resource_not_unique"
4558

    
4559
-- | Resolver errors
4560
errorsEcodeResolver :: String
4561
errorsEcodeResolver = "resolver_error"
4562

    
4563
-- | Wrong entity state
4564
errorsEcodeState :: String
4565
errorsEcodeState = "wrong_state"
4566

    
4567
-- | Temporarily out of resources; operation can be tried again
4568
errorsEcodeTempNores :: String
4569
errorsEcodeTempNores = "temp_insufficient_resources"
4570

    
4571
errorsEcodeAll :: FrozenSet String
4572
errorsEcodeAll =
4573
  ConstantUtils.mkSet [ errorsEcodeNores
4574
                      , errorsEcodeExists
4575
                      , errorsEcodeState
4576
                      , errorsEcodeNotunique
4577
                      , errorsEcodeTempNores
4578
                      , errorsEcodeNoent
4579
                      , errorsEcodeFault
4580
                      , errorsEcodeResolver
4581
                      , errorsEcodeInval
4582
                      , errorsEcodeEnviron
4583
                      ]
4584

    
4585
-- * Jstore related constants
4586

    
4587
jstoreJobsPerArchiveDirectory :: Int
4588
jstoreJobsPerArchiveDirectory = 10000
4589

    
4590
-- * Gluster settings
4591

    
4592
-- | Where Ganeti should manage Gluster volume mountpoints
4593
glusterMountpoint :: String
4594
glusterMountpoint = "/var/run/ganeti/gluster"