root / htools / Ganeti / OpParams.hs @ c65621d7
History | View | Annotate | Download (19.9 kB)
1 |
{-# LANGUAGE TemplateHaskell #-} |
---|---|
2 |
|
3 |
{-| Implementation of opcodes parameters. |
4 |
|
5 |
These are defined in a separate module only due to TemplateHaskell |
6 |
stage restrictions - expressions defined in the current module can't |
7 |
be passed to splices. So we have to either parameters/repeat each |
8 |
parameter definition multiple times, or separate them into this |
9 |
module. |
10 |
|
11 |
-} |
12 |
|
13 |
{- |
14 |
|
15 |
Copyright (C) 2012 Google Inc. |
16 |
|
17 |
This program is free software; you can redistribute it and/or modify |
18 |
it under the terms of the GNU General Public License as published by |
19 |
the Free Software Foundation; either version 2 of the License, or |
20 |
(at your option) any later version. |
21 |
|
22 |
This program is distributed in the hope that it will be useful, but |
23 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
24 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
25 |
General Public License for more details. |
26 |
|
27 |
You should have received a copy of the GNU General Public License |
28 |
along with this program; if not, write to the Free Software |
29 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
30 |
02110-1301, USA. |
31 |
|
32 |
-} |
33 |
|
34 |
module Ganeti.OpParams |
35 |
( TagType(..) |
36 |
, TagObject(..) |
37 |
, tagObjectFrom |
38 |
, decodeTagObject |
39 |
, encodeTagObject |
40 |
, ReplaceDisksMode(..) |
41 |
, DiskIndex |
42 |
, mkDiskIndex |
43 |
, unDiskIndex |
44 |
, INicParams(..) |
45 |
, IDiskParams(..) |
46 |
, pInstanceName |
47 |
, pInstances |
48 |
, pName |
49 |
, pTagsList |
50 |
, pTagsObject |
51 |
, pOutputFields |
52 |
, pShutdownTimeout |
53 |
, pForce |
54 |
, pIgnoreOfflineNodes |
55 |
, pNodeName |
56 |
, pNodeNames |
57 |
, pGroupName |
58 |
, pMigrationMode |
59 |
, pMigrationLive |
60 |
, pForceVariant |
61 |
, pWaitForSync |
62 |
, pWaitForSyncFalse |
63 |
, pIgnoreConsistency |
64 |
, pStorageName |
65 |
, pUseLocking |
66 |
, pNameCheck |
67 |
, pNodeGroupAllocPolicy |
68 |
, pGroupNodeParams |
69 |
, pQueryWhat |
70 |
, pEarlyRelease |
71 |
, pNoRemember |
72 |
, pMigrationTargetNode |
73 |
, pStartupPaused |
74 |
, pVerbose |
75 |
, pDebugSimulateErrors |
76 |
, pErrorCodes |
77 |
, pSkipChecks |
78 |
, pIgnoreErrors |
79 |
, pOptGroupName |
80 |
, pDiskParams |
81 |
, pHvState |
82 |
, pDiskState |
83 |
, pIgnoreIpolicy |
84 |
, pAllowRuntimeChgs |
85 |
, pVgName |
86 |
, pEnabledHypervisors |
87 |
, pClusterHvParams |
88 |
, pClusterBeParams |
89 |
, pOsHvp |
90 |
, pOsParams |
91 |
, pCandidatePoolSize |
92 |
, pUidPool |
93 |
, pAddUids |
94 |
, pRemoveUids |
95 |
, pMaintainNodeHealth |
96 |
, pPreallocWipeDisks |
97 |
, pNicParams |
98 |
, pNdParams |
99 |
, pIpolicy |
100 |
, pDrbdHelper |
101 |
, pDefaultIAllocator |
102 |
, pMasterNetdev |
103 |
, pMasterNetmask |
104 |
, pReservedLvs |
105 |
, pHiddenOs |
106 |
, pBlacklistedOs |
107 |
, pUseExternalMipScript |
108 |
, pQueryFields |
109 |
, pQueryFilter |
110 |
, pOobCommand |
111 |
, pOobTimeout |
112 |
, pIgnoreStatus |
113 |
, pPowerDelay |
114 |
, pPrimaryIp |
115 |
, pSecondaryIp |
116 |
, pReadd |
117 |
, pNodeGroup |
118 |
, pMasterCapable |
119 |
, pVmCapable |
120 |
, pNames |
121 |
, pNodes |
122 |
, pStorageType |
123 |
, pStorageChanges |
124 |
, pMasterCandidate |
125 |
, pOffline |
126 |
, pDrained |
127 |
, pAutoPromote |
128 |
, pPowered |
129 |
, pIallocator |
130 |
, pRemoteNode |
131 |
, pEvacMode |
132 |
) where |
133 |
|
134 |
import qualified Data.Set as Set |
135 |
import Text.JSON (readJSON, showJSON, JSON, JSValue(..), fromJSString, |
136 |
JSObject) |
137 |
import Text.JSON.Pretty (pp_value) |
138 |
|
139 |
import qualified Ganeti.Constants as C |
140 |
import Ganeti.THH |
141 |
import Ganeti.JSON |
142 |
import Ganeti.Types |
143 |
import qualified Ganeti.Query.Language as Qlang |
144 |
|
145 |
-- * Helper functions and types |
146 |
|
147 |
-- * Type aliases |
148 |
|
149 |
-- | Build a boolean field. |
150 |
booleanField :: String -> Field |
151 |
booleanField = flip simpleField [t| Bool |] |
152 |
|
153 |
-- | Default a field to 'False'. |
154 |
defaultFalse :: String -> Field |
155 |
defaultFalse = defaultField [| False |] . booleanField |
156 |
|
157 |
-- | Default a field to 'True'. |
158 |
defaultTrue :: String -> Field |
159 |
defaultTrue = defaultField [| True |] . booleanField |
160 |
|
161 |
-- | An alias for a 'String' field. |
162 |
stringField :: String -> Field |
163 |
stringField = flip simpleField [t| String |] |
164 |
|
165 |
-- | An alias for an optional string field. |
166 |
optionalStringField :: String -> Field |
167 |
optionalStringField = optionalField . stringField |
168 |
|
169 |
-- | An alias for an optional non-empty string field. |
170 |
optionalNEStringField :: String -> Field |
171 |
optionalNEStringField = optionalField . flip simpleField [t| NonEmptyString |] |
172 |
|
173 |
--- | Unchecked value, should be replaced by a better definition. |
174 |
--- type UncheckedValue = JSValue |
175 |
|
176 |
-- | Unchecked dict, should be replaced by a better definition. |
177 |
type UncheckedDict = JSObject JSValue |
178 |
|
179 |
-- ** Tags |
180 |
|
181 |
-- | Data type representing what items do the tag operations apply to. |
182 |
$(declareSADT "TagType" |
183 |
[ ("TagTypeInstance", 'C.tagInstance) |
184 |
, ("TagTypeNode", 'C.tagNode) |
185 |
, ("TagTypeGroup", 'C.tagNodegroup) |
186 |
, ("TagTypeCluster", 'C.tagCluster) |
187 |
]) |
188 |
$(makeJSONInstance ''TagType) |
189 |
|
190 |
-- | Data type holding a tag object (type and object name). |
191 |
data TagObject = TagInstance String |
192 |
| TagNode String |
193 |
| TagGroup String |
194 |
| TagCluster |
195 |
deriving (Show, Read, Eq) |
196 |
|
197 |
-- | Tag type for a given tag object. |
198 |
tagTypeOf :: TagObject -> TagType |
199 |
tagTypeOf (TagInstance {}) = TagTypeInstance |
200 |
tagTypeOf (TagNode {}) = TagTypeNode |
201 |
tagTypeOf (TagGroup {}) = TagTypeGroup |
202 |
tagTypeOf (TagCluster {}) = TagTypeCluster |
203 |
|
204 |
-- | Gets the potential tag object name. |
205 |
tagNameOf :: TagObject -> Maybe String |
206 |
tagNameOf (TagInstance s) = Just s |
207 |
tagNameOf (TagNode s) = Just s |
208 |
tagNameOf (TagGroup s) = Just s |
209 |
tagNameOf TagCluster = Nothing |
210 |
|
211 |
-- | Builds a 'TagObject' from a tag type and name. |
212 |
tagObjectFrom :: (Monad m) => TagType -> JSValue -> m TagObject |
213 |
tagObjectFrom TagTypeInstance (JSString s) = |
214 |
return . TagInstance $ fromJSString s |
215 |
tagObjectFrom TagTypeNode (JSString s) = return . TagNode $ fromJSString s |
216 |
tagObjectFrom TagTypeGroup (JSString s) = return . TagGroup $ fromJSString s |
217 |
tagObjectFrom TagTypeCluster JSNull = return TagCluster |
218 |
tagObjectFrom t v = |
219 |
fail $ "Invalid tag type/name combination: " ++ show t ++ "/" ++ |
220 |
show (pp_value v) |
221 |
|
222 |
-- | Name of the tag \"name\" field. |
223 |
tagNameField :: String |
224 |
tagNameField = "name" |
225 |
|
226 |
-- | Custom encoder for 'TagObject' as represented in an opcode. |
227 |
encodeTagObject :: TagObject -> (JSValue, [(String, JSValue)]) |
228 |
encodeTagObject t = ( showJSON (tagTypeOf t) |
229 |
, [(tagNameField, maybe JSNull showJSON (tagNameOf t))] ) |
230 |
|
231 |
-- | Custom decoder for 'TagObject' as represented in an opcode. |
232 |
decodeTagObject :: (Monad m) => [(String, JSValue)] -> JSValue -> m TagObject |
233 |
decodeTagObject obj kind = do |
234 |
ttype <- fromJVal kind |
235 |
tname <- fromObj obj tagNameField |
236 |
tagObjectFrom ttype tname |
237 |
|
238 |
-- ** Disks |
239 |
|
240 |
-- | Replace disks type. |
241 |
$(declareSADT "ReplaceDisksMode" |
242 |
[ ("ReplaceOnPrimary", 'C.replaceDiskPri) |
243 |
, ("ReplaceOnSecondary", 'C.replaceDiskSec) |
244 |
, ("ReplaceNewSecondary", 'C.replaceDiskChg) |
245 |
, ("ReplaceAuto", 'C.replaceDiskAuto) |
246 |
]) |
247 |
$(makeJSONInstance ''ReplaceDisksMode) |
248 |
|
249 |
-- | Disk index type (embedding constraints on the index value via a |
250 |
-- smart constructor). |
251 |
newtype DiskIndex = DiskIndex { unDiskIndex :: Int } |
252 |
deriving (Show, Read, Eq, Ord) |
253 |
|
254 |
-- | Smart constructor for 'DiskIndex'. |
255 |
mkDiskIndex :: (Monad m) => Int -> m DiskIndex |
256 |
mkDiskIndex i | i >= 0 && i < C.maxDisks = return (DiskIndex i) |
257 |
| otherwise = fail $ "Invalid value for disk index '" ++ |
258 |
show i ++ "', required between 0 and " ++ |
259 |
show C.maxDisks |
260 |
|
261 |
instance JSON DiskIndex where |
262 |
readJSON v = readJSON v >>= mkDiskIndex |
263 |
showJSON = showJSON . unDiskIndex |
264 |
|
265 |
-- ** I* param types |
266 |
|
267 |
-- | Type holding disk access modes. |
268 |
$(declareSADT "DiskAccess" |
269 |
[ ("DiskReadOnly", 'C.diskRdonly) |
270 |
, ("DiskReadWrite", 'C.diskRdwr) |
271 |
]) |
272 |
$(makeJSONInstance ''DiskAccess) |
273 |
|
274 |
-- | NIC modification definition. |
275 |
$(buildObject "INicParams" "inic" |
276 |
[ optionalField $ simpleField C.inicMac [t| NonEmptyString |] |
277 |
, optionalField $ simpleField C.inicIp [t| String |] |
278 |
, optionalField $ simpleField C.inicMode [t| NonEmptyString |] |
279 |
, optionalField $ simpleField C.inicLink [t| NonEmptyString |] |
280 |
]) |
281 |
|
282 |
-- | Disk modification definition. |
283 |
$(buildObject "IDiskParams" "idisk" |
284 |
[ simpleField C.idiskSize [t| Int |] -- FIXME: VTYPE_UNIT |
285 |
, simpleField C.idiskMode [t| DiskAccess |] |
286 |
, simpleField C.idiskAdopt [t| NonEmptyString |] |
287 |
, simpleField C.idiskVg [t| NonEmptyString |] |
288 |
, simpleField C.idiskMetavg [t| NonEmptyString |] |
289 |
]) |
290 |
|
291 |
-- * Parameters |
292 |
|
293 |
-- | A required instance name (for single-instance LUs). |
294 |
pInstanceName :: Field |
295 |
pInstanceName = simpleField "instance_name" [t| String |] |
296 |
|
297 |
-- | A list of instances. |
298 |
pInstances :: Field |
299 |
pInstances = defaultField [| [] |] $ |
300 |
simpleField "instances" [t| [NonEmptyString] |] |
301 |
|
302 |
-- | A generic name. |
303 |
pName :: Field |
304 |
pName = simpleField "name" [t| NonEmptyString |] |
305 |
|
306 |
-- | Tags list. |
307 |
pTagsList :: Field |
308 |
pTagsList = simpleField "tags" [t| [String] |] |
309 |
|
310 |
-- | Tags object. |
311 |
pTagsObject :: Field |
312 |
pTagsObject = customField 'decodeTagObject 'encodeTagObject $ |
313 |
simpleField "kind" [t| TagObject |] |
314 |
|
315 |
-- | Selected output fields. |
316 |
pOutputFields :: Field |
317 |
pOutputFields = simpleField "output_fields" [t| [NonEmptyString] |] |
318 |
|
319 |
-- | How long to wait for instance to shut down. |
320 |
pShutdownTimeout :: Field |
321 |
pShutdownTimeout = defaultField [| C.defaultShutdownTimeout |] $ |
322 |
simpleField "shutdown_timeout" [t| NonNegative Int |] |
323 |
|
324 |
-- | Whether to force the operation. |
325 |
pForce :: Field |
326 |
pForce = defaultFalse "force" |
327 |
|
328 |
-- | Whether to ignore offline nodes. |
329 |
pIgnoreOfflineNodes :: Field |
330 |
pIgnoreOfflineNodes = defaultFalse "ignore_offline_nodes" |
331 |
|
332 |
-- | A required node name (for single-node LUs). |
333 |
pNodeName :: Field |
334 |
pNodeName = simpleField "node_name" [t| NonEmptyString |] |
335 |
|
336 |
-- | List of nodes. |
337 |
pNodeNames :: Field |
338 |
pNodeNames = |
339 |
defaultField [| [] |] $ simpleField "node_names" [t| [NonEmptyString] |] |
340 |
|
341 |
-- | A required node group name (for single-group LUs). |
342 |
pGroupName :: Field |
343 |
pGroupName = simpleField "group_name" [t| NonEmptyString |] |
344 |
|
345 |
-- | Migration type (live\/non-live). |
346 |
pMigrationMode :: Field |
347 |
pMigrationMode = |
348 |
renameField "MigrationMode" . |
349 |
optionalField $ |
350 |
simpleField "mode" [t| MigrationMode |] |
351 |
|
352 |
-- | Obsolete \'live\' migration mode (boolean). |
353 |
pMigrationLive :: Field |
354 |
pMigrationLive = |
355 |
renameField "OldLiveMode" . optionalField $ booleanField "live" |
356 |
|
357 |
-- | Whether to force an unknown OS variant. |
358 |
pForceVariant :: Field |
359 |
pForceVariant = defaultFalse "force_variant" |
360 |
|
361 |
-- | Whether to wait for the disk to synchronize. |
362 |
pWaitForSync :: Field |
363 |
pWaitForSync = defaultTrue "wait_for_sync" |
364 |
|
365 |
-- | Whether to wait for the disk to synchronize (defaults to false). |
366 |
pWaitForSyncFalse :: Field |
367 |
pWaitForSyncFalse = defaultField [| False |] pWaitForSync |
368 |
|
369 |
-- | Whether to ignore disk consistency |
370 |
pIgnoreConsistency :: Field |
371 |
pIgnoreConsistency = defaultFalse "ignore_consistency" |
372 |
|
373 |
-- | Storage name. |
374 |
pStorageName :: Field |
375 |
pStorageName = |
376 |
renameField "StorageName" $ simpleField "name" [t| NonEmptyString |] |
377 |
|
378 |
-- | Whether to use synchronization. |
379 |
pUseLocking :: Field |
380 |
pUseLocking = defaultFalse "use_locking" |
381 |
|
382 |
-- | Whether to check name. |
383 |
pNameCheck :: Field |
384 |
pNameCheck = defaultTrue "name_check" |
385 |
|
386 |
-- | Instance allocation policy. |
387 |
pNodeGroupAllocPolicy :: Field |
388 |
pNodeGroupAllocPolicy = optionalField $ |
389 |
simpleField "alloc_policy" [t| AllocPolicy |] |
390 |
|
391 |
-- | Default node parameters for group. |
392 |
pGroupNodeParams :: Field |
393 |
pGroupNodeParams = optionalField $ simpleField "ndparams" [t| UncheckedDict |] |
394 |
|
395 |
-- | Resource(s) to query for. |
396 |
pQueryWhat :: Field |
397 |
pQueryWhat = simpleField "what" [t| Qlang.QueryTypeOp |] |
398 |
|
399 |
-- | Whether to release locks as soon as possible. |
400 |
pEarlyRelease :: Field |
401 |
pEarlyRelease = defaultFalse "early_release" |
402 |
|
403 |
-- _PIpCheckDoc = "Whether to ensure instance's IP address is inactive" |
404 |
|
405 |
-- | Do not remember instance state changes. |
406 |
pNoRemember :: Field |
407 |
pNoRemember = defaultFalse "no_remember" |
408 |
|
409 |
-- | Target node for instance migration/failover. |
410 |
pMigrationTargetNode :: Field |
411 |
pMigrationTargetNode = optionalNEStringField "target_node" |
412 |
|
413 |
-- | Pause instance at startup. |
414 |
pStartupPaused :: Field |
415 |
pStartupPaused = defaultFalse "startup_paused" |
416 |
|
417 |
-- | Verbose mode. |
418 |
pVerbose :: Field |
419 |
pVerbose = defaultFalse "verbose" |
420 |
|
421 |
-- ** Parameters for cluster verification |
422 |
|
423 |
-- | Whether to simulate errors (useful for debugging). |
424 |
pDebugSimulateErrors :: Field |
425 |
pDebugSimulateErrors = defaultFalse "debug_simulate_errors" |
426 |
|
427 |
-- | Error codes. |
428 |
pErrorCodes :: Field |
429 |
pErrorCodes = defaultFalse "error_codes" |
430 |
|
431 |
-- | Which checks to skip. |
432 |
pSkipChecks :: Field |
433 |
pSkipChecks = defaultField [| Set.empty |] $ |
434 |
simpleField "skip_checks" [t| Set.Set VerifyOptionalChecks |] |
435 |
|
436 |
-- | List of error codes that should be treated as warnings. |
437 |
pIgnoreErrors :: Field |
438 |
pIgnoreErrors = defaultField [| Set.empty |] $ |
439 |
simpleField "ignore_errors" [t| Set.Set CVErrorCode |] |
440 |
|
441 |
-- | Optional group name. |
442 |
pOptGroupName :: Field |
443 |
pOptGroupName = renameField "OptGroupName" . |
444 |
optionalField $ simpleField "group_name" [t| NonEmptyString |] |
445 |
|
446 |
-- | Disk templates' parameter defaults. |
447 |
pDiskParams :: Field |
448 |
pDiskParams = optionalField $ |
449 |
simpleField "diskparams" [t| GenericContainer DiskTemplate |
450 |
UncheckedDict |] |
451 |
|
452 |
-- * Parameters for node resource model |
453 |
|
454 |
-- | Set hypervisor states. |
455 |
pHvState :: Field |
456 |
pHvState = optionalField $ simpleField "hv_state" [t| UncheckedDict |] |
457 |
|
458 |
-- | Set disk states. |
459 |
pDiskState :: Field |
460 |
pDiskState = optionalField $ simpleField "disk_state" [t| UncheckedDict |] |
461 |
|
462 |
-- | Whether to ignore ipolicy violations. |
463 |
pIgnoreIpolicy :: Field |
464 |
pIgnoreIpolicy = defaultFalse "ignore_ipolicy" |
465 |
|
466 |
-- | Allow runtime changes while migrating. |
467 |
pAllowRuntimeChgs :: Field |
468 |
pAllowRuntimeChgs = defaultTrue "allow_runtime_changes" |
469 |
|
470 |
-- | Utility type for OpClusterSetParams. |
471 |
type TestClusterOsListItem = (DdmSimple, NonEmptyString) |
472 |
|
473 |
-- | Utility type of OsList. |
474 |
type TestClusterOsList = [TestClusterOsListItem] |
475 |
|
476 |
-- Utility type for NIC definitions. |
477 |
--type TestNicDef = INicParams |
478 |
--type TDiskParams = IDiskParams |
479 |
|
480 |
-- | Volume group name. |
481 |
pVgName :: Field |
482 |
pVgName = optionalStringField "vg_name" |
483 |
|
484 |
-- | List of enabled hypervisors. |
485 |
pEnabledHypervisors :: Field |
486 |
pEnabledHypervisors = |
487 |
optionalField $ |
488 |
simpleField "enabled_hypervisors" [t| NonEmpty Hypervisor |] |
489 |
|
490 |
-- | Cluster-wide hypervisor parameters, hypervisor-dependent. |
491 |
pClusterHvParams :: Field |
492 |
pClusterHvParams = |
493 |
optionalField $ |
494 |
simpleField "hvparams" [t| Container UncheckedDict |] |
495 |
|
496 |
-- | Cluster-wide beparams. |
497 |
pClusterBeParams :: Field |
498 |
pClusterBeParams = optionalField $ simpleField "beparams" [t| UncheckedDict |] |
499 |
|
500 |
-- | Cluster-wide per-OS hypervisor parameter defaults. |
501 |
pOsHvp :: Field |
502 |
pOsHvp = optionalField $ simpleField "os_hvp" [t| Container UncheckedDict |] |
503 |
|
504 |
-- | Cluster-wide OS parameter defaults. |
505 |
pOsParams :: Field |
506 |
pOsParams = |
507 |
optionalField $ simpleField "osparams" [t| Container UncheckedDict |] |
508 |
|
509 |
-- | Candidate pool size. |
510 |
pCandidatePoolSize :: Field |
511 |
pCandidatePoolSize = |
512 |
optionalField $ simpleField "candidate_pool_size" [t| Positive Int |] |
513 |
|
514 |
-- | Set UID pool, must be list of lists describing UID ranges (two |
515 |
-- items, start and end inclusive. |
516 |
pUidPool :: Field |
517 |
pUidPool = optionalField $ simpleField "uid_pool" [t| [[(Int, Int)]] |] |
518 |
|
519 |
-- | Extend UID pool, must be list of lists describing UID ranges (two |
520 |
-- items, start and end inclusive. |
521 |
pAddUids :: Field |
522 |
pAddUids = optionalField $ simpleField "add_uids" [t| [[(Int, Int)]] |] |
523 |
|
524 |
-- | Shrink UID pool, must be list of lists describing UID ranges (two |
525 |
-- items, start and end inclusive) to be removed. |
526 |
pRemoveUids :: Field |
527 |
pRemoveUids = optionalField $ simpleField "remove_uids" [t| [[(Int, Int)]] |] |
528 |
|
529 |
-- | Whether to automatically maintain node health. |
530 |
pMaintainNodeHealth :: Field |
531 |
pMaintainNodeHealth = optionalField $ booleanField "maintain_node_health" |
532 |
|
533 |
-- | Whether to wipe disks before allocating them to instances. |
534 |
pPreallocWipeDisks :: Field |
535 |
pPreallocWipeDisks = optionalField $ booleanField "prealloc_wipe_disks" |
536 |
|
537 |
-- | Cluster-wide NIC parameter defaults. |
538 |
pNicParams :: Field |
539 |
pNicParams = optionalField $ simpleField "nicparams" [t| INicParams |] |
540 |
|
541 |
-- | Cluster-wide node parameter defaults. |
542 |
pNdParams :: Field |
543 |
pNdParams = optionalField $ simpleField "ndparams" [t| UncheckedDict |] |
544 |
|
545 |
-- | Cluster-wipe ipolict specs. |
546 |
pIpolicy :: Field |
547 |
pIpolicy = optionalField $ simpleField "ipolicy" [t| UncheckedDict |] |
548 |
|
549 |
-- | DRBD helper program. |
550 |
pDrbdHelper :: Field |
551 |
pDrbdHelper = optionalStringField "drbd_helper" |
552 |
|
553 |
-- | Default iallocator for cluster. |
554 |
pDefaultIAllocator :: Field |
555 |
pDefaultIAllocator = optionalStringField "default_iallocator" |
556 |
|
557 |
-- | Master network device. |
558 |
pMasterNetdev :: Field |
559 |
pMasterNetdev = optionalStringField "master_netdev" |
560 |
|
561 |
-- | Netmask of the master IP. |
562 |
pMasterNetmask :: Field |
563 |
pMasterNetmask = optionalField $ simpleField "master_netmask" [t| Int |] |
564 |
|
565 |
-- | List of reserved LVs. |
566 |
pReservedLvs :: Field |
567 |
pReservedLvs = |
568 |
optionalField $ simpleField "reserved_lvs" [t| [NonEmptyString] |] |
569 |
|
570 |
-- | Modify list of hidden operating systems: each modification must |
571 |
-- have two items, the operation and the OS name; the operation can be |
572 |
-- add or remove. |
573 |
pHiddenOs :: Field |
574 |
pHiddenOs = optionalField $ simpleField "hidden_os" [t| TestClusterOsList |] |
575 |
|
576 |
-- | Modify list of blacklisted operating systems: each modification |
577 |
-- must have two items, the operation and the OS name; the operation |
578 |
-- can be add or remove. |
579 |
pBlacklistedOs :: Field |
580 |
pBlacklistedOs = |
581 |
optionalField $ simpleField "blacklisted_os" [t| TestClusterOsList |] |
582 |
|
583 |
-- | Whether to use an external master IP address setup script. |
584 |
pUseExternalMipScript :: Field |
585 |
pUseExternalMipScript = optionalField $ booleanField "use_external_mip_script" |
586 |
|
587 |
-- | Requested fields. |
588 |
pQueryFields :: Field |
589 |
pQueryFields = simpleField "fields" [t| [NonEmptyString] |] |
590 |
|
591 |
-- | Query filter. |
592 |
pQueryFilter :: Field |
593 |
pQueryFilter = simpleField "qfilter" [t| Qlang.Filter String |] |
594 |
|
595 |
-- | OOB command to run. |
596 |
pOobCommand :: Field |
597 |
pOobCommand = simpleField "command" [t| OobCommand |] |
598 |
|
599 |
-- | Timeout before the OOB helper will be terminated. |
600 |
pOobTimeout :: Field |
601 |
pOobTimeout = |
602 |
defaultField [| C.oobTimeout |] $ simpleField "timeout" [t| Int |] |
603 |
|
604 |
-- | Ignores the node offline status for power off. |
605 |
pIgnoreStatus :: Field |
606 |
pIgnoreStatus = defaultFalse "ignore_status" |
607 |
|
608 |
-- | Time in seconds to wait between powering on nodes. |
609 |
pPowerDelay :: Field |
610 |
pPowerDelay = |
611 |
-- FIXME: we can't use the proper type "NonNegative Double", since |
612 |
-- the default constant is a plain Double, not a non-negative one. |
613 |
defaultField [| C.oobPowerDelay |] $ |
614 |
simpleField "power_delay" [t| Double |] |
615 |
|
616 |
-- | Primary IP address. |
617 |
pPrimaryIp :: Field |
618 |
pPrimaryIp = optionalStringField "primary_ip" |
619 |
|
620 |
-- | Secondary IP address. |
621 |
pSecondaryIp :: Field |
622 |
pSecondaryIp = optionalNEStringField "secondary_ip" |
623 |
|
624 |
-- | Whether node is re-added to cluster. |
625 |
pReadd :: Field |
626 |
pReadd = defaultFalse "readd" |
627 |
|
628 |
-- | Initial node group. |
629 |
pNodeGroup :: Field |
630 |
pNodeGroup = optionalNEStringField "group" |
631 |
|
632 |
-- | Whether node can become master or master candidate. |
633 |
pMasterCapable :: Field |
634 |
pMasterCapable = optionalField $ booleanField "master_capable" |
635 |
|
636 |
-- | Whether node can host instances. |
637 |
pVmCapable :: Field |
638 |
pVmCapable = optionalField $ booleanField "vm_capable" |
639 |
|
640 |
-- | List of names. |
641 |
pNames :: Field |
642 |
pNames = defaultField [| [] |] $ simpleField "names" [t| [NonEmptyString] |] |
643 |
|
644 |
-- | List of node names. |
645 |
pNodes :: Field |
646 |
pNodes = defaultField [| [] |] $ simpleField "nodes" [t| [NonEmptyString] |] |
647 |
|
648 |
-- | Storage type. |
649 |
pStorageType :: Field |
650 |
pStorageType = simpleField "storage_type" [t| StorageType |] |
651 |
|
652 |
-- | Storage changes (unchecked). |
653 |
pStorageChanges :: Field |
654 |
pStorageChanges = simpleField "changes" [t| UncheckedDict |] |
655 |
|
656 |
-- | Whether the node should become a master candidate. |
657 |
pMasterCandidate :: Field |
658 |
pMasterCandidate = optionalField $ booleanField "master_candidate" |
659 |
|
660 |
-- | Whether the node should be marked as offline. |
661 |
pOffline :: Field |
662 |
pOffline = optionalField $ booleanField "offline" |
663 |
|
664 |
-- | Whether the node should be marked as drained. |
665 |
pDrained ::Field |
666 |
pDrained = optionalField $ booleanField "drained" |
667 |
|
668 |
-- | Whether node(s) should be promoted to master candidate if necessary. |
669 |
pAutoPromote :: Field |
670 |
pAutoPromote = defaultFalse "auto_promote" |
671 |
|
672 |
-- | Whether the node should be marked as powered |
673 |
pPowered :: Field |
674 |
pPowered = optionalField $ booleanField "powered" |
675 |
|
676 |
-- | Iallocator for deciding the target node for shared-storage |
677 |
-- instances during migrate and failover. |
678 |
pIallocator :: Field |
679 |
pIallocator = optionalNEStringField "iallocator" |
680 |
|
681 |
-- | New secondary node. |
682 |
pRemoteNode :: Field |
683 |
pRemoteNode = optionalNEStringField "remote_node" |
684 |
|
685 |
-- | Node evacuation mode. |
686 |
pEvacMode :: Field |
687 |
pEvacMode = renameField "EvacMode" $ simpleField "mode" [t| NodeEvacMode |] |