Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 96431562

History | View | Annotate | Download (113.9 kB)

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

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

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

    
15
-}
16

    
17
{-
18

    
19
Copyright (C) 2013 Google Inc.
20

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

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

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

    
36
-}
37
module Ganeti.Constants where
38

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

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

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

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

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

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

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

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

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

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

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

    
86
-- ** Build-time constants
87

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
135
-- * Various versions
136

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

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

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

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

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

    
152
osApiV10 :: Int
153
osApiV10 = 10
154

    
155
osApiV15 :: Int
156
osApiV15 = 15
157

    
158
osApiV20 :: Int
159
osApiV20 = 20
160

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

    
164
exportVersion :: Int
165
exportVersion = 0
166

    
167
rapiVersion :: Int
168
rapiVersion = 2
169

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

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

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

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

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

    
189
-- * User separation
190

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
239
-- * Cpu pinning separators and constants
240

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

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

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

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

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

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

    
279
-- * Wipe
280

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

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

    
288
minWipeChunkPercent :: Int
289
minWipeChunkPercent = 10
290

    
291
-- * Directories
292

    
293
runDirsMode :: Int
294
runDirsMode = 0o775
295

    
296
secureDirMode :: Int
297
secureDirMode = 0o700
298

    
299
secureFileMode :: Int
300
secureFileMode = 0o600
301

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

    
305
-- * 'autoconf' enable/disable
306

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

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

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

    
316
-- * SSH constants
317

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

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

    
324
-- * Daemons
325

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

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

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

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

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

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

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

    
353
defaultConfdPort :: Int
354
defaultConfdPort = 1814
355

    
356
defaultMondPort :: Int
357
defaultMondPort = 1815
358

    
359
defaultNodedPort :: Int
360
defaultNodedPort = 1811
361

    
362
defaultRapiPort :: Int
363
defaultRapiPort = 5080
364

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

    
373
firstDrbdPort :: Int
374
firstDrbdPort = 11000
375

    
376
lastDrbdPort :: Int
377
lastDrbdPort = 14999
378

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

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

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

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

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

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

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

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

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

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

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

    
421
luxiVersion :: Int
422
luxiVersion = configVersion
423

    
424
-- * Syslog
425

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

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

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

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

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

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

    
444
-- * Xen
445

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

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

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

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

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

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

    
466
-- * KVM and socat
467

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

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

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

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

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

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

    
486
-- * Console types
487

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

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

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

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

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

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

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

    
526
-- * X509
527

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

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

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

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

    
543
-- * Import/export daemon mode
544

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

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

    
551
-- * Import/export transport compression
552

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

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

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

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

    
565
-- * Import/export I/O
566

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

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

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

    
580
-- * Values
581

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

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

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

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

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

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

    
600
-- * Hooks
601

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

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

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

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

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

    
617
hooksVersion :: Int
618
hooksVersion = 2
619

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

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

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

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

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

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

    
637
-- * Hkr
638

    
639
hkrSkip :: Int
640
hkrSkip = 0
641

    
642
hkrFail :: Int
643
hkrFail = 1
644

    
645
hkrSuccess :: Int
646
hkrSuccess = 2
647

    
648
-- * Storage types
649

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
717
-- * Storage operations
718

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

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

    
727
-- * Volume fields
728

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

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

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

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

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

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

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

    
750
-- * Local disk status
751

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

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

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

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

    
766
-- * Disk template types
767

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

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

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

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

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

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

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

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

    
792
-- | 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
                       qrOs,
3342
                       qrExtstorage]
3343

    
3344
-- | List of resources which can be queried using Local UniX Interface
3345
qrViaLuxi :: FrozenSet String
3346
qrViaLuxi = ConstantUtils.mkSet [qrGroup,
3347
                                 qrExport,
3348
                                 qrJob,
3349
                                 qrLock,
3350
                                 qrNetwork,
3351
                                 qrNode]
3352

    
3353
-- | List of resources which can be queried using RAPI
3354
qrViaRapi :: FrozenSet String
3355
qrViaRapi = ConstantUtils.mkSet [qrLock, qrJob]
3356

    
3357
-- * Query field types
3358

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

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

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

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

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

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

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

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

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

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

    
3400
rsNormal :: Int
3401
rsNormal = 0
3402

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

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

    
3413
rsUnknown :: Int
3414
rsUnknown = 1
3415

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

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

    
3432
-- * Max dynamic devices
3433

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

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

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

    
3444
-- * SSCONF keys
3445

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3520
-- * Hvparams keys
3521

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

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

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

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

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

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

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

    
3549
ssFilePerms :: Int
3550
ssFilePerms = 0o444
3551

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

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

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

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

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

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

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

    
3705
defaultDiskCustom :: String
3706
defaultDiskCustom = ""
3707

    
3708
defaultDiskResync :: Bool
3709
defaultDiskResync = False
3710

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

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

    
3719
defaultNetCustom :: String
3720
defaultNetCustom = ""
3721

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

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

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

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

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

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

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

    
3843
masterPoolSizeDefault :: Int
3844
masterPoolSizeDefault = 10
3845

    
3846
-- * Exclusive storage
3847

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

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

    
3856
-- * Confd
3857

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

    
3861
-- Confd request type
3862

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

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

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

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

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

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

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

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

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

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

    
3896
-- * Confd request type
3897

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

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

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

    
3907
-- * Confd repl status
3908

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

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

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

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

    
3922
-- * Confd node role
3923

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

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

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

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

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

    
3939
-- * A few common errors for confd
3940

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

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

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

    
3950
-- * Confd request query fields
3951

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

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

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

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

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

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

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

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

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

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

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

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

    
4018
uidpoolUidMin :: Int
4019
uidpoolUidMin = 0
4020

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

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

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

    
4034
-- * Possible values for NodeGroup.alloc_policy
4035

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

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

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

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

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

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

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

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

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

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

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

    
4076
-- * SSH key types
4077

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

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

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

    
4087
-- * SSH authorized key types
4088

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

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

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

    
4098
-- * SSH setup
4099

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

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

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

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

    
4112
-- * Key files for SSH daemon
4113

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

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

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

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

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

    
4132
-- * Node daemon setup
4133

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

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

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

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

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

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

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

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

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

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

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

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

    
4175
-- * Auto-repair tag prefixes
4176

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

    
4180
autoRepairTagEnabled :: String
4181
autoRepairTagEnabled = autoRepairTagPrefix
4182

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

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

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

    
4192
-- * Auto-repair levels
4193

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

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

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

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

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

    
4213
-- * Auto-repair results
4214

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

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

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

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

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

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

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

    
4239
-- *  CPU load collector
4240

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

    
4244
cpuavgloadBufferSize :: Int
4245
cpuavgloadBufferSize = 150
4246

    
4247
cpuavgloadWindowSize :: Int
4248
cpuavgloadWindowSize = 600
4249

    
4250
-- * Monitoring daemon
4251

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

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

    
4260
-- * Disk access modes
4261

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

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

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

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

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

    
4280
-- * Hotplug Actions
4281

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

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

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

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

    
4295
-- * Hotplug Device Targets
4296

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

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

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

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

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

    
4315
-- * UUID regex
4316

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

    
4320
-- * Luxi constants
4321

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4397
luxiReqSetDrainFlag :: String
4398
luxiReqSetDrainFlag = "SetDrainFlag"
4399

    
4400
luxiReqSetWatcherPause :: String
4401
luxiReqSetWatcherPause = "SetWatcherPause"
4402

    
4403
luxiReqAll :: FrozenSet String
4404
luxiReqAll =
4405
  ConstantUtils.mkSet
4406
  [ luxiReqArchiveJob
4407
  , luxiReqAutoArchiveJobs
4408
  , luxiReqCancelJob
4409
  , luxiReqChangeJobPriority
4410
  , luxiReqQuery
4411
  , luxiReqQueryClusterInfo
4412
  , luxiReqQueryConfigValues
4413
  , luxiReqQueryExports
4414
  , luxiReqQueryFields
4415
  , luxiReqQueryGroups
4416
  , luxiReqQueryInstances
4417
  , luxiReqQueryJobs
4418
  , luxiReqQueryNodes
4419
  , luxiReqQueryNetworks
4420
  , luxiReqQueryTags
4421
  , luxiReqSetDrainFlag
4422
  , luxiReqSetWatcherPause
4423
  , luxiReqSubmitJob
4424
  , luxiReqSubmitJobToDrainedQueue
4425
  , luxiReqSubmitManyJobs
4426
  , luxiReqWaitForJobChange
4427
  , luxiReqPickupJob
4428
  ]
4429

    
4430
luxiDefCtmo :: Int
4431
luxiDefCtmo = 10
4432

    
4433
luxiDefRwto :: Int
4434
luxiDefRwto = 60
4435

    
4436
-- | 'WaitForJobChange' timeout
4437
luxiWfjcTimeout :: Int
4438
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4439

    
4440
-- * Query language constants
4441

    
4442
-- ** Logic operators with one or more operands, each of which is a
4443
-- filter on its own
4444

    
4445
qlangOpAnd :: String
4446
qlangOpAnd = "&"
4447

    
4448
qlangOpOr :: String
4449
qlangOpOr = "|"
4450

    
4451
-- ** Unary operators with exactly one operand
4452

    
4453
qlangOpNot :: String
4454
qlangOpNot = "!"
4455

    
4456
qlangOpTrue :: String
4457
qlangOpTrue = "?"
4458

    
4459
-- ** Binary operators with exactly two operands, the field name and
4460
-- an operator-specific value
4461

    
4462
qlangOpContains :: String
4463
qlangOpContains = "=[]"
4464

    
4465
qlangOpEqual :: String
4466
qlangOpEqual = "="
4467

    
4468
qlangOpGe :: String
4469
qlangOpGe = ">="
4470

    
4471
qlangOpGt :: String
4472
qlangOpGt = ">"
4473

    
4474
qlangOpLe :: String
4475
qlangOpLe = "<="
4476

    
4477
qlangOpLt :: String
4478
qlangOpLt = "<"
4479

    
4480
qlangOpNotEqual :: String
4481
qlangOpNotEqual = "!="
4482

    
4483
qlangOpRegexp :: String
4484
qlangOpRegexp = "=~"
4485

    
4486
-- | Characters used for detecting user-written filters (see
4487
-- L{_CheckFilter})
4488

    
4489
qlangFilterDetectionChars :: FrozenSet String
4490
qlangFilterDetectionChars =
4491
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4492
                       ")", "(", "\x0b", "\n",
4493
                       "\r", "\x0c", "/", "<",
4494
                       "\t", ">", "=", "\\", "~"]
4495

    
4496
-- | Characters used to detect globbing filters
4497
qlangGlobDetectionChars :: FrozenSet String
4498
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4499

    
4500
-- * Error related constants
4501
--
4502
-- 'OpPrereqError' failure types
4503

    
4504
-- | Environment error (e.g. node disk error)
4505
errorsEcodeEnviron :: String
4506
errorsEcodeEnviron = "environment_error"
4507

    
4508
-- | Entity already exists
4509
errorsEcodeExists :: String
4510
errorsEcodeExists = "already_exists"
4511

    
4512
-- | Internal cluster error
4513
errorsEcodeFault :: String
4514
errorsEcodeFault = "internal_error"
4515

    
4516
-- | Wrong arguments (at syntax level)
4517
errorsEcodeInval :: String
4518
errorsEcodeInval = "wrong_input"
4519

    
4520
-- | Entity not found
4521
errorsEcodeNoent :: String
4522
errorsEcodeNoent = "unknown_entity"
4523

    
4524
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4525
errorsEcodeNores :: String
4526
errorsEcodeNores = "insufficient_resources"
4527

    
4528
-- | Resource not unique (e.g. MAC or IP duplication)
4529
errorsEcodeNotunique :: String
4530
errorsEcodeNotunique = "resource_not_unique"
4531

    
4532
-- | Resolver errors
4533
errorsEcodeResolver :: String
4534
errorsEcodeResolver = "resolver_error"
4535

    
4536
-- | Wrong entity state
4537
errorsEcodeState :: String
4538
errorsEcodeState = "wrong_state"
4539

    
4540
-- | Temporarily out of resources; operation can be tried again
4541
errorsEcodeTempNores :: String
4542
errorsEcodeTempNores = "temp_insufficient_resources"
4543

    
4544
errorsEcodeAll :: FrozenSet String
4545
errorsEcodeAll =
4546
  ConstantUtils.mkSet [ errorsEcodeNores
4547
                      , errorsEcodeExists
4548
                      , errorsEcodeState
4549
                      , errorsEcodeNotunique
4550
                      , errorsEcodeTempNores
4551
                      , errorsEcodeNoent
4552
                      , errorsEcodeFault
4553
                      , errorsEcodeResolver
4554
                      , errorsEcodeInval
4555
                      , errorsEcodeEnviron
4556
                      ]
4557

    
4558
-- * Jstore related constants
4559

    
4560
jstoreJobsPerArchiveDirectory :: Int
4561
jstoreJobsPerArchiveDirectory = 10000