Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / HsConstants.hs @ 2924f169

History | View | Annotate | Download (29.3 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
-- * Reboot types
429

    
430
instanceRebootSoft :: String
431
instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
432

    
433
instanceRebootHard :: String
434
instanceRebootHard = Types.rebootTypeToRaw RebootHard
435

    
436
instanceRebootFull :: String
437
instanceRebootFull = Types.rebootTypeToRaw RebootFull
438

    
439
rebootTypes :: FrozenSet String
440
rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
441

    
442
-- * VTypes
443

    
444
vtypeBool :: String
445
vtypeBool = Types.vTypeToRaw VTypeBool
446

    
447
vtypeInt :: String
448
vtypeInt = Types.vTypeToRaw VTypeInt
449

    
450
vtypeMaybeString :: String
451
vtypeMaybeString = Types.vTypeToRaw VTypeMaybeString
452

    
453
-- | Size in MiBs
454
vtypeSize :: String
455
vtypeSize = Types.vTypeToRaw VTypeSize
456

    
457
vtypeString :: String
458
vtypeString = Types.vTypeToRaw VTypeString
459

    
460
enforceableTypes :: FrozenSet String
461
enforceableTypes = ConstantUtils.mkSet $ map Types.vTypeToRaw [minBound..]
462

    
463
-- * OOB supported commands
464

    
465
oobPowerOn :: String
466
oobPowerOn = Types.oobCommandToRaw OobPowerOn
467

    
468
oobPowerOff :: String
469
oobPowerOff = Types.oobCommandToRaw OobPowerOff
470

    
471
oobPowerCycle :: String
472
oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
473

    
474
oobPowerStatus :: String
475
oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
476

    
477
oobHealth :: String
478
oobHealth = Types.oobCommandToRaw OobHealth
479

    
480
oobCommands :: FrozenSet String
481
oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
482

    
483
oobPowerStatusPowered :: String
484
oobPowerStatusPowered = "powered"
485

    
486
-- | 60 seconds
487
oobTimeout :: Int
488
oobTimeout = 60
489

    
490
-- | 2 seconds
491
oobPowerDelay :: Double
492
oobPowerDelay = 2.0
493

    
494
oobStatusCritical :: String
495
oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
496

    
497
oobStatusOk :: String
498
oobStatusOk = Types.oobStatusToRaw OobStatusOk
499

    
500
oobStatusUnknown :: String
501
oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
502

    
503
oobStatusWarning :: String
504
oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
505

    
506
oobStatuses :: FrozenSet String
507
oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
508

    
509
-- * NIC_* constants are used inside the ganeti config
510

    
511
nicLink :: String
512
nicLink = "link"
513

    
514
nicMode :: String
515
nicMode = "mode"
516

    
517
nicVlan :: String
518
nicVlan = "vlan"
519

    
520
nicModeBridged :: String
521
nicModeBridged = Types.nICModeToRaw NMBridged
522

    
523
nicModeRouted :: String
524
nicModeRouted = Types.nICModeToRaw NMRouted
525

    
526
nicModeOvs :: String
527
nicModeOvs = Types.nICModeToRaw NMOvs
528

    
529
nicIpPool :: String
530
nicIpPool = Types.nICModeToRaw NMPool
531

    
532
nicValidModes :: FrozenSet String
533
nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
534

    
535
-- * Hypervisor constants
536

    
537
htXenPvm :: String
538
htXenPvm = Types.hypervisorToRaw XenPvm
539

    
540
htFake :: String
541
htFake = Types.hypervisorToRaw Fake
542

    
543
htXenHvm :: String
544
htXenHvm = Types.hypervisorToRaw XenHvm
545

    
546
htKvm :: String
547
htKvm = Types.hypervisorToRaw Kvm
548

    
549
htChroot :: String
550
htChroot = Types.hypervisorToRaw Chroot
551

    
552
htLxc :: String
553
htLxc = Types.hypervisorToRaw Lxc
554

    
555
hyperTypes :: FrozenSet String
556
hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
557

    
558
htsReqPort :: FrozenSet String
559
htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
560

    
561
-- * Migration type
562

    
563
htMigrationLive :: String
564
htMigrationLive = Types.migrationModeToRaw MigrationLive
565

    
566
htMigrationNonlive :: String
567
htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
568

    
569
htMigrationModes :: FrozenSet String
570
htMigrationModes =
571
  ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
572

    
573
-- * Cluster verify steps
574

    
575
verifyNplusoneMem :: String
576
verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
577

    
578
verifyOptionalChecks :: FrozenSet String
579
verifyOptionalChecks =
580
  ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
581

    
582
-- * Cluster Verify error classes
583

    
584
cvTcluster :: String
585
cvTcluster = "cluster"
586

    
587
cvTgroup :: String
588
cvTgroup = "group"
589

    
590
cvTnode :: String
591
cvTnode = "node"
592

    
593
cvTinstance :: String
594
cvTinstance = "instance"
595

    
596
-- * Cluster Verify error codes and documentation
597

    
598
cvEclustercert :: (String, String, String)
599
cvEclustercert =
600
  ("cluster",
601
   Types.cVErrorCodeToRaw CvECLUSTERCERT,
602
   "Cluster certificate files verification failure")
603

    
604
cvEclustercfg :: (String, String, String)
605
cvEclustercfg =
606
  ("cluster",
607
   Types.cVErrorCodeToRaw CvECLUSTERCFG,
608
   "Cluster configuration verification failure")
609

    
610
cvEclusterdanglinginst :: (String, String, String)
611
cvEclusterdanglinginst =
612
  ("node",
613
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
614
   "Some instances have a non-existing primary node")
615

    
616
cvEclusterdanglingnodes :: (String, String, String)
617
cvEclusterdanglingnodes =
618
  ("node",
619
   Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
620
   "Some nodes belong to non-existing groups")
621

    
622
cvEclusterfilecheck :: (String, String, String)
623
cvEclusterfilecheck =
624
  ("cluster",
625
   Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
626
   "Cluster configuration verification failure")
627

    
628
cvEgroupdifferentpvsize :: (String, String, String)
629
cvEgroupdifferentpvsize =
630
  ("group",
631
   Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
632
   "PVs in the group have different sizes")
633

    
634
cvEinstancebadnode :: (String, String, String)
635
cvEinstancebadnode =
636
  ("instance",
637
   Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
638
   "Instance marked as running lives on an offline node")
639

    
640
cvEinstancedown :: (String, String, String)
641
cvEinstancedown =
642
  ("instance",
643
   Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
644
   "Instance not running on its primary node")
645

    
646
cvEinstancefaultydisk :: (String, String, String)
647
cvEinstancefaultydisk =
648
  ("instance",
649
   Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
650
   "Impossible to retrieve status for a disk")
651

    
652
cvEinstancelayout :: (String, String, String)
653
cvEinstancelayout =
654
  ("instance",
655
   Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
656
   "Instance has multiple secondary nodes")
657

    
658
cvEinstancemissingcfgparameter :: (String, String, String)
659
cvEinstancemissingcfgparameter =
660
  ("instance",
661
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
662
   "A configuration parameter for an instance is missing")
663

    
664
cvEinstancemissingdisk :: (String, String, String)
665
cvEinstancemissingdisk =
666
  ("instance",
667
   Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
668
   "Missing volume on an instance")
669

    
670
cvEinstancepolicy :: (String, String, String)
671
cvEinstancepolicy =
672
  ("instance",
673
   Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
674
   "Instance does not meet policy")
675

    
676
cvEinstancesplitgroups :: (String, String, String)
677
cvEinstancesplitgroups =
678
  ("instance",
679
   Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
680
   "Instance with primary and secondary nodes in different groups")
681

    
682
cvEinstanceunsuitablenode :: (String, String, String)
683
cvEinstanceunsuitablenode =
684
  ("instance",
685
   Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
686
   "Instance running on nodes that are not suitable for it")
687

    
688
cvEinstancewrongnode :: (String, String, String)
689
cvEinstancewrongnode =
690
  ("instance",
691
   Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
692
   "Instance running on the wrong node")
693

    
694
cvEnodedrbd :: (String, String, String)
695
cvEnodedrbd =
696
  ("node",
697
   Types.cVErrorCodeToRaw CvENODEDRBD,
698
   "Error parsing the DRBD status file")
699

    
700
cvEnodedrbdhelper :: (String, String, String)
701
cvEnodedrbdhelper =
702
  ("node",
703
   Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
704
   "Error caused by the DRBD helper")
705

    
706
cvEnodedrbdversion :: (String, String, String)
707
cvEnodedrbdversion =
708
  ("node",
709
   Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
710
   "DRBD version mismatch within a node group")
711

    
712
cvEnodefilecheck :: (String, String, String)
713
cvEnodefilecheck =
714
  ("node",
715
   Types.cVErrorCodeToRaw CvENODEFILECHECK,
716
   "Error retrieving the checksum of the node files")
717

    
718
cvEnodefilestoragepaths :: (String, String, String)
719
cvEnodefilestoragepaths =
720
  ("node",
721
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
722
   "Detected bad file storage paths")
723

    
724
cvEnodefilestoragepathunusable :: (String, String, String)
725
cvEnodefilestoragepathunusable =
726
  ("node",
727
   Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
728
   "File storage path unusable")
729

    
730
cvEnodehooks :: (String, String, String)
731
cvEnodehooks =
732
  ("node",
733
   Types.cVErrorCodeToRaw CvENODEHOOKS,
734
   "Communication failure in hooks execution")
735

    
736
cvEnodehv :: (String, String, String)
737
cvEnodehv =
738
  ("node",
739
   Types.cVErrorCodeToRaw CvENODEHV,
740
   "Hypervisor parameters verification failure")
741

    
742
cvEnodelvm :: (String, String, String)
743
cvEnodelvm =
744
  ("node",
745
   Types.cVErrorCodeToRaw CvENODELVM,
746
   "LVM-related node error")
747

    
748
cvEnoden1 :: (String, String, String)
749
cvEnoden1 =
750
  ("node",
751
   Types.cVErrorCodeToRaw CvENODEN1,
752
   "Not enough memory to accommodate instance failovers")
753

    
754
cvEnodenet :: (String, String, String)
755
cvEnodenet =
756
  ("node",
757
   Types.cVErrorCodeToRaw CvENODENET,
758
   "Network-related node error")
759

    
760
cvEnodeoobpath :: (String, String, String)
761
cvEnodeoobpath =
762
  ("node",
763
   Types.cVErrorCodeToRaw CvENODEOOBPATH,
764
   "Invalid Out Of Band path")
765

    
766
cvEnodeorphaninstance :: (String, String, String)
767
cvEnodeorphaninstance =
768
  ("node",
769
   Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
770
   "Unknown intance running on a node")
771

    
772
cvEnodeorphanlv :: (String, String, String)
773
cvEnodeorphanlv =
774
  ("node",
775
   Types.cVErrorCodeToRaw CvENODEORPHANLV,
776
   "Unknown LVM logical volume")
777

    
778
cvEnodeos :: (String, String, String)
779
cvEnodeos =
780
  ("node",
781
   Types.cVErrorCodeToRaw CvENODEOS,
782
   "OS-related node error")
783

    
784
cvEnoderpc :: (String, String, String)
785
cvEnoderpc =
786
  ("node",
787
   Types.cVErrorCodeToRaw CvENODERPC,
788
   "Error during connection to the primary node of an instance")
789

    
790
cvEnodesetup :: (String, String, String)
791
cvEnodesetup =
792
  ("node",
793
   Types.cVErrorCodeToRaw CvENODESETUP,
794
   "Node setup error")
795

    
796
cvEnodesharedfilestoragepathunusable :: (String, String, String)
797
cvEnodesharedfilestoragepathunusable =
798
  ("node",
799
   Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
800
   "Shared file storage path unusable")
801

    
802
cvEnodessh :: (String, String, String)
803
cvEnodessh =
804
  ("node",
805
   Types.cVErrorCodeToRaw CvENODESSH,
806
   "SSH-related node error")
807

    
808
cvEnodetime :: (String, String, String)
809
cvEnodetime =
810
  ("node",
811
   Types.cVErrorCodeToRaw CvENODETIME,
812
   "Node returned invalid time")
813

    
814
cvEnodeuserscripts :: (String, String, String)
815
cvEnodeuserscripts =
816
  ("node",
817
   Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
818
   "User scripts not present or not executable")
819

    
820
cvEnodeversion :: (String, String, String)
821
cvEnodeversion =
822
  ("node",
823
   Types.cVErrorCodeToRaw CvENODEVERSION,
824
   "Protocol version mismatch or Ganeti version mismatch")
825

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

    
868
cvAllEcodesStrings :: FrozenSet String
869
cvAllEcodesStrings =
870
  ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
871

    
872
-- * Instance status
873

    
874
inststAdmindown :: String
875
inststAdmindown = Types.instanceStatusToRaw StatusDown
876

    
877
inststAdminoffline :: String
878
inststAdminoffline = Types.instanceStatusToRaw StatusOffline
879

    
880
inststErrordown :: String
881
inststErrordown = Types.instanceStatusToRaw ErrorDown
882

    
883
inststErrorup :: String
884
inststErrorup = Types.instanceStatusToRaw ErrorUp
885

    
886
inststNodedown :: String
887
inststNodedown = Types.instanceStatusToRaw NodeDown
888

    
889
inststNodeoffline :: String
890
inststNodeoffline = Types.instanceStatusToRaw NodeOffline
891

    
892
inststRunning :: String
893
inststRunning = Types.instanceStatusToRaw Running
894

    
895
inststWrongnode :: String
896
inststWrongnode = Types.instanceStatusToRaw WrongNode
897

    
898
inststAll :: FrozenSet String
899
inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
900

    
901
-- * Admin states
902

    
903
adminstDown :: String
904
adminstDown = Types.adminStateToRaw AdminDown
905

    
906
adminstOffline :: String
907
adminstOffline = Types.adminStateToRaw AdminOffline
908

    
909
adminstUp :: String
910
adminstUp = Types.adminStateToRaw AdminUp
911

    
912
adminstAll :: FrozenSet String
913
adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
914

    
915
-- * Node roles
916

    
917
nrDrained :: String
918
nrDrained = Types.nodeRoleToRaw NRDrained
919

    
920
nrMaster :: String
921
nrMaster = Types.nodeRoleToRaw NRMaster
922

    
923
nrMcandidate :: String
924
nrMcandidate = Types.nodeRoleToRaw NRCandidate
925

    
926
nrOffline :: String
927
nrOffline = Types.nodeRoleToRaw NROffline
928

    
929
nrRegular :: String
930
nrRegular = Types.nodeRoleToRaw NRRegular
931

    
932
nrAll :: FrozenSet String
933
nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
934

    
935
-- * Allocator framework constants
936

    
937
iallocatorVersion :: Int
938
iallocatorVersion = 2
939

    
940
iallocatorDirIn :: String
941
iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
942

    
943
iallocatorDirOut :: String
944
iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
945

    
946
validIallocatorDirections :: FrozenSet String
947
validIallocatorDirections =
948
  ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
949

    
950
iallocatorModeAlloc :: String
951
iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
952

    
953
iallocatorModeChgGroup :: String
954
iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
955

    
956
iallocatorModeMultiAlloc :: String
957
iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
958

    
959
iallocatorModeNodeEvac :: String
960
iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
961

    
962
iallocatorModeReloc :: String
963
iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
964

    
965
validIallocatorModes :: FrozenSet String
966
validIallocatorModes =
967
  ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
968

    
969
iallocatorSearchPath :: [String]
970
iallocatorSearchPath = AutoConf.iallocatorSearchPath
971

    
972
defaultIallocatorShortcut :: String
973
defaultIallocatorShortcut = "."
974

    
975
iallocatorNevacPri :: String
976
iallocatorNevacPri = Types.nodeEvacModeToRaw NEvacPrimary
977

    
978
iallocatorNevacSec :: String
979
iallocatorNevacSec = Types.nodeEvacModeToRaw NEvacSecondary
980

    
981
iallocatorNevacAll :: String
982
iallocatorNevacAll = Types.nodeEvacModeToRaw NEvacAll
983

    
984
iallocatorNevacModes :: FrozenSet String
985
iallocatorNevacModes =
986
  ConstantUtils.mkSet $ map Types.nodeEvacModeToRaw [minBound..]
987

    
988
-- * Node evacuation
989

    
990
nodeEvacPri :: String
991
nodeEvacPri = Types.nodeEvacModeToRaw NEvacPrimary
992

    
993
nodeEvacSec :: String
994
nodeEvacSec = Types.nodeEvacModeToRaw NEvacSecondary
995

    
996
nodeEvacAll :: String
997
nodeEvacAll = Types.nodeEvacModeToRaw NEvacAll
998

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

    
1002
-- * Job status
1003

    
1004
jobStatusQueued :: String
1005
jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
1006

    
1007
jobStatusWaiting :: String
1008
jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
1009

    
1010
jobStatusCanceling :: String
1011
jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
1012

    
1013
jobStatusRunning :: String
1014
jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
1015

    
1016
jobStatusCanceled :: String
1017
jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
1018

    
1019
jobStatusSuccess :: String
1020
jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
1021

    
1022
jobStatusError :: String
1023
jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
1024

    
1025
jobsPending :: FrozenSet String
1026
jobsPending =
1027
  ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
1028

    
1029
jobsFinalized :: FrozenSet String
1030
jobsFinalized =
1031
  ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
1032

    
1033
jobStatusAll :: FrozenSet String
1034
jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
1035

    
1036
-- * OpCode status
1037

    
1038
-- ** Not yet finalized opcodes
1039

    
1040
opStatusCanceling :: String
1041
opStatusCanceling = "canceling"
1042

    
1043
opStatusQueued :: String
1044
opStatusQueued = "queued"
1045

    
1046
opStatusRunning :: String
1047
opStatusRunning = "running"
1048

    
1049
opStatusWaiting :: String
1050
opStatusWaiting = "waiting"
1051

    
1052
-- ** Finalized opcodes
1053

    
1054
opStatusCanceled :: String
1055
opStatusCanceled = "canceled"
1056

    
1057
opStatusError :: String
1058
opStatusError = "error"
1059

    
1060
opStatusSuccess :: String
1061
opStatusSuccess = "success"
1062

    
1063
opsFinalized :: FrozenSet String
1064
opsFinalized =
1065
  ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
1066

    
1067
-- * OpCode priority
1068

    
1069
opPrioLowest :: Int
1070
opPrioLowest = 19
1071

    
1072
opPrioHighest :: Int
1073
opPrioHighest = -20
1074

    
1075
opPrioLow :: Int
1076
opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
1077

    
1078
opPrioNormal :: Int
1079
opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
1080

    
1081
opPrioHigh :: Int
1082
opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
1083

    
1084
opPrioSubmitValid :: FrozenSet Int
1085
opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
1086

    
1087
opPrioDefault :: Int
1088
opPrioDefault = opPrioNormal
1089

    
1090
-- * Execution log types
1091

    
1092
elogMessage :: String
1093
elogMessage = Types.eLogTypeToRaw ELogMessage
1094

    
1095
elogRemoteImport :: String
1096
elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
1097

    
1098
elogJqueueTest :: String
1099
elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
1100

    
1101
-- * Possible values for NodeGroup.alloc_policy
1102

    
1103
allocPolicyLastResort :: String
1104
allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
1105

    
1106
allocPolicyPreferred :: String
1107
allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
1108

    
1109
allocPolicyUnallocable :: String
1110
allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
1111

    
1112
validAllocPolicies :: [String]
1113
validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
1114

    
1115
-- | Temporary external/shared storage parameters
1116
blockdevDriverManual :: String
1117
blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
1118

    
1119
-- | Path generating random UUID
1120
randomUuidFile :: String
1121
randomUuidFile = ConstantUtils.randomUuidFile
1122

    
1123
-- * Auto-repair tag prefixes
1124

    
1125
autoRepairTagPrefix :: String
1126
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
1127

    
1128
autoRepairTagEnabled :: String
1129
autoRepairTagEnabled = autoRepairTagPrefix
1130

    
1131
autoRepairTagPending :: String
1132
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
1133

    
1134
autoRepairTagResult :: String
1135
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
1136

    
1137
autoRepairTagSuspended :: String
1138
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
1139

    
1140
-- * Auto-repair levels
1141

    
1142
autoRepairFailover :: String
1143
autoRepairFailover = "failover"
1144

    
1145
autoRepairFixStorage :: String
1146
autoRepairFixStorage = "fix-storage"
1147

    
1148
autoRepairMigrate :: String
1149
autoRepairMigrate = "migrate"
1150

    
1151
autoRepairReinstall :: String
1152
autoRepairReinstall = "reinstall"
1153

    
1154
autoRepairAllTypes :: FrozenSet String
1155
autoRepairAllTypes =
1156
  ConstantUtils.mkSet [autoRepairFailover,
1157
                       autoRepairFixStorage,
1158
                       autoRepairMigrate,
1159
                       autoRepairReinstall]
1160

    
1161
-- * Auto-repair results
1162

    
1163
autoRepairEnoperm :: String
1164
autoRepairEnoperm = "enoperm"
1165

    
1166
autoRepairFailure :: String
1167
autoRepairFailure = "failure"
1168

    
1169
autoRepairSuccess :: String
1170
autoRepairSuccess = "success"
1171

    
1172
autoRepairAllResults :: FrozenSet String
1173
autoRepairAllResults =
1174
  ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
1175

    
1176
-- | The version identifier for builtin data collectors
1177
builtinDataCollectorVersion :: String
1178
builtinDataCollectorVersion = "B"
1179

    
1180
-- | The reason trail opcode parameter name
1181
opcodeReason :: String
1182
opcodeReason = "reason"
1183

    
1184
diskstatsFile :: String
1185
diskstatsFile = "/proc/diskstats"
1186

    
1187
-- | CPU load collector
1188
statFile :: String
1189
statFile = "/proc/stat"
1190

    
1191
-- | Mond's variable for periodical data collection
1192
mondTimeInterval :: Int
1193
mondTimeInterval = 5