Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 1211c6ed

History | View | Annotate | Download (113.8 kB)

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

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

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

    
15
-}
16

    
17
{-
18

    
19
Copyright (C) 2013 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
-- | This is used to order determine the default disk template when
793
-- the list of enabled disk templates is inferred from the current
794
-- state of the cluster.  This only happens on an upgrade from a
795
-- version of Ganeti that did not support the 'enabled_disk_templates'
796
-- so far.
797
diskTemplatePreference :: [String]
798
diskTemplatePreference =
799
  map Types.diskTemplateToRaw
800
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile, DTPlain, DTRbd, DTSharedFile]
801

    
802
diskTemplates :: FrozenSet String
803
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
804

    
805
-- | Disk templates that are enabled by default
806
defaultEnabledDiskTemplates :: [String]
807
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
808

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

    
823
-- | The set of network-mirrored disk templates
824
dtsIntMirror :: FrozenSet String
825
dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
826

    
827
-- | 'DTDiskless' is 'trivially' externally mirrored
828
dtsExtMirror :: FrozenSet String
829
dtsExtMirror =
830
  ConstantUtils.mkSet $
831
  map Types.diskTemplateToRaw [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd]
832

    
833
-- | The set of non-lvm-based disk templates
834
dtsNotLvm :: FrozenSet String
835
dtsNotLvm =
836
  ConstantUtils.mkSet $
837
  map Types.diskTemplateToRaw
838
  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd]
839

    
840
-- | The set of disk templates which can be grown
841
dtsGrowable :: FrozenSet String
842
dtsGrowable =
843
  ConstantUtils.mkSet $
844
  map Types.diskTemplateToRaw
845
  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd]
846

    
847
-- | The set of disk templates that allow adoption
848
dtsMayAdopt :: FrozenSet String
849
dtsMayAdopt =
850
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
851

    
852
-- | The set of disk templates that *must* use adoption
853
dtsMustAdopt :: FrozenSet String
854
dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
855

    
856
-- | The set of disk templates that allow migrations
857
dtsMirrored :: FrozenSet String
858
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
859

    
860
-- | The set of file based disk templates
861
dtsFilebased :: FrozenSet String
862
dtsFilebased =
863
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTSharedFile, DTFile]
864

    
865
-- | The set of disk templates that can be moved by copying
866
--
867
-- Note: a requirement is that they're not accessed externally or
868
-- shared between nodes; in particular, sharedfile is not suitable.
869
dtsCopyable :: FrozenSet String
870
dtsCopyable =
871
  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
872

    
873
-- | The set of disk templates that are supported by exclusive_storage
874
dtsExclStorage :: FrozenSet String
875
dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
876

    
877
-- | Templates for which we don't perform checks on free space
878
dtsNoFreeSpaceCheck :: FrozenSet String
879
dtsNoFreeSpaceCheck =
880
  ConstantUtils.mkSet $
881
  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd]
882

    
883
dtsBlock :: FrozenSet String
884
dtsBlock =
885
  ConstantUtils.mkSet $
886
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
887

    
888
-- | The set of lvm-based disk templates
889
dtsLvm :: FrozenSet String
890
dtsLvm = diskTemplates `ConstantUtils.difference` dtsNotLvm
891

    
892
-- * Drbd
893

    
894
drbdHmacAlg :: String
895
drbdHmacAlg = "md5"
896

    
897
drbdDefaultNetProtocol :: String
898
drbdDefaultNetProtocol = "C"
899

    
900
drbdMigrationNetProtocol :: String
901
drbdMigrationNetProtocol = "C"
902

    
903
drbdStatusFile :: String
904
drbdStatusFile = "/proc/drbd"
905

    
906
-- | Size of DRBD meta block device
907
drbdMetaSize :: Int
908
drbdMetaSize = 128
909

    
910
-- * Drbd barrier types
911

    
912
drbdBDiskBarriers :: String
913
drbdBDiskBarriers = "b"
914

    
915
drbdBDiskDrain :: String
916
drbdBDiskDrain = "d"
917

    
918
drbdBDiskFlush :: String
919
drbdBDiskFlush = "f"
920

    
921
drbdBNone :: String
922
drbdBNone = "n"
923

    
924
-- | Valid barrier combinations: "n" or any non-null subset of "bfd"
925
drbdValidBarrierOpt :: FrozenSet (FrozenSet String)
926
drbdValidBarrierOpt =
927
  ConstantUtils.mkSet
928
  [ ConstantUtils.mkSet [drbdBNone]
929
  , ConstantUtils.mkSet [drbdBDiskBarriers]
930
  , ConstantUtils.mkSet [drbdBDiskDrain]
931
  , ConstantUtils.mkSet [drbdBDiskFlush]
932
  , ConstantUtils.mkSet [drbdBDiskDrain, drbdBDiskFlush]
933
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskDrain]
934
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush]
935
  , ConstantUtils.mkSet [drbdBDiskBarriers, drbdBDiskFlush, drbdBDiskDrain]
936
  ]
937

    
938
-- | Rbd tool command
939
rbdCmd :: String
940
rbdCmd = "rbd"
941

    
942
-- * File backend driver
943

    
944
fdBlktap :: String
945
fdBlktap = Types.fileDriverToRaw FileBlktap
946

    
947
fdLoop :: String
948
fdLoop = Types.fileDriverToRaw FileLoop
949

    
950
fileDriver :: FrozenSet String
951
fileDriver =
952
  ConstantUtils.mkSet $
953
  map Types.fileDriverToRaw [minBound..]
954

    
955
-- | The set of drbd-like disk types
956
dtsDrbd :: FrozenSet String
957
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
958

    
959
-- * Disk access mode
960

    
961
diskRdonly :: String
962
diskRdonly = Types.diskModeToRaw DiskRdOnly
963

    
964
diskRdwr :: String
965
diskRdwr = Types.diskModeToRaw DiskRdWr
966

    
967
diskAccessSet :: FrozenSet String
968
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
969

    
970
-- * Disk replacement mode
971

    
972
replaceDiskAuto :: String
973
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
974

    
975
replaceDiskChg :: String
976
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
977

    
978
replaceDiskPri :: String
979
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
980

    
981
replaceDiskSec :: String
982
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
983

    
984
replaceModes :: FrozenSet String
985
replaceModes =
986
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
987

    
988
-- * Instance export mode
989

    
990
exportModeLocal :: String
991
exportModeLocal = Types.exportModeToRaw ExportModeLocal
992

    
993
exportModeRemote :: String
994
exportModeRemote = Types.exportModeToRaw ExportModeRemote
995

    
996
exportModes :: FrozenSet String
997
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
998

    
999
-- * Instance creation modes
1000

    
1001
instanceCreate :: String
1002
instanceCreate = Types.instCreateModeToRaw InstCreate
1003

    
1004
instanceImport :: String
1005
instanceImport = Types.instCreateModeToRaw InstImport
1006

    
1007
instanceRemoteImport :: String
1008
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1009

    
1010
instanceCreateModes :: FrozenSet String
1011
instanceCreateModes =
1012
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1013

    
1014
-- * Remote import/export handshake message and version
1015

    
1016
rieHandshake :: String
1017
rieHandshake = "Hi, I'm Ganeti"
1018

    
1019
rieVersion :: Int
1020
rieVersion = 0
1021

    
1022
-- | Remote import/export certificate validity (seconds)
1023
rieCertValidity :: Int
1024
rieCertValidity = 24 * 60 * 60
1025

    
1026
-- | Export only: how long to wait per connection attempt (seconds)
1027
rieConnectAttemptTimeout :: Int
1028
rieConnectAttemptTimeout = 20
1029

    
1030
-- | Export only: number of attempts to connect
1031
rieConnectRetries :: Int
1032
rieConnectRetries = 10
1033

    
1034
-- | Overall timeout for establishing connection
1035
rieConnectTimeout :: Int
1036
rieConnectTimeout = 180
1037

    
1038
-- | Give child process up to 5 seconds to exit after sending a signal
1039
childLingerTimeout :: Double
1040
childLingerTimeout = 5.0
1041

    
1042
-- * Import/export config options
1043

    
1044
inisectBep :: String
1045
inisectBep = "backend"
1046

    
1047
inisectExp :: String
1048
inisectExp = "export"
1049

    
1050
inisectHyp :: String
1051
inisectHyp = "hypervisor"
1052

    
1053
inisectIns :: String
1054
inisectIns = "instance"
1055

    
1056
inisectOsp :: String
1057
inisectOsp = "os"
1058

    
1059
-- * Dynamic device modification
1060

    
1061
ddmAdd :: String
1062
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1063

    
1064
ddmModify :: String
1065
ddmModify = Types.ddmFullToRaw DdmFullModify
1066

    
1067
ddmRemove :: String
1068
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1069

    
1070
ddmsValues :: FrozenSet String
1071
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1072

    
1073
ddmsValuesWithModify :: FrozenSet String
1074
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1075

    
1076
-- * Common exit codes
1077

    
1078
exitSuccess :: Int
1079
exitSuccess = 0
1080

    
1081
exitFailure :: Int
1082
exitFailure = ConstantUtils.exitFailure
1083

    
1084
exitNotcluster :: Int
1085
exitNotcluster = 5
1086

    
1087
exitNotmaster :: Int
1088
exitNotmaster = 11
1089

    
1090
exitNodesetupError :: Int
1091
exitNodesetupError = 12
1092

    
1093
-- | Need user confirmation
1094
exitConfirmation :: Int
1095
exitConfirmation = 13
1096

    
1097
-- | Exit code for query operations with unknown fields
1098
exitUnknownField :: Int
1099
exitUnknownField = 14
1100

    
1101
-- * Tags
1102

    
1103
tagCluster :: String
1104
tagCluster = Types.tagKindToRaw TagKindCluster
1105

    
1106
tagInstance :: String
1107
tagInstance = Types.tagKindToRaw TagKindInstance
1108

    
1109
tagNetwork :: String
1110
tagNetwork = Types.tagKindToRaw TagKindNetwork
1111

    
1112
tagNode :: String
1113
tagNode = Types.tagKindToRaw TagKindNode
1114

    
1115
tagNodegroup :: String
1116
tagNodegroup = Types.tagKindToRaw TagKindGroup
1117

    
1118
validTagTypes :: FrozenSet String
1119
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1120

    
1121
maxTagLen :: Int
1122
maxTagLen = 128
1123

    
1124
maxTagsPerObj :: Int
1125
maxTagsPerObj = 4096
1126

    
1127
-- * Others
1128

    
1129
defaultBridge :: String
1130
defaultBridge = "xen-br0"
1131

    
1132
defaultOvs :: String
1133
defaultOvs = "switch1"
1134

    
1135
-- | 60 MiB/s, expressed in KiB/s
1136
classicDrbdSyncSpeed :: Int
1137
classicDrbdSyncSpeed = 60 * 1024
1138

    
1139
ip4AddressAny :: String
1140
ip4AddressAny = "0.0.0.0"
1141

    
1142
ip4AddressLocalhost :: String
1143
ip4AddressLocalhost = "127.0.0.1"
1144

    
1145
ip6AddressAny :: String
1146
ip6AddressAny = "::"
1147

    
1148
ip6AddressLocalhost :: String
1149
ip6AddressLocalhost = "::1"
1150

    
1151
ip4Version :: Int
1152
ip4Version = 4
1153

    
1154
ip6Version :: Int
1155
ip6Version = 6
1156

    
1157
validIpVersions :: FrozenSet Int
1158
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1159

    
1160
tcpPingTimeout :: Int
1161
tcpPingTimeout = 10
1162

    
1163
defaultVg :: String
1164
defaultVg = "xenvg"
1165

    
1166
defaultDrbdHelper :: String
1167
defaultDrbdHelper = "/bin/true"
1168

    
1169
minVgSize :: Int
1170
minVgSize = 20480
1171

    
1172
defaultMacPrefix :: String
1173
defaultMacPrefix = "aa:00:00"
1174

    
1175
-- | Default maximum instance wait time (seconds)
1176
defaultShutdownTimeout :: Int
1177
defaultShutdownTimeout = 120
1178

    
1179
-- | Node clock skew (seconds)
1180
nodeMaxClockSkew :: Int
1181
nodeMaxClockSkew = 150
1182

    
1183
-- | Time for an intra-cluster disk transfer to wait for a connection
1184
diskTransferConnectTimeout :: Int
1185
diskTransferConnectTimeout = 60
1186

    
1187
-- | Disk index separator
1188
diskSeparator :: String
1189
diskSeparator = AutoConf.diskSeparator
1190

    
1191
ipCommandPath :: String
1192
ipCommandPath = AutoConf.ipPath
1193

    
1194
-- | Key for job IDs in opcode result
1195
jobIdsKey :: String
1196
jobIdsKey = "jobs"
1197

    
1198
-- * Runparts results
1199

    
1200
runpartsErr :: Int
1201
runpartsErr = 2
1202

    
1203
runpartsRun :: Int
1204
runpartsRun = 1
1205

    
1206
runpartsSkip :: Int
1207
runpartsSkip = 0
1208

    
1209
runpartsStatus :: [Int]
1210
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1211

    
1212
-- * RPC
1213

    
1214
rpcEncodingNone :: Int
1215
rpcEncodingNone = 0
1216

    
1217
rpcEncodingZlibBase64 :: Int
1218
rpcEncodingZlibBase64 = 1
1219

    
1220
-- * Timeout table
1221
--
1222
-- Various time constants for the timeout table
1223

    
1224
rpcTmoUrgent :: Int
1225
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1226

    
1227
rpcTmoFast :: Int
1228
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1229

    
1230
rpcTmoNormal :: Int
1231
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1232

    
1233
rpcTmoSlow :: Int
1234
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1235

    
1236
-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
1237
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1238
-- Python name.
1239
rpcTmo_4hrs :: Int
1240
rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
1241

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

    
1248
-- | Timeout for connecting to nodes (seconds)
1249
rpcConnectTimeout :: Int
1250
rpcConnectTimeout = 5
1251

    
1252
-- OS
1253

    
1254
osScriptCreate :: String
1255
osScriptCreate = "create"
1256

    
1257
osScriptExport :: String
1258
osScriptExport = "export"
1259

    
1260
osScriptImport :: String
1261
osScriptImport = "import"
1262

    
1263
osScriptRename :: String
1264
osScriptRename = "rename"
1265

    
1266
osScriptVerify :: String
1267
osScriptVerify = "verify"
1268

    
1269
osScripts :: [String]
1270
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1271
             osScriptVerify]
1272

    
1273
osApiFile :: String
1274
osApiFile = "ganeti_api_version"
1275

    
1276
osVariantsFile :: String
1277
osVariantsFile = "variants.list"
1278

    
1279
osParametersFile :: String
1280
osParametersFile = "parameters.list"
1281

    
1282
osValidateParameters :: String
1283
osValidateParameters = "parameters"
1284

    
1285
osValidateCalls :: FrozenSet String
1286
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1287

    
1288
-- | External Storage (ES) related constants
1289

    
1290
esActionAttach :: String
1291
esActionAttach = "attach"
1292

    
1293
esActionCreate :: String
1294
esActionCreate = "create"
1295

    
1296
esActionDetach :: String
1297
esActionDetach = "detach"
1298

    
1299
esActionGrow :: String
1300
esActionGrow = "grow"
1301

    
1302
esActionRemove :: String
1303
esActionRemove = "remove"
1304

    
1305
esActionSetinfo :: String
1306
esActionSetinfo = "setinfo"
1307

    
1308
esActionVerify :: String
1309
esActionVerify = "verify"
1310

    
1311
esScriptCreate :: String
1312
esScriptCreate = esActionCreate
1313

    
1314
esScriptRemove :: String
1315
esScriptRemove = esActionRemove
1316

    
1317
esScriptGrow :: String
1318
esScriptGrow = esActionGrow
1319

    
1320
esScriptAttach :: String
1321
esScriptAttach = esActionAttach
1322

    
1323
esScriptDetach :: String
1324
esScriptDetach = esActionDetach
1325

    
1326
esScriptSetinfo :: String
1327
esScriptSetinfo = esActionSetinfo
1328

    
1329
esScriptVerify :: String
1330
esScriptVerify = esActionVerify
1331

    
1332
esScripts :: FrozenSet String
1333
esScripts =
1334
  ConstantUtils.mkSet [esScriptAttach,
1335
                       esScriptCreate,
1336
                       esScriptDetach,
1337
                       esScriptGrow,
1338
                       esScriptRemove,
1339
                       esScriptSetinfo,
1340
                       esScriptVerify]
1341

    
1342
esParametersFile :: String
1343
esParametersFile = "parameters.list"
1344

    
1345
-- * Reboot types
1346

    
1347
instanceRebootSoft :: String
1348
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1349

    
1350
instanceRebootHard :: String
1351
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1352

    
1353
instanceRebootFull :: String
1354
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1355

    
1356
rebootTypes :: FrozenSet String
1357
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1358

    
1359
-- * Instance reboot behaviors
1360

    
1361
instanceRebootAllowed :: String
1362
instanceRebootAllowed = "reboot"
1363

    
1364
instanceRebootExit :: String
1365
instanceRebootExit = "exit"
1366

    
1367
rebootBehaviors :: [String]
1368
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1369

    
1370
-- * VTypes
1371

    
1372
vtypeBool :: VType
1373
vtypeBool = VTypeBool
1374

    
1375
vtypeInt :: VType
1376
vtypeInt = VTypeInt
1377

    
1378
vtypeMaybeString :: VType
1379
vtypeMaybeString = VTypeMaybeString
1380

    
1381
-- | Size in MiBs
1382
vtypeSize :: VType
1383
vtypeSize = VTypeSize
1384

    
1385
vtypeString :: VType
1386
vtypeString = VTypeString
1387

    
1388
enforceableTypes :: FrozenSet VType
1389
enforceableTypes = ConstantUtils.mkSet [minBound..]
1390

    
1391
-- | Constant representing that the user does not specify any IP version
1392
ifaceNoIpVersionSpecified :: Int
1393
ifaceNoIpVersionSpecified = 0
1394

    
1395
validSerialSpeeds :: [Int]
1396
validSerialSpeeds =
1397
  [75,
1398
   110,
1399
   300,
1400
   600,
1401
   1200,
1402
   1800,
1403
   2400,
1404
   4800,
1405
   9600,
1406
   14400,
1407
   19200,
1408
   28800,
1409
   38400,
1410
   57600,
1411
   115200,
1412
   230400,
1413
   345600,
1414
   460800]
1415

    
1416
-- * HV parameter names (global namespace)
1417

    
1418
hvAcpi :: String
1419
hvAcpi = "acpi"
1420

    
1421
hvBlockdevPrefix :: String
1422
hvBlockdevPrefix = "blockdev_prefix"
1423

    
1424
hvBootloaderArgs :: String
1425
hvBootloaderArgs = "bootloader_args"
1426

    
1427
hvBootloaderPath :: String
1428
hvBootloaderPath = "bootloader_path"
1429

    
1430
hvBootOrder :: String
1431
hvBootOrder = "boot_order"
1432

    
1433
hvCdromImagePath :: String
1434
hvCdromImagePath = "cdrom_image_path"
1435

    
1436
hvCpuCap :: String
1437
hvCpuCap = "cpu_cap"
1438

    
1439
hvCpuCores :: String
1440
hvCpuCores = "cpu_cores"
1441

    
1442
hvCpuMask :: String
1443
hvCpuMask = "cpu_mask"
1444

    
1445
hvCpuSockets :: String
1446
hvCpuSockets = "cpu_sockets"
1447

    
1448
hvCpuThreads :: String
1449
hvCpuThreads = "cpu_threads"
1450

    
1451
hvCpuType :: String
1452
hvCpuType = "cpu_type"
1453

    
1454
hvCpuWeight :: String
1455
hvCpuWeight = "cpu_weight"
1456

    
1457
hvDeviceModel :: String
1458
hvDeviceModel = "device_model"
1459

    
1460
hvDiskCache :: String
1461
hvDiskCache = "disk_cache"
1462

    
1463
hvDiskType :: String
1464
hvDiskType = "disk_type"
1465

    
1466
hvInitrdPath :: String
1467
hvInitrdPath = "initrd_path"
1468

    
1469
hvInitScript :: String
1470
hvInitScript = "init_script"
1471

    
1472
hvKernelArgs :: String
1473
hvKernelArgs = "kernel_args"
1474

    
1475
hvKernelPath :: String
1476
hvKernelPath = "kernel_path"
1477

    
1478
hvKeymap :: String
1479
hvKeymap = "keymap"
1480

    
1481
hvKvmCdrom2ImagePath :: String
1482
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1483

    
1484
hvKvmCdromDiskType :: String
1485
hvKvmCdromDiskType = "cdrom_disk_type"
1486

    
1487
hvKvmExtra :: String
1488
hvKvmExtra = "kvm_extra"
1489

    
1490
hvKvmFlag :: String
1491
hvKvmFlag = "kvm_flag"
1492

    
1493
hvKvmFloppyImagePath :: String
1494
hvKvmFloppyImagePath = "floppy_image_path"
1495

    
1496
hvKvmMachineVersion :: String
1497
hvKvmMachineVersion = "machine_version"
1498

    
1499
hvKvmPath :: String
1500
hvKvmPath = "kvm_path"
1501

    
1502
hvKvmSpiceAudioCompr :: String
1503
hvKvmSpiceAudioCompr = "spice_playback_compression"
1504

    
1505
hvKvmSpiceBind :: String
1506
hvKvmSpiceBind = "spice_bind"
1507

    
1508
hvKvmSpiceIpVersion :: String
1509
hvKvmSpiceIpVersion = "spice_ip_version"
1510

    
1511
hvKvmSpiceJpegImgCompr :: String
1512
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1513

    
1514
hvKvmSpiceLosslessImgCompr :: String
1515
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1516

    
1517
hvKvmSpicePasswordFile :: String
1518
hvKvmSpicePasswordFile = "spice_password_file"
1519

    
1520
hvKvmSpiceStreamingVideoDetection :: String
1521
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1522

    
1523
hvKvmSpiceTlsCiphers :: String
1524
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1525

    
1526
hvKvmSpiceUseTls :: String
1527
hvKvmSpiceUseTls = "spice_use_tls"
1528

    
1529
hvKvmSpiceUseVdagent :: String
1530
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1531

    
1532
hvKvmSpiceZlibGlzImgCompr :: String
1533
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1534

    
1535
hvKvmUseChroot :: String
1536
hvKvmUseChroot = "use_chroot"
1537

    
1538
hvMemPath :: String
1539
hvMemPath = "mem_path"
1540

    
1541
hvMigrationBandwidth :: String
1542
hvMigrationBandwidth = "migration_bandwidth"
1543

    
1544
hvMigrationDowntime :: String
1545
hvMigrationDowntime = "migration_downtime"
1546

    
1547
hvMigrationMode :: String
1548
hvMigrationMode = "migration_mode"
1549

    
1550
hvMigrationPort :: String
1551
hvMigrationPort = "migration_port"
1552

    
1553
hvNicType :: String
1554
hvNicType = "nic_type"
1555

    
1556
hvPae :: String
1557
hvPae = "pae"
1558

    
1559
hvPassthrough :: String
1560
hvPassthrough = "pci_pass"
1561

    
1562
hvRebootBehavior :: String
1563
hvRebootBehavior = "reboot_behavior"
1564

    
1565
hvRootPath :: String
1566
hvRootPath = "root_path"
1567

    
1568
hvSecurityDomain :: String
1569
hvSecurityDomain = "security_domain"
1570

    
1571
hvSecurityModel :: String
1572
hvSecurityModel = "security_model"
1573

    
1574
hvSerialConsole :: String
1575
hvSerialConsole = "serial_console"
1576

    
1577
hvSerialSpeed :: String
1578
hvSerialSpeed = "serial_speed"
1579

    
1580
hvSoundhw :: String
1581
hvSoundhw = "soundhw"
1582

    
1583
hvUsbDevices :: String
1584
hvUsbDevices = "usb_devices"
1585

    
1586
hvUsbMouse :: String
1587
hvUsbMouse = "usb_mouse"
1588

    
1589
hvUseBootloader :: String
1590
hvUseBootloader = "use_bootloader"
1591

    
1592
hvUseLocaltime :: String
1593
hvUseLocaltime = "use_localtime"
1594

    
1595
hvVga :: String
1596
hvVga = "vga"
1597

    
1598
hvVhostNet :: String
1599
hvVhostNet = "vhost_net"
1600

    
1601
hvVifScript :: String
1602
hvVifScript = "vif_script"
1603

    
1604
hvVifType :: String
1605
hvVifType = "vif_type"
1606

    
1607
hvViridian :: String
1608
hvViridian = "viridian"
1609

    
1610
hvVncBindAddress :: String
1611
hvVncBindAddress = "vnc_bind_address"
1612

    
1613
hvVncPasswordFile :: String
1614
hvVncPasswordFile = "vnc_password_file"
1615

    
1616
hvVncTls :: String
1617
hvVncTls = "vnc_tls"
1618

    
1619
hvVncX509 :: String
1620
hvVncX509 = "vnc_x509_path"
1621

    
1622
hvVncX509Verify :: String
1623
hvVncX509Verify = "vnc_x509_verify"
1624

    
1625
hvVnetHdr :: String
1626
hvVnetHdr = "vnet_hdr"
1627

    
1628
hvXenCmd :: String
1629
hvXenCmd = "xen_cmd"
1630

    
1631
hvXenCpuid :: String
1632
hvXenCpuid = "cpuid"
1633

    
1634
hvsParameterTitles :: Map String String
1635
hvsParameterTitles =
1636
  Map.fromList
1637
  [(hvAcpi, "ACPI"),
1638
   (hvBootOrder, "Boot_order"),
1639
   (hvCdromImagePath, "CDROM_image_path"),
1640
   (hvCpuType, "cpu_type"),
1641
   (hvDiskType, "Disk_type"),
1642
   (hvInitrdPath, "Initrd_path"),
1643
   (hvKernelPath, "Kernel_path"),
1644
   (hvNicType, "NIC_type"),
1645
   (hvPae, "PAE"),
1646
   (hvPassthrough, "pci_pass"),
1647
   (hvVncBindAddress, "VNC_bind_address")]
1648

    
1649
hvsParameters :: FrozenSet String
1650
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1651

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

    
1728
-- * Migration statuses
1729

    
1730
hvMigrationActive :: String
1731
hvMigrationActive = "active"
1732

    
1733
hvMigrationCancelled :: String
1734
hvMigrationCancelled = "cancelled"
1735

    
1736
hvMigrationCompleted :: String
1737
hvMigrationCompleted = "completed"
1738

    
1739
hvMigrationFailed :: String
1740
hvMigrationFailed = "failed"
1741

    
1742
hvMigrationValidStatuses :: FrozenSet String
1743
hvMigrationValidStatuses =
1744
  ConstantUtils.mkSet [hvMigrationActive,
1745
                       hvMigrationCancelled,
1746
                       hvMigrationCompleted,
1747
                       hvMigrationFailed]
1748

    
1749
hvMigrationFailedStatuses :: FrozenSet String
1750
hvMigrationFailedStatuses =
1751
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1752

    
1753
-- | KVM-specific statuses
1754
--
1755
-- FIXME: this constant seems unnecessary
1756
hvKvmMigrationValidStatuses :: FrozenSet String
1757
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1758

    
1759
-- | Node info keys
1760
hvNodeinfoKeyVersion :: String
1761
hvNodeinfoKeyVersion = "hv_version"
1762

    
1763
-- * Hypervisor state
1764

    
1765
hvstCpuNode :: String
1766
hvstCpuNode = "cpu_node"
1767

    
1768
hvstCpuTotal :: String
1769
hvstCpuTotal = "cpu_total"
1770

    
1771
hvstMemoryHv :: String
1772
hvstMemoryHv = "mem_hv"
1773

    
1774
hvstMemoryNode :: String
1775
hvstMemoryNode = "mem_node"
1776

    
1777
hvstMemoryTotal :: String
1778
hvstMemoryTotal = "mem_total"
1779

    
1780
hvstsParameters :: FrozenSet String
1781
hvstsParameters =
1782
  ConstantUtils.mkSet [hvstCpuNode,
1783
                       hvstCpuTotal,
1784
                       hvstMemoryHv,
1785
                       hvstMemoryNode,
1786
                       hvstMemoryTotal]
1787

    
1788
hvstDefaults :: Map String Int
1789
hvstDefaults =
1790
  Map.fromList
1791
  [(hvstCpuNode, 1),
1792
   (hvstCpuTotal, 1),
1793
   (hvstMemoryHv, 0),
1794
   (hvstMemoryTotal, 0),
1795
   (hvstMemoryNode, 0)]
1796

    
1797
hvstsParameterTypes :: Map String VType
1798
hvstsParameterTypes =
1799
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1800
                (hvstMemoryNode, VTypeInt),
1801
                (hvstMemoryHv, VTypeInt),
1802
                (hvstCpuTotal, VTypeInt),
1803
                (hvstCpuNode, VTypeInt)]
1804

    
1805
-- * Disk state
1806

    
1807
dsDiskOverhead :: String
1808
dsDiskOverhead = "disk_overhead"
1809

    
1810
dsDiskReserved :: String
1811
dsDiskReserved = "disk_reserved"
1812

    
1813
dsDiskTotal :: String
1814
dsDiskTotal = "disk_total"
1815

    
1816
dsDefaults :: Map String Int
1817
dsDefaults =
1818
  Map.fromList
1819
  [(dsDiskTotal, 0),
1820
   (dsDiskReserved, 0),
1821
   (dsDiskOverhead, 0)]
1822

    
1823
dssParameterTypes :: Map String VType
1824
dssParameterTypes =
1825
  Map.fromList [(dsDiskTotal, VTypeInt),
1826
                (dsDiskReserved, VTypeInt),
1827
                (dsDiskOverhead, VTypeInt)]
1828

    
1829
dssParameters :: FrozenSet String
1830
dssParameters =
1831
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1832

    
1833
dsValidTypes :: FrozenSet String
1834
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1835

    
1836
-- Backend parameter names
1837

    
1838
beAlwaysFailover :: String
1839
beAlwaysFailover = "always_failover"
1840

    
1841
beAutoBalance :: String
1842
beAutoBalance = "auto_balance"
1843

    
1844
beMaxmem :: String
1845
beMaxmem = "maxmem"
1846

    
1847
-- | Deprecated and replaced by max and min mem
1848
beMemory :: String
1849
beMemory = "memory"
1850

    
1851
beMinmem :: String
1852
beMinmem = "minmem"
1853

    
1854
beSpindleUse :: String
1855
beSpindleUse = "spindle_use"
1856

    
1857
beVcpus :: String
1858
beVcpus = "vcpus"
1859

    
1860
besParameterTypes :: Map String VType
1861
besParameterTypes =
1862
  Map.fromList [(beAlwaysFailover, VTypeBool),
1863
                (beAutoBalance, VTypeBool),
1864
                (beMaxmem, VTypeSize),
1865
                (beMinmem, VTypeSize),
1866
                (beSpindleUse, VTypeInt),
1867
                (beVcpus, VTypeInt)]
1868

    
1869
besParameterTitles :: Map String String
1870
besParameterTitles =
1871
  Map.fromList [(beAutoBalance, "Auto_balance"),
1872
                (beMinmem, "ConfigMinMem"),
1873
                (beVcpus, "ConfigVCPUs"),
1874
                (beMaxmem, "ConfigMaxMem")]
1875

    
1876
besParameterCompat :: Map String VType
1877
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1878

    
1879
besParameters :: FrozenSet String
1880
besParameters =
1881
  ConstantUtils.mkSet [beAlwaysFailover,
1882
                       beAutoBalance,
1883
                       beMaxmem,
1884
                       beMinmem,
1885
                       beSpindleUse,
1886
                       beVcpus]
1887

    
1888
-- | Instance specs
1889
--
1890
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1891

    
1892
ispecMemSize :: String
1893
ispecMemSize = ConstantUtils.ispecMemSize
1894

    
1895
ispecCpuCount :: String
1896
ispecCpuCount = ConstantUtils.ispecCpuCount
1897

    
1898
ispecDiskCount :: String
1899
ispecDiskCount = ConstantUtils.ispecDiskCount
1900

    
1901
ispecDiskSize :: String
1902
ispecDiskSize = ConstantUtils.ispecDiskSize
1903

    
1904
ispecNicCount :: String
1905
ispecNicCount = ConstantUtils.ispecNicCount
1906

    
1907
ispecSpindleUse :: String
1908
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1909

    
1910
ispecsParameterTypes :: Map String VType
1911
ispecsParameterTypes =
1912
  Map.fromList
1913
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1914
   (ConstantUtils.ispecCpuCount, VTypeInt),
1915
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1916
   (ConstantUtils.ispecMemSize, VTypeInt),
1917
   (ConstantUtils.ispecNicCount, VTypeInt),
1918
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1919

    
1920
ispecsParameters :: FrozenSet String
1921
ispecsParameters =
1922
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1923
                       ConstantUtils.ispecDiskCount,
1924
                       ConstantUtils.ispecDiskSize,
1925
                       ConstantUtils.ispecMemSize,
1926
                       ConstantUtils.ispecNicCount,
1927
                       ConstantUtils.ispecSpindleUse]
1928

    
1929
ispecsMinmax :: String
1930
ispecsMinmax = ConstantUtils.ispecsMinmax
1931

    
1932
ispecsMax :: String
1933
ispecsMax = "max"
1934

    
1935
ispecsMin :: String
1936
ispecsMin = "min"
1937

    
1938
ispecsStd :: String
1939
ispecsStd = ConstantUtils.ispecsStd
1940

    
1941
ipolicyDts :: String
1942
ipolicyDts = ConstantUtils.ipolicyDts
1943

    
1944
ipolicyVcpuRatio :: String
1945
ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
1946

    
1947
ipolicySpindleRatio :: String
1948
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
1949

    
1950
ispecsMinmaxKeys :: FrozenSet String
1951
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1952

    
1953
ipolicyParameters :: FrozenSet String
1954
ipolicyParameters =
1955
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1956
                       ConstantUtils.ipolicySpindleRatio]
1957

    
1958
ipolicyAllKeys :: FrozenSet String
1959
ipolicyAllKeys =
1960
  ConstantUtils.union ipolicyParameters $
1961
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1962
                       ConstantUtils.ispecsMinmax,
1963
                       ispecsStd]
1964

    
1965
-- | Node parameter names
1966

    
1967
ndExclusiveStorage :: String
1968
ndExclusiveStorage = "exclusive_storage"
1969

    
1970
ndOobProgram :: String
1971
ndOobProgram = "oob_program"
1972

    
1973
ndSpindleCount :: String
1974
ndSpindleCount = "spindle_count"
1975

    
1976
ndOvs :: String
1977
ndOvs = "ovs"
1978

    
1979
ndOvsLink :: String
1980
ndOvsLink = "ovs_link"
1981

    
1982
ndOvsName :: String
1983
ndOvsName = "ovs_name"
1984

    
1985
ndSshPort :: String
1986
ndSshPort = "ssh_port"
1987

    
1988
ndsParameterTypes :: Map String VType
1989
ndsParameterTypes =
1990
  Map.fromList
1991
  [(ndExclusiveStorage, VTypeBool),
1992
   (ndOobProgram, VTypeString),
1993
   (ndOvs, VTypeBool),
1994
   (ndOvsLink, VTypeMaybeString),
1995
   (ndOvsName, VTypeMaybeString),
1996
   (ndSpindleCount, VTypeInt),
1997
   (ndSshPort, VTypeInt)]
1998

    
1999
ndsParameters :: FrozenSet String
2000
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
2001

    
2002
ndsParameterTitles :: Map String String
2003
ndsParameterTitles =
2004
  Map.fromList
2005
  [(ndExclusiveStorage, "ExclusiveStorage"),
2006
   (ndOobProgram, "OutOfBandProgram"),
2007
   (ndOvs, "OpenvSwitch"),
2008
   (ndOvsLink, "OpenvSwitchLink"),
2009
   (ndOvsName, "OpenvSwitchName"),
2010
   (ndSpindleCount, "SpindleCount")]
2011

    
2012
-- * Logical Disks parameters
2013

    
2014
ldpAccess :: String
2015
ldpAccess = "access"
2016

    
2017
ldpBarriers :: String
2018
ldpBarriers = "disabled-barriers"
2019

    
2020
ldpDefaultMetavg :: String
2021
ldpDefaultMetavg = "default-metavg"
2022

    
2023
ldpDelayTarget :: String
2024
ldpDelayTarget = "c-delay-target"
2025

    
2026
ldpDiskCustom :: String
2027
ldpDiskCustom = "disk-custom"
2028

    
2029
ldpDynamicResync :: String
2030
ldpDynamicResync = "dynamic-resync"
2031

    
2032
ldpFillTarget :: String
2033
ldpFillTarget = "c-fill-target"
2034

    
2035
ldpMaxRate :: String
2036
ldpMaxRate = "c-max-rate"
2037

    
2038
ldpMinRate :: String
2039
ldpMinRate = "c-min-rate"
2040

    
2041
ldpNetCustom :: String
2042
ldpNetCustom = "net-custom"
2043

    
2044
ldpNoMetaFlush :: String
2045
ldpNoMetaFlush = "disable-meta-flush"
2046

    
2047
ldpPlanAhead :: String
2048
ldpPlanAhead = "c-plan-ahead"
2049

    
2050
ldpPool :: String
2051
ldpPool = "pool"
2052

    
2053
ldpProtocol :: String
2054
ldpProtocol = "protocol"
2055

    
2056
ldpResyncRate :: String
2057
ldpResyncRate = "resync-rate"
2058

    
2059
ldpStripes :: String
2060
ldpStripes = "stripes"
2061

    
2062
diskLdTypes :: Map String VType
2063
diskLdTypes =
2064
  Map.fromList
2065
  [(ldpAccess, VTypeString),
2066
   (ldpResyncRate, VTypeInt),
2067
   (ldpStripes, VTypeInt),
2068
   (ldpBarriers, VTypeString),
2069
   (ldpNoMetaFlush, VTypeBool),
2070
   (ldpDefaultMetavg, VTypeString),
2071
   (ldpDiskCustom, VTypeString),
2072
   (ldpNetCustom, VTypeString),
2073
   (ldpProtocol, VTypeString),
2074
   (ldpDynamicResync, VTypeBool),
2075
   (ldpPlanAhead, VTypeInt),
2076
   (ldpFillTarget, VTypeInt),
2077
   (ldpDelayTarget, VTypeInt),
2078
   (ldpMaxRate, VTypeInt),
2079
   (ldpMinRate, VTypeInt),
2080
   (ldpPool, VTypeString)]
2081

    
2082
diskLdParameters :: FrozenSet String
2083
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2084

    
2085
-- * Disk template parameters
2086
--
2087
-- Disk template parameters can be set/changed by the user via
2088
-- gnt-cluster and gnt-group)
2089

    
2090
drbdResyncRate :: String
2091
drbdResyncRate = "resync-rate"
2092

    
2093
drbdDataStripes :: String
2094
drbdDataStripes = "data-stripes"
2095

    
2096
drbdMetaStripes :: String
2097
drbdMetaStripes = "meta-stripes"
2098

    
2099
drbdDiskBarriers :: String
2100
drbdDiskBarriers = "disk-barriers"
2101

    
2102
drbdMetaBarriers :: String
2103
drbdMetaBarriers = "meta-barriers"
2104

    
2105
drbdDefaultMetavg :: String
2106
drbdDefaultMetavg = "metavg"
2107

    
2108
drbdDiskCustom :: String
2109
drbdDiskCustom = "disk-custom"
2110

    
2111
drbdNetCustom :: String
2112
drbdNetCustom = "net-custom"
2113

    
2114
drbdProtocol :: String
2115
drbdProtocol = "protocol"
2116

    
2117
drbdDynamicResync :: String
2118
drbdDynamicResync = "dynamic-resync"
2119

    
2120
drbdPlanAhead :: String
2121
drbdPlanAhead = "c-plan-ahead"
2122

    
2123
drbdFillTarget :: String
2124
drbdFillTarget = "c-fill-target"
2125

    
2126
drbdDelayTarget :: String
2127
drbdDelayTarget = "c-delay-target"
2128

    
2129
drbdMaxRate :: String
2130
drbdMaxRate = "c-max-rate"
2131

    
2132
drbdMinRate :: String
2133
drbdMinRate = "c-min-rate"
2134

    
2135
lvStripes :: String
2136
lvStripes = "stripes"
2137

    
2138
rbdAccess :: String
2139
rbdAccess = "access"
2140

    
2141
rbdPool :: String
2142
rbdPool = "pool"
2143

    
2144
diskDtTypes :: Map String VType
2145
diskDtTypes =
2146
  Map.fromList [(drbdResyncRate, VTypeInt),
2147
                (drbdDataStripes, VTypeInt),
2148
                (drbdMetaStripes, VTypeInt),
2149
                (drbdDiskBarriers, VTypeString),
2150
                (drbdMetaBarriers, VTypeBool),
2151
                (drbdDefaultMetavg, VTypeString),
2152
                (drbdDiskCustom, VTypeString),
2153
                (drbdNetCustom, VTypeString),
2154
                (drbdProtocol, VTypeString),
2155
                (drbdDynamicResync, VTypeBool),
2156
                (drbdPlanAhead, VTypeInt),
2157
                (drbdFillTarget, VTypeInt),
2158
                (drbdDelayTarget, VTypeInt),
2159
                (drbdMaxRate, VTypeInt),
2160
                (drbdMinRate, VTypeInt),
2161
                (lvStripes, VTypeInt),
2162
                (rbdAccess, VTypeString),
2163
                (rbdPool, VTypeString)]
2164

    
2165
diskDtParameters :: FrozenSet String
2166
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2167

    
2168
-- * Dynamic disk parameters
2169

    
2170
ddpLocalIp :: String
2171
ddpLocalIp = "local-ip"
2172

    
2173
ddpRemoteIp :: String
2174
ddpRemoteIp = "remote-ip"
2175

    
2176
ddpPort :: String
2177
ddpPort = "port"
2178

    
2179
ddpLocalMinor :: String
2180
ddpLocalMinor = "local-minor"
2181

    
2182
ddpRemoteMinor :: String
2183
ddpRemoteMinor = "remote-minor"
2184

    
2185
-- * OOB supported commands
2186

    
2187
oobPowerOn :: String
2188
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2189

    
2190
oobPowerOff :: String
2191
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2192

    
2193
oobPowerCycle :: String
2194
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2195

    
2196
oobPowerStatus :: String
2197
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2198

    
2199
oobHealth :: String
2200
oobHealth = Types.oobCommandToRaw OobHealth
2201

    
2202
oobCommands :: FrozenSet String
2203
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2204

    
2205
oobPowerStatusPowered :: String
2206
oobPowerStatusPowered = "powered"
2207

    
2208
-- | 60 seconds
2209
oobTimeout :: Int
2210
oobTimeout = 60
2211

    
2212
-- | 2 seconds
2213
oobPowerDelay :: Double
2214
oobPowerDelay = 2.0
2215

    
2216
oobStatusCritical :: String
2217
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2218

    
2219
oobStatusOk :: String
2220
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2221

    
2222
oobStatusUnknown :: String
2223
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2224

    
2225
oobStatusWarning :: String
2226
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2227

    
2228
oobStatuses :: FrozenSet String
2229
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2230

    
2231
-- | Instance Parameters Profile
2232
ppDefault :: String
2233
ppDefault = "default"
2234

    
2235
-- * nic* constants are used inside the ganeti config
2236

    
2237
nicLink :: String
2238
nicLink = "link"
2239

    
2240
nicMode :: String
2241
nicMode = "mode"
2242

    
2243
nicVlan :: String
2244
nicVlan = "vlan"
2245

    
2246
nicsParameterTypes :: Map String VType
2247
nicsParameterTypes =
2248
  Map.fromList [(nicMode, vtypeString),
2249
                (nicLink, vtypeString),
2250
                (nicVlan, vtypeString)]
2251

    
2252
nicsParameters :: FrozenSet String
2253
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2254

    
2255
nicModeBridged :: String
2256
nicModeBridged = Types.nICModeToRaw NMBridged
2257

    
2258
nicModeRouted :: String
2259
nicModeRouted = Types.nICModeToRaw NMRouted
2260

    
2261
nicModeOvs :: String
2262
nicModeOvs = Types.nICModeToRaw NMOvs
2263

    
2264
nicIpPool :: String
2265
nicIpPool = Types.nICModeToRaw NMPool
2266

    
2267
nicValidModes :: FrozenSet String
2268
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2269

    
2270
releaseAction :: String
2271
releaseAction = "release"
2272

    
2273
reserveAction :: String
2274
reserveAction = "reserve"
2275

    
2276
-- * idisk* constants are used in opcodes, to create/change disks
2277

    
2278
idiskAdopt :: String
2279
idiskAdopt = "adopt"
2280

    
2281
idiskMetavg :: String
2282
idiskMetavg = "metavg"
2283

    
2284
idiskMode :: String
2285
idiskMode = "mode"
2286

    
2287
idiskName :: String
2288
idiskName = "name"
2289

    
2290
idiskSize :: String
2291
idiskSize = "size"
2292

    
2293
idiskSpindles :: String
2294
idiskSpindles = "spindles"
2295

    
2296
idiskVg :: String
2297
idiskVg = "vg"
2298

    
2299
idiskProvider :: String
2300
idiskProvider = "provider"
2301

    
2302
idiskParamsTypes :: Map String VType
2303
idiskParamsTypes =
2304
  Map.fromList [(idiskSize, VTypeSize),
2305
                (idiskSpindles, VTypeInt),
2306
                (idiskMode, VTypeString),
2307
                (idiskAdopt, VTypeString),
2308
                (idiskVg, VTypeString),
2309
                (idiskMetavg, VTypeString),
2310
                (idiskProvider, VTypeString),
2311
                (idiskName, VTypeMaybeString)]
2312

    
2313
idiskParams :: FrozenSet String
2314
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2315

    
2316
-- * inic* constants are used in opcodes, to create/change nics
2317

    
2318
inicBridge :: String
2319
inicBridge = "bridge"
2320

    
2321
inicIp :: String
2322
inicIp = "ip"
2323

    
2324
inicLink :: String
2325
inicLink = "link"
2326

    
2327
inicMac :: String
2328
inicMac = "mac"
2329

    
2330
inicMode :: String
2331
inicMode = "mode"
2332

    
2333
inicName :: String
2334
inicName = "name"
2335

    
2336
inicNetwork :: String
2337
inicNetwork = "network"
2338

    
2339
inicVlan :: String
2340
inicVlan = "vlan"
2341

    
2342
inicParamsTypes :: Map String VType
2343
inicParamsTypes =
2344
  Map.fromList [(inicBridge, VTypeMaybeString),
2345
                (inicIp, VTypeMaybeString),
2346
                (inicLink, VTypeString),
2347
                (inicMac, VTypeString),
2348
                (inicMode, VTypeString),
2349
                (inicName, VTypeMaybeString),
2350
                (inicNetwork, VTypeMaybeString),
2351
                (inicVlan, VTypeMaybeString)]
2352

    
2353
inicParams :: FrozenSet String
2354
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2355

    
2356
-- * Hypervisor constants
2357

    
2358
htXenPvm :: String
2359
htXenPvm = Types.hypervisorToRaw XenPvm
2360

    
2361
htFake :: String
2362
htFake = Types.hypervisorToRaw Fake
2363

    
2364
htXenHvm :: String
2365
htXenHvm = Types.hypervisorToRaw XenHvm
2366

    
2367
htKvm :: String
2368
htKvm = Types.hypervisorToRaw Kvm
2369

    
2370
htChroot :: String
2371
htChroot = Types.hypervisorToRaw Chroot
2372

    
2373
htLxc :: String
2374
htLxc = Types.hypervisorToRaw Lxc
2375

    
2376
hyperTypes :: FrozenSet String
2377
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2378

    
2379
htsReqPort :: FrozenSet String
2380
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2381

    
2382
vncBasePort :: Int
2383
vncBasePort = 5900
2384

    
2385
vncDefaultBindAddress :: String
2386
vncDefaultBindAddress = ip4AddressAny
2387

    
2388
-- * NIC types
2389

    
2390
htNicE1000 :: String
2391
htNicE1000 = "e1000"
2392

    
2393
htNicI82551 :: String
2394
htNicI82551 = "i82551"
2395

    
2396
htNicI8259er :: String
2397
htNicI8259er = "i82559er"
2398

    
2399
htNicI85557b :: String
2400
htNicI85557b = "i82557b"
2401

    
2402
htNicNe2kIsa :: String
2403
htNicNe2kIsa = "ne2k_isa"
2404

    
2405
htNicNe2kPci :: String
2406
htNicNe2kPci = "ne2k_pci"
2407

    
2408
htNicParavirtual :: String
2409
htNicParavirtual = "paravirtual"
2410

    
2411
htNicPcnet :: String
2412
htNicPcnet = "pcnet"
2413

    
2414
htNicRtl8139 :: String
2415
htNicRtl8139 = "rtl8139"
2416

    
2417
htHvmValidNicTypes :: FrozenSet String
2418
htHvmValidNicTypes =
2419
  ConstantUtils.mkSet [htNicE1000,
2420
                       htNicNe2kIsa,
2421
                       htNicNe2kPci,
2422
                       htNicParavirtual,
2423
                       htNicRtl8139]
2424

    
2425
htKvmValidNicTypes :: FrozenSet String
2426
htKvmValidNicTypes =
2427
  ConstantUtils.mkSet [htNicE1000,
2428
                       htNicI82551,
2429
                       htNicI8259er,
2430
                       htNicI85557b,
2431
                       htNicNe2kIsa,
2432
                       htNicNe2kPci,
2433
                       htNicParavirtual,
2434
                       htNicPcnet,
2435
                       htNicRtl8139]
2436

    
2437
-- * Vif types
2438

    
2439
-- | Default vif type in xen-hvm
2440
htHvmVifIoemu :: String
2441
htHvmVifIoemu = "ioemu"
2442

    
2443
htHvmVifVif :: String
2444
htHvmVifVif = "vif"
2445

    
2446
htHvmValidVifTypes :: FrozenSet String
2447
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2448

    
2449
-- * Disk types
2450

    
2451
htDiskIde :: String
2452
htDiskIde = "ide"
2453

    
2454
htDiskIoemu :: String
2455
htDiskIoemu = "ioemu"
2456

    
2457
htDiskMtd :: String
2458
htDiskMtd = "mtd"
2459

    
2460
htDiskParavirtual :: String
2461
htDiskParavirtual = "paravirtual"
2462

    
2463
htDiskPflash :: String
2464
htDiskPflash = "pflash"
2465

    
2466
htDiskScsi :: String
2467
htDiskScsi = "scsi"
2468

    
2469
htDiskSd :: String
2470
htDiskSd = "sd"
2471

    
2472
htHvmValidDiskTypes :: FrozenSet String
2473
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2474

    
2475
htKvmValidDiskTypes :: FrozenSet String
2476
htKvmValidDiskTypes =
2477
  ConstantUtils.mkSet [htDiskIde,
2478
                       htDiskMtd,
2479
                       htDiskParavirtual,
2480
                       htDiskPflash,
2481
                       htDiskScsi,
2482
                       htDiskSd]
2483

    
2484
htCacheDefault :: String
2485
htCacheDefault = "default"
2486

    
2487
htCacheNone :: String
2488
htCacheNone = "none"
2489

    
2490
htCacheWback :: String
2491
htCacheWback = "writeback"
2492

    
2493
htCacheWthrough :: String
2494
htCacheWthrough = "writethrough"
2495

    
2496
htValidCacheTypes :: FrozenSet String
2497
htValidCacheTypes =
2498
  ConstantUtils.mkSet [htCacheDefault,
2499
                       htCacheNone,
2500
                       htCacheWback,
2501
                       htCacheWthrough]
2502

    
2503
-- * Mouse types
2504

    
2505
htMouseMouse :: String
2506
htMouseMouse = "mouse"
2507

    
2508
htMouseTablet :: String
2509
htMouseTablet = "tablet"
2510

    
2511
htKvmValidMouseTypes :: FrozenSet String
2512
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2513

    
2514
-- * Boot order
2515

    
2516
htBoCdrom :: String
2517
htBoCdrom = "cdrom"
2518

    
2519
htBoDisk :: String
2520
htBoDisk = "disk"
2521

    
2522
htBoFloppy :: String
2523
htBoFloppy = "floppy"
2524

    
2525
htBoNetwork :: String
2526
htBoNetwork = "network"
2527

    
2528
htKvmValidBoTypes :: FrozenSet String
2529
htKvmValidBoTypes =
2530
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2531

    
2532
-- * SPICE lossless image compression options
2533

    
2534
htKvmSpiceLosslessImgComprAutoGlz :: String
2535
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2536

    
2537
htKvmSpiceLosslessImgComprAutoLz :: String
2538
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2539

    
2540
htKvmSpiceLosslessImgComprGlz :: String
2541
htKvmSpiceLosslessImgComprGlz = "glz"
2542

    
2543
htKvmSpiceLosslessImgComprLz :: String
2544
htKvmSpiceLosslessImgComprLz = "lz"
2545

    
2546
htKvmSpiceLosslessImgComprOff :: String
2547
htKvmSpiceLosslessImgComprOff = "off"
2548

    
2549
htKvmSpiceLosslessImgComprQuic :: String
2550
htKvmSpiceLosslessImgComprQuic = "quic"
2551

    
2552
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2553
htKvmSpiceValidLosslessImgComprOptions =
2554
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2555
                       htKvmSpiceLosslessImgComprAutoLz,
2556
                       htKvmSpiceLosslessImgComprGlz,
2557
                       htKvmSpiceLosslessImgComprLz,
2558
                       htKvmSpiceLosslessImgComprOff,
2559
                       htKvmSpiceLosslessImgComprQuic]
2560

    
2561
htKvmSpiceLossyImgComprAlways :: String
2562
htKvmSpiceLossyImgComprAlways = "always"
2563

    
2564
htKvmSpiceLossyImgComprAuto :: String
2565
htKvmSpiceLossyImgComprAuto = "auto"
2566

    
2567
htKvmSpiceLossyImgComprNever :: String
2568
htKvmSpiceLossyImgComprNever = "never"
2569

    
2570
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2571
htKvmSpiceValidLossyImgComprOptions =
2572
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2573
                       htKvmSpiceLossyImgComprAuto,
2574
                       htKvmSpiceLossyImgComprNever]
2575

    
2576
-- * SPICE video stream detection
2577

    
2578
htKvmSpiceVideoStreamDetectionAll :: String
2579
htKvmSpiceVideoStreamDetectionAll = "all"
2580

    
2581
htKvmSpiceVideoStreamDetectionFilter :: String
2582
htKvmSpiceVideoStreamDetectionFilter = "filter"
2583

    
2584
htKvmSpiceVideoStreamDetectionOff :: String
2585
htKvmSpiceVideoStreamDetectionOff = "off"
2586

    
2587
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2588
htKvmSpiceValidVideoStreamDetectionOptions =
2589
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2590
                       htKvmSpiceVideoStreamDetectionFilter,
2591
                       htKvmSpiceVideoStreamDetectionOff]
2592

    
2593
-- * Security models
2594

    
2595
htSmNone :: String
2596
htSmNone = "none"
2597

    
2598
htSmPool :: String
2599
htSmPool = "pool"
2600

    
2601
htSmUser :: String
2602
htSmUser = "user"
2603

    
2604
htKvmValidSmTypes :: FrozenSet String
2605
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2606

    
2607
-- * Kvm flag values
2608

    
2609
htKvmDisabled :: String
2610
htKvmDisabled = "disabled"
2611

    
2612
htKvmEnabled :: String
2613
htKvmEnabled = "enabled"
2614

    
2615
htKvmFlagValues :: FrozenSet String
2616
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2617

    
2618
-- * Migration type
2619

    
2620
htMigrationLive :: String
2621
htMigrationLive = Types.migrationModeToRaw MigrationLive
2622

    
2623
htMigrationNonlive :: String
2624
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2625

    
2626
htMigrationModes :: FrozenSet String
2627
htMigrationModes =
2628
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2629

    
2630
-- * Cluster verify steps
2631

    
2632
verifyNplusoneMem :: String
2633
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2634

    
2635
verifyOptionalChecks :: FrozenSet String
2636
verifyOptionalChecks =
2637
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2638

    
2639
-- * Cluster Verify error classes
2640

    
2641
cvTcluster :: String
2642
cvTcluster = "cluster"
2643

    
2644
cvTgroup :: String
2645
cvTgroup = "group"
2646

    
2647
cvTnode :: String
2648
cvTnode = "node"
2649

    
2650
cvTinstance :: String
2651
cvTinstance = "instance"
2652

    
2653
-- * Cluster Verify error codes and documentation
2654

    
2655
cvEclustercert :: (String, String, String)
2656
cvEclustercert =
2657
  ("cluster",
2658
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2659
   "Cluster certificate files verification failure")
2660

    
2661
cvEclustercfg :: (String, String, String)
2662
cvEclustercfg =
2663
  ("cluster",
2664
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2665
   "Cluster configuration verification failure")
2666

    
2667
cvEclusterdanglinginst :: (String, String, String)
2668
cvEclusterdanglinginst =
2669
  ("node",
2670
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2671
   "Some instances have a non-existing primary node")
2672

    
2673
cvEclusterdanglingnodes :: (String, String, String)
2674
cvEclusterdanglingnodes =
2675
  ("node",
2676
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2677
   "Some nodes belong to non-existing groups")
2678

    
2679
cvEclusterfilecheck :: (String, String, String)
2680
cvEclusterfilecheck =
2681
  ("cluster",
2682
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2683
   "Cluster configuration verification failure")
2684

    
2685
cvEgroupdifferentpvsize :: (String, String, String)
2686
cvEgroupdifferentpvsize =
2687
  ("group",
2688
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2689
   "PVs in the group have different sizes")
2690

    
2691
cvEinstancebadnode :: (String, String, String)
2692
cvEinstancebadnode =
2693
  ("instance",
2694
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2695
   "Instance marked as running lives on an offline node")
2696

    
2697
cvEinstancedown :: (String, String, String)
2698
cvEinstancedown =
2699
  ("instance",
2700
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2701
   "Instance not running on its primary node")
2702

    
2703
cvEinstancefaultydisk :: (String, String, String)
2704
cvEinstancefaultydisk =
2705
  ("instance",
2706
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2707
   "Impossible to retrieve status for a disk")
2708

    
2709
cvEinstancelayout :: (String, String, String)
2710
cvEinstancelayout =
2711
  ("instance",
2712
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2713
   "Instance has multiple secondary nodes")
2714

    
2715
cvEinstancemissingcfgparameter :: (String, String, String)
2716
cvEinstancemissingcfgparameter =
2717
  ("instance",
2718
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2719
   "A configuration parameter for an instance is missing")
2720

    
2721
cvEinstancemissingdisk :: (String, String, String)
2722
cvEinstancemissingdisk =
2723
  ("instance",
2724
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2725
   "Missing volume on an instance")
2726

    
2727
cvEinstancepolicy :: (String, String, String)
2728
cvEinstancepolicy =
2729
  ("instance",
2730
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2731
   "Instance does not meet policy")
2732

    
2733
cvEinstancesplitgroups :: (String, String, String)
2734
cvEinstancesplitgroups =
2735
  ("instance",
2736
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2737
   "Instance with primary and secondary nodes in different groups")
2738

    
2739
cvEinstanceunsuitablenode :: (String, String, String)
2740
cvEinstanceunsuitablenode =
2741
  ("instance",
2742
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2743
   "Instance running on nodes that are not suitable for it")
2744

    
2745
cvEinstancewrongnode :: (String, String, String)
2746
cvEinstancewrongnode =
2747
  ("instance",
2748
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2749
   "Instance running on the wrong node")
2750

    
2751
cvEnodedrbd :: (String, String, String)
2752
cvEnodedrbd =
2753
  ("node",
2754
   Types.cVErrorCodeToRaw CvENODEDRBD,
2755
   "Error parsing the DRBD status file")
2756

    
2757
cvEnodedrbdhelper :: (String, String, String)
2758
cvEnodedrbdhelper =
2759
  ("node",
2760
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2761
   "Error caused by the DRBD helper")
2762

    
2763
cvEnodedrbdversion :: (String, String, String)
2764
cvEnodedrbdversion =
2765
  ("node",
2766
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2767
   "DRBD version mismatch within a node group")
2768

    
2769
cvEnodefilecheck :: (String, String, String)
2770
cvEnodefilecheck =
2771
  ("node",
2772
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2773
   "Error retrieving the checksum of the node files")
2774

    
2775
cvEnodefilestoragepaths :: (String, String, String)
2776
cvEnodefilestoragepaths =
2777
  ("node",
2778
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2779
   "Detected bad file storage paths")
2780

    
2781
cvEnodefilestoragepathunusable :: (String, String, String)
2782
cvEnodefilestoragepathunusable =
2783
  ("node",
2784
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2785
   "File storage path unusable")
2786

    
2787
cvEnodehooks :: (String, String, String)
2788
cvEnodehooks =
2789
  ("node",
2790
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2791
   "Communication failure in hooks execution")
2792

    
2793
cvEnodehv :: (String, String, String)
2794
cvEnodehv =
2795
  ("node",
2796
   Types.cVErrorCodeToRaw CvENODEHV,
2797
   "Hypervisor parameters verification failure")
2798

    
2799
cvEnodelvm :: (String, String, String)
2800
cvEnodelvm =
2801
  ("node",
2802
   Types.cVErrorCodeToRaw CvENODELVM,
2803
   "LVM-related node error")
2804

    
2805
cvEnoden1 :: (String, String, String)
2806
cvEnoden1 =
2807
  ("node",
2808
   Types.cVErrorCodeToRaw CvENODEN1,
2809
   "Not enough memory to accommodate instance failovers")
2810

    
2811
cvEnodenet :: (String, String, String)
2812
cvEnodenet =
2813
  ("node",
2814
   Types.cVErrorCodeToRaw CvENODENET,
2815
   "Network-related node error")
2816

    
2817
cvEnodeoobpath :: (String, String, String)
2818
cvEnodeoobpath =
2819
  ("node",
2820
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2821
   "Invalid Out Of Band path")
2822

    
2823
cvEnodeorphaninstance :: (String, String, String)
2824
cvEnodeorphaninstance =
2825
  ("node",
2826
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2827
   "Unknown intance running on a node")
2828

    
2829
cvEnodeorphanlv :: (String, String, String)
2830
cvEnodeorphanlv =
2831
  ("node",
2832
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2833
   "Unknown LVM logical volume")
2834

    
2835
cvEnodeos :: (String, String, String)
2836
cvEnodeos =
2837
  ("node",
2838
   Types.cVErrorCodeToRaw CvENODEOS,
2839
   "OS-related node error")
2840

    
2841
cvEnoderpc :: (String, String, String)
2842
cvEnoderpc =
2843
  ("node",
2844
   Types.cVErrorCodeToRaw CvENODERPC,
2845
   "Error during connection to the primary node of an instance")
2846

    
2847
cvEnodesetup :: (String, String, String)
2848
cvEnodesetup =
2849
  ("node",
2850
   Types.cVErrorCodeToRaw CvENODESETUP,
2851
   "Node setup error")
2852

    
2853
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2854
cvEnodesharedfilestoragepathunusable =
2855
  ("node",
2856
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2857
   "Shared file storage path unusable")
2858

    
2859
cvEnodessh :: (String, String, String)
2860
cvEnodessh =
2861
  ("node",
2862
   Types.cVErrorCodeToRaw CvENODESSH,
2863
   "SSH-related node error")
2864

    
2865
cvEnodetime :: (String, String, String)
2866
cvEnodetime =
2867
  ("node",
2868
   Types.cVErrorCodeToRaw CvENODETIME,
2869
   "Node returned invalid time")
2870

    
2871
cvEnodeuserscripts :: (String, String, String)
2872
cvEnodeuserscripts =
2873
  ("node",
2874
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2875
   "User scripts not present or not executable")
2876

    
2877
cvEnodeversion :: (String, String, String)
2878
cvEnodeversion =
2879
  ("node",
2880
   Types.cVErrorCodeToRaw CvENODEVERSION,
2881
   "Protocol version mismatch or Ganeti version mismatch")
2882

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

    
2925
cvAllEcodesStrings :: FrozenSet String
2926
cvAllEcodesStrings =
2927
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2928

    
2929
-- * Node verify constants
2930

    
2931
nvBridges :: String
2932
nvBridges = "bridges"
2933

    
2934
nvDrbdhelper :: String
2935
nvDrbdhelper = "drbd-helper"
2936

    
2937
nvDrbdversion :: String
2938
nvDrbdversion = "drbd-version"
2939

    
2940
nvDrbdlist :: String
2941
nvDrbdlist = "drbd-list"
2942

    
2943
nvExclusivepvs :: String
2944
nvExclusivepvs = "exclusive-pvs"
2945

    
2946
nvFilelist :: String
2947
nvFilelist = "filelist"
2948

    
2949
nvAcceptedStoragePaths :: String
2950
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2951

    
2952
nvFileStoragePath :: String
2953
nvFileStoragePath = "file-storage-path"
2954

    
2955
nvSharedFileStoragePath :: String
2956
nvSharedFileStoragePath = "shared-file-storage-path"
2957

    
2958
nvHvinfo :: String
2959
nvHvinfo = "hvinfo"
2960

    
2961
nvHvparams :: String
2962
nvHvparams = "hvparms"
2963

    
2964
nvHypervisor :: String
2965
nvHypervisor = "hypervisor"
2966

    
2967
nvInstancelist :: String
2968
nvInstancelist = "instancelist"
2969

    
2970
nvLvlist :: String
2971
nvLvlist = "lvlist"
2972

    
2973
nvMasterip :: String
2974
nvMasterip = "master-ip"
2975

    
2976
nvNodelist :: String
2977
nvNodelist = "nodelist"
2978

    
2979
nvNodenettest :: String
2980
nvNodenettest = "node-net-test"
2981

    
2982
nvNodesetup :: String
2983
nvNodesetup = "nodesetup"
2984

    
2985
nvOobPaths :: String
2986
nvOobPaths = "oob-paths"
2987

    
2988
nvOslist :: String
2989
nvOslist = "oslist"
2990

    
2991
nvPvlist :: String
2992
nvPvlist = "pvlist"
2993

    
2994
nvTime :: String
2995
nvTime = "time"
2996

    
2997
nvUserscripts :: String
2998
nvUserscripts = "user-scripts"
2999

    
3000
nvVersion :: String
3001
nvVersion = "version"
3002

    
3003
nvVglist :: String
3004
nvVglist = "vglist"
3005

    
3006
nvVmnodes :: String
3007
nvVmnodes = "vmnodes"
3008

    
3009
-- * Instance status
3010

    
3011
inststAdmindown :: String
3012
inststAdmindown = Types.instanceStatusToRaw StatusDown
3013

    
3014
inststAdminoffline :: String
3015
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3016

    
3017
inststErrordown :: String
3018
inststErrordown = Types.instanceStatusToRaw ErrorDown
3019

    
3020
inststErrorup :: String
3021
inststErrorup = Types.instanceStatusToRaw ErrorUp
3022

    
3023
inststNodedown :: String
3024
inststNodedown = Types.instanceStatusToRaw NodeDown
3025

    
3026
inststNodeoffline :: String
3027
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3028

    
3029
inststRunning :: String
3030
inststRunning = Types.instanceStatusToRaw Running
3031

    
3032
inststUserdown :: String
3033
inststUserdown = Types.instanceStatusToRaw UserDown
3034

    
3035
inststWrongnode :: String
3036
inststWrongnode = Types.instanceStatusToRaw WrongNode
3037

    
3038
inststAll :: FrozenSet String
3039
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3040

    
3041
-- * Admin states
3042

    
3043
adminstDown :: String
3044
adminstDown = Types.adminStateToRaw AdminDown
3045

    
3046
adminstOffline :: String
3047
adminstOffline = Types.adminStateToRaw AdminOffline
3048

    
3049
adminstUp :: String
3050
adminstUp = Types.adminStateToRaw AdminUp
3051

    
3052
adminstAll :: FrozenSet String
3053
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3054

    
3055
-- * Node roles
3056

    
3057
nrDrained :: String
3058
nrDrained = Types.nodeRoleToRaw NRDrained
3059

    
3060
nrMaster :: String
3061
nrMaster = Types.nodeRoleToRaw NRMaster
3062

    
3063
nrMcandidate :: String
3064
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3065

    
3066
nrOffline :: String
3067
nrOffline = Types.nodeRoleToRaw NROffline
3068

    
3069
nrRegular :: String
3070
nrRegular = Types.nodeRoleToRaw NRRegular
3071

    
3072
nrAll :: FrozenSet String
3073
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3074

    
3075
-- * SSL certificate check constants (in days)
3076

    
3077
sslCertExpirationError :: Int
3078
sslCertExpirationError = 7
3079

    
3080
sslCertExpirationWarn :: Int
3081
sslCertExpirationWarn = 30
3082

    
3083
-- * Allocator framework constants
3084

    
3085
iallocatorVersion :: Int
3086
iallocatorVersion = 2
3087

    
3088
iallocatorDirIn :: String
3089
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3090

    
3091
iallocatorDirOut :: String
3092
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3093

    
3094
validIallocatorDirections :: FrozenSet String
3095
validIallocatorDirections =
3096
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3097

    
3098
iallocatorModeAlloc :: String
3099
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3100

    
3101
iallocatorModeChgGroup :: String
3102
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3103

    
3104
iallocatorModeMultiAlloc :: String
3105
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3106

    
3107
iallocatorModeNodeEvac :: String
3108
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3109

    
3110
iallocatorModeReloc :: String
3111
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3112

    
3113
validIallocatorModes :: FrozenSet String
3114
validIallocatorModes =
3115
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3116

    
3117
iallocatorSearchPath :: [String]
3118
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3119

    
3120
defaultIallocatorShortcut :: String
3121
defaultIallocatorShortcut = "."
3122

    
3123
-- * Node evacuation
3124

    
3125
nodeEvacPri :: String
3126
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3127

    
3128
nodeEvacSec :: String
3129
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3130

    
3131
nodeEvacAll :: String
3132
nodeEvacAll = Types.evacModeToRaw ChangeAll
3133

    
3134
nodeEvacModes :: FrozenSet String
3135
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3136

    
3137
-- * Job queue
3138

    
3139
jobQueueVersion :: Int
3140
jobQueueVersion = 1
3141

    
3142
jobQueueSizeHardLimit :: Int
3143
jobQueueSizeHardLimit = 5000
3144

    
3145
jobQueueFilesPerms :: Int
3146
jobQueueFilesPerms = 0o640
3147

    
3148
-- * Unchanged job return
3149

    
3150
jobNotchanged :: String
3151
jobNotchanged = "nochange"
3152

    
3153
-- * Job status
3154

    
3155
jobStatusQueued :: String
3156
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3157

    
3158
jobStatusWaiting :: String
3159
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3160

    
3161
jobStatusCanceling :: String
3162
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3163

    
3164
jobStatusRunning :: String
3165
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3166

    
3167
jobStatusCanceled :: String
3168
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3169

    
3170
jobStatusSuccess :: String
3171
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3172

    
3173
jobStatusError :: String
3174
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3175

    
3176
jobsPending :: FrozenSet String
3177
jobsPending =
3178
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3179

    
3180
jobsFinalized :: FrozenSet String
3181
jobsFinalized =
3182
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3183

    
3184
jobStatusAll :: FrozenSet String
3185
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3186

    
3187
-- * OpCode status
3188

    
3189
-- ** Not yet finalized opcodes
3190

    
3191
opStatusCanceling :: String
3192
opStatusCanceling = "canceling"
3193

    
3194
opStatusQueued :: String
3195
opStatusQueued = "queued"
3196

    
3197
opStatusRunning :: String
3198
opStatusRunning = "running"
3199

    
3200
opStatusWaiting :: String
3201
opStatusWaiting = "waiting"
3202

    
3203
-- ** Finalized opcodes
3204

    
3205
opStatusCanceled :: String
3206
opStatusCanceled = "canceled"
3207

    
3208
opStatusError :: String
3209
opStatusError = "error"
3210

    
3211
opStatusSuccess :: String
3212
opStatusSuccess = "success"
3213

    
3214
opsFinalized :: FrozenSet String
3215
opsFinalized =
3216
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3217

    
3218
-- * OpCode priority
3219

    
3220
opPrioLowest :: Int
3221
opPrioLowest = 19
3222

    
3223
opPrioHighest :: Int
3224
opPrioHighest = -20
3225

    
3226
opPrioLow :: Int
3227
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3228

    
3229
opPrioNormal :: Int
3230
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3231

    
3232
opPrioHigh :: Int
3233
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3234

    
3235
opPrioSubmitValid :: FrozenSet Int
3236
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3237

    
3238
opPrioDefault :: Int
3239
opPrioDefault = opPrioNormal
3240

    
3241
-- * Lock recalculate mode
3242

    
3243
locksAppend :: String
3244
locksAppend = "append"
3245

    
3246
locksReplace :: String
3247
locksReplace = "replace"
3248

    
3249
-- * Lock timeout
3250
--
3251
-- The lock timeout (sum) before we transition into blocking acquire
3252
-- (this can still be reset by priority change).  Computed as max time
3253
-- (10 hours) before we should actually go into blocking acquire,
3254
-- given that we start from the default priority level.
3255

    
3256
lockAttemptsMaxwait :: Double
3257
lockAttemptsMaxwait = 15.0
3258

    
3259
lockAttemptsMinwait :: Double
3260
lockAttemptsMinwait = 1.0
3261

    
3262
lockAttemptsTimeout :: Int
3263
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3264

    
3265
-- * Execution log types
3266

    
3267
elogMessage :: String
3268
elogMessage = Types.eLogTypeToRaw ELogMessage
3269

    
3270
elogRemoteImport :: String
3271
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3272

    
3273
elogJqueueTest :: String
3274
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3275

    
3276
-- * /etc/hosts modification
3277

    
3278
etcHostsAdd :: String
3279
etcHostsAdd = "add"
3280

    
3281
etcHostsRemove :: String
3282
etcHostsRemove = "remove"
3283

    
3284
-- * Job queue test
3285

    
3286
jqtMsgprefix :: String
3287
jqtMsgprefix = "TESTMSG="
3288

    
3289
jqtExec :: String
3290
jqtExec = "exec"
3291

    
3292
jqtExpandnames :: String
3293
jqtExpandnames = "expandnames"
3294

    
3295
jqtLogmsg :: String
3296
jqtLogmsg = "logmsg"
3297

    
3298
jqtStartmsg :: String
3299
jqtStartmsg = "startmsg"
3300

    
3301
jqtAll :: FrozenSet String
3302
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3303

    
3304
-- * Query resources
3305

    
3306
qrCluster :: String
3307
qrCluster = "cluster"
3308

    
3309
qrExport :: String
3310
qrExport = "export"
3311

    
3312
qrExtstorage :: String
3313
qrExtstorage = "extstorage"
3314

    
3315
qrGroup :: String
3316
qrGroup = "group"
3317

    
3318
qrInstance :: String
3319
qrInstance = "instance"
3320

    
3321
qrJob :: String
3322
qrJob = "job"
3323

    
3324
qrLock :: String
3325
qrLock = "lock"
3326

    
3327
qrNetwork :: String
3328
qrNetwork = "network"
3329

    
3330
qrNode :: String
3331
qrNode = "node"
3332

    
3333
qrOs :: String
3334
qrOs = "os"
3335

    
3336
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3337
qrViaOp :: FrozenSet String
3338
qrViaOp =
3339
  ConstantUtils.mkSet [qrCluster,
3340
                       qrInstance,
3341
                       qrNode,
3342
                       qrGroup,
3343
                       qrOs,
3344
                       qrExport,
3345
                       qrNetwork,
3346
                       qrExtstorage]
3347

    
3348
-- | List of resources which can be queried using Local UniX Interface
3349
qrViaLuxi :: FrozenSet String
3350
qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob]
3351

    
3352
-- | List of resources which can be queried using RAPI
3353
qrViaRapi :: FrozenSet String
3354
qrViaRapi = qrViaLuxi
3355

    
3356
-- * Query field types
3357

    
3358
qftBool :: String
3359
qftBool = "bool"
3360

    
3361
qftNumber :: String
3362
qftNumber = "number"
3363

    
3364
qftOther :: String
3365
qftOther = "other"
3366

    
3367
qftText :: String
3368
qftText = "text"
3369

    
3370
qftTimestamp :: String
3371
qftTimestamp = "timestamp"
3372

    
3373
qftUnit :: String
3374
qftUnit = "unit"
3375

    
3376
qftUnknown :: String
3377
qftUnknown = "unknown"
3378

    
3379
qftAll :: FrozenSet String
3380
qftAll =
3381
  ConstantUtils.mkSet [qftBool,
3382
                       qftNumber,
3383
                       qftOther,
3384
                       qftText,
3385
                       qftTimestamp,
3386
                       qftUnit,
3387
                       qftUnknown]
3388

    
3389
-- * Query result field status
3390
--
3391
-- Don't change or reuse values as they're used by clients.
3392
--
3393
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3394

    
3395
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3396
rsNodata :: Int
3397
rsNodata = 2
3398

    
3399
rsNormal :: Int
3400
rsNormal = 0
3401

    
3402
-- | Resource marked offline
3403
rsOffline :: Int
3404
rsOffline = 4
3405

    
3406
-- | Value unavailable/unsupported for item; if this field is
3407
-- supported but we cannot get the data for the moment, 'rsNodata' or
3408
-- 'rsOffline' should be used
3409
rsUnavail :: Int
3410
rsUnavail = 3
3411

    
3412
rsUnknown :: Int
3413
rsUnknown = 1
3414

    
3415
rsAll :: FrozenSet Int
3416
rsAll =
3417
  ConstantUtils.mkSet [rsNodata,
3418
                       rsNormal,
3419
                       rsOffline,
3420
                       rsUnavail,
3421
                       rsUnknown]
3422

    
3423
-- | Special field cases and their verbose/terse formatting
3424
rssDescription :: Map Int (String, String)
3425
rssDescription =
3426
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3427
                (rsNodata, ("(nodata)", "?")),
3428
                (rsOffline, ("(offline)", "*")),
3429
                (rsUnavail, ("(unavail)", "-"))]
3430

    
3431
-- * Max dynamic devices
3432

    
3433
maxDisks :: Int
3434
maxDisks = Types.maxDisks
3435

    
3436
maxNics :: Int
3437
maxNics = Types.maxNics
3438

    
3439
-- | SSCONF file prefix
3440
ssconfFileprefix :: String
3441
ssconfFileprefix = "ssconf_"
3442

    
3443
-- * SSCONF keys
3444

    
3445
ssClusterName :: String
3446
ssClusterName = "cluster_name"
3447

    
3448
ssClusterTags :: String
3449
ssClusterTags = "cluster_tags"
3450

    
3451
ssFileStorageDir :: String
3452
ssFileStorageDir = "file_storage_dir"
3453

    
3454
ssSharedFileStorageDir :: String
3455
ssSharedFileStorageDir = "shared_file_storage_dir"
3456

    
3457
ssMasterCandidates :: String
3458
ssMasterCandidates = "master_candidates"
3459

    
3460
ssMasterCandidatesIps :: String
3461
ssMasterCandidatesIps = "master_candidates_ips"
3462

    
3463
ssMasterIp :: String
3464
ssMasterIp = "master_ip"
3465

    
3466
ssMasterNetdev :: String
3467
ssMasterNetdev = "master_netdev"
3468

    
3469
ssMasterNetmask :: String
3470
ssMasterNetmask = "master_netmask"
3471

    
3472
ssMasterNode :: String
3473
ssMasterNode = "master_node"
3474

    
3475
ssNodeList :: String
3476
ssNodeList = "node_list"
3477

    
3478
ssNodePrimaryIps :: String
3479
ssNodePrimaryIps = "node_primary_ips"
3480

    
3481
ssNodeSecondaryIps :: String
3482
ssNodeSecondaryIps = "node_secondary_ips"
3483

    
3484
ssOfflineNodes :: String
3485
ssOfflineNodes = "offline_nodes"
3486

    
3487
ssOnlineNodes :: String
3488
ssOnlineNodes = "online_nodes"
3489

    
3490
ssPrimaryIpFamily :: String
3491
ssPrimaryIpFamily = "primary_ip_family"
3492

    
3493
ssInstanceList :: String
3494
ssInstanceList = "instance_list"
3495

    
3496
ssReleaseVersion :: String
3497
ssReleaseVersion = "release_version"
3498

    
3499
ssHypervisorList :: String
3500
ssHypervisorList = "hypervisor_list"
3501

    
3502
ssMaintainNodeHealth :: String
3503
ssMaintainNodeHealth = "maintain_node_health"
3504

    
3505
ssUidPool :: String
3506
ssUidPool = "uid_pool"
3507

    
3508
ssNodegroups :: String
3509
ssNodegroups = "nodegroups"
3510

    
3511
ssNetworks :: String
3512
ssNetworks = "networks"
3513

    
3514
-- | This is not a complete SSCONF key, but the prefix for the
3515
-- hypervisor keys
3516
ssHvparamsPref :: String
3517
ssHvparamsPref = "hvparams_"
3518

    
3519
-- * Hvparams keys
3520

    
3521
ssHvparamsXenChroot :: String
3522
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3523

    
3524
ssHvparamsXenFake :: String
3525
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3526

    
3527
ssHvparamsXenHvm :: String
3528
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3529

    
3530
ssHvparamsXenKvm :: String
3531
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3532

    
3533
ssHvparamsXenLxc :: String
3534
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3535

    
3536
ssHvparamsXenPvm :: String
3537
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3538

    
3539
validSsHvparamsKeys :: FrozenSet String
3540
validSsHvparamsKeys =
3541
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3542
                       ssHvparamsXenLxc,
3543
                       ssHvparamsXenFake,
3544
                       ssHvparamsXenHvm,
3545
                       ssHvparamsXenKvm,
3546
                       ssHvparamsXenPvm]
3547

    
3548
ssFilePerms :: Int
3549
ssFilePerms = 0o444
3550

    
3551
-- | Cluster wide default parameters
3552
defaultEnabledHypervisor :: String
3553
defaultEnabledHypervisor = htXenPvm
3554

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

    
3667
hvcGlobals :: FrozenSet String
3668
hvcGlobals =
3669
  ConstantUtils.mkSet [hvMigrationBandwidth,
3670
                       hvMigrationMode,
3671
                       hvMigrationPort,
3672
                       hvXenCmd]
3673

    
3674
becDefaults :: Map String PyValueEx
3675
becDefaults =
3676
  Map.fromList
3677
  [ (beMinmem, PyValueEx (128 :: Int))
3678
  , (beMaxmem, PyValueEx (128 :: Int))
3679
  , (beVcpus, PyValueEx (1 :: Int))
3680
  , (beAutoBalance, PyValueEx True)
3681
  , (beAlwaysFailover, PyValueEx False)
3682
  , (beSpindleUse, PyValueEx (1 :: Int))
3683
  ]
3684

    
3685
ndcDefaults :: Map String PyValueEx
3686
ndcDefaults =
3687
  Map.fromList
3688
  [ (ndOobProgram,       PyValueEx "")
3689
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3690
  , (ndExclusiveStorage, PyValueEx False)
3691
  , (ndOvs,              PyValueEx False)
3692
  , (ndOvsName,          PyValueEx defaultOvs)
3693
  , (ndOvsLink,          PyValueEx "")
3694
  , (ndSshPort,          PyValueEx (22 :: Int))
3695
  ]
3696

    
3697
ndcGlobals :: FrozenSet String
3698
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3699

    
3700
-- | Default delay target measured in sectors
3701
defaultDelayTarget :: Int
3702
defaultDelayTarget = 1
3703

    
3704
defaultDiskCustom :: String
3705
defaultDiskCustom = ""
3706

    
3707
defaultDiskResync :: Bool
3708
defaultDiskResync = False
3709

    
3710
-- | Default fill target measured in sectors
3711
defaultFillTarget :: Int
3712
defaultFillTarget = 0
3713

    
3714
-- | Default mininum rate measured in KiB/s
3715
defaultMinRate :: Int
3716
defaultMinRate = 4 * 1024
3717

    
3718
defaultNetCustom :: String
3719
defaultNetCustom = ""
3720

    
3721
-- | Default plan ahead measured in sectors
3722
--
3723
-- The default values for the DRBD dynamic resync speed algorithm are
3724
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3725
-- (that we don't need to set to 0, because we have a separate option
3726
-- to enable it) and for c-max-rate, that we cap to the default value
3727
-- for the static resync rate.
3728
defaultPlanAhead :: Int
3729
defaultPlanAhead = 20
3730

    
3731
defaultRbdPool :: String
3732
defaultRbdPool = "rbd"
3733

    
3734
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3735
diskLdDefaults =
3736
  Map.fromList
3737
  [ (DTBlock, Map.empty)
3738
  , (DTDrbd8, Map.fromList
3739
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3740
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3741
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3742
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3743
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3744
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3745
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3746
              , (ldpMinRate,       PyValueEx defaultMinRate)
3747
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3748
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3749
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3750
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3751
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3752
              ])
3753
  , (DTExt, Map.empty)
3754
  , (DTFile, Map.empty)
3755
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3756
  , (DTRbd, Map.fromList
3757
            [ (ldpPool, PyValueEx defaultRbdPool)
3758
            , (ldpAccess, PyValueEx diskKernelspace)
3759
            ])
3760
  , (DTSharedFile, Map.empty)
3761
  ]
3762

    
3763
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3764
diskDtDefaults =
3765
  Map.fromList
3766
  [ (DTBlock,      Map.empty)
3767
  , (DTDiskless,   Map.empty)
3768
  , (DTDrbd8,      Map.fromList
3769
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3770
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3771
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3772
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3773
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3774
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3775
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3776
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3777
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3778
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3779
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3780
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3781
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3782
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3783
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3784
                   ])
3785
  , (DTExt,        Map.empty)
3786
  , (DTFile,       Map.empty)
3787
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3788
  , (DTRbd,        Map.fromList
3789
                   [ (rbdPool, PyValueEx defaultRbdPool)
3790
                   , (rbdAccess, PyValueEx diskKernelspace)
3791
                   ])
3792
  , (DTSharedFile, Map.empty)
3793
  ]
3794

    
3795
niccDefaults :: Map String PyValueEx
3796
niccDefaults =
3797
  Map.fromList
3798
  [ (nicMode, PyValueEx nicModeBridged)
3799
  , (nicLink, PyValueEx defaultBridge)
3800
  , (nicVlan, PyValueEx "")
3801
  ]
3802

    
3803
-- | All of the following values are quite arbitrary - there are no
3804
-- "good" defaults, these must be customised per-site
3805
ispecsMinmaxDefaults :: Map String (Map String Int)
3806
ispecsMinmaxDefaults =
3807
  Map.fromList
3808
  [(ispecsMin,
3809
    Map.fromList
3810
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3811
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3812
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3813
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3814
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3815
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3816
   (ispecsMax,
3817
    Map.fromList
3818
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3819
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3820
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3821
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3822
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3823
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3824

    
3825
ipolicyDefaults :: Map String PyValueEx
3826
ipolicyDefaults =
3827
  Map.fromList
3828
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3829
  , (ispecsStd,           PyValueEx (Map.fromList
3830
                                     [ (ispecMemSize,    128)
3831
                                     , (ispecCpuCount,   1)
3832
                                     , (ispecDiskCount,  1)
3833
                                     , (ispecDiskSize,   1024)
3834
                                     , (ispecNicCount,   1)
3835
                                     , (ispecSpindleUse, 1)
3836
                                     ] :: Map String Int))
3837
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3838
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3839
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3840
  ]
3841

    
3842
masterPoolSizeDefault :: Int
3843
masterPoolSizeDefault = 10
3844

    
3845
-- * Exclusive storage
3846

    
3847
-- | Error margin used to compare physical disks
3848
partMargin :: Double
3849
partMargin = 0.01
3850

    
3851
-- | Space reserved when creating instance disks
3852
partReserved :: Double
3853
partReserved = 0.02
3854

    
3855
-- * Confd
3856

    
3857
confdProtocolVersion :: Int
3858
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3859

    
3860
-- Confd request type
3861

    
3862
confdReqPing :: Int
3863
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3864

    
3865
confdReqNodeRoleByname :: Int
3866
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3867

    
3868
confdReqNodePipByInstanceIp :: Int
3869
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3870

    
3871
confdReqClusterMaster :: Int
3872
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3873

    
3874
confdReqNodePipList :: Int
3875
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3876

    
3877
confdReqMcPipList :: Int
3878
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3879

    
3880
confdReqInstancesIpsList :: Int
3881
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3882

    
3883
confdReqNodeDrbd :: Int
3884
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3885

    
3886
confdReqNodeInstances :: Int
3887
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3888

    
3889
confdReqs :: FrozenSet Int
3890
confdReqs =
3891
  ConstantUtils.mkSet .
3892
  map Types.confdRequestTypeToRaw $
3893
  [minBound..] \\ [ReqNodeInstances]
3894

    
3895
-- * Confd request type
3896

    
3897
confdReqfieldName :: Int
3898
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3899

    
3900
confdReqfieldIp :: Int
3901
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3902

    
3903
confdReqfieldMnodePip :: Int
3904
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3905

    
3906
-- * Confd repl status
3907

    
3908
confdReplStatusOk :: Int
3909
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3910

    
3911
confdReplStatusError :: Int
3912
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3913

    
3914
confdReplStatusNotimplemented :: Int
3915
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3916

    
3917
confdReplStatuses :: FrozenSet Int
3918
confdReplStatuses =
3919
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3920

    
3921
-- * Confd node role
3922

    
3923
confdNodeRoleMaster :: Int
3924
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3925

    
3926
confdNodeRoleCandidate :: Int
3927
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3928

    
3929
confdNodeRoleOffline :: Int
3930
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3931

    
3932
confdNodeRoleDrained :: Int
3933
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3934

    
3935
confdNodeRoleRegular :: Int
3936
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3937

    
3938
-- * A few common errors for confd
3939

    
3940
confdErrorUnknownEntry :: Int
3941
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3942

    
3943
confdErrorInternal :: Int
3944
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3945

    
3946
confdErrorArgument :: Int
3947
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3948

    
3949
-- * Confd request query fields
3950

    
3951
confdReqqLink :: String
3952
confdReqqLink = ConstantUtils.confdReqqLink
3953

    
3954
confdReqqIp :: String
3955
confdReqqIp = ConstantUtils.confdReqqIp
3956

    
3957
confdReqqIplist :: String
3958
confdReqqIplist = ConstantUtils.confdReqqIplist
3959

    
3960
confdReqqFields :: String
3961
confdReqqFields = ConstantUtils.confdReqqFields
3962

    
3963
-- | Each request is "salted" by the current timestamp.
3964
--
3965
-- This constant decides how many seconds of skew to accept.
3966
--
3967
-- TODO: make this a default and allow the value to be more
3968
-- configurable
3969
confdMaxClockSkew :: Int
3970
confdMaxClockSkew = 2 * nodeMaxClockSkew
3971

    
3972
-- | When we haven't reloaded the config for more than this amount of
3973
-- seconds, we force a test to see if inotify is betraying us. Using a
3974
-- prime number to ensure we get less chance of 'same wakeup' with
3975
-- other processes.
3976
confdConfigReloadTimeout :: Int
3977
confdConfigReloadTimeout = 17
3978

    
3979
-- | If we receive more than one update in this amount of
3980
-- microseconds, we move to polling every RATELIMIT seconds, rather
3981
-- than relying on inotify, to be able to serve more requests.
3982
confdConfigReloadRatelimit :: Int
3983
confdConfigReloadRatelimit = 250000
3984

    
3985
-- | Magic number prepended to all confd queries.
3986
--
3987
-- This allows us to distinguish different types of confd protocols
3988
-- and handle them. For example by changing this we can move the whole
3989
-- payload to be compressed, or move away from json.
3990
confdMagicFourcc :: String
3991
confdMagicFourcc = "plj0"
3992

    
3993
-- | By default a confd request is sent to the minimum between this
3994
-- number and all MCs. 6 was chosen because even in the case of a
3995
-- disastrous 50% response rate, we should have enough answers to be
3996
-- able to compare more than one.
3997
confdDefaultReqCoverage :: Int
3998
confdDefaultReqCoverage = 6
3999

    
4000
-- | Timeout in seconds to expire pending query request in the confd
4001
-- client library. We don't actually expect any answer more than 10
4002
-- seconds after we sent a request.
4003
confdClientExpireTimeout :: Int
4004
confdClientExpireTimeout = 10
4005

    
4006
-- | Maximum UDP datagram size.
4007
--
4008
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4009
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4010
--   (assuming we can't use jumbo frames)
4011
-- We just set this to 60K, which should be enough
4012
maxUdpDataSize :: Int
4013
maxUdpDataSize = 61440
4014

    
4015
-- * User-id pool minimum/maximum acceptable user-ids
4016

    
4017
uidpoolUidMin :: Int
4018
uidpoolUidMin = 0
4019

    
4020
-- | Assuming 32 bit user-ids
4021
uidpoolUidMax :: Integer
4022
uidpoolUidMax = 2 ^ 32 - 1
4023

    
4024
-- | Name or path of the pgrep command
4025
pgrep :: String
4026
pgrep = "pgrep"
4027

    
4028
-- | Name of the node group that gets created at cluster init or
4029
-- upgrade
4030
initialNodeGroupName :: String
4031
initialNodeGroupName = "default"
4032

    
4033
-- * Possible values for NodeGroup.alloc_policy
4034

    
4035
allocPolicyLastResort :: String
4036
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4037

    
4038
allocPolicyPreferred :: String
4039
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4040

    
4041
allocPolicyUnallocable :: String
4042
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4043

    
4044
validAllocPolicies :: [String]
4045
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4046

    
4047
-- | Temporary external/shared storage parameters
4048
blockdevDriverManual :: String
4049
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4050

    
4051
-- | 'qemu-img' path, required for 'ovfconverter'
4052
qemuimgPath :: String
4053
qemuimgPath = AutoConf.qemuimgPath
4054

    
4055
-- | Whether htools was enabled at compilation time
4056
--
4057
-- FIXME: this should be moved next to the other enable constants,
4058
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4059
htools :: Bool
4060
htools = AutoConf.htools
4061

    
4062
-- | The hail iallocator
4063
iallocHail :: String
4064
iallocHail = "hail"
4065

    
4066
-- * Fake opcodes for functions that have hooks attached to them via
4067
-- backend.RunLocalHooks
4068

    
4069
fakeOpMasterTurndown :: String
4070
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4071

    
4072
fakeOpMasterTurnup :: String
4073
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4074

    
4075
-- * SSH key types
4076

    
4077
sshkDsa :: String
4078
sshkDsa = "dsa"
4079

    
4080
sshkRsa :: String
4081
sshkRsa = "rsa"
4082

    
4083
sshkAll :: FrozenSet String
4084
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4085

    
4086
-- * SSH authorized key types
4087

    
4088
sshakDss :: String
4089
sshakDss = "ssh-dss"
4090

    
4091
sshakRsa :: String
4092
sshakRsa = "ssh-rsa"
4093

    
4094
sshakAll :: FrozenSet String
4095
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4096

    
4097
-- * SSH setup
4098

    
4099
sshsClusterName :: String
4100
sshsClusterName = "cluster_name"
4101

    
4102
sshsSshHostKey :: String
4103
sshsSshHostKey = "ssh_host_key"
4104

    
4105
sshsSshRootKey :: String
4106
sshsSshRootKey = "ssh_root_key"
4107

    
4108
sshsNodeDaemonCertificate :: String
4109
sshsNodeDaemonCertificate = "node_daemon_certificate"
4110

    
4111
-- * Key files for SSH daemon
4112

    
4113
sshHostDsaPriv :: String
4114
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4115

    
4116
sshHostDsaPub :: String
4117
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4118

    
4119
sshHostRsaPriv :: String
4120
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4121

    
4122
sshHostRsaPub :: String
4123
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4124

    
4125
sshDaemonKeyfiles :: Map String (String, String)
4126
sshDaemonKeyfiles =
4127
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4128
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4129
               ]
4130

    
4131
-- * Node daemon setup
4132

    
4133
ndsClusterName :: String
4134
ndsClusterName = "cluster_name"
4135

    
4136
ndsNodeDaemonCertificate :: String
4137
ndsNodeDaemonCertificate = "node_daemon_certificate"
4138

    
4139
ndsSsconf :: String
4140
ndsSsconf = "ssconf"
4141

    
4142
ndsStartNodeDaemon :: String
4143
ndsStartNodeDaemon = "start_node_daemon"
4144

    
4145
-- * The source reasons for the execution of an OpCode
4146

    
4147
opcodeReasonSrcClient :: String
4148
opcodeReasonSrcClient = "gnt:client"
4149

    
4150
opcodeReasonSrcNoded :: String
4151
opcodeReasonSrcNoded = "gnt:daemon:noded"
4152

    
4153
opcodeReasonSrcOpcode :: String
4154
opcodeReasonSrcOpcode = "gnt:opcode"
4155

    
4156
opcodeReasonSrcRlib2 :: String
4157
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4158

    
4159
opcodeReasonSrcUser :: String
4160
opcodeReasonSrcUser = "gnt:user"
4161

    
4162
opcodeReasonSources :: FrozenSet String
4163
opcodeReasonSources =
4164
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4165
                       opcodeReasonSrcNoded,
4166
                       opcodeReasonSrcOpcode,
4167
                       opcodeReasonSrcRlib2,
4168
                       opcodeReasonSrcUser]
4169

    
4170
-- | Path generating random UUID
4171
randomUuidFile :: String
4172
randomUuidFile = ConstantUtils.randomUuidFile
4173

    
4174
-- * Auto-repair tag prefixes
4175

    
4176
autoRepairTagPrefix :: String
4177
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4178

    
4179
autoRepairTagEnabled :: String
4180
autoRepairTagEnabled = autoRepairTagPrefix
4181

    
4182
autoRepairTagPending :: String
4183
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4184

    
4185
autoRepairTagResult :: String
4186
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4187

    
4188
autoRepairTagSuspended :: String
4189
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4190

    
4191
-- * Auto-repair levels
4192

    
4193
autoRepairFailover :: String
4194
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4195

    
4196
autoRepairFixStorage :: String
4197
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4198

    
4199
autoRepairMigrate :: String
4200
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4201

    
4202
autoRepairReinstall :: String
4203
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4204

    
4205
autoRepairAllTypes :: FrozenSet String
4206
autoRepairAllTypes =
4207
  ConstantUtils.mkSet [autoRepairFailover,
4208
                       autoRepairFixStorage,
4209
                       autoRepairMigrate,
4210
                       autoRepairReinstall]
4211

    
4212
-- * Auto-repair results
4213

    
4214
autoRepairEnoperm :: String
4215
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4216

    
4217
autoRepairFailure :: String
4218
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4219

    
4220
autoRepairSuccess :: String
4221
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4222

    
4223
autoRepairAllResults :: FrozenSet String
4224
autoRepairAllResults =
4225
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4226

    
4227
-- | The version identifier for builtin data collectors
4228
builtinDataCollectorVersion :: String
4229
builtinDataCollectorVersion = "B"
4230

    
4231
-- | The reason trail opcode parameter name
4232
opcodeReason :: String
4233
opcodeReason = "reason"
4234

    
4235
diskstatsFile :: String
4236
diskstatsFile = "/proc/diskstats"
4237

    
4238
-- *  CPU load collector
4239

    
4240
statFile :: String
4241
statFile = "/proc/stat"
4242

    
4243
cpuavgloadBufferSize :: Int
4244
cpuavgloadBufferSize = 150
4245

    
4246
cpuavgloadWindowSize :: Int
4247
cpuavgloadWindowSize = 600
4248

    
4249
-- * Monitoring daemon
4250

    
4251
-- | Mond's variable for periodical data collection
4252
mondTimeInterval :: Int
4253
mondTimeInterval = 5
4254

    
4255
-- | Mond's latest API version
4256
mondLatestApiVersion :: Int
4257
mondLatestApiVersion = 1
4258

    
4259
-- * Disk access modes
4260

    
4261
diskUserspace :: String
4262
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4263

    
4264
diskKernelspace :: String
4265
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4266

    
4267
diskValidAccessModes :: FrozenSet String
4268
diskValidAccessModes =
4269
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4270

    
4271
-- | Timeout for queue draining in upgrades
4272
upgradeQueueDrainTimeout :: Int
4273
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4274

    
4275
-- | Intervall at which the queue is polled during upgrades
4276
upgradeQueuePollInterval :: Int
4277
upgradeQueuePollInterval  = 10
4278

    
4279
-- * Hotplug Actions
4280

    
4281
hotplugActionAdd :: String
4282
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4283

    
4284
hotplugActionRemove :: String
4285
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4286

    
4287
hotplugActionModify :: String
4288
hotplugActionModify = Types.hotplugActionToRaw HAMod
4289

    
4290
hotplugAllActions :: FrozenSet String
4291
hotplugAllActions =
4292
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4293

    
4294
-- * Hotplug Device Targets
4295

    
4296
hotplugTargetNic :: String
4297
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4298

    
4299
hotplugTargetDisk :: String
4300
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4301

    
4302
hotplugAllTargets :: FrozenSet String
4303
hotplugAllTargets =
4304
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4305

    
4306
-- | Timeout for disk removal (seconds)
4307
diskRemoveRetryTimeout :: Int
4308
diskRemoveRetryTimeout = 30
4309

    
4310
-- | Interval between disk removal retries (seconds)
4311
diskRemoveRetryInterval :: Int
4312
diskRemoveRetryInterval  = 3
4313

    
4314
-- * UUID regex
4315

    
4316
uuidRegex :: String
4317
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4318

    
4319
-- * Luxi constants
4320

    
4321
luxiKeyMethod :: String
4322
luxiKeyMethod = "method"
4323

    
4324
luxiKeyArgs :: String
4325
luxiKeyArgs = "args"
4326

    
4327
luxiKeySuccess :: String
4328
luxiKeySuccess = "success"
4329

    
4330
luxiKeyResult :: String
4331
luxiKeyResult = "result"
4332

    
4333
luxiKeyVersion :: String
4334
luxiKeyVersion = "version"
4335

    
4336
luxiReqSubmitJob :: String
4337
luxiReqSubmitJob = "SubmitJob"
4338

    
4339
luxiReqSubmitJobToDrainedQueue :: String
4340
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4341

    
4342
luxiReqSubmitManyJobs :: String
4343
luxiReqSubmitManyJobs = "SubmitManyJobs"
4344

    
4345
luxiReqWaitForJobChange :: String
4346
luxiReqWaitForJobChange = "WaitForJobChange"
4347

    
4348
luxiReqPickupJob :: String
4349
luxiReqPickupJob = "PickupJob"
4350

    
4351
luxiReqCancelJob :: String
4352
luxiReqCancelJob = "CancelJob"
4353

    
4354
luxiReqArchiveJob :: String
4355
luxiReqArchiveJob = "ArchiveJob"
4356

    
4357
luxiReqChangeJobPriority :: String
4358
luxiReqChangeJobPriority = "ChangeJobPriority"
4359

    
4360
luxiReqAutoArchiveJobs :: String
4361
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4362

    
4363
luxiReqQuery :: String
4364
luxiReqQuery = "Query"
4365

    
4366
luxiReqQueryFields :: String
4367
luxiReqQueryFields = "QueryFields"
4368

    
4369
luxiReqQueryJobs :: String
4370
luxiReqQueryJobs = "QueryJobs"
4371

    
4372
luxiReqQueryInstances :: String
4373
luxiReqQueryInstances = "QueryInstances"
4374

    
4375
luxiReqQueryNodes :: String
4376
luxiReqQueryNodes = "QueryNodes"
4377

    
4378
luxiReqQueryGroups :: String
4379
luxiReqQueryGroups = "QueryGroups"
4380

    
4381
luxiReqQueryNetworks :: String
4382
luxiReqQueryNetworks = "QueryNetworks"
4383

    
4384
luxiReqQueryExports :: String
4385
luxiReqQueryExports = "QueryExports"
4386

    
4387
luxiReqQueryConfigValues :: String
4388
luxiReqQueryConfigValues = "QueryConfigValues"
4389

    
4390
luxiReqQueryClusterInfo :: String
4391
luxiReqQueryClusterInfo = "QueryClusterInfo"
4392

    
4393
luxiReqQueryTags :: String
4394
luxiReqQueryTags = "QueryTags"
4395

    
4396
luxiReqSetDrainFlag :: String
4397
luxiReqSetDrainFlag = "SetDrainFlag"
4398

    
4399
luxiReqSetWatcherPause :: String
4400
luxiReqSetWatcherPause = "SetWatcherPause"
4401

    
4402
luxiReqAll :: FrozenSet String
4403
luxiReqAll =
4404
  ConstantUtils.mkSet
4405
  [ luxiReqArchiveJob
4406
  , luxiReqAutoArchiveJobs
4407
  , luxiReqCancelJob
4408
  , luxiReqChangeJobPriority
4409
  , luxiReqQuery
4410
  , luxiReqQueryClusterInfo
4411
  , luxiReqQueryConfigValues
4412
  , luxiReqQueryExports
4413
  , luxiReqQueryFields
4414
  , luxiReqQueryGroups
4415
  , luxiReqQueryInstances
4416
  , luxiReqQueryJobs
4417
  , luxiReqQueryNodes
4418
  , luxiReqQueryNetworks
4419
  , luxiReqQueryTags
4420
  , luxiReqSetDrainFlag
4421
  , luxiReqSetWatcherPause
4422
  , luxiReqSubmitJob
4423
  , luxiReqSubmitJobToDrainedQueue
4424
  , luxiReqSubmitManyJobs
4425
  , luxiReqWaitForJobChange
4426
  , luxiReqPickupJob
4427
  ]
4428

    
4429
luxiDefCtmo :: Int
4430
luxiDefCtmo = 10
4431

    
4432
luxiDefRwto :: Int
4433
luxiDefRwto = 60
4434

    
4435
-- | 'WaitForJobChange' timeout
4436
luxiWfjcTimeout :: Int
4437
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4438

    
4439
-- * Query language constants
4440

    
4441
-- ** Logic operators with one or more operands, each of which is a
4442
-- filter on its own
4443

    
4444
qlangOpAnd :: String
4445
qlangOpAnd = "&"
4446

    
4447
qlangOpOr :: String
4448
qlangOpOr = "|"
4449

    
4450
-- ** Unary operators with exactly one operand
4451

    
4452
qlangOpNot :: String
4453
qlangOpNot = "!"
4454

    
4455
qlangOpTrue :: String
4456
qlangOpTrue = "?"
4457

    
4458
-- ** Binary operators with exactly two operands, the field name and
4459
-- an operator-specific value
4460

    
4461
qlangOpContains :: String
4462
qlangOpContains = "=[]"
4463

    
4464
qlangOpEqual :: String
4465
qlangOpEqual = "="
4466

    
4467
qlangOpGe :: String
4468
qlangOpGe = ">="
4469

    
4470
qlangOpGt :: String
4471
qlangOpGt = ">"
4472

    
4473
qlangOpLe :: String
4474
qlangOpLe = "<="
4475

    
4476
qlangOpLt :: String
4477
qlangOpLt = "<"
4478

    
4479
qlangOpNotEqual :: String
4480
qlangOpNotEqual = "!="
4481

    
4482
qlangOpRegexp :: String
4483
qlangOpRegexp = "=~"
4484

    
4485
-- | Characters used for detecting user-written filters (see
4486
-- L{_CheckFilter})
4487

    
4488
qlangFilterDetectionChars :: FrozenSet String
4489
qlangFilterDetectionChars =
4490
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4491
                       ")", "(", "\x0b", "\n",
4492
                       "\r", "\x0c", "/", "<",
4493
                       "\t", ">", "=", "\\", "~"]
4494

    
4495
-- | Characters used to detect globbing filters
4496
qlangGlobDetectionChars :: FrozenSet String
4497
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4498

    
4499
-- * Error related constants
4500
--
4501
-- 'OpPrereqError' failure types
4502

    
4503
-- | Environment error (e.g. node disk error)
4504
errorsEcodeEnviron :: String
4505
errorsEcodeEnviron = "environment_error"
4506

    
4507
-- | Entity already exists
4508
errorsEcodeExists :: String
4509
errorsEcodeExists = "already_exists"
4510

    
4511
-- | Internal cluster error
4512
errorsEcodeFault :: String
4513
errorsEcodeFault = "internal_error"
4514

    
4515
-- | Wrong arguments (at syntax level)
4516
errorsEcodeInval :: String
4517
errorsEcodeInval = "wrong_input"
4518

    
4519
-- | Entity not found
4520
errorsEcodeNoent :: String
4521
errorsEcodeNoent = "unknown_entity"
4522

    
4523
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4524
errorsEcodeNores :: String
4525
errorsEcodeNores = "insufficient_resources"
4526

    
4527
-- | Resource not unique (e.g. MAC or IP duplication)
4528
errorsEcodeNotunique :: String
4529
errorsEcodeNotunique = "resource_not_unique"
4530

    
4531
-- | Resolver errors
4532
errorsEcodeResolver :: String
4533
errorsEcodeResolver = "resolver_error"
4534

    
4535
-- | Wrong entity state
4536
errorsEcodeState :: String
4537
errorsEcodeState = "wrong_state"
4538

    
4539
-- | Temporarily out of resources; operation can be tried again
4540
errorsEcodeTempNores :: String
4541
errorsEcodeTempNores = "temp_insufficient_resources"
4542

    
4543
errorsEcodeAll :: FrozenSet String
4544
errorsEcodeAll =
4545
  ConstantUtils.mkSet [ errorsEcodeNores
4546
                      , errorsEcodeExists
4547
                      , errorsEcodeState
4548
                      , errorsEcodeNotunique
4549
                      , errorsEcodeTempNores
4550
                      , errorsEcodeNoent
4551
                      , errorsEcodeFault
4552
                      , errorsEcodeResolver
4553
                      , errorsEcodeInval
4554
                      , errorsEcodeEnviron
4555
                      ]
4556

    
4557
-- * Jstore related constants
4558

    
4559
jstoreJobsPerArchiveDirectory :: Int
4560
jstoreJobsPerArchiveDirectory = 10000