Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 8e4aacdc

History | View | Annotate | Download (114.7 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
-- | The set of lvm-based disk templates
896
dtsHaveAccess :: FrozenSet String
897
dtsHaveAccess = ConstantUtils.mkSet $
898
  map Types.diskTemplateToRaw [DTRbd, DTExt]
899

    
900
-- * Drbd
901

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

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

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

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

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

    
918
-- * Drbd barrier types
919

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

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

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

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

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

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

    
950
-- * File backend driver
951

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

    
955
fdBlktap2 :: String
956
fdBlktap2 = Types.fileDriverToRaw FileBlktap2
957

    
958
fdLoop :: String
959
fdLoop = Types.fileDriverToRaw FileLoop
960

    
961
fdDefault :: String
962
fdDefault = fdLoop
963

    
964
fileDriver :: FrozenSet String
965
fileDriver =
966
  ConstantUtils.mkSet $
967
  map Types.fileDriverToRaw [minBound..]
968

    
969
-- | The set of drbd-like disk types
970
dtsDrbd :: FrozenSet String
971
dtsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
972

    
973
-- * Disk access mode
974

    
975
diskRdonly :: String
976
diskRdonly = Types.diskModeToRaw DiskRdOnly
977

    
978
diskRdwr :: String
979
diskRdwr = Types.diskModeToRaw DiskRdWr
980

    
981
diskAccessSet :: FrozenSet String
982
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
983

    
984
-- * Disk replacement mode
985

    
986
replaceDiskAuto :: String
987
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
988

    
989
replaceDiskChg :: String
990
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
991

    
992
replaceDiskPri :: String
993
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
994

    
995
replaceDiskSec :: String
996
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
997

    
998
replaceModes :: FrozenSet String
999
replaceModes =
1000
  ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
1001

    
1002
-- * Instance export mode
1003

    
1004
exportModeLocal :: String
1005
exportModeLocal = Types.exportModeToRaw ExportModeLocal
1006

    
1007
exportModeRemote :: String
1008
exportModeRemote = Types.exportModeToRaw ExportModeRemote
1009

    
1010
exportModes :: FrozenSet String
1011
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
1012

    
1013
-- * Instance creation modes
1014

    
1015
instanceCreate :: String
1016
instanceCreate = Types.instCreateModeToRaw InstCreate
1017

    
1018
instanceImport :: String
1019
instanceImport = Types.instCreateModeToRaw InstImport
1020

    
1021
instanceRemoteImport :: String
1022
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
1023

    
1024
instanceCreateModes :: FrozenSet String
1025
instanceCreateModes =
1026
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
1027

    
1028
-- * Remote import/export handshake message and version
1029

    
1030
rieHandshake :: String
1031
rieHandshake = "Hi, I'm Ganeti"
1032

    
1033
rieVersion :: Int
1034
rieVersion = 0
1035

    
1036
-- | Remote import/export certificate validity (seconds)
1037
rieCertValidity :: Int
1038
rieCertValidity = 24 * 60 * 60
1039

    
1040
-- | Export only: how long to wait per connection attempt (seconds)
1041
rieConnectAttemptTimeout :: Int
1042
rieConnectAttemptTimeout = 20
1043

    
1044
-- | Export only: number of attempts to connect
1045
rieConnectRetries :: Int
1046
rieConnectRetries = 10
1047

    
1048
-- | Overall timeout for establishing connection
1049
rieConnectTimeout :: Int
1050
rieConnectTimeout = 180
1051

    
1052
-- | Give child process up to 5 seconds to exit after sending a signal
1053
childLingerTimeout :: Double
1054
childLingerTimeout = 5.0
1055

    
1056
-- * Import/export config options
1057

    
1058
inisectBep :: String
1059
inisectBep = "backend"
1060

    
1061
inisectExp :: String
1062
inisectExp = "export"
1063

    
1064
inisectHyp :: String
1065
inisectHyp = "hypervisor"
1066

    
1067
inisectIns :: String
1068
inisectIns = "instance"
1069

    
1070
inisectOsp :: String
1071
inisectOsp = "os"
1072

    
1073
-- * Dynamic device modification
1074

    
1075
ddmAdd :: String
1076
ddmAdd = Types.ddmFullToRaw DdmFullAdd
1077

    
1078
ddmModify :: String
1079
ddmModify = Types.ddmFullToRaw DdmFullModify
1080

    
1081
ddmRemove :: String
1082
ddmRemove = Types.ddmFullToRaw DdmFullRemove
1083

    
1084
ddmsValues :: FrozenSet String
1085
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
1086

    
1087
ddmsValuesWithModify :: FrozenSet String
1088
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
1089

    
1090
-- * Common exit codes
1091

    
1092
exitSuccess :: Int
1093
exitSuccess = 0
1094

    
1095
exitFailure :: Int
1096
exitFailure = ConstantUtils.exitFailure
1097

    
1098
exitNotcluster :: Int
1099
exitNotcluster = 5
1100

    
1101
exitNotmaster :: Int
1102
exitNotmaster = 11
1103

    
1104
exitNodesetupError :: Int
1105
exitNodesetupError = 12
1106

    
1107
-- | Need user confirmation
1108
exitConfirmation :: Int
1109
exitConfirmation = 13
1110

    
1111
-- | Exit code for query operations with unknown fields
1112
exitUnknownField :: Int
1113
exitUnknownField = 14
1114

    
1115
-- * Tags
1116

    
1117
tagCluster :: String
1118
tagCluster = Types.tagKindToRaw TagKindCluster
1119

    
1120
tagInstance :: String
1121
tagInstance = Types.tagKindToRaw TagKindInstance
1122

    
1123
tagNetwork :: String
1124
tagNetwork = Types.tagKindToRaw TagKindNetwork
1125

    
1126
tagNode :: String
1127
tagNode = Types.tagKindToRaw TagKindNode
1128

    
1129
tagNodegroup :: String
1130
tagNodegroup = Types.tagKindToRaw TagKindGroup
1131

    
1132
validTagTypes :: FrozenSet String
1133
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
1134

    
1135
maxTagLen :: Int
1136
maxTagLen = 128
1137

    
1138
maxTagsPerObj :: Int
1139
maxTagsPerObj = 4096
1140

    
1141
-- * Others
1142

    
1143
defaultBridge :: String
1144
defaultBridge = "xen-br0"
1145

    
1146
defaultOvs :: String
1147
defaultOvs = "switch1"
1148

    
1149
-- | 60 MiB/s, expressed in KiB/s
1150
classicDrbdSyncSpeed :: Int
1151
classicDrbdSyncSpeed = 60 * 1024
1152

    
1153
ip4AddressAny :: String
1154
ip4AddressAny = "0.0.0.0"
1155

    
1156
ip4AddressLocalhost :: String
1157
ip4AddressLocalhost = "127.0.0.1"
1158

    
1159
ip6AddressAny :: String
1160
ip6AddressAny = "::"
1161

    
1162
ip6AddressLocalhost :: String
1163
ip6AddressLocalhost = "::1"
1164

    
1165
ip4Version :: Int
1166
ip4Version = 4
1167

    
1168
ip6Version :: Int
1169
ip6Version = 6
1170

    
1171
validIpVersions :: FrozenSet Int
1172
validIpVersions = ConstantUtils.mkSet [ip4Version, ip6Version]
1173

    
1174
tcpPingTimeout :: Int
1175
tcpPingTimeout = 10
1176

    
1177
defaultVg :: String
1178
defaultVg = "xenvg"
1179

    
1180
defaultDrbdHelper :: String
1181
defaultDrbdHelper = "/bin/true"
1182

    
1183
minVgSize :: Int
1184
minVgSize = 20480
1185

    
1186
defaultMacPrefix :: String
1187
defaultMacPrefix = "aa:00:00"
1188

    
1189
-- | Default maximum instance wait time (seconds)
1190
defaultShutdownTimeout :: Int
1191
defaultShutdownTimeout = 120
1192

    
1193
-- | Node clock skew (seconds)
1194
nodeMaxClockSkew :: Int
1195
nodeMaxClockSkew = 150
1196

    
1197
-- | Time for an intra-cluster disk transfer to wait for a connection
1198
diskTransferConnectTimeout :: Int
1199
diskTransferConnectTimeout = 60
1200

    
1201
-- | Disk index separator
1202
diskSeparator :: String
1203
diskSeparator = AutoConf.diskSeparator
1204

    
1205
ipCommandPath :: String
1206
ipCommandPath = AutoConf.ipPath
1207

    
1208
-- | Key for job IDs in opcode result
1209
jobIdsKey :: String
1210
jobIdsKey = "jobs"
1211

    
1212
-- * Runparts results
1213

    
1214
runpartsErr :: Int
1215
runpartsErr = 2
1216

    
1217
runpartsRun :: Int
1218
runpartsRun = 1
1219

    
1220
runpartsSkip :: Int
1221
runpartsSkip = 0
1222

    
1223
runpartsStatus :: [Int]
1224
runpartsStatus = [runpartsErr, runpartsRun, runpartsSkip]
1225

    
1226
-- * RPC
1227

    
1228
rpcEncodingNone :: Int
1229
rpcEncodingNone = 0
1230

    
1231
rpcEncodingZlibBase64 :: Int
1232
rpcEncodingZlibBase64 = 1
1233

    
1234
-- * Timeout table
1235
--
1236
-- Various time constants for the timeout table
1237

    
1238
rpcTmoUrgent :: Int
1239
rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
1240

    
1241
rpcTmoFast :: Int
1242
rpcTmoFast = Types.rpcTimeoutToRaw Fast
1243

    
1244
rpcTmoNormal :: Int
1245
rpcTmoNormal = Types.rpcTimeoutToRaw Normal
1246

    
1247
rpcTmoSlow :: Int
1248
rpcTmoSlow = Types.rpcTimeoutToRaw Slow
1249

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

    
1256
-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
1257
-- in the 'Ganeti.THH.deCamelCase' function and generate the correct
1258
-- Python name.
1259
rpcTmo_1day :: Int
1260
rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
1261

    
1262
-- | Timeout for connecting to nodes (seconds)
1263
rpcConnectTimeout :: Int
1264
rpcConnectTimeout = 5
1265

    
1266
-- OS
1267

    
1268
osScriptCreate :: String
1269
osScriptCreate = "create"
1270

    
1271
osScriptExport :: String
1272
osScriptExport = "export"
1273

    
1274
osScriptImport :: String
1275
osScriptImport = "import"
1276

    
1277
osScriptRename :: String
1278
osScriptRename = "rename"
1279

    
1280
osScriptVerify :: String
1281
osScriptVerify = "verify"
1282

    
1283
osScripts :: [String]
1284
osScripts = [osScriptCreate, osScriptExport, osScriptImport, osScriptRename,
1285
             osScriptVerify]
1286

    
1287
osApiFile :: String
1288
osApiFile = "ganeti_api_version"
1289

    
1290
osVariantsFile :: String
1291
osVariantsFile = "variants.list"
1292

    
1293
osParametersFile :: String
1294
osParametersFile = "parameters.list"
1295

    
1296
osValidateParameters :: String
1297
osValidateParameters = "parameters"
1298

    
1299
osValidateCalls :: FrozenSet String
1300
osValidateCalls = ConstantUtils.mkSet [osValidateParameters]
1301

    
1302
-- | External Storage (ES) related constants
1303

    
1304
esActionAttach :: String
1305
esActionAttach = "attach"
1306

    
1307
esActionCreate :: String
1308
esActionCreate = "create"
1309

    
1310
esActionDetach :: String
1311
esActionDetach = "detach"
1312

    
1313
esActionGrow :: String
1314
esActionGrow = "grow"
1315

    
1316
esActionRemove :: String
1317
esActionRemove = "remove"
1318

    
1319
esActionSetinfo :: String
1320
esActionSetinfo = "setinfo"
1321

    
1322
esActionVerify :: String
1323
esActionVerify = "verify"
1324

    
1325
esScriptCreate :: String
1326
esScriptCreate = esActionCreate
1327

    
1328
esScriptRemove :: String
1329
esScriptRemove = esActionRemove
1330

    
1331
esScriptGrow :: String
1332
esScriptGrow = esActionGrow
1333

    
1334
esScriptAttach :: String
1335
esScriptAttach = esActionAttach
1336

    
1337
esScriptDetach :: String
1338
esScriptDetach = esActionDetach
1339

    
1340
esScriptSetinfo :: String
1341
esScriptSetinfo = esActionSetinfo
1342

    
1343
esScriptVerify :: String
1344
esScriptVerify = esActionVerify
1345

    
1346
esScripts :: FrozenSet String
1347
esScripts =
1348
  ConstantUtils.mkSet [esScriptAttach,
1349
                       esScriptCreate,
1350
                       esScriptDetach,
1351
                       esScriptGrow,
1352
                       esScriptRemove,
1353
                       esScriptSetinfo,
1354
                       esScriptVerify]
1355

    
1356
esParametersFile :: String
1357
esParametersFile = "parameters.list"
1358

    
1359
-- * Reboot types
1360

    
1361
instanceRebootSoft :: String
1362
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
1363

    
1364
instanceRebootHard :: String
1365
instanceRebootHard = Types.rebootTypeToRaw RebootHard
1366

    
1367
instanceRebootFull :: String
1368
instanceRebootFull = Types.rebootTypeToRaw RebootFull
1369

    
1370
rebootTypes :: FrozenSet String
1371
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
1372

    
1373
-- * Instance reboot behaviors
1374

    
1375
instanceRebootAllowed :: String
1376
instanceRebootAllowed = "reboot"
1377

    
1378
instanceRebootExit :: String
1379
instanceRebootExit = "exit"
1380

    
1381
rebootBehaviors :: [String]
1382
rebootBehaviors = [instanceRebootAllowed, instanceRebootExit]
1383

    
1384
-- * VTypes
1385

    
1386
vtypeBool :: VType
1387
vtypeBool = VTypeBool
1388

    
1389
vtypeInt :: VType
1390
vtypeInt = VTypeInt
1391

    
1392
vtypeMaybeString :: VType
1393
vtypeMaybeString = VTypeMaybeString
1394

    
1395
-- | Size in MiBs
1396
vtypeSize :: VType
1397
vtypeSize = VTypeSize
1398

    
1399
vtypeString :: VType
1400
vtypeString = VTypeString
1401

    
1402
enforceableTypes :: FrozenSet VType
1403
enforceableTypes = ConstantUtils.mkSet [minBound..]
1404

    
1405
-- | Constant representing that the user does not specify any IP version
1406
ifaceNoIpVersionSpecified :: Int
1407
ifaceNoIpVersionSpecified = 0
1408

    
1409
validSerialSpeeds :: [Int]
1410
validSerialSpeeds =
1411
  [75,
1412
   110,
1413
   300,
1414
   600,
1415
   1200,
1416
   1800,
1417
   2400,
1418
   4800,
1419
   9600,
1420
   14400,
1421
   19200,
1422
   28800,
1423
   38400,
1424
   57600,
1425
   115200,
1426
   230400,
1427
   345600,
1428
   460800]
1429

    
1430
-- * HV parameter names (global namespace)
1431

    
1432
hvAcpi :: String
1433
hvAcpi = "acpi"
1434

    
1435
hvBlockdevPrefix :: String
1436
hvBlockdevPrefix = "blockdev_prefix"
1437

    
1438
hvBootloaderArgs :: String
1439
hvBootloaderArgs = "bootloader_args"
1440

    
1441
hvBootloaderPath :: String
1442
hvBootloaderPath = "bootloader_path"
1443

    
1444
hvBootOrder :: String
1445
hvBootOrder = "boot_order"
1446

    
1447
hvCdromImagePath :: String
1448
hvCdromImagePath = "cdrom_image_path"
1449

    
1450
hvCpuCap :: String
1451
hvCpuCap = "cpu_cap"
1452

    
1453
hvCpuCores :: String
1454
hvCpuCores = "cpu_cores"
1455

    
1456
hvCpuMask :: String
1457
hvCpuMask = "cpu_mask"
1458

    
1459
hvCpuSockets :: String
1460
hvCpuSockets = "cpu_sockets"
1461

    
1462
hvCpuThreads :: String
1463
hvCpuThreads = "cpu_threads"
1464

    
1465
hvCpuType :: String
1466
hvCpuType = "cpu_type"
1467

    
1468
hvCpuWeight :: String
1469
hvCpuWeight = "cpu_weight"
1470

    
1471
hvDeviceModel :: String
1472
hvDeviceModel = "device_model"
1473

    
1474
hvDiskCache :: String
1475
hvDiskCache = "disk_cache"
1476

    
1477
hvDiskType :: String
1478
hvDiskType = "disk_type"
1479

    
1480
hvInitrdPath :: String
1481
hvInitrdPath = "initrd_path"
1482

    
1483
hvInitScript :: String
1484
hvInitScript = "init_script"
1485

    
1486
hvKernelArgs :: String
1487
hvKernelArgs = "kernel_args"
1488

    
1489
hvKernelPath :: String
1490
hvKernelPath = "kernel_path"
1491

    
1492
hvKeymap :: String
1493
hvKeymap = "keymap"
1494

    
1495
hvKvmCdrom2ImagePath :: String
1496
hvKvmCdrom2ImagePath = "cdrom2_image_path"
1497

    
1498
hvKvmCdromDiskType :: String
1499
hvKvmCdromDiskType = "cdrom_disk_type"
1500

    
1501
hvKvmExtra :: String
1502
hvKvmExtra = "kvm_extra"
1503

    
1504
hvKvmFlag :: String
1505
hvKvmFlag = "kvm_flag"
1506

    
1507
hvKvmFloppyImagePath :: String
1508
hvKvmFloppyImagePath = "floppy_image_path"
1509

    
1510
hvKvmMachineVersion :: String
1511
hvKvmMachineVersion = "machine_version"
1512

    
1513
hvKvmMigrationCaps :: String
1514
hvKvmMigrationCaps = "migration_caps"
1515

    
1516
hvKvmPath :: String
1517
hvKvmPath = "kvm_path"
1518

    
1519
hvKvmSpiceAudioCompr :: String
1520
hvKvmSpiceAudioCompr = "spice_playback_compression"
1521

    
1522
hvKvmSpiceBind :: String
1523
hvKvmSpiceBind = "spice_bind"
1524

    
1525
hvKvmSpiceIpVersion :: String
1526
hvKvmSpiceIpVersion = "spice_ip_version"
1527

    
1528
hvKvmSpiceJpegImgCompr :: String
1529
hvKvmSpiceJpegImgCompr = "spice_jpeg_wan_compression"
1530

    
1531
hvKvmSpiceLosslessImgCompr :: String
1532
hvKvmSpiceLosslessImgCompr = "spice_image_compression"
1533

    
1534
hvKvmSpicePasswordFile :: String
1535
hvKvmSpicePasswordFile = "spice_password_file"
1536

    
1537
hvKvmSpiceStreamingVideoDetection :: String
1538
hvKvmSpiceStreamingVideoDetection = "spice_streaming_video"
1539

    
1540
hvKvmSpiceTlsCiphers :: String
1541
hvKvmSpiceTlsCiphers = "spice_tls_ciphers"
1542

    
1543
hvKvmSpiceUseTls :: String
1544
hvKvmSpiceUseTls = "spice_use_tls"
1545

    
1546
hvKvmSpiceUseVdagent :: String
1547
hvKvmSpiceUseVdagent = "spice_use_vdagent"
1548

    
1549
hvKvmSpiceZlibGlzImgCompr :: String
1550
hvKvmSpiceZlibGlzImgCompr = "spice_zlib_glz_wan_compression"
1551

    
1552
hvKvmUseChroot :: String
1553
hvKvmUseChroot = "use_chroot"
1554

    
1555
hvMemPath :: String
1556
hvMemPath = "mem_path"
1557

    
1558
hvMigrationBandwidth :: String
1559
hvMigrationBandwidth = "migration_bandwidth"
1560

    
1561
hvMigrationDowntime :: String
1562
hvMigrationDowntime = "migration_downtime"
1563

    
1564
hvMigrationMode :: String
1565
hvMigrationMode = "migration_mode"
1566

    
1567
hvMigrationPort :: String
1568
hvMigrationPort = "migration_port"
1569

    
1570
hvNicType :: String
1571
hvNicType = "nic_type"
1572

    
1573
hvPae :: String
1574
hvPae = "pae"
1575

    
1576
hvPassthrough :: String
1577
hvPassthrough = "pci_pass"
1578

    
1579
hvRebootBehavior :: String
1580
hvRebootBehavior = "reboot_behavior"
1581

    
1582
hvRootPath :: String
1583
hvRootPath = "root_path"
1584

    
1585
hvSecurityDomain :: String
1586
hvSecurityDomain = "security_domain"
1587

    
1588
hvSecurityModel :: String
1589
hvSecurityModel = "security_model"
1590

    
1591
hvSerialConsole :: String
1592
hvSerialConsole = "serial_console"
1593

    
1594
hvSerialSpeed :: String
1595
hvSerialSpeed = "serial_speed"
1596

    
1597
hvSoundhw :: String
1598
hvSoundhw = "soundhw"
1599

    
1600
hvUsbDevices :: String
1601
hvUsbDevices = "usb_devices"
1602

    
1603
hvUsbMouse :: String
1604
hvUsbMouse = "usb_mouse"
1605

    
1606
hvUseBootloader :: String
1607
hvUseBootloader = "use_bootloader"
1608

    
1609
hvUseLocaltime :: String
1610
hvUseLocaltime = "use_localtime"
1611

    
1612
hvVga :: String
1613
hvVga = "vga"
1614

    
1615
hvVhostNet :: String
1616
hvVhostNet = "vhost_net"
1617

    
1618
hvVifScript :: String
1619
hvVifScript = "vif_script"
1620

    
1621
hvVifType :: String
1622
hvVifType = "vif_type"
1623

    
1624
hvViridian :: String
1625
hvViridian = "viridian"
1626

    
1627
hvVncBindAddress :: String
1628
hvVncBindAddress = "vnc_bind_address"
1629

    
1630
hvVncPasswordFile :: String
1631
hvVncPasswordFile = "vnc_password_file"
1632

    
1633
hvVncTls :: String
1634
hvVncTls = "vnc_tls"
1635

    
1636
hvVncX509 :: String
1637
hvVncX509 = "vnc_x509_path"
1638

    
1639
hvVncX509Verify :: String
1640
hvVncX509Verify = "vnc_x509_verify"
1641

    
1642
hvVnetHdr :: String
1643
hvVnetHdr = "vnet_hdr"
1644

    
1645
hvXenCmd :: String
1646
hvXenCmd = "xen_cmd"
1647

    
1648
hvXenCpuid :: String
1649
hvXenCpuid = "cpuid"
1650

    
1651
hvsParameterTitles :: Map String String
1652
hvsParameterTitles =
1653
  Map.fromList
1654
  [(hvAcpi, "ACPI"),
1655
   (hvBootOrder, "Boot_order"),
1656
   (hvCdromImagePath, "CDROM_image_path"),
1657
   (hvCpuType, "cpu_type"),
1658
   (hvDiskType, "Disk_type"),
1659
   (hvInitrdPath, "Initrd_path"),
1660
   (hvKernelPath, "Kernel_path"),
1661
   (hvNicType, "NIC_type"),
1662
   (hvPae, "PAE"),
1663
   (hvPassthrough, "pci_pass"),
1664
   (hvVncBindAddress, "VNC_bind_address")]
1665

    
1666
hvsParameters :: FrozenSet String
1667
hvsParameters = ConstantUtils.mkSet $ Map.keys hvsParameterTypes
1668

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

    
1746
-- * Migration statuses
1747

    
1748
hvMigrationActive :: String
1749
hvMigrationActive = "active"
1750

    
1751
hvMigrationCancelled :: String
1752
hvMigrationCancelled = "cancelled"
1753

    
1754
hvMigrationCompleted :: String
1755
hvMigrationCompleted = "completed"
1756

    
1757
hvMigrationFailed :: String
1758
hvMigrationFailed = "failed"
1759

    
1760
hvMigrationValidStatuses :: FrozenSet String
1761
hvMigrationValidStatuses =
1762
  ConstantUtils.mkSet [hvMigrationActive,
1763
                       hvMigrationCancelled,
1764
                       hvMigrationCompleted,
1765
                       hvMigrationFailed]
1766

    
1767
hvMigrationFailedStatuses :: FrozenSet String
1768
hvMigrationFailedStatuses =
1769
  ConstantUtils.mkSet [hvMigrationFailed, hvMigrationCancelled]
1770

    
1771
-- | KVM-specific statuses
1772
--
1773
-- FIXME: this constant seems unnecessary
1774
hvKvmMigrationValidStatuses :: FrozenSet String
1775
hvKvmMigrationValidStatuses = hvMigrationValidStatuses
1776

    
1777
-- | Node info keys
1778
hvNodeinfoKeyVersion :: String
1779
hvNodeinfoKeyVersion = "hv_version"
1780

    
1781
-- * Hypervisor state
1782

    
1783
hvstCpuNode :: String
1784
hvstCpuNode = "cpu_node"
1785

    
1786
hvstCpuTotal :: String
1787
hvstCpuTotal = "cpu_total"
1788

    
1789
hvstMemoryHv :: String
1790
hvstMemoryHv = "mem_hv"
1791

    
1792
hvstMemoryNode :: String
1793
hvstMemoryNode = "mem_node"
1794

    
1795
hvstMemoryTotal :: String
1796
hvstMemoryTotal = "mem_total"
1797

    
1798
hvstsParameters :: FrozenSet String
1799
hvstsParameters =
1800
  ConstantUtils.mkSet [hvstCpuNode,
1801
                       hvstCpuTotal,
1802
                       hvstMemoryHv,
1803
                       hvstMemoryNode,
1804
                       hvstMemoryTotal]
1805

    
1806
hvstDefaults :: Map String Int
1807
hvstDefaults =
1808
  Map.fromList
1809
  [(hvstCpuNode, 1),
1810
   (hvstCpuTotal, 1),
1811
   (hvstMemoryHv, 0),
1812
   (hvstMemoryTotal, 0),
1813
   (hvstMemoryNode, 0)]
1814

    
1815
hvstsParameterTypes :: Map String VType
1816
hvstsParameterTypes =
1817
  Map.fromList [(hvstMemoryTotal, VTypeInt),
1818
                (hvstMemoryNode, VTypeInt),
1819
                (hvstMemoryHv, VTypeInt),
1820
                (hvstCpuTotal, VTypeInt),
1821
                (hvstCpuNode, VTypeInt)]
1822

    
1823
-- * Disk state
1824

    
1825
dsDiskOverhead :: String
1826
dsDiskOverhead = "disk_overhead"
1827

    
1828
dsDiskReserved :: String
1829
dsDiskReserved = "disk_reserved"
1830

    
1831
dsDiskTotal :: String
1832
dsDiskTotal = "disk_total"
1833

    
1834
dsDefaults :: Map String Int
1835
dsDefaults =
1836
  Map.fromList
1837
  [(dsDiskTotal, 0),
1838
   (dsDiskReserved, 0),
1839
   (dsDiskOverhead, 0)]
1840

    
1841
dssParameterTypes :: Map String VType
1842
dssParameterTypes =
1843
  Map.fromList [(dsDiskTotal, VTypeInt),
1844
                (dsDiskReserved, VTypeInt),
1845
                (dsDiskOverhead, VTypeInt)]
1846

    
1847
dssParameters :: FrozenSet String
1848
dssParameters =
1849
  ConstantUtils.mkSet [dsDiskTotal, dsDiskReserved, dsDiskOverhead]
1850

    
1851
dsValidTypes :: FrozenSet String
1852
dsValidTypes = ConstantUtils.mkSet [Types.diskTemplateToRaw DTPlain]
1853

    
1854
-- Backend parameter names
1855

    
1856
beAlwaysFailover :: String
1857
beAlwaysFailover = "always_failover"
1858

    
1859
beAutoBalance :: String
1860
beAutoBalance = "auto_balance"
1861

    
1862
beMaxmem :: String
1863
beMaxmem = "maxmem"
1864

    
1865
-- | Deprecated and replaced by max and min mem
1866
beMemory :: String
1867
beMemory = "memory"
1868

    
1869
beMinmem :: String
1870
beMinmem = "minmem"
1871

    
1872
beSpindleUse :: String
1873
beSpindleUse = "spindle_use"
1874

    
1875
beVcpus :: String
1876
beVcpus = "vcpus"
1877

    
1878
besParameterTypes :: Map String VType
1879
besParameterTypes =
1880
  Map.fromList [(beAlwaysFailover, VTypeBool),
1881
                (beAutoBalance, VTypeBool),
1882
                (beMaxmem, VTypeSize),
1883
                (beMinmem, VTypeSize),
1884
                (beSpindleUse, VTypeInt),
1885
                (beVcpus, VTypeInt)]
1886

    
1887
besParameterTitles :: Map String String
1888
besParameterTitles =
1889
  Map.fromList [(beAutoBalance, "Auto_balance"),
1890
                (beMinmem, "ConfigMinMem"),
1891
                (beVcpus, "ConfigVCPUs"),
1892
                (beMaxmem, "ConfigMaxMem")]
1893

    
1894
besParameterCompat :: Map String VType
1895
besParameterCompat = Map.insert beMemory VTypeSize besParameterTypes
1896

    
1897
besParameters :: FrozenSet String
1898
besParameters =
1899
  ConstantUtils.mkSet [beAlwaysFailover,
1900
                       beAutoBalance,
1901
                       beMaxmem,
1902
                       beMinmem,
1903
                       beSpindleUse,
1904
                       beVcpus]
1905

    
1906
-- | Instance specs
1907
--
1908
-- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
1909

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

    
1913
ispecCpuCount :: String
1914
ispecCpuCount = ConstantUtils.ispecCpuCount
1915

    
1916
ispecDiskCount :: String
1917
ispecDiskCount = ConstantUtils.ispecDiskCount
1918

    
1919
ispecDiskSize :: String
1920
ispecDiskSize = ConstantUtils.ispecDiskSize
1921

    
1922
ispecNicCount :: String
1923
ispecNicCount = ConstantUtils.ispecNicCount
1924

    
1925
ispecSpindleUse :: String
1926
ispecSpindleUse = ConstantUtils.ispecSpindleUse
1927

    
1928
ispecsParameterTypes :: Map String VType
1929
ispecsParameterTypes =
1930
  Map.fromList
1931
  [(ConstantUtils.ispecDiskSize, VTypeInt),
1932
   (ConstantUtils.ispecCpuCount, VTypeInt),
1933
   (ConstantUtils.ispecSpindleUse, VTypeInt),
1934
   (ConstantUtils.ispecMemSize, VTypeInt),
1935
   (ConstantUtils.ispecNicCount, VTypeInt),
1936
   (ConstantUtils.ispecDiskCount, VTypeInt)]
1937

    
1938
ispecsParameters :: FrozenSet String
1939
ispecsParameters =
1940
  ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
1941
                       ConstantUtils.ispecDiskCount,
1942
                       ConstantUtils.ispecDiskSize,
1943
                       ConstantUtils.ispecMemSize,
1944
                       ConstantUtils.ispecNicCount,
1945
                       ConstantUtils.ispecSpindleUse]
1946

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

    
1950
ispecsMax :: String
1951
ispecsMax = "max"
1952

    
1953
ispecsMin :: String
1954
ispecsMin = "min"
1955

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

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

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

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

    
1968
ispecsMinmaxKeys :: FrozenSet String
1969
ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
1970

    
1971
ipolicyParameters :: FrozenSet String
1972
ipolicyParameters =
1973
  ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
1974
                       ConstantUtils.ipolicySpindleRatio]
1975

    
1976
ipolicyAllKeys :: FrozenSet String
1977
ipolicyAllKeys =
1978
  ConstantUtils.union ipolicyParameters $
1979
  ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
1980
                       ConstantUtils.ispecsMinmax,
1981
                       ispecsStd]
1982

    
1983
-- | Node parameter names
1984

    
1985
ndExclusiveStorage :: String
1986
ndExclusiveStorage = "exclusive_storage"
1987

    
1988
ndOobProgram :: String
1989
ndOobProgram = "oob_program"
1990

    
1991
ndSpindleCount :: String
1992
ndSpindleCount = "spindle_count"
1993

    
1994
ndOvs :: String
1995
ndOvs = "ovs"
1996

    
1997
ndOvsLink :: String
1998
ndOvsLink = "ovs_link"
1999

    
2000
ndOvsName :: String
2001
ndOvsName = "ovs_name"
2002

    
2003
ndsParameterTypes :: Map String VType
2004
ndsParameterTypes =
2005
  Map.fromList
2006
  [(ndExclusiveStorage, VTypeBool),
2007
   (ndOobProgram, VTypeString),
2008
   (ndOvs, VTypeBool),
2009
   (ndOvsLink, VTypeMaybeString),
2010
   (ndOvsName, VTypeMaybeString),
2011
   (ndSpindleCount, VTypeInt)]
2012

    
2013
ndsParameters :: FrozenSet String
2014
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
2015

    
2016
ndsParameterTitles :: Map String String
2017
ndsParameterTitles =
2018
  Map.fromList
2019
  [(ndExclusiveStorage, "ExclusiveStorage"),
2020
   (ndOobProgram, "OutOfBandProgram"),
2021
   (ndOvs, "OpenvSwitch"),
2022
   (ndOvsLink, "OpenvSwitchLink"),
2023
   (ndOvsName, "OpenvSwitchName"),
2024
   (ndSpindleCount, "SpindleCount")]
2025

    
2026
-- * Logical Disks parameters
2027

    
2028
ldpAccess :: String
2029
ldpAccess = "access"
2030

    
2031
ldpBarriers :: String
2032
ldpBarriers = "disabled-barriers"
2033

    
2034
ldpDefaultMetavg :: String
2035
ldpDefaultMetavg = "default-metavg"
2036

    
2037
ldpDelayTarget :: String
2038
ldpDelayTarget = "c-delay-target"
2039

    
2040
ldpDiskCustom :: String
2041
ldpDiskCustom = "disk-custom"
2042

    
2043
ldpDynamicResync :: String
2044
ldpDynamicResync = "dynamic-resync"
2045

    
2046
ldpFillTarget :: String
2047
ldpFillTarget = "c-fill-target"
2048

    
2049
ldpMaxRate :: String
2050
ldpMaxRate = "c-max-rate"
2051

    
2052
ldpMinRate :: String
2053
ldpMinRate = "c-min-rate"
2054

    
2055
ldpNetCustom :: String
2056
ldpNetCustom = "net-custom"
2057

    
2058
ldpNoMetaFlush :: String
2059
ldpNoMetaFlush = "disable-meta-flush"
2060

    
2061
ldpPlanAhead :: String
2062
ldpPlanAhead = "c-plan-ahead"
2063

    
2064
ldpPool :: String
2065
ldpPool = "pool"
2066

    
2067
ldpProtocol :: String
2068
ldpProtocol = "protocol"
2069

    
2070
ldpResyncRate :: String
2071
ldpResyncRate = "resync-rate"
2072

    
2073
ldpStripes :: String
2074
ldpStripes = "stripes"
2075

    
2076
diskLdTypes :: Map String VType
2077
diskLdTypes =
2078
  Map.fromList
2079
  [(ldpAccess, VTypeString),
2080
   (ldpResyncRate, VTypeInt),
2081
   (ldpStripes, VTypeInt),
2082
   (ldpBarriers, VTypeString),
2083
   (ldpNoMetaFlush, VTypeBool),
2084
   (ldpDefaultMetavg, VTypeString),
2085
   (ldpDiskCustom, VTypeString),
2086
   (ldpNetCustom, VTypeString),
2087
   (ldpProtocol, VTypeString),
2088
   (ldpDynamicResync, VTypeBool),
2089
   (ldpPlanAhead, VTypeInt),
2090
   (ldpFillTarget, VTypeInt),
2091
   (ldpDelayTarget, VTypeInt),
2092
   (ldpMaxRate, VTypeInt),
2093
   (ldpMinRate, VTypeInt),
2094
   (ldpPool, VTypeString)]
2095

    
2096
diskLdParameters :: FrozenSet String
2097
diskLdParameters = ConstantUtils.mkSet (Map.keys diskLdTypes)
2098

    
2099
-- * Disk template parameters
2100
--
2101
-- Disk template parameters can be set/changed by the user via
2102
-- gnt-cluster and gnt-group)
2103

    
2104
drbdResyncRate :: String
2105
drbdResyncRate = "resync-rate"
2106

    
2107
drbdDataStripes :: String
2108
drbdDataStripes = "data-stripes"
2109

    
2110
drbdMetaStripes :: String
2111
drbdMetaStripes = "meta-stripes"
2112

    
2113
drbdDiskBarriers :: String
2114
drbdDiskBarriers = "disk-barriers"
2115

    
2116
drbdMetaBarriers :: String
2117
drbdMetaBarriers = "meta-barriers"
2118

    
2119
drbdDefaultMetavg :: String
2120
drbdDefaultMetavg = "metavg"
2121

    
2122
drbdDiskCustom :: String
2123
drbdDiskCustom = "disk-custom"
2124

    
2125
drbdNetCustom :: String
2126
drbdNetCustom = "net-custom"
2127

    
2128
drbdProtocol :: String
2129
drbdProtocol = "protocol"
2130

    
2131
drbdDynamicResync :: String
2132
drbdDynamicResync = "dynamic-resync"
2133

    
2134
drbdPlanAhead :: String
2135
drbdPlanAhead = "c-plan-ahead"
2136

    
2137
drbdFillTarget :: String
2138
drbdFillTarget = "c-fill-target"
2139

    
2140
drbdDelayTarget :: String
2141
drbdDelayTarget = "c-delay-target"
2142

    
2143
drbdMaxRate :: String
2144
drbdMaxRate = "c-max-rate"
2145

    
2146
drbdMinRate :: String
2147
drbdMinRate = "c-min-rate"
2148

    
2149
lvStripes :: String
2150
lvStripes = "stripes"
2151

    
2152
rbdAccess :: String
2153
rbdAccess = "access"
2154

    
2155
rbdPool :: String
2156
rbdPool = "pool"
2157

    
2158
diskDtTypes :: Map String VType
2159
diskDtTypes =
2160
  Map.fromList [(drbdResyncRate, VTypeInt),
2161
                (drbdDataStripes, VTypeInt),
2162
                (drbdMetaStripes, VTypeInt),
2163
                (drbdDiskBarriers, VTypeString),
2164
                (drbdMetaBarriers, VTypeBool),
2165
                (drbdDefaultMetavg, VTypeString),
2166
                (drbdDiskCustom, VTypeString),
2167
                (drbdNetCustom, VTypeString),
2168
                (drbdProtocol, VTypeString),
2169
                (drbdDynamicResync, VTypeBool),
2170
                (drbdPlanAhead, VTypeInt),
2171
                (drbdFillTarget, VTypeInt),
2172
                (drbdDelayTarget, VTypeInt),
2173
                (drbdMaxRate, VTypeInt),
2174
                (drbdMinRate, VTypeInt),
2175
                (lvStripes, VTypeInt),
2176
                (rbdAccess, VTypeString),
2177
                (rbdPool, VTypeString)]
2178

    
2179
diskDtParameters :: FrozenSet String
2180
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2181

    
2182
-- * Dynamic disk parameters
2183

    
2184
ddpLocalIp :: String
2185
ddpLocalIp = "local-ip"
2186

    
2187
ddpRemoteIp :: String
2188
ddpRemoteIp = "remote-ip"
2189

    
2190
ddpPort :: String
2191
ddpPort = "port"
2192

    
2193
ddpLocalMinor :: String
2194
ddpLocalMinor = "local-minor"
2195

    
2196
ddpRemoteMinor :: String
2197
ddpRemoteMinor = "remote-minor"
2198

    
2199
-- * OOB supported commands
2200

    
2201
oobPowerOn :: String
2202
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2203

    
2204
oobPowerOff :: String
2205
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2206

    
2207
oobPowerCycle :: String
2208
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2209

    
2210
oobPowerStatus :: String
2211
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2212

    
2213
oobHealth :: String
2214
oobHealth = Types.oobCommandToRaw OobHealth
2215

    
2216
oobCommands :: FrozenSet String
2217
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2218

    
2219
oobPowerStatusPowered :: String
2220
oobPowerStatusPowered = "powered"
2221

    
2222
-- | 60 seconds
2223
oobTimeout :: Int
2224
oobTimeout = 60
2225

    
2226
-- | 2 seconds
2227
oobPowerDelay :: Double
2228
oobPowerDelay = 2.0
2229

    
2230
oobStatusCritical :: String
2231
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2232

    
2233
oobStatusOk :: String
2234
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2235

    
2236
oobStatusUnknown :: String
2237
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2238

    
2239
oobStatusWarning :: String
2240
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2241

    
2242
oobStatuses :: FrozenSet String
2243
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2244

    
2245
-- | Instance Parameters Profile
2246
ppDefault :: String
2247
ppDefault = "default"
2248

    
2249
-- * nic* constants are used inside the ganeti config
2250

    
2251
nicLink :: String
2252
nicLink = "link"
2253

    
2254
nicMode :: String
2255
nicMode = "mode"
2256

    
2257
nicVlan :: String
2258
nicVlan = "vlan"
2259

    
2260
nicsParameterTypes :: Map String VType
2261
nicsParameterTypes =
2262
  Map.fromList [(nicMode, vtypeString),
2263
                (nicLink, vtypeString),
2264
                (nicVlan, vtypeString)]
2265

    
2266
nicsParameters :: FrozenSet String
2267
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2268

    
2269
nicModeBridged :: String
2270
nicModeBridged = Types.nICModeToRaw NMBridged
2271

    
2272
nicModeRouted :: String
2273
nicModeRouted = Types.nICModeToRaw NMRouted
2274

    
2275
nicModeOvs :: String
2276
nicModeOvs = Types.nICModeToRaw NMOvs
2277

    
2278
nicIpPool :: String
2279
nicIpPool = Types.nICModeToRaw NMPool
2280

    
2281
nicValidModes :: FrozenSet String
2282
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2283

    
2284
releaseAction :: String
2285
releaseAction = "release"
2286

    
2287
reserveAction :: String
2288
reserveAction = "reserve"
2289

    
2290
-- * idisk* constants are used in opcodes, to create/change disks
2291

    
2292
idiskAdopt :: String
2293
idiskAdopt = "adopt"
2294

    
2295
idiskMetavg :: String
2296
idiskMetavg = "metavg"
2297

    
2298
idiskMode :: String
2299
idiskMode = "mode"
2300

    
2301
idiskName :: String
2302
idiskName = "name"
2303

    
2304
idiskSize :: String
2305
idiskSize = "size"
2306

    
2307
idiskSpindles :: String
2308
idiskSpindles = "spindles"
2309

    
2310
idiskVg :: String
2311
idiskVg = "vg"
2312

    
2313
idiskProvider :: String
2314
idiskProvider = "provider"
2315

    
2316
idiskAccess :: String
2317
idiskAccess = "access"
2318

    
2319
idiskParamsTypes :: Map String VType
2320
idiskParamsTypes =
2321
  Map.fromList [(idiskSize, VTypeSize),
2322
                (idiskSpindles, VTypeInt),
2323
                (idiskMode, VTypeString),
2324
                (idiskAdopt, VTypeString),
2325
                (idiskVg, VTypeString),
2326
                (idiskMetavg, VTypeString),
2327
                (idiskProvider, VTypeString),
2328
                (idiskAccess, VTypeString),
2329
                (idiskName, VTypeMaybeString)]
2330

    
2331
idiskParams :: FrozenSet String
2332
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2333

    
2334
modifiableIdiskParamsTypes :: Map String VType
2335
modifiableIdiskParamsTypes =
2336
  Map.fromList [(idiskMode, VTypeString),
2337
                (idiskName, VTypeString)]
2338

    
2339
modifiableIdiskParams :: FrozenSet String
2340
modifiableIdiskParams =
2341
  ConstantUtils.mkSet (Map.keys modifiableIdiskParamsTypes)
2342

    
2343
-- * inic* constants are used in opcodes, to create/change nics
2344

    
2345
inicBridge :: String
2346
inicBridge = "bridge"
2347

    
2348
inicIp :: String
2349
inicIp = "ip"
2350

    
2351
inicLink :: String
2352
inicLink = "link"
2353

    
2354
inicMac :: String
2355
inicMac = "mac"
2356

    
2357
inicMode :: String
2358
inicMode = "mode"
2359

    
2360
inicName :: String
2361
inicName = "name"
2362

    
2363
inicNetwork :: String
2364
inicNetwork = "network"
2365

    
2366
inicVlan :: String
2367
inicVlan = "vlan"
2368

    
2369
inicParamsTypes :: Map String VType
2370
inicParamsTypes =
2371
  Map.fromList [(inicBridge, VTypeMaybeString),
2372
                (inicIp, VTypeMaybeString),
2373
                (inicLink, VTypeString),
2374
                (inicMac, VTypeString),
2375
                (inicMode, VTypeString),
2376
                (inicName, VTypeMaybeString),
2377
                (inicNetwork, VTypeMaybeString),
2378
                (inicVlan, VTypeMaybeString)]
2379

    
2380
inicParams :: FrozenSet String
2381
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2382

    
2383
-- * Hypervisor constants
2384

    
2385
htXenPvm :: String
2386
htXenPvm = Types.hypervisorToRaw XenPvm
2387

    
2388
htFake :: String
2389
htFake = Types.hypervisorToRaw Fake
2390

    
2391
htXenHvm :: String
2392
htXenHvm = Types.hypervisorToRaw XenHvm
2393

    
2394
htKvm :: String
2395
htKvm = Types.hypervisorToRaw Kvm
2396

    
2397
htChroot :: String
2398
htChroot = Types.hypervisorToRaw Chroot
2399

    
2400
htLxc :: String
2401
htLxc = Types.hypervisorToRaw Lxc
2402

    
2403
hyperTypes :: FrozenSet String
2404
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2405

    
2406
htsReqPort :: FrozenSet String
2407
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2408

    
2409
vncBasePort :: Int
2410
vncBasePort = 5900
2411

    
2412
vncDefaultBindAddress :: String
2413
vncDefaultBindAddress = ip4AddressAny
2414

    
2415
-- * NIC types
2416

    
2417
htNicE1000 :: String
2418
htNicE1000 = "e1000"
2419

    
2420
htNicI82551 :: String
2421
htNicI82551 = "i82551"
2422

    
2423
htNicI8259er :: String
2424
htNicI8259er = "i82559er"
2425

    
2426
htNicI85557b :: String
2427
htNicI85557b = "i82557b"
2428

    
2429
htNicNe2kIsa :: String
2430
htNicNe2kIsa = "ne2k_isa"
2431

    
2432
htNicNe2kPci :: String
2433
htNicNe2kPci = "ne2k_pci"
2434

    
2435
htNicParavirtual :: String
2436
htNicParavirtual = "paravirtual"
2437

    
2438
htNicPcnet :: String
2439
htNicPcnet = "pcnet"
2440

    
2441
htNicRtl8139 :: String
2442
htNicRtl8139 = "rtl8139"
2443

    
2444
htHvmValidNicTypes :: FrozenSet String
2445
htHvmValidNicTypes =
2446
  ConstantUtils.mkSet [htNicE1000,
2447
                       htNicNe2kIsa,
2448
                       htNicNe2kPci,
2449
                       htNicParavirtual,
2450
                       htNicRtl8139]
2451

    
2452
htKvmValidNicTypes :: FrozenSet String
2453
htKvmValidNicTypes =
2454
  ConstantUtils.mkSet [htNicE1000,
2455
                       htNicI82551,
2456
                       htNicI8259er,
2457
                       htNicI85557b,
2458
                       htNicNe2kIsa,
2459
                       htNicNe2kPci,
2460
                       htNicParavirtual,
2461
                       htNicPcnet,
2462
                       htNicRtl8139]
2463

    
2464
-- * Vif types
2465

    
2466
-- | Default vif type in xen-hvm
2467
htHvmVifIoemu :: String
2468
htHvmVifIoemu = "ioemu"
2469

    
2470
htHvmVifVif :: String
2471
htHvmVifVif = "vif"
2472

    
2473
htHvmValidVifTypes :: FrozenSet String
2474
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2475

    
2476
-- * Disk types
2477

    
2478
htDiskIde :: String
2479
htDiskIde = "ide"
2480

    
2481
htDiskIoemu :: String
2482
htDiskIoemu = "ioemu"
2483

    
2484
htDiskMtd :: String
2485
htDiskMtd = "mtd"
2486

    
2487
htDiskParavirtual :: String
2488
htDiskParavirtual = "paravirtual"
2489

    
2490
htDiskPflash :: String
2491
htDiskPflash = "pflash"
2492

    
2493
htDiskScsi :: String
2494
htDiskScsi = "scsi"
2495

    
2496
htDiskSd :: String
2497
htDiskSd = "sd"
2498

    
2499
htHvmValidDiskTypes :: FrozenSet String
2500
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2501

    
2502
htKvmValidDiskTypes :: FrozenSet String
2503
htKvmValidDiskTypes =
2504
  ConstantUtils.mkSet [htDiskIde,
2505
                       htDiskMtd,
2506
                       htDiskParavirtual,
2507
                       htDiskPflash,
2508
                       htDiskScsi,
2509
                       htDiskSd]
2510

    
2511
htCacheDefault :: String
2512
htCacheDefault = "default"
2513

    
2514
htCacheNone :: String
2515
htCacheNone = "none"
2516

    
2517
htCacheWback :: String
2518
htCacheWback = "writeback"
2519

    
2520
htCacheWthrough :: String
2521
htCacheWthrough = "writethrough"
2522

    
2523
htValidCacheTypes :: FrozenSet String
2524
htValidCacheTypes =
2525
  ConstantUtils.mkSet [htCacheDefault,
2526
                       htCacheNone,
2527
                       htCacheWback,
2528
                       htCacheWthrough]
2529

    
2530
-- * Mouse types
2531

    
2532
htMouseMouse :: String
2533
htMouseMouse = "mouse"
2534

    
2535
htMouseTablet :: String
2536
htMouseTablet = "tablet"
2537

    
2538
htKvmValidMouseTypes :: FrozenSet String
2539
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2540

    
2541
-- * Boot order
2542

    
2543
htBoCdrom :: String
2544
htBoCdrom = "cdrom"
2545

    
2546
htBoDisk :: String
2547
htBoDisk = "disk"
2548

    
2549
htBoFloppy :: String
2550
htBoFloppy = "floppy"
2551

    
2552
htBoNetwork :: String
2553
htBoNetwork = "network"
2554

    
2555
htKvmValidBoTypes :: FrozenSet String
2556
htKvmValidBoTypes =
2557
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2558

    
2559
-- * SPICE lossless image compression options
2560

    
2561
htKvmSpiceLosslessImgComprAutoGlz :: String
2562
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2563

    
2564
htKvmSpiceLosslessImgComprAutoLz :: String
2565
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2566

    
2567
htKvmSpiceLosslessImgComprGlz :: String
2568
htKvmSpiceLosslessImgComprGlz = "glz"
2569

    
2570
htKvmSpiceLosslessImgComprLz :: String
2571
htKvmSpiceLosslessImgComprLz = "lz"
2572

    
2573
htKvmSpiceLosslessImgComprOff :: String
2574
htKvmSpiceLosslessImgComprOff = "off"
2575

    
2576
htKvmSpiceLosslessImgComprQuic :: String
2577
htKvmSpiceLosslessImgComprQuic = "quic"
2578

    
2579
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2580
htKvmSpiceValidLosslessImgComprOptions =
2581
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2582
                       htKvmSpiceLosslessImgComprAutoLz,
2583
                       htKvmSpiceLosslessImgComprGlz,
2584
                       htKvmSpiceLosslessImgComprLz,
2585
                       htKvmSpiceLosslessImgComprOff,
2586
                       htKvmSpiceLosslessImgComprQuic]
2587

    
2588
htKvmSpiceLossyImgComprAlways :: String
2589
htKvmSpiceLossyImgComprAlways = "always"
2590

    
2591
htKvmSpiceLossyImgComprAuto :: String
2592
htKvmSpiceLossyImgComprAuto = "auto"
2593

    
2594
htKvmSpiceLossyImgComprNever :: String
2595
htKvmSpiceLossyImgComprNever = "never"
2596

    
2597
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2598
htKvmSpiceValidLossyImgComprOptions =
2599
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2600
                       htKvmSpiceLossyImgComprAuto,
2601
                       htKvmSpiceLossyImgComprNever]
2602

    
2603
-- * SPICE video stream detection
2604

    
2605
htKvmSpiceVideoStreamDetectionAll :: String
2606
htKvmSpiceVideoStreamDetectionAll = "all"
2607

    
2608
htKvmSpiceVideoStreamDetectionFilter :: String
2609
htKvmSpiceVideoStreamDetectionFilter = "filter"
2610

    
2611
htKvmSpiceVideoStreamDetectionOff :: String
2612
htKvmSpiceVideoStreamDetectionOff = "off"
2613

    
2614
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2615
htKvmSpiceValidVideoStreamDetectionOptions =
2616
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2617
                       htKvmSpiceVideoStreamDetectionFilter,
2618
                       htKvmSpiceVideoStreamDetectionOff]
2619

    
2620
-- * Security models
2621

    
2622
htSmNone :: String
2623
htSmNone = "none"
2624

    
2625
htSmPool :: String
2626
htSmPool = "pool"
2627

    
2628
htSmUser :: String
2629
htSmUser = "user"
2630

    
2631
htKvmValidSmTypes :: FrozenSet String
2632
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2633

    
2634
-- * Kvm flag values
2635

    
2636
htKvmDisabled :: String
2637
htKvmDisabled = "disabled"
2638

    
2639
htKvmEnabled :: String
2640
htKvmEnabled = "enabled"
2641

    
2642
htKvmFlagValues :: FrozenSet String
2643
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2644

    
2645
-- * Migration type
2646

    
2647
htMigrationLive :: String
2648
htMigrationLive = Types.migrationModeToRaw MigrationLive
2649

    
2650
htMigrationNonlive :: String
2651
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2652

    
2653
htMigrationModes :: FrozenSet String
2654
htMigrationModes =
2655
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2656

    
2657
-- * Cluster verify steps
2658

    
2659
verifyNplusoneMem :: String
2660
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2661

    
2662
verifyOptionalChecks :: FrozenSet String
2663
verifyOptionalChecks =
2664
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2665

    
2666
-- * Cluster Verify error classes
2667

    
2668
cvTcluster :: String
2669
cvTcluster = "cluster"
2670

    
2671
cvTgroup :: String
2672
cvTgroup = "group"
2673

    
2674
cvTnode :: String
2675
cvTnode = "node"
2676

    
2677
cvTinstance :: String
2678
cvTinstance = "instance"
2679

    
2680
-- * Cluster Verify error codes and documentation
2681

    
2682
cvEclustercert :: (String, String, String)
2683
cvEclustercert =
2684
  ("cluster",
2685
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2686
   "Cluster certificate files verification failure")
2687

    
2688
cvEclustercfg :: (String, String, String)
2689
cvEclustercfg =
2690
  ("cluster",
2691
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2692
   "Cluster configuration verification failure")
2693

    
2694
cvEclusterdanglinginst :: (String, String, String)
2695
cvEclusterdanglinginst =
2696
  ("node",
2697
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2698
   "Some instances have a non-existing primary node")
2699

    
2700
cvEclusterdanglingnodes :: (String, String, String)
2701
cvEclusterdanglingnodes =
2702
  ("node",
2703
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2704
   "Some nodes belong to non-existing groups")
2705

    
2706
cvEclusterfilecheck :: (String, String, String)
2707
cvEclusterfilecheck =
2708
  ("cluster",
2709
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2710
   "Cluster configuration verification failure")
2711

    
2712
cvEgroupdifferentpvsize :: (String, String, String)
2713
cvEgroupdifferentpvsize =
2714
  ("group",
2715
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2716
   "PVs in the group have different sizes")
2717

    
2718
cvEinstancebadnode :: (String, String, String)
2719
cvEinstancebadnode =
2720
  ("instance",
2721
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2722
   "Instance marked as running lives on an offline node")
2723

    
2724
cvEinstancedown :: (String, String, String)
2725
cvEinstancedown =
2726
  ("instance",
2727
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2728
   "Instance not running on its primary node")
2729

    
2730
cvEinstancefaultydisk :: (String, String, String)
2731
cvEinstancefaultydisk =
2732
  ("instance",
2733
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2734
   "Impossible to retrieve status for a disk")
2735

    
2736
cvEinstancelayout :: (String, String, String)
2737
cvEinstancelayout =
2738
  ("instance",
2739
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2740
   "Instance has multiple secondary nodes")
2741

    
2742
cvEinstancemissingcfgparameter :: (String, String, String)
2743
cvEinstancemissingcfgparameter =
2744
  ("instance",
2745
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2746
   "A configuration parameter for an instance is missing")
2747

    
2748
cvEinstancemissingdisk :: (String, String, String)
2749
cvEinstancemissingdisk =
2750
  ("instance",
2751
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2752
   "Missing volume on an instance")
2753

    
2754
cvEinstancepolicy :: (String, String, String)
2755
cvEinstancepolicy =
2756
  ("instance",
2757
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2758
   "Instance does not meet policy")
2759

    
2760
cvEinstancesplitgroups :: (String, String, String)
2761
cvEinstancesplitgroups =
2762
  ("instance",
2763
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2764
   "Instance with primary and secondary nodes in different groups")
2765

    
2766
cvEinstanceunsuitablenode :: (String, String, String)
2767
cvEinstanceunsuitablenode =
2768
  ("instance",
2769
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2770
   "Instance running on nodes that are not suitable for it")
2771

    
2772
cvEinstancewrongnode :: (String, String, String)
2773
cvEinstancewrongnode =
2774
  ("instance",
2775
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2776
   "Instance running on the wrong node")
2777

    
2778
cvEnodedrbd :: (String, String, String)
2779
cvEnodedrbd =
2780
  ("node",
2781
   Types.cVErrorCodeToRaw CvENODEDRBD,
2782
   "Error parsing the DRBD status file")
2783

    
2784
cvEnodedrbdhelper :: (String, String, String)
2785
cvEnodedrbdhelper =
2786
  ("node",
2787
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2788
   "Error caused by the DRBD helper")
2789

    
2790
cvEnodedrbdversion :: (String, String, String)
2791
cvEnodedrbdversion =
2792
  ("node",
2793
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2794
   "DRBD version mismatch within a node group")
2795

    
2796
cvEnodefilecheck :: (String, String, String)
2797
cvEnodefilecheck =
2798
  ("node",
2799
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2800
   "Error retrieving the checksum of the node files")
2801

    
2802
cvEnodefilestoragepaths :: (String, String, String)
2803
cvEnodefilestoragepaths =
2804
  ("node",
2805
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2806
   "Detected bad file storage paths")
2807

    
2808
cvEnodefilestoragepathunusable :: (String, String, String)
2809
cvEnodefilestoragepathunusable =
2810
  ("node",
2811
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2812
   "File storage path unusable")
2813

    
2814
cvEnodehooks :: (String, String, String)
2815
cvEnodehooks =
2816
  ("node",
2817
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2818
   "Communication failure in hooks execution")
2819

    
2820
cvEnodehv :: (String, String, String)
2821
cvEnodehv =
2822
  ("node",
2823
   Types.cVErrorCodeToRaw CvENODEHV,
2824
   "Hypervisor parameters verification failure")
2825

    
2826
cvEnodelvm :: (String, String, String)
2827
cvEnodelvm =
2828
  ("node",
2829
   Types.cVErrorCodeToRaw CvENODELVM,
2830
   "LVM-related node error")
2831

    
2832
cvEnoden1 :: (String, String, String)
2833
cvEnoden1 =
2834
  ("node",
2835
   Types.cVErrorCodeToRaw CvENODEN1,
2836
   "Not enough memory to accommodate instance failovers")
2837

    
2838
cvEnodenet :: (String, String, String)
2839
cvEnodenet =
2840
  ("node",
2841
   Types.cVErrorCodeToRaw CvENODENET,
2842
   "Network-related node error")
2843

    
2844
cvEnodeoobpath :: (String, String, String)
2845
cvEnodeoobpath =
2846
  ("node",
2847
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2848
   "Invalid Out Of Band path")
2849

    
2850
cvEnodeorphaninstance :: (String, String, String)
2851
cvEnodeorphaninstance =
2852
  ("node",
2853
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2854
   "Unknown intance running on a node")
2855

    
2856
cvEnodeorphanlv :: (String, String, String)
2857
cvEnodeorphanlv =
2858
  ("node",
2859
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2860
   "Unknown LVM logical volume")
2861

    
2862
cvEnodeos :: (String, String, String)
2863
cvEnodeos =
2864
  ("node",
2865
   Types.cVErrorCodeToRaw CvENODEOS,
2866
   "OS-related node error")
2867

    
2868
cvEnoderpc :: (String, String, String)
2869
cvEnoderpc =
2870
  ("node",
2871
   Types.cVErrorCodeToRaw CvENODERPC,
2872
   "Error during connection to the primary node of an instance")
2873

    
2874
cvEnodesetup :: (String, String, String)
2875
cvEnodesetup =
2876
  ("node",
2877
   Types.cVErrorCodeToRaw CvENODESETUP,
2878
   "Node setup error")
2879

    
2880
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2881
cvEnodesharedfilestoragepathunusable =
2882
  ("node",
2883
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2884
   "Shared file storage path unusable")
2885

    
2886
cvEnodessh :: (String, String, String)
2887
cvEnodessh =
2888
  ("node",
2889
   Types.cVErrorCodeToRaw CvENODESSH,
2890
   "SSH-related node error")
2891

    
2892
cvEnodetime :: (String, String, String)
2893
cvEnodetime =
2894
  ("node",
2895
   Types.cVErrorCodeToRaw CvENODETIME,
2896
   "Node returned invalid time")
2897

    
2898
cvEnodeuserscripts :: (String, String, String)
2899
cvEnodeuserscripts =
2900
  ("node",
2901
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2902
   "User scripts not present or not executable")
2903

    
2904
cvEnodeversion :: (String, String, String)
2905
cvEnodeversion =
2906
  ("node",
2907
   Types.cVErrorCodeToRaw CvENODEVERSION,
2908
   "Protocol version mismatch or Ganeti version mismatch")
2909

    
2910
cvAllEcodes :: FrozenSet (String, String, String)
2911
cvAllEcodes =
2912
  ConstantUtils.mkSet
2913
  [cvEclustercert,
2914
   cvEclustercfg,
2915
   cvEclusterdanglinginst,
2916
   cvEclusterdanglingnodes,
2917
   cvEclusterfilecheck,
2918
   cvEgroupdifferentpvsize,
2919
   cvEinstancebadnode,
2920
   cvEinstancedown,
2921
   cvEinstancefaultydisk,
2922
   cvEinstancelayout,
2923
   cvEinstancemissingcfgparameter,
2924
   cvEinstancemissingdisk,
2925
   cvEinstancepolicy,
2926
   cvEinstancesplitgroups,
2927
   cvEinstanceunsuitablenode,
2928
   cvEinstancewrongnode,
2929
   cvEnodedrbd,
2930
   cvEnodedrbdhelper,
2931
   cvEnodedrbdversion,
2932
   cvEnodefilecheck,
2933
   cvEnodefilestoragepaths,
2934
   cvEnodefilestoragepathunusable,
2935
   cvEnodehooks,
2936
   cvEnodehv,
2937
   cvEnodelvm,
2938
   cvEnoden1,
2939
   cvEnodenet,
2940
   cvEnodeoobpath,
2941
   cvEnodeorphaninstance,
2942
   cvEnodeorphanlv,
2943
   cvEnodeos,
2944
   cvEnoderpc,
2945
   cvEnodesetup,
2946
   cvEnodesharedfilestoragepathunusable,
2947
   cvEnodessh,
2948
   cvEnodetime,
2949
   cvEnodeuserscripts,
2950
   cvEnodeversion]
2951

    
2952
cvAllEcodesStrings :: FrozenSet String
2953
cvAllEcodesStrings =
2954
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2955

    
2956
-- * Node verify constants
2957

    
2958
nvBridges :: String
2959
nvBridges = "bridges"
2960

    
2961
nvDrbdhelper :: String
2962
nvDrbdhelper = "drbd-helper"
2963

    
2964
nvDrbdversion :: String
2965
nvDrbdversion = "drbd-version"
2966

    
2967
nvDrbdlist :: String
2968
nvDrbdlist = "drbd-list"
2969

    
2970
nvExclusivepvs :: String
2971
nvExclusivepvs = "exclusive-pvs"
2972

    
2973
nvFilelist :: String
2974
nvFilelist = "filelist"
2975

    
2976
nvAcceptedStoragePaths :: String
2977
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2978

    
2979
nvFileStoragePath :: String
2980
nvFileStoragePath = "file-storage-path"
2981

    
2982
nvSharedFileStoragePath :: String
2983
nvSharedFileStoragePath = "shared-file-storage-path"
2984

    
2985
nvHvinfo :: String
2986
nvHvinfo = "hvinfo"
2987

    
2988
nvHvparams :: String
2989
nvHvparams = "hvparms"
2990

    
2991
nvHypervisor :: String
2992
nvHypervisor = "hypervisor"
2993

    
2994
nvInstancelist :: String
2995
nvInstancelist = "instancelist"
2996

    
2997
nvLvlist :: String
2998
nvLvlist = "lvlist"
2999

    
3000
nvMasterip :: String
3001
nvMasterip = "master-ip"
3002

    
3003
nvNodelist :: String
3004
nvNodelist = "nodelist"
3005

    
3006
nvNodenettest :: String
3007
nvNodenettest = "node-net-test"
3008

    
3009
nvNodesetup :: String
3010
nvNodesetup = "nodesetup"
3011

    
3012
nvOobPaths :: String
3013
nvOobPaths = "oob-paths"
3014

    
3015
nvOslist :: String
3016
nvOslist = "oslist"
3017

    
3018
nvPvlist :: String
3019
nvPvlist = "pvlist"
3020

    
3021
nvTime :: String
3022
nvTime = "time"
3023

    
3024
nvUserscripts :: String
3025
nvUserscripts = "user-scripts"
3026

    
3027
nvVersion :: String
3028
nvVersion = "version"
3029

    
3030
nvVglist :: String
3031
nvVglist = "vglist"
3032

    
3033
nvVmnodes :: String
3034
nvVmnodes = "vmnodes"
3035

    
3036
-- * Instance status
3037

    
3038
inststAdmindown :: String
3039
inststAdmindown = Types.instanceStatusToRaw StatusDown
3040

    
3041
inststAdminoffline :: String
3042
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3043

    
3044
inststErrordown :: String
3045
inststErrordown = Types.instanceStatusToRaw ErrorDown
3046

    
3047
inststErrorup :: String
3048
inststErrorup = Types.instanceStatusToRaw ErrorUp
3049

    
3050
inststNodedown :: String
3051
inststNodedown = Types.instanceStatusToRaw NodeDown
3052

    
3053
inststNodeoffline :: String
3054
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3055

    
3056
inststRunning :: String
3057
inststRunning = Types.instanceStatusToRaw Running
3058

    
3059
inststWrongnode :: String
3060
inststWrongnode = Types.instanceStatusToRaw WrongNode
3061

    
3062
inststAll :: FrozenSet String
3063
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3064

    
3065
-- * Admin states
3066

    
3067
adminstDown :: String
3068
adminstDown = Types.adminStateToRaw AdminDown
3069

    
3070
adminstOffline :: String
3071
adminstOffline = Types.adminStateToRaw AdminOffline
3072

    
3073
adminstUp :: String
3074
adminstUp = Types.adminStateToRaw AdminUp
3075

    
3076
adminstAll :: FrozenSet String
3077
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3078

    
3079
-- * Node roles
3080

    
3081
nrDrained :: String
3082
nrDrained = Types.nodeRoleToRaw NRDrained
3083

    
3084
nrMaster :: String
3085
nrMaster = Types.nodeRoleToRaw NRMaster
3086

    
3087
nrMcandidate :: String
3088
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3089

    
3090
nrOffline :: String
3091
nrOffline = Types.nodeRoleToRaw NROffline
3092

    
3093
nrRegular :: String
3094
nrRegular = Types.nodeRoleToRaw NRRegular
3095

    
3096
nrAll :: FrozenSet String
3097
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3098

    
3099
-- * SSL certificate check constants (in days)
3100

    
3101
sslCertExpirationError :: Int
3102
sslCertExpirationError = 7
3103

    
3104
sslCertExpirationWarn :: Int
3105
sslCertExpirationWarn = 30
3106

    
3107
-- * Allocator framework constants
3108

    
3109
iallocatorVersion :: Int
3110
iallocatorVersion = 2
3111

    
3112
iallocatorDirIn :: String
3113
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3114

    
3115
iallocatorDirOut :: String
3116
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3117

    
3118
validIallocatorDirections :: FrozenSet String
3119
validIallocatorDirections =
3120
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3121

    
3122
iallocatorModeAlloc :: String
3123
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3124

    
3125
iallocatorModeChgGroup :: String
3126
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3127

    
3128
iallocatorModeMultiAlloc :: String
3129
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3130

    
3131
iallocatorModeNodeEvac :: String
3132
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3133

    
3134
iallocatorModeReloc :: String
3135
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3136

    
3137
validIallocatorModes :: FrozenSet String
3138
validIallocatorModes =
3139
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3140

    
3141
iallocatorSearchPath :: [String]
3142
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3143

    
3144
defaultIallocatorShortcut :: String
3145
defaultIallocatorShortcut = "."
3146

    
3147
-- * Node evacuation
3148

    
3149
nodeEvacPri :: String
3150
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3151

    
3152
nodeEvacSec :: String
3153
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3154

    
3155
nodeEvacAll :: String
3156
nodeEvacAll = Types.evacModeToRaw ChangeAll
3157

    
3158
nodeEvacModes :: FrozenSet String
3159
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3160

    
3161
-- * Job queue
3162

    
3163
jobQueueVersion :: Int
3164
jobQueueVersion = 1
3165

    
3166
jobQueueSizeHardLimit :: Int
3167
jobQueueSizeHardLimit = 5000
3168

    
3169
jobQueueFilesPerms :: Int
3170
jobQueueFilesPerms = 0o640
3171

    
3172
-- * Unchanged job return
3173

    
3174
jobNotchanged :: String
3175
jobNotchanged = "nochange"
3176

    
3177
-- * Job status
3178

    
3179
jobStatusQueued :: String
3180
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3181

    
3182
jobStatusWaiting :: String
3183
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3184

    
3185
jobStatusCanceling :: String
3186
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3187

    
3188
jobStatusRunning :: String
3189
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3190

    
3191
jobStatusCanceled :: String
3192
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3193

    
3194
jobStatusSuccess :: String
3195
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3196

    
3197
jobStatusError :: String
3198
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3199

    
3200
jobsPending :: FrozenSet String
3201
jobsPending =
3202
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3203

    
3204
jobsFinalized :: FrozenSet String
3205
jobsFinalized =
3206
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3207

    
3208
jobStatusAll :: FrozenSet String
3209
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3210

    
3211
-- * OpCode status
3212

    
3213
-- ** Not yet finalized opcodes
3214

    
3215
opStatusCanceling :: String
3216
opStatusCanceling = "canceling"
3217

    
3218
opStatusQueued :: String
3219
opStatusQueued = "queued"
3220

    
3221
opStatusRunning :: String
3222
opStatusRunning = "running"
3223

    
3224
opStatusWaiting :: String
3225
opStatusWaiting = "waiting"
3226

    
3227
-- ** Finalized opcodes
3228

    
3229
opStatusCanceled :: String
3230
opStatusCanceled = "canceled"
3231

    
3232
opStatusError :: String
3233
opStatusError = "error"
3234

    
3235
opStatusSuccess :: String
3236
opStatusSuccess = "success"
3237

    
3238
opsFinalized :: FrozenSet String
3239
opsFinalized =
3240
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3241

    
3242
-- * OpCode priority
3243

    
3244
opPrioLowest :: Int
3245
opPrioLowest = 19
3246

    
3247
opPrioHighest :: Int
3248
opPrioHighest = -20
3249

    
3250
opPrioLow :: Int
3251
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3252

    
3253
opPrioNormal :: Int
3254
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3255

    
3256
opPrioHigh :: Int
3257
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3258

    
3259
opPrioSubmitValid :: FrozenSet Int
3260
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3261

    
3262
opPrioDefault :: Int
3263
opPrioDefault = opPrioNormal
3264

    
3265
-- * Lock recalculate mode
3266

    
3267
locksAppend :: String
3268
locksAppend = "append"
3269

    
3270
locksReplace :: String
3271
locksReplace = "replace"
3272

    
3273
-- * Lock timeout
3274
--
3275
-- The lock timeout (sum) before we transition into blocking acquire
3276
-- (this can still be reset by priority change).  Computed as max time
3277
-- (10 hours) before we should actually go into blocking acquire,
3278
-- given that we start from the default priority level.
3279

    
3280
lockAttemptsMaxwait :: Double
3281
lockAttemptsMaxwait = 15.0
3282

    
3283
lockAttemptsMinwait :: Double
3284
lockAttemptsMinwait = 1.0
3285

    
3286
lockAttemptsTimeout :: Int
3287
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3288

    
3289
-- * Execution log types
3290

    
3291
elogMessage :: String
3292
elogMessage = Types.eLogTypeToRaw ELogMessage
3293

    
3294
elogRemoteImport :: String
3295
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3296

    
3297
elogJqueueTest :: String
3298
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3299

    
3300
-- * /etc/hosts modification
3301

    
3302
etcHostsAdd :: String
3303
etcHostsAdd = "add"
3304

    
3305
etcHostsRemove :: String
3306
etcHostsRemove = "remove"
3307

    
3308
-- * Job queue test
3309

    
3310
jqtMsgprefix :: String
3311
jqtMsgprefix = "TESTMSG="
3312

    
3313
jqtExec :: String
3314
jqtExec = "exec"
3315

    
3316
jqtExpandnames :: String
3317
jqtExpandnames = "expandnames"
3318

    
3319
jqtLogmsg :: String
3320
jqtLogmsg = "logmsg"
3321

    
3322
jqtStartmsg :: String
3323
jqtStartmsg = "startmsg"
3324

    
3325
jqtAll :: FrozenSet String
3326
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3327

    
3328
-- * Query resources
3329

    
3330
qrCluster :: String
3331
qrCluster = "cluster"
3332

    
3333
qrExport :: String
3334
qrExport = "export"
3335

    
3336
qrExtstorage :: String
3337
qrExtstorage = "extstorage"
3338

    
3339
qrGroup :: String
3340
qrGroup = "group"
3341

    
3342
qrInstance :: String
3343
qrInstance = "instance"
3344

    
3345
qrJob :: String
3346
qrJob = "job"
3347

    
3348
qrLock :: String
3349
qrLock = "lock"
3350

    
3351
qrNetwork :: String
3352
qrNetwork = "network"
3353

    
3354
qrNode :: String
3355
qrNode = "node"
3356

    
3357
qrOs :: String
3358
qrOs = "os"
3359

    
3360
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3361
qrViaOp :: FrozenSet String
3362
qrViaOp =
3363
  ConstantUtils.mkSet [qrCluster,
3364
                       qrInstance,
3365
                       qrNode,
3366
                       qrGroup,
3367
                       qrOs,
3368
                       qrExport,
3369
                       qrNetwork,
3370
                       qrExtstorage]
3371

    
3372
-- | List of resources which can be queried using Local UniX Interface
3373
qrViaLuxi :: FrozenSet String
3374
qrViaLuxi = ConstantUtils.mkSet [qrLock, qrJob]
3375

    
3376
-- | List of resources which can be queried using RAPI
3377
qrViaRapi :: FrozenSet String
3378
qrViaRapi = qrViaLuxi
3379

    
3380
-- * Query field types
3381

    
3382
qftBool :: String
3383
qftBool = "bool"
3384

    
3385
qftNumber :: String
3386
qftNumber = "number"
3387

    
3388
qftOther :: String
3389
qftOther = "other"
3390

    
3391
qftText :: String
3392
qftText = "text"
3393

    
3394
qftTimestamp :: String
3395
qftTimestamp = "timestamp"
3396

    
3397
qftUnit :: String
3398
qftUnit = "unit"
3399

    
3400
qftUnknown :: String
3401
qftUnknown = "unknown"
3402

    
3403
qftAll :: FrozenSet String
3404
qftAll =
3405
  ConstantUtils.mkSet [qftBool,
3406
                       qftNumber,
3407
                       qftOther,
3408
                       qftText,
3409
                       qftTimestamp,
3410
                       qftUnit,
3411
                       qftUnknown]
3412

    
3413
-- * Query result field status
3414
--
3415
-- Don't change or reuse values as they're used by clients.
3416
--
3417
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3418

    
3419
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3420
rsNodata :: Int
3421
rsNodata = 2
3422

    
3423
rsNormal :: Int
3424
rsNormal = 0
3425

    
3426
-- | Resource marked offline
3427
rsOffline :: Int
3428
rsOffline = 4
3429

    
3430
-- | Value unavailable/unsupported for item; if this field is
3431
-- supported but we cannot get the data for the moment, 'rsNodata' or
3432
-- 'rsOffline' should be used
3433
rsUnavail :: Int
3434
rsUnavail = 3
3435

    
3436
rsUnknown :: Int
3437
rsUnknown = 1
3438

    
3439
rsAll :: FrozenSet Int
3440
rsAll =
3441
  ConstantUtils.mkSet [rsNodata,
3442
                       rsNormal,
3443
                       rsOffline,
3444
                       rsUnavail,
3445
                       rsUnknown]
3446

    
3447
-- | Special field cases and their verbose/terse formatting
3448
rssDescription :: Map Int (String, String)
3449
rssDescription =
3450
  Map.fromList [(rsUnknown, ("(unknown)", "??")),
3451
                (rsNodata, ("(nodata)", "?")),
3452
                (rsOffline, ("(offline)", "*")),
3453
                (rsUnavail, ("(unavail)", "-"))]
3454

    
3455
-- * Max dynamic devices
3456

    
3457
maxDisks :: Int
3458
maxDisks = Types.maxDisks
3459

    
3460
maxNics :: Int
3461
maxNics = Types.maxNics
3462

    
3463
-- | SSCONF file prefix
3464
ssconfFileprefix :: String
3465
ssconfFileprefix = "ssconf_"
3466

    
3467
-- * SSCONF keys
3468

    
3469
ssClusterName :: String
3470
ssClusterName = "cluster_name"
3471

    
3472
ssClusterTags :: String
3473
ssClusterTags = "cluster_tags"
3474

    
3475
ssFileStorageDir :: String
3476
ssFileStorageDir = "file_storage_dir"
3477

    
3478
ssSharedFileStorageDir :: String
3479
ssSharedFileStorageDir = "shared_file_storage_dir"
3480

    
3481
ssMasterCandidates :: String
3482
ssMasterCandidates = "master_candidates"
3483

    
3484
ssMasterCandidatesIps :: String
3485
ssMasterCandidatesIps = "master_candidates_ips"
3486

    
3487
ssMasterIp :: String
3488
ssMasterIp = "master_ip"
3489

    
3490
ssMasterNetdev :: String
3491
ssMasterNetdev = "master_netdev"
3492

    
3493
ssMasterNetmask :: String
3494
ssMasterNetmask = "master_netmask"
3495

    
3496
ssMasterNode :: String
3497
ssMasterNode = "master_node"
3498

    
3499
ssNodeList :: String
3500
ssNodeList = "node_list"
3501

    
3502
ssNodePrimaryIps :: String
3503
ssNodePrimaryIps = "node_primary_ips"
3504

    
3505
ssNodeSecondaryIps :: String
3506
ssNodeSecondaryIps = "node_secondary_ips"
3507

    
3508
ssOfflineNodes :: String
3509
ssOfflineNodes = "offline_nodes"
3510

    
3511
ssOnlineNodes :: String
3512
ssOnlineNodes = "online_nodes"
3513

    
3514
ssPrimaryIpFamily :: String
3515
ssPrimaryIpFamily = "primary_ip_family"
3516

    
3517
ssInstanceList :: String
3518
ssInstanceList = "instance_list"
3519

    
3520
ssReleaseVersion :: String
3521
ssReleaseVersion = "release_version"
3522

    
3523
ssHypervisorList :: String
3524
ssHypervisorList = "hypervisor_list"
3525

    
3526
ssMaintainNodeHealth :: String
3527
ssMaintainNodeHealth = "maintain_node_health"
3528

    
3529
ssUidPool :: String
3530
ssUidPool = "uid_pool"
3531

    
3532
ssNodegroups :: String
3533
ssNodegroups = "nodegroups"
3534

    
3535
ssNetworks :: String
3536
ssNetworks = "networks"
3537

    
3538
-- | This is not a complete SSCONF key, but the prefix for the
3539
-- hypervisor keys
3540
ssHvparamsPref :: String
3541
ssHvparamsPref = "hvparams_"
3542

    
3543
-- * Hvparams keys
3544

    
3545
ssHvparamsXenChroot :: String
3546
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3547

    
3548
ssHvparamsXenFake :: String
3549
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3550

    
3551
ssHvparamsXenHvm :: String
3552
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3553

    
3554
ssHvparamsXenKvm :: String
3555
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3556

    
3557
ssHvparamsXenLxc :: String
3558
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3559

    
3560
ssHvparamsXenPvm :: String
3561
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3562

    
3563
validSsHvparamsKeys :: FrozenSet String
3564
validSsHvparamsKeys =
3565
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3566
                       ssHvparamsXenLxc,
3567
                       ssHvparamsXenFake,
3568
                       ssHvparamsXenHvm,
3569
                       ssHvparamsXenKvm,
3570
                       ssHvparamsXenPvm]
3571

    
3572
ssFilePerms :: Int
3573
ssFilePerms = 0o444
3574

    
3575
-- | Cluster wide default parameters
3576
defaultEnabledHypervisor :: String
3577
defaultEnabledHypervisor = htXenPvm
3578

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

    
3692
hvcGlobals :: FrozenSet String
3693
hvcGlobals =
3694
  ConstantUtils.mkSet [hvMigrationBandwidth,
3695
                       hvMigrationMode,
3696
                       hvMigrationPort,
3697
                       hvXenCmd]
3698

    
3699
becDefaults :: Map String PyValueEx
3700
becDefaults =
3701
  Map.fromList
3702
  [ (beMinmem, PyValueEx (128 :: Int))
3703
  , (beMaxmem, PyValueEx (128 :: Int))
3704
  , (beVcpus, PyValueEx (1 :: Int))
3705
  , (beAutoBalance, PyValueEx True)
3706
  , (beAlwaysFailover, PyValueEx False)
3707
  , (beSpindleUse, PyValueEx (1 :: Int))
3708
  ]
3709

    
3710
ndcDefaults :: Map String PyValueEx
3711
ndcDefaults =
3712
  Map.fromList
3713
  [ (ndOobProgram,       PyValueEx "")
3714
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3715
  , (ndExclusiveStorage, PyValueEx False)
3716
  , (ndOvs,              PyValueEx False)
3717
  , (ndOvsName,          PyValueEx defaultOvs)
3718
  , (ndOvsLink,          PyValueEx "")
3719
  ]
3720

    
3721
ndcGlobals :: FrozenSet String
3722
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3723

    
3724
-- | Default delay target measured in sectors
3725
defaultDelayTarget :: Int
3726
defaultDelayTarget = 1
3727

    
3728
defaultDiskCustom :: String
3729
defaultDiskCustom = ""
3730

    
3731
defaultDiskResync :: Bool
3732
defaultDiskResync = False
3733

    
3734
-- | Default fill target measured in sectors
3735
defaultFillTarget :: Int
3736
defaultFillTarget = 0
3737

    
3738
-- | Default mininum rate measured in KiB/s
3739
defaultMinRate :: Int
3740
defaultMinRate = 4 * 1024
3741

    
3742
defaultNetCustom :: String
3743
defaultNetCustom = ""
3744

    
3745
-- | Default plan ahead measured in sectors
3746
--
3747
-- The default values for the DRBD dynamic resync speed algorithm are
3748
-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
3749
-- (that we don't need to set to 0, because we have a separate option
3750
-- to enable it) and for c-max-rate, that we cap to the default value
3751
-- for the static resync rate.
3752
defaultPlanAhead :: Int
3753
defaultPlanAhead = 20
3754

    
3755
defaultRbdPool :: String
3756
defaultRbdPool = "rbd"
3757

    
3758
diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
3759
diskLdDefaults =
3760
  Map.fromList
3761
  [ (DTBlock, Map.empty)
3762
  , (DTDrbd8, Map.fromList
3763
              [ (ldpBarriers,      PyValueEx drbdBarriers)
3764
              , (ldpDefaultMetavg, PyValueEx defaultVg)
3765
              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
3766
              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
3767
              , (ldpDynamicResync, PyValueEx defaultDiskResync)
3768
              , (ldpFillTarget,    PyValueEx defaultFillTarget)
3769
              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
3770
              , (ldpMinRate,       PyValueEx defaultMinRate)
3771
              , (ldpNetCustom,     PyValueEx defaultNetCustom)
3772
              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
3773
              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
3774
              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
3775
              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
3776
              ])
3777
  , (DTExt, Map.fromList
3778
            [ (ldpAccess, PyValueEx diskKernelspace)
3779
            ])
3780
  , (DTFile, Map.empty)
3781
  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
3782
  , (DTRbd, Map.fromList
3783
            [ (ldpPool, PyValueEx defaultRbdPool)
3784
            , (ldpAccess, PyValueEx diskKernelspace)
3785
            ])
3786
  , (DTSharedFile, Map.empty)
3787
  ]
3788

    
3789
diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
3790
diskDtDefaults =
3791
  Map.fromList
3792
  [ (DTBlock,      Map.empty)
3793
  , (DTDiskless,   Map.empty)
3794
  , (DTDrbd8,      Map.fromList
3795
                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
3796
                   , (drbdDefaultMetavg, PyValueEx defaultVg)
3797
                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
3798
                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
3799
                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
3800
                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
3801
                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
3802
                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
3803
                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
3804
                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
3805
                   , (drbdMinRate,       PyValueEx defaultMinRate)
3806
                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
3807
                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
3808
                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
3809
                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
3810
                   ])
3811
  , (DTExt,        Map.fromList
3812
                   [ (rbdAccess, PyValueEx diskKernelspace)
3813
                   ])
3814
  , (DTFile,       Map.empty)
3815
  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
3816
  , (DTRbd,        Map.fromList
3817
                   [ (rbdPool, PyValueEx defaultRbdPool)
3818
                   , (rbdAccess, PyValueEx diskKernelspace)
3819
                   ])
3820
  , (DTSharedFile, Map.empty)
3821
  ]
3822

    
3823
niccDefaults :: Map String PyValueEx
3824
niccDefaults =
3825
  Map.fromList
3826
  [ (nicMode, PyValueEx nicModeBridged)
3827
  , (nicLink, PyValueEx defaultBridge)
3828
  , (nicVlan, PyValueEx "")
3829
  ]
3830

    
3831
-- | All of the following values are quite arbitrary - there are no
3832
-- "good" defaults, these must be customised per-site
3833
ispecsMinmaxDefaults :: Map String (Map String Int)
3834
ispecsMinmaxDefaults =
3835
  Map.fromList
3836
  [(ispecsMin,
3837
    Map.fromList
3838
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMinISpec),
3839
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMinISpec),
3840
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMinISpec),
3841
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMinISpec),
3842
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMinISpec),
3843
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMinISpec)]),
3844
   (ispecsMax,
3845
    Map.fromList
3846
    [(ConstantUtils.ispecMemSize, Types.iSpecMemorySize Types.defMaxISpec),
3847
     (ConstantUtils.ispecCpuCount, Types.iSpecCpuCount Types.defMaxISpec),
3848
     (ConstantUtils.ispecDiskCount, Types.iSpecDiskCount Types.defMaxISpec),
3849
     (ConstantUtils.ispecDiskSize, Types.iSpecDiskSize Types.defMaxISpec),
3850
     (ConstantUtils.ispecNicCount, Types.iSpecNicCount Types.defMaxISpec),
3851
     (ConstantUtils.ispecSpindleUse, Types.iSpecSpindleUse Types.defMaxISpec)])]
3852

    
3853
ipolicyDefaults :: Map String PyValueEx
3854
ipolicyDefaults =
3855
  Map.fromList
3856
  [ (ispecsMinmax,        PyValueEx [ispecsMinmaxDefaults])
3857
  , (ispecsStd,           PyValueEx (Map.fromList
3858
                                     [ (ispecMemSize,    128)
3859
                                     , (ispecCpuCount,   1)
3860
                                     , (ispecDiskCount,  1)
3861
                                     , (ispecDiskSize,   1024)
3862
                                     , (ispecNicCount,   1)
3863
                                     , (ispecSpindleUse, 1)
3864
                                     ] :: Map String Int))
3865
  , (ipolicyDts,          PyValueEx (ConstantUtils.toList diskTemplates))
3866
  , (ipolicyVcpuRatio,    PyValueEx (4.0 :: Double))
3867
  , (ipolicySpindleRatio, PyValueEx (32.0 :: Double))
3868
  ]
3869

    
3870
masterPoolSizeDefault :: Int
3871
masterPoolSizeDefault = 10
3872

    
3873
-- * Exclusive storage
3874

    
3875
-- | Error margin used to compare physical disks
3876
partMargin :: Double
3877
partMargin = 0.01
3878

    
3879
-- | Space reserved when creating instance disks
3880
partReserved :: Double
3881
partReserved = 0.02
3882

    
3883
-- * Confd
3884

    
3885
confdProtocolVersion :: Int
3886
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3887

    
3888
-- Confd request type
3889

    
3890
confdReqPing :: Int
3891
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3892

    
3893
confdReqNodeRoleByname :: Int
3894
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3895

    
3896
confdReqNodePipByInstanceIp :: Int
3897
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3898

    
3899
confdReqClusterMaster :: Int
3900
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3901

    
3902
confdReqNodePipList :: Int
3903
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3904

    
3905
confdReqMcPipList :: Int
3906
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3907

    
3908
confdReqInstancesIpsList :: Int
3909
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3910

    
3911
confdReqNodeDrbd :: Int
3912
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3913

    
3914
confdReqNodeInstances :: Int
3915
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3916

    
3917
confdReqs :: FrozenSet Int
3918
confdReqs =
3919
  ConstantUtils.mkSet .
3920
  map Types.confdRequestTypeToRaw $
3921
  [minBound..] \\ [ReqNodeInstances]
3922

    
3923
-- * Confd request type
3924

    
3925
confdReqfieldName :: Int
3926
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3927

    
3928
confdReqfieldIp :: Int
3929
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3930

    
3931
confdReqfieldMnodePip :: Int
3932
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3933

    
3934
-- * Confd repl status
3935

    
3936
confdReplStatusOk :: Int
3937
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3938

    
3939
confdReplStatusError :: Int
3940
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3941

    
3942
confdReplStatusNotimplemented :: Int
3943
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3944

    
3945
confdReplStatuses :: FrozenSet Int
3946
confdReplStatuses =
3947
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3948

    
3949
-- * Confd node role
3950

    
3951
confdNodeRoleMaster :: Int
3952
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3953

    
3954
confdNodeRoleCandidate :: Int
3955
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3956

    
3957
confdNodeRoleOffline :: Int
3958
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3959

    
3960
confdNodeRoleDrained :: Int
3961
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3962

    
3963
confdNodeRoleRegular :: Int
3964
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3965

    
3966
-- * A few common errors for confd
3967

    
3968
confdErrorUnknownEntry :: Int
3969
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3970

    
3971
confdErrorInternal :: Int
3972
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3973

    
3974
confdErrorArgument :: Int
3975
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3976

    
3977
-- * Confd request query fields
3978

    
3979
confdReqqLink :: String
3980
confdReqqLink = ConstantUtils.confdReqqLink
3981

    
3982
confdReqqIp :: String
3983
confdReqqIp = ConstantUtils.confdReqqIp
3984

    
3985
confdReqqIplist :: String
3986
confdReqqIplist = ConstantUtils.confdReqqIplist
3987

    
3988
confdReqqFields :: String
3989
confdReqqFields = ConstantUtils.confdReqqFields
3990

    
3991
-- | Each request is "salted" by the current timestamp.
3992
--
3993
-- This constant decides how many seconds of skew to accept.
3994
--
3995
-- TODO: make this a default and allow the value to be more
3996
-- configurable
3997
confdMaxClockSkew :: Int
3998
confdMaxClockSkew = 2 * nodeMaxClockSkew
3999

    
4000
-- | When we haven't reloaded the config for more than this amount of
4001
-- seconds, we force a test to see if inotify is betraying us. Using a
4002
-- prime number to ensure we get less chance of 'same wakeup' with
4003
-- other processes.
4004
confdConfigReloadTimeout :: Int
4005
confdConfigReloadTimeout = 17
4006

    
4007
-- | If we receive more than one update in this amount of
4008
-- microseconds, we move to polling every RATELIMIT seconds, rather
4009
-- than relying on inotify, to be able to serve more requests.
4010
confdConfigReloadRatelimit :: Int
4011
confdConfigReloadRatelimit = 250000
4012

    
4013
-- | Magic number prepended to all confd queries.
4014
--
4015
-- This allows us to distinguish different types of confd protocols
4016
-- and handle them. For example by changing this we can move the whole
4017
-- payload to be compressed, or move away from json.
4018
confdMagicFourcc :: String
4019
confdMagicFourcc = "plj0"
4020

    
4021
-- | By default a confd request is sent to the minimum between this
4022
-- number and all MCs. 6 was chosen because even in the case of a
4023
-- disastrous 50% response rate, we should have enough answers to be
4024
-- able to compare more than one.
4025
confdDefaultReqCoverage :: Int
4026
confdDefaultReqCoverage = 6
4027

    
4028
-- | Timeout in seconds to expire pending query request in the confd
4029
-- client library. We don't actually expect any answer more than 10
4030
-- seconds after we sent a request.
4031
confdClientExpireTimeout :: Int
4032
confdClientExpireTimeout = 10
4033

    
4034
-- | Maximum UDP datagram size.
4035
--
4036
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4037
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4038
--   (assuming we can't use jumbo frames)
4039
-- We just set this to 60K, which should be enough
4040
maxUdpDataSize :: Int
4041
maxUdpDataSize = 61440
4042

    
4043
-- * User-id pool minimum/maximum acceptable user-ids
4044

    
4045
uidpoolUidMin :: Int
4046
uidpoolUidMin = 0
4047

    
4048
-- | Assuming 32 bit user-ids
4049
uidpoolUidMax :: Integer
4050
uidpoolUidMax = 2 ^ 32 - 1
4051

    
4052
-- | Name or path of the pgrep command
4053
pgrep :: String
4054
pgrep = "pgrep"
4055

    
4056
-- | Name of the node group that gets created at cluster init or
4057
-- upgrade
4058
initialNodeGroupName :: String
4059
initialNodeGroupName = "default"
4060

    
4061
-- * Possible values for NodeGroup.alloc_policy
4062

    
4063
allocPolicyLastResort :: String
4064
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4065

    
4066
allocPolicyPreferred :: String
4067
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4068

    
4069
allocPolicyUnallocable :: String
4070
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4071

    
4072
validAllocPolicies :: [String]
4073
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4074

    
4075
-- | Temporary external/shared storage parameters
4076
blockdevDriverManual :: String
4077
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4078

    
4079
-- | 'qemu-img' path, required for 'ovfconverter'
4080
qemuimgPath :: String
4081
qemuimgPath = AutoConf.qemuimgPath
4082

    
4083
-- | Whether htools was enabled at compilation time
4084
--
4085
-- FIXME: this should be moved next to the other enable constants,
4086
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4087
htools :: Bool
4088
htools = AutoConf.htools
4089

    
4090
-- | The hail iallocator
4091
iallocHail :: String
4092
iallocHail = "hail"
4093

    
4094
-- * Fake opcodes for functions that have hooks attached to them via
4095
-- backend.RunLocalHooks
4096

    
4097
fakeOpMasterTurndown :: String
4098
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4099

    
4100
fakeOpMasterTurnup :: String
4101
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4102

    
4103
-- * SSH key types
4104

    
4105
sshkDsa :: String
4106
sshkDsa = "dsa"
4107

    
4108
sshkRsa :: String
4109
sshkRsa = "rsa"
4110

    
4111
sshkAll :: FrozenSet String
4112
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4113

    
4114
-- * SSH authorized key types
4115

    
4116
sshakDss :: String
4117
sshakDss = "ssh-dss"
4118

    
4119
sshakRsa :: String
4120
sshakRsa = "ssh-rsa"
4121

    
4122
sshakAll :: FrozenSet String
4123
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4124

    
4125
-- * SSH setup
4126

    
4127
sshsClusterName :: String
4128
sshsClusterName = "cluster_name"
4129

    
4130
sshsSshHostKey :: String
4131
sshsSshHostKey = "ssh_host_key"
4132

    
4133
sshsSshRootKey :: String
4134
sshsSshRootKey = "ssh_root_key"
4135

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

    
4139
-- * Key files for SSH daemon
4140

    
4141
sshHostDsaPriv :: String
4142
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4143

    
4144
sshHostDsaPub :: String
4145
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4146

    
4147
sshHostRsaPriv :: String
4148
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4149

    
4150
sshHostRsaPub :: String
4151
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4152

    
4153
sshDaemonKeyfiles :: Map String (String, String)
4154
sshDaemonKeyfiles =
4155
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4156
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4157
               ]
4158

    
4159
-- * Node daemon setup
4160

    
4161
ndsClusterName :: String
4162
ndsClusterName = "cluster_name"
4163

    
4164
ndsNodeDaemonCertificate :: String
4165
ndsNodeDaemonCertificate = "node_daemon_certificate"
4166

    
4167
ndsSsconf :: String
4168
ndsSsconf = "ssconf"
4169

    
4170
ndsStartNodeDaemon :: String
4171
ndsStartNodeDaemon = "start_node_daemon"
4172

    
4173
-- * The source reasons for the execution of an OpCode
4174

    
4175
opcodeReasonSrcClient :: String
4176
opcodeReasonSrcClient = "gnt:client"
4177

    
4178
opcodeReasonSrcNoded :: String
4179
opcodeReasonSrcNoded = "gnt:daemon:noded"
4180

    
4181
opcodeReasonSrcOpcode :: String
4182
opcodeReasonSrcOpcode = "gnt:opcode"
4183

    
4184
opcodeReasonSrcRlib2 :: String
4185
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4186

    
4187
opcodeReasonSrcUser :: String
4188
opcodeReasonSrcUser = "gnt:user"
4189

    
4190
opcodeReasonSources :: FrozenSet String
4191
opcodeReasonSources =
4192
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4193
                       opcodeReasonSrcNoded,
4194
                       opcodeReasonSrcOpcode,
4195
                       opcodeReasonSrcRlib2,
4196
                       opcodeReasonSrcUser]
4197

    
4198
-- | Path generating random UUID
4199
randomUuidFile :: String
4200
randomUuidFile = ConstantUtils.randomUuidFile
4201

    
4202
-- * Auto-repair tag prefixes
4203

    
4204
autoRepairTagPrefix :: String
4205
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4206

    
4207
autoRepairTagEnabled :: String
4208
autoRepairTagEnabled = autoRepairTagPrefix
4209

    
4210
autoRepairTagPending :: String
4211
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4212

    
4213
autoRepairTagResult :: String
4214
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4215

    
4216
autoRepairTagSuspended :: String
4217
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4218

    
4219
-- * Auto-repair levels
4220

    
4221
autoRepairFailover :: String
4222
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4223

    
4224
autoRepairFixStorage :: String
4225
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4226

    
4227
autoRepairMigrate :: String
4228
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4229

    
4230
autoRepairReinstall :: String
4231
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4232

    
4233
autoRepairAllTypes :: FrozenSet String
4234
autoRepairAllTypes =
4235
  ConstantUtils.mkSet [autoRepairFailover,
4236
                       autoRepairFixStorage,
4237
                       autoRepairMigrate,
4238
                       autoRepairReinstall]
4239

    
4240
-- * Auto-repair results
4241

    
4242
autoRepairEnoperm :: String
4243
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4244

    
4245
autoRepairFailure :: String
4246
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4247

    
4248
autoRepairSuccess :: String
4249
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4250

    
4251
autoRepairAllResults :: FrozenSet String
4252
autoRepairAllResults =
4253
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4254

    
4255
-- | The version identifier for builtin data collectors
4256
builtinDataCollectorVersion :: String
4257
builtinDataCollectorVersion = "B"
4258

    
4259
-- | The reason trail opcode parameter name
4260
opcodeReason :: String
4261
opcodeReason = "reason"
4262

    
4263
-- | The reason trail opcode parameter name
4264
opcodeSequential :: String
4265
opcodeSequential = "sequential"
4266

    
4267
diskstatsFile :: String
4268
diskstatsFile = "/proc/diskstats"
4269

    
4270
-- *  CPU load collector
4271

    
4272
statFile :: String
4273
statFile = "/proc/stat"
4274

    
4275
cpuavgloadBufferSize :: Int
4276
cpuavgloadBufferSize = 150
4277

    
4278
cpuavgloadWindowSize :: Int
4279
cpuavgloadWindowSize = 600
4280

    
4281
-- * Monitoring daemon
4282

    
4283
-- | Mond's variable for periodical data collection
4284
mondTimeInterval :: Int
4285
mondTimeInterval = 5
4286

    
4287
-- | Mond's latest API version
4288
mondLatestApiVersion :: Int
4289
mondLatestApiVersion = 1
4290

    
4291
-- * Disk access modes
4292

    
4293
diskUserspace :: String
4294
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4295

    
4296
diskKernelspace :: String
4297
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4298

    
4299
diskValidAccessModes :: FrozenSet String
4300
diskValidAccessModes =
4301
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4302

    
4303
-- | Timeout for queue draining in upgrades
4304
upgradeQueueDrainTimeout :: Int
4305
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4306

    
4307
-- | Intervall at which the queue is polled during upgrades
4308
upgradeQueuePollInterval :: Int
4309
upgradeQueuePollInterval  = 10
4310

    
4311
-- * Hotplug Actions
4312

    
4313
hotplugActionAdd :: String
4314
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4315

    
4316
hotplugActionRemove :: String
4317
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4318

    
4319
hotplugActionModify :: String
4320
hotplugActionModify = Types.hotplugActionToRaw HAMod
4321

    
4322
hotplugAllActions :: FrozenSet String
4323
hotplugAllActions =
4324
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4325

    
4326
-- * Hotplug Device Targets
4327

    
4328
hotplugTargetNic :: String
4329
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4330

    
4331
hotplugTargetDisk :: String
4332
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4333

    
4334
hotplugAllTargets :: FrozenSet String
4335
hotplugAllTargets =
4336
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4337

    
4338
-- | Timeout for disk removal (seconds)
4339
diskRemoveRetryTimeout :: Int
4340
diskRemoveRetryTimeout = 30
4341

    
4342
-- | Interval between disk removal retries (seconds)
4343
diskRemoveRetryInterval :: Int
4344
diskRemoveRetryInterval  = 3
4345

    
4346
-- * UUID regex
4347

    
4348
uuidRegex :: String
4349
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4350

    
4351
-- * Luxi constants
4352

    
4353
luxiSocketPerms :: Int
4354
luxiSocketPerms = 0o660
4355

    
4356
luxiKeyMethod :: String
4357
luxiKeyMethod = "method"
4358

    
4359
luxiKeyArgs :: String
4360
luxiKeyArgs = "args"
4361

    
4362
luxiKeySuccess :: String
4363
luxiKeySuccess = "success"
4364

    
4365
luxiKeyResult :: String
4366
luxiKeyResult = "result"
4367

    
4368
luxiKeyVersion :: String
4369
luxiKeyVersion = "version"
4370

    
4371
luxiReqSubmitJob :: String
4372
luxiReqSubmitJob = "SubmitJob"
4373

    
4374
luxiReqSubmitJobToDrainedQueue :: String
4375
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4376

    
4377
luxiReqSubmitManyJobs :: String
4378
luxiReqSubmitManyJobs = "SubmitManyJobs"
4379

    
4380
luxiReqWaitForJobChange :: String
4381
luxiReqWaitForJobChange = "WaitForJobChange"
4382

    
4383
luxiReqCancelJob :: String
4384
luxiReqCancelJob = "CancelJob"
4385

    
4386
luxiReqArchiveJob :: String
4387
luxiReqArchiveJob = "ArchiveJob"
4388

    
4389
luxiReqChangeJobPriority :: String
4390
luxiReqChangeJobPriority = "ChangeJobPriority"
4391

    
4392
luxiReqAutoArchiveJobs :: String
4393
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4394

    
4395
luxiReqQuery :: String
4396
luxiReqQuery = "Query"
4397

    
4398
luxiReqQueryFields :: String
4399
luxiReqQueryFields = "QueryFields"
4400

    
4401
luxiReqQueryJobs :: String
4402
luxiReqQueryJobs = "QueryJobs"
4403

    
4404
luxiReqQueryInstances :: String
4405
luxiReqQueryInstances = "QueryInstances"
4406

    
4407
luxiReqQueryNodes :: String
4408
luxiReqQueryNodes = "QueryNodes"
4409

    
4410
luxiReqQueryGroups :: String
4411
luxiReqQueryGroups = "QueryGroups"
4412

    
4413
luxiReqQueryNetworks :: String
4414
luxiReqQueryNetworks = "QueryNetworks"
4415

    
4416
luxiReqQueryExports :: String
4417
luxiReqQueryExports = "QueryExports"
4418

    
4419
luxiReqQueryConfigValues :: String
4420
luxiReqQueryConfigValues = "QueryConfigValues"
4421

    
4422
luxiReqQueryClusterInfo :: String
4423
luxiReqQueryClusterInfo = "QueryClusterInfo"
4424

    
4425
luxiReqQueryTags :: String
4426
luxiReqQueryTags = "QueryTags"
4427

    
4428
luxiReqSetDrainFlag :: String
4429
luxiReqSetDrainFlag = "SetDrainFlag"
4430

    
4431
luxiReqSetWatcherPause :: String
4432
luxiReqSetWatcherPause = "SetWatcherPause"
4433

    
4434
luxiReqAll :: FrozenSet String
4435
luxiReqAll =
4436
  ConstantUtils.mkSet
4437
  [ luxiReqArchiveJob
4438
  , luxiReqAutoArchiveJobs
4439
  , luxiReqCancelJob
4440
  , luxiReqChangeJobPriority
4441
  , luxiReqQuery
4442
  , luxiReqQueryClusterInfo
4443
  , luxiReqQueryConfigValues
4444
  , luxiReqQueryExports
4445
  , luxiReqQueryFields
4446
  , luxiReqQueryGroups
4447
  , luxiReqQueryInstances
4448
  , luxiReqQueryJobs
4449
  , luxiReqQueryNodes
4450
  , luxiReqQueryNetworks
4451
  , luxiReqQueryTags
4452
  , luxiReqSetDrainFlag
4453
  , luxiReqSetWatcherPause
4454
  , luxiReqSubmitJob
4455
  , luxiReqSubmitJobToDrainedQueue
4456
  , luxiReqSubmitManyJobs
4457
  , luxiReqWaitForJobChange
4458
  ]
4459

    
4460
luxiDefCtmo :: Int
4461
luxiDefCtmo = 10
4462

    
4463
luxiDefRwto :: Int
4464
luxiDefRwto = 60
4465

    
4466
-- | 'WaitForJobChange' timeout
4467
luxiWfjcTimeout :: Int
4468
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4469

    
4470
-- * Query language constants
4471

    
4472
-- ** Logic operators with one or more operands, each of which is a
4473
-- filter on its own
4474

    
4475
qlangOpAnd :: String
4476
qlangOpAnd = "&"
4477

    
4478
qlangOpOr :: String
4479
qlangOpOr = "|"
4480

    
4481
-- ** Unary operators with exactly one operand
4482

    
4483
qlangOpNot :: String
4484
qlangOpNot = "!"
4485

    
4486
qlangOpTrue :: String
4487
qlangOpTrue = "?"
4488

    
4489
-- ** Binary operators with exactly two operands, the field name and
4490
-- an operator-specific value
4491

    
4492
qlangOpContains :: String
4493
qlangOpContains = "=[]"
4494

    
4495
qlangOpEqual :: String
4496
qlangOpEqual = "="
4497

    
4498
qlangOpGe :: String
4499
qlangOpGe = ">="
4500

    
4501
qlangOpGt :: String
4502
qlangOpGt = ">"
4503

    
4504
qlangOpLe :: String
4505
qlangOpLe = "<="
4506

    
4507
qlangOpLt :: String
4508
qlangOpLt = "<"
4509

    
4510
qlangOpNotEqual :: String
4511
qlangOpNotEqual = "!="
4512

    
4513
qlangOpRegexp :: String
4514
qlangOpRegexp = "=~"
4515

    
4516
-- | Characters used for detecting user-written filters (see
4517
-- L{_CheckFilter})
4518

    
4519
qlangFilterDetectionChars :: FrozenSet String
4520
qlangFilterDetectionChars =
4521
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4522
                       ")", "(", "\x0b", "\n",
4523
                       "\r", "\x0c", "/", "<",
4524
                       "\t", ">", "=", "\\", "~"]
4525

    
4526
-- | Characters used to detect globbing filters
4527
qlangGlobDetectionChars :: FrozenSet String
4528
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4529

    
4530
-- * Error related constants
4531
--
4532
-- 'OpPrereqError' failure types
4533

    
4534
-- | Environment error (e.g. node disk error)
4535
errorsEcodeEnviron :: String
4536
errorsEcodeEnviron = "environment_error"
4537

    
4538
-- | Entity already exists
4539
errorsEcodeExists :: String
4540
errorsEcodeExists = "already_exists"
4541

    
4542
-- | Internal cluster error
4543
errorsEcodeFault :: String
4544
errorsEcodeFault = "internal_error"
4545

    
4546
-- | Wrong arguments (at syntax level)
4547
errorsEcodeInval :: String
4548
errorsEcodeInval = "wrong_input"
4549

    
4550
-- | Entity not found
4551
errorsEcodeNoent :: String
4552
errorsEcodeNoent = "unknown_entity"
4553

    
4554
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4555
errorsEcodeNores :: String
4556
errorsEcodeNores = "insufficient_resources"
4557

    
4558
-- | Resource not unique (e.g. MAC or IP duplication)
4559
errorsEcodeNotunique :: String
4560
errorsEcodeNotunique = "resource_not_unique"
4561

    
4562
-- | Resolver errors
4563
errorsEcodeResolver :: String
4564
errorsEcodeResolver = "resolver_error"
4565

    
4566
-- | Wrong entity state
4567
errorsEcodeState :: String
4568
errorsEcodeState = "wrong_state"
4569

    
4570
-- | Temporarily out of resources; operation can be tried again
4571
errorsEcodeTempNores :: String
4572
errorsEcodeTempNores = "temp_insufficient_resources"
4573

    
4574
errorsEcodeAll :: FrozenSet String
4575
errorsEcodeAll =
4576
  ConstantUtils.mkSet [ errorsEcodeNores
4577
                      , errorsEcodeExists
4578
                      , errorsEcodeState
4579
                      , errorsEcodeNotunique
4580
                      , errorsEcodeTempNores
4581
                      , errorsEcodeNoent
4582
                      , errorsEcodeFault
4583
                      , errorsEcodeResolver
4584
                      , errorsEcodeInval
4585
                      , errorsEcodeEnviron
4586
                      ]
4587

    
4588
-- * Jstore related constants
4589

    
4590
jstoreJobsPerArchiveDirectory :: Int
4591
jstoreJobsPerArchiveDirectory = 10000