Move VTypes to the appropriate place
[ganeti-local] / src / Ganeti / HsConstants.hs
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.List ((\\))
40 import Data.Map (Map)
41 import qualified Data.Map as Map (fromList, keys, insert)
42
43 import AutoConf
44 import Ganeti.ConstantUtils (PythonChar(..), FrozenSet, Protocol(..),
45                              buildVersion)
46 import qualified Ganeti.ConstantUtils as ConstantUtils
47 import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..),
48                        ExtraLogReason(..))
49 import Ganeti.HTools.Types (AutoRepairResult(..), AutoRepairType(..))
50 import qualified Ganeti.HTools.Types as Types
51 import Ganeti.Logging (SyslogUsage(..))
52 import qualified Ganeti.Logging as Logging (syslogUsageToRaw)
53 import qualified Ganeti.Runtime as Runtime
54 import Ganeti.Types
55 import qualified Ganeti.Types as Types
56 import Ganeti.Confd.Types (ConfdRequestType(..), ConfdReqField(..),
57                            ConfdReplyStatus(..), ConfdNodeRole(..),
58                            ConfdErrorType(..))
59 import qualified Ganeti.Confd.Types as Types
60
61 {-# ANN module "HLint: ignore Use camelCase" #-}
62
63 -- * 'autoconf' constants for Python only ('autotools/build-bash-completion')
64
65 htoolsProgs :: [String]
66 htoolsProgs = AutoConf.htoolsProgs
67
68 -- * 'autoconf' constants for Python only ('lib/constants.py')
69
70 drbdBarriers :: String
71 drbdBarriers = AutoConf.drbdBarriers
72
73 drbdNoMetaFlush :: Bool
74 drbdNoMetaFlush = AutoConf.drbdNoMetaFlush
75
76 lvmStripecount :: Int
77 lvmStripecount = AutoConf.lvmStripecount
78
79 -- * 'autoconf' constants for Python only ('lib/pathutils.py')
80
81 -- ** Build-time constants
82
83 exportDir :: String
84 exportDir = AutoConf.exportDir
85
86 osSearchPath :: [String]
87 osSearchPath = AutoConf.osSearchPath
88
89 esSearchPath :: [String]
90 esSearchPath = AutoConf.esSearchPath
91
92 sshConfigDir :: String
93 sshConfigDir = AutoConf.sshConfigDir
94
95 xenConfigDir :: String
96 xenConfigDir = AutoConf.xenConfigDir
97
98 sysconfdir :: String
99 sysconfdir = AutoConf.sysconfdir
100
101 toolsdir :: String
102 toolsdir = AutoConf.toolsdir
103
104 localstatedir :: String
105 localstatedir = AutoConf.localstatedir
106
107 -- ** Paths which don't change for a virtual cluster
108
109 pkglibdir :: String
110 pkglibdir = AutoConf.pkglibdir
111
112 sharedir :: String
113 sharedir = AutoConf.sharedir
114
115 -- * 'autoconf' constants for Python only ('lib/build/sphinx_ext.py')
116
117 manPages :: Map String Int
118 manPages = Map.fromList AutoConf.manPages
119
120 -- * 'autoconf' constants for QA cluster only ('qa/qa_cluster.py')
121
122 versionedsharedir :: String
123 versionedsharedir = AutoConf.versionedsharedir
124
125 -- * 'autoconf' constants for Python only ('tests/py/docs_unittest.py')
126
127 gntScripts :: [String]
128 gntScripts = AutoConf.gntScripts
129
130 -- * Various versions
131
132 releaseVersion :: String
133 releaseVersion = AutoConf.packageVersion
134
135 versionMajor :: Int
136 versionMajor = AutoConf.versionMajor
137
138 versionMinor :: Int
139 versionMinor = AutoConf.versionMinor
140
141 versionRevision :: Int
142 versionRevision = AutoConf.versionRevision
143
144 dirVersion :: String
145 dirVersion = AutoConf.dirVersion
146
147 osApiV10 :: Int
148 osApiV10 = 10
149
150 osApiV15 :: Int
151 osApiV15 = 15
152
153 osApiV20 :: Int
154 osApiV20 = 20
155
156 osApiVersions :: FrozenSet Int
157 osApiVersions = ConstantUtils.mkSet [osApiV10, osApiV15, osApiV20]
158
159 configMajor :: Int
160 configMajor = AutoConf.versionMajor
161
162 configMinor :: Int
163 configMinor = AutoConf.versionMinor
164
165 -- | The configuration is supposed to remain stable across
166 -- revisions. Therefore, the revision number is cleared to '0'.
167 configRevision :: Int
168 configRevision = 0
169
170 configVersion :: Int
171 configVersion = buildVersion configMajor configMinor configRevision
172
173 -- | Similarly to the configuration (see 'configRevision'), the
174 -- protocols are supposed to remain stable across revisions.
175 protocolVersion :: Int
176 protocolVersion = buildVersion configMajor configMinor configRevision
177
178 -- * User separation
179
180 daemonsGroup :: String
181 daemonsGroup = Runtime.daemonGroup (ExtraGroup DaemonsGroup)
182
183 adminGroup :: String
184 adminGroup = Runtime.daemonGroup (ExtraGroup AdminGroup)
185
186 masterdUser :: String
187 masterdUser = Runtime.daemonUser GanetiMasterd
188
189 masterdGroup :: String
190 masterdGroup = Runtime.daemonGroup (DaemonGroup GanetiMasterd)
191
192 rapiUser :: String
193 rapiUser = Runtime.daemonUser GanetiRapi
194
195 rapiGroup :: String
196 rapiGroup = Runtime.daemonGroup (DaemonGroup GanetiRapi)
197
198 confdUser :: String
199 confdUser = Runtime.daemonUser GanetiConfd
200
201 confdGroup :: String
202 confdGroup = Runtime.daemonGroup (DaemonGroup GanetiConfd)
203
204 luxidUser :: String
205 luxidUser = Runtime.daemonUser GanetiLuxid
206
207 luxidGroup :: String
208 luxidGroup = Runtime.daemonGroup (DaemonGroup GanetiLuxid)
209
210 nodedUser :: String
211 nodedUser = Runtime.daemonUser GanetiNoded
212
213 nodedGroup :: String
214 nodedGroup = Runtime.daemonGroup (DaemonGroup GanetiNoded)
215
216 mondUser :: String
217 mondUser = Runtime.daemonUser GanetiMond
218
219 mondGroup :: String
220 mondGroup = Runtime.daemonGroup (DaemonGroup GanetiMond)
221
222 sshLoginUser :: String
223 sshLoginUser = AutoConf.sshLoginUser
224
225 sshConsoleUser :: String
226 sshConsoleUser = AutoConf.sshConsoleUser
227
228 -- * Wipe
229
230 ddCmd :: String
231 ddCmd = "dd"
232
233 -- | 1GB
234 maxWipeChunk :: Int
235 maxWipeChunk = 1024
236
237 minWipeChunkPercent :: Int
238 minWipeChunkPercent = 10
239
240 -- * Directories
241
242 runDirsMode :: Int
243 runDirsMode = 0o775
244
245 secureDirMode :: Int
246 secureDirMode = 0o700
247
248 secureFileMode :: Int
249 secureFileMode = 0o600
250
251 adoptableBlockdevRoot :: String
252 adoptableBlockdevRoot = "/dev/disk/"
253
254 -- * 'autoconf' enable/disable
255
256 enableConfd :: Bool
257 enableConfd = AutoConf.enableConfd
258
259 enableMond :: Bool
260 enableMond = AutoConf.enableMond
261
262 enableRestrictedCommands :: Bool
263 enableRestrictedCommands = AutoConf.enableRestrictedCommands
264
265 enableSplitQuery :: Bool
266 enableSplitQuery = AutoConf.enableSplitQuery
267
268 -- * SSH constants
269
270 ssh :: String
271 ssh = "ssh"
272
273 scp :: String
274 scp = "scp"
275
276 -- * Daemons
277
278 confd :: String
279 confd = Runtime.daemonName GanetiConfd
280
281 masterd :: String
282 masterd = Runtime.daemonName GanetiMasterd
283
284 mond :: String
285 mond = Runtime.daemonName GanetiMond
286
287 noded :: String
288 noded = Runtime.daemonName GanetiNoded
289
290 luxid :: String
291 luxid = Runtime.daemonName GanetiLuxid
292
293 rapi :: String
294 rapi = Runtime.daemonName GanetiRapi
295
296 daemons :: FrozenSet String
297 daemons =
298   ConstantUtils.mkSet [confd,
299                        luxid,
300                        masterd,
301                        mond,
302                        noded,
303                        rapi]
304
305 defaultConfdPort :: Int
306 defaultConfdPort = 1814
307
308 defaultMondPort :: Int
309 defaultMondPort = 1815
310
311 defaultNodedPort :: Int
312 defaultNodedPort = 1811
313
314 defaultRapiPort :: Int
315 defaultRapiPort = 5080
316
317 daemonsPorts :: Map String (Protocol, Int)
318 daemonsPorts =
319   Map.fromList [(confd, (Udp, defaultConfdPort)),
320                 (mond, (Tcp, defaultMondPort)),
321                 (noded, (Tcp, defaultNodedPort)),
322                 (rapi, (Tcp, defaultRapiPort)),
323                 (ssh, (Tcp, 22))]
324
325 firstDrbdPort :: Int
326 firstDrbdPort = 11000
327
328 lastDrbdPort :: Int
329 lastDrbdPort = 14999
330
331 daemonsLogbase :: Map String String
332 daemonsLogbase =
333   Map.fromList
334   [ (Runtime.daemonName d, Runtime.daemonLogBase d) | d <- [minBound..] ]
335
336 extraLogreasonAccess :: String
337 extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog
338
339 extraLogreasonError :: String
340 extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
341
342 devConsole :: String
343 devConsole = ConstantUtils.devConsole
344
345 -- * Luxi (Local UniX Interface) related constants
346
347 luxiEom :: PythonChar
348 luxiEom = PythonChar '\x03'
349
350 -- | Environment variable for the luxi override socket
351 luxiOverride :: String
352 luxiOverride = "FORCE_LUXI_SOCKET"
353
354 luxiOverrideMaster :: String
355 luxiOverrideMaster = "master"
356
357 luxiOverrideQuery :: String
358 luxiOverrideQuery = "query"
359
360 luxiVersion :: Int
361 luxiVersion = configVersion
362
363 -- * Syslog
364
365 syslogUsage :: String
366 syslogUsage = AutoConf.syslogUsage
367
368 syslogNo :: String
369 syslogNo = Logging.syslogUsageToRaw SyslogNo
370
371 syslogYes :: String
372 syslogYes = Logging.syslogUsageToRaw SyslogYes
373
374 syslogOnly :: String
375 syslogOnly = Logging.syslogUsageToRaw SyslogOnly
376
377 syslogSocket :: String
378 syslogSocket = "/dev/log"
379
380 -- * Xen
381
382 xenBootloader :: String
383 xenBootloader = AutoConf.xenBootloader
384
385 xenCmdXl :: String
386 xenCmdXl = "xl"
387
388 xenCmdXm :: String
389 xenCmdXm = "xm"
390
391 xenInitrd :: String
392 xenInitrd = AutoConf.xenInitrd
393
394 xenKernel :: String
395 xenKernel = AutoConf.xenKernel
396
397 -- FIXME: perhaps rename to 'validXenCommands' for consistency with
398 -- other constants
399 knownXenCommands :: FrozenSet String
400 knownXenCommands = ConstantUtils.mkSet [xenCmdXl, xenCmdXm]
401
402 -- * KVM and socat
403
404 kvmPath :: String
405 kvmPath = AutoConf.kvmPath
406
407 kvmKernel :: String
408 kvmKernel = AutoConf.kvmKernel
409
410 socatEscapeCode :: String
411 socatEscapeCode = "0x1d"
412
413 socatPath :: String
414 socatPath = AutoConf.socatPath
415
416 socatUseCompress :: Bool
417 socatUseCompress = AutoConf.socatUseCompress
418
419 socatUseEscape :: Bool
420 socatUseEscape = AutoConf.socatUseEscape
421
422 -- * Storage types
423
424 stBlock :: String
425 stBlock = Types.storageTypeToRaw StorageBlock
426
427 stDiskless :: String
428 stDiskless = Types.storageTypeToRaw StorageDiskless
429
430 stExt :: String
431 stExt = Types.storageTypeToRaw StorageExt
432
433 stFile :: String
434 stFile = Types.storageTypeToRaw StorageFile
435
436 stLvmPv :: String
437 stLvmPv = Types.storageTypeToRaw StorageLvmPv
438
439 stLvmVg :: String
440 stLvmVg = Types.storageTypeToRaw StorageLvmVg
441
442 stRados :: String
443 stRados = Types.storageTypeToRaw StorageRados
444
445 storageTypes :: FrozenSet String
446 storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw [minBound..]
447
448 -- * Storage fields
449 -- ** First two are valid in LU context only, not passed to backend
450
451 sfNode :: String
452 sfNode = "node"
453
454 sfType :: String
455 sfType = "type"
456
457 -- ** and the rest are valid in backend
458
459 sfAllocatable :: String
460 sfAllocatable = Types.storageFieldToRaw SFAllocatable
461
462 sfFree :: String
463 sfFree = Types.storageFieldToRaw SFFree
464
465 sfName :: String
466 sfName = Types.storageFieldToRaw SFName
467
468 sfSize :: String
469 sfSize = Types.storageFieldToRaw SFSize
470
471 sfUsed :: String
472 sfUsed = Types.storageFieldToRaw SFUsed
473
474 -- * Local disk status
475
476 ldsFaulty :: Int
477 ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
478
479 ldsOkay :: Int
480 ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
481
482 ldsUnknown :: Int
483 ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
484
485 ldsNames :: Map Int String
486 ldsNames =
487   Map.fromList [ (Types.localDiskStatusToRaw ds,
488                   localDiskStatusName ds) | ds <- [minBound..] ]
489
490 -- * Disk template types
491
492 dtDiskless :: String
493 dtDiskless = Types.diskTemplateToRaw DTDiskless
494
495 dtFile :: String
496 dtFile = Types.diskTemplateToRaw DTFile
497
498 dtSharedFile :: String
499 dtSharedFile = Types.diskTemplateToRaw DTSharedFile
500
501 dtPlain :: String
502 dtPlain = Types.diskTemplateToRaw DTPlain
503
504 dtBlock :: String
505 dtBlock = Types.diskTemplateToRaw DTBlock
506
507 dtDrbd8 :: String
508 dtDrbd8 = Types.diskTemplateToRaw DTDrbd8
509
510 dtRbd :: String
511 dtRbd = Types.diskTemplateToRaw DTRbd
512
513 dtExt :: String
514 dtExt = Types.diskTemplateToRaw DTExt
515
516 -- | This is used to order determine the default disk template when
517 -- the list of enabled disk templates is inferred from the current
518 -- state of the cluster.  This only happens on an upgrade from a
519 -- version of Ganeti that did not support the 'enabled_disk_templates'
520 -- so far.
521 diskTemplatePreference :: [String]
522 diskTemplatePreference =
523   map Types.diskTemplateToRaw
524   [DTBlock, DTDiskless, DTDrbd8, DTExt, DTFile, DTPlain, DTRbd, DTSharedFile]
525
526 diskTemplates :: FrozenSet String
527 diskTemplates = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [minBound..]
528
529 -- | Disk templates that are enabled by default
530 defaultEnabledDiskTemplates :: [String]
531 defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, DTPlain]
532
533 -- | The set of network-mirrored disk templates
534 dtsIntMirror :: FrozenSet String
535 dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
536
537 -- | 'DTDiskless' is 'trivially' externally mirrored
538 dtsExtMirror :: FrozenSet String
539 dtsExtMirror =
540   ConstantUtils.mkSet $
541   map Types.diskTemplateToRaw [DTDiskless, DTBlock, DTExt, DTSharedFile, DTRbd]
542
543 -- | The set of non-lvm-based disk templates
544 dtsNotLvm :: FrozenSet String
545 dtsNotLvm =
546   ConstantUtils.mkSet $
547   map Types.diskTemplateToRaw
548   [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd]
549
550 -- | The set of disk templates which can be grown
551 dtsGrowable :: FrozenSet String
552 dtsGrowable =
553   ConstantUtils.mkSet $
554   map Types.diskTemplateToRaw
555   [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd]
556
557 -- | The set of disk templates that allow adoption
558 dtsMayAdopt :: FrozenSet String
559 dtsMayAdopt =
560   ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
561
562 -- | The set of disk templates that *must* use adoption
563 dtsMustAdopt :: FrozenSet String
564 dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
565
566 -- | The set of disk templates that allow migrations
567 dtsMirrored :: FrozenSet String
568 dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
569
570 -- | The set of file based disk templates
571 dtsFilebased :: FrozenSet String
572 dtsFilebased =
573   ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTSharedFile, DTFile]
574
575 -- | The set of disk templates that can be moved by copying
576 --
577 -- Note: a requirement is that they're not accessed externally or
578 -- shared between nodes; in particular, sharedfile is not suitable.
579 dtsCopyable :: FrozenSet String
580 dtsCopyable =
581   ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
582
583 -- | The set of disk templates that are supported by exclusive_storage
584 dtsExclStorage :: FrozenSet String
585 dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain]
586
587 -- | Templates for which we don't perform checks on free space
588 dtsNoFreeSpaceCheck :: FrozenSet String
589 dtsNoFreeSpaceCheck =
590   ConstantUtils.mkSet $
591   map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd]
592
593 dtsBlock :: FrozenSet String
594 dtsBlock =
595   ConstantUtils.mkSet $
596   map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
597
598 -- * File backend driver
599
600 fdBlktap :: String
601 fdBlktap = Types.fileDriverToRaw FileBlktap
602
603 fdLoop :: String
604 fdLoop = Types.fileDriverToRaw FileLoop
605
606 fileDriver :: FrozenSet String
607 fileDriver =
608   ConstantUtils.mkSet $
609   map Types.fileDriverToRaw [minBound..]
610
611 -- | The set of drbd-like disk types
612 ldsDrbd :: FrozenSet String
613 ldsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
614
615 -- * Disk access mode
616
617 diskRdonly :: String
618 diskRdonly = Types.diskModeToRaw DiskRdOnly
619
620 diskRdwr :: String
621 diskRdwr = Types.diskModeToRaw DiskRdWr
622
623 diskAccessSet :: FrozenSet String
624 diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
625
626 -- * Disk replacement mode
627
628 replaceDiskAuto :: String
629 replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
630
631 replaceDiskChg :: String
632 replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
633
634 replaceDiskPri :: String
635 replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
636
637 replaceDiskSec :: String
638 replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
639
640 replaceModes :: FrozenSet String
641 replaceModes =
642   ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
643
644 -- * Instance export mode
645
646 exportModeLocal :: String
647 exportModeLocal = Types.exportModeToRaw ExportModeLocal
648
649 exportModeRemote :: String
650 exportModeRemote = Types.exportModeToRaw ExportModeRemote
651
652 exportModes :: FrozenSet String
653 exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
654
655 -- * Instance creation modes
656
657 instanceCreate :: String
658 instanceCreate = Types.instCreateModeToRaw InstCreate
659
660 instanceImport :: String
661 instanceImport = Types.instCreateModeToRaw InstImport
662
663 instanceRemoteImport :: String
664 instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
665
666 instanceCreateModes :: FrozenSet String
667 instanceCreateModes =
668   ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
669
670 -- * Dynamic device modification
671
672 ddmAdd :: String
673 ddmAdd = Types.ddmFullToRaw DdmFullAdd
674
675 ddmModify :: String
676 ddmModify = Types.ddmFullToRaw DdmFullModify
677
678 ddmRemove :: String
679 ddmRemove = Types.ddmFullToRaw DdmFullRemove
680
681 ddmsValues :: FrozenSet String
682 ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
683
684 ddmsValuesWithModify :: FrozenSet String
685 ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
686
687 -- * Common exit codes
688
689 exitSuccess :: Int
690 exitSuccess = 0
691
692 exitFailure :: Int
693 exitFailure = ConstantUtils.exitFailure
694
695 exitNotcluster :: Int
696 exitNotcluster = 5
697
698 exitNotmaster :: Int
699 exitNotmaster = 11
700
701 exitNodesetupError :: Int
702 exitNodesetupError = 12
703
704 -- | Need user confirmation
705 exitConfirmation :: Int
706 exitConfirmation = 13
707
708 -- | Exit code for query operations with unknown fields
709 exitUnknownField :: Int
710 exitUnknownField = 14
711
712 -- * Tags
713
714 tagCluster :: String
715 tagCluster = Types.tagKindToRaw TagKindCluster
716
717 tagInstance :: String
718 tagInstance = Types.tagKindToRaw TagKindInstance
719
720 tagNetwork :: String
721 tagNetwork = Types.tagKindToRaw TagKindNetwork
722
723 tagNode :: String
724 tagNode = Types.tagKindToRaw TagKindNode
725
726 tagNodegroup :: String
727 tagNodegroup = Types.tagKindToRaw TagKindGroup
728
729 validTagTypes :: FrozenSet String
730 validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
731
732 maxTagLen :: Int
733 maxTagLen = 128
734
735 maxTagsPerObj :: Int
736 maxTagsPerObj = 4096
737
738 -- | Node clock skew in seconds
739 nodeMaxClockSkew :: Int
740 nodeMaxClockSkew = 150
741
742 -- | Disk index separator
743 diskSeparator :: String
744 diskSeparator = AutoConf.diskSeparator
745
746 -- * Timeout table
747 --
748 -- Various time constants for the timeout table
749
750 rpcTmoUrgent :: Int
751 rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
752
753 rpcTmoFast :: Int
754 rpcTmoFast = Types.rpcTimeoutToRaw Fast
755
756 rpcTmoNormal :: Int
757 rpcTmoNormal = Types.rpcTimeoutToRaw Normal
758
759 rpcTmoSlow :: Int
760 rpcTmoSlow = Types.rpcTimeoutToRaw Slow
761
762 -- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
763 -- in the 'Ganeti.THH.deCamelCase' function and generate the correct
764 -- Python name.
765 rpcTmo_4hrs :: Int
766 rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
767
768 -- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
769 -- in the 'Ganeti.THH.deCamelCase' function and generate the correct
770 -- Python name.
771 rpcTmo_1day :: Int
772 rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
773
774 -- | Timeout for connecting to nodes (seconds)
775 rpcConnectTimeout :: Int
776 rpcConnectTimeout = 5
777
778 -- * VTypes
779
780 vtypeBool :: VType
781 vtypeBool = VTypeBool
782
783 vtypeInt :: VType
784 vtypeInt = VTypeInt
785
786 vtypeMaybeString :: VType
787 vtypeMaybeString = VTypeMaybeString
788
789 -- | Size in MiBs
790 vtypeSize :: VType
791 vtypeSize = VTypeSize
792
793 vtypeString :: VType
794 vtypeString = VTypeString
795
796 enforceableTypes :: FrozenSet VType
797 enforceableTypes = ConstantUtils.mkSet [minBound..]
798
799 -- | Instance specs
800 --
801 -- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
802
803 ispecMemSize :: String
804 ispecMemSize = ConstantUtils.ispecMemSize
805
806 ispecCpuCount :: String
807 ispecCpuCount = ConstantUtils.ispecCpuCount
808
809 ispecDiskCount :: String
810 ispecDiskCount = ConstantUtils.ispecDiskCount
811
812 ispecDiskSize :: String
813 ispecDiskSize = ConstantUtils.ispecDiskSize
814
815 ispecNicCount :: String
816 ispecNicCount = ConstantUtils.ispecNicCount
817
818 ispecSpindleUse :: String
819 ispecSpindleUse = ConstantUtils.ispecSpindleUse
820
821 ispecsParameterTypes :: Map String VType
822 ispecsParameterTypes =
823   Map.fromList
824   [(ConstantUtils.ispecDiskSize, VTypeInt),
825    (ConstantUtils.ispecCpuCount, VTypeInt),
826    (ConstantUtils.ispecSpindleUse, VTypeInt),
827    (ConstantUtils.ispecMemSize, VTypeInt),
828    (ConstantUtils.ispecNicCount, VTypeInt),
829    (ConstantUtils.ispecDiskCount, VTypeInt)]
830
831 ispecsParameters :: FrozenSet String
832 ispecsParameters =
833   ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
834                        ConstantUtils.ispecDiskCount,
835                        ConstantUtils.ispecDiskSize,
836                        ConstantUtils.ispecMemSize,
837                        ConstantUtils.ispecNicCount,
838                        ConstantUtils.ispecSpindleUse]
839
840 ispecsMinmax :: String
841 ispecsMinmax = ConstantUtils.ispecsMinmax
842
843 ispecsMax :: String
844 ispecsMax = "max"
845
846 ispecsMin :: String
847 ispecsMin = "min"
848
849 ispecsStd :: String
850 ispecsStd = ConstantUtils.ispecsStd
851
852 ipolicyDts :: String
853 ipolicyDts = ConstantUtils.ipolicyDts
854
855 ipolicyVcpuRatio :: String
856 ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
857
858 ipolicySpindleRatio :: String
859 ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
860
861 ispecsMinmaxKeys :: FrozenSet String
862 ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
863
864 ipolicyParameters :: FrozenSet String
865 ipolicyParameters =
866   ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
867                        ConstantUtils.ipolicySpindleRatio]
868
869 ipolicyAllKeys :: FrozenSet String
870 ipolicyAllKeys =
871   ConstantUtils.union ipolicyParameters $
872   ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
873                        ConstantUtils.ispecsMinmax,
874                        ispecsStd]
875
876 -- | Node parameter names
877
878 ndExclusiveStorage :: String
879 ndExclusiveStorage = "exclusive_storage"
880
881 ndOobProgram :: String
882 ndOobProgram = "oob_program"
883
884 ndSpindleCount :: String
885 ndSpindleCount = "spindle_count"
886
887 ndOvs :: String
888 ndOvs = "ovs"
889
890 ndOvsLink :: String
891 ndOvsLink = "ovs_link"
892
893 ndOvsName :: String
894 ndOvsName = "ovs_name"
895
896 ndsParameterTypes :: Map String VType
897 ndsParameterTypes =
898   Map.fromList
899   [(ndExclusiveStorage, VTypeBool),
900    (ndOobProgram, VTypeString),
901    (ndOvs, VTypeBool),
902    (ndOvsLink, VTypeMaybeString),
903    (ndOvsName, VTypeMaybeString),
904    (ndSpindleCount, VTypeInt)]
905
906 ndsParameters :: FrozenSet String
907 ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
908
909 ndsParameterTitles :: Map String String
910 ndsParameterTitles =
911   Map.fromList
912   [(ndExclusiveStorage, "ExclusiveStorage"),
913    (ndOobProgram, "OutOfBandProgram"),
914    (ndOvs, "OpenvSwitch"),
915    (ndOvsLink, "OpenvSwitchLink"),
916    (ndOvsName, "OpenvSwitchName"),
917    (ndSpindleCount, "SpindleCount")]
918
919 ipCommandPath :: String
920 ipCommandPath = AutoConf.ipPath
921
922 -- * Reboot types
923
924 instanceRebootSoft :: String
925 instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
926
927 instanceRebootHard :: String
928 instanceRebootHard = Types.rebootTypeToRaw RebootHard
929
930 instanceRebootFull :: String
931 instanceRebootFull = Types.rebootTypeToRaw RebootFull
932
933 rebootTypes :: FrozenSet String
934 rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
935
936
937
938
939
940
941
942
943 -- * OOB supported commands
944
945 oobPowerOn :: String
946 oobPowerOn = Types.oobCommandToRaw OobPowerOn
947
948 oobPowerOff :: String
949 oobPowerOff = Types.oobCommandToRaw OobPowerOff
950
951 oobPowerCycle :: String
952 oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
953
954 oobPowerStatus :: String
955 oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
956
957 oobHealth :: String
958 oobHealth = Types.oobCommandToRaw OobHealth
959
960 oobCommands :: FrozenSet String
961 oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
962
963 oobPowerStatusPowered :: String
964 oobPowerStatusPowered = "powered"
965
966 -- | 60 seconds
967 oobTimeout :: Int
968 oobTimeout = 60
969
970 -- | 2 seconds
971 oobPowerDelay :: Double
972 oobPowerDelay = 2.0
973
974 oobStatusCritical :: String
975 oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
976
977 oobStatusOk :: String
978 oobStatusOk = Types.oobStatusToRaw OobStatusOk
979
980 oobStatusUnknown :: String
981 oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
982
983 oobStatusWarning :: String
984 oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
985
986 oobStatuses :: FrozenSet String
987 oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
988
989 -- * NIC_* constants are used inside the ganeti config
990
991 nicLink :: String
992 nicLink = "link"
993
994 nicMode :: String
995 nicMode = "mode"
996
997 nicVlan :: String
998 nicVlan = "vlan"
999
1000 nicModeBridged :: String
1001 nicModeBridged = Types.nICModeToRaw NMBridged
1002
1003 nicModeRouted :: String
1004 nicModeRouted = Types.nICModeToRaw NMRouted
1005
1006 nicModeOvs :: String
1007 nicModeOvs = Types.nICModeToRaw NMOvs
1008
1009 nicIpPool :: String
1010 nicIpPool = Types.nICModeToRaw NMPool
1011
1012 nicValidModes :: FrozenSet String
1013 nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
1014
1015 -- * Hypervisor constants
1016
1017 htXenPvm :: String
1018 htXenPvm = Types.hypervisorToRaw XenPvm
1019
1020 htFake :: String
1021 htFake = Types.hypervisorToRaw Fake
1022
1023 htXenHvm :: String
1024 htXenHvm = Types.hypervisorToRaw XenHvm
1025
1026 htKvm :: String
1027 htKvm = Types.hypervisorToRaw Kvm
1028
1029 htChroot :: String
1030 htChroot = Types.hypervisorToRaw Chroot
1031
1032 htLxc :: String
1033 htLxc = Types.hypervisorToRaw Lxc
1034
1035 hyperTypes :: FrozenSet String
1036 hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
1037
1038 htsReqPort :: FrozenSet String
1039 htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
1040
1041 -- * Migration type
1042
1043 htMigrationLive :: String
1044 htMigrationLive = Types.migrationModeToRaw MigrationLive
1045
1046 htMigrationNonlive :: String
1047 htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
1048
1049 htMigrationModes :: FrozenSet String
1050 htMigrationModes =
1051   ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
1052
1053 -- * Cluster verify steps
1054
1055 verifyNplusoneMem :: String
1056 verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
1057
1058 verifyOptionalChecks :: FrozenSet String
1059 verifyOptionalChecks =
1060   ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
1061
1062 -- * Cluster Verify error classes
1063
1064 cvTcluster :: String
1065 cvTcluster = "cluster"
1066
1067 cvTgroup :: String
1068 cvTgroup = "group"
1069
1070 cvTnode :: String
1071 cvTnode = "node"
1072
1073 cvTinstance :: String
1074 cvTinstance = "instance"
1075
1076 -- * Cluster Verify error codes and documentation
1077
1078 cvEclustercert :: (String, String, String)
1079 cvEclustercert =
1080   ("cluster",
1081    Types.cVErrorCodeToRaw CvECLUSTERCERT,
1082    "Cluster certificate files verification failure")
1083
1084 cvEclustercfg :: (String, String, String)
1085 cvEclustercfg =
1086   ("cluster",
1087    Types.cVErrorCodeToRaw CvECLUSTERCFG,
1088    "Cluster configuration verification failure")
1089
1090 cvEclusterdanglinginst :: (String, String, String)
1091 cvEclusterdanglinginst =
1092   ("node",
1093    Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
1094    "Some instances have a non-existing primary node")
1095
1096 cvEclusterdanglingnodes :: (String, String, String)
1097 cvEclusterdanglingnodes =
1098   ("node",
1099    Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
1100    "Some nodes belong to non-existing groups")
1101
1102 cvEclusterfilecheck :: (String, String, String)
1103 cvEclusterfilecheck =
1104   ("cluster",
1105    Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
1106    "Cluster configuration verification failure")
1107
1108 cvEgroupdifferentpvsize :: (String, String, String)
1109 cvEgroupdifferentpvsize =
1110   ("group",
1111    Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
1112    "PVs in the group have different sizes")
1113
1114 cvEinstancebadnode :: (String, String, String)
1115 cvEinstancebadnode =
1116   ("instance",
1117    Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
1118    "Instance marked as running lives on an offline node")
1119
1120 cvEinstancedown :: (String, String, String)
1121 cvEinstancedown =
1122   ("instance",
1123    Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
1124    "Instance not running on its primary node")
1125
1126 cvEinstancefaultydisk :: (String, String, String)
1127 cvEinstancefaultydisk =
1128   ("instance",
1129    Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
1130    "Impossible to retrieve status for a disk")
1131
1132 cvEinstancelayout :: (String, String, String)
1133 cvEinstancelayout =
1134   ("instance",
1135    Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
1136    "Instance has multiple secondary nodes")
1137
1138 cvEinstancemissingcfgparameter :: (String, String, String)
1139 cvEinstancemissingcfgparameter =
1140   ("instance",
1141    Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
1142    "A configuration parameter for an instance is missing")
1143
1144 cvEinstancemissingdisk :: (String, String, String)
1145 cvEinstancemissingdisk =
1146   ("instance",
1147    Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
1148    "Missing volume on an instance")
1149
1150 cvEinstancepolicy :: (String, String, String)
1151 cvEinstancepolicy =
1152   ("instance",
1153    Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
1154    "Instance does not meet policy")
1155
1156 cvEinstancesplitgroups :: (String, String, String)
1157 cvEinstancesplitgroups =
1158   ("instance",
1159    Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
1160    "Instance with primary and secondary nodes in different groups")
1161
1162 cvEinstanceunsuitablenode :: (String, String, String)
1163 cvEinstanceunsuitablenode =
1164   ("instance",
1165    Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
1166    "Instance running on nodes that are not suitable for it")
1167
1168 cvEinstancewrongnode :: (String, String, String)
1169 cvEinstancewrongnode =
1170   ("instance",
1171    Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
1172    "Instance running on the wrong node")
1173
1174 cvEnodedrbd :: (String, String, String)
1175 cvEnodedrbd =
1176   ("node",
1177    Types.cVErrorCodeToRaw CvENODEDRBD,
1178    "Error parsing the DRBD status file")
1179
1180 cvEnodedrbdhelper :: (String, String, String)
1181 cvEnodedrbdhelper =
1182   ("node",
1183    Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
1184    "Error caused by the DRBD helper")
1185
1186 cvEnodedrbdversion :: (String, String, String)
1187 cvEnodedrbdversion =
1188   ("node",
1189    Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
1190    "DRBD version mismatch within a node group")
1191
1192 cvEnodefilecheck :: (String, String, String)
1193 cvEnodefilecheck =
1194   ("node",
1195    Types.cVErrorCodeToRaw CvENODEFILECHECK,
1196    "Error retrieving the checksum of the node files")
1197
1198 cvEnodefilestoragepaths :: (String, String, String)
1199 cvEnodefilestoragepaths =
1200   ("node",
1201    Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
1202    "Detected bad file storage paths")
1203
1204 cvEnodefilestoragepathunusable :: (String, String, String)
1205 cvEnodefilestoragepathunusable =
1206   ("node",
1207    Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
1208    "File storage path unusable")
1209
1210 cvEnodehooks :: (String, String, String)
1211 cvEnodehooks =
1212   ("node",
1213    Types.cVErrorCodeToRaw CvENODEHOOKS,
1214    "Communication failure in hooks execution")
1215
1216 cvEnodehv :: (String, String, String)
1217 cvEnodehv =
1218   ("node",
1219    Types.cVErrorCodeToRaw CvENODEHV,
1220    "Hypervisor parameters verification failure")
1221
1222 cvEnodelvm :: (String, String, String)
1223 cvEnodelvm =
1224   ("node",
1225    Types.cVErrorCodeToRaw CvENODELVM,
1226    "LVM-related node error")
1227
1228 cvEnoden1 :: (String, String, String)
1229 cvEnoden1 =
1230   ("node",
1231    Types.cVErrorCodeToRaw CvENODEN1,
1232    "Not enough memory to accommodate instance failovers")
1233
1234 cvEnodenet :: (String, String, String)
1235 cvEnodenet =
1236   ("node",
1237    Types.cVErrorCodeToRaw CvENODENET,
1238    "Network-related node error")
1239
1240 cvEnodeoobpath :: (String, String, String)
1241 cvEnodeoobpath =
1242   ("node",
1243    Types.cVErrorCodeToRaw CvENODEOOBPATH,
1244    "Invalid Out Of Band path")
1245
1246 cvEnodeorphaninstance :: (String, String, String)
1247 cvEnodeorphaninstance =
1248   ("node",
1249    Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
1250    "Unknown intance running on a node")
1251
1252 cvEnodeorphanlv :: (String, String, String)
1253 cvEnodeorphanlv =
1254   ("node",
1255    Types.cVErrorCodeToRaw CvENODEORPHANLV,
1256    "Unknown LVM logical volume")
1257
1258 cvEnodeos :: (String, String, String)
1259 cvEnodeos =
1260   ("node",
1261    Types.cVErrorCodeToRaw CvENODEOS,
1262    "OS-related node error")
1263
1264 cvEnoderpc :: (String, String, String)
1265 cvEnoderpc =
1266   ("node",
1267    Types.cVErrorCodeToRaw CvENODERPC,
1268    "Error during connection to the primary node of an instance")
1269
1270 cvEnodesetup :: (String, String, String)
1271 cvEnodesetup =
1272   ("node",
1273    Types.cVErrorCodeToRaw CvENODESETUP,
1274    "Node setup error")
1275
1276 cvEnodesharedfilestoragepathunusable :: (String, String, String)
1277 cvEnodesharedfilestoragepathunusable =
1278   ("node",
1279    Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
1280    "Shared file storage path unusable")
1281
1282 cvEnodessh :: (String, String, String)
1283 cvEnodessh =
1284   ("node",
1285    Types.cVErrorCodeToRaw CvENODESSH,
1286    "SSH-related node error")
1287
1288 cvEnodetime :: (String, String, String)
1289 cvEnodetime =
1290   ("node",
1291    Types.cVErrorCodeToRaw CvENODETIME,
1292    "Node returned invalid time")
1293
1294 cvEnodeuserscripts :: (String, String, String)
1295 cvEnodeuserscripts =
1296   ("node",
1297    Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
1298    "User scripts not present or not executable")
1299
1300 cvEnodeversion :: (String, String, String)
1301 cvEnodeversion =
1302   ("node",
1303    Types.cVErrorCodeToRaw CvENODEVERSION,
1304    "Protocol version mismatch or Ganeti version mismatch")
1305
1306 cvAllEcodes :: FrozenSet (String, String, String)
1307 cvAllEcodes =
1308   ConstantUtils.mkSet
1309   [cvEclustercert,
1310    cvEclustercfg,
1311    cvEclusterdanglinginst,
1312    cvEclusterdanglingnodes,
1313    cvEclusterfilecheck,
1314    cvEgroupdifferentpvsize,
1315    cvEinstancebadnode,
1316    cvEinstancedown,
1317    cvEinstancefaultydisk,
1318    cvEinstancelayout,
1319    cvEinstancemissingcfgparameter,
1320    cvEinstancemissingdisk,
1321    cvEinstancepolicy,
1322    cvEinstancesplitgroups,
1323    cvEinstanceunsuitablenode,
1324    cvEinstancewrongnode,
1325    cvEnodedrbd,
1326    cvEnodedrbdhelper,
1327    cvEnodedrbdversion,
1328    cvEnodefilecheck,
1329    cvEnodefilestoragepaths,
1330    cvEnodefilestoragepathunusable,
1331    cvEnodehooks,
1332    cvEnodehv,
1333    cvEnodelvm,
1334    cvEnoden1,
1335    cvEnodenet,
1336    cvEnodeoobpath,
1337    cvEnodeorphaninstance,
1338    cvEnodeorphanlv,
1339    cvEnodeos,
1340    cvEnoderpc,
1341    cvEnodesetup,
1342    cvEnodesharedfilestoragepathunusable,
1343    cvEnodessh,
1344    cvEnodetime,
1345    cvEnodeuserscripts,
1346    cvEnodeversion]
1347
1348 cvAllEcodesStrings :: FrozenSet String
1349 cvAllEcodesStrings =
1350   ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
1351
1352 -- * Instance status
1353
1354 inststAdmindown :: String
1355 inststAdmindown = Types.instanceStatusToRaw StatusDown
1356
1357 inststAdminoffline :: String
1358 inststAdminoffline = Types.instanceStatusToRaw StatusOffline
1359
1360 inststErrordown :: String
1361 inststErrordown = Types.instanceStatusToRaw ErrorDown
1362
1363 inststErrorup :: String
1364 inststErrorup = Types.instanceStatusToRaw ErrorUp
1365
1366 inststNodedown :: String
1367 inststNodedown = Types.instanceStatusToRaw NodeDown
1368
1369 inststNodeoffline :: String
1370 inststNodeoffline = Types.instanceStatusToRaw NodeOffline
1371
1372 inststRunning :: String
1373 inststRunning = Types.instanceStatusToRaw Running
1374
1375 inststWrongnode :: String
1376 inststWrongnode = Types.instanceStatusToRaw WrongNode
1377
1378 inststAll :: FrozenSet String
1379 inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
1380
1381 -- * Admin states
1382
1383 adminstDown :: String
1384 adminstDown = Types.adminStateToRaw AdminDown
1385
1386 adminstOffline :: String
1387 adminstOffline = Types.adminStateToRaw AdminOffline
1388
1389 adminstUp :: String
1390 adminstUp = Types.adminStateToRaw AdminUp
1391
1392 adminstAll :: FrozenSet String
1393 adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
1394
1395 -- * Node roles
1396
1397 nrDrained :: String
1398 nrDrained = Types.nodeRoleToRaw NRDrained
1399
1400 nrMaster :: String
1401 nrMaster = Types.nodeRoleToRaw NRMaster
1402
1403 nrMcandidate :: String
1404 nrMcandidate = Types.nodeRoleToRaw NRCandidate
1405
1406 nrOffline :: String
1407 nrOffline = Types.nodeRoleToRaw NROffline
1408
1409 nrRegular :: String
1410 nrRegular = Types.nodeRoleToRaw NRRegular
1411
1412 nrAll :: FrozenSet String
1413 nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
1414
1415 -- * Allocator framework constants
1416
1417 iallocatorVersion :: Int
1418 iallocatorVersion = 2
1419
1420 iallocatorDirIn :: String
1421 iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
1422
1423 iallocatorDirOut :: String
1424 iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
1425
1426 validIallocatorDirections :: FrozenSet String
1427 validIallocatorDirections =
1428   ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
1429
1430 iallocatorModeAlloc :: String
1431 iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
1432
1433 iallocatorModeChgGroup :: String
1434 iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
1435
1436 iallocatorModeMultiAlloc :: String
1437 iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
1438
1439 iallocatorModeNodeEvac :: String
1440 iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
1441
1442 iallocatorModeReloc :: String
1443 iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
1444
1445 validIallocatorModes :: FrozenSet String
1446 validIallocatorModes =
1447   ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
1448
1449 iallocatorSearchPath :: [String]
1450 iallocatorSearchPath = AutoConf.iallocatorSearchPath
1451
1452 defaultIallocatorShortcut :: String
1453 defaultIallocatorShortcut = "."
1454
1455 -- * Node evacuation
1456
1457 nodeEvacPri :: String
1458 nodeEvacPri = Types.evacModeToRaw ChangePrimary
1459
1460 nodeEvacSec :: String
1461 nodeEvacSec = Types.evacModeToRaw ChangeSecondary
1462
1463 nodeEvacAll :: String
1464 nodeEvacAll = Types.evacModeToRaw ChangeAll
1465
1466 nodeEvacModes :: FrozenSet String
1467 nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
1468
1469 -- * Job status
1470
1471 jobStatusQueued :: String
1472 jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
1473
1474 jobStatusWaiting :: String
1475 jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
1476
1477 jobStatusCanceling :: String
1478 jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
1479
1480 jobStatusRunning :: String
1481 jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
1482
1483 jobStatusCanceled :: String
1484 jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
1485
1486 jobStatusSuccess :: String
1487 jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
1488
1489 jobStatusError :: String
1490 jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
1491
1492 jobsPending :: FrozenSet String
1493 jobsPending =
1494   ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
1495
1496 jobsFinalized :: FrozenSet String
1497 jobsFinalized =
1498   ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
1499
1500 jobStatusAll :: FrozenSet String
1501 jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
1502
1503 -- * OpCode status
1504
1505 -- ** Not yet finalized opcodes
1506
1507 opStatusCanceling :: String
1508 opStatusCanceling = "canceling"
1509
1510 opStatusQueued :: String
1511 opStatusQueued = "queued"
1512
1513 opStatusRunning :: String
1514 opStatusRunning = "running"
1515
1516 opStatusWaiting :: String
1517 opStatusWaiting = "waiting"
1518
1519 -- ** Finalized opcodes
1520
1521 opStatusCanceled :: String
1522 opStatusCanceled = "canceled"
1523
1524 opStatusError :: String
1525 opStatusError = "error"
1526
1527 opStatusSuccess :: String
1528 opStatusSuccess = "success"
1529
1530 opsFinalized :: FrozenSet String
1531 opsFinalized =
1532   ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
1533
1534 -- * OpCode priority
1535
1536 opPrioLowest :: Int
1537 opPrioLowest = 19
1538
1539 opPrioHighest :: Int
1540 opPrioHighest = -20
1541
1542 opPrioLow :: Int
1543 opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
1544
1545 opPrioNormal :: Int
1546 opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
1547
1548 opPrioHigh :: Int
1549 opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
1550
1551 opPrioSubmitValid :: FrozenSet Int
1552 opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
1553
1554 opPrioDefault :: Int
1555 opPrioDefault = opPrioNormal
1556
1557 -- * Execution log types
1558
1559 elogMessage :: String
1560 elogMessage = Types.eLogTypeToRaw ELogMessage
1561
1562 elogRemoteImport :: String
1563 elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
1564
1565 elogJqueueTest :: String
1566 elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
1567
1568 -- * Confd
1569
1570 confdProtocolVersion :: Int
1571 confdProtocolVersion = ConstantUtils.confdProtocolVersion
1572
1573 -- Confd request type
1574
1575 confdReqPing :: Int
1576 confdReqPing = Types.confdRequestTypeToRaw ReqPing
1577
1578 confdReqNodeRoleByname :: Int
1579 confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
1580
1581 confdReqNodePipByInstanceIp :: Int
1582 confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
1583
1584 confdReqClusterMaster :: Int
1585 confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
1586
1587 confdReqNodePipList :: Int
1588 confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
1589
1590 confdReqMcPipList :: Int
1591 confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
1592
1593 confdReqInstancesIpsList :: Int
1594 confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
1595
1596 confdReqNodeDrbd :: Int
1597 confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
1598
1599 confdReqNodeInstances :: Int
1600 confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
1601
1602 confdReqs :: FrozenSet Int
1603 confdReqs =
1604   ConstantUtils.mkSet .
1605   map Types.confdRequestTypeToRaw $
1606   [minBound..] \\ [ReqNodeInstances]
1607
1608 -- * Confd request type
1609
1610 confdReqfieldName :: Int
1611 confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
1612
1613 confdReqfieldIp :: Int
1614 confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
1615
1616 confdReqfieldMnodePip :: Int
1617 confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
1618
1619 -- * Confd repl status
1620
1621 confdReplStatusOk :: Int
1622 confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
1623
1624 confdReplStatusError :: Int
1625 confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
1626
1627 confdReplStatusNotimplemented :: Int
1628 confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
1629
1630 confdReplStatuses :: FrozenSet Int
1631 confdReplStatuses =
1632   ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
1633
1634 -- * Confd node role
1635
1636 confdNodeRoleMaster :: Int
1637 confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
1638
1639 confdNodeRoleCandidate :: Int
1640 confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
1641
1642 confdNodeRoleOffline :: Int
1643 confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
1644
1645 confdNodeRoleDrained :: Int
1646 confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
1647
1648 confdNodeRoleRegular :: Int
1649 confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
1650
1651 -- * A few common errors for confd
1652
1653 confdErrorUnknownEntry :: Int
1654 confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
1655
1656 confdErrorInternal :: Int
1657 confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
1658
1659 confdErrorArgument :: Int
1660 confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
1661
1662 -- * Confd request query fields
1663
1664 confdReqqLink :: String
1665 confdReqqLink = ConstantUtils.confdReqqLink
1666
1667 confdReqqIp :: String
1668 confdReqqIp = ConstantUtils.confdReqqIp
1669
1670 confdReqqIplist :: String
1671 confdReqqIplist = ConstantUtils.confdReqqIplist
1672
1673 confdReqqFields :: String
1674 confdReqqFields = ConstantUtils.confdReqqFields
1675
1676 -- | Each request is "salted" by the current timestamp.
1677 --
1678 -- This constant decides how many seconds of skew to accept.
1679 --
1680 -- TODO: make this a default and allow the value to be more
1681 -- configurable
1682 confdMaxClockSkew :: Int
1683 confdMaxClockSkew = 2 * nodeMaxClockSkew
1684
1685 -- | When we haven't reloaded the config for more than this amount of
1686 -- seconds, we force a test to see if inotify is betraying us. Using a
1687 -- prime number to ensure we get less chance of 'same wakeup' with
1688 -- other processes.
1689 confdConfigReloadTimeout :: Int
1690 confdConfigReloadTimeout = 17
1691
1692 -- | If we receive more than one update in this amount of
1693 -- microseconds, we move to polling every RATELIMIT seconds, rather
1694 -- than relying on inotify, to be able to serve more requests.
1695 confdConfigReloadRatelimit :: Int
1696 confdConfigReloadRatelimit = 250000
1697
1698 -- | Magic number prepended to all confd queries.
1699 --
1700 -- This allows us to distinguish different types of confd protocols
1701 -- and handle them. For example by changing this we can move the whole
1702 -- payload to be compressed, or move away from json.
1703 confdMagicFourcc :: String
1704 confdMagicFourcc = "plj0"
1705
1706 -- | By default a confd request is sent to the minimum between this
1707 -- number and all MCs. 6 was chosen because even in the case of a
1708 -- disastrous 50% response rate, we should have enough answers to be
1709 -- able to compare more than one.
1710 confdDefaultReqCoverage :: Int
1711 confdDefaultReqCoverage = 6
1712
1713 -- | Timeout in seconds to expire pending query request in the confd
1714 -- client library. We don't actually expect any answer more than 10
1715 -- seconds after we sent a request.
1716 confdClientExpireTimeout :: Int
1717 confdClientExpireTimeout = 10
1718
1719 -- * Possible values for NodeGroup.alloc_policy
1720
1721 allocPolicyLastResort :: String
1722 allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
1723
1724 allocPolicyPreferred :: String
1725 allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
1726
1727 allocPolicyUnallocable :: String
1728 allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
1729
1730 validAllocPolicies :: [String]
1731 validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
1732
1733 -- | Temporary external/shared storage parameters
1734 blockdevDriverManual :: String
1735 blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
1736
1737 -- | 'qemu-img' path, required for 'ovfconverter'
1738 qemuimgPath :: String
1739 qemuimgPath = AutoConf.qemuimgPath
1740
1741 -- | Whether htools was enabled at compilation time
1742 --
1743 -- FIXME: this should be moved next to the other enable constants,
1744 -- such as, 'enableConfd', and renamed to 'enableHtools'.
1745 htools :: Bool
1746 htools = AutoConf.htools
1747
1748 -- * Key files for SSH daemon
1749
1750 sshHostDsaPriv :: String
1751 sshHostDsaPriv = sshConfigDir ++ "/ssh_host_dsa_key"
1752
1753 sshHostDsaPub :: String
1754 sshHostDsaPub = sshHostDsaPriv ++ ".pub"
1755
1756 sshHostRsaPriv :: String
1757 sshHostRsaPriv = sshConfigDir ++ "/ssh_host_rsa_key"
1758
1759 sshHostRsaPub :: String
1760 sshHostRsaPub = sshHostRsaPriv ++ ".pub"
1761
1762 -- | Path generating random UUID
1763 randomUuidFile :: String
1764 randomUuidFile = ConstantUtils.randomUuidFile
1765
1766 -- * Auto-repair tag prefixes
1767
1768 autoRepairTagPrefix :: String
1769 autoRepairTagPrefix = "ganeti:watcher:autorepair:"
1770
1771 autoRepairTagEnabled :: String
1772 autoRepairTagEnabled = autoRepairTagPrefix
1773
1774 autoRepairTagPending :: String
1775 autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
1776
1777 autoRepairTagResult :: String
1778 autoRepairTagResult = autoRepairTagPrefix ++ "result:"
1779
1780 autoRepairTagSuspended :: String
1781 autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
1782
1783 -- * Auto-repair levels
1784
1785 autoRepairFailover :: String
1786 autoRepairFailover = "failover"
1787
1788 autoRepairFixStorage :: String
1789 autoRepairFixStorage = "fix-storage"
1790
1791 autoRepairMigrate :: String
1792 autoRepairMigrate = "migrate"
1793
1794 autoRepairReinstall :: String
1795 autoRepairReinstall = "reinstall"
1796
1797 autoRepairAllTypes :: FrozenSet String
1798 autoRepairAllTypes =
1799   ConstantUtils.mkSet [autoRepairFailover,
1800                        autoRepairFixStorage,
1801                        autoRepairMigrate,
1802                        autoRepairReinstall]
1803
1804 -- * Auto-repair results
1805
1806 autoRepairEnoperm :: String
1807 autoRepairEnoperm = "enoperm"
1808
1809 autoRepairFailure :: String
1810 autoRepairFailure = "failure"
1811
1812 autoRepairSuccess :: String
1813 autoRepairSuccess = "success"
1814
1815 autoRepairAllResults :: FrozenSet String
1816 autoRepairAllResults =
1817   ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
1818
1819 -- | The version identifier for builtin data collectors
1820 builtinDataCollectorVersion :: String
1821 builtinDataCollectorVersion = "B"
1822
1823 -- | The reason trail opcode parameter name
1824 opcodeReason :: String
1825 opcodeReason = "reason"
1826
1827 diskstatsFile :: String
1828 diskstatsFile = "/proc/diskstats"
1829
1830 -- *  CPU load collector
1831
1832 statFile :: String
1833 statFile = "/proc/stat"
1834
1835 cpuavgloadBufferSize :: Int
1836 cpuavgloadBufferSize = 150
1837
1838 cpuavgloadWindowSize :: Int
1839 cpuavgloadWindowSize = 600
1840
1841 -- | Mond's variable for periodical data collection
1842 mondTimeInterval :: Int
1843 mondTimeInterval = 5
1844
1845 -- * Disk access modes
1846
1847 diskUserspace :: String
1848 diskUserspace = Types.diskAccessModeToRaw DiskUserspace
1849
1850 diskKernelspace :: String
1851 diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
1852
1853 diskValidAccessModes :: FrozenSet String
1854 diskValidAccessModes =
1855   ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
1856
1857 -- | Timeout for queue draining in upgrades
1858 upgradeQueueDrainTimeout :: Int
1859 upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
1860
1861 -- | Intervall at which the queue is polled during upgrades
1862 upgradeQueuePollInterval :: Int
1863 upgradeQueuePollInterval  = 10