4bd913927a2b529c19f12e3277a6efd14a1e6879
[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 -- * File backend driver
534
535 fdBlktap :: String
536 fdBlktap = Types.fileDriverToRaw FileBlktap
537
538 fdLoop :: String
539 fdLoop = Types.fileDriverToRaw FileLoop
540
541 fileDriver :: FrozenSet String
542 fileDriver =
543   ConstantUtils.mkSet $
544   map Types.fileDriverToRaw [minBound..]
545
546 -- | The set of drbd-like disk types
547 ldsDrbd :: FrozenSet String
548 ldsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
549
550 -- * Disk access mode
551
552 diskRdonly :: String
553 diskRdonly = Types.diskModeToRaw DiskRdOnly
554
555 diskRdwr :: String
556 diskRdwr = Types.diskModeToRaw DiskRdWr
557
558 diskAccessSet :: FrozenSet String
559 diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
560
561 -- * Disk replacement mode
562
563 replaceDiskAuto :: String
564 replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
565
566 replaceDiskChg :: String
567 replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
568
569 replaceDiskPri :: String
570 replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
571
572 replaceDiskSec :: String
573 replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
574
575 replaceModes :: FrozenSet String
576 replaceModes =
577   ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
578
579 -- * Instance export mode
580
581 exportModeLocal :: String
582 exportModeLocal = Types.exportModeToRaw ExportModeLocal
583
584 exportModeRemote :: String
585 exportModeRemote = Types.exportModeToRaw ExportModeRemote
586
587 exportModes :: FrozenSet String
588 exportModes = ConstantUtils.mkSet $ map Types.exportModeToRaw [minBound..]
589
590 -- * Instance creation modes
591
592 instanceCreate :: String
593 instanceCreate = Types.instCreateModeToRaw InstCreate
594
595 instanceImport :: String
596 instanceImport = Types.instCreateModeToRaw InstImport
597
598 instanceRemoteImport :: String
599 instanceRemoteImport = Types.instCreateModeToRaw InstRemoteImport
600
601 instanceCreateModes :: FrozenSet String
602 instanceCreateModes =
603   ConstantUtils.mkSet $ map Types.instCreateModeToRaw [minBound..]
604
605 -- * Dynamic device modification
606
607 ddmAdd :: String
608 ddmAdd = Types.ddmFullToRaw DdmFullAdd
609
610 ddmModify :: String
611 ddmModify = Types.ddmFullToRaw DdmFullModify
612
613 ddmRemove :: String
614 ddmRemove = Types.ddmFullToRaw DdmFullRemove
615
616 ddmsValues :: FrozenSet String
617 ddmsValues = ConstantUtils.mkSet [ddmAdd, ddmRemove]
618
619 ddmsValuesWithModify :: FrozenSet String
620 ddmsValuesWithModify = ConstantUtils.mkSet $ map Types.ddmFullToRaw [minBound..]
621
622 -- * Common exit codes
623
624 exitSuccess :: Int
625 exitSuccess = 0
626
627 exitFailure :: Int
628 exitFailure = ConstantUtils.exitFailure
629
630 exitNotcluster :: Int
631 exitNotcluster = 5
632
633 exitNotmaster :: Int
634 exitNotmaster = 11
635
636 exitNodesetupError :: Int
637 exitNodesetupError = 12
638
639 -- | Need user confirmation
640 exitConfirmation :: Int
641 exitConfirmation = 13
642
643 -- | Exit code for query operations with unknown fields
644 exitUnknownField :: Int
645 exitUnknownField = 14
646
647 -- * Tags
648
649 tagCluster :: String
650 tagCluster = Types.tagKindToRaw TagKindCluster
651
652 tagInstance :: String
653 tagInstance = Types.tagKindToRaw TagKindInstance
654
655 tagNetwork :: String
656 tagNetwork = Types.tagKindToRaw TagKindNetwork
657
658 tagNode :: String
659 tagNode = Types.tagKindToRaw TagKindNode
660
661 tagNodegroup :: String
662 tagNodegroup = Types.tagKindToRaw TagKindGroup
663
664 validTagTypes :: FrozenSet String
665 validTagTypes = ConstantUtils.mkSet $ map Types.tagKindToRaw [minBound..]
666
667 maxTagLen :: Int
668 maxTagLen = 128
669
670 maxTagsPerObj :: Int
671 maxTagsPerObj = 4096
672
673 -- | Node clock skew in seconds
674 nodeMaxClockSkew :: Int
675 nodeMaxClockSkew = 150
676
677 -- | Disk index separator
678 diskSeparator :: String
679 diskSeparator = AutoConf.diskSeparator
680
681 -- * Timeout table
682 --
683 -- Various time constants for the timeout table
684
685 rpcTmoUrgent :: Int
686 rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent
687
688 rpcTmoFast :: Int
689 rpcTmoFast = Types.rpcTimeoutToRaw Fast
690
691 rpcTmoNormal :: Int
692 rpcTmoNormal = Types.rpcTimeoutToRaw Normal
693
694 rpcTmoSlow :: Int
695 rpcTmoSlow = Types.rpcTimeoutToRaw Slow
696
697 -- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation
698 -- in the 'Ganeti.THH.deCamelCase' function and generate the correct
699 -- Python name.
700 rpcTmo_4hrs :: Int
701 rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours
702
703 -- | 'rpcTmo_1day' contains an underscore to circumvent a limitation
704 -- in the 'Ganeti.THH.deCamelCase' function and generate the correct
705 -- Python name.
706 rpcTmo_1day :: Int
707 rpcTmo_1day = Types.rpcTimeoutToRaw OneDay
708
709 -- | Timeout for connecting to nodes (seconds)
710 rpcConnectTimeout :: Int
711 rpcConnectTimeout = 5
712
713
714 -- | Instance specs
715 --
716 -- FIXME: these should be associated with 'Ganeti.HTools.Types.ISpec'
717
718 ispecMemSize :: String
719 ispecMemSize = ConstantUtils.ispecMemSize
720
721 ispecCpuCount :: String
722 ispecCpuCount = ConstantUtils.ispecCpuCount
723
724 ispecDiskCount :: String
725 ispecDiskCount = ConstantUtils.ispecDiskCount
726
727 ispecDiskSize :: String
728 ispecDiskSize = ConstantUtils.ispecDiskSize
729
730 ispecNicCount :: String
731 ispecNicCount = ConstantUtils.ispecNicCount
732
733 ispecSpindleUse :: String
734 ispecSpindleUse = ConstantUtils.ispecSpindleUse
735
736 ispecsParameterTypes :: Map String VType
737 ispecsParameterTypes =
738   Map.fromList
739   [(ConstantUtils.ispecDiskSize, VTypeInt),
740    (ConstantUtils.ispecCpuCount, VTypeInt),
741    (ConstantUtils.ispecSpindleUse, VTypeInt),
742    (ConstantUtils.ispecMemSize, VTypeInt),
743    (ConstantUtils.ispecNicCount, VTypeInt),
744    (ConstantUtils.ispecDiskCount, VTypeInt)]
745
746 ispecsParameters :: FrozenSet String
747 ispecsParameters =
748   ConstantUtils.mkSet [ConstantUtils.ispecCpuCount,
749                        ConstantUtils.ispecDiskCount,
750                        ConstantUtils.ispecDiskSize,
751                        ConstantUtils.ispecMemSize,
752                        ConstantUtils.ispecNicCount,
753                        ConstantUtils.ispecSpindleUse]
754
755 ispecsMinmax :: String
756 ispecsMinmax = ConstantUtils.ispecsMinmax
757
758 ispecsMax :: String
759 ispecsMax = "max"
760
761 ispecsMin :: String
762 ispecsMin = "min"
763
764 ispecsStd :: String
765 ispecsStd = ConstantUtils.ispecsStd
766
767 ipolicyDts :: String
768 ipolicyDts = ConstantUtils.ipolicyDts
769
770 ipolicyVcpuRatio :: String
771 ipolicyVcpuRatio = ConstantUtils.ipolicyVcpuRatio
772
773 ipolicySpindleRatio :: String
774 ipolicySpindleRatio = ConstantUtils.ipolicySpindleRatio
775
776 ispecsMinmaxKeys :: FrozenSet String
777 ispecsMinmaxKeys = ConstantUtils.mkSet [ispecsMax, ispecsMin]
778
779 ipolicyParameters :: FrozenSet String
780 ipolicyParameters =
781   ConstantUtils.mkSet [ConstantUtils.ipolicyVcpuRatio,
782                        ConstantUtils.ipolicySpindleRatio]
783
784 ipolicyAllKeys :: FrozenSet String
785 ipolicyAllKeys =
786   ConstantUtils.union ipolicyParameters $
787   ConstantUtils.mkSet [ConstantUtils.ipolicyDts,
788                        ConstantUtils.ispecsMinmax,
789                        ispecsStd]
790
791 -- | Node parameter names
792
793 ndExclusiveStorage :: String
794 ndExclusiveStorage = "exclusive_storage"
795
796 ndOobProgram :: String
797 ndOobProgram = "oob_program"
798
799 ndSpindleCount :: String
800 ndSpindleCount = "spindle_count"
801
802 ndOvs :: String
803 ndOvs = "ovs"
804
805 ndOvsLink :: String
806 ndOvsLink = "ovs_link"
807
808 ndOvsName :: String
809 ndOvsName = "ovs_name"
810
811 ndsParameterTypes :: Map String VType
812 ndsParameterTypes =
813   Map.fromList
814   [(ndExclusiveStorage, VTypeBool),
815    (ndOobProgram, VTypeString),
816    (ndOvs, VTypeBool),
817    (ndOvsLink, VTypeMaybeString),
818    (ndOvsName, VTypeMaybeString),
819    (ndSpindleCount, VTypeInt)]
820
821 ndsParameters :: FrozenSet String
822 ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
823
824 ndsParameterTitles :: Map String String
825 ndsParameterTitles =
826   Map.fromList
827   [(ndExclusiveStorage, "ExclusiveStorage"),
828    (ndOobProgram, "OutOfBandProgram"),
829    (ndOvs, "OpenvSwitch"),
830    (ndOvsLink, "OpenvSwitchLink"),
831    (ndOvsName, "OpenvSwitchName"),
832    (ndSpindleCount, "SpindleCount")]
833
834 ipCommandPath :: String
835 ipCommandPath = AutoConf.ipPath
836
837 -- * Reboot types
838
839 instanceRebootSoft :: String
840 instanceRebootSoft = Types.rebootTypeToRaw RebootSoft
841
842 instanceRebootHard :: String
843 instanceRebootHard = Types.rebootTypeToRaw RebootHard
844
845 instanceRebootFull :: String
846 instanceRebootFull = Types.rebootTypeToRaw RebootFull
847
848 rebootTypes :: FrozenSet String
849 rebootTypes = ConstantUtils.mkSet $ map Types.rebootTypeToRaw [minBound..]
850
851 -- * VTypes
852
853 vtypeBool :: String
854 vtypeBool = Types.vTypeToRaw VTypeBool
855
856 vtypeInt :: String
857 vtypeInt = Types.vTypeToRaw VTypeInt
858
859 vtypeMaybeString :: String
860 vtypeMaybeString = Types.vTypeToRaw VTypeMaybeString
861
862 -- | Size in MiBs
863 vtypeSize :: String
864 vtypeSize = Types.vTypeToRaw VTypeSize
865
866 vtypeString :: String
867 vtypeString = Types.vTypeToRaw VTypeString
868
869 enforceableTypes :: FrozenSet String
870 enforceableTypes = ConstantUtils.mkSet $ map Types.vTypeToRaw [minBound..]
871
872 -- * OOB supported commands
873
874 oobPowerOn :: String
875 oobPowerOn = Types.oobCommandToRaw OobPowerOn
876
877 oobPowerOff :: String
878 oobPowerOff = Types.oobCommandToRaw OobPowerOff
879
880 oobPowerCycle :: String
881 oobPowerCycle = Types.oobCommandToRaw OobPowerCycle
882
883 oobPowerStatus :: String
884 oobPowerStatus = Types.oobCommandToRaw OobPowerStatus
885
886 oobHealth :: String
887 oobHealth = Types.oobCommandToRaw OobHealth
888
889 oobCommands :: FrozenSet String
890 oobCommands = ConstantUtils.mkSet $ map Types.oobCommandToRaw [minBound..]
891
892 oobPowerStatusPowered :: String
893 oobPowerStatusPowered = "powered"
894
895 -- | 60 seconds
896 oobTimeout :: Int
897 oobTimeout = 60
898
899 -- | 2 seconds
900 oobPowerDelay :: Double
901 oobPowerDelay = 2.0
902
903 oobStatusCritical :: String
904 oobStatusCritical = Types.oobStatusToRaw OobStatusCritical
905
906 oobStatusOk :: String
907 oobStatusOk = Types.oobStatusToRaw OobStatusOk
908
909 oobStatusUnknown :: String
910 oobStatusUnknown = Types.oobStatusToRaw OobStatusUnknown
911
912 oobStatusWarning :: String
913 oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
914
915 oobStatuses :: FrozenSet String
916 oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
917
918 -- * NIC_* constants are used inside the ganeti config
919
920 nicLink :: String
921 nicLink = "link"
922
923 nicMode :: String
924 nicMode = "mode"
925
926 nicVlan :: String
927 nicVlan = "vlan"
928
929 nicModeBridged :: String
930 nicModeBridged = Types.nICModeToRaw NMBridged
931
932 nicModeRouted :: String
933 nicModeRouted = Types.nICModeToRaw NMRouted
934
935 nicModeOvs :: String
936 nicModeOvs = Types.nICModeToRaw NMOvs
937
938 nicIpPool :: String
939 nicIpPool = Types.nICModeToRaw NMPool
940
941 nicValidModes :: FrozenSet String
942 nicValidModes = ConstantUtils.mkSet $ map Types.nICModeToRaw [minBound..]
943
944 -- * Hypervisor constants
945
946 htXenPvm :: String
947 htXenPvm = Types.hypervisorToRaw XenPvm
948
949 htFake :: String
950 htFake = Types.hypervisorToRaw Fake
951
952 htXenHvm :: String
953 htXenHvm = Types.hypervisorToRaw XenHvm
954
955 htKvm :: String
956 htKvm = Types.hypervisorToRaw Kvm
957
958 htChroot :: String
959 htChroot = Types.hypervisorToRaw Chroot
960
961 htLxc :: String
962 htLxc = Types.hypervisorToRaw Lxc
963
964 hyperTypes :: FrozenSet String
965 hyperTypes = ConstantUtils.mkSet $ map Types.hypervisorToRaw [minBound..]
966
967 htsReqPort :: FrozenSet String
968 htsReqPort = ConstantUtils.mkSet [htXenHvm, htKvm]
969
970 -- * Migration type
971
972 htMigrationLive :: String
973 htMigrationLive = Types.migrationModeToRaw MigrationLive
974
975 htMigrationNonlive :: String
976 htMigrationNonlive = Types.migrationModeToRaw MigrationNonLive
977
978 htMigrationModes :: FrozenSet String
979 htMigrationModes =
980   ConstantUtils.mkSet $ map Types.migrationModeToRaw [minBound..]
981
982 -- * Cluster verify steps
983
984 verifyNplusoneMem :: String
985 verifyNplusoneMem = Types.verifyOptionalChecksToRaw VerifyNPlusOneMem
986
987 verifyOptionalChecks :: FrozenSet String
988 verifyOptionalChecks =
989   ConstantUtils.mkSet $ map Types.verifyOptionalChecksToRaw [minBound..]
990
991 -- * Cluster Verify error classes
992
993 cvTcluster :: String
994 cvTcluster = "cluster"
995
996 cvTgroup :: String
997 cvTgroup = "group"
998
999 cvTnode :: String
1000 cvTnode = "node"
1001
1002 cvTinstance :: String
1003 cvTinstance = "instance"
1004
1005 -- * Cluster Verify error codes and documentation
1006
1007 cvEclustercert :: (String, String, String)
1008 cvEclustercert =
1009   ("cluster",
1010    Types.cVErrorCodeToRaw CvECLUSTERCERT,
1011    "Cluster certificate files verification failure")
1012
1013 cvEclustercfg :: (String, String, String)
1014 cvEclustercfg =
1015   ("cluster",
1016    Types.cVErrorCodeToRaw CvECLUSTERCFG,
1017    "Cluster configuration verification failure")
1018
1019 cvEclusterdanglinginst :: (String, String, String)
1020 cvEclusterdanglinginst =
1021   ("node",
1022    Types.cVErrorCodeToRaw CvECLUSTERDANGLINGINST,
1023    "Some instances have a non-existing primary node")
1024
1025 cvEclusterdanglingnodes :: (String, String, String)
1026 cvEclusterdanglingnodes =
1027   ("node",
1028    Types.cVErrorCodeToRaw CvECLUSTERDANGLINGNODES,
1029    "Some nodes belong to non-existing groups")
1030
1031 cvEclusterfilecheck :: (String, String, String)
1032 cvEclusterfilecheck =
1033   ("cluster",
1034    Types.cVErrorCodeToRaw CvECLUSTERFILECHECK,
1035    "Cluster configuration verification failure")
1036
1037 cvEgroupdifferentpvsize :: (String, String, String)
1038 cvEgroupdifferentpvsize =
1039   ("group",
1040    Types.cVErrorCodeToRaw CvEGROUPDIFFERENTPVSIZE,
1041    "PVs in the group have different sizes")
1042
1043 cvEinstancebadnode :: (String, String, String)
1044 cvEinstancebadnode =
1045   ("instance",
1046    Types.cVErrorCodeToRaw CvEINSTANCEBADNODE,
1047    "Instance marked as running lives on an offline node")
1048
1049 cvEinstancedown :: (String, String, String)
1050 cvEinstancedown =
1051   ("instance",
1052    Types.cVErrorCodeToRaw CvEINSTANCEDOWN,
1053    "Instance not running on its primary node")
1054
1055 cvEinstancefaultydisk :: (String, String, String)
1056 cvEinstancefaultydisk =
1057   ("instance",
1058    Types.cVErrorCodeToRaw CvEINSTANCEFAULTYDISK,
1059    "Impossible to retrieve status for a disk")
1060
1061 cvEinstancelayout :: (String, String, String)
1062 cvEinstancelayout =
1063   ("instance",
1064    Types.cVErrorCodeToRaw CvEINSTANCELAYOUT,
1065    "Instance has multiple secondary nodes")
1066
1067 cvEinstancemissingcfgparameter :: (String, String, String)
1068 cvEinstancemissingcfgparameter =
1069   ("instance",
1070    Types.cVErrorCodeToRaw CvEINSTANCEMISSINGCFGPARAMETER,
1071    "A configuration parameter for an instance is missing")
1072
1073 cvEinstancemissingdisk :: (String, String, String)
1074 cvEinstancemissingdisk =
1075   ("instance",
1076    Types.cVErrorCodeToRaw CvEINSTANCEMISSINGDISK,
1077    "Missing volume on an instance")
1078
1079 cvEinstancepolicy :: (String, String, String)
1080 cvEinstancepolicy =
1081   ("instance",
1082    Types.cVErrorCodeToRaw CvEINSTANCEPOLICY,
1083    "Instance does not meet policy")
1084
1085 cvEinstancesplitgroups :: (String, String, String)
1086 cvEinstancesplitgroups =
1087   ("instance",
1088    Types.cVErrorCodeToRaw CvEINSTANCESPLITGROUPS,
1089    "Instance with primary and secondary nodes in different groups")
1090
1091 cvEinstanceunsuitablenode :: (String, String, String)
1092 cvEinstanceunsuitablenode =
1093   ("instance",
1094    Types.cVErrorCodeToRaw CvEINSTANCEUNSUITABLENODE,
1095    "Instance running on nodes that are not suitable for it")
1096
1097 cvEinstancewrongnode :: (String, String, String)
1098 cvEinstancewrongnode =
1099   ("instance",
1100    Types.cVErrorCodeToRaw CvEINSTANCEWRONGNODE,
1101    "Instance running on the wrong node")
1102
1103 cvEnodedrbd :: (String, String, String)
1104 cvEnodedrbd =
1105   ("node",
1106    Types.cVErrorCodeToRaw CvENODEDRBD,
1107    "Error parsing the DRBD status file")
1108
1109 cvEnodedrbdhelper :: (String, String, String)
1110 cvEnodedrbdhelper =
1111   ("node",
1112    Types.cVErrorCodeToRaw CvENODEDRBDHELPER,
1113    "Error caused by the DRBD helper")
1114
1115 cvEnodedrbdversion :: (String, String, String)
1116 cvEnodedrbdversion =
1117   ("node",
1118    Types.cVErrorCodeToRaw CvENODEDRBDVERSION,
1119    "DRBD version mismatch within a node group")
1120
1121 cvEnodefilecheck :: (String, String, String)
1122 cvEnodefilecheck =
1123   ("node",
1124    Types.cVErrorCodeToRaw CvENODEFILECHECK,
1125    "Error retrieving the checksum of the node files")
1126
1127 cvEnodefilestoragepaths :: (String, String, String)
1128 cvEnodefilestoragepaths =
1129   ("node",
1130    Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHS,
1131    "Detected bad file storage paths")
1132
1133 cvEnodefilestoragepathunusable :: (String, String, String)
1134 cvEnodefilestoragepathunusable =
1135   ("node",
1136    Types.cVErrorCodeToRaw CvENODEFILESTORAGEPATHUNUSABLE,
1137    "File storage path unusable")
1138
1139 cvEnodehooks :: (String, String, String)
1140 cvEnodehooks =
1141   ("node",
1142    Types.cVErrorCodeToRaw CvENODEHOOKS,
1143    "Communication failure in hooks execution")
1144
1145 cvEnodehv :: (String, String, String)
1146 cvEnodehv =
1147   ("node",
1148    Types.cVErrorCodeToRaw CvENODEHV,
1149    "Hypervisor parameters verification failure")
1150
1151 cvEnodelvm :: (String, String, String)
1152 cvEnodelvm =
1153   ("node",
1154    Types.cVErrorCodeToRaw CvENODELVM,
1155    "LVM-related node error")
1156
1157 cvEnoden1 :: (String, String, String)
1158 cvEnoden1 =
1159   ("node",
1160    Types.cVErrorCodeToRaw CvENODEN1,
1161    "Not enough memory to accommodate instance failovers")
1162
1163 cvEnodenet :: (String, String, String)
1164 cvEnodenet =
1165   ("node",
1166    Types.cVErrorCodeToRaw CvENODENET,
1167    "Network-related node error")
1168
1169 cvEnodeoobpath :: (String, String, String)
1170 cvEnodeoobpath =
1171   ("node",
1172    Types.cVErrorCodeToRaw CvENODEOOBPATH,
1173    "Invalid Out Of Band path")
1174
1175 cvEnodeorphaninstance :: (String, String, String)
1176 cvEnodeorphaninstance =
1177   ("node",
1178    Types.cVErrorCodeToRaw CvENODEORPHANINSTANCE,
1179    "Unknown intance running on a node")
1180
1181 cvEnodeorphanlv :: (String, String, String)
1182 cvEnodeorphanlv =
1183   ("node",
1184    Types.cVErrorCodeToRaw CvENODEORPHANLV,
1185    "Unknown LVM logical volume")
1186
1187 cvEnodeos :: (String, String, String)
1188 cvEnodeos =
1189   ("node",
1190    Types.cVErrorCodeToRaw CvENODEOS,
1191    "OS-related node error")
1192
1193 cvEnoderpc :: (String, String, String)
1194 cvEnoderpc =
1195   ("node",
1196    Types.cVErrorCodeToRaw CvENODERPC,
1197    "Error during connection to the primary node of an instance")
1198
1199 cvEnodesetup :: (String, String, String)
1200 cvEnodesetup =
1201   ("node",
1202    Types.cVErrorCodeToRaw CvENODESETUP,
1203    "Node setup error")
1204
1205 cvEnodesharedfilestoragepathunusable :: (String, String, String)
1206 cvEnodesharedfilestoragepathunusable =
1207   ("node",
1208    Types.cVErrorCodeToRaw CvENODESHAREDFILESTORAGEPATHUNUSABLE,
1209    "Shared file storage path unusable")
1210
1211 cvEnodessh :: (String, String, String)
1212 cvEnodessh =
1213   ("node",
1214    Types.cVErrorCodeToRaw CvENODESSH,
1215    "SSH-related node error")
1216
1217 cvEnodetime :: (String, String, String)
1218 cvEnodetime =
1219   ("node",
1220    Types.cVErrorCodeToRaw CvENODETIME,
1221    "Node returned invalid time")
1222
1223 cvEnodeuserscripts :: (String, String, String)
1224 cvEnodeuserscripts =
1225   ("node",
1226    Types.cVErrorCodeToRaw CvENODEUSERSCRIPTS,
1227    "User scripts not present or not executable")
1228
1229 cvEnodeversion :: (String, String, String)
1230 cvEnodeversion =
1231   ("node",
1232    Types.cVErrorCodeToRaw CvENODEVERSION,
1233    "Protocol version mismatch or Ganeti version mismatch")
1234
1235 cvAllEcodes :: FrozenSet (String, String, String)
1236 cvAllEcodes =
1237   ConstantUtils.mkSet
1238   [cvEclustercert,
1239    cvEclustercfg,
1240    cvEclusterdanglinginst,
1241    cvEclusterdanglingnodes,
1242    cvEclusterfilecheck,
1243    cvEgroupdifferentpvsize,
1244    cvEinstancebadnode,
1245    cvEinstancedown,
1246    cvEinstancefaultydisk,
1247    cvEinstancelayout,
1248    cvEinstancemissingcfgparameter,
1249    cvEinstancemissingdisk,
1250    cvEinstancepolicy,
1251    cvEinstancesplitgroups,
1252    cvEinstanceunsuitablenode,
1253    cvEinstancewrongnode,
1254    cvEnodedrbd,
1255    cvEnodedrbdhelper,
1256    cvEnodedrbdversion,
1257    cvEnodefilecheck,
1258    cvEnodefilestoragepaths,
1259    cvEnodefilestoragepathunusable,
1260    cvEnodehooks,
1261    cvEnodehv,
1262    cvEnodelvm,
1263    cvEnoden1,
1264    cvEnodenet,
1265    cvEnodeoobpath,
1266    cvEnodeorphaninstance,
1267    cvEnodeorphanlv,
1268    cvEnodeos,
1269    cvEnoderpc,
1270    cvEnodesetup,
1271    cvEnodesharedfilestoragepathunusable,
1272    cvEnodessh,
1273    cvEnodetime,
1274    cvEnodeuserscripts,
1275    cvEnodeversion]
1276
1277 cvAllEcodesStrings :: FrozenSet String
1278 cvAllEcodesStrings =
1279   ConstantUtils.mkSet $ map Types.cVErrorCodeToRaw [minBound..]
1280
1281 -- * Instance status
1282
1283 inststAdmindown :: String
1284 inststAdmindown = Types.instanceStatusToRaw StatusDown
1285
1286 inststAdminoffline :: String
1287 inststAdminoffline = Types.instanceStatusToRaw StatusOffline
1288
1289 inststErrordown :: String
1290 inststErrordown = Types.instanceStatusToRaw ErrorDown
1291
1292 inststErrorup :: String
1293 inststErrorup = Types.instanceStatusToRaw ErrorUp
1294
1295 inststNodedown :: String
1296 inststNodedown = Types.instanceStatusToRaw NodeDown
1297
1298 inststNodeoffline :: String
1299 inststNodeoffline = Types.instanceStatusToRaw NodeOffline
1300
1301 inststRunning :: String
1302 inststRunning = Types.instanceStatusToRaw Running
1303
1304 inststWrongnode :: String
1305 inststWrongnode = Types.instanceStatusToRaw WrongNode
1306
1307 inststAll :: FrozenSet String
1308 inststAll = ConstantUtils.mkSet $ map Types.instanceStatusToRaw [minBound..]
1309
1310 -- * Admin states
1311
1312 adminstDown :: String
1313 adminstDown = Types.adminStateToRaw AdminDown
1314
1315 adminstOffline :: String
1316 adminstOffline = Types.adminStateToRaw AdminOffline
1317
1318 adminstUp :: String
1319 adminstUp = Types.adminStateToRaw AdminUp
1320
1321 adminstAll :: FrozenSet String
1322 adminstAll = ConstantUtils.mkSet $ map Types.adminStateToRaw [minBound..]
1323
1324 -- * Node roles
1325
1326 nrDrained :: String
1327 nrDrained = Types.nodeRoleToRaw NRDrained
1328
1329 nrMaster :: String
1330 nrMaster = Types.nodeRoleToRaw NRMaster
1331
1332 nrMcandidate :: String
1333 nrMcandidate = Types.nodeRoleToRaw NRCandidate
1334
1335 nrOffline :: String
1336 nrOffline = Types.nodeRoleToRaw NROffline
1337
1338 nrRegular :: String
1339 nrRegular = Types.nodeRoleToRaw NRRegular
1340
1341 nrAll :: FrozenSet String
1342 nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
1343
1344 -- * Allocator framework constants
1345
1346 iallocatorVersion :: Int
1347 iallocatorVersion = 2
1348
1349 iallocatorDirIn :: String
1350 iallocatorDirIn = Types.iAllocatorTestDirToRaw IAllocatorDirIn
1351
1352 iallocatorDirOut :: String
1353 iallocatorDirOut = Types.iAllocatorTestDirToRaw IAllocatorDirOut
1354
1355 validIallocatorDirections :: FrozenSet String
1356 validIallocatorDirections =
1357   ConstantUtils.mkSet $ map Types.iAllocatorTestDirToRaw [minBound..]
1358
1359 iallocatorModeAlloc :: String
1360 iallocatorModeAlloc = Types.iAllocatorModeToRaw IAllocatorAlloc
1361
1362 iallocatorModeChgGroup :: String
1363 iallocatorModeChgGroup = Types.iAllocatorModeToRaw IAllocatorChangeGroup
1364
1365 iallocatorModeMultiAlloc :: String
1366 iallocatorModeMultiAlloc = Types.iAllocatorModeToRaw IAllocatorMultiAlloc
1367
1368 iallocatorModeNodeEvac :: String
1369 iallocatorModeNodeEvac = Types.iAllocatorModeToRaw IAllocatorNodeEvac
1370
1371 iallocatorModeReloc :: String
1372 iallocatorModeReloc = Types.iAllocatorModeToRaw IAllocatorReloc
1373
1374 validIallocatorModes :: FrozenSet String
1375 validIallocatorModes =
1376   ConstantUtils.mkSet $ map Types.iAllocatorModeToRaw [minBound..]
1377
1378 iallocatorSearchPath :: [String]
1379 iallocatorSearchPath = AutoConf.iallocatorSearchPath
1380
1381 defaultIallocatorShortcut :: String
1382 defaultIallocatorShortcut = "."
1383
1384 -- * Node evacuation
1385
1386 nodeEvacPri :: String
1387 nodeEvacPri = Types.evacModeToRaw ChangePrimary
1388
1389 nodeEvacSec :: String
1390 nodeEvacSec = Types.evacModeToRaw ChangeSecondary
1391
1392 nodeEvacAll :: String
1393 nodeEvacAll = Types.evacModeToRaw ChangeAll
1394
1395 nodeEvacModes :: FrozenSet String
1396 nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
1397
1398 -- * Job status
1399
1400 jobStatusQueued :: String
1401 jobStatusQueued = Types.jobStatusToRaw JOB_STATUS_QUEUED
1402
1403 jobStatusWaiting :: String
1404 jobStatusWaiting = Types.jobStatusToRaw JOB_STATUS_WAITING
1405
1406 jobStatusCanceling :: String
1407 jobStatusCanceling = Types.jobStatusToRaw JOB_STATUS_CANCELING
1408
1409 jobStatusRunning :: String
1410 jobStatusRunning = Types.jobStatusToRaw JOB_STATUS_RUNNING
1411
1412 jobStatusCanceled :: String
1413 jobStatusCanceled = Types.jobStatusToRaw JOB_STATUS_CANCELED
1414
1415 jobStatusSuccess :: String
1416 jobStatusSuccess = Types.jobStatusToRaw JOB_STATUS_SUCCESS
1417
1418 jobStatusError :: String
1419 jobStatusError = Types.jobStatusToRaw JOB_STATUS_ERROR
1420
1421 jobsPending :: FrozenSet String
1422 jobsPending =
1423   ConstantUtils.mkSet [jobStatusQueued, jobStatusWaiting, jobStatusCanceling]
1424
1425 jobsFinalized :: FrozenSet String
1426 jobsFinalized =
1427   ConstantUtils.mkSet $ map Types.finalizedJobStatusToRaw [minBound..]
1428
1429 jobStatusAll :: FrozenSet String
1430 jobStatusAll = ConstantUtils.mkSet $ map Types.jobStatusToRaw [minBound..]
1431
1432 -- * OpCode status
1433
1434 -- ** Not yet finalized opcodes
1435
1436 opStatusCanceling :: String
1437 opStatusCanceling = "canceling"
1438
1439 opStatusQueued :: String
1440 opStatusQueued = "queued"
1441
1442 opStatusRunning :: String
1443 opStatusRunning = "running"
1444
1445 opStatusWaiting :: String
1446 opStatusWaiting = "waiting"
1447
1448 -- ** Finalized opcodes
1449
1450 opStatusCanceled :: String
1451 opStatusCanceled = "canceled"
1452
1453 opStatusError :: String
1454 opStatusError = "error"
1455
1456 opStatusSuccess :: String
1457 opStatusSuccess = "success"
1458
1459 opsFinalized :: FrozenSet String
1460 opsFinalized =
1461   ConstantUtils.mkSet [opStatusCanceled, opStatusError, opStatusSuccess]
1462
1463 -- * OpCode priority
1464
1465 opPrioLowest :: Int
1466 opPrioLowest = 19
1467
1468 opPrioHighest :: Int
1469 opPrioHighest = -20
1470
1471 opPrioLow :: Int
1472 opPrioLow = Types.opSubmitPriorityToRaw OpPrioLow
1473
1474 opPrioNormal :: Int
1475 opPrioNormal = Types.opSubmitPriorityToRaw OpPrioNormal
1476
1477 opPrioHigh :: Int
1478 opPrioHigh = Types.opSubmitPriorityToRaw OpPrioHigh
1479
1480 opPrioSubmitValid :: FrozenSet Int
1481 opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
1482
1483 opPrioDefault :: Int
1484 opPrioDefault = opPrioNormal
1485
1486 -- * Execution log types
1487
1488 elogMessage :: String
1489 elogMessage = Types.eLogTypeToRaw ELogMessage
1490
1491 elogRemoteImport :: String
1492 elogRemoteImport = Types.eLogTypeToRaw ELogRemoteImport
1493
1494 elogJqueueTest :: String
1495 elogJqueueTest = Types.eLogTypeToRaw ELogJqueueTest
1496
1497 -- * Confd
1498
1499 confdProtocolVersion :: Int
1500 confdProtocolVersion = ConstantUtils.confdProtocolVersion
1501
1502 -- Confd request type
1503
1504 confdReqPing :: Int
1505 confdReqPing = Types.confdRequestTypeToRaw ReqPing
1506
1507 confdReqNodeRoleByname :: Int
1508 confdReqNodeRoleByname = Types.confdRequestTypeToRaw ReqNodeRoleByName
1509
1510 confdReqNodePipByInstanceIp :: Int
1511 confdReqNodePipByInstanceIp = Types.confdRequestTypeToRaw ReqNodePipByInstPip
1512
1513 confdReqClusterMaster :: Int
1514 confdReqClusterMaster = Types.confdRequestTypeToRaw ReqClusterMaster
1515
1516 confdReqNodePipList :: Int
1517 confdReqNodePipList = Types.confdRequestTypeToRaw ReqNodePipList
1518
1519 confdReqMcPipList :: Int
1520 confdReqMcPipList = Types.confdRequestTypeToRaw ReqMcPipList
1521
1522 confdReqInstancesIpsList :: Int
1523 confdReqInstancesIpsList = Types.confdRequestTypeToRaw ReqInstIpsList
1524
1525 confdReqNodeDrbd :: Int
1526 confdReqNodeDrbd = Types.confdRequestTypeToRaw ReqNodeDrbd
1527
1528 confdReqNodeInstances :: Int
1529 confdReqNodeInstances = Types.confdRequestTypeToRaw ReqNodeInstances
1530
1531 confdReqs :: FrozenSet Int
1532 confdReqs =
1533   ConstantUtils.mkSet .
1534   map Types.confdRequestTypeToRaw $
1535   [minBound..] \\ [ReqNodeInstances]
1536
1537 -- * Confd request type
1538
1539 confdReqfieldName :: Int
1540 confdReqfieldName = Types.confdReqFieldToRaw ReqFieldName
1541
1542 confdReqfieldIp :: Int
1543 confdReqfieldIp = Types.confdReqFieldToRaw ReqFieldIp
1544
1545 confdReqfieldMnodePip :: Int
1546 confdReqfieldMnodePip = Types.confdReqFieldToRaw ReqFieldMNodePip
1547
1548 -- * Confd repl status
1549
1550 confdReplStatusOk :: Int
1551 confdReplStatusOk = Types.confdReplyStatusToRaw ReplyStatusOk
1552
1553 confdReplStatusError :: Int
1554 confdReplStatusError = Types.confdReplyStatusToRaw ReplyStatusError
1555
1556 confdReplStatusNotimplemented :: Int
1557 confdReplStatusNotimplemented = Types.confdReplyStatusToRaw ReplyStatusNotImpl
1558
1559 confdReplStatuses :: FrozenSet Int
1560 confdReplStatuses =
1561   ConstantUtils.mkSet $ map Types.confdReplyStatusToRaw [minBound..]
1562
1563 -- * Confd node role
1564
1565 confdNodeRoleMaster :: Int
1566 confdNodeRoleMaster = Types.confdNodeRoleToRaw NodeRoleMaster
1567
1568 confdNodeRoleCandidate :: Int
1569 confdNodeRoleCandidate = Types.confdNodeRoleToRaw NodeRoleCandidate
1570
1571 confdNodeRoleOffline :: Int
1572 confdNodeRoleOffline = Types.confdNodeRoleToRaw NodeRoleOffline
1573
1574 confdNodeRoleDrained :: Int
1575 confdNodeRoleDrained = Types.confdNodeRoleToRaw NodeRoleDrained
1576
1577 confdNodeRoleRegular :: Int
1578 confdNodeRoleRegular = Types.confdNodeRoleToRaw NodeRoleRegular
1579
1580 -- * A few common errors for confd
1581
1582 confdErrorUnknownEntry :: Int
1583 confdErrorUnknownEntry = Types.confdErrorTypeToRaw ConfdErrorUnknownEntry
1584
1585 confdErrorInternal :: Int
1586 confdErrorInternal = Types.confdErrorTypeToRaw ConfdErrorInternal
1587
1588 confdErrorArgument :: Int
1589 confdErrorArgument = Types.confdErrorTypeToRaw ConfdErrorArgument
1590
1591 -- * Confd request query fields
1592
1593 confdReqqLink :: String
1594 confdReqqLink = ConstantUtils.confdReqqLink
1595
1596 confdReqqIp :: String
1597 confdReqqIp = ConstantUtils.confdReqqIp
1598
1599 confdReqqIplist :: String
1600 confdReqqIplist = ConstantUtils.confdReqqIplist
1601
1602 confdReqqFields :: String
1603 confdReqqFields = ConstantUtils.confdReqqFields
1604
1605 -- | Each request is "salted" by the current timestamp.
1606 --
1607 -- This constant decides how many seconds of skew to accept.
1608 --
1609 -- TODO: make this a default and allow the value to be more
1610 -- configurable
1611 confdMaxClockSkew :: Int
1612 confdMaxClockSkew = 2 * nodeMaxClockSkew
1613
1614 -- | When we haven't reloaded the config for more than this amount of
1615 -- seconds, we force a test to see if inotify is betraying us. Using a
1616 -- prime number to ensure we get less chance of 'same wakeup' with
1617 -- other processes.
1618 confdConfigReloadTimeout :: Int
1619 confdConfigReloadTimeout = 17
1620
1621 -- | If we receive more than one update in this amount of
1622 -- microseconds, we move to polling every RATELIMIT seconds, rather
1623 -- than relying on inotify, to be able to serve more requests.
1624 confdConfigReloadRatelimit :: Int
1625 confdConfigReloadRatelimit = 250000
1626
1627 -- | Magic number prepended to all confd queries.
1628 --
1629 -- This allows us to distinguish different types of confd protocols
1630 -- and handle them. For example by changing this we can move the whole
1631 -- payload to be compressed, or move away from json.
1632 confdMagicFourcc :: String
1633 confdMagicFourcc = "plj0"
1634
1635 -- | By default a confd request is sent to the minimum between this
1636 -- number and all MCs. 6 was chosen because even in the case of a
1637 -- disastrous 50% response rate, we should have enough answers to be
1638 -- able to compare more than one.
1639 confdDefaultReqCoverage :: Int
1640 confdDefaultReqCoverage = 6
1641
1642 -- | Timeout in seconds to expire pending query request in the confd
1643 -- client library. We don't actually expect any answer more than 10
1644 -- seconds after we sent a request.
1645 confdClientExpireTimeout :: Int
1646 confdClientExpireTimeout = 10
1647
1648 -- * Possible values for NodeGroup.alloc_policy
1649
1650 allocPolicyLastResort :: String
1651 allocPolicyLastResort = Types.allocPolicyToRaw AllocLastResort
1652
1653 allocPolicyPreferred :: String
1654 allocPolicyPreferred = Types.allocPolicyToRaw AllocPreferred
1655
1656 allocPolicyUnallocable :: String
1657 allocPolicyUnallocable = Types.allocPolicyToRaw AllocUnallocable
1658
1659 validAllocPolicies :: [String]
1660 validAllocPolicies = map Types.allocPolicyToRaw [minBound..]
1661
1662 -- | Temporary external/shared storage parameters
1663 blockdevDriverManual :: String
1664 blockdevDriverManual = Types.blockDriverToRaw BlockDrvManual
1665
1666 -- | 'qemu-img' path, required for 'ovfconverter'
1667 qemuimgPath :: String
1668 qemuimgPath = AutoConf.qemuimgPath
1669
1670 -- | Whether htools was enabled at compilation time
1671 --
1672 -- FIXME: this should be moved next to the other enable constants,
1673 -- such as, 'enableConfd', and renamed to 'enableHtools'.
1674 htools :: Bool
1675 htools = AutoConf.htools
1676
1677 -- | Path generating random UUID
1678 randomUuidFile :: String
1679 randomUuidFile = ConstantUtils.randomUuidFile
1680
1681 -- * Auto-repair tag prefixes
1682
1683 autoRepairTagPrefix :: String
1684 autoRepairTagPrefix = "ganeti:watcher:autorepair:"
1685
1686 autoRepairTagEnabled :: String
1687 autoRepairTagEnabled = autoRepairTagPrefix
1688
1689 autoRepairTagPending :: String
1690 autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
1691
1692 autoRepairTagResult :: String
1693 autoRepairTagResult = autoRepairTagPrefix ++ "result:"
1694
1695 autoRepairTagSuspended :: String
1696 autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
1697
1698 -- * Auto-repair levels
1699
1700 autoRepairFailover :: String
1701 autoRepairFailover = "failover"
1702
1703 autoRepairFixStorage :: String
1704 autoRepairFixStorage = "fix-storage"
1705
1706 autoRepairMigrate :: String
1707 autoRepairMigrate = "migrate"
1708
1709 autoRepairReinstall :: String
1710 autoRepairReinstall = "reinstall"
1711
1712 autoRepairAllTypes :: FrozenSet String
1713 autoRepairAllTypes =
1714   ConstantUtils.mkSet [autoRepairFailover,
1715                        autoRepairFixStorage,
1716                        autoRepairMigrate,
1717                        autoRepairReinstall]
1718
1719 -- * Auto-repair results
1720
1721 autoRepairEnoperm :: String
1722 autoRepairEnoperm = "enoperm"
1723
1724 autoRepairFailure :: String
1725 autoRepairFailure = "failure"
1726
1727 autoRepairSuccess :: String
1728 autoRepairSuccess = "success"
1729
1730 autoRepairAllResults :: FrozenSet String
1731 autoRepairAllResults =
1732   ConstantUtils.mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess]
1733
1734 -- | The version identifier for builtin data collectors
1735 builtinDataCollectorVersion :: String
1736 builtinDataCollectorVersion = "B"
1737
1738 -- | The reason trail opcode parameter name
1739 opcodeReason :: String
1740 opcodeReason = "reason"
1741
1742 diskstatsFile :: String
1743 diskstatsFile = "/proc/diskstats"
1744
1745 -- *  CPU load collector
1746
1747 statFile :: String
1748 statFile = "/proc/stat"
1749
1750 cpuavgloadBufferSize :: Int
1751 cpuavgloadBufferSize = 150
1752
1753 cpuavgloadWindowSize :: Int
1754 cpuavgloadWindowSize = 600
1755
1756 -- | Mond's variable for periodical data collection
1757 mondTimeInterval :: Int
1758 mondTimeInterval = 5
1759
1760 -- * Disk access modes
1761
1762 diskUserspace :: String
1763 diskUserspace = Types.diskAccessModeToRaw DiskUserspace
1764
1765 diskKernelspace :: String
1766 diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
1767
1768 diskValidAccessModes :: FrozenSet String
1769 diskValidAccessModes =
1770   ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
1771
1772 -- | Timeout for queue draining in upgrades
1773 upgradeQueueDrainTimeout :: Int
1774 upgradeQueueDrainTimeout = 36 * 60 * 60 -- 1.5 days
1775
1776 -- | Intervall at which the queue is polled during upgrades
1777 upgradeQueuePollInterval :: Int
1778 upgradeQueuePollInterval  = 10