Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 07e68848

History | View | Annotate | Download (113.6 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
enableSplitQuery :: Bool
317
enableSplitQuery = AutoConf.enableSplitQuery
318

    
319
-- * SSH constants
320

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

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

    
327
-- * Daemons
328

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

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

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

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

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

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

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

    
356
defaultConfdPort :: Int
357
defaultConfdPort = 1814
358

    
359
defaultMondPort :: Int
360
defaultMondPort = 1815
361

    
362
defaultNodedPort :: Int
363
defaultNodedPort = 1811
364

    
365
defaultRapiPort :: Int
366
defaultRapiPort = 5080
367

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

    
376
firstDrbdPort :: Int
377
firstDrbdPort = 11000
378

    
379
lastDrbdPort :: Int
380
lastDrbdPort = 14999
381

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

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

    
397
extraLogreasonAccess :: String
398
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
399

    
400
extraLogreasonError :: String
401
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
402

    
403
devConsole :: String
404
devConsole = ConstantUtils.devConsole
405

    
406
procMounts :: String
407
procMounts = "/proc/mounts"
408

    
409
-- * Luxi (Local UniX Interface) related constants
410

    
411
luxiEom :: PythonChar
412
luxiEom = PythonChar '\x03'
413

    
414
-- | Environment variable for the luxi override socket
415
luxiOverride :: String
416
luxiOverride = "FORCE_LUXI_SOCKET"
417

    
418
luxiOverrideMaster :: String
419
luxiOverrideMaster = "master"
420

    
421
luxiOverrideQuery :: String
422
luxiOverrideQuery = "query"
423

    
424
luxiVersion :: Int
425
luxiVersion = configVersion
426

    
427
-- * Syslog
428

    
429
syslogUsage :: String
430
syslogUsage = AutoConf.syslogUsage
431

    
432
syslogNo :: String
433
syslogNo = Logging.syslogUsageToRaw SyslogNo
434

    
435
syslogYes :: String
436
syslogYes = Logging.syslogUsageToRaw SyslogYes
437

    
438
syslogOnly :: String
439
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
440

    
441
syslogSocket :: String
442
syslogSocket = "/dev/log"
443

    
444
exportConfFile :: String
445
exportConfFile = "config.ini"
446

    
447
-- * Xen
448

    
449
xenBootloader :: String
450
xenBootloader = AutoConf.xenBootloader
451

    
452
xenCmdXl :: String
453
xenCmdXl = "xl"
454

    
455
xenCmdXm :: String
456
xenCmdXm = "xm"
457

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

    
461
xenKernel :: String
462
xenKernel = AutoConf.xenKernel
463

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

    
469
-- * KVM and socat
470

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

    
474
kvmKernel :: String
475
kvmKernel = AutoConf.kvmKernel
476

    
477
socatEscapeCode :: String
478
socatEscapeCode = "0x1d"
479

    
480
socatPath :: String
481
socatPath = AutoConf.socatPath
482

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

    
486
socatUseEscape :: Bool
487
socatUseEscape = AutoConf.socatUseEscape
488

    
489
-- * Console types
490

    
491
-- | Display a message for console access
492
consMessage :: String
493
consMessage = "msg"
494

    
495
-- | Console as SPICE server
496
consSpice :: String
497
consSpice = "spice"
498

    
499
-- | Console as SSH command
500
consSsh :: String
501
consSsh = "ssh"
502

    
503
-- | Console as VNC server
504
consVnc :: String
505
consVnc = "vnc"
506

    
507
consAll :: FrozenSet String
508
consAll = ConstantUtils.mkSet [consMessage, consSpice, consSsh, consVnc]
509

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

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

    
529
-- * X509
530

    
531
-- | commonName (CN) used in certificates
532
x509CertCn :: String
533
x509CertCn = "ganeti.example.com"
534

    
535
-- | Default validity of certificates in days
536
x509CertDefaultValidity :: Int
537
x509CertDefaultValidity = 365 * 5
538

    
539
x509CertSignatureHeader :: String
540
x509CertSignatureHeader = "X-Ganeti-Signature"
541

    
542
-- | Digest used to sign certificates ("openssl x509" uses SHA1 by default)
543
x509CertSignDigest :: String
544
x509CertSignDigest = "SHA1"
545

    
546
-- * Import/export daemon mode
547

    
548
iemExport :: String
549
iemExport = "export"
550

    
551
iemImport :: String
552
iemImport = "import"
553

    
554
-- * Import/export transport compression
555

    
556
iecGzip :: String
557
iecGzip = "gzip"
558

    
559
iecNone :: String
560
iecNone = "none"
561

    
562
iecAll :: [String]
563
iecAll = [iecGzip, iecNone]
564

    
565
ieCustomSize :: String
566
ieCustomSize = "fd"
567

    
568
-- * Import/export I/O
569

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

    
575
-- | Raw block device I/O using "dd"
576
ieioRawDisk :: String
577
ieioRawDisk = "raw"
578

    
579
-- | OS definition import/export script
580
ieioScript :: String
581
ieioScript = "script"
582

    
583
-- * Values
584

    
585
valueDefault :: String
586
valueDefault = "default"
587

    
588
valueAuto :: String
589
valueAuto = "auto"
590

    
591
valueGenerate :: String
592
valueGenerate = "generate"
593

    
594
valueNone :: String
595
valueNone = "none"
596

    
597
valueTrue :: String
598
valueTrue = "true"
599

    
600
valueFalse :: String
601
valueFalse = "false"
602

    
603
-- * Hooks
604

    
605
hooksNameCfgupdate :: String
606
hooksNameCfgupdate = "config-update"
607

    
608
hooksNameWatcher :: String
609
hooksNameWatcher = "watcher"
610

    
611
hooksPath :: String
612
hooksPath = "/sbin:/bin:/usr/sbin:/usr/bin"
613

    
614
hooksPhasePost :: String
615
hooksPhasePost = "post"
616

    
617
hooksPhasePre :: String
618
hooksPhasePre = "pre"
619

    
620
hooksVersion :: Int
621
hooksVersion = 2
622

    
623
-- * Hooks subject type (what object type does the LU deal with)
624

    
625
htypeCluster :: String
626
htypeCluster = "CLUSTER"
627

    
628
htypeGroup :: String
629
htypeGroup = "GROUP"
630

    
631
htypeInstance :: String
632
htypeInstance = "INSTANCE"
633

    
634
htypeNetwork :: String
635
htypeNetwork = "NETWORK"
636

    
637
htypeNode :: String
638
htypeNode = "NODE"
639

    
640
-- * Hkr
641

    
642
hkrSkip :: Int
643
hkrSkip = 0
644

    
645
hkrFail :: Int
646
hkrFail = 1
647

    
648
hkrSuccess :: Int
649
hkrSuccess = 2
650

    
651
-- * Storage types
652

    
653
stBlock :: String
654
stBlock = Types.storageTypeToRaw StorageBlock
655

    
656
stDiskless :: String
657
stDiskless = Types.storageTypeToRaw StorageDiskless
658

    
659
stExt :: String
660
stExt = Types.storageTypeToRaw StorageExt
661

    
662
stFile :: String
663
stFile = Types.storageTypeToRaw StorageFile
664

    
665
stLvmPv :: String
666
stLvmPv = Types.storageTypeToRaw StorageLvmPv
667

    
668
stLvmVg :: String
669
stLvmVg = Types.storageTypeToRaw StorageLvmVg
670

    
671
stRados :: String
672
stRados = Types.storageTypeToRaw StorageRados
673

    
674
storageTypes :: FrozenSet String
675
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
676

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

    
684
-- * Storage fields
685
-- ** First two are valid in LU context only, not passed to backend
686

    
687
sfNode :: String
688
sfNode = "node"
689

    
690
sfType :: String
691
sfType = "type"
692

    
693
-- ** and the rest are valid in backend
694

    
695
sfAllocatable :: String
696
sfAllocatable = Types.storageFieldToRaw SFAllocatable
697

    
698
sfFree :: String
699
sfFree = Types.storageFieldToRaw SFFree
700

    
701
sfName :: String
702
sfName = Types.storageFieldToRaw SFName
703

    
704
sfSize :: String
705
sfSize = Types.storageFieldToRaw SFSize
706

    
707
sfUsed :: String
708
sfUsed = Types.storageFieldToRaw SFUsed
709

    
710
validStorageFields :: FrozenSet String
711
validStorageFields =
712
  ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++
713
                        [sfNode, sfType]
714

    
715
modifiableStorageFields :: Map String (FrozenSet String)
716
modifiableStorageFields =
717
  Map.fromList [(Types.storageTypeToRaw StorageLvmPv,
718
                 ConstantUtils.mkSet [sfAllocatable])]
719

    
720
-- * Storage operations
721

    
722
soFixConsistency :: String
723
soFixConsistency = "fix-consistency"
724

    
725
validStorageOperations :: Map String (FrozenSet String)
726
validStorageOperations =
727
  Map.fromList [(Types.storageTypeToRaw StorageLvmVg,
728
                 ConstantUtils.mkSet [soFixConsistency])]
729

    
730
-- * Volume fields
731

    
732
vfDev :: String
733
vfDev = "dev"
734

    
735
vfInstance :: String
736
vfInstance = "instance"
737

    
738
vfName :: String
739
vfName = "name"
740

    
741
vfNode :: String
742
vfNode = "node"
743

    
744
vfPhys :: String
745
vfPhys = "phys"
746

    
747
vfSize :: String
748
vfSize = "size"
749

    
750
vfVg :: String
751
vfVg = "vg"
752

    
753
-- * Local disk status
754

    
755
ldsFaulty :: Int
756
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
757

    
758
ldsOkay :: Int
759
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
760

    
761
ldsUnknown :: Int
762
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
763

    
764
ldsNames :: Map Int String
765
ldsNames =
766
  Map.fromList [ (Types.localDiskStatusToRaw ds,
767
                  localDiskStatusName ds) | ds <- [minBound..] ]
768

    
769
-- * Disk template types
770

    
771
dtDiskless :: String
772
dtDiskless = Types.diskTemplateToRaw DTDiskless
773

    
774
dtFile :: String
775
dtFile = Types.diskTemplateToRaw DTFile
776

    
777
dtSharedFile :: String
778
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
779

    
780
dtPlain :: String
781
dtPlain = Types.diskTemplateToRaw DTPlain
782

    
783
dtBlock :: String
784
dtBlock = Types.diskTemplateToRaw DTBlock
785

    
786
dtDrbd8 :: String
787
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
788

    
789
dtRbd :: String
790
dtRbd = Types.diskTemplateToRaw DTRbd
791

    
792
dtExt :: String
793
dtExt = Types.diskTemplateToRaw DTExt
794

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

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

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

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

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

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

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

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

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

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

    
859
-- | The set of disk templates that allow migrations
860
dtsMirrored :: FrozenSet String
861
dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
862

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

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

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

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

    
886
dtsBlock :: FrozenSet String
887
dtsBlock =
888
  ConstantUtils.mkSet $
889
  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
890

    
891
-- | The set of lvm-based disk templates
892
dtsLvm :: FrozenSet String
893
dtsLvm = diskTemplates `ConstantUtils.difference` dtsNotLvm
894

    
895
-- * Drbd
896

    
897
drbdHmacAlg :: String
898
drbdHmacAlg = "md5"
899

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

    
903
drbdMigrationNetProtocol :: String
904
drbdMigrationNetProtocol = "C"
905

    
906
drbdStatusFile :: String
907
drbdStatusFile = "/proc/drbd"
908

    
909
-- | Size of DRBD meta block device
910
drbdMetaSize :: Int
911
drbdMetaSize = 128
912

    
913
-- * Drbd barrier types
914

    
915
drbdBDiskBarriers :: String
916
drbdBDiskBarriers = "b"
917

    
918
drbdBDiskDrain :: String
919
drbdBDiskDrain = "d"
920

    
921
drbdBDiskFlush :: String
922
drbdBDiskFlush = "f"
923

    
924
drbdBNone :: String
925
drbdBNone = "n"
926

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

    
941
-- | Rbd tool command
942
rbdCmd :: String
943
rbdCmd = "rbd"
944

    
945
-- * File backend driver
946

    
947
fdBlktap :: String
948
fdBlktap = Types.fileDriverToRaw FileBlktap
949

    
950
fdLoop :: String
951
fdLoop = Types.fileDriverToRaw FileLoop
952

    
953
fileDriver :: FrozenSet String
954
fileDriver =
955
  ConstantUtils.mkSet $
956
  map Types.fileDriverToRaw [minBound..]
957

    
958
-- | The set of drbd-like disk types
959
dtsDrbd :: FrozenSet String
960
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
961

    
962
-- * Disk access mode
963

    
964
diskRdonly :: String
965
diskRdonly = Types.diskModeToRaw DiskRdOnly
966

    
967
diskRdwr :: String
968
diskRdwr = Types.diskModeToRaw DiskRdWr
969

    
970
diskAccessSet :: FrozenSet String
971
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
972

    
973
-- * Disk replacement mode
974

    
975
replaceDiskAuto :: String
976
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
977

    
978
replaceDiskChg :: String
979
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
980

    
981
replaceDiskPri :: String
982
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
983

    
984
replaceDiskSec :: String
985
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
986

    
987
replaceModes :: FrozenSet String
988
replaceModes =
989
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
990

    
991
-- * Instance export mode
992

    
993
exportModeLocal :: String
994
exportModeLocal = Types.exportModeToRaw ExportModeLocal
995

    
996
exportModeRemote :: String
997
exportModeRemote = Types.exportModeToRaw ExportModeRemote
998

    
999
exportModes :: FrozenSet String
1000
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
1001

    
1002
-- * Instance creation modes
1003

    
1004
instanceCreate :: String
1005
instanceCreate = Types.instCreateModeToRaw InstCreate
1006

    
1007
instanceImport :: String
1008
instanceImport = Types.instCreateModeToRaw InstImport
1009

    
1010
instanceRemoteImport :: String
1011
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1012

    
1013
instanceCreateModes :: FrozenSet String
1014
instanceCreateModes =
1015
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1016

    
1017
-- * Remote import/export handshake message and version
1018

    
1019
rieHandshake :: String
1020
rieHandshake = "Hi, I'm Ganeti"
1021

    
1022
rieVersion :: Int
1023
rieVersion = 0
1024

    
1025
-- | Remote import/export certificate validity (seconds)
1026
rieCertValidity :: Int
1027
rieCertValidity = 24 * 60 * 60
1028

    
1029
-- | Export only: how long to wait per connection attempt (seconds)
1030
rieConnectAttemptTimeout :: Int
1031
rieConnectAttemptTimeout = 20
1032

    
1033
-- | Export only: number of attempts to connect
1034
rieConnectRetries :: Int
1035
rieConnectRetries = 10
1036

    
1037
-- | Overall timeout for establishing connection
1038
rieConnectTimeout :: Int
1039
rieConnectTimeout = 180
1040

    
1041
-- | Give child process up to 5 seconds to exit after sending a signal
1042
childLingerTimeout :: Double
1043
childLingerTimeout = 5.0
1044

    
1045
-- * Import/export config options
1046

    
1047
inisectBep :: String
1048
inisectBep = "backend"
1049

    
1050
inisectExp :: String
1051
inisectExp = "export"
1052

    
1053
inisectHyp :: String
1054
inisectHyp = "hypervisor"
1055

    
1056
inisectIns :: String
1057
inisectIns = "instance"
1058

    
1059
inisectOsp :: String
1060
inisectOsp = "os"
1061

    
1062
-- * Dynamic device modification
1063

    
1064
ddmAdd :: String
1065
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1066

    
1067
ddmModify :: String
1068
ddmModify = Types.ddmFullToRaw DdmFullModify
1069

    
1070
ddmRemove :: String
1071
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1072

    
1073
ddmsValues :: FrozenSet String
1074
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1075

    
1076
ddmsValuesWithModify :: FrozenSet String
1077
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1078

    
1079
-- * Common exit codes
1080

    
1081
exitSuccess :: Int
1082
exitSuccess = 0
1083

    
1084
exitFailure :: Int
1085
exitFailure = ConstantUtils.exitFailure
1086

    
1087
exitNotcluster :: Int
1088
exitNotcluster = 5
1089

    
1090
exitNotmaster :: Int
1091
exitNotmaster = 11
1092

    
1093
exitNodesetupError :: Int
1094
exitNodesetupError = 12
1095

    
1096
-- | Need user confirmation
1097
exitConfirmation :: Int
1098
exitConfirmation = 13
1099

    
1100
-- | Exit code for query operations with unknown fields
1101
exitUnknownField :: Int
1102
exitUnknownField = 14
1103

    
1104
-- * Tags
1105

    
1106
tagCluster :: String
1107
tagCluster = Types.tagKindToRaw TagKindCluster
1108

    
1109
tagInstance :: String
1110
tagInstance = Types.tagKindToRaw TagKindInstance
1111

    
1112
tagNetwork :: String
1113
tagNetwork = Types.tagKindToRaw TagKindNetwork
1114

    
1115
tagNode :: String
1116
tagNode = Types.tagKindToRaw TagKindNode
1117

    
1118
tagNodegroup :: String
1119
tagNodegroup = Types.tagKindToRaw TagKindGroup
1120

    
1121
validTagTypes :: FrozenSet String
1122
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1123

    
1124
maxTagLen :: Int
1125
maxTagLen = 128
1126

    
1127
maxTagsPerObj :: Int
1128
maxTagsPerObj = 4096
1129

    
1130
-- * Others
1131

    
1132
defaultBridge :: String
1133
defaultBridge = "xen-br0"
1134

    
1135
defaultOvs :: String
1136
defaultOvs = "switch1"
1137

    
1138
-- | 60 MiB/s, expressed in KiB/s
1139
classicDrbdSyncSpeed :: Int
1140
classicDrbdSyncSpeed = 60 * 1024
1141

    
1142
ip4AddressAny :: String
1143
ip4AddressAny = "0.0.0.0"
1144

    
1145
ip4AddressLocalhost :: String
1146
ip4AddressLocalhost = "127.0.0.1"
1147

    
1148
ip6AddressAny :: String
1149
ip6AddressAny = "::"
1150

    
1151
ip6AddressLocalhost :: String
1152
ip6AddressLocalhost = "::1"
1153

    
1154
ip4Version :: Int
1155
ip4Version = 4
1156

    
1157
ip6Version :: Int
1158
ip6Version = 6
1159

    
1160
validIpVersions :: FrozenSet Int
1161
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1162

    
1163
tcpPingTimeout :: Int
1164
tcpPingTimeout = 10
1165

    
1166
defaultVg :: String
1167
defaultVg = "xenvg"
1168

    
1169
defaultDrbdHelper :: String
1170
defaultDrbdHelper = "/bin/true"
1171

    
1172
minVgSize :: Int
1173
minVgSize = 20480
1174

    
1175
defaultMacPrefix :: String
1176
defaultMacPrefix = "aa:00:00"
1177

    
1178
-- | Default maximum instance wait time (seconds)
1179
defaultShutdownTimeout :: Int
1180
defaultShutdownTimeout = 120
1181

    
1182
-- | Node clock skew (seconds)
1183
nodeMaxClockSkew :: Int
1184
nodeMaxClockSkew = 150
1185

    
1186
-- | Time for an intra-cluster disk transfer to wait for a connection
1187
diskTransferConnectTimeout :: Int
1188
diskTransferConnectTimeout = 60
1189

    
1190
-- | Disk index separator
1191
diskSeparator :: String
1192
diskSeparator = AutoConf.diskSeparator
1193

    
1194
ipCommandPath :: String
1195
ipCommandPath = AutoConf.ipPath
1196

    
1197
-- | Key for job IDs in opcode result
1198
jobIdsKey :: String
1199
jobIdsKey = "jobs"
1200

    
1201
-- * Runparts results
1202

    
1203
runpartsErr :: Int
1204
runpartsErr = 2
1205

    
1206
runpartsRun :: Int
1207
runpartsRun = 1
1208

    
1209
runpartsSkip :: Int
1210
runpartsSkip = 0
1211

    
1212
runpartsStatus :: [Int]
1213
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1214

    
1215
-- * RPC
1216

    
1217
rpcEncodingNone :: Int
1218
rpcEncodingNone = 0
1219

    
1220
rpcEncodingZlibBase64 :: Int
1221
rpcEncodingZlibBase64 = 1
1222

    
1223
-- * Timeout table
1224
--
1225
-- Various time constants for the timeout table
1226

    
1227
rpcTmoUrgent :: Int
1228
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1229

    
1230
rpcTmoFast :: Int
1231
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1232

    
1233
rpcTmoNormal :: Int
1234
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1235

    
1236
rpcTmoSlow :: Int
1237
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1238

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

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

    
1251
-- | Timeout for connecting to nodes (seconds)
1252
rpcConnectTimeout :: Int
1253
rpcConnectTimeout = 5
1254

    
1255
-- OS
1256

    
1257
osScriptCreate :: String
1258
osScriptCreate = "create"
1259

    
1260
osScriptExport :: String
1261
osScriptExport = "export"
1262

    
1263
osScriptImport :: String
1264
osScriptImport = "import"
1265

    
1266
osScriptRename :: String
1267
osScriptRename = "rename"
1268

    
1269
osScriptVerify :: String
1270
osScriptVerify = "verify"
1271

    
1272
osScripts :: [String]
1273
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1274
             osScriptVerify]
1275

    
1276
osApiFile :: String
1277
osApiFile = "ganeti_api_version"
1278

    
1279
osVariantsFile :: String
1280
osVariantsFile = "variants.list"
1281

    
1282
osParametersFile :: String
1283
osParametersFile = "parameters.list"
1284

    
1285
osValidateParameters :: String
1286
osValidateParameters = "parameters"
1287

    
1288
osValidateCalls :: FrozenSet String
1289
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1290

    
1291
-- | External Storage (ES) related constants
1292

    
1293
esActionAttach :: String
1294
esActionAttach = "attach"
1295

    
1296
esActionCreate :: String
1297
esActionCreate = "create"
1298

    
1299
esActionDetach :: String
1300
esActionDetach = "detach"
1301

    
1302
esActionGrow :: String
1303
esActionGrow = "grow"
1304

    
1305
esActionRemove :: String
1306
esActionRemove = "remove"
1307

    
1308
esActionSetinfo :: String
1309
esActionSetinfo = "setinfo"
1310

    
1311
esActionVerify :: String
1312
esActionVerify = "verify"
1313

    
1314
esScriptCreate :: String
1315
esScriptCreate = esActionCreate
1316

    
1317
esScriptRemove :: String
1318
esScriptRemove = esActionRemove
1319

    
1320
esScriptGrow :: String
1321
esScriptGrow = esActionGrow
1322

    
1323
esScriptAttach :: String
1324
esScriptAttach = esActionAttach
1325

    
1326
esScriptDetach :: String
1327
esScriptDetach = esActionDetach
1328

    
1329
esScriptSetinfo :: String
1330
esScriptSetinfo = esActionSetinfo
1331

    
1332
esScriptVerify :: String
1333
esScriptVerify = esActionVerify
1334

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

    
1345
esParametersFile :: String
1346
esParametersFile = "parameters.list"
1347

    
1348
-- * Reboot types
1349

    
1350
instanceRebootSoft :: String
1351
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1352

    
1353
instanceRebootHard :: String
1354
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1355

    
1356
instanceRebootFull :: String
1357
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1358

    
1359
rebootTypes :: FrozenSet String
1360
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1361

    
1362
-- * Instance reboot behaviors
1363

    
1364
instanceRebootAllowed :: String
1365
instanceRebootAllowed = "reboot"
1366

    
1367
instanceRebootExit :: String
1368
instanceRebootExit = "exit"
1369

    
1370
rebootBehaviors :: [String]
1371
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1372

    
1373
-- * VTypes
1374

    
1375
vtypeBool :: VType
1376
vtypeBool = VTypeBool
1377

    
1378
vtypeInt :: VType
1379
vtypeInt = VTypeInt
1380

    
1381
vtypeMaybeString :: VType
1382
vtypeMaybeString = VTypeMaybeString
1383

    
1384
-- | Size in MiBs
1385
vtypeSize :: VType
1386
vtypeSize = VTypeSize
1387

    
1388
vtypeString :: VType
1389
vtypeString = VTypeString
1390

    
1391
enforceableTypes :: FrozenSet VType
1392
enforceableTypes = ConstantUtils.mkSet [minBound..]
1393

    
1394
-- | Constant representing that the user does not specify any IP version
1395
ifaceNoIpVersionSpecified :: Int
1396
ifaceNoIpVersionSpecified = 0
1397

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

    
1419
-- * HV parameter names (global namespace)
1420

    
1421
hvAcpi :: String
1422
hvAcpi = "acpi"
1423

    
1424
hvBlockdevPrefix :: String
1425
hvBlockdevPrefix = "blockdev_prefix"
1426

    
1427
hvBootloaderArgs :: String
1428
hvBootloaderArgs = "bootloader_args"
1429

    
1430
hvBootloaderPath :: String
1431
hvBootloaderPath = "bootloader_path"
1432

    
1433
hvBootOrder :: String
1434
hvBootOrder = "boot_order"
1435

    
1436
hvCdromImagePath :: String
1437
hvCdromImagePath = "cdrom_image_path"
1438

    
1439
hvCpuCap :: String
1440
hvCpuCap = "cpu_cap"
1441

    
1442
hvCpuCores :: String
1443
hvCpuCores = "cpu_cores"
1444

    
1445
hvCpuMask :: String
1446
hvCpuMask = "cpu_mask"
1447

    
1448
hvCpuSockets :: String
1449
hvCpuSockets = "cpu_sockets"
1450

    
1451
hvCpuThreads :: String
1452
hvCpuThreads = "cpu_threads"
1453

    
1454
hvCpuType :: String
1455
hvCpuType = "cpu_type"
1456

    
1457
hvCpuWeight :: String
1458
hvCpuWeight = "cpu_weight"
1459

    
1460
hvDeviceModel :: String
1461
hvDeviceModel = "device_model"
1462

    
1463
hvDiskCache :: String
1464
hvDiskCache = "disk_cache"
1465

    
1466
hvDiskType :: String
1467
hvDiskType = "disk_type"
1468

    
1469
hvInitrdPath :: String
1470
hvInitrdPath = "initrd_path"
1471

    
1472
hvInitScript :: String
1473
hvInitScript = "init_script"
1474

    
1475
hvKernelArgs :: String
1476
hvKernelArgs = "kernel_args"
1477

    
1478
hvKernelPath :: String
1479
hvKernelPath = "kernel_path"
1480

    
1481
hvKeymap :: String
1482
hvKeymap = "keymap"
1483

    
1484
hvKvmCdrom2ImagePath :: String
1485
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1486

    
1487
hvKvmCdromDiskType :: String
1488
hvKvmCdromDiskType = "cdrom_disk_type"
1489

    
1490
hvKvmExtra :: String
1491
hvKvmExtra = "kvm_extra"
1492

    
1493
hvKvmFlag :: String
1494
hvKvmFlag = "kvm_flag"
1495

    
1496
hvKvmFloppyImagePath :: String
1497
hvKvmFloppyImagePath = "floppy_image_path"
1498

    
1499
hvKvmMachineVersion :: String
1500
hvKvmMachineVersion = "machine_version"
1501

    
1502
hvKvmPath :: String
1503
hvKvmPath = "kvm_path"
1504

    
1505
hvKvmSpiceAudioCompr :: String
1506
hvKvmSpiceAudioCompr = "spice_playback_compression"
1507

    
1508
hvKvmSpiceBind :: String
1509
hvKvmSpiceBind = "spice_bind"
1510

    
1511
hvKvmSpiceIpVersion :: String
1512
hvKvmSpiceIpVersion = "spice_ip_version"
1513

    
1514
hvKvmSpiceJpegImgCompr :: String
1515
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1516

    
1517
hvKvmSpiceLosslessImgCompr :: String
1518
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1519

    
1520
hvKvmSpicePasswordFile :: String
1521
hvKvmSpicePasswordFile = "spice_password_file"
1522

    
1523
hvKvmSpiceStreamingVideoDetection :: String
1524
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1525

    
1526
hvKvmSpiceTlsCiphers :: String
1527
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1528

    
1529
hvKvmSpiceUseTls :: String
1530
hvKvmSpiceUseTls = "spice_use_tls"
1531

    
1532
hvKvmSpiceUseVdagent :: String
1533
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1534

    
1535
hvKvmSpiceZlibGlzImgCompr :: String
1536
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1537

    
1538
hvKvmUseChroot :: String
1539
hvKvmUseChroot = "use_chroot"
1540

    
1541
hvMemPath :: String
1542
hvMemPath = "mem_path"
1543

    
1544
hvMigrationBandwidth :: String
1545
hvMigrationBandwidth = "migration_bandwidth"
1546

    
1547
hvMigrationDowntime :: String
1548
hvMigrationDowntime = "migration_downtime"
1549

    
1550
hvMigrationMode :: String
1551
hvMigrationMode = "migration_mode"
1552

    
1553
hvMigrationPort :: String
1554
hvMigrationPort = "migration_port"
1555

    
1556
hvNicType :: String
1557
hvNicType = "nic_type"
1558

    
1559
hvPae :: String
1560
hvPae = "pae"
1561

    
1562
hvPassthrough :: String
1563
hvPassthrough = "pci_pass"
1564

    
1565
hvRebootBehavior :: String
1566
hvRebootBehavior = "reboot_behavior"
1567

    
1568
hvRootPath :: String
1569
hvRootPath = "root_path"
1570

    
1571
hvSecurityDomain :: String
1572
hvSecurityDomain = "security_domain"
1573

    
1574
hvSecurityModel :: String
1575
hvSecurityModel = "security_model"
1576

    
1577
hvSerialConsole :: String
1578
hvSerialConsole = "serial_console"
1579

    
1580
hvSerialSpeed :: String
1581
hvSerialSpeed = "serial_speed"
1582

    
1583
hvSoundhw :: String
1584
hvSoundhw = "soundhw"
1585

    
1586
hvUsbDevices :: String
1587
hvUsbDevices = "usb_devices"
1588

    
1589
hvUsbMouse :: String
1590
hvUsbMouse = "usb_mouse"
1591

    
1592
hvUseBootloader :: String
1593
hvUseBootloader = "use_bootloader"
1594

    
1595
hvUseLocaltime :: String
1596
hvUseLocaltime = "use_localtime"
1597

    
1598
hvVga :: String
1599
hvVga = "vga"
1600

    
1601
hvVhostNet :: String
1602
hvVhostNet = "vhost_net"
1603

    
1604
hvVifScript :: String
1605
hvVifScript = "vif_script"
1606

    
1607
hvVifType :: String
1608
hvVifType = "vif_type"
1609

    
1610
hvViridian :: String
1611
hvViridian = "viridian"
1612

    
1613
hvVncBindAddress :: String
1614
hvVncBindAddress = "vnc_bind_address"
1615

    
1616
hvVncPasswordFile :: String
1617
hvVncPasswordFile = "vnc_password_file"
1618

    
1619
hvVncTls :: String
1620
hvVncTls = "vnc_tls"
1621

    
1622
hvVncX509 :: String
1623
hvVncX509 = "vnc_x509_path"
1624

    
1625
hvVncX509Verify :: String
1626
hvVncX509Verify = "vnc_x509_verify"
1627

    
1628
hvVnetHdr :: String
1629
hvVnetHdr = "vnet_hdr"
1630

    
1631
hvXenCmd :: String
1632
hvXenCmd = "xen_cmd"
1633

    
1634
hvXenCpuid :: String
1635
hvXenCpuid = "cpuid"
1636

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

    
1652
hvsParameters :: FrozenSet String
1653
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1654

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

    
1731
-- * Migration statuses
1732

    
1733
hvMigrationActive :: String
1734
hvMigrationActive = "active"
1735

    
1736
hvMigrationCancelled :: String
1737
hvMigrationCancelled = "cancelled"
1738

    
1739
hvMigrationCompleted :: String
1740
hvMigrationCompleted = "completed"
1741

    
1742
hvMigrationFailed :: String
1743
hvMigrationFailed = "failed"
1744

    
1745
hvMigrationValidStatuses :: FrozenSet String
1746
hvMigrationValidStatuses =
1747
  ConstantUtils.mkSet [hvMigrationActive,
1748
                       hvMigrationCancelled,
1749
                       hvMigrationCompleted,
1750
                       hvMigrationFailed]
1751

    
1752
hvMigrationFailedStatuses :: FrozenSet String
1753
hvMigrationFailedStatuses =
1754
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1755

    
1756
-- | KVM-specific statuses
1757
--
1758
-- FIXME: this constant seems unnecessary
1759
hvKvmMigrationValidStatuses :: FrozenSet String
1760
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1761

    
1762
-- | Node info keys
1763
hvNodeinfoKeyVersion :: String
1764
hvNodeinfoKeyVersion = "hv_version"
1765

    
1766
-- * Hypervisor state
1767

    
1768
hvstCpuNode :: String
1769
hvstCpuNode = "cpu_node"
1770

    
1771
hvstCpuTotal :: String
1772
hvstCpuTotal = "cpu_total"
1773

    
1774
hvstMemoryHv :: String
1775
hvstMemoryHv = "mem_hv"
1776

    
1777
hvstMemoryNode :: String
1778
hvstMemoryNode = "mem_node"
1779

    
1780
hvstMemoryTotal :: String
1781
hvstMemoryTotal = "mem_total"
1782

    
1783
hvstsParameters :: FrozenSet String
1784
hvstsParameters =
1785
  ConstantUtils.mkSet [hvstCpuNode,
1786
                       hvstCpuTotal,
1787
                       hvstMemoryHv,
1788
                       hvstMemoryNode,
1789
                       hvstMemoryTotal]
1790

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

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

    
1808
-- * Disk state
1809

    
1810
dsDiskOverhead :: String
1811
dsDiskOverhead = "disk_overhead"
1812

    
1813
dsDiskReserved :: String
1814
dsDiskReserved = "disk_reserved"
1815

    
1816
dsDiskTotal :: String
1817
dsDiskTotal = "disk_total"
1818

    
1819
dsDefaults :: Map String Int
1820
dsDefaults =
1821
  Map.fromList
1822
  [(dsDiskTotal, 0),
1823
   (dsDiskReserved, 0),
1824
   (dsDiskOverhead, 0)]
1825

    
1826
dssParameterTypes :: Map String VType
1827
dssParameterTypes =
1828
  Map.fromList [(dsDiskTotal, VTypeInt),
1829
                (dsDiskReserved, VTypeInt),
1830
                (dsDiskOverhead, VTypeInt)]
1831

    
1832
dssParameters :: FrozenSet String
1833
dssParameters =
1834
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1835

    
1836
dsValidTypes :: FrozenSet String
1837
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1838

    
1839
-- Backend parameter names
1840

    
1841
beAlwaysFailover :: String
1842
beAlwaysFailover = "always_failover"
1843

    
1844
beAutoBalance :: String
1845
beAutoBalance = "auto_balance"
1846

    
1847
beMaxmem :: String
1848
beMaxmem = "maxmem"
1849

    
1850
-- | Deprecated and replaced by max and min mem
1851
beMemory :: String
1852
beMemory = "memory"
1853

    
1854
beMinmem :: String
1855
beMinmem = "minmem"
1856

    
1857
beSpindleUse :: String
1858
beSpindleUse = "spindle_use"
1859

    
1860
beVcpus :: String
1861
beVcpus = "vcpus"
1862

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

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

    
1879
besParameterCompat :: Map String VType
1880
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1881

    
1882
besParameters :: FrozenSet String
1883
besParameters =
1884
  ConstantUtils.mkSet [beAlwaysFailover,
1885
                       beAutoBalance,
1886
                       beMaxmem,
1887
                       beMinmem,
1888
                       beSpindleUse,
1889
                       beVcpus]
1890

    
1891
-- | Instance specs
1892
--
1893
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1894

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

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

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

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

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

    
1910
ispecSpindleUse :: String
1911
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1912

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

    
1923
ispecsParameters :: FrozenSet String
1924
ispecsParameters =
1925
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1926
                       ConstantUtils.ispecDiskCount,
1927
                       ConstantUtils.ispecDiskSize,
1928
                       ConstantUtils.ispecMemSize,
1929
                       ConstantUtils.ispecNicCount,
1930
                       ConstantUtils.ispecSpindleUse]
1931

    
1932
ispecsMinmax :: String
1933
ispecsMinmax = ConstantUtils.ispecsMinmax
1934

    
1935
ispecsMax :: String
1936
ispecsMax = "max"
1937

    
1938
ispecsMin :: String
1939
ispecsMin = "min"
1940

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

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

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

    
1950
ipolicySpindleRatio :: String
1951
ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
1952

    
1953
ispecsMinmaxKeys :: FrozenSet String
1954
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1955

    
1956
ipolicyParameters :: FrozenSet String
1957
ipolicyParameters =
1958
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1959
                       ConstantUtils.ipolicySpindleRatio]
1960

    
1961
ipolicyAllKeys :: FrozenSet String
1962
ipolicyAllKeys =
1963
  ConstantUtils.union ipolicyParameters $
1964
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1965
                       ConstantUtils.ispecsMinmax,
1966
                       ispecsStd]
1967

    
1968
-- | Node parameter names
1969

    
1970
ndExclusiveStorage :: String
1971
ndExclusiveStorage = "exclusive_storage"
1972

    
1973
ndOobProgram :: String
1974
ndOobProgram = "oob_program"
1975

    
1976
ndSpindleCount :: String
1977
ndSpindleCount = "spindle_count"
1978

    
1979
ndOvs :: String
1980
ndOvs = "ovs"
1981

    
1982
ndOvsLink :: String
1983
ndOvsLink = "ovs_link"
1984

    
1985
ndOvsName :: String
1986
ndOvsName = "ovs_name"
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

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

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

    
2011
-- * Logical Disks parameters
2012

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2167
-- * Dynamic disk parameters
2168

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

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

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

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

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

    
2184
-- * OOB supported commands
2185

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2355
-- * Hypervisor constants
2356

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

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

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

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

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

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

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

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

    
2381
vncBasePort :: Int
2382
vncBasePort = 5900
2383

    
2384
vncDefaultBindAddress :: String
2385
vncDefaultBindAddress = ip4AddressAny
2386

    
2387
-- * NIC types
2388

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

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

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

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

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

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

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

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

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

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

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

    
2436
-- * Vif types
2437

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

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

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

    
2448
-- * Disk types
2449

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2502
-- * Mouse types
2503

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

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

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

    
2513
-- * Boot order
2514

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

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

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

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

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

    
2531
-- * SPICE lossless image compression options
2532

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

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

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

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

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

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

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

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

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

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

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

    
2575
-- * SPICE video stream detection
2576

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

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

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

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

    
2592
-- * Security models
2593

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

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

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

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

    
2606
-- * Kvm flag values
2607

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

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

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

    
2617
-- * Migration type
2618

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

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

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

    
2629
-- * Cluster verify steps
2630

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

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

    
2638
-- * Cluster Verify error classes
2639

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

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

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

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

    
2652
-- * Cluster Verify error codes and documentation
2653

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2928
-- * Node verify constants
2929

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3008
-- * Instance status
3009

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

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

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

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

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

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

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

    
3031
inststWrongnode :: String
3032
inststWrongnode = Types.instanceStatusToRaw WrongNode
3033

    
3034
inststAll :: FrozenSet String
3035
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3036

    
3037
-- * Admin states
3038

    
3039
adminstDown :: String
3040
adminstDown = Types.adminStateToRaw AdminDown
3041

    
3042
adminstOffline :: String
3043
adminstOffline = Types.adminStateToRaw AdminOffline
3044

    
3045
adminstUp :: String
3046
adminstUp = Types.adminStateToRaw AdminUp
3047

    
3048
adminstAll :: FrozenSet String
3049
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3050

    
3051
-- * Node roles
3052

    
3053
nrDrained :: String
3054
nrDrained = Types.nodeRoleToRaw NRDrained
3055

    
3056
nrMaster :: String
3057
nrMaster = Types.nodeRoleToRaw NRMaster
3058

    
3059
nrMcandidate :: String
3060
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3061

    
3062
nrOffline :: String
3063
nrOffline = Types.nodeRoleToRaw NROffline
3064

    
3065
nrRegular :: String
3066
nrRegular = Types.nodeRoleToRaw NRRegular
3067

    
3068
nrAll :: FrozenSet String
3069
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3070

    
3071
-- * SSL certificate check constants (in days)
3072

    
3073
sslCertExpirationError :: Int
3074
sslCertExpirationError = 7
3075

    
3076
sslCertExpirationWarn :: Int
3077
sslCertExpirationWarn = 30
3078

    
3079
-- * Allocator framework constants
3080

    
3081
iallocatorVersion :: Int
3082
iallocatorVersion = 2
3083

    
3084
iallocatorDirIn :: String
3085
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3086

    
3087
iallocatorDirOut :: String
3088
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3089

    
3090
validIallocatorDirections :: FrozenSet String
3091
validIallocatorDirections =
3092
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3093

    
3094
iallocatorModeAlloc :: String
3095
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3096

    
3097
iallocatorModeChgGroup :: String
3098
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3099

    
3100
iallocatorModeMultiAlloc :: String
3101
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3102

    
3103
iallocatorModeNodeEvac :: String
3104
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3105

    
3106
iallocatorModeReloc :: String
3107
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3108

    
3109
validIallocatorModes :: FrozenSet String
3110
validIallocatorModes =
3111
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3112

    
3113
iallocatorSearchPath :: [String]
3114
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3115

    
3116
defaultIallocatorShortcut :: String
3117
defaultIallocatorShortcut = "."
3118

    
3119
-- * Node evacuation
3120

    
3121
nodeEvacPri :: String
3122
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3123

    
3124
nodeEvacSec :: String
3125
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3126

    
3127
nodeEvacAll :: String
3128
nodeEvacAll = Types.evacModeToRaw ChangeAll
3129

    
3130
nodeEvacModes :: FrozenSet String
3131
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3132

    
3133
-- * Job queue
3134

    
3135
jobQueueVersion :: Int
3136
jobQueueVersion = 1
3137

    
3138
jobQueueSizeHardLimit :: Int
3139
jobQueueSizeHardLimit = 5000
3140

    
3141
jobQueueFilesPerms :: Int
3142
jobQueueFilesPerms = 0o640
3143

    
3144
-- * Unchanged job return
3145

    
3146
jobNotchanged :: String
3147
jobNotchanged = "nochange"
3148

    
3149
-- * Job status
3150

    
3151
jobStatusQueued :: String
3152
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3153

    
3154
jobStatusWaiting :: String
3155
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3156

    
3157
jobStatusCanceling :: String
3158
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3159

    
3160
jobStatusRunning :: String
3161
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3162

    
3163
jobStatusCanceled :: String
3164
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3165

    
3166
jobStatusSuccess :: String
3167
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3168

    
3169
jobStatusError :: String
3170
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3171

    
3172
jobsPending :: FrozenSet String
3173
jobsPending =
3174
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3175

    
3176
jobsFinalized :: FrozenSet String
3177
jobsFinalized =
3178
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3179

    
3180
jobStatusAll :: FrozenSet String
3181
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3182

    
3183
-- * OpCode status
3184

    
3185
-- ** Not yet finalized opcodes
3186

    
3187
opStatusCanceling :: String
3188
opStatusCanceling = "canceling"
3189

    
3190
opStatusQueued :: String
3191
opStatusQueued = "queued"
3192

    
3193
opStatusRunning :: String
3194
opStatusRunning = "running"
3195

    
3196
opStatusWaiting :: String
3197
opStatusWaiting = "waiting"
3198

    
3199
-- ** Finalized opcodes
3200

    
3201
opStatusCanceled :: String
3202
opStatusCanceled = "canceled"
3203

    
3204
opStatusError :: String
3205
opStatusError = "error"
3206

    
3207
opStatusSuccess :: String
3208
opStatusSuccess = "success"
3209

    
3210
opsFinalized :: FrozenSet String
3211
opsFinalized =
3212
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3213

    
3214
-- * OpCode priority
3215

    
3216
opPrioLowest :: Int
3217
opPrioLowest = 19
3218

    
3219
opPrioHighest :: Int
3220
opPrioHighest = -20
3221

    
3222
opPrioLow :: Int
3223
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3224

    
3225
opPrioNormal :: Int
3226
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3227

    
3228
opPrioHigh :: Int
3229
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3230

    
3231
opPrioSubmitValid :: FrozenSet Int
3232
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3233

    
3234
opPrioDefault :: Int
3235
opPrioDefault = opPrioNormal
3236

    
3237
-- * Lock recalculate mode
3238

    
3239
locksAppend :: String
3240
locksAppend = "append"
3241

    
3242
locksReplace :: String
3243
locksReplace = "replace"
3244

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

    
3252
lockAttemptsMaxwait :: Double
3253
lockAttemptsMaxwait = 15.0
3254

    
3255
lockAttemptsMinwait :: Double
3256
lockAttemptsMinwait = 1.0
3257

    
3258
lockAttemptsTimeout :: Int
3259
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3260

    
3261
-- * Execution log types
3262

    
3263
elogMessage :: String
3264
elogMessage = Types.eLogTypeToRaw ELogMessage
3265

    
3266
elogRemoteImport :: String
3267
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3268

    
3269
elogJqueueTest :: String
3270
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3271

    
3272
-- * /etc/hosts modification
3273

    
3274
etcHostsAdd :: String
3275
etcHostsAdd = "add"
3276

    
3277
etcHostsRemove :: String
3278
etcHostsRemove = "remove"
3279

    
3280
-- * Job queue test
3281

    
3282
jqtMsgprefix :: String
3283
jqtMsgprefix = "TESTMSG="
3284

    
3285
jqtExec :: String
3286
jqtExec = "exec"
3287

    
3288
jqtExpandnames :: String
3289
jqtExpandnames = "expandnames"
3290

    
3291
jqtLogmsg :: String
3292
jqtLogmsg = "logmsg"
3293

    
3294
jqtStartmsg :: String
3295
jqtStartmsg = "startmsg"
3296

    
3297
jqtAll :: FrozenSet String
3298
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3299

    
3300
-- * Query resources
3301

    
3302
qrCluster :: String
3303
qrCluster = "cluster"
3304

    
3305
qrExport :: String
3306
qrExport = "export"
3307

    
3308
qrExtstorage :: String
3309
qrExtstorage = "extstorage"
3310

    
3311
qrGroup :: String
3312
qrGroup = "group"
3313

    
3314
qrInstance :: String
3315
qrInstance = "instance"
3316

    
3317
qrJob :: String
3318
qrJob = "job"
3319

    
3320
qrLock :: String
3321
qrLock = "lock"
3322

    
3323
qrNetwork :: String
3324
qrNetwork = "network"
3325

    
3326
qrNode :: String
3327
qrNode = "node"
3328

    
3329
qrOs :: String
3330
qrOs = "os"
3331

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

    
3344
-- | List of resources which can be queried using Local UniX Interface
3345
qrViaLuxi :: FrozenSet String
3346
qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob]
3347

    
3348
-- | List of resources which can be queried using RAPI
3349
qrViaRapi :: FrozenSet String
3350
qrViaRapi = qrViaLuxi
3351

    
3352
-- * Query field types
3353

    
3354
qftBool :: String
3355
qftBool = "bool"
3356

    
3357
qftNumber :: String
3358
qftNumber = "number"
3359

    
3360
qftOther :: String
3361
qftOther = "other"
3362

    
3363
qftText :: String
3364
qftText = "text"
3365

    
3366
qftTimestamp :: String
3367
qftTimestamp = "timestamp"
3368

    
3369
qftUnit :: String
3370
qftUnit = "unit"
3371

    
3372
qftUnknown :: String
3373
qftUnknown = "unknown"
3374

    
3375
qftAll :: FrozenSet String
3376
qftAll =
3377
  ConstantUtils.mkSet [qftBool,
3378
                       qftNumber,
3379
                       qftOther,
3380
                       qftText,
3381
                       qftTimestamp,
3382
                       qftUnit,
3383
                       qftUnknown]
3384

    
3385
-- * Query result field status
3386
--
3387
-- Don't change or reuse values as they're used by clients.
3388
--
3389
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3390

    
3391
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3392
rsNodata :: Int
3393
rsNodata = 2
3394

    
3395
rsNormal :: Int
3396
rsNormal = 0
3397

    
3398
-- | Resource marked offline
3399
rsOffline :: Int
3400
rsOffline = 4
3401

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

    
3408
rsUnknown :: Int
3409
rsUnknown = 1
3410

    
3411
rsAll :: FrozenSet Int
3412
rsAll =
3413
  ConstantUtils.mkSet [rsNodata,
3414
                       rsNormal,
3415
                       rsOffline,
3416
                       rsUnavail,
3417
                       rsUnknown]
3418

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

    
3427
-- * Max dynamic devices
3428

    
3429
maxDisks :: Int
3430
maxDisks = Types.maxDisks
3431

    
3432
maxNics :: Int
3433
maxNics = Types.maxNics
3434

    
3435
-- | SSCONF file prefix
3436
ssconfFileprefix :: String
3437
ssconfFileprefix = "ssconf_"
3438

    
3439
-- * SSCONF keys
3440

    
3441
ssClusterName :: String
3442
ssClusterName = "cluster_name"
3443

    
3444
ssClusterTags :: String
3445
ssClusterTags = "cluster_tags"
3446

    
3447
ssFileStorageDir :: String
3448
ssFileStorageDir = "file_storage_dir"
3449

    
3450
ssSharedFileStorageDir :: String
3451
ssSharedFileStorageDir = "shared_file_storage_dir"
3452

    
3453
ssMasterCandidates :: String
3454
ssMasterCandidates = "master_candidates"
3455

    
3456
ssMasterCandidatesIps :: String
3457
ssMasterCandidatesIps = "master_candidates_ips"
3458

    
3459
ssMasterIp :: String
3460
ssMasterIp = "master_ip"
3461

    
3462
ssMasterNetdev :: String
3463
ssMasterNetdev = "master_netdev"
3464

    
3465
ssMasterNetmask :: String
3466
ssMasterNetmask = "master_netmask"
3467

    
3468
ssMasterNode :: String
3469
ssMasterNode = "master_node"
3470

    
3471
ssNodeList :: String
3472
ssNodeList = "node_list"
3473

    
3474
ssNodePrimaryIps :: String
3475
ssNodePrimaryIps = "node_primary_ips"
3476

    
3477
ssNodeSecondaryIps :: String
3478
ssNodeSecondaryIps = "node_secondary_ips"
3479

    
3480
ssOfflineNodes :: String
3481
ssOfflineNodes = "offline_nodes"
3482

    
3483
ssOnlineNodes :: String
3484
ssOnlineNodes = "online_nodes"
3485

    
3486
ssPrimaryIpFamily :: String
3487
ssPrimaryIpFamily = "primary_ip_family"
3488

    
3489
ssInstanceList :: String
3490
ssInstanceList = "instance_list"
3491

    
3492
ssReleaseVersion :: String
3493
ssReleaseVersion = "release_version"
3494

    
3495
ssHypervisorList :: String
3496
ssHypervisorList = "hypervisor_list"
3497

    
3498
ssMaintainNodeHealth :: String
3499
ssMaintainNodeHealth = "maintain_node_health"
3500

    
3501
ssUidPool :: String
3502
ssUidPool = "uid_pool"
3503

    
3504
ssNodegroups :: String
3505
ssNodegroups = "nodegroups"
3506

    
3507
ssNetworks :: String
3508
ssNetworks = "networks"
3509

    
3510
-- | This is not a complete SSCONF key, but the prefix for the
3511
-- hypervisor keys
3512
ssHvparamsPref :: String
3513
ssHvparamsPref = "hvparams_"
3514

    
3515
-- * Hvparams keys
3516

    
3517
ssHvparamsXenChroot :: String
3518
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3519

    
3520
ssHvparamsXenFake :: String
3521
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3522

    
3523
ssHvparamsXenHvm :: String
3524
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3525

    
3526
ssHvparamsXenKvm :: String
3527
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3528

    
3529
ssHvparamsXenLxc :: String
3530
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3531

    
3532
ssHvparamsXenPvm :: String
3533
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3534

    
3535
validSsHvparamsKeys :: FrozenSet String
3536
validSsHvparamsKeys =
3537
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3538
                       ssHvparamsXenLxc,
3539
                       ssHvparamsXenFake,
3540
                       ssHvparamsXenHvm,
3541
                       ssHvparamsXenKvm,
3542
                       ssHvparamsXenPvm]
3543

    
3544
ssFilePerms :: Int
3545
ssFilePerms = 0o444
3546

    
3547
-- | Cluster wide default parameters
3548
defaultEnabledHypervisor :: String
3549
defaultEnabledHypervisor = htXenPvm
3550

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

    
3663
hvcGlobals :: FrozenSet String
3664
hvcGlobals =
3665
  ConstantUtils.mkSet [hvMigrationBandwidth,
3666
                       hvMigrationMode,
3667
                       hvMigrationPort,
3668
                       hvXenCmd]
3669

    
3670
becDefaults :: Map String PyValueEx
3671
becDefaults =
3672
  Map.fromList
3673
  [ (beMinmem, PyValueEx (128 :: Int))
3674
  , (beMaxmem, PyValueEx (128 :: Int))
3675
  , (beVcpus, PyValueEx (1 :: Int))
3676
  , (beAutoBalance, PyValueEx True)
3677
  , (beAlwaysFailover, PyValueEx False)
3678
  , (beSpindleUse, PyValueEx (1 :: Int))
3679
  ]
3680

    
3681
ndcDefaults :: Map String PyValueEx
3682
ndcDefaults =
3683
  Map.fromList
3684
  [ (ndOobProgram,       PyValueEx "")
3685
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3686
  , (ndExclusiveStorage, PyValueEx False)
3687
  , (ndOvs,              PyValueEx False)
3688
  , (ndOvsName,          PyValueEx defaultOvs)
3689
  , (ndOvsLink,          PyValueEx "")
3690
  ]
3691

    
3692
ndcGlobals :: FrozenSet String
3693
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3694

    
3695
-- | Default delay target measured in sectors
3696
defaultDelayTarget :: Int
3697
defaultDelayTarget = 1
3698

    
3699
defaultDiskCustom :: String
3700
defaultDiskCustom = ""
3701

    
3702
defaultDiskResync :: Bool
3703
defaultDiskResync = False
3704

    
3705
-- | Default fill target measured in sectors
3706
defaultFillTarget :: Int
3707
defaultFillTarget = 0
3708

    
3709
-- | Default mininum rate measured in KiB/s
3710
defaultMinRate :: Int
3711
defaultMinRate = 4 * 1024
3712

    
3713
defaultNetCustom :: String
3714
defaultNetCustom = ""
3715

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

    
3726
defaultRbdPool :: String
3727
defaultRbdPool = "rbd"
3728

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

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

    
3790
niccDefaults :: Map String PyValueEx
3791
niccDefaults =
3792
  Map.fromList
3793
  [ (nicMode, PyValueEx nicModeBridged)
3794
  , (nicLink, PyValueEx defaultBridge)
3795
  , (nicVlan, PyValueEx "")
3796
  ]
3797

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

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

    
3837
masterPoolSizeDefault :: Int
3838
masterPoolSizeDefault = 10
3839

    
3840
-- * Exclusive storage
3841

    
3842
-- | Error margin used to compare physical disks
3843
partMargin :: Double
3844
partMargin = 0.01
3845

    
3846
-- | Space reserved when creating instance disks
3847
partReserved :: Double
3848
partReserved = 0.02
3849

    
3850
-- * Confd
3851

    
3852
confdProtocolVersion :: Int
3853
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3854

    
3855
-- Confd request type
3856

    
3857
confdReqPing :: Int
3858
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3859

    
3860
confdReqNodeRoleByname :: Int
3861
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3862

    
3863
confdReqNodePipByInstanceIp :: Int
3864
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3865

    
3866
confdReqClusterMaster :: Int
3867
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3868

    
3869
confdReqNodePipList :: Int
3870
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3871

    
3872
confdReqMcPipList :: Int
3873
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3874

    
3875
confdReqInstancesIpsList :: Int
3876
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3877

    
3878
confdReqNodeDrbd :: Int
3879
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3880

    
3881
confdReqNodeInstances :: Int
3882
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3883

    
3884
confdReqs :: FrozenSet Int
3885
confdReqs =
3886
  ConstantUtils.mkSet .
3887
  map Types.confdRequestTypeToRaw $
3888
  [minBound..] \\ [ReqNodeInstances]
3889

    
3890
-- * Confd request type
3891

    
3892
confdReqfieldName :: Int
3893
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3894

    
3895
confdReqfieldIp :: Int
3896
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3897

    
3898
confdReqfieldMnodePip :: Int
3899
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3900

    
3901
-- * Confd repl status
3902

    
3903
confdReplStatusOk :: Int
3904
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3905

    
3906
confdReplStatusError :: Int
3907
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3908

    
3909
confdReplStatusNotimplemented :: Int
3910
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3911

    
3912
confdReplStatuses :: FrozenSet Int
3913
confdReplStatuses =
3914
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3915

    
3916
-- * Confd node role
3917

    
3918
confdNodeRoleMaster :: Int
3919
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3920

    
3921
confdNodeRoleCandidate :: Int
3922
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3923

    
3924
confdNodeRoleOffline :: Int
3925
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3926

    
3927
confdNodeRoleDrained :: Int
3928
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3929

    
3930
confdNodeRoleRegular :: Int
3931
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3932

    
3933
-- * A few common errors for confd
3934

    
3935
confdErrorUnknownEntry :: Int
3936
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3937

    
3938
confdErrorInternal :: Int
3939
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3940

    
3941
confdErrorArgument :: Int
3942
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3943

    
3944
-- * Confd request query fields
3945

    
3946
confdReqqLink :: String
3947
confdReqqLink = ConstantUtils.confdReqqLink
3948

    
3949
confdReqqIp :: String
3950
confdReqqIp = ConstantUtils.confdReqqIp
3951

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

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

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

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

    
3974
-- | If we receive more than one update in this amount of
3975
-- microseconds, we move to polling every RATELIMIT seconds, rather
3976
-- than relying on inotify, to be able to serve more requests.
3977
confdConfigReloadRatelimit :: Int
3978
confdConfigReloadRatelimit = 250000
3979

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

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

    
3995
-- | Timeout in seconds to expire pending query request in the confd
3996
-- client library. We don't actually expect any answer more than 10
3997
-- seconds after we sent a request.
3998
confdClientExpireTimeout :: Int
3999
confdClientExpireTimeout = 10
4000

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

    
4010
-- * User-id pool minimum/maximum acceptable user-ids
4011

    
4012
uidpoolUidMin :: Int
4013
uidpoolUidMin = 0
4014

    
4015
-- | Assuming 32 bit user-ids
4016
uidpoolUidMax :: Integer
4017
uidpoolUidMax = 2 ^ 32 - 1
4018

    
4019
-- | Name or path of the pgrep command
4020
pgrep :: String
4021
pgrep = "pgrep"
4022

    
4023
-- | Name of the node group that gets created at cluster init or
4024
-- upgrade
4025
initialNodeGroupName :: String
4026
initialNodeGroupName = "default"
4027

    
4028
-- * Possible values for NodeGroup.alloc_policy
4029

    
4030
allocPolicyLastResort :: String
4031
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4032

    
4033
allocPolicyPreferred :: String
4034
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4035

    
4036
allocPolicyUnallocable :: String
4037
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4038

    
4039
validAllocPolicies :: [String]
4040
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4041

    
4042
-- | Temporary external/shared storage parameters
4043
blockdevDriverManual :: String
4044
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4045

    
4046
-- | 'qemu-img' path, required for 'ovfconverter'
4047
qemuimgPath :: String
4048
qemuimgPath = AutoConf.qemuimgPath
4049

    
4050
-- | Whether htools was enabled at compilation time
4051
--
4052
-- FIXME: this should be moved next to the other enable constants,
4053
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4054
htools :: Bool
4055
htools = AutoConf.htools
4056

    
4057
-- | The hail iallocator
4058
iallocHail :: String
4059
iallocHail = "hail"
4060

    
4061
-- * Fake opcodes for functions that have hooks attached to them via
4062
-- backend.RunLocalHooks
4063

    
4064
fakeOpMasterTurndown :: String
4065
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4066

    
4067
fakeOpMasterTurnup :: String
4068
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4069

    
4070
-- * SSH key types
4071

    
4072
sshkDsa :: String
4073
sshkDsa = "dsa"
4074

    
4075
sshkRsa :: String
4076
sshkRsa = "rsa"
4077

    
4078
sshkAll :: FrozenSet String
4079
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4080

    
4081
-- * SSH authorized key types
4082

    
4083
sshakDss :: String
4084
sshakDss = "ssh-dss"
4085

    
4086
sshakRsa :: String
4087
sshakRsa = "ssh-rsa"
4088

    
4089
sshakAll :: FrozenSet String
4090
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4091

    
4092
-- * SSH setup
4093

    
4094
sshsClusterName :: String
4095
sshsClusterName = "cluster_name"
4096

    
4097
sshsSshHostKey :: String
4098
sshsSshHostKey = "ssh_host_key"
4099

    
4100
sshsSshRootKey :: String
4101
sshsSshRootKey = "ssh_root_key"
4102

    
4103
sshsNodeDaemonCertificate :: String
4104
sshsNodeDaemonCertificate = "node_daemon_certificate"
4105

    
4106
-- * Key files for SSH daemon
4107

    
4108
sshHostDsaPriv :: String
4109
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4110

    
4111
sshHostDsaPub :: String
4112
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4113

    
4114
sshHostRsaPriv :: String
4115
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4116

    
4117
sshHostRsaPub :: String
4118
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4119

    
4120
sshDaemonKeyfiles :: Map String (String, String)
4121
sshDaemonKeyfiles =
4122
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4123
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4124
               ]
4125

    
4126
-- * Node daemon setup
4127

    
4128
ndsClusterName :: String
4129
ndsClusterName = "cluster_name"
4130

    
4131
ndsNodeDaemonCertificate :: String
4132
ndsNodeDaemonCertificate = "node_daemon_certificate"
4133

    
4134
ndsSsconf :: String
4135
ndsSsconf = "ssconf"
4136

    
4137
ndsStartNodeDaemon :: String
4138
ndsStartNodeDaemon = "start_node_daemon"
4139

    
4140
-- * The source reasons for the execution of an OpCode
4141

    
4142
opcodeReasonSrcClient :: String
4143
opcodeReasonSrcClient = "gnt:client"
4144

    
4145
opcodeReasonSrcNoded :: String
4146
opcodeReasonSrcNoded = "gnt:daemon:noded"
4147

    
4148
opcodeReasonSrcOpcode :: String
4149
opcodeReasonSrcOpcode = "gnt:opcode"
4150

    
4151
opcodeReasonSrcRlib2 :: String
4152
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4153

    
4154
opcodeReasonSrcUser :: String
4155
opcodeReasonSrcUser = "gnt:user"
4156

    
4157
opcodeReasonSources :: FrozenSet String
4158
opcodeReasonSources =
4159
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4160
                       opcodeReasonSrcNoded,
4161
                       opcodeReasonSrcOpcode,
4162
                       opcodeReasonSrcRlib2,
4163
                       opcodeReasonSrcUser]
4164

    
4165
-- | Path generating random UUID
4166
randomUuidFile :: String
4167
randomUuidFile = ConstantUtils.randomUuidFile
4168

    
4169
-- * Auto-repair tag prefixes
4170

    
4171
autoRepairTagPrefix :: String
4172
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4173

    
4174
autoRepairTagEnabled :: String
4175
autoRepairTagEnabled = autoRepairTagPrefix
4176

    
4177
autoRepairTagPending :: String
4178
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4179

    
4180
autoRepairTagResult :: String
4181
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4182

    
4183
autoRepairTagSuspended :: String
4184
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4185

    
4186
-- * Auto-repair levels
4187

    
4188
autoRepairFailover :: String
4189
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4190

    
4191
autoRepairFixStorage :: String
4192
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4193

    
4194
autoRepairMigrate :: String
4195
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4196

    
4197
autoRepairReinstall :: String
4198
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4199

    
4200
autoRepairAllTypes :: FrozenSet String
4201
autoRepairAllTypes =
4202
  ConstantUtils.mkSet [autoRepairFailover,
4203
                       autoRepairFixStorage,
4204
                       autoRepairMigrate,
4205
                       autoRepairReinstall]
4206

    
4207
-- * Auto-repair results
4208

    
4209
autoRepairEnoperm :: String
4210
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4211

    
4212
autoRepairFailure :: String
4213
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4214

    
4215
autoRepairSuccess :: String
4216
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4217

    
4218
autoRepairAllResults :: FrozenSet String
4219
autoRepairAllResults =
4220
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4221

    
4222
-- | The version identifier for builtin data collectors
4223
builtinDataCollectorVersion :: String
4224
builtinDataCollectorVersion = "B"
4225

    
4226
-- | The reason trail opcode parameter name
4227
opcodeReason :: String
4228
opcodeReason = "reason"
4229

    
4230
diskstatsFile :: String
4231
diskstatsFile = "/proc/diskstats"
4232

    
4233
-- *  CPU load collector
4234

    
4235
statFile :: String
4236
statFile = "/proc/stat"
4237

    
4238
cpuavgloadBufferSize :: Int
4239
cpuavgloadBufferSize = 150
4240

    
4241
cpuavgloadWindowSize :: Int
4242
cpuavgloadWindowSize = 600
4243

    
4244
-- * Monitoring daemon
4245

    
4246
-- | Mond's variable for periodical data collection
4247
mondTimeInterval :: Int
4248
mondTimeInterval = 5
4249

    
4250
-- | Mond's latest API version
4251
mondLatestApiVersion :: Int
4252
mondLatestApiVersion = 1
4253

    
4254
-- * Disk access modes
4255

    
4256
diskUserspace :: String
4257
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4258

    
4259
diskKernelspace :: String
4260
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4261

    
4262
diskValidAccessModes :: FrozenSet String
4263
diskValidAccessModes =
4264
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4265

    
4266
-- | Timeout for queue draining in upgrades
4267
upgradeQueueDrainTimeout :: Int
4268
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4269

    
4270
-- | Intervall at which the queue is polled during upgrades
4271
upgradeQueuePollInterval :: Int
4272
upgradeQueuePollInterval  = 10
4273

    
4274
-- * Hotplug Actions
4275

    
4276
hotplugActionAdd :: String
4277
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4278

    
4279
hotplugActionRemove :: String
4280
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4281

    
4282
hotplugActionModify :: String
4283
hotplugActionModify = Types.hotplugActionToRaw HAMod
4284

    
4285
hotplugAllActions :: FrozenSet String
4286
hotplugAllActions =
4287
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4288

    
4289
-- * Hotplug Device Targets
4290

    
4291
hotplugTargetNic :: String
4292
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4293

    
4294
hotplugTargetDisk :: String
4295
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4296

    
4297
hotplugAllTargets :: FrozenSet String
4298
hotplugAllTargets =
4299
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4300

    
4301
-- | Timeout for disk removal (seconds)
4302
diskRemoveRetryTimeout :: Int
4303
diskRemoveRetryTimeout = 30
4304

    
4305
-- | Interval between disk removal retries (seconds)
4306
diskRemoveRetryInterval :: Int
4307
diskRemoveRetryInterval  = 3
4308

    
4309
-- * UUID regex
4310

    
4311
uuidRegex :: String
4312
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4313

    
4314
-- * Luxi constants
4315

    
4316
luxiKeyMethod :: String
4317
luxiKeyMethod = "method"
4318

    
4319
luxiKeyArgs :: String
4320
luxiKeyArgs = "args"
4321

    
4322
luxiKeySuccess :: String
4323
luxiKeySuccess = "success"
4324

    
4325
luxiKeyResult :: String
4326
luxiKeyResult = "result"
4327

    
4328
luxiKeyVersion :: String
4329
luxiKeyVersion = "version"
4330

    
4331
luxiReqSubmitJob :: String
4332
luxiReqSubmitJob = "SubmitJob"
4333

    
4334
luxiReqSubmitJobToDrainedQueue :: String
4335
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4336

    
4337
luxiReqSubmitManyJobs :: String
4338
luxiReqSubmitManyJobs = "SubmitManyJobs"
4339

    
4340
luxiReqWaitForJobChange :: String
4341
luxiReqWaitForJobChange = "WaitForJobChange"
4342

    
4343
luxiReqCancelJob :: String
4344
luxiReqCancelJob = "CancelJob"
4345

    
4346
luxiReqArchiveJob :: String
4347
luxiReqArchiveJob = "ArchiveJob"
4348

    
4349
luxiReqChangeJobPriority :: String
4350
luxiReqChangeJobPriority = "ChangeJobPriority"
4351

    
4352
luxiReqAutoArchiveJobs :: String
4353
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4354

    
4355
luxiReqQuery :: String
4356
luxiReqQuery = "Query"
4357

    
4358
luxiReqQueryFields :: String
4359
luxiReqQueryFields = "QueryFields"
4360

    
4361
luxiReqQueryJobs :: String
4362
luxiReqQueryJobs = "QueryJobs"
4363

    
4364
luxiReqQueryInstances :: String
4365
luxiReqQueryInstances = "QueryInstances"
4366

    
4367
luxiReqQueryNodes :: String
4368
luxiReqQueryNodes = "QueryNodes"
4369

    
4370
luxiReqQueryGroups :: String
4371
luxiReqQueryGroups = "QueryGroups"
4372

    
4373
luxiReqQueryNetworks :: String
4374
luxiReqQueryNetworks = "QueryNetworks"
4375

    
4376
luxiReqQueryExports :: String
4377
luxiReqQueryExports = "QueryExports"
4378

    
4379
luxiReqQueryConfigValues :: String
4380
luxiReqQueryConfigValues = "QueryConfigValues"
4381

    
4382
luxiReqQueryClusterInfo :: String
4383
luxiReqQueryClusterInfo = "QueryClusterInfo"
4384

    
4385
luxiReqQueryTags :: String
4386
luxiReqQueryTags = "QueryTags"
4387

    
4388
luxiReqSetDrainFlag :: String
4389
luxiReqSetDrainFlag = "SetDrainFlag"
4390

    
4391
luxiReqSetWatcherPause :: String
4392
luxiReqSetWatcherPause = "SetWatcherPause"
4393

    
4394
luxiReqAll :: FrozenSet String
4395
luxiReqAll =
4396
  ConstantUtils.mkSet
4397
  [ luxiReqArchiveJob
4398
  , luxiReqAutoArchiveJobs
4399
  , luxiReqCancelJob
4400
  , luxiReqChangeJobPriority
4401
  , luxiReqQuery
4402
  , luxiReqQueryClusterInfo
4403
  , luxiReqQueryConfigValues
4404
  , luxiReqQueryExports
4405
  , luxiReqQueryFields
4406
  , luxiReqQueryGroups
4407
  , luxiReqQueryInstances
4408
  , luxiReqQueryJobs
4409
  , luxiReqQueryNodes
4410
  , luxiReqQueryNetworks
4411
  , luxiReqQueryTags
4412
  , luxiReqSetDrainFlag
4413
  , luxiReqSetWatcherPause
4414
  , luxiReqSubmitJob
4415
  , luxiReqSubmitJobToDrainedQueue
4416
  , luxiReqSubmitManyJobs
4417
  , luxiReqWaitForJobChange
4418
  ]
4419

    
4420
luxiDefCtmo :: Int
4421
luxiDefCtmo = 10
4422

    
4423
luxiDefRwto :: Int
4424
luxiDefRwto = 60
4425

    
4426
-- | 'WaitForJobChange' timeout
4427
luxiWfjcTimeout :: Int
4428
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4429

    
4430
-- * Query language constants
4431

    
4432
-- ** Logic operators with one or more operands, each of which is a
4433
-- filter on its own
4434

    
4435
qlangOpAnd :: String
4436
qlangOpAnd = "&"
4437

    
4438
qlangOpOr :: String
4439
qlangOpOr = "|"
4440

    
4441
-- ** Unary operators with exactly one operand
4442

    
4443
qlangOpNot :: String
4444
qlangOpNot = "!"
4445

    
4446
qlangOpTrue :: String
4447
qlangOpTrue = "?"
4448

    
4449
-- ** Binary operators with exactly two operands, the field name and
4450
-- an operator-specific value
4451

    
4452
qlangOpContains :: String
4453
qlangOpContains = "=[]"
4454

    
4455
qlangOpEqual :: String
4456
qlangOpEqual = "="
4457

    
4458
qlangOpGe :: String
4459
qlangOpGe = ">="
4460

    
4461
qlangOpGt :: String
4462
qlangOpGt = ">"
4463

    
4464
qlangOpLe :: String
4465
qlangOpLe = "<="
4466

    
4467
qlangOpLt :: String
4468
qlangOpLt = "<"
4469

    
4470
qlangOpNotEqual :: String
4471
qlangOpNotEqual = "!="
4472

    
4473
qlangOpRegexp :: String
4474
qlangOpRegexp = "=~"
4475

    
4476
-- | Characters used for detecting user-written filters (see
4477
-- L{_CheckFilter})
4478

    
4479
qlangFilterDetectionChars :: FrozenSet String
4480
qlangFilterDetectionChars =
4481
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4482
                       ")", "(", "\x0b", "\n",
4483
                       "\r", "\x0c", "/", "<",
4484
                       "\t", ">", "=", "\\", "~"]
4485

    
4486
-- | Characters used to detect globbing filters
4487
qlangGlobDetectionChars :: FrozenSet String
4488
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4489

    
4490
-- * Error related constants
4491
--
4492
-- 'OpPrereqError' failure types
4493

    
4494
-- | Environment error (e.g. node disk error)
4495
errorsEcodeEnviron :: String
4496
errorsEcodeEnviron = "environment_error"
4497

    
4498
-- | Entity already exists
4499
errorsEcodeExists :: String
4500
errorsEcodeExists = "already_exists"
4501

    
4502
-- | Internal cluster error
4503
errorsEcodeFault :: String
4504
errorsEcodeFault = "internal_error"
4505

    
4506
-- | Wrong arguments (at syntax level)
4507
errorsEcodeInval :: String
4508
errorsEcodeInval = "wrong_input"
4509

    
4510
-- | Entity not found
4511
errorsEcodeNoent :: String
4512
errorsEcodeNoent = "unknown_entity"
4513

    
4514
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4515
errorsEcodeNores :: String
4516
errorsEcodeNores = "insufficient_resources"
4517

    
4518
-- | Resource not unique (e.g. MAC or IP duplication)
4519
errorsEcodeNotunique :: String
4520
errorsEcodeNotunique = "resource_not_unique"
4521

    
4522
-- | Resolver errors
4523
errorsEcodeResolver :: String
4524
errorsEcodeResolver = "resolver_error"
4525

    
4526
-- | Wrong entity state
4527
errorsEcodeState :: String
4528
errorsEcodeState = "wrong_state"
4529

    
4530
-- | Temporarily out of resources; operation can be tried again
4531
errorsEcodeTempNores :: String
4532
errorsEcodeTempNores = "temp_insufficient_resources"
4533

    
4534
errorsEcodeAll :: FrozenSet String
4535
errorsEcodeAll =
4536
  ConstantUtils.mkSet [ errorsEcodeNores
4537
                      , errorsEcodeExists
4538
                      , errorsEcodeState
4539
                      , errorsEcodeNotunique
4540
                      , errorsEcodeTempNores
4541
                      , errorsEcodeNoent
4542
                      , errorsEcodeFault
4543
                      , errorsEcodeResolver
4544
                      , errorsEcodeInval
4545
                      , errorsEcodeEnviron
4546
                      ]
4547

    
4548
-- * Jstore related constants
4549

    
4550
jstoreJobsPerArchiveDirectory :: Int
4551
jstoreJobsPerArchiveDirectory = 10000