Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Constants.hs @ 845b7ed1

History | View | Annotate | Download (116.1 kB)

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

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

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

    
15
-}
16

    
17
{-
18

    
19
Copyright (C) 2013 Google Inc.
20

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

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

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

    
36
-}
37
module Ganeti.Constants where
38

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

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

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

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

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

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

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

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

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

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

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

    
86
-- ** Build-time constants
87

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
135
-- * Various versions
136

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

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

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

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

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

    
152
osApiV10 :: Int
153
osApiV10 = 10
154

    
155
osApiV15 :: Int
156
osApiV15 = 15
157

    
158
osApiV20 :: Int
159
osApiV20 = 20
160

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

    
164
exportVersion :: Int
165
exportVersion = 0
166

    
167
rapiVersion :: Int
168
rapiVersion = 2
169

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

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

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

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

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

    
189
-- * User separation
190

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
239
-- * Cpu pinning separators and constants
240

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

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

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

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

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

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

    
279
-- * Wipe
280

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

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

    
288
minWipeChunkPercent :: Int
289
minWipeChunkPercent = 10
290

    
291
-- * Directories
292

    
293
runDirsMode :: Int
294
runDirsMode = 0o775
295

    
296
secureDirMode :: Int
297
secureDirMode = 0o700
298

    
299
secureFileMode :: Int
300
secureFileMode = 0o600
301

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

    
305
-- * 'autoconf' enable/disable
306

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

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

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

    
316
-- * SSH constants
317

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

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

    
324
-- * Daemons
325

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

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

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

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

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

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

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

    
353
defaultConfdPort :: Int
354
defaultConfdPort = 1814
355

    
356
defaultMondPort :: Int
357
defaultMondPort = 1815
358

    
359
defaultNodedPort :: Int
360
defaultNodedPort = 1811
361

    
362
defaultRapiPort :: Int
363
defaultRapiPort = 5080
364

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

    
373
firstDrbdPort :: Int
374
firstDrbdPort = 11000
375

    
376
lastDrbdPort :: Int
377
lastDrbdPort = 14999
378

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

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

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

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

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

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

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

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

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

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

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

    
421
luxiVersion :: Int
422
luxiVersion = configVersion
423

    
424
-- * Syslog
425

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

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

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

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

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

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

    
444
-- * Xen
445

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

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

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

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

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

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

    
466
-- * KVM and socat
467

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

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

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

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

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

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

    
486
-- * Console types
487

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

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

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

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

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

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

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

    
526
-- * X509
527

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

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

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

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

    
543
-- * Import/export daemon mode
544

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

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

    
551
-- * Import/export transport compression
552

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

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

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

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

    
565
-- * Import/export I/O
566

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

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

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

    
580
-- * Values
581

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

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

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

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

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

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

    
600
-- * Hooks
601

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

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

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

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

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

    
617
hooksVersion :: Int
618
hooksVersion = 2
619

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

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

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

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

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

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

    
637
-- * Hkr
638

    
639
hkrSkip :: Int
640
hkrSkip = 0
641

    
642
hkrFail :: Int
643
hkrFail = 1
644

    
645
hkrSuccess :: Int
646
hkrSuccess = 2
647

    
648
-- * Storage types
649

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
717
-- * Storage operations
718

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

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

    
727
-- * Volume fields
728

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

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

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

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

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

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

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

    
750
-- * Local disk status
751

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

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

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

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

    
766
-- * Disk template types
767

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
899
-- * Drbd
900

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

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

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

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

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

    
917
-- * Drbd barrier types
918

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

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

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

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

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

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

    
949
-- * File backend driver
950

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

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

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

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

    
966
-- * Disk access mode
967

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

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

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

    
977
-- * Disk replacement mode
978

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

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

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

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

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

    
995
-- * Instance export mode
996

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

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

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

    
1006
-- * Instance creation modes
1007

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

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

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

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

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

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

    
1026
rieVersion :: Int
1027
rieVersion = 0
1028

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

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

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

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

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

    
1049
-- * Import/export config options
1050

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

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

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

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

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

    
1066
-- * Dynamic device modification
1067

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

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

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

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

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

    
1083
-- * Common exit codes
1084

    
1085
exitSuccess :: Int
1086
exitSuccess = 0
1087

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

    
1091
exitNotcluster :: Int
1092
exitNotcluster = 5
1093

    
1094
exitNotmaster :: Int
1095
exitNotmaster = 11
1096

    
1097
exitNodesetupError :: Int
1098
exitNodesetupError = 12
1099

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

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

    
1108
-- * Tags
1109

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

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

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

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

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

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

    
1128
maxTagLen :: Int
1129
maxTagLen = 128
1130

    
1131
maxTagsPerObj :: Int
1132
maxTagsPerObj = 4096
1133

    
1134
-- * Others
1135

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

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

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

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

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

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

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

    
1158
ip4Version :: Int
1159
ip4Version = 4
1160

    
1161
ip6Version :: Int
1162
ip6Version = 6
1163

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

    
1167
tcpPingTimeout :: Int
1168
tcpPingTimeout = 10
1169

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

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

    
1176
minVgSize :: Int
1177
minVgSize = 20480
1178

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

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

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

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

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

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

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

    
1205
-- * Runparts results
1206

    
1207
runpartsErr :: Int
1208
runpartsErr = 2
1209

    
1210
runpartsRun :: Int
1211
runpartsRun = 1
1212

    
1213
runpartsSkip :: Int
1214
runpartsSkip = 0
1215

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

    
1219
-- * RPC
1220

    
1221
rpcEncodingNone :: Int
1222
rpcEncodingNone = 0
1223

    
1224
rpcEncodingZlibBase64 :: Int
1225
rpcEncodingZlibBase64 = 1
1226

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

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

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

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

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

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

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

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

    
1259
-- OS
1260

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1318
esScriptCreate :: String
1319
esScriptCreate = esActionCreate
1320

    
1321
esScriptRemove :: String
1322
esScriptRemove = esActionRemove
1323

    
1324
esScriptGrow :: String
1325
esScriptGrow = esActionGrow
1326

    
1327
esScriptAttach :: String
1328
esScriptAttach = esActionAttach
1329

    
1330
esScriptDetach :: String
1331
esScriptDetach = esActionDetach
1332

    
1333
esScriptSetinfo :: String
1334
esScriptSetinfo = esActionSetinfo
1335

    
1336
esScriptVerify :: String
1337
esScriptVerify = esActionVerify
1338

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

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

    
1352
-- * Reboot types
1353

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

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

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

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

    
1366
-- * Instance reboot behaviors
1367

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

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

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

    
1377
-- * VTypes
1378

    
1379
vtypeBool :: VType
1380
vtypeBool = VTypeBool
1381

    
1382
vtypeInt :: VType
1383
vtypeInt = VTypeInt
1384

    
1385
vtypeMaybeString :: VType
1386
vtypeMaybeString = VTypeMaybeString
1387

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

    
1392
vtypeString :: VType
1393
vtypeString = VTypeString
1394

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1735
-- * Migration statuses
1736

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

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

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

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

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

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

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

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

    
1770
-- * Hypervisor state
1771

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

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

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

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

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

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

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

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

    
1812
-- * Disk state
1813

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

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

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

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

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

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

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

    
1843
-- Backend parameter names
1844

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1972
-- | Node parameter names
1973

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

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

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

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

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

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

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

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

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

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

    
2019
-- * Logical Disks parameters
2020

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2176
diskDtParameters :: FrozenSet String
2177
diskDtParameters = ConstantUtils.mkSet (Map.keys diskDtTypes)
2178

    
2179
-- * Dynamic disk parameters
2180

    
2181
ddpLocalIp :: String
2182
ddpLocalIp = "local-ip"
2183

    
2184
ddpRemoteIp :: String
2185
ddpRemoteIp = "remote-ip"
2186

    
2187
ddpPort :: String
2188
ddpPort = "port"
2189

    
2190
ddpLocalMinor :: String
2191
ddpLocalMinor = "local-minor"
2192

    
2193
ddpRemoteMinor :: String
2194
ddpRemoteMinor = "remote-minor"
2195

    
2196
-- * OOB supported commands
2197

    
2198
oobPowerOn :: String
2199
oobPowerOn = Types.oobCommandToRaw OobPowerOn
2200

    
2201
oobPowerOff :: String
2202
oobPowerOff = Types.oobCommandToRaw OobPowerOff
2203

    
2204
oobPowerCycle :: String
2205
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
2206

    
2207
oobPowerStatus :: String
2208
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
2209

    
2210
oobHealth :: String
2211
oobHealth = Types.oobCommandToRaw OobHealth
2212

    
2213
oobCommands :: FrozenSet String
2214
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
2215

    
2216
oobPowerStatusPowered :: String
2217
oobPowerStatusPowered = "powered"
2218

    
2219
-- | 60 seconds
2220
oobTimeout :: Int
2221
oobTimeout = 60
2222

    
2223
-- | 2 seconds
2224
oobPowerDelay :: Double
2225
oobPowerDelay = 2.0
2226

    
2227
oobStatusCritical :: String
2228
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
2229

    
2230
oobStatusOk :: String
2231
oobStatusOk = Types.oobStatusToRaw OobStatusOk
2232

    
2233
oobStatusUnknown :: String
2234
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
2235

    
2236
oobStatusWarning :: String
2237
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
2238

    
2239
oobStatuses :: FrozenSet String
2240
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
2241

    
2242
-- | Instance Parameters Profile
2243
ppDefault :: String
2244
ppDefault = "default"
2245

    
2246
-- * nic* constants are used inside the ganeti config
2247

    
2248
nicLink :: String
2249
nicLink = "link"
2250

    
2251
nicMode :: String
2252
nicMode = "mode"
2253

    
2254
nicVlan :: String
2255
nicVlan = "vlan"
2256

    
2257
nicsParameterTypes :: Map String VType
2258
nicsParameterTypes =
2259
  Map.fromList [(nicMode, vtypeString),
2260
                (nicLink, vtypeString),
2261
                (nicVlan, vtypeString)]
2262

    
2263
nicsParameters :: FrozenSet String
2264
nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
2265

    
2266
nicModeBridged :: String
2267
nicModeBridged = Types.nICModeToRaw NMBridged
2268

    
2269
nicModeRouted :: String
2270
nicModeRouted = Types.nICModeToRaw NMRouted
2271

    
2272
nicModeOvs :: String
2273
nicModeOvs = Types.nICModeToRaw NMOvs
2274

    
2275
nicIpPool :: String
2276
nicIpPool = Types.nICModeToRaw NMPool
2277

    
2278
nicValidModes :: FrozenSet String
2279
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
2280

    
2281
releaseAction :: String
2282
releaseAction = "release"
2283

    
2284
reserveAction :: String
2285
reserveAction = "reserve"
2286

    
2287
-- * idisk* constants are used in opcodes, to create/change disks
2288

    
2289
idiskAdopt :: String
2290
idiskAdopt = "adopt"
2291

    
2292
idiskMetavg :: String
2293
idiskMetavg = "metavg"
2294

    
2295
idiskMode :: String
2296
idiskMode = "mode"
2297

    
2298
idiskName :: String
2299
idiskName = "name"
2300

    
2301
idiskSize :: String
2302
idiskSize = "size"
2303

    
2304
idiskSpindles :: String
2305
idiskSpindles = "spindles"
2306

    
2307
idiskVg :: String
2308
idiskVg = "vg"
2309

    
2310
idiskProvider :: String
2311
idiskProvider = "provider"
2312

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

    
2324
idiskParams :: FrozenSet String
2325
idiskParams = ConstantUtils.mkSet (Map.keys idiskParamsTypes)
2326

    
2327
-- * inic* constants are used in opcodes, to create/change nics
2328

    
2329
inicBridge :: String
2330
inicBridge = "bridge"
2331

    
2332
inicIp :: String
2333
inicIp = "ip"
2334

    
2335
inicLink :: String
2336
inicLink = "link"
2337

    
2338
inicMac :: String
2339
inicMac = "mac"
2340

    
2341
inicMode :: String
2342
inicMode = "mode"
2343

    
2344
inicName :: String
2345
inicName = "name"
2346

    
2347
inicNetwork :: String
2348
inicNetwork = "network"
2349

    
2350
inicVlan :: String
2351
inicVlan = "vlan"
2352

    
2353
inicParamsTypes :: Map String VType
2354
inicParamsTypes =
2355
  Map.fromList [(inicBridge, VTypeMaybeString),
2356
                (inicIp, VTypeMaybeString),
2357
                (inicLink, VTypeString),
2358
                (inicMac, VTypeString),
2359
                (inicMode, VTypeString),
2360
                (inicName, VTypeMaybeString),
2361
                (inicNetwork, VTypeMaybeString),
2362
                (inicVlan, VTypeMaybeString)]
2363

    
2364
inicParams :: FrozenSet String
2365
inicParams = ConstantUtils.mkSet (Map.keys inicParamsTypes)
2366

    
2367
-- * Hypervisor constants
2368

    
2369
htXenPvm :: String
2370
htXenPvm = Types.hypervisorToRaw XenPvm
2371

    
2372
htFake :: String
2373
htFake = Types.hypervisorToRaw Fake
2374

    
2375
htXenHvm :: String
2376
htXenHvm = Types.hypervisorToRaw XenHvm
2377

    
2378
htKvm :: String
2379
htKvm = Types.hypervisorToRaw Kvm
2380

    
2381
htChroot :: String
2382
htChroot = Types.hypervisorToRaw Chroot
2383

    
2384
htLxc :: String
2385
htLxc = Types.hypervisorToRaw Lxc
2386

    
2387
hyperTypes :: FrozenSet String
2388
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
2389

    
2390
htsReqPort :: FrozenSet String
2391
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
2392

    
2393
vncBasePort :: Int
2394
vncBasePort = 5900
2395

    
2396
vncDefaultBindAddress :: String
2397
vncDefaultBindAddress = ip4AddressAny
2398

    
2399
-- * NIC types
2400

    
2401
htNicE1000 :: String
2402
htNicE1000 = "e1000"
2403

    
2404
htNicI82551 :: String
2405
htNicI82551 = "i82551"
2406

    
2407
htNicI8259er :: String
2408
htNicI8259er = "i82559er"
2409

    
2410
htNicI85557b :: String
2411
htNicI85557b = "i82557b"
2412

    
2413
htNicNe2kIsa :: String
2414
htNicNe2kIsa = "ne2k_isa"
2415

    
2416
htNicNe2kPci :: String
2417
htNicNe2kPci = "ne2k_pci"
2418

    
2419
htNicParavirtual :: String
2420
htNicParavirtual = "paravirtual"
2421

    
2422
htNicPcnet :: String
2423
htNicPcnet = "pcnet"
2424

    
2425
htNicRtl8139 :: String
2426
htNicRtl8139 = "rtl8139"
2427

    
2428
htHvmValidNicTypes :: FrozenSet String
2429
htHvmValidNicTypes =
2430
  ConstantUtils.mkSet [htNicE1000,
2431
                       htNicNe2kIsa,
2432
                       htNicNe2kPci,
2433
                       htNicParavirtual,
2434
                       htNicRtl8139]
2435

    
2436
htKvmValidNicTypes :: FrozenSet String
2437
htKvmValidNicTypes =
2438
  ConstantUtils.mkSet [htNicE1000,
2439
                       htNicI82551,
2440
                       htNicI8259er,
2441
                       htNicI85557b,
2442
                       htNicNe2kIsa,
2443
                       htNicNe2kPci,
2444
                       htNicParavirtual,
2445
                       htNicPcnet,
2446
                       htNicRtl8139]
2447

    
2448
-- * Vif types
2449

    
2450
-- | Default vif type in xen-hvm
2451
htHvmVifIoemu :: String
2452
htHvmVifIoemu = "ioemu"
2453

    
2454
htHvmVifVif :: String
2455
htHvmVifVif = "vif"
2456

    
2457
htHvmValidVifTypes :: FrozenSet String
2458
htHvmValidVifTypes = ConstantUtils.mkSet [htHvmVifIoemu, htHvmVifVif]
2459

    
2460
-- * Disk types
2461

    
2462
htDiskIde :: String
2463
htDiskIde = "ide"
2464

    
2465
htDiskIoemu :: String
2466
htDiskIoemu = "ioemu"
2467

    
2468
htDiskMtd :: String
2469
htDiskMtd = "mtd"
2470

    
2471
htDiskParavirtual :: String
2472
htDiskParavirtual = "paravirtual"
2473

    
2474
htDiskPflash :: String
2475
htDiskPflash = "pflash"
2476

    
2477
htDiskScsi :: String
2478
htDiskScsi = "scsi"
2479

    
2480
htDiskSd :: String
2481
htDiskSd = "sd"
2482

    
2483
htHvmValidDiskTypes :: FrozenSet String
2484
htHvmValidDiskTypes = ConstantUtils.mkSet [htDiskIoemu, htDiskParavirtual]
2485

    
2486
htKvmValidDiskTypes :: FrozenSet String
2487
htKvmValidDiskTypes =
2488
  ConstantUtils.mkSet [htDiskIde,
2489
                       htDiskMtd,
2490
                       htDiskParavirtual,
2491
                       htDiskPflash,
2492
                       htDiskScsi,
2493
                       htDiskSd]
2494

    
2495
htCacheDefault :: String
2496
htCacheDefault = "default"
2497

    
2498
htCacheNone :: String
2499
htCacheNone = "none"
2500

    
2501
htCacheWback :: String
2502
htCacheWback = "writeback"
2503

    
2504
htCacheWthrough :: String
2505
htCacheWthrough = "writethrough"
2506

    
2507
htValidCacheTypes :: FrozenSet String
2508
htValidCacheTypes =
2509
  ConstantUtils.mkSet [htCacheDefault,
2510
                       htCacheNone,
2511
                       htCacheWback,
2512
                       htCacheWthrough]
2513

    
2514
-- * Mouse types
2515

    
2516
htMouseMouse :: String
2517
htMouseMouse = "mouse"
2518

    
2519
htMouseTablet :: String
2520
htMouseTablet = "tablet"
2521

    
2522
htKvmValidMouseTypes :: FrozenSet String
2523
htKvmValidMouseTypes = ConstantUtils.mkSet [htMouseMouse, htMouseTablet]
2524

    
2525
-- * Boot order
2526

    
2527
htBoCdrom :: String
2528
htBoCdrom = "cdrom"
2529

    
2530
htBoDisk :: String
2531
htBoDisk = "disk"
2532

    
2533
htBoFloppy :: String
2534
htBoFloppy = "floppy"
2535

    
2536
htBoNetwork :: String
2537
htBoNetwork = "network"
2538

    
2539
htKvmValidBoTypes :: FrozenSet String
2540
htKvmValidBoTypes =
2541
  ConstantUtils.mkSet [htBoCdrom, htBoDisk, htBoFloppy, htBoNetwork]
2542

    
2543
-- * SPICE lossless image compression options
2544

    
2545
htKvmSpiceLosslessImgComprAutoGlz :: String
2546
htKvmSpiceLosslessImgComprAutoGlz = "auto_glz"
2547

    
2548
htKvmSpiceLosslessImgComprAutoLz :: String
2549
htKvmSpiceLosslessImgComprAutoLz = "auto_lz"
2550

    
2551
htKvmSpiceLosslessImgComprGlz :: String
2552
htKvmSpiceLosslessImgComprGlz = "glz"
2553

    
2554
htKvmSpiceLosslessImgComprLz :: String
2555
htKvmSpiceLosslessImgComprLz = "lz"
2556

    
2557
htKvmSpiceLosslessImgComprOff :: String
2558
htKvmSpiceLosslessImgComprOff = "off"
2559

    
2560
htKvmSpiceLosslessImgComprQuic :: String
2561
htKvmSpiceLosslessImgComprQuic = "quic"
2562

    
2563
htKvmSpiceValidLosslessImgComprOptions :: FrozenSet String
2564
htKvmSpiceValidLosslessImgComprOptions =
2565
  ConstantUtils.mkSet [htKvmSpiceLosslessImgComprAutoGlz,
2566
                       htKvmSpiceLosslessImgComprAutoLz,
2567
                       htKvmSpiceLosslessImgComprGlz,
2568
                       htKvmSpiceLosslessImgComprLz,
2569
                       htKvmSpiceLosslessImgComprOff,
2570
                       htKvmSpiceLosslessImgComprQuic]
2571

    
2572
htKvmSpiceLossyImgComprAlways :: String
2573
htKvmSpiceLossyImgComprAlways = "always"
2574

    
2575
htKvmSpiceLossyImgComprAuto :: String
2576
htKvmSpiceLossyImgComprAuto = "auto"
2577

    
2578
htKvmSpiceLossyImgComprNever :: String
2579
htKvmSpiceLossyImgComprNever = "never"
2580

    
2581
htKvmSpiceValidLossyImgComprOptions :: FrozenSet String
2582
htKvmSpiceValidLossyImgComprOptions =
2583
  ConstantUtils.mkSet [htKvmSpiceLossyImgComprAlways,
2584
                       htKvmSpiceLossyImgComprAuto,
2585
                       htKvmSpiceLossyImgComprNever]
2586

    
2587
-- * SPICE video stream detection
2588

    
2589
htKvmSpiceVideoStreamDetectionAll :: String
2590
htKvmSpiceVideoStreamDetectionAll = "all"
2591

    
2592
htKvmSpiceVideoStreamDetectionFilter :: String
2593
htKvmSpiceVideoStreamDetectionFilter = "filter"
2594

    
2595
htKvmSpiceVideoStreamDetectionOff :: String
2596
htKvmSpiceVideoStreamDetectionOff = "off"
2597

    
2598
htKvmSpiceValidVideoStreamDetectionOptions :: FrozenSet String
2599
htKvmSpiceValidVideoStreamDetectionOptions =
2600
  ConstantUtils.mkSet [htKvmSpiceVideoStreamDetectionAll,
2601
                       htKvmSpiceVideoStreamDetectionFilter,
2602
                       htKvmSpiceVideoStreamDetectionOff]
2603

    
2604
-- * Security models
2605

    
2606
htSmNone :: String
2607
htSmNone = "none"
2608

    
2609
htSmPool :: String
2610
htSmPool = "pool"
2611

    
2612
htSmUser :: String
2613
htSmUser = "user"
2614

    
2615
htKvmValidSmTypes :: FrozenSet String
2616
htKvmValidSmTypes = ConstantUtils.mkSet [htSmNone, htSmPool, htSmUser]
2617

    
2618
-- * Kvm flag values
2619

    
2620
htKvmDisabled :: String
2621
htKvmDisabled = "disabled"
2622

    
2623
htKvmEnabled :: String
2624
htKvmEnabled = "enabled"
2625

    
2626
htKvmFlagValues :: FrozenSet String
2627
htKvmFlagValues = ConstantUtils.mkSet [htKvmDisabled, htKvmEnabled]
2628

    
2629
-- * Migration type
2630

    
2631
htMigrationLive :: String
2632
htMigrationLive = Types.migrationModeToRaw MigrationLive
2633

    
2634
htMigrationNonlive :: String
2635
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
2636

    
2637
htMigrationModes :: FrozenSet String
2638
htMigrationModes =
2639
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
2640

    
2641
-- * Cluster verify steps
2642

    
2643
verifyNplusoneMem :: String
2644
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
2645

    
2646
verifyOptionalChecks :: FrozenSet String
2647
verifyOptionalChecks =
2648
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
2649

    
2650
-- * Cluster Verify error classes
2651

    
2652
cvTcluster :: String
2653
cvTcluster = "cluster"
2654

    
2655
cvTgroup :: String
2656
cvTgroup = "group"
2657

    
2658
cvTnode :: String
2659
cvTnode = "node"
2660

    
2661
cvTinstance :: String
2662
cvTinstance = "instance"
2663

    
2664
-- * Cluster Verify error codes and documentation
2665

    
2666
cvEclustercert :: (String, String, String)
2667
cvEclustercert =
2668
  ("cluster",
2669
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
2670
   "Cluster certificate files verification failure")
2671

    
2672
cvEclustercfg :: (String, String, String)
2673
cvEclustercfg =
2674
  ("cluster",
2675
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
2676
   "Cluster configuration verification failure")
2677

    
2678
cvEclusterdanglinginst :: (String, String, String)
2679
cvEclusterdanglinginst =
2680
  ("node",
2681
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
2682
   "Some instances have a non-existing primary node")
2683

    
2684
cvEclusterdanglingnodes :: (String, String, String)
2685
cvEclusterdanglingnodes =
2686
  ("node",
2687
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
2688
   "Some nodes belong to non-existing groups")
2689

    
2690
cvEclusterfilecheck :: (String, String, String)
2691
cvEclusterfilecheck =
2692
  ("cluster",
2693
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
2694
   "Cluster configuration verification failure")
2695

    
2696
cvEgroupdifferentpvsize :: (String, String, String)
2697
cvEgroupdifferentpvsize =
2698
  ("group",
2699
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
2700
   "PVs in the group have different sizes")
2701

    
2702
cvEinstancebadnode :: (String, String, String)
2703
cvEinstancebadnode =
2704
  ("instance",
2705
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
2706
   "Instance marked as running lives on an offline node")
2707

    
2708
cvEinstancedown :: (String, String, String)
2709
cvEinstancedown =
2710
  ("instance",
2711
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
2712
   "Instance not running on its primary node")
2713

    
2714
cvEinstancefaultydisk :: (String, String, String)
2715
cvEinstancefaultydisk =
2716
  ("instance",
2717
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
2718
   "Impossible to retrieve status for a disk")
2719

    
2720
cvEinstancelayout :: (String, String, String)
2721
cvEinstancelayout =
2722
  ("instance",
2723
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
2724
   "Instance has multiple secondary nodes")
2725

    
2726
cvEinstancemissingcfgparameter :: (String, String, String)
2727
cvEinstancemissingcfgparameter =
2728
  ("instance",
2729
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
2730
   "A configuration parameter for an instance is missing")
2731

    
2732
cvEinstancemissingdisk :: (String, String, String)
2733
cvEinstancemissingdisk =
2734
  ("instance",
2735
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
2736
   "Missing volume on an instance")
2737

    
2738
cvEinstancepolicy :: (String, String, String)
2739
cvEinstancepolicy =
2740
  ("instance",
2741
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
2742
   "Instance does not meet policy")
2743

    
2744
cvEinstancesplitgroups :: (String, String, String)
2745
cvEinstancesplitgroups =
2746
  ("instance",
2747
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
2748
   "Instance with primary and secondary nodes in different groups")
2749

    
2750
cvEinstanceunsuitablenode :: (String, String, String)
2751
cvEinstanceunsuitablenode =
2752
  ("instance",
2753
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
2754
   "Instance running on nodes that are not suitable for it")
2755

    
2756
cvEinstancewrongnode :: (String, String, String)
2757
cvEinstancewrongnode =
2758
  ("instance",
2759
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
2760
   "Instance running on the wrong node")
2761

    
2762
cvEnodedrbd :: (String, String, String)
2763
cvEnodedrbd =
2764
  ("node",
2765
   Types.cVErrorCodeToRaw CvENODEDRBD,
2766
   "Error parsing the DRBD status file")
2767

    
2768
cvEnodedrbdhelper :: (String, String, String)
2769
cvEnodedrbdhelper =
2770
  ("node",
2771
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
2772
   "Error caused by the DRBD helper")
2773

    
2774
cvEnodedrbdversion :: (String, String, String)
2775
cvEnodedrbdversion =
2776
  ("node",
2777
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
2778
   "DRBD version mismatch within a node group")
2779

    
2780
cvEnodefilecheck :: (String, String, String)
2781
cvEnodefilecheck =
2782
  ("node",
2783
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
2784
   "Error retrieving the checksum of the node files")
2785

    
2786
cvEnodefilestoragepaths :: (String, String, String)
2787
cvEnodefilestoragepaths =
2788
  ("node",
2789
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
2790
   "Detected bad file storage paths")
2791

    
2792
cvEnodefilestoragepathunusable :: (String, String, String)
2793
cvEnodefilestoragepathunusable =
2794
  ("node",
2795
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
2796
   "File storage path unusable")
2797

    
2798
cvEnodehooks :: (String, String, String)
2799
cvEnodehooks =
2800
  ("node",
2801
   Types.cVErrorCodeToRaw CvENODEHOOKS,
2802
   "Communication failure in hooks execution")
2803

    
2804
cvEnodehv :: (String, String, String)
2805
cvEnodehv =
2806
  ("node",
2807
   Types.cVErrorCodeToRaw CvENODEHV,
2808
   "Hypervisor parameters verification failure")
2809

    
2810
cvEnodelvm :: (String, String, String)
2811
cvEnodelvm =
2812
  ("node",
2813
   Types.cVErrorCodeToRaw CvENODELVM,
2814
   "LVM-related node error")
2815

    
2816
cvEnoden1 :: (String, String, String)
2817
cvEnoden1 =
2818
  ("node",
2819
   Types.cVErrorCodeToRaw CvENODEN1,
2820
   "Not enough memory to accommodate instance failovers")
2821

    
2822
cvEnodenet :: (String, String, String)
2823
cvEnodenet =
2824
  ("node",
2825
   Types.cVErrorCodeToRaw CvENODENET,
2826
   "Network-related node error")
2827

    
2828
cvEnodeoobpath :: (String, String, String)
2829
cvEnodeoobpath =
2830
  ("node",
2831
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
2832
   "Invalid Out Of Band path")
2833

    
2834
cvEnodeorphaninstance :: (String, String, String)
2835
cvEnodeorphaninstance =
2836
  ("node",
2837
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
2838
   "Unknown intance running on a node")
2839

    
2840
cvEnodeorphanlv :: (String, String, String)
2841
cvEnodeorphanlv =
2842
  ("node",
2843
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
2844
   "Unknown LVM logical volume")
2845

    
2846
cvEnodeos :: (String, String, String)
2847
cvEnodeos =
2848
  ("node",
2849
   Types.cVErrorCodeToRaw CvENODEOS,
2850
   "OS-related node error")
2851

    
2852
cvEnoderpc :: (String, String, String)
2853
cvEnoderpc =
2854
  ("node",
2855
   Types.cVErrorCodeToRaw CvENODERPC,
2856
   "Error during connection to the primary node of an instance")
2857

    
2858
cvEnodesetup :: (String, String, String)
2859
cvEnodesetup =
2860
  ("node",
2861
   Types.cVErrorCodeToRaw CvENODESETUP,
2862
   "Node setup error")
2863

    
2864
cvEnodesharedfilestoragepathunusable :: (String, String, String)
2865
cvEnodesharedfilestoragepathunusable =
2866
  ("node",
2867
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
2868
   "Shared file storage path unusable")
2869

    
2870
cvEnodessh :: (String, String, String)
2871
cvEnodessh =
2872
  ("node",
2873
   Types.cVErrorCodeToRaw CvENODESSH,
2874
   "SSH-related node error")
2875

    
2876
cvEnodetime :: (String, String, String)
2877
cvEnodetime =
2878
  ("node",
2879
   Types.cVErrorCodeToRaw CvENODETIME,
2880
   "Node returned invalid time")
2881

    
2882
cvEnodeuserscripts :: (String, String, String)
2883
cvEnodeuserscripts =
2884
  ("node",
2885
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
2886
   "User scripts not present or not executable")
2887

    
2888
cvEnodeversion :: (String, String, String)
2889
cvEnodeversion =
2890
  ("node",
2891
   Types.cVErrorCodeToRaw CvENODEVERSION,
2892
   "Protocol version mismatch or Ganeti version mismatch")
2893

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

    
2936
cvAllEcodesStrings :: FrozenSet String
2937
cvAllEcodesStrings =
2938
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
2939

    
2940
-- * Node verify constants
2941

    
2942
nvBridges :: String
2943
nvBridges = "bridges"
2944

    
2945
nvDrbdhelper :: String
2946
nvDrbdhelper = "drbd-helper"
2947

    
2948
nvDrbdversion :: String
2949
nvDrbdversion = "drbd-version"
2950

    
2951
nvDrbdlist :: String
2952
nvDrbdlist = "drbd-list"
2953

    
2954
nvExclusivepvs :: String
2955
nvExclusivepvs = "exclusive-pvs"
2956

    
2957
nvFilelist :: String
2958
nvFilelist = "filelist"
2959

    
2960
nvAcceptedStoragePaths :: String
2961
nvAcceptedStoragePaths = "allowed-file-storage-paths"
2962

    
2963
nvFileStoragePath :: String
2964
nvFileStoragePath = "file-storage-path"
2965

    
2966
nvSharedFileStoragePath :: String
2967
nvSharedFileStoragePath = "shared-file-storage-path"
2968

    
2969
nvHvinfo :: String
2970
nvHvinfo = "hvinfo"
2971

    
2972
nvHvparams :: String
2973
nvHvparams = "hvparms"
2974

    
2975
nvHypervisor :: String
2976
nvHypervisor = "hypervisor"
2977

    
2978
nvInstancelist :: String
2979
nvInstancelist = "instancelist"
2980

    
2981
nvLvlist :: String
2982
nvLvlist = "lvlist"
2983

    
2984
nvMasterip :: String
2985
nvMasterip = "master-ip"
2986

    
2987
nvNodelist :: String
2988
nvNodelist = "nodelist"
2989

    
2990
nvNodenettest :: String
2991
nvNodenettest = "node-net-test"
2992

    
2993
nvNodesetup :: String
2994
nvNodesetup = "nodesetup"
2995

    
2996
nvOobPaths :: String
2997
nvOobPaths = "oob-paths"
2998

    
2999
nvOslist :: String
3000
nvOslist = "oslist"
3001

    
3002
nvPvlist :: String
3003
nvPvlist = "pvlist"
3004

    
3005
nvTime :: String
3006
nvTime = "time"
3007

    
3008
nvUserscripts :: String
3009
nvUserscripts = "user-scripts"
3010

    
3011
nvVersion :: String
3012
nvVersion = "version"
3013

    
3014
nvVglist :: String
3015
nvVglist = "vglist"
3016

    
3017
nvVmnodes :: String
3018
nvVmnodes = "vmnodes"
3019

    
3020
-- * Instance status
3021

    
3022
inststAdmindown :: String
3023
inststAdmindown = Types.instanceStatusToRaw StatusDown
3024

    
3025
inststAdminoffline :: String
3026
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
3027

    
3028
inststErrordown :: String
3029
inststErrordown = Types.instanceStatusToRaw ErrorDown
3030

    
3031
inststErrorup :: String
3032
inststErrorup = Types.instanceStatusToRaw ErrorUp
3033

    
3034
inststNodedown :: String
3035
inststNodedown = Types.instanceStatusToRaw NodeDown
3036

    
3037
inststNodeoffline :: String
3038
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
3039

    
3040
inststRunning :: String
3041
inststRunning = Types.instanceStatusToRaw Running
3042

    
3043
inststUserdown :: String
3044
inststUserdown = Types.instanceStatusToRaw UserDown
3045

    
3046
inststWrongnode :: String
3047
inststWrongnode = Types.instanceStatusToRaw WrongNode
3048

    
3049
inststAll :: FrozenSet String
3050
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
3051

    
3052
-- * Admin states
3053

    
3054
adminstDown :: String
3055
adminstDown = Types.adminStateToRaw AdminDown
3056

    
3057
adminstOffline :: String
3058
adminstOffline = Types.adminStateToRaw AdminOffline
3059

    
3060
adminstUp :: String
3061
adminstUp = Types.adminStateToRaw AdminUp
3062

    
3063
adminstAll :: FrozenSet String
3064
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
3065

    
3066
-- * Node roles
3067

    
3068
nrDrained :: String
3069
nrDrained = Types.nodeRoleToRaw NRDrained
3070

    
3071
nrMaster :: String
3072
nrMaster = Types.nodeRoleToRaw NRMaster
3073

    
3074
nrMcandidate :: String
3075
nrMcandidate = Types.nodeRoleToRaw NRCandidate
3076

    
3077
nrOffline :: String
3078
nrOffline = Types.nodeRoleToRaw NROffline
3079

    
3080
nrRegular :: String
3081
nrRegular = Types.nodeRoleToRaw NRRegular
3082

    
3083
nrAll :: FrozenSet String
3084
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
3085

    
3086
-- * SSL certificate check constants (in days)
3087

    
3088
sslCertExpirationError :: Int
3089
sslCertExpirationError = 7
3090

    
3091
sslCertExpirationWarn :: Int
3092
sslCertExpirationWarn = 30
3093

    
3094
-- * Allocator framework constants
3095

    
3096
iallocatorVersion :: Int
3097
iallocatorVersion = 2
3098

    
3099
iallocatorDirIn :: String
3100
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
3101

    
3102
iallocatorDirOut :: String
3103
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
3104

    
3105
validIallocatorDirections :: FrozenSet String
3106
validIallocatorDirections =
3107
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
3108

    
3109
iallocatorModeAlloc :: String
3110
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
3111

    
3112
iallocatorModeChgGroup :: String
3113
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
3114

    
3115
iallocatorModeMultiAlloc :: String
3116
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
3117

    
3118
iallocatorModeNodeEvac :: String
3119
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
3120

    
3121
iallocatorModeReloc :: String
3122
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
3123

    
3124
validIallocatorModes :: FrozenSet String
3125
validIallocatorModes =
3126
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
3127

    
3128
iallocatorSearchPath :: [String]
3129
iallocatorSearchPath = AutoConf.iallocatorSearchPath
3130

    
3131
defaultIallocatorShortcut :: String
3132
defaultIallocatorShortcut = "."
3133

    
3134
-- * Node evacuation
3135

    
3136
nodeEvacPri :: String
3137
nodeEvacPri = Types.evacModeToRaw ChangePrimary
3138

    
3139
nodeEvacSec :: String
3140
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
3141

    
3142
nodeEvacAll :: String
3143
nodeEvacAll = Types.evacModeToRaw ChangeAll
3144

    
3145
nodeEvacModes :: FrozenSet String
3146
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
3147

    
3148
-- * Job queue
3149

    
3150
jobQueueVersion :: Int
3151
jobQueueVersion = 1
3152

    
3153
jobQueueSizeHardLimit :: Int
3154
jobQueueSizeHardLimit = 5000
3155

    
3156
jobQueueFilesPerms :: Int
3157
jobQueueFilesPerms = 0o640
3158

    
3159
-- * Unchanged job return
3160

    
3161
jobNotchanged :: String
3162
jobNotchanged = "nochange"
3163

    
3164
-- * Job status
3165

    
3166
jobStatusQueued :: String
3167
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
3168

    
3169
jobStatusWaiting :: String
3170
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
3171

    
3172
jobStatusCanceling :: String
3173
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
3174

    
3175
jobStatusRunning :: String
3176
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
3177

    
3178
jobStatusCanceled :: String
3179
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
3180

    
3181
jobStatusSuccess :: String
3182
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
3183

    
3184
jobStatusError :: String
3185
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
3186

    
3187
jobsPending :: FrozenSet String
3188
jobsPending =
3189
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
3190

    
3191
jobsFinalized :: FrozenSet String
3192
jobsFinalized =
3193
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
3194

    
3195
jobStatusAll :: FrozenSet String
3196
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
3197

    
3198
-- * OpCode status
3199

    
3200
-- ** Not yet finalized opcodes
3201

    
3202
opStatusCanceling :: String
3203
opStatusCanceling = "canceling"
3204

    
3205
opStatusQueued :: String
3206
opStatusQueued = "queued"
3207

    
3208
opStatusRunning :: String
3209
opStatusRunning = "running"
3210

    
3211
opStatusWaiting :: String
3212
opStatusWaiting = "waiting"
3213

    
3214
-- ** Finalized opcodes
3215

    
3216
opStatusCanceled :: String
3217
opStatusCanceled = "canceled"
3218

    
3219
opStatusError :: String
3220
opStatusError = "error"
3221

    
3222
opStatusSuccess :: String
3223
opStatusSuccess = "success"
3224

    
3225
opsFinalized :: FrozenSet String
3226
opsFinalized =
3227
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
3228

    
3229
-- * OpCode priority
3230

    
3231
opPrioLowest :: Int
3232
opPrioLowest = 19
3233

    
3234
opPrioHighest :: Int
3235
opPrioHighest = -20
3236

    
3237
opPrioLow :: Int
3238
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
3239

    
3240
opPrioNormal :: Int
3241
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
3242

    
3243
opPrioHigh :: Int
3244
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
3245

    
3246
opPrioSubmitValid :: FrozenSet Int
3247
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
3248

    
3249
opPrioDefault :: Int
3250
opPrioDefault = opPrioNormal
3251

    
3252
-- * Lock recalculate mode
3253

    
3254
locksAppend :: String
3255
locksAppend = "append"
3256

    
3257
locksReplace :: String
3258
locksReplace = "replace"
3259

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

    
3267
lockAttemptsMaxwait :: Double
3268
lockAttemptsMaxwait = 15.0
3269

    
3270
lockAttemptsMinwait :: Double
3271
lockAttemptsMinwait = 1.0
3272

    
3273
lockAttemptsTimeout :: Int
3274
lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
3275

    
3276
-- * Execution log types
3277

    
3278
elogMessage :: String
3279
elogMessage = Types.eLogTypeToRaw ELogMessage
3280

    
3281
elogRemoteImport :: String
3282
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
3283

    
3284
elogJqueueTest :: String
3285
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
3286

    
3287
-- * /etc/hosts modification
3288

    
3289
etcHostsAdd :: String
3290
etcHostsAdd = "add"
3291

    
3292
etcHostsRemove :: String
3293
etcHostsRemove = "remove"
3294

    
3295
-- * Job queue test
3296

    
3297
jqtMsgprefix :: String
3298
jqtMsgprefix = "TESTMSG="
3299

    
3300
jqtExec :: String
3301
jqtExec = "exec"
3302

    
3303
jqtExpandnames :: String
3304
jqtExpandnames = "expandnames"
3305

    
3306
jqtLogmsg :: String
3307
jqtLogmsg = "logmsg"
3308

    
3309
jqtStartmsg :: String
3310
jqtStartmsg = "startmsg"
3311

    
3312
jqtAll :: FrozenSet String
3313
jqtAll = ConstantUtils.mkSet [jqtExec, jqtExpandnames, jqtLogmsg, jqtStartmsg]
3314

    
3315
-- * Query resources
3316

    
3317
qrCluster :: String
3318
qrCluster = "cluster"
3319

    
3320
qrExport :: String
3321
qrExport = "export"
3322

    
3323
qrExtstorage :: String
3324
qrExtstorage = "extstorage"
3325

    
3326
qrGroup :: String
3327
qrGroup = "group"
3328

    
3329
qrInstance :: String
3330
qrInstance = "instance"
3331

    
3332
qrJob :: String
3333
qrJob = "job"
3334

    
3335
qrLock :: String
3336
qrLock = "lock"
3337

    
3338
qrNetwork :: String
3339
qrNetwork = "network"
3340

    
3341
qrNode :: String
3342
qrNode = "node"
3343

    
3344
qrOs :: String
3345
qrOs = "os"
3346

    
3347
-- | List of resources which can be queried using 'Ganeti.OpCodes.OpQuery'
3348
qrViaOp :: FrozenSet String
3349
qrViaOp =
3350
  ConstantUtils.mkSet [qrCluster,
3351
                       qrOs,
3352
                       qrExtstorage]
3353

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

    
3364
-- | List of resources which can be queried using RAPI
3365
qrViaRapi :: FrozenSet String
3366
qrViaRapi = qrViaLuxi
3367

    
3368
-- | List of resources which can be queried via RAPI including PUT requests
3369
qrViaRapiPut :: FrozenSet String
3370
qrViaRapiPut = ConstantUtils.mkSet [qrLock, qrJob]
3371

    
3372
-- * Query field types
3373

    
3374
qftBool :: String
3375
qftBool = "bool"
3376

    
3377
qftNumber :: String
3378
qftNumber = "number"
3379

    
3380
qftOther :: String
3381
qftOther = "other"
3382

    
3383
qftText :: String
3384
qftText = "text"
3385

    
3386
qftTimestamp :: String
3387
qftTimestamp = "timestamp"
3388

    
3389
qftUnit :: String
3390
qftUnit = "unit"
3391

    
3392
qftUnknown :: String
3393
qftUnknown = "unknown"
3394

    
3395
qftAll :: FrozenSet String
3396
qftAll =
3397
  ConstantUtils.mkSet [qftBool,
3398
                       qftNumber,
3399
                       qftOther,
3400
                       qftText,
3401
                       qftTimestamp,
3402
                       qftUnit,
3403
                       qftUnknown]
3404

    
3405
-- * Query result field status
3406
--
3407
-- Don't change or reuse values as they're used by clients.
3408
--
3409
-- FIXME: link with 'Ganeti.Query.Language.ResultStatus'
3410

    
3411
-- | No data (e.g. RPC error), can be used instead of 'rsOffline'
3412
rsNodata :: Int
3413
rsNodata = 2
3414

    
3415
rsNormal :: Int
3416
rsNormal = 0
3417

    
3418
-- | Resource marked offline
3419
rsOffline :: Int
3420
rsOffline = 4
3421

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

    
3428
rsUnknown :: Int
3429
rsUnknown = 1
3430

    
3431
rsAll :: FrozenSet Int
3432
rsAll =
3433
  ConstantUtils.mkSet [rsNodata,
3434
                       rsNormal,
3435
                       rsOffline,
3436
                       rsUnavail,
3437
                       rsUnknown]
3438

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

    
3447
-- * Max dynamic devices
3448

    
3449
maxDisks :: Int
3450
maxDisks = Types.maxDisks
3451

    
3452
maxNics :: Int
3453
maxNics = Types.maxNics
3454

    
3455
-- | SSCONF file prefix
3456
ssconfFileprefix :: String
3457
ssconfFileprefix = "ssconf_"
3458

    
3459
-- * SSCONF keys
3460

    
3461
ssClusterName :: String
3462
ssClusterName = "cluster_name"
3463

    
3464
ssClusterTags :: String
3465
ssClusterTags = "cluster_tags"
3466

    
3467
ssFileStorageDir :: String
3468
ssFileStorageDir = "file_storage_dir"
3469

    
3470
ssSharedFileStorageDir :: String
3471
ssSharedFileStorageDir = "shared_file_storage_dir"
3472

    
3473
ssGlusterStorageDir :: String
3474
ssGlusterStorageDir = "gluster_storage_dir"
3475

    
3476
ssMasterCandidates :: String
3477
ssMasterCandidates = "master_candidates"
3478

    
3479
ssMasterCandidatesIps :: String
3480
ssMasterCandidatesIps = "master_candidates_ips"
3481

    
3482
ssMasterIp :: String
3483
ssMasterIp = "master_ip"
3484

    
3485
ssMasterNetdev :: String
3486
ssMasterNetdev = "master_netdev"
3487

    
3488
ssMasterNetmask :: String
3489
ssMasterNetmask = "master_netmask"
3490

    
3491
ssMasterNode :: String
3492
ssMasterNode = "master_node"
3493

    
3494
ssNodeList :: String
3495
ssNodeList = "node_list"
3496

    
3497
ssNodePrimaryIps :: String
3498
ssNodePrimaryIps = "node_primary_ips"
3499

    
3500
ssNodeSecondaryIps :: String
3501
ssNodeSecondaryIps = "node_secondary_ips"
3502

    
3503
ssOfflineNodes :: String
3504
ssOfflineNodes = "offline_nodes"
3505

    
3506
ssOnlineNodes :: String
3507
ssOnlineNodes = "online_nodes"
3508

    
3509
ssPrimaryIpFamily :: String
3510
ssPrimaryIpFamily = "primary_ip_family"
3511

    
3512
ssInstanceList :: String
3513
ssInstanceList = "instance_list"
3514

    
3515
ssReleaseVersion :: String
3516
ssReleaseVersion = "release_version"
3517

    
3518
ssHypervisorList :: String
3519
ssHypervisorList = "hypervisor_list"
3520

    
3521
ssMaintainNodeHealth :: String
3522
ssMaintainNodeHealth = "maintain_node_health"
3523

    
3524
ssUidPool :: String
3525
ssUidPool = "uid_pool"
3526

    
3527
ssNodegroups :: String
3528
ssNodegroups = "nodegroups"
3529

    
3530
ssNetworks :: String
3531
ssNetworks = "networks"
3532

    
3533
-- | This is not a complete SSCONF key, but the prefix for the
3534
-- hypervisor keys
3535
ssHvparamsPref :: String
3536
ssHvparamsPref = "hvparams_"
3537

    
3538
-- * Hvparams keys
3539

    
3540
ssHvparamsXenChroot :: String
3541
ssHvparamsXenChroot = ssHvparamsPref ++ htChroot
3542

    
3543
ssHvparamsXenFake :: String
3544
ssHvparamsXenFake = ssHvparamsPref ++ htFake
3545

    
3546
ssHvparamsXenHvm :: String
3547
ssHvparamsXenHvm = ssHvparamsPref ++ htXenHvm
3548

    
3549
ssHvparamsXenKvm :: String
3550
ssHvparamsXenKvm = ssHvparamsPref ++ htKvm
3551

    
3552
ssHvparamsXenLxc :: String
3553
ssHvparamsXenLxc = ssHvparamsPref ++ htLxc
3554

    
3555
ssHvparamsXenPvm :: String
3556
ssHvparamsXenPvm = ssHvparamsPref ++ htXenPvm
3557

    
3558
validSsHvparamsKeys :: FrozenSet String
3559
validSsHvparamsKeys =
3560
  ConstantUtils.mkSet [ssHvparamsXenChroot,
3561
                       ssHvparamsXenLxc,
3562
                       ssHvparamsXenFake,
3563
                       ssHvparamsXenHvm,
3564
                       ssHvparamsXenKvm,
3565
                       ssHvparamsXenPvm]
3566

    
3567
ssFilePerms :: Int
3568
ssFilePerms = 0o444
3569

    
3570
-- | Cluster wide default parameters
3571
defaultEnabledHypervisor :: String
3572
defaultEnabledHypervisor = htXenPvm
3573

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

    
3686
hvcGlobals :: FrozenSet String
3687
hvcGlobals =
3688
  ConstantUtils.mkSet [hvMigrationBandwidth,
3689
                       hvMigrationMode,
3690
                       hvMigrationPort,
3691
                       hvXenCmd]
3692

    
3693
becDefaults :: Map String PyValueEx
3694
becDefaults =
3695
  Map.fromList
3696
  [ (beMinmem, PyValueEx (128 :: Int))
3697
  , (beMaxmem, PyValueEx (128 :: Int))
3698
  , (beVcpus, PyValueEx (1 :: Int))
3699
  , (beAutoBalance, PyValueEx True)
3700
  , (beAlwaysFailover, PyValueEx False)
3701
  , (beSpindleUse, PyValueEx (1 :: Int))
3702
  ]
3703

    
3704
ndcDefaults :: Map String PyValueEx
3705
ndcDefaults =
3706
  Map.fromList
3707
  [ (ndOobProgram,       PyValueEx "")
3708
  , (ndSpindleCount,     PyValueEx (1 :: Int))
3709
  , (ndExclusiveStorage, PyValueEx False)
3710
  , (ndOvs,              PyValueEx False)
3711
  , (ndOvsName,          PyValueEx defaultOvs)
3712
  , (ndOvsLink,          PyValueEx "")
3713
  , (ndSshPort,          PyValueEx (22 :: Int))
3714
  ]
3715

    
3716
ndcGlobals :: FrozenSet String
3717
ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
3718

    
3719
-- | Default delay target measured in sectors
3720
defaultDelayTarget :: Int
3721
defaultDelayTarget = 1
3722

    
3723
defaultDiskCustom :: String
3724
defaultDiskCustom = ""
3725

    
3726
defaultDiskResync :: Bool
3727
defaultDiskResync = False
3728

    
3729
-- | Default fill target measured in sectors
3730
defaultFillTarget :: Int
3731
defaultFillTarget = 0
3732

    
3733
-- | Default mininum rate measured in KiB/s
3734
defaultMinRate :: Int
3735
defaultMinRate = 4 * 1024
3736

    
3737
defaultNetCustom :: String
3738
defaultNetCustom = ""
3739

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

    
3750
defaultRbdPool :: String
3751
defaultRbdPool = "rbd"
3752

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

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

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

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

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

    
3873
masterPoolSizeDefault :: Int
3874
masterPoolSizeDefault = 10
3875

    
3876
-- * Exclusive storage
3877

    
3878
-- | Error margin used to compare physical disks
3879
partMargin :: Double
3880
partMargin = 0.01
3881

    
3882
-- | Space reserved when creating instance disks
3883
partReserved :: Double
3884
partReserved = 0.02
3885

    
3886
-- * Luxid job scheduling
3887

    
3888
-- | Time intervall in seconds for polling updates on the job queue. This
3889
-- intervall is only relevant if the number of running jobs reaches the maximal
3890
-- allowed number, as otherwise new jobs will be started immediately anyway.
3891
luxidJobqueuePollInterval :: Int
3892
luxidJobqueuePollInterval = 3
3893

    
3894
-- | Maximal number of jobs to be running at the same time. Once this number is
3895
-- reached, new jobs will just be queued and only started, once some of the
3896
-- other jobs have finished.
3897
luxidMaximalRunningJobs :: Int
3898
luxidMaximalRunningJobs = 20
3899

    
3900
-- * Confd
3901

    
3902
confdProtocolVersion :: Int
3903
confdProtocolVersion = ConstantUtils.confdProtocolVersion
3904

    
3905
-- Confd request type
3906

    
3907
confdReqPing :: Int
3908
confdReqPing = Types.confdRequestTypeToRaw ReqPing
3909

    
3910
confdReqNodeRoleByname :: Int
3911
confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
3912

    
3913
confdReqNodePipByInstanceIp :: Int
3914
confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
3915

    
3916
confdReqClusterMaster :: Int
3917
confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
3918

    
3919
confdReqNodePipList :: Int
3920
confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
3921

    
3922
confdReqMcPipList :: Int
3923
confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
3924

    
3925
confdReqInstancesIpsList :: Int
3926
confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
3927

    
3928
confdReqNodeDrbd :: Int
3929
confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
3930

    
3931
confdReqNodeInstances :: Int
3932
confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
3933

    
3934
confdReqs :: FrozenSet Int
3935
confdReqs =
3936
  ConstantUtils.mkSet .
3937
  map Types.confdRequestTypeToRaw $
3938
  [minBound..] \\ [ReqNodeInstances]
3939

    
3940
-- * Confd request type
3941

    
3942
confdReqfieldName :: Int
3943
confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
3944

    
3945
confdReqfieldIp :: Int
3946
confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
3947

    
3948
confdReqfieldMnodePip :: Int
3949
confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
3950

    
3951
-- * Confd repl status
3952

    
3953
confdReplStatusOk :: Int
3954
confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
3955

    
3956
confdReplStatusError :: Int
3957
confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
3958

    
3959
confdReplStatusNotimplemented :: Int
3960
confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
3961

    
3962
confdReplStatuses :: FrozenSet Int
3963
confdReplStatuses =
3964
  ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
3965

    
3966
-- * Confd node role
3967

    
3968
confdNodeRoleMaster :: Int
3969
confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
3970

    
3971
confdNodeRoleCandidate :: Int
3972
confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
3973

    
3974
confdNodeRoleOffline :: Int
3975
confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
3976

    
3977
confdNodeRoleDrained :: Int
3978
confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
3979

    
3980
confdNodeRoleRegular :: Int
3981
confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
3982

    
3983
-- * A few common errors for confd
3984

    
3985
confdErrorUnknownEntry :: Int
3986
confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
3987

    
3988
confdErrorInternal :: Int
3989
confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
3990

    
3991
confdErrorArgument :: Int
3992
confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
3993

    
3994
-- * Confd request query fields
3995

    
3996
confdReqqLink :: String
3997
confdReqqLink = ConstantUtils.confdReqqLink
3998

    
3999
confdReqqIp :: String
4000
confdReqqIp = ConstantUtils.confdReqqIp
4001

    
4002
confdReqqIplist :: String
4003
confdReqqIplist = ConstantUtils.confdReqqIplist
4004

    
4005
confdReqqFields :: String
4006
confdReqqFields = ConstantUtils.confdReqqFields
4007

    
4008
-- | Each request is "salted" by the current timestamp.
4009
--
4010
-- This constant decides how many seconds of skew to accept.
4011
--
4012
-- TODO: make this a default and allow the value to be more
4013
-- configurable
4014
confdMaxClockSkew :: Int
4015
confdMaxClockSkew = 2 * nodeMaxClockSkew
4016

    
4017
-- | When we haven't reloaded the config for more than this amount of
4018
-- seconds, we force a test to see if inotify is betraying us. Using a
4019
-- prime number to ensure we get less chance of 'same wakeup' with
4020
-- other processes.
4021
confdConfigReloadTimeout :: Int
4022
confdConfigReloadTimeout = 17
4023

    
4024
-- | If we receive more than one update in this amount of
4025
-- microseconds, we move to polling every RATELIMIT seconds, rather
4026
-- than relying on inotify, to be able to serve more requests.
4027
confdConfigReloadRatelimit :: Int
4028
confdConfigReloadRatelimit = 250000
4029

    
4030
-- | Magic number prepended to all confd queries.
4031
--
4032
-- This allows us to distinguish different types of confd protocols
4033
-- and handle them. For example by changing this we can move the whole
4034
-- payload to be compressed, or move away from json.
4035
confdMagicFourcc :: String
4036
confdMagicFourcc = "plj0"
4037

    
4038
-- | By default a confd request is sent to the minimum between this
4039
-- number and all MCs. 6 was chosen because even in the case of a
4040
-- disastrous 50% response rate, we should have enough answers to be
4041
-- able to compare more than one.
4042
confdDefaultReqCoverage :: Int
4043
confdDefaultReqCoverage = 6
4044

    
4045
-- | Timeout in seconds to expire pending query request in the confd
4046
-- client library. We don't actually expect any answer more than 10
4047
-- seconds after we sent a request.
4048
confdClientExpireTimeout :: Int
4049
confdClientExpireTimeout = 10
4050

    
4051
-- | Maximum UDP datagram size.
4052
--
4053
-- On IPv4: 64K - 20 (ip header size) - 8 (udp header size) = 65507
4054
-- On IPv6: 64K - 40 (ip6 header size) - 8 (udp header size) = 65487
4055
--   (assuming we can't use jumbo frames)
4056
-- We just set this to 60K, which should be enough
4057
maxUdpDataSize :: Int
4058
maxUdpDataSize = 61440
4059

    
4060
-- * User-id pool minimum/maximum acceptable user-ids
4061

    
4062
uidpoolUidMin :: Int
4063
uidpoolUidMin = 0
4064

    
4065
-- | Assuming 32 bit user-ids
4066
uidpoolUidMax :: Integer
4067
uidpoolUidMax = 2 ^ 32 - 1
4068

    
4069
-- | Name or path of the pgrep command
4070
pgrep :: String
4071
pgrep = "pgrep"
4072

    
4073
-- | Name of the node group that gets created at cluster init or
4074
-- upgrade
4075
initialNodeGroupName :: String
4076
initialNodeGroupName = "default"
4077

    
4078
-- * Possible values for NodeGroup.alloc_policy
4079

    
4080
allocPolicyLastResort :: String
4081
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
4082

    
4083
allocPolicyPreferred :: String
4084
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
4085

    
4086
allocPolicyUnallocable :: String
4087
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
4088

    
4089
validAllocPolicies :: [String]
4090
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
4091

    
4092
-- | Temporary external/shared storage parameters
4093
blockdevDriverManual :: String
4094
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
4095

    
4096
-- | 'qemu-img' path, required for 'ovfconverter'
4097
qemuimgPath :: String
4098
qemuimgPath = AutoConf.qemuimgPath
4099

    
4100
-- | Whether htools was enabled at compilation time
4101
--
4102
-- FIXME: this should be moved next to the other enable constants,
4103
-- such as, 'enableConfd', and renamed to 'enableHtools'.
4104
htools :: Bool
4105
htools = AutoConf.htools
4106

    
4107
-- | The hail iallocator
4108
iallocHail :: String
4109
iallocHail = "hail"
4110

    
4111
-- * Fake opcodes for functions that have hooks attached to them via
4112
-- backend.RunLocalHooks
4113

    
4114
fakeOpMasterTurndown :: String
4115
fakeOpMasterTurndown = "OP_CLUSTER_IP_TURNDOWN"
4116

    
4117
fakeOpMasterTurnup :: String
4118
fakeOpMasterTurnup = "OP_CLUSTER_IP_TURNUP"
4119

    
4120
-- * SSH key types
4121

    
4122
sshkDsa :: String
4123
sshkDsa = "dsa"
4124

    
4125
sshkRsa :: String
4126
sshkRsa = "rsa"
4127

    
4128
sshkAll :: FrozenSet String
4129
sshkAll = ConstantUtils.mkSet [sshkRsa, sshkDsa]
4130

    
4131
-- * SSH authorized key types
4132

    
4133
sshakDss :: String
4134
sshakDss = "ssh-dss"
4135

    
4136
sshakRsa :: String
4137
sshakRsa = "ssh-rsa"
4138

    
4139
sshakAll :: FrozenSet String
4140
sshakAll = ConstantUtils.mkSet [sshakDss, sshakRsa]
4141

    
4142
-- * SSH setup
4143

    
4144
sshsClusterName :: String
4145
sshsClusterName = "cluster_name"
4146

    
4147
sshsSshHostKey :: String
4148
sshsSshHostKey = "ssh_host_key"
4149

    
4150
sshsSshRootKey :: String
4151
sshsSshRootKey = "ssh_root_key"
4152

    
4153
sshsNodeDaemonCertificate :: String
4154
sshsNodeDaemonCertificate = "node_daemon_certificate"
4155

    
4156
-- * Key files for SSH daemon
4157

    
4158
sshHostDsaPriv :: String
4159
sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
4160

    
4161
sshHostDsaPub :: String
4162
sshHostDsaPub = sshHostDsaPriv ++ ".pub"
4163

    
4164
sshHostRsaPriv :: String
4165
sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
4166

    
4167
sshHostRsaPub :: String
4168
sshHostRsaPub = sshHostRsaPriv ++ ".pub"
4169

    
4170
sshDaemonKeyfiles :: Map String (String, String)
4171
sshDaemonKeyfiles =
4172
  Map.fromList [ (sshkRsa, (sshHostRsaPriv, sshHostRsaPub))
4173
               , (sshkDsa, (sshHostDsaPriv, sshHostDsaPub))
4174
               ]
4175

    
4176
-- * Node daemon setup
4177

    
4178
ndsClusterName :: String
4179
ndsClusterName = "cluster_name"
4180

    
4181
ndsNodeDaemonCertificate :: String
4182
ndsNodeDaemonCertificate = "node_daemon_certificate"
4183

    
4184
ndsSsconf :: String
4185
ndsSsconf = "ssconf"
4186

    
4187
ndsStartNodeDaemon :: String
4188
ndsStartNodeDaemon = "start_node_daemon"
4189

    
4190
-- * The source reasons for the execution of an OpCode
4191

    
4192
opcodeReasonSrcClient :: String
4193
opcodeReasonSrcClient = "gnt:client"
4194

    
4195
opcodeReasonSrcNoded :: String
4196
opcodeReasonSrcNoded = "gnt:daemon:noded"
4197

    
4198
opcodeReasonSrcOpcode :: String
4199
opcodeReasonSrcOpcode = "gnt:opcode"
4200

    
4201
opcodeReasonSrcRlib2 :: String
4202
opcodeReasonSrcRlib2 = "gnt:library:rlib2"
4203

    
4204
opcodeReasonSrcUser :: String
4205
opcodeReasonSrcUser = "gnt:user"
4206

    
4207
opcodeReasonSources :: FrozenSet String
4208
opcodeReasonSources =
4209
  ConstantUtils.mkSet [opcodeReasonSrcClient,
4210
                       opcodeReasonSrcNoded,
4211
                       opcodeReasonSrcOpcode,
4212
                       opcodeReasonSrcRlib2,
4213
                       opcodeReasonSrcUser]
4214

    
4215
-- | Path generating random UUID
4216
randomUuidFile :: String
4217
randomUuidFile = ConstantUtils.randomUuidFile
4218

    
4219
-- * Auto-repair tag prefixes
4220

    
4221
autoRepairTagPrefix :: String
4222
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
4223

    
4224
autoRepairTagEnabled :: String
4225
autoRepairTagEnabled = autoRepairTagPrefix
4226

    
4227
autoRepairTagPending :: String
4228
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
4229

    
4230
autoRepairTagResult :: String
4231
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
4232

    
4233
autoRepairTagSuspended :: String
4234
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
4235

    
4236
-- * Auto-repair levels
4237

    
4238
autoRepairFailover :: String
4239
autoRepairFailover = Types.autoRepairTypeToRaw ArFailover
4240

    
4241
autoRepairFixStorage :: String
4242
autoRepairFixStorage = Types.autoRepairTypeToRaw ArFixStorage
4243

    
4244
autoRepairMigrate :: String
4245
autoRepairMigrate = Types.autoRepairTypeToRaw ArMigrate
4246

    
4247
autoRepairReinstall :: String
4248
autoRepairReinstall = Types.autoRepairTypeToRaw ArReinstall
4249

    
4250
autoRepairAllTypes :: FrozenSet String
4251
autoRepairAllTypes =
4252
  ConstantUtils.mkSet [autoRepairFailover,
4253
                       autoRepairFixStorage,
4254
                       autoRepairMigrate,
4255
                       autoRepairReinstall]
4256

    
4257
-- * Auto-repair results
4258

    
4259
autoRepairEnoperm :: String
4260
autoRepairEnoperm = Types.autoRepairResultToRaw ArEnoperm
4261

    
4262
autoRepairFailure :: String
4263
autoRepairFailure = Types.autoRepairResultToRaw ArFailure
4264

    
4265
autoRepairSuccess :: String
4266
autoRepairSuccess = Types.autoRepairResultToRaw ArSuccess
4267

    
4268
autoRepairAllResults :: FrozenSet String
4269
autoRepairAllResults =
4270
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
4271

    
4272
-- | The version identifier for builtin data collectors
4273
builtinDataCollectorVersion :: String
4274
builtinDataCollectorVersion = "B"
4275

    
4276
-- | The reason trail opcode parameter name
4277
opcodeReason :: String
4278
opcodeReason = "reason"
4279

    
4280
diskstatsFile :: String
4281
diskstatsFile = "/proc/diskstats"
4282

    
4283
-- *  CPU load collector
4284

    
4285
statFile :: String
4286
statFile = "/proc/stat"
4287

    
4288
cpuavgloadBufferSize :: Int
4289
cpuavgloadBufferSize = 150
4290

    
4291
cpuavgloadWindowSize :: Int
4292
cpuavgloadWindowSize = 600
4293

    
4294
-- * Monitoring daemon
4295

    
4296
-- | Mond's variable for periodical data collection
4297
mondTimeInterval :: Int
4298
mondTimeInterval = 5
4299

    
4300
-- | Mond's latest API version
4301
mondLatestApiVersion :: Int
4302
mondLatestApiVersion = 1
4303

    
4304
-- * Disk access modes
4305

    
4306
diskUserspace :: String
4307
diskUserspace = Types.diskAccessModeToRaw DiskUserspace
4308

    
4309
diskKernelspace :: String
4310
diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
4311

    
4312
diskValidAccessModes :: FrozenSet String
4313
diskValidAccessModes =
4314
  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
4315

    
4316
-- | Timeout for queue draining in upgrades
4317
upgradeQueueDrainTimeout :: Int
4318
upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
4319

    
4320
-- | Intervall at which the queue is polled during upgrades
4321
upgradeQueuePollInterval :: Int
4322
upgradeQueuePollInterval  = 10
4323

    
4324
-- * Hotplug Actions
4325

    
4326
hotplugActionAdd :: String
4327
hotplugActionAdd = Types.hotplugActionToRaw HAAdd
4328

    
4329
hotplugActionRemove :: String
4330
hotplugActionRemove = Types.hotplugActionToRaw HARemove
4331

    
4332
hotplugActionModify :: String
4333
hotplugActionModify = Types.hotplugActionToRaw HAMod
4334

    
4335
hotplugAllActions :: FrozenSet String
4336
hotplugAllActions =
4337
  ConstantUtils.mkSet $ map Types.hotplugActionToRaw [minBound..]
4338

    
4339
-- * Hotplug Device Targets
4340

    
4341
hotplugTargetNic :: String
4342
hotplugTargetNic = Types.hotplugTargetToRaw HTNic
4343

    
4344
hotplugTargetDisk :: String
4345
hotplugTargetDisk = Types.hotplugTargetToRaw HTDisk
4346

    
4347
hotplugAllTargets :: FrozenSet String
4348
hotplugAllTargets =
4349
  ConstantUtils.mkSet $ map Types.hotplugTargetToRaw [minBound..]
4350

    
4351
-- | Timeout for disk removal (seconds)
4352
diskRemoveRetryTimeout :: Int
4353
diskRemoveRetryTimeout = 30
4354

    
4355
-- | Interval between disk removal retries (seconds)
4356
diskRemoveRetryInterval :: Int
4357
diskRemoveRetryInterval  = 3
4358

    
4359
-- * UUID regex
4360

    
4361
uuidRegex :: String
4362
uuidRegex = "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
4363

    
4364
-- * Luxi constants
4365

    
4366
luxiKeyMethod :: String
4367
luxiKeyMethod = "method"
4368

    
4369
luxiKeyArgs :: String
4370
luxiKeyArgs = "args"
4371

    
4372
luxiKeySuccess :: String
4373
luxiKeySuccess = "success"
4374

    
4375
luxiKeyResult :: String
4376
luxiKeyResult = "result"
4377

    
4378
luxiKeyVersion :: String
4379
luxiKeyVersion = "version"
4380

    
4381
luxiReqSubmitJob :: String
4382
luxiReqSubmitJob = "SubmitJob"
4383

    
4384
luxiReqSubmitJobToDrainedQueue :: String
4385
luxiReqSubmitJobToDrainedQueue = "SubmitJobToDrainedQueue"
4386

    
4387
luxiReqSubmitManyJobs :: String
4388
luxiReqSubmitManyJobs = "SubmitManyJobs"
4389

    
4390
luxiReqWaitForJobChange :: String
4391
luxiReqWaitForJobChange = "WaitForJobChange"
4392

    
4393
luxiReqPickupJob :: String
4394
luxiReqPickupJob = "PickupJob"
4395

    
4396
luxiReqCancelJob :: String
4397
luxiReqCancelJob = "CancelJob"
4398

    
4399
luxiReqArchiveJob :: String
4400
luxiReqArchiveJob = "ArchiveJob"
4401

    
4402
luxiReqChangeJobPriority :: String
4403
luxiReqChangeJobPriority = "ChangeJobPriority"
4404

    
4405
luxiReqAutoArchiveJobs :: String
4406
luxiReqAutoArchiveJobs = "AutoArchiveJobs"
4407

    
4408
luxiReqQuery :: String
4409
luxiReqQuery = "Query"
4410

    
4411
luxiReqQueryFields :: String
4412
luxiReqQueryFields = "QueryFields"
4413

    
4414
luxiReqQueryJobs :: String
4415
luxiReqQueryJobs = "QueryJobs"
4416

    
4417
luxiReqQueryInstances :: String
4418
luxiReqQueryInstances = "QueryInstances"
4419

    
4420
luxiReqQueryNodes :: String
4421
luxiReqQueryNodes = "QueryNodes"
4422

    
4423
luxiReqQueryGroups :: String
4424
luxiReqQueryGroups = "QueryGroups"
4425

    
4426
luxiReqQueryNetworks :: String
4427
luxiReqQueryNetworks = "QueryNetworks"
4428

    
4429
luxiReqQueryExports :: String
4430
luxiReqQueryExports = "QueryExports"
4431

    
4432
luxiReqQueryConfigValues :: String
4433
luxiReqQueryConfigValues = "QueryConfigValues"
4434

    
4435
luxiReqQueryClusterInfo :: String
4436
luxiReqQueryClusterInfo = "QueryClusterInfo"
4437

    
4438
luxiReqQueryTags :: String
4439
luxiReqQueryTags = "QueryTags"
4440

    
4441
luxiReqSetDrainFlag :: String
4442
luxiReqSetDrainFlag = "SetDrainFlag"
4443

    
4444
luxiReqSetWatcherPause :: String
4445
luxiReqSetWatcherPause = "SetWatcherPause"
4446

    
4447
luxiReqAll :: FrozenSet String
4448
luxiReqAll =
4449
  ConstantUtils.mkSet
4450
  [ luxiReqArchiveJob
4451
  , luxiReqAutoArchiveJobs
4452
  , luxiReqCancelJob
4453
  , luxiReqChangeJobPriority
4454
  , luxiReqQuery
4455
  , luxiReqQueryClusterInfo
4456
  , luxiReqQueryConfigValues
4457
  , luxiReqQueryExports
4458
  , luxiReqQueryFields
4459
  , luxiReqQueryGroups
4460
  , luxiReqQueryInstances
4461
  , luxiReqQueryJobs
4462
  , luxiReqQueryNodes
4463
  , luxiReqQueryNetworks
4464
  , luxiReqQueryTags
4465
  , luxiReqSetDrainFlag
4466
  , luxiReqSetWatcherPause
4467
  , luxiReqSubmitJob
4468
  , luxiReqSubmitJobToDrainedQueue
4469
  , luxiReqSubmitManyJobs
4470
  , luxiReqWaitForJobChange
4471
  , luxiReqPickupJob
4472
  ]
4473

    
4474
luxiDefCtmo :: Int
4475
luxiDefCtmo = 10
4476

    
4477
luxiDefRwto :: Int
4478
luxiDefRwto = 60
4479

    
4480
-- | 'WaitForJobChange' timeout
4481
luxiWfjcTimeout :: Int
4482
luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
4483

    
4484
-- * Query language constants
4485

    
4486
-- ** Logic operators with one or more operands, each of which is a
4487
-- filter on its own
4488

    
4489
qlangOpAnd :: String
4490
qlangOpAnd = "&"
4491

    
4492
qlangOpOr :: String
4493
qlangOpOr = "|"
4494

    
4495
-- ** Unary operators with exactly one operand
4496

    
4497
qlangOpNot :: String
4498
qlangOpNot = "!"
4499

    
4500
qlangOpTrue :: String
4501
qlangOpTrue = "?"
4502

    
4503
-- ** Binary operators with exactly two operands, the field name and
4504
-- an operator-specific value
4505

    
4506
qlangOpContains :: String
4507
qlangOpContains = "=[]"
4508

    
4509
qlangOpEqual :: String
4510
qlangOpEqual = "="
4511

    
4512
qlangOpGe :: String
4513
qlangOpGe = ">="
4514

    
4515
qlangOpGt :: String
4516
qlangOpGt = ">"
4517

    
4518
qlangOpLe :: String
4519
qlangOpLe = "<="
4520

    
4521
qlangOpLt :: String
4522
qlangOpLt = "<"
4523

    
4524
qlangOpNotEqual :: String
4525
qlangOpNotEqual = "!="
4526

    
4527
qlangOpRegexp :: String
4528
qlangOpRegexp = "=~"
4529

    
4530
-- | Characters used for detecting user-written filters (see
4531
-- L{_CheckFilter})
4532

    
4533
qlangFilterDetectionChars :: FrozenSet String
4534
qlangFilterDetectionChars =
4535
  ConstantUtils.mkSet ["!", " ", "\"", "\'",
4536
                       ")", "(", "\x0b", "\n",
4537
                       "\r", "\x0c", "/", "<",
4538
                       "\t", ">", "=", "\\", "~"]
4539

    
4540
-- | Characters used to detect globbing filters
4541
qlangGlobDetectionChars :: FrozenSet String
4542
qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]
4543

    
4544
-- * Error related constants
4545
--
4546
-- 'OpPrereqError' failure types
4547

    
4548
-- | Environment error (e.g. node disk error)
4549
errorsEcodeEnviron :: String
4550
errorsEcodeEnviron = "environment_error"
4551

    
4552
-- | Entity already exists
4553
errorsEcodeExists :: String
4554
errorsEcodeExists = "already_exists"
4555

    
4556
-- | Internal cluster error
4557
errorsEcodeFault :: String
4558
errorsEcodeFault = "internal_error"
4559

    
4560
-- | Wrong arguments (at syntax level)
4561
errorsEcodeInval :: String
4562
errorsEcodeInval = "wrong_input"
4563

    
4564
-- | Entity not found
4565
errorsEcodeNoent :: String
4566
errorsEcodeNoent = "unknown_entity"
4567

    
4568
-- | Not enough resources (iallocator failure, disk space, memory, etc)
4569
errorsEcodeNores :: String
4570
errorsEcodeNores = "insufficient_resources"
4571

    
4572
-- | Resource not unique (e.g. MAC or IP duplication)
4573
errorsEcodeNotunique :: String
4574
errorsEcodeNotunique = "resource_not_unique"
4575

    
4576
-- | Resolver errors
4577
errorsEcodeResolver :: String
4578
errorsEcodeResolver = "resolver_error"
4579

    
4580
-- | Wrong entity state
4581
errorsEcodeState :: String
4582
errorsEcodeState = "wrong_state"
4583

    
4584
-- | Temporarily out of resources; operation can be tried again
4585
errorsEcodeTempNores :: String
4586
errorsEcodeTempNores = "temp_insufficient_resources"
4587

    
4588
errorsEcodeAll :: FrozenSet String
4589
errorsEcodeAll =
4590
  ConstantUtils.mkSet [ errorsEcodeNores
4591
                      , errorsEcodeExists
4592
                      , errorsEcodeState
4593
                      , errorsEcodeNotunique
4594
                      , errorsEcodeTempNores
4595
                      , errorsEcodeNoent
4596
                      , errorsEcodeFault
4597
                      , errorsEcodeResolver
4598
                      , errorsEcodeInval
4599
                      , errorsEcodeEnviron
4600
                      ]
4601

    
4602
-- * Jstore related constants
4603

    
4604
jstoreJobsPerArchiveDirectory :: Int
4605
jstoreJobsPerArchiveDirectory = 10000
4606

    
4607
-- * Gluster settings
4608

    
4609
-- | Name of the Gluster host setting
4610
glusterHost :: String
4611
glusterHost = "host"
4612

    
4613
-- | Default value of the Gluster host setting
4614
glusterHostDefault :: String
4615
glusterHostDefault = "127.0.0.1"
4616

    
4617
-- | Name of the Gluster volume setting
4618
glusterVolume :: String
4619
glusterVolume = "volume"
4620

    
4621
-- | Default value of the Gluster volume setting
4622
glusterVolumeDefault :: String
4623
glusterVolumeDefault = "gv0"
4624

    
4625
-- | Name of the Gluster port setting
4626
glusterPort :: String
4627
glusterPort = "port"
4628

    
4629
-- | Default value of the Gluster port setting
4630
glusterPortDefault :: Int
4631
glusterPortDefault = 24007