Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ 61e32567

History | View | Annotate | Download (31.2 kB)

1
{-| HsConstants contains the Haskell constants
2

    
3
This is a transitional module complementary to 'Ganeti.Constants'.  It
4
is intended to contain the Haskell constants that are meant to be
5
generated in 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.HsConstants where
38

    
39
import Data.Map (Map)
40
import qualified Data.Map as Map (fromList)
41

    
42
import AutoConf
43
import Ganeti.ConstantUtils (FrozenSet, Protocol(..))
44
import qualified Ganeti.ConstantUtils as ConstantUtils
45
import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..),
46
                       ExtraLogReason(..))
47
import Ganeti.Logging (SyslogUsage(..))
48
import qualified Ganeti.Logging as Logging (syslogUsageToRaw)
49
import qualified Ganeti.Runtime as Runtime
50
import Ganeti.Types
51
import qualified Ganeti.Types as Types
52

    
53
-- * Constants for 'lib/pathutils.py'
54

    
55
osSearchPath :: [String]
56
osSearchPath = AutoConf.osSearchPath
57

    
58
esSearchPath :: [String]
59
esSearchPath = AutoConf.esSearchPath
60

    
61
-- * User separation
62
daemonsGroup :: String
63
daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
64

    
65
adminGroup :: String
66
adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
67

    
68
masterdUser :: String
69
masterdUser = Runtime.daemonUser GanetiMasterd
70

    
71
masterdGroup :: String
72
masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
73

    
74
rapiUser :: String
75
rapiUser = Runtime.daemonUser GanetiRapi
76

    
77
rapiGroup :: String
78
rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
79

    
80
confdUser :: String
81
confdUser = Runtime.daemonUser GanetiConfd
82

    
83
confdGroup :: String
84
confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
85

    
86
luxidUser :: String
87
luxidUser = Runtime.daemonUser GanetiLuxid
88

    
89
luxidGroup :: String
90
luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
91

    
92
nodedUser :: String
93
nodedUser = Runtime.daemonUser GanetiNoded
94

    
95
nodedGroup :: String
96
nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
97

    
98
mondUser :: String
99
mondUser = Runtime.daemonUser GanetiMond
100

    
101
mondGroup :: String
102
mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
103

    
104
sshLoginUser :: String
105
sshLoginUser = AutoConf.sshLoginUser
106

    
107
sshConsoleUser :: String
108
sshConsoleUser = AutoConf.sshConsoleUser
109

    
110
-- * SSH constants
111

    
112
ssh :: String
113
ssh = "ssh"
114

    
115
scp :: String
116
scp = "scp"
117

    
118
-- * Daemons
119

    
120
confd :: String
121
confd = Runtime.daemonName GanetiConfd
122

    
123
masterd :: String
124
masterd = Runtime.daemonName GanetiMasterd
125

    
126
mond :: String
127
mond = Runtime.daemonName GanetiMond
128

    
129
noded :: String
130
noded = Runtime.daemonName GanetiNoded
131

    
132
luxid :: String
133
luxid = Runtime.daemonName GanetiLuxid
134

    
135
rapi :: String
136
rapi = Runtime.daemonName GanetiRapi
137

    
138
daemons :: FrozenSet String
139
daemons =
140
  ConstantUtils.mkSet [confd,
141
                       luxid,
142
                       masterd,
143
                       mond,
144
                       noded,
145
                       rapi]
146

    
147
defaultConfdPort :: Int
148
defaultConfdPort = 1814
149

    
150
defaultMondPort :: Int
151
defaultMondPort = 1815
152

    
153
defaultNodedPort :: Int
154
defaultNodedPort = 1811
155

    
156
defaultRapiPort :: Int
157
defaultRapiPort = 5080
158

    
159
daemonsPorts :: Map String (Protocol, Int)
160
daemonsPorts =
161
  Map.fromList [(confd, (Udp, defaultConfdPort)),
162
                (mond, (Tcp, defaultMondPort)),
163
                (noded, (Tcp, defaultNodedPort)),
164
                (rapi, (Tcp, defaultRapiPort)),
165
                (ssh, (Tcp, 22))]
166

    
167
daemonsLogbase :: Map String String
168
daemonsLogbase =
169
  Map.fromList
170
  [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
171

    
172
extraLogreasonAccess :: String
173
extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
174

    
175
extraLogreasonError :: String
176
extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
177

    
178
devConsole :: String
179
devConsole = ConstantUtils.devConsole
180

    
181
-- * Syslog
182

    
183
syslogUsage :: String
184
syslogUsage = AutoConf.syslogUsage
185

    
186
syslogNo :: String
187
syslogNo = Logging.syslogUsageToRaw SyslogNo
188

    
189
syslogYes :: String
190
syslogYes = Logging.syslogUsageToRaw SyslogYes
191

    
192
syslogOnly :: String
193
syslogOnly = Logging.syslogUsageToRaw SyslogOnly
194

    
195
syslogSocket :: String
196
syslogSocket = "/dev/log"
197

    
198
-- * Xen
199

    
200
xenBootloader :: String
201
xenBootloader = AutoConf.xenBootloader
202

    
203
xenCmdXl :: String
204
xenCmdXl = "xl"
205

    
206
xenCmdXm :: String
207
xenCmdXm = "xm"
208

    
209
xenInitrd :: String
210
xenInitrd = AutoConf.xenInitrd
211

    
212
xenKernel :: String
213
xenKernel = AutoConf.xenKernel
214

    
215
-- FIXME: perhaps rename to 'validXenCommands' for consistency with
216
-- other constants
217
knownXenCommands :: FrozenSet String
218
knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
219

    
220
-- * Storage types
221

    
222
stBlock :: String
223
stBlock = Types.storageTypeToRaw StorageBlock
224

    
225
stDiskless :: String
226
stDiskless = Types.storageTypeToRaw StorageDiskless
227

    
228
stExt :: String
229
stExt = Types.storageTypeToRaw StorageExt
230

    
231
stFile :: String
232
stFile = Types.storageTypeToRaw StorageFile
233

    
234
stLvmPv :: String
235
stLvmPv = Types.storageTypeToRaw StorageLvmPv
236

    
237
stLvmVg :: String
238
stLvmVg = Types.storageTypeToRaw StorageLvmVg
239

    
240
stRados :: String
241
stRados = Types.storageTypeToRaw StorageRados
242

    
243
storageTypes :: FrozenSet String
244
storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
245

    
246
-- * Storage fields
247
-- ** First two are valid in LU context only, not passed to backend
248

    
249
sfNode :: String
250
sfNode = "node"
251

    
252
sfType :: String
253
sfType = "type"
254

    
255
-- ** and the rest are valid in backend
256

    
257
sfAllocatable :: String
258
sfAllocatable = Types.storageFieldToRaw SFAllocatable
259

    
260
sfFree :: String
261
sfFree = Types.storageFieldToRaw SFFree
262

    
263
sfName :: String
264
sfName = Types.storageFieldToRaw SFName
265

    
266
sfSize :: String
267
sfSize = Types.storageFieldToRaw SFSize
268

    
269
sfUsed :: String
270
sfUsed = Types.storageFieldToRaw SFUsed
271

    
272
-- * Disk template types
273

    
274
dtDiskless :: String
275
dtDiskless = Types.diskTemplateToRaw DTDiskless
276

    
277
dtFile :: String
278
dtFile = Types.diskTemplateToRaw DTFile
279

    
280
dtSharedFile :: String
281
dtSharedFile = Types.diskTemplateToRaw DTSharedFile
282

    
283
dtPlain :: String
284
dtPlain = Types.diskTemplateToRaw DTPlain
285

    
286
dtBlock :: String
287
dtBlock = Types.diskTemplateToRaw DTBlock
288

    
289
dtDrbd8 :: String
290
dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
291

    
292
dtRbd :: String
293
dtRbd = Types.diskTemplateToRaw DTRbd
294

    
295
dtExt :: String
296
dtExt = Types.diskTemplateToRaw DTExt
297

    
298
-- | This is used to order determine the default disk template when
299
-- the list of enabled disk templates is inferred from the current
300
-- state of the cluster.  This only happens on an upgrade from a
301
-- version of Ganeti that did not support the 'enabled_disk_templates'
302
-- so far.
303
diskTemplatePreference :: [String]
304
diskTemplatePreference =
305
  map Types.diskTemplateToRaw
306
  [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile, DTPlain, DTRbd, DTSharedFile]
307

    
308
diskTemplates :: FrozenSet String
309
diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
310

    
311
-- | Disk templates that are enabled by default
312
defaultEnabledDiskTemplates :: [String]
313
defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
314

    
315
-- * File backend driver
316

    
317
fdBlktap :: String
318
fdBlktap = Types.fileDriverToRaw FileBlktap
319

    
320
fdLoop :: String
321
fdLoop = Types.fileDriverToRaw FileLoop
322

    
323
-- * Disk access mode
324

    
325
diskRdonly :: String
326
diskRdonly = Types.diskModeToRaw DiskRdOnly
327

    
328
diskRdwr :: String
329
diskRdwr = Types.diskModeToRaw DiskRdWr
330

    
331
diskAccessSet :: FrozenSet String
332
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
333

    
334
-- * Instance export mode
335

    
336
exportModeLocal :: String
337
exportModeLocal = Types.exportModeToRaw ExportModeLocal
338

    
339
exportModeRemote :: String
340
exportModeRemote = Types.exportModeToRaw ExportModeRemote
341

    
342
exportModes :: FrozenSet String
343
exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
344

    
345
-- * Instance creation modes
346

    
347
instanceCreate :: String
348
instanceCreate = Types.instCreateModeToRaw InstCreate
349

    
350
instanceImport :: String
351
instanceImport = Types.instCreateModeToRaw InstImport
352

    
353
instanceRemoteImport :: String
354
instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
355

    
356
instanceCreateModes :: FrozenSet String
357
instanceCreateModes =
358
  ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
359

    
360
-- * Dynamic device modification
361

    
362
ddmAdd :: String
363
ddmAdd = Types.ddmFullToRaw DdmFullAdd
364

    
365
ddmModify :: String
366
ddmModify = Types.ddmFullToRaw DdmFullModify
367

    
368
ddmRemove :: String
369
ddmRemove = Types.ddmFullToRaw DdmFullRemove
370

    
371
ddmsValues :: FrozenSet String
372
ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
373

    
374
ddmsValuesWithModify :: FrozenSet String
375
ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
376

    
377
-- * Common exit codes
378

    
379
exitSuccess :: Int
380
exitSuccess = 0
381

    
382
exitFailure :: Int
383
exitFailure = ConstantUtils.exitFailure
384

    
385
exitNotcluster :: Int
386
exitNotcluster = 5
387

    
388
exitNotmaster :: Int
389
exitNotmaster = 11
390

    
391
exitNodesetupError :: Int
392
exitNodesetupError = 12
393

    
394
-- | Need user confirmation
395
exitConfirmation :: Int
396
exitConfirmation = 13
397

    
398
-- | Exit code for query operations with unknown fields
399
exitUnknownField :: Int
400
exitUnknownField = 14
401

    
402
-- * Tags
403

    
404
tagCluster :: String
405
tagCluster = Types.tagKindToRaw TagKindCluster
406

    
407
tagInstance :: String
408
tagInstance = Types.tagKindToRaw TagKindInstance
409

    
410
tagNetwork :: String
411
tagNetwork = Types.tagKindToRaw TagKindNetwork
412

    
413
tagNode :: String
414
tagNode = Types.tagKindToRaw TagKindNode
415

    
416
tagNodegroup :: String
417
tagNodegroup = Types.tagKindToRaw TagKindGroup
418

    
419
validTagTypes :: FrozenSet String
420
validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
421

    
422
maxTagLen :: Int
423
maxTagLen = 128
424

    
425
maxTagsPerObj :: Int
426
maxTagsPerObj = 4096
427

    
428
-- | Node clock skew in seconds
429
nodeMaxClockSkew :: Int
430
nodeMaxClockSkew = 150
431

    
432
-- * Reboot types
433

    
434
instanceRebootSoft :: String
435
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
436

    
437
instanceRebootHard :: String
438
instanceRebootHard = Types.rebootTypeToRaw RebootHard
439

    
440
instanceRebootFull :: String
441
instanceRebootFull = Types.rebootTypeToRaw RebootFull
442

    
443
rebootTypes :: FrozenSet String
444
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
445

    
446
-- * VTypes
447

    
448
vtypeBool :: String
449
vtypeBool = Types.vTypeToRaw VTypeBool
450

    
451
vtypeInt :: String
452
vtypeInt = Types.vTypeToRaw VTypeInt
453

    
454
vtypeMaybeString :: String
455
vtypeMaybeString = Types.vTypeToRaw VTypeMaybeString
456

    
457
-- | Size in MiBs
458
vtypeSize :: String
459
vtypeSize = Types.vTypeToRaw VTypeSize
460

    
461
vtypeString :: String
462
vtypeString = Types.vTypeToRaw VTypeString
463

    
464
enforceableTypes :: FrozenSet String
465
enforceableTypes = ConstantUtils.mkSet $ map Types.vTypeToRaw [minBound..]
466

    
467
-- * OOB supported commands
468

    
469
oobPowerOn :: String
470
oobPowerOn = Types.oobCommandToRaw OobPowerOn
471

    
472
oobPowerOff :: String
473
oobPowerOff = Types.oobCommandToRaw OobPowerOff
474

    
475
oobPowerCycle :: String
476
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
477

    
478
oobPowerStatus :: String
479
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
480

    
481
oobHealth :: String
482
oobHealth = Types.oobCommandToRaw OobHealth
483

    
484
oobCommands :: FrozenSet String
485
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
486

    
487
oobPowerStatusPowered :: String
488
oobPowerStatusPowered = "powered"
489

    
490
-- | 60 seconds
491
oobTimeout :: Int
492
oobTimeout = 60
493

    
494
-- | 2 seconds
495
oobPowerDelay :: Double
496
oobPowerDelay = 2.0
497

    
498
oobStatusCritical :: String
499
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
500

    
501
oobStatusOk :: String
502
oobStatusOk = Types.oobStatusToRaw OobStatusOk
503

    
504
oobStatusUnknown :: String
505
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
506

    
507
oobStatusWarning :: String
508
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
509

    
510
oobStatuses :: FrozenSet String
511
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
512

    
513
-- * NIC_* constants are used inside the ganeti config
514

    
515
nicLink :: String
516
nicLink = "link"
517

    
518
nicMode :: String
519
nicMode = "mode"
520

    
521
nicVlan :: String
522
nicVlan = "vlan"
523

    
524
nicModeBridged :: String
525
nicModeBridged = Types.nICModeToRaw NMBridged
526

    
527
nicModeRouted :: String
528
nicModeRouted = Types.nICModeToRaw NMRouted
529

    
530
nicModeOvs :: String
531
nicModeOvs = Types.nICModeToRaw NMOvs
532

    
533
nicIpPool :: String
534
nicIpPool = Types.nICModeToRaw NMPool
535

    
536
nicValidModes :: FrozenSet String
537
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
538

    
539
-- * Hypervisor constants
540

    
541
htXenPvm :: String
542
htXenPvm = Types.hypervisorToRaw XenPvm
543

    
544
htFake :: String
545
htFake = Types.hypervisorToRaw Fake
546

    
547
htXenHvm :: String
548
htXenHvm = Types.hypervisorToRaw XenHvm
549

    
550
htKvm :: String
551
htKvm = Types.hypervisorToRaw Kvm
552

    
553
htChroot :: String
554
htChroot = Types.hypervisorToRaw Chroot
555

    
556
htLxc :: String
557
htLxc = Types.hypervisorToRaw Lxc
558

    
559
hyperTypes :: FrozenSet String
560
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
561

    
562
htsReqPort :: FrozenSet String
563
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
564

    
565
-- * Migration type
566

    
567
htMigrationLive :: String
568
htMigrationLive = Types.migrationModeToRaw MigrationLive
569

    
570
htMigrationNonlive :: String
571
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
572

    
573
htMigrationModes :: FrozenSet String
574
htMigrationModes =
575
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
576

    
577
-- * Cluster verify steps
578

    
579
verifyNplusoneMem :: String
580
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
581

    
582
verifyOptionalChecks :: FrozenSet String
583
verifyOptionalChecks =
584
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
585

    
586
-- * Cluster Verify error classes
587

    
588
cvTcluster :: String
589
cvTcluster = "cluster"
590

    
591
cvTgroup :: String
592
cvTgroup = "group"
593

    
594
cvTnode :: String
595
cvTnode = "node"
596

    
597
cvTinstance :: String
598
cvTinstance = "instance"
599

    
600
-- * Cluster Verify error codes and documentation
601

    
602
cvEclustercert :: (String, String, String)
603
cvEclustercert =
604
  ("cluster",
605
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
606
   "Cluster certificate files verification failure")
607

    
608
cvEclustercfg :: (String, String, String)
609
cvEclustercfg =
610
  ("cluster",
611
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
612
   "Cluster configuration verification failure")
613

    
614
cvEclusterdanglinginst :: (String, String, String)
615
cvEclusterdanglinginst =
616
  ("node",
617
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
618
   "Some instances have a non-existing primary node")
619

    
620
cvEclusterdanglingnodes :: (String, String, String)
621
cvEclusterdanglingnodes =
622
  ("node",
623
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
624
   "Some nodes belong to non-existing groups")
625

    
626
cvEclusterfilecheck :: (String, String, String)
627
cvEclusterfilecheck =
628
  ("cluster",
629
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
630
   "Cluster configuration verification failure")
631

    
632
cvEgroupdifferentpvsize :: (String, String, String)
633
cvEgroupdifferentpvsize =
634
  ("group",
635
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
636
   "PVs in the group have different sizes")
637

    
638
cvEinstancebadnode :: (String, String, String)
639
cvEinstancebadnode =
640
  ("instance",
641
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
642
   "Instance marked as running lives on an offline node")
643

    
644
cvEinstancedown :: (String, String, String)
645
cvEinstancedown =
646
  ("instance",
647
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
648
   "Instance not running on its primary node")
649

    
650
cvEinstancefaultydisk :: (String, String, String)
651
cvEinstancefaultydisk =
652
  ("instance",
653
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
654
   "Impossible to retrieve status for a disk")
655

    
656
cvEinstancelayout :: (String, String, String)
657
cvEinstancelayout =
658
  ("instance",
659
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
660
   "Instance has multiple secondary nodes")
661

    
662
cvEinstancemissingcfgparameter :: (String, String, String)
663
cvEinstancemissingcfgparameter =
664
  ("instance",
665
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
666
   "A configuration parameter for an instance is missing")
667

    
668
cvEinstancemissingdisk :: (String, String, String)
669
cvEinstancemissingdisk =
670
  ("instance",
671
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
672
   "Missing volume on an instance")
673

    
674
cvEinstancepolicy :: (String, String, String)
675
cvEinstancepolicy =
676
  ("instance",
677
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
678
   "Instance does not meet policy")
679

    
680
cvEinstancesplitgroups :: (String, String, String)
681
cvEinstancesplitgroups =
682
  ("instance",
683
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
684
   "Instance with primary and secondary nodes in different groups")
685

    
686
cvEinstanceunsuitablenode :: (String, String, String)
687
cvEinstanceunsuitablenode =
688
  ("instance",
689
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
690
   "Instance running on nodes that are not suitable for it")
691

    
692
cvEinstancewrongnode :: (String, String, String)
693
cvEinstancewrongnode =
694
  ("instance",
695
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
696
   "Instance running on the wrong node")
697

    
698
cvEnodedrbd :: (String, String, String)
699
cvEnodedrbd =
700
  ("node",
701
   Types.cVErrorCodeToRaw CvENODEDRBD,
702
   "Error parsing the DRBD status file")
703

    
704
cvEnodedrbdhelper :: (String, String, String)
705
cvEnodedrbdhelper =
706
  ("node",
707
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
708
   "Error caused by the DRBD helper")
709

    
710
cvEnodedrbdversion :: (String, String, String)
711
cvEnodedrbdversion =
712
  ("node",
713
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
714
   "DRBD version mismatch within a node group")
715

    
716
cvEnodefilecheck :: (String, String, String)
717
cvEnodefilecheck =
718
  ("node",
719
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
720
   "Error retrieving the checksum of the node files")
721

    
722
cvEnodefilestoragepaths :: (String, String, String)
723
cvEnodefilestoragepaths =
724
  ("node",
725
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
726
   "Detected bad file storage paths")
727

    
728
cvEnodefilestoragepathunusable :: (String, String, String)
729
cvEnodefilestoragepathunusable =
730
  ("node",
731
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
732
   "File storage path unusable")
733

    
734
cvEnodehooks :: (String, String, String)
735
cvEnodehooks =
736
  ("node",
737
   Types.cVErrorCodeToRaw CvENODEHOOKS,
738
   "Communication failure in hooks execution")
739

    
740
cvEnodehv :: (String, String, String)
741
cvEnodehv =
742
  ("node",
743
   Types.cVErrorCodeToRaw CvENODEHV,
744
   "Hypervisor parameters verification failure")
745

    
746
cvEnodelvm :: (String, String, String)
747
cvEnodelvm =
748
  ("node",
749
   Types.cVErrorCodeToRaw CvENODELVM,
750
   "LVM-related node error")
751

    
752
cvEnoden1 :: (String, String, String)
753
cvEnoden1 =
754
  ("node",
755
   Types.cVErrorCodeToRaw CvENODEN1,
756
   "Not enough memory to accommodate instance failovers")
757

    
758
cvEnodenet :: (String, String, String)
759
cvEnodenet =
760
  ("node",
761
   Types.cVErrorCodeToRaw CvENODENET,
762
   "Network-related node error")
763

    
764
cvEnodeoobpath :: (String, String, String)
765
cvEnodeoobpath =
766
  ("node",
767
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
768
   "Invalid Out Of Band path")
769

    
770
cvEnodeorphaninstance :: (String, String, String)
771
cvEnodeorphaninstance =
772
  ("node",
773
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
774
   "Unknown intance running on a node")
775

    
776
cvEnodeorphanlv :: (String, String, String)
777
cvEnodeorphanlv =
778
  ("node",
779
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
780
   "Unknown LVM logical volume")
781

    
782
cvEnodeos :: (String, String, String)
783
cvEnodeos =
784
  ("node",
785
   Types.cVErrorCodeToRaw CvENODEOS,
786
   "OS-related node error")
787

    
788
cvEnoderpc :: (String, String, String)
789
cvEnoderpc =
790
  ("node",
791
   Types.cVErrorCodeToRaw CvENODERPC,
792
   "Error during connection to the primary node of an instance")
793

    
794
cvEnodesetup :: (String, String, String)
795
cvEnodesetup =
796
  ("node",
797
   Types.cVErrorCodeToRaw CvENODESETUP,
798
   "Node setup error")
799

    
800
cvEnodesharedfilestoragepathunusable :: (String, String, String)
801
cvEnodesharedfilestoragepathunusable =
802
  ("node",
803
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
804
   "Shared file storage path unusable")
805

    
806
cvEnodessh :: (String, String, String)
807
cvEnodessh =
808
  ("node",
809
   Types.cVErrorCodeToRaw CvENODESSH,
810
   "SSH-related node error")
811

    
812
cvEnodetime :: (String, String, String)
813
cvEnodetime =
814
  ("node",
815
   Types.cVErrorCodeToRaw CvENODETIME,
816
   "Node returned invalid time")
817

    
818
cvEnodeuserscripts :: (String, String, String)
819
cvEnodeuserscripts =
820
  ("node",
821
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
822
   "User scripts not present or not executable")
823

    
824
cvEnodeversion :: (String, String, String)
825
cvEnodeversion =
826
  ("node",
827
   Types.cVErrorCodeToRaw CvENODEVERSION,
828
   "Protocol version mismatch or Ganeti version mismatch")
829

    
830
cvAllEcodes :: FrozenSet (String, String, String)
831
cvAllEcodes =
832
  ConstantUtils.mkSet
833
  [cvEclustercert,
834
   cvEclustercfg,
835
   cvEclusterdanglinginst,
836
   cvEclusterdanglingnodes,
837
   cvEclusterfilecheck,
838
   cvEgroupdifferentpvsize,
839
   cvEinstancebadnode,
840
   cvEinstancedown,
841
   cvEinstancefaultydisk,
842
   cvEinstancelayout,
843
   cvEinstancemissingcfgparameter,
844
   cvEinstancemissingdisk,
845
   cvEinstancepolicy,
846
   cvEinstancesplitgroups,
847
   cvEinstanceunsuitablenode,
848
   cvEinstancewrongnode,
849
   cvEnodedrbd,
850
   cvEnodedrbdhelper,
851
   cvEnodedrbdversion,
852
   cvEnodefilecheck,
853
   cvEnodefilestoragepaths,
854
   cvEnodefilestoragepathunusable,
855
   cvEnodehooks,
856
   cvEnodehv,
857
   cvEnodelvm,
858
   cvEnoden1,
859
   cvEnodenet,
860
   cvEnodeoobpath,
861
   cvEnodeorphaninstance,
862
   cvEnodeorphanlv,
863
   cvEnodeos,
864
   cvEnoderpc,
865
   cvEnodesetup,
866
   cvEnodesharedfilestoragepathunusable,
867
   cvEnodessh,
868
   cvEnodetime,
869
   cvEnodeuserscripts,
870
   cvEnodeversion]
871

    
872
cvAllEcodesStrings :: FrozenSet String
873
cvAllEcodesStrings =
874
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
875

    
876
-- * Instance status
877

    
878
inststAdmindown :: String
879
inststAdmindown = Types.instanceStatusToRaw StatusDown
880

    
881
inststAdminoffline :: String
882
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
883

    
884
inststErrordown :: String
885
inststErrordown = Types.instanceStatusToRaw ErrorDown
886

    
887
inststErrorup :: String
888
inststErrorup = Types.instanceStatusToRaw ErrorUp
889

    
890
inststNodedown :: String
891
inststNodedown = Types.instanceStatusToRaw NodeDown
892

    
893
inststNodeoffline :: String
894
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
895

    
896
inststRunning :: String
897
inststRunning = Types.instanceStatusToRaw Running
898

    
899
inststWrongnode :: String
900
inststWrongnode = Types.instanceStatusToRaw WrongNode
901

    
902
inststAll :: FrozenSet String
903
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
904

    
905
-- * Admin states
906

    
907
adminstDown :: String
908
adminstDown = Types.adminStateToRaw AdminDown
909

    
910
adminstOffline :: String
911
adminstOffline = Types.adminStateToRaw AdminOffline
912

    
913
adminstUp :: String
914
adminstUp = Types.adminStateToRaw AdminUp
915

    
916
adminstAll :: FrozenSet String
917
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
918

    
919
-- * Node roles
920

    
921
nrDrained :: String
922
nrDrained = Types.nodeRoleToRaw NRDrained
923

    
924
nrMaster :: String
925
nrMaster = Types.nodeRoleToRaw NRMaster
926

    
927
nrMcandidate :: String
928
nrMcandidate = Types.nodeRoleToRaw NRCandidate
929

    
930
nrOffline :: String
931
nrOffline = Types.nodeRoleToRaw NROffline
932

    
933
nrRegular :: String
934
nrRegular = Types.nodeRoleToRaw NRRegular
935

    
936
nrAll :: FrozenSet String
937
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
938

    
939
-- * Allocator framework constants
940

    
941
iallocatorVersion :: Int
942
iallocatorVersion = 2
943

    
944
iallocatorDirIn :: String
945
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
946

    
947
iallocatorDirOut :: String
948
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
949

    
950
validIallocatorDirections :: FrozenSet String
951
validIallocatorDirections =
952
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
953

    
954
iallocatorModeAlloc :: String
955
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
956

    
957
iallocatorModeChgGroup :: String
958
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
959

    
960
iallocatorModeMultiAlloc :: String
961
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
962

    
963
iallocatorModeNodeEvac :: String
964
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
965

    
966
iallocatorModeReloc :: String
967
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
968

    
969
validIallocatorModes :: FrozenSet String
970
validIallocatorModes =
971
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
972

    
973
iallocatorSearchPath :: [String]
974
iallocatorSearchPath = AutoConf.iallocatorSearchPath
975

    
976
defaultIallocatorShortcut :: String
977
defaultIallocatorShortcut = "."
978

    
979
iallocatorNevacPri :: String
980
iallocatorNevacPri = Types.nodeEvacModeToRaw NEvacPrimary
981

    
982
iallocatorNevacSec :: String
983
iallocatorNevacSec = Types.nodeEvacModeToRaw NEvacSecondary
984

    
985
iallocatorNevacAll :: String
986
iallocatorNevacAll = Types.nodeEvacModeToRaw NEvacAll
987

    
988
iallocatorNevacModes :: FrozenSet String
989
iallocatorNevacModes =
990
  ConstantUtils.mkSet $ map Types.nodeEvacModeToRaw [minBound..]
991

    
992
-- * Node evacuation
993

    
994
nodeEvacPri :: String
995
nodeEvacPri = Types.nodeEvacModeToRaw NEvacPrimary
996

    
997
nodeEvacSec :: String
998
nodeEvacSec = Types.nodeEvacModeToRaw NEvacSecondary
999

    
1000
nodeEvacAll :: String
1001
nodeEvacAll = Types.nodeEvacModeToRaw NEvacAll
1002

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

    
1006
-- * Job status
1007

    
1008
jobStatusQueued :: String
1009
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
1010

    
1011
jobStatusWaiting :: String
1012
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
1013

    
1014
jobStatusCanceling :: String
1015
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
1016

    
1017
jobStatusRunning :: String
1018
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
1019

    
1020
jobStatusCanceled :: String
1021
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
1022

    
1023
jobStatusSuccess :: String
1024
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
1025

    
1026
jobStatusError :: String
1027
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
1028

    
1029
jobsPending :: FrozenSet String
1030
jobsPending =
1031
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
1032

    
1033
jobsFinalized :: FrozenSet String
1034
jobsFinalized =
1035
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
1036

    
1037
jobStatusAll :: FrozenSet String
1038
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
1039

    
1040
-- * OpCode status
1041

    
1042
-- ** Not yet finalized opcodes
1043

    
1044
opStatusCanceling :: String
1045
opStatusCanceling = "canceling"
1046

    
1047
opStatusQueued :: String
1048
opStatusQueued = "queued"
1049

    
1050
opStatusRunning :: String
1051
opStatusRunning = "running"
1052

    
1053
opStatusWaiting :: String
1054
opStatusWaiting = "waiting"
1055

    
1056
-- ** Finalized opcodes
1057

    
1058
opStatusCanceled :: String
1059
opStatusCanceled = "canceled"
1060

    
1061
opStatusError :: String
1062
opStatusError = "error"
1063

    
1064
opStatusSuccess :: String
1065
opStatusSuccess = "success"
1066

    
1067
opsFinalized :: FrozenSet String
1068
opsFinalized =
1069
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
1070

    
1071
-- * OpCode priority
1072

    
1073
opPrioLowest :: Int
1074
opPrioLowest = 19
1075

    
1076
opPrioHighest :: Int
1077
opPrioHighest = -20
1078

    
1079
opPrioLow :: Int
1080
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
1081

    
1082
opPrioNormal :: Int
1083
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
1084

    
1085
opPrioHigh :: Int
1086
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
1087

    
1088
opPrioSubmitValid :: FrozenSet Int
1089
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
1090

    
1091
opPrioDefault :: Int
1092
opPrioDefault = opPrioNormal
1093

    
1094
-- * Execution log types
1095

    
1096
elogMessage :: String
1097
elogMessage = Types.eLogTypeToRaw ELogMessage
1098

    
1099
elogRemoteImport :: String
1100
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
1101

    
1102
elogJqueueTest :: String
1103
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
1104

    
1105
-- * A few common errors for confd
1106

    
1107
confdErrorArgument :: Int
1108
confdErrorArgument = 3
1109

    
1110
confdErrorInternal :: Int
1111
confdErrorInternal = 2
1112

    
1113
confdErrorUnknownEntry :: Int
1114
confdErrorUnknownEntry = 1
1115

    
1116
-- | Each request is "salted" by the current timestamp.
1117
--
1118
-- This constant decides how many seconds of skew to accept.
1119
--
1120
-- TODO: make this a default and allow the value to be more
1121
-- configurable
1122
confdMaxClockSkew :: Int
1123
confdMaxClockSkew = 2 * nodeMaxClockSkew
1124

    
1125
-- | When we haven't reloaded the config for more than this amount of
1126
-- seconds, we force a test to see if inotify is betraying us. Using a
1127
-- prime number to ensure we get less chance of 'same wakeup' with
1128
-- other processes.
1129
confdConfigReloadTimeout :: Int
1130
confdConfigReloadTimeout = 17
1131

    
1132
-- | If we receive more than one update in this amount of
1133
-- microseconds, we move to polling every RATELIMIT seconds, rather
1134
-- than relying on inotify, to be able to serve more requests.
1135
confdConfigReloadRatelimit :: Int
1136
confdConfigReloadRatelimit = 250000
1137

    
1138
-- | Magic number prepended to all confd queries.
1139
--
1140
-- This allows us to distinguish different types of confd protocols
1141
-- and handle them. For example by changing this we can move the whole
1142
-- payload to be compressed, or move away from json.
1143
confdMagicFourcc :: String
1144
confdMagicFourcc = "plj0"
1145

    
1146
-- | By default a confd request is sent to the minimum between this
1147
-- number and all MCs. 6 was chosen because even in the case of a
1148
-- disastrous 50% response rate, we should have enough answers to be
1149
-- able to compare more than one.
1150
confdDefaultReqCoverage :: Int
1151
confdDefaultReqCoverage = 6
1152

    
1153
-- | Timeout in seconds to expire pending query request in the confd
1154
-- client library. We don't actually expect any answer more than 10
1155
-- seconds after we sent a request.
1156
confdClientExpireTimeout :: Int
1157
confdClientExpireTimeout = 10
1158

    
1159
-- * Possible values for NodeGroup.alloc_policy
1160

    
1161
allocPolicyLastResort :: String
1162
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
1163

    
1164
allocPolicyPreferred :: String
1165
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
1166

    
1167
allocPolicyUnallocable :: String
1168
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
1169

    
1170
validAllocPolicies :: [String]
1171
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
1172

    
1173
-- | Temporary external/shared storage parameters
1174
blockdevDriverManual :: String
1175
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
1176

    
1177
-- | Path generating random UUID
1178
randomUuidFile :: String
1179
randomUuidFile = ConstantUtils.randomUuidFile
1180

    
1181
-- * Auto-repair tag prefixes
1182

    
1183
autoRepairTagPrefix :: String
1184
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
1185

    
1186
autoRepairTagEnabled :: String
1187
autoRepairTagEnabled = autoRepairTagPrefix
1188

    
1189
autoRepairTagPending :: String
1190
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
1191

    
1192
autoRepairTagResult :: String
1193
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
1194

    
1195
autoRepairTagSuspended :: String
1196
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
1197

    
1198
-- * Auto-repair levels
1199

    
1200
autoRepairFailover :: String
1201
autoRepairFailover = "failover"
1202

    
1203
autoRepairFixStorage :: String
1204
autoRepairFixStorage = "fix-storage"
1205

    
1206
autoRepairMigrate :: String
1207
autoRepairMigrate = "migrate"
1208

    
1209
autoRepairReinstall :: String
1210
autoRepairReinstall = "reinstall"
1211

    
1212
autoRepairAllTypes :: FrozenSet String
1213
autoRepairAllTypes =
1214
  ConstantUtils.mkSet [autoRepairFailover,
1215
                       autoRepairFixStorage,
1216
                       autoRepairMigrate,
1217
                       autoRepairReinstall]
1218

    
1219
-- * Auto-repair results
1220

    
1221
autoRepairEnoperm :: String
1222
autoRepairEnoperm = "enoperm"
1223

    
1224
autoRepairFailure :: String
1225
autoRepairFailure = "failure"
1226

    
1227
autoRepairSuccess :: String
1228
autoRepairSuccess = "success"
1229

    
1230
autoRepairAllResults :: FrozenSet String
1231
autoRepairAllResults =
1232
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
1233

    
1234
-- | The version identifier for builtin data collectors
1235
builtinDataCollectorVersion :: String
1236
builtinDataCollectorVersion = "B"
1237

    
1238
-- | The reason trail opcode parameter name
1239
opcodeReason :: String
1240
opcodeReason = "reason"
1241

    
1242
diskstatsFile :: String
1243
diskstatsFile = "/proc/diskstats"
1244

    
1245
-- | CPU load collector
1246
statFile :: String
1247
statFile = "/proc/stat"
1248

    
1249
-- | Mond's variable for periodical data collection
1250
mondTimeInterval :: Int
1251
mondTimeInterval = 5