root / htools / Ganeti / OpParams.hs @ 67fc4de7
History | View | Annotate | Download (41.1 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 |
, DiskAccess(..) |
45 |
, INicParams(..) |
46 |
, IDiskParams(..) |
47 |
, RecreateDisksInfo(..) |
48 |
, DdmOldChanges(..) |
49 |
, SetParamsMods(..) |
50 |
, ExportTarget(..) |
51 |
, pInstanceName |
52 |
, pInstances |
53 |
, pName |
54 |
, pTagsList |
55 |
, pTagsObject |
56 |
, pOutputFields |
57 |
, pShutdownTimeout |
58 |
, pShutdownTimeout' |
59 |
, pShutdownInstance |
60 |
, pForce |
61 |
, pIgnoreOfflineNodes |
62 |
, pNodeName |
63 |
, pNodeNames |
64 |
, pGroupName |
65 |
, pMigrationMode |
66 |
, pMigrationLive |
67 |
, pMigrationCleanup |
68 |
, pForceVariant |
69 |
, pWaitForSync |
70 |
, pWaitForSyncFalse |
71 |
, pIgnoreConsistency |
72 |
, pStorageName |
73 |
, pUseLocking |
74 |
, pNameCheck |
75 |
, pNodeGroupAllocPolicy |
76 |
, pGroupNodeParams |
77 |
, pQueryWhat |
78 |
, pEarlyRelease |
79 |
, pIpCheck |
80 |
, pIpConflictsCheck |
81 |
, pNoRemember |
82 |
, pMigrationTargetNode |
83 |
, pMoveTargetNode |
84 |
, pStartupPaused |
85 |
, pVerbose |
86 |
, pDebugSimulateErrors |
87 |
, pErrorCodes |
88 |
, pSkipChecks |
89 |
, pIgnoreErrors |
90 |
, pOptGroupName |
91 |
, pDiskParams |
92 |
, pHvState |
93 |
, pDiskState |
94 |
, pIgnoreIpolicy |
95 |
, pAllowRuntimeChgs |
96 |
, pInstDisks |
97 |
, pDiskTemplate |
98 |
, pFileDriver |
99 |
, pFileStorageDir |
100 |
, pVgName |
101 |
, pEnabledHypervisors |
102 |
, pHypervisor |
103 |
, pClusterHvParams |
104 |
, pInstHvParams |
105 |
, pClusterBeParams |
106 |
, pInstBeParams |
107 |
, pResetDefaults |
108 |
, pOsHvp |
109 |
, pClusterOsParams |
110 |
, pInstOsParams |
111 |
, pCandidatePoolSize |
112 |
, pUidPool |
113 |
, pAddUids |
114 |
, pRemoveUids |
115 |
, pMaintainNodeHealth |
116 |
, pPreallocWipeDisks |
117 |
, pNicParams |
118 |
, pInstNics |
119 |
, pNdParams |
120 |
, pIpolicy |
121 |
, pDrbdHelper |
122 |
, pDefaultIAllocator |
123 |
, pMasterNetdev |
124 |
, pMasterNetmask |
125 |
, pReservedLvs |
126 |
, pHiddenOs |
127 |
, pBlacklistedOs |
128 |
, pUseExternalMipScript |
129 |
, pQueryFields |
130 |
, pQueryFilter |
131 |
, pOobCommand |
132 |
, pOobTimeout |
133 |
, pIgnoreStatus |
134 |
, pPowerDelay |
135 |
, pPrimaryIp |
136 |
, pSecondaryIp |
137 |
, pReadd |
138 |
, pNodeGroup |
139 |
, pMasterCapable |
140 |
, pVmCapable |
141 |
, pNames |
142 |
, pNodes |
143 |
, pRequiredNodes |
144 |
, pStorageType |
145 |
, pStorageChanges |
146 |
, pMasterCandidate |
147 |
, pOffline |
148 |
, pDrained |
149 |
, pAutoPromote |
150 |
, pPowered |
151 |
, pIallocator |
152 |
, pRemoteNode |
153 |
, pEvacMode |
154 |
, pInstCreateMode |
155 |
, pNoInstall |
156 |
, pInstOs |
157 |
, pPrimaryNode |
158 |
, pSecondaryNode |
159 |
, pSourceHandshake |
160 |
, pSourceInstance |
161 |
, pSourceShutdownTimeout |
162 |
, pSourceX509Ca |
163 |
, pSrcNode |
164 |
, pSrcPath |
165 |
, pStartInstance |
166 |
, pInstTags |
167 |
, pMultiAllocInstances |
168 |
, pTempOsParams |
169 |
, pTempHvParams |
170 |
, pTempBeParams |
171 |
, pIgnoreFailures |
172 |
, pNewName |
173 |
, pIgnoreSecondaries |
174 |
, pRebootType |
175 |
, pIgnoreDiskSize |
176 |
, pRecreateDisksInfo |
177 |
, pStatic |
178 |
, pInstParamsNicChanges |
179 |
, pInstParamsDiskChanges |
180 |
, pRuntimeMem |
181 |
, pOsNameChange |
182 |
, pDiskIndex |
183 |
, pDiskChgAmount |
184 |
, pDiskChgAbsolute |
185 |
, pTargetGroups |
186 |
, pExportMode |
187 |
, pExportTargetNode |
188 |
, pRemoveInstance |
189 |
, pIgnoreRemoveFailures |
190 |
, pX509KeyName |
191 |
, pX509DestCA |
192 |
, pTagSearchPattern |
193 |
, pRestrictedCommand |
194 |
, pReplaceDisksMode |
195 |
, pReplaceDisksList |
196 |
, pAllowFailover |
197 |
, pDelayDuration |
198 |
, pDelayOnMaster |
199 |
, pDelayOnNodes |
200 |
, pDelayRepeat |
201 |
, pIAllocatorDirection |
202 |
, pIAllocatorMode |
203 |
, pIAllocatorReqName |
204 |
, pIAllocatorNics |
205 |
, pIAllocatorDisks |
206 |
, pIAllocatorMemory |
207 |
, pIAllocatorVCpus |
208 |
, pIAllocatorOs |
209 |
, pIAllocatorInstances |
210 |
, pIAllocatorEvacMode |
211 |
, pIAllocatorSpindleUse |
212 |
, pIAllocatorCount |
213 |
, pJQueueNotifyWaitLock |
214 |
, pJQueueNotifyExec |
215 |
, pJQueueLogMessages |
216 |
, pJQueueFail |
217 |
, pTestDummyResult |
218 |
, pTestDummyMessages |
219 |
, pTestDummyFail |
220 |
, pTestDummySubmitJobs |
221 |
, pNetworkName |
222 |
, pNetworkType |
223 |
, pNetworkAddress4 |
224 |
, pNetworkGateway4 |
225 |
, pNetworkAddress6 |
226 |
, pNetworkGateway6 |
227 |
, pNetworkMacPrefix |
228 |
, pNetworkAddRsvdIps |
229 |
, pNetworkRemoveRsvdIps |
230 |
, pNetworkMode |
231 |
, pNetworkLink |
232 |
, dOldQuery |
233 |
, dOldQueryNoLocking |
234 |
) where |
235 |
|
236 |
import Control.Monad (liftM) |
237 |
import qualified Data.Set as Set |
238 |
import Text.JSON (readJSON, showJSON, JSON, JSValue(..), fromJSString, |
239 |
JSObject, toJSObject) |
240 |
import qualified Text.JSON |
241 |
import Text.JSON.Pretty (pp_value) |
242 |
|
243 |
import Ganeti.BasicTypes |
244 |
import qualified Ganeti.Constants as C |
245 |
import Ganeti.THH |
246 |
import Ganeti.JSON |
247 |
import Ganeti.Types |
248 |
import qualified Ganeti.Query.Language as Qlang |
249 |
|
250 |
-- * Helper functions and types |
251 |
|
252 |
-- * Type aliases |
253 |
|
254 |
-- | Build a boolean field. |
255 |
booleanField :: String -> Field |
256 |
booleanField = flip simpleField [t| Bool |] |
257 |
|
258 |
-- | Default a field to 'False'. |
259 |
defaultFalse :: String -> Field |
260 |
defaultFalse = defaultField [| False |] . booleanField |
261 |
|
262 |
-- | Default a field to 'True'. |
263 |
defaultTrue :: String -> Field |
264 |
defaultTrue = defaultField [| True |] . booleanField |
265 |
|
266 |
-- | An alias for a 'String' field. |
267 |
stringField :: String -> Field |
268 |
stringField = flip simpleField [t| String |] |
269 |
|
270 |
-- | An alias for an optional string field. |
271 |
optionalStringField :: String -> Field |
272 |
optionalStringField = optionalField . stringField |
273 |
|
274 |
-- | An alias for an optional non-empty string field. |
275 |
optionalNEStringField :: String -> Field |
276 |
optionalNEStringField = optionalField . flip simpleField [t| NonEmptyString |] |
277 |
|
278 |
-- | Unchecked value, should be replaced by a better definition. |
279 |
type UncheckedValue = JSValue |
280 |
|
281 |
-- | Unchecked dict, should be replaced by a better definition. |
282 |
type UncheckedDict = JSObject JSValue |
283 |
|
284 |
-- | Unchecked list, shoild be replaced by a better definition. |
285 |
type UncheckedList = [JSValue] |
286 |
|
287 |
-- | Function to force a non-negative value, without returning via a |
288 |
-- monad. This is needed for, and should be used /only/ in the case of |
289 |
-- forcing constants. In case the constant is wrong (< 0), this will |
290 |
-- become a runtime error. |
291 |
forceNonNeg :: (Num a, Ord a, Show a) => a -> NonNegative a |
292 |
forceNonNeg i = case mkNonNegative i of |
293 |
Ok n -> n |
294 |
Bad msg -> error msg |
295 |
|
296 |
-- ** Tags |
297 |
|
298 |
-- | Data type representing what items do the tag operations apply to. |
299 |
$(declareSADT "TagType" |
300 |
[ ("TagTypeInstance", 'C.tagInstance) |
301 |
, ("TagTypeNode", 'C.tagNode) |
302 |
, ("TagTypeGroup", 'C.tagNodegroup) |
303 |
, ("TagTypeCluster", 'C.tagCluster) |
304 |
]) |
305 |
$(makeJSONInstance ''TagType) |
306 |
|
307 |
-- | Data type holding a tag object (type and object name). |
308 |
data TagObject = TagInstance String |
309 |
| TagNode String |
310 |
| TagGroup String |
311 |
| TagCluster |
312 |
deriving (Show, Eq) |
313 |
|
314 |
-- | Tag type for a given tag object. |
315 |
tagTypeOf :: TagObject -> TagType |
316 |
tagTypeOf (TagInstance {}) = TagTypeInstance |
317 |
tagTypeOf (TagNode {}) = TagTypeNode |
318 |
tagTypeOf (TagGroup {}) = TagTypeGroup |
319 |
tagTypeOf (TagCluster {}) = TagTypeCluster |
320 |
|
321 |
-- | Gets the potential tag object name. |
322 |
tagNameOf :: TagObject -> Maybe String |
323 |
tagNameOf (TagInstance s) = Just s |
324 |
tagNameOf (TagNode s) = Just s |
325 |
tagNameOf (TagGroup s) = Just s |
326 |
tagNameOf TagCluster = Nothing |
327 |
|
328 |
-- | Builds a 'TagObject' from a tag type and name. |
329 |
tagObjectFrom :: (Monad m) => TagType -> JSValue -> m TagObject |
330 |
tagObjectFrom TagTypeInstance (JSString s) = |
331 |
return . TagInstance $ fromJSString s |
332 |
tagObjectFrom TagTypeNode (JSString s) = return . TagNode $ fromJSString s |
333 |
tagObjectFrom TagTypeGroup (JSString s) = return . TagGroup $ fromJSString s |
334 |
tagObjectFrom TagTypeCluster JSNull = return TagCluster |
335 |
tagObjectFrom t v = |
336 |
fail $ "Invalid tag type/name combination: " ++ show t ++ "/" ++ |
337 |
show (pp_value v) |
338 |
|
339 |
-- | Name of the tag \"name\" field. |
340 |
tagNameField :: String |
341 |
tagNameField = "name" |
342 |
|
343 |
-- | Custom encoder for 'TagObject' as represented in an opcode. |
344 |
encodeTagObject :: TagObject -> (JSValue, [(String, JSValue)]) |
345 |
encodeTagObject t = ( showJSON (tagTypeOf t) |
346 |
, [(tagNameField, maybe JSNull showJSON (tagNameOf t))] ) |
347 |
|
348 |
-- | Custom decoder for 'TagObject' as represented in an opcode. |
349 |
decodeTagObject :: (Monad m) => [(String, JSValue)] -> JSValue -> m TagObject |
350 |
decodeTagObject obj kind = do |
351 |
ttype <- fromJVal kind |
352 |
tname <- fromObj obj tagNameField |
353 |
tagObjectFrom ttype tname |
354 |
|
355 |
-- ** Disks |
356 |
|
357 |
-- | Replace disks type. |
358 |
$(declareSADT "ReplaceDisksMode" |
359 |
[ ("ReplaceOnPrimary", 'C.replaceDiskPri) |
360 |
, ("ReplaceOnSecondary", 'C.replaceDiskSec) |
361 |
, ("ReplaceNewSecondary", 'C.replaceDiskChg) |
362 |
, ("ReplaceAuto", 'C.replaceDiskAuto) |
363 |
]) |
364 |
$(makeJSONInstance ''ReplaceDisksMode) |
365 |
|
366 |
-- | Disk index type (embedding constraints on the index value via a |
367 |
-- smart constructor). |
368 |
newtype DiskIndex = DiskIndex { unDiskIndex :: Int } |
369 |
deriving (Show, Eq, Ord) |
370 |
|
371 |
-- | Smart constructor for 'DiskIndex'. |
372 |
mkDiskIndex :: (Monad m) => Int -> m DiskIndex |
373 |
mkDiskIndex i | i >= 0 && i < C.maxDisks = return (DiskIndex i) |
374 |
| otherwise = fail $ "Invalid value for disk index '" ++ |
375 |
show i ++ "', required between 0 and " ++ |
376 |
show C.maxDisks |
377 |
|
378 |
instance JSON DiskIndex where |
379 |
readJSON v = readJSON v >>= mkDiskIndex |
380 |
showJSON = showJSON . unDiskIndex |
381 |
|
382 |
-- ** I* param types |
383 |
|
384 |
-- | Type holding disk access modes. |
385 |
$(declareSADT "DiskAccess" |
386 |
[ ("DiskReadOnly", 'C.diskRdonly) |
387 |
, ("DiskReadWrite", 'C.diskRdwr) |
388 |
]) |
389 |
$(makeJSONInstance ''DiskAccess) |
390 |
|
391 |
-- | NIC modification definition. |
392 |
$(buildObject "INicParams" "inic" |
393 |
[ optionalField $ simpleField C.inicMac [t| NonEmptyString |] |
394 |
, optionalField $ simpleField C.inicIp [t| String |] |
395 |
, optionalField $ simpleField C.inicMode [t| NonEmptyString |] |
396 |
, optionalField $ simpleField C.inicLink [t| NonEmptyString |] |
397 |
]) |
398 |
|
399 |
-- | Disk modification definition. FIXME: disksize should be VTYPE_UNIT. |
400 |
$(buildObject "IDiskParams" "idisk" |
401 |
[ optionalField $ simpleField C.idiskSize [t| Int |] |
402 |
, optionalField $ simpleField C.idiskMode [t| DiskAccess |] |
403 |
, optionalField $ simpleField C.idiskAdopt [t| NonEmptyString |] |
404 |
, optionalField $ simpleField C.idiskVg [t| NonEmptyString |] |
405 |
, optionalField $ simpleField C.idiskMetavg [t| NonEmptyString |] |
406 |
]) |
407 |
|
408 |
-- | Disk changes type for OpInstanceRecreateDisks. This is a bit |
409 |
-- strange, because the type in Python is something like Either |
410 |
-- [DiskIndex] [DiskChanges], but we can't represent the type of an |
411 |
-- empty list in JSON, so we have to add a custom case for the empty |
412 |
-- list. |
413 |
data RecreateDisksInfo |
414 |
= RecreateDisksAll |
415 |
| RecreateDisksIndices (NonEmpty DiskIndex) |
416 |
| RecreateDisksParams (NonEmpty (DiskIndex, IDiskParams)) |
417 |
deriving (Eq, Show) |
418 |
|
419 |
readRecreateDisks :: JSValue -> Text.JSON.Result RecreateDisksInfo |
420 |
readRecreateDisks (JSArray []) = return RecreateDisksAll |
421 |
readRecreateDisks v = |
422 |
case readJSON v::Text.JSON.Result [DiskIndex] of |
423 |
Text.JSON.Ok indices -> liftM RecreateDisksIndices (mkNonEmpty indices) |
424 |
_ -> case readJSON v::Text.JSON.Result [(DiskIndex, IDiskParams)] of |
425 |
Text.JSON.Ok params -> liftM RecreateDisksParams (mkNonEmpty params) |
426 |
_ -> fail $ "Can't parse disk information as either list of disk" |
427 |
++ " indices or list of disk parameters; value recevied:" |
428 |
++ show (pp_value v) |
429 |
|
430 |
instance JSON RecreateDisksInfo where |
431 |
readJSON = readRecreateDisks |
432 |
showJSON RecreateDisksAll = showJSON () |
433 |
showJSON (RecreateDisksIndices idx) = showJSON idx |
434 |
showJSON (RecreateDisksParams params) = showJSON params |
435 |
|
436 |
-- | Simple type for old-style ddm changes. |
437 |
data DdmOldChanges = DdmOldIndex (NonNegative Int) |
438 |
| DdmOldMod DdmSimple |
439 |
deriving (Eq, Show) |
440 |
|
441 |
readDdmOldChanges :: JSValue -> Text.JSON.Result DdmOldChanges |
442 |
readDdmOldChanges v = |
443 |
case readJSON v::Text.JSON.Result (NonNegative Int) of |
444 |
Text.JSON.Ok nn -> return $ DdmOldIndex nn |
445 |
_ -> case readJSON v::Text.JSON.Result DdmSimple of |
446 |
Text.JSON.Ok ddms -> return $ DdmOldMod ddms |
447 |
_ -> fail $ "Can't parse value '" ++ show (pp_value v) ++ "' as" |
448 |
++ " either index or modification" |
449 |
|
450 |
instance JSON DdmOldChanges where |
451 |
showJSON (DdmOldIndex i) = showJSON i |
452 |
showJSON (DdmOldMod m) = showJSON m |
453 |
readJSON = readDdmOldChanges |
454 |
|
455 |
-- | Instance disk or nic modifications. |
456 |
data SetParamsMods a |
457 |
= SetParamsEmpty |
458 |
| SetParamsDeprecated (NonEmpty (DdmOldChanges, a)) |
459 |
| SetParamsNew (NonEmpty (DdmFull, Int, a)) |
460 |
deriving (Eq, Show) |
461 |
|
462 |
-- | Custom deserialiser for 'SetParamsMods'. |
463 |
readSetParams :: (JSON a) => JSValue -> Text.JSON.Result (SetParamsMods a) |
464 |
readSetParams (JSArray []) = return SetParamsEmpty |
465 |
readSetParams v = |
466 |
case readJSON v::Text.JSON.Result [(DdmOldChanges, JSValue)] of |
467 |
Text.JSON.Ok _ -> liftM SetParamsDeprecated $ readJSON v |
468 |
_ -> liftM SetParamsNew $ readJSON v |
469 |
|
470 |
instance (JSON a) => JSON (SetParamsMods a) where |
471 |
showJSON SetParamsEmpty = showJSON () |
472 |
showJSON (SetParamsDeprecated v) = showJSON v |
473 |
showJSON (SetParamsNew v) = showJSON v |
474 |
readJSON = readSetParams |
475 |
|
476 |
-- | Custom type for target_node parameter of OpBackupExport, which |
477 |
-- varies depending on mode. FIXME: this uses an UncheckedList since |
478 |
-- we don't care about individual rows (just like the Python code |
479 |
-- tests). But the proper type could be parsed if we wanted. |
480 |
data ExportTarget = ExportTargetLocal NonEmptyString |
481 |
| ExportTargetRemote UncheckedList |
482 |
deriving (Eq, Show) |
483 |
|
484 |
-- | Custom reader for 'ExportTarget'. |
485 |
readExportTarget :: JSValue -> Text.JSON.Result ExportTarget |
486 |
readExportTarget (JSString s) = liftM ExportTargetLocal $ |
487 |
mkNonEmpty (fromJSString s) |
488 |
readExportTarget (JSArray arr) = return $ ExportTargetRemote arr |
489 |
readExportTarget v = fail $ "Invalid value received for 'target_node': " ++ |
490 |
show (pp_value v) |
491 |
|
492 |
instance JSON ExportTarget where |
493 |
showJSON (ExportTargetLocal s) = showJSON s |
494 |
showJSON (ExportTargetRemote l) = showJSON l |
495 |
readJSON = readExportTarget |
496 |
|
497 |
-- * Parameters |
498 |
|
499 |
-- | A required instance name (for single-instance LUs). |
500 |
pInstanceName :: Field |
501 |
pInstanceName = simpleField "instance_name" [t| String |] |
502 |
|
503 |
-- | A list of instances. |
504 |
pInstances :: Field |
505 |
pInstances = defaultField [| [] |] $ |
506 |
simpleField "instances" [t| [NonEmptyString] |] |
507 |
|
508 |
-- | A generic name. |
509 |
pName :: Field |
510 |
pName = simpleField "name" [t| NonEmptyString |] |
511 |
|
512 |
-- | Tags list. |
513 |
pTagsList :: Field |
514 |
pTagsList = simpleField "tags" [t| [String] |] |
515 |
|
516 |
-- | Tags object. |
517 |
pTagsObject :: Field |
518 |
pTagsObject = |
519 |
customField 'decodeTagObject 'encodeTagObject [tagNameField] $ |
520 |
simpleField "kind" [t| TagObject |] |
521 |
|
522 |
-- | Selected output fields. |
523 |
pOutputFields :: Field |
524 |
pOutputFields = simpleField "output_fields" [t| [NonEmptyString] |] |
525 |
|
526 |
-- | How long to wait for instance to shut down. |
527 |
pShutdownTimeout :: Field |
528 |
pShutdownTimeout = defaultField [| forceNonNeg C.defaultShutdownTimeout |] $ |
529 |
simpleField "shutdown_timeout" [t| NonNegative Int |] |
530 |
|
531 |
-- | Another name for the shutdown timeout, because we like to be |
532 |
-- inconsistent. |
533 |
pShutdownTimeout' :: Field |
534 |
pShutdownTimeout' = |
535 |
renameField "InstShutdownTimeout" . |
536 |
defaultField [| forceNonNeg C.defaultShutdownTimeout |] $ |
537 |
simpleField "timeout" [t| NonNegative Int |] |
538 |
|
539 |
-- | Whether to shutdown the instance in backup-export. |
540 |
pShutdownInstance :: Field |
541 |
pShutdownInstance = defaultTrue "shutdown" |
542 |
|
543 |
-- | Whether to force the operation. |
544 |
pForce :: Field |
545 |
pForce = defaultFalse "force" |
546 |
|
547 |
-- | Whether to ignore offline nodes. |
548 |
pIgnoreOfflineNodes :: Field |
549 |
pIgnoreOfflineNodes = defaultFalse "ignore_offline_nodes" |
550 |
|
551 |
-- | A required node name (for single-node LUs). |
552 |
pNodeName :: Field |
553 |
pNodeName = simpleField "node_name" [t| NonEmptyString |] |
554 |
|
555 |
-- | List of nodes. |
556 |
pNodeNames :: Field |
557 |
pNodeNames = |
558 |
defaultField [| [] |] $ simpleField "node_names" [t| [NonEmptyString] |] |
559 |
|
560 |
-- | A required node group name (for single-group LUs). |
561 |
pGroupName :: Field |
562 |
pGroupName = simpleField "group_name" [t| NonEmptyString |] |
563 |
|
564 |
-- | Migration type (live\/non-live). |
565 |
pMigrationMode :: Field |
566 |
pMigrationMode = |
567 |
renameField "MigrationMode" . |
568 |
optionalField $ |
569 |
simpleField "mode" [t| MigrationMode |] |
570 |
|
571 |
-- | Obsolete \'live\' migration mode (boolean). |
572 |
pMigrationLive :: Field |
573 |
pMigrationLive = |
574 |
renameField "OldLiveMode" . optionalField $ booleanField "live" |
575 |
|
576 |
-- | Migration cleanup parameter. |
577 |
pMigrationCleanup :: Field |
578 |
pMigrationCleanup = renameField "MigrationCleanup" $ defaultFalse "cleanup" |
579 |
|
580 |
-- | Whether to force an unknown OS variant. |
581 |
pForceVariant :: Field |
582 |
pForceVariant = defaultFalse "force_variant" |
583 |
|
584 |
-- | Whether to wait for the disk to synchronize. |
585 |
pWaitForSync :: Field |
586 |
pWaitForSync = defaultTrue "wait_for_sync" |
587 |
|
588 |
-- | Whether to wait for the disk to synchronize (defaults to false). |
589 |
pWaitForSyncFalse :: Field |
590 |
pWaitForSyncFalse = defaultField [| False |] pWaitForSync |
591 |
|
592 |
-- | Whether to ignore disk consistency |
593 |
pIgnoreConsistency :: Field |
594 |
pIgnoreConsistency = defaultFalse "ignore_consistency" |
595 |
|
596 |
-- | Storage name. |
597 |
pStorageName :: Field |
598 |
pStorageName = |
599 |
renameField "StorageName" $ simpleField "name" [t| NonEmptyString |] |
600 |
|
601 |
-- | Whether to use synchronization. |
602 |
pUseLocking :: Field |
603 |
pUseLocking = defaultFalse "use_locking" |
604 |
|
605 |
-- | Whether to check name. |
606 |
pNameCheck :: Field |
607 |
pNameCheck = defaultTrue "name_check" |
608 |
|
609 |
-- | Instance allocation policy. |
610 |
pNodeGroupAllocPolicy :: Field |
611 |
pNodeGroupAllocPolicy = optionalField $ |
612 |
simpleField "alloc_policy" [t| AllocPolicy |] |
613 |
|
614 |
-- | Default node parameters for group. |
615 |
pGroupNodeParams :: Field |
616 |
pGroupNodeParams = optionalField $ simpleField "ndparams" [t| UncheckedDict |] |
617 |
|
618 |
-- | Resource(s) to query for. |
619 |
pQueryWhat :: Field |
620 |
pQueryWhat = simpleField "what" [t| Qlang.QueryTypeOp |] |
621 |
|
622 |
-- | Whether to release locks as soon as possible. |
623 |
pEarlyRelease :: Field |
624 |
pEarlyRelease = defaultFalse "early_release" |
625 |
|
626 |
-- | Whether to ensure instance's IP address is inactive. |
627 |
pIpCheck :: Field |
628 |
pIpCheck = defaultTrue "ip_check" |
629 |
|
630 |
-- | Check for conflicting IPs. |
631 |
pIpConflictsCheck :: Field |
632 |
pIpConflictsCheck = defaultTrue "conflicts_check" |
633 |
|
634 |
-- | Do not remember instance state changes. |
635 |
pNoRemember :: Field |
636 |
pNoRemember = defaultFalse "no_remember" |
637 |
|
638 |
-- | Target node for instance migration/failover. |
639 |
pMigrationTargetNode :: Field |
640 |
pMigrationTargetNode = optionalNEStringField "target_node" |
641 |
|
642 |
-- | Target node for instance move (required). |
643 |
pMoveTargetNode :: Field |
644 |
pMoveTargetNode = |
645 |
renameField "MoveTargetNode" $ |
646 |
simpleField "target_node" [t| NonEmptyString |] |
647 |
|
648 |
-- | Pause instance at startup. |
649 |
pStartupPaused :: Field |
650 |
pStartupPaused = defaultFalse "startup_paused" |
651 |
|
652 |
-- | Verbose mode. |
653 |
pVerbose :: Field |
654 |
pVerbose = defaultFalse "verbose" |
655 |
|
656 |
-- ** Parameters for cluster verification |
657 |
|
658 |
-- | Whether to simulate errors (useful for debugging). |
659 |
pDebugSimulateErrors :: Field |
660 |
pDebugSimulateErrors = defaultFalse "debug_simulate_errors" |
661 |
|
662 |
-- | Error codes. |
663 |
pErrorCodes :: Field |
664 |
pErrorCodes = defaultFalse "error_codes" |
665 |
|
666 |
-- | Which checks to skip. |
667 |
pSkipChecks :: Field |
668 |
pSkipChecks = defaultField [| Set.empty |] $ |
669 |
simpleField "skip_checks" [t| Set.Set VerifyOptionalChecks |] |
670 |
|
671 |
-- | List of error codes that should be treated as warnings. |
672 |
pIgnoreErrors :: Field |
673 |
pIgnoreErrors = defaultField [| Set.empty |] $ |
674 |
simpleField "ignore_errors" [t| Set.Set CVErrorCode |] |
675 |
|
676 |
-- | Optional group name. |
677 |
pOptGroupName :: Field |
678 |
pOptGroupName = renameField "OptGroupName" . |
679 |
optionalField $ simpleField "group_name" [t| NonEmptyString |] |
680 |
|
681 |
-- | Disk templates' parameter defaults. |
682 |
pDiskParams :: Field |
683 |
pDiskParams = optionalField $ |
684 |
simpleField "diskparams" [t| GenericContainer DiskTemplate |
685 |
UncheckedDict |] |
686 |
|
687 |
-- * Parameters for node resource model |
688 |
|
689 |
-- | Set hypervisor states. |
690 |
pHvState :: Field |
691 |
pHvState = optionalField $ simpleField "hv_state" [t| UncheckedDict |] |
692 |
|
693 |
-- | Set disk states. |
694 |
pDiskState :: Field |
695 |
pDiskState = optionalField $ simpleField "disk_state" [t| UncheckedDict |] |
696 |
|
697 |
-- | Whether to ignore ipolicy violations. |
698 |
pIgnoreIpolicy :: Field |
699 |
pIgnoreIpolicy = defaultFalse "ignore_ipolicy" |
700 |
|
701 |
-- | Allow runtime changes while migrating. |
702 |
pAllowRuntimeChgs :: Field |
703 |
pAllowRuntimeChgs = defaultTrue "allow_runtime_changes" |
704 |
|
705 |
-- | Utility type for OpClusterSetParams. |
706 |
type TestClusterOsListItem = (DdmSimple, NonEmptyString) |
707 |
|
708 |
-- | Utility type of OsList. |
709 |
type TestClusterOsList = [TestClusterOsListItem] |
710 |
|
711 |
-- Utility type for NIC definitions. |
712 |
--type TestNicDef = INicParams |
713 |
|
714 |
-- | List of instance disks. |
715 |
pInstDisks :: Field |
716 |
pInstDisks = renameField "instDisks" $ simpleField "disks" [t| [IDiskParams] |] |
717 |
|
718 |
-- | Instance disk template. |
719 |
pDiskTemplate :: Field |
720 |
pDiskTemplate = simpleField "disk_template" [t| DiskTemplate |] |
721 |
|
722 |
-- | File driver. |
723 |
pFileDriver :: Field |
724 |
pFileDriver = optionalField $ simpleField "file_driver" [t| FileDriver |] |
725 |
|
726 |
-- | Directory for storing file-backed disks. |
727 |
pFileStorageDir :: Field |
728 |
pFileStorageDir = optionalNEStringField "file_storage_dir" |
729 |
|
730 |
-- | Volume group name. |
731 |
pVgName :: Field |
732 |
pVgName = optionalStringField "vg_name" |
733 |
|
734 |
-- | List of enabled hypervisors. |
735 |
pEnabledHypervisors :: Field |
736 |
pEnabledHypervisors = |
737 |
optionalField $ |
738 |
simpleField "enabled_hypervisors" [t| NonEmpty Hypervisor |] |
739 |
|
740 |
-- | Selected hypervisor for an instance. |
741 |
pHypervisor :: Field |
742 |
pHypervisor = |
743 |
optionalField $ |
744 |
simpleField "hypervisor" [t| Hypervisor |] |
745 |
|
746 |
-- | Cluster-wide hypervisor parameters, hypervisor-dependent. |
747 |
pClusterHvParams :: Field |
748 |
pClusterHvParams = |
749 |
renameField "ClusterHvParams" . |
750 |
optionalField $ |
751 |
simpleField "hvparams" [t| Container UncheckedDict |] |
752 |
|
753 |
-- | Instance hypervisor parameters. |
754 |
pInstHvParams :: Field |
755 |
pInstHvParams = |
756 |
renameField "InstHvParams" . |
757 |
defaultField [| toJSObject [] |] $ |
758 |
simpleField "hvparams" [t| UncheckedDict |] |
759 |
|
760 |
-- | Cluster-wide beparams. |
761 |
pClusterBeParams :: Field |
762 |
pClusterBeParams = |
763 |
renameField "ClusterBeParams" . |
764 |
optionalField $ simpleField "beparams" [t| UncheckedDict |] |
765 |
|
766 |
-- | Instance beparams. |
767 |
pInstBeParams :: Field |
768 |
pInstBeParams = |
769 |
renameField "InstBeParams" . |
770 |
defaultField [| toJSObject [] |] $ |
771 |
simpleField "beparams" [t| UncheckedDict |] |
772 |
|
773 |
-- | Reset instance parameters to default if equal. |
774 |
pResetDefaults :: Field |
775 |
pResetDefaults = defaultFalse "identify_defaults" |
776 |
|
777 |
-- | Cluster-wide per-OS hypervisor parameter defaults. |
778 |
pOsHvp :: Field |
779 |
pOsHvp = optionalField $ simpleField "os_hvp" [t| Container UncheckedDict |] |
780 |
|
781 |
-- | Cluster-wide OS parameter defaults. |
782 |
pClusterOsParams :: Field |
783 |
pClusterOsParams = |
784 |
renameField "ClusterOsParams" . |
785 |
optionalField $ simpleField "osparams" [t| Container UncheckedDict |] |
786 |
|
787 |
-- | Instance OS parameters. |
788 |
pInstOsParams :: Field |
789 |
pInstOsParams = |
790 |
renameField "InstOsParams" . defaultField [| toJSObject [] |] $ |
791 |
simpleField "osparams" [t| UncheckedDict |] |
792 |
|
793 |
-- | Temporary OS parameters (currently only in reinstall, might be |
794 |
-- added to install as well). |
795 |
pTempOsParams :: Field |
796 |
pTempOsParams = |
797 |
renameField "TempOsParams" . |
798 |
optionalField $ simpleField "osparams" [t| UncheckedDict |] |
799 |
|
800 |
-- | Temporary hypervisor parameters, hypervisor-dependent. |
801 |
pTempHvParams :: Field |
802 |
pTempHvParams = |
803 |
renameField "TempHvParams" . |
804 |
defaultField [| toJSObject [] |] $ |
805 |
simpleField "hvparams" [t| UncheckedDict |] |
806 |
|
807 |
-- | Temporary backend parameters. |
808 |
pTempBeParams :: Field |
809 |
pTempBeParams = |
810 |
renameField "TempBeParams" . |
811 |
defaultField [| toJSObject [] |] $ |
812 |
simpleField "beparams" [t| UncheckedDict |] |
813 |
|
814 |
-- | Candidate pool size. |
815 |
pCandidatePoolSize :: Field |
816 |
pCandidatePoolSize = |
817 |
optionalField $ simpleField "candidate_pool_size" [t| Positive Int |] |
818 |
|
819 |
-- | Set UID pool, must be list of lists describing UID ranges (two |
820 |
-- items, start and end inclusive. |
821 |
pUidPool :: Field |
822 |
pUidPool = optionalField $ simpleField "uid_pool" [t| [[(Int, Int)]] |] |
823 |
|
824 |
-- | Extend UID pool, must be list of lists describing UID ranges (two |
825 |
-- items, start and end inclusive. |
826 |
pAddUids :: Field |
827 |
pAddUids = optionalField $ simpleField "add_uids" [t| [[(Int, Int)]] |] |
828 |
|
829 |
-- | Shrink UID pool, must be list of lists describing UID ranges (two |
830 |
-- items, start and end inclusive) to be removed. |
831 |
pRemoveUids :: Field |
832 |
pRemoveUids = optionalField $ simpleField "remove_uids" [t| [[(Int, Int)]] |] |
833 |
|
834 |
-- | Whether to automatically maintain node health. |
835 |
pMaintainNodeHealth :: Field |
836 |
pMaintainNodeHealth = optionalField $ booleanField "maintain_node_health" |
837 |
|
838 |
-- | Whether to wipe disks before allocating them to instances. |
839 |
pPreallocWipeDisks :: Field |
840 |
pPreallocWipeDisks = optionalField $ booleanField "prealloc_wipe_disks" |
841 |
|
842 |
-- | Cluster-wide NIC parameter defaults. |
843 |
pNicParams :: Field |
844 |
pNicParams = optionalField $ simpleField "nicparams" [t| INicParams |] |
845 |
|
846 |
-- | Instance NIC definitions. |
847 |
pInstNics :: Field |
848 |
pInstNics = simpleField "nics" [t| [INicParams] |] |
849 |
|
850 |
-- | Cluster-wide node parameter defaults. |
851 |
pNdParams :: Field |
852 |
pNdParams = optionalField $ simpleField "ndparams" [t| UncheckedDict |] |
853 |
|
854 |
-- | Cluster-wide ipolicy specs. |
855 |
pIpolicy :: Field |
856 |
pIpolicy = optionalField $ simpleField "ipolicy" [t| UncheckedDict |] |
857 |
|
858 |
-- | DRBD helper program. |
859 |
pDrbdHelper :: Field |
860 |
pDrbdHelper = optionalStringField "drbd_helper" |
861 |
|
862 |
-- | Default iallocator for cluster. |
863 |
pDefaultIAllocator :: Field |
864 |
pDefaultIAllocator = optionalStringField "default_iallocator" |
865 |
|
866 |
-- | Master network device. |
867 |
pMasterNetdev :: Field |
868 |
pMasterNetdev = optionalStringField "master_netdev" |
869 |
|
870 |
-- | Netmask of the master IP. |
871 |
pMasterNetmask :: Field |
872 |
pMasterNetmask = |
873 |
optionalField $ simpleField "master_netmask" [t| NonNegative Int |] |
874 |
|
875 |
-- | List of reserved LVs. |
876 |
pReservedLvs :: Field |
877 |
pReservedLvs = |
878 |
optionalField $ simpleField "reserved_lvs" [t| [NonEmptyString] |] |
879 |
|
880 |
-- | Modify list of hidden operating systems: each modification must |
881 |
-- have two items, the operation and the OS name; the operation can be |
882 |
-- add or remove. |
883 |
pHiddenOs :: Field |
884 |
pHiddenOs = optionalField $ simpleField "hidden_os" [t| TestClusterOsList |] |
885 |
|
886 |
-- | Modify list of blacklisted operating systems: each modification |
887 |
-- must have two items, the operation and the OS name; the operation |
888 |
-- can be add or remove. |
889 |
pBlacklistedOs :: Field |
890 |
pBlacklistedOs = |
891 |
optionalField $ simpleField "blacklisted_os" [t| TestClusterOsList |] |
892 |
|
893 |
-- | Whether to use an external master IP address setup script. |
894 |
pUseExternalMipScript :: Field |
895 |
pUseExternalMipScript = optionalField $ booleanField "use_external_mip_script" |
896 |
|
897 |
-- | Requested fields. |
898 |
pQueryFields :: Field |
899 |
pQueryFields = simpleField "fields" [t| [NonEmptyString] |] |
900 |
|
901 |
-- | Query filter. |
902 |
pQueryFilter :: Field |
903 |
pQueryFilter = simpleField "qfilter" [t| Qlang.Filter String |] |
904 |
|
905 |
-- | OOB command to run. |
906 |
pOobCommand :: Field |
907 |
pOobCommand = simpleField "command" [t| OobCommand |] |
908 |
|
909 |
-- | Timeout before the OOB helper will be terminated. |
910 |
pOobTimeout :: Field |
911 |
pOobTimeout = |
912 |
defaultField [| C.oobTimeout |] $ simpleField "timeout" [t| Int |] |
913 |
|
914 |
-- | Ignores the node offline status for power off. |
915 |
pIgnoreStatus :: Field |
916 |
pIgnoreStatus = defaultFalse "ignore_status" |
917 |
|
918 |
-- | Time in seconds to wait between powering on nodes. |
919 |
pPowerDelay :: Field |
920 |
pPowerDelay = |
921 |
-- FIXME: we can't use the proper type "NonNegative Double", since |
922 |
-- the default constant is a plain Double, not a non-negative one. |
923 |
defaultField [| C.oobPowerDelay |] $ |
924 |
simpleField "power_delay" [t| Double |] |
925 |
|
926 |
-- | Primary IP address. |
927 |
pPrimaryIp :: Field |
928 |
pPrimaryIp = optionalStringField "primary_ip" |
929 |
|
930 |
-- | Secondary IP address. |
931 |
pSecondaryIp :: Field |
932 |
pSecondaryIp = optionalNEStringField "secondary_ip" |
933 |
|
934 |
-- | Whether node is re-added to cluster. |
935 |
pReadd :: Field |
936 |
pReadd = defaultFalse "readd" |
937 |
|
938 |
-- | Initial node group. |
939 |
pNodeGroup :: Field |
940 |
pNodeGroup = optionalNEStringField "group" |
941 |
|
942 |
-- | Whether node can become master or master candidate. |
943 |
pMasterCapable :: Field |
944 |
pMasterCapable = optionalField $ booleanField "master_capable" |
945 |
|
946 |
-- | Whether node can host instances. |
947 |
pVmCapable :: Field |
948 |
pVmCapable = optionalField $ booleanField "vm_capable" |
949 |
|
950 |
-- | List of names. |
951 |
pNames :: Field |
952 |
pNames = defaultField [| [] |] $ simpleField "names" [t| [NonEmptyString] |] |
953 |
|
954 |
-- | List of node names. |
955 |
pNodes :: Field |
956 |
pNodes = defaultField [| [] |] $ simpleField "nodes" [t| [NonEmptyString] |] |
957 |
|
958 |
-- | Required list of node names. |
959 |
pRequiredNodes :: Field |
960 |
pRequiredNodes = |
961 |
renameField "ReqNodes " $ simpleField "nodes" [t| [NonEmptyString] |] |
962 |
|
963 |
-- | Storage type. |
964 |
pStorageType :: Field |
965 |
pStorageType = simpleField "storage_type" [t| StorageType |] |
966 |
|
967 |
-- | Storage changes (unchecked). |
968 |
pStorageChanges :: Field |
969 |
pStorageChanges = simpleField "changes" [t| UncheckedDict |] |
970 |
|
971 |
-- | Whether the node should become a master candidate. |
972 |
pMasterCandidate :: Field |
973 |
pMasterCandidate = optionalField $ booleanField "master_candidate" |
974 |
|
975 |
-- | Whether the node should be marked as offline. |
976 |
pOffline :: Field |
977 |
pOffline = optionalField $ booleanField "offline" |
978 |
|
979 |
-- | Whether the node should be marked as drained. |
980 |
pDrained ::Field |
981 |
pDrained = optionalField $ booleanField "drained" |
982 |
|
983 |
-- | Whether node(s) should be promoted to master candidate if necessary. |
984 |
pAutoPromote :: Field |
985 |
pAutoPromote = defaultFalse "auto_promote" |
986 |
|
987 |
-- | Whether the node should be marked as powered |
988 |
pPowered :: Field |
989 |
pPowered = optionalField $ booleanField "powered" |
990 |
|
991 |
-- | Iallocator for deciding the target node for shared-storage |
992 |
-- instances during migrate and failover. |
993 |
pIallocator :: Field |
994 |
pIallocator = optionalNEStringField "iallocator" |
995 |
|
996 |
-- | New secondary node. |
997 |
pRemoteNode :: Field |
998 |
pRemoteNode = optionalNEStringField "remote_node" |
999 |
|
1000 |
-- | Node evacuation mode. |
1001 |
pEvacMode :: Field |
1002 |
pEvacMode = renameField "EvacMode" $ simpleField "mode" [t| NodeEvacMode |] |
1003 |
|
1004 |
-- | Instance creation mode. |
1005 |
pInstCreateMode :: Field |
1006 |
pInstCreateMode = |
1007 |
renameField "InstCreateMode" $ simpleField "mode" [t| InstCreateMode |] |
1008 |
|
1009 |
-- | Do not install the OS (will disable automatic start). |
1010 |
pNoInstall :: Field |
1011 |
pNoInstall = optionalField $ booleanField "no_install" |
1012 |
|
1013 |
-- | OS type for instance installation. |
1014 |
pInstOs :: Field |
1015 |
pInstOs = optionalNEStringField "os_type" |
1016 |
|
1017 |
-- | Primary node for an instance. |
1018 |
pPrimaryNode :: Field |
1019 |
pPrimaryNode = optionalNEStringField "pnode" |
1020 |
|
1021 |
-- | Secondary node for an instance. |
1022 |
pSecondaryNode :: Field |
1023 |
pSecondaryNode = optionalNEStringField "snode" |
1024 |
|
1025 |
-- | Signed handshake from source (remote import only). |
1026 |
pSourceHandshake :: Field |
1027 |
pSourceHandshake = |
1028 |
optionalField $ simpleField "source_handshake" [t| UncheckedList |] |
1029 |
|
1030 |
-- | Source instance name (remote import only). |
1031 |
pSourceInstance :: Field |
1032 |
pSourceInstance = optionalNEStringField "source_instance_name" |
1033 |
|
1034 |
-- | How long source instance was given to shut down (remote import only). |
1035 |
-- FIXME: non-negative int, whereas the constant is a plain int. |
1036 |
pSourceShutdownTimeout :: Field |
1037 |
pSourceShutdownTimeout = |
1038 |
defaultField [| forceNonNeg C.defaultShutdownTimeout |] $ |
1039 |
simpleField "source_shutdown_timeout" [t| NonNegative Int |] |
1040 |
|
1041 |
-- | Source X509 CA in PEM format (remote import only). |
1042 |
pSourceX509Ca :: Field |
1043 |
pSourceX509Ca = optionalNEStringField "source_x509_ca" |
1044 |
|
1045 |
-- | Source node for import. |
1046 |
pSrcNode :: Field |
1047 |
pSrcNode = optionalNEStringField "src_node" |
1048 |
|
1049 |
-- | Source directory for import. |
1050 |
pSrcPath :: Field |
1051 |
pSrcPath = optionalNEStringField "src_path" |
1052 |
|
1053 |
-- | Whether to start instance after creation. |
1054 |
pStartInstance :: Field |
1055 |
pStartInstance = defaultTrue "start" |
1056 |
|
1057 |
-- | Instance tags. FIXME: unify/simplify with pTags, once that |
1058 |
-- migrates to NonEmpty String. |
1059 |
pInstTags :: Field |
1060 |
pInstTags = |
1061 |
renameField "InstTags" . |
1062 |
defaultField [| [] |] $ |
1063 |
simpleField "tags" [t| [NonEmptyString] |] |
1064 |
|
1065 |
-- | Unchecked list of OpInstanceCreate, used in OpInstanceMultiAlloc. |
1066 |
pMultiAllocInstances :: Field |
1067 |
pMultiAllocInstances = |
1068 |
renameField "InstMultiAlloc" . |
1069 |
defaultField [| [] |] $ |
1070 |
simpleField "instances"[t| UncheckedList |] |
1071 |
|
1072 |
-- | Ignore failures parameter. |
1073 |
pIgnoreFailures :: Field |
1074 |
pIgnoreFailures = defaultFalse "ignore_failures" |
1075 |
|
1076 |
-- | New instance or cluster name. |
1077 |
pNewName :: Field |
1078 |
pNewName = simpleField "new_name" [t| NonEmptyString |] |
1079 |
|
1080 |
-- | Whether to start the instance even if secondary disks are failing. |
1081 |
pIgnoreSecondaries :: Field |
1082 |
pIgnoreSecondaries = defaultFalse "ignore_secondaries" |
1083 |
|
1084 |
-- | How to reboot the instance. |
1085 |
pRebootType :: Field |
1086 |
pRebootType = simpleField "reboot_type" [t| RebootType |] |
1087 |
|
1088 |
-- | Whether to ignore recorded disk size. |
1089 |
pIgnoreDiskSize :: Field |
1090 |
pIgnoreDiskSize = defaultFalse "ignore_size" |
1091 |
|
1092 |
-- | Disk list for recreate disks. |
1093 |
pRecreateDisksInfo :: Field |
1094 |
pRecreateDisksInfo = |
1095 |
renameField "RecreateDisksInfo" . |
1096 |
defaultField [| RecreateDisksAll |] $ |
1097 |
simpleField "disks" [t| RecreateDisksInfo |] |
1098 |
|
1099 |
-- | Whether to only return configuration data without querying nodes. |
1100 |
pStatic :: Field |
1101 |
pStatic = defaultFalse "static" |
1102 |
|
1103 |
-- | InstanceSetParams NIC changes. |
1104 |
pInstParamsNicChanges :: Field |
1105 |
pInstParamsNicChanges = |
1106 |
renameField "InstNicChanges" . |
1107 |
defaultField [| SetParamsEmpty |] $ |
1108 |
simpleField "nics" [t| SetParamsMods INicParams |] |
1109 |
|
1110 |
-- | InstanceSetParams Disk changes. |
1111 |
pInstParamsDiskChanges :: Field |
1112 |
pInstParamsDiskChanges = |
1113 |
renameField "InstDiskChanges" . |
1114 |
defaultField [| SetParamsEmpty |] $ |
1115 |
simpleField "disks" [t| SetParamsMods IDiskParams |] |
1116 |
|
1117 |
-- | New runtime memory. |
1118 |
pRuntimeMem :: Field |
1119 |
pRuntimeMem = optionalField $ simpleField "runtime_mem" [t| Positive Int |] |
1120 |
|
1121 |
-- | Change the instance's OS without reinstalling the instance |
1122 |
pOsNameChange :: Field |
1123 |
pOsNameChange = optionalNEStringField "os_name" |
1124 |
|
1125 |
-- | Disk index for e.g. grow disk. |
1126 |
pDiskIndex :: Field |
1127 |
pDiskIndex = renameField "DiskIndex " $ simpleField "disk" [t| DiskIndex |] |
1128 |
|
1129 |
-- | Disk amount to add or grow to. |
1130 |
pDiskChgAmount :: Field |
1131 |
pDiskChgAmount = |
1132 |
renameField "DiskChgAmount" $ simpleField "amount" [t| NonNegative Int |] |
1133 |
|
1134 |
-- | Whether the amount parameter is an absolute target or a relative one. |
1135 |
pDiskChgAbsolute :: Field |
1136 |
pDiskChgAbsolute = renameField "DiskChkAbsolute" $ defaultFalse "absolute" |
1137 |
|
1138 |
-- | Destination group names or UUIDs (defaults to \"all but current group\". |
1139 |
pTargetGroups :: Field |
1140 |
pTargetGroups = |
1141 |
optionalField $ simpleField "target_groups" [t| [NonEmptyString] |] |
1142 |
|
1143 |
-- | Export mode field. |
1144 |
pExportMode :: Field |
1145 |
pExportMode = |
1146 |
renameField "ExportMode" $ simpleField "mode" [t| ExportMode |] |
1147 |
|
1148 |
-- | Export target_node field, depends on mode. |
1149 |
pExportTargetNode :: Field |
1150 |
pExportTargetNode = |
1151 |
renameField "ExportTarget" $ |
1152 |
simpleField "target_node" [t| ExportTarget |] |
1153 |
|
1154 |
-- | Whether to remove instance after export. |
1155 |
pRemoveInstance :: Field |
1156 |
pRemoveInstance = defaultFalse "remove_instance" |
1157 |
|
1158 |
-- | Whether to ignore failures while removing instances. |
1159 |
pIgnoreRemoveFailures :: Field |
1160 |
pIgnoreRemoveFailures = defaultFalse "ignore_remove_failures" |
1161 |
|
1162 |
-- | Name of X509 key (remote export only). |
1163 |
pX509KeyName :: Field |
1164 |
pX509KeyName = optionalField $ simpleField "x509_key_name" [t| UncheckedList |] |
1165 |
|
1166 |
-- | Destination X509 CA (remote export only). |
1167 |
pX509DestCA :: Field |
1168 |
pX509DestCA = optionalNEStringField "destination_x509_ca" |
1169 |
|
1170 |
-- | Search pattern (regular expression). FIXME: this should be |
1171 |
-- compiled at load time? |
1172 |
pTagSearchPattern :: Field |
1173 |
pTagSearchPattern = |
1174 |
renameField "TagSearchPattern" $ simpleField "pattern" [t| NonEmptyString |] |
1175 |
|
1176 |
-- | Restricted command name. |
1177 |
pRestrictedCommand :: Field |
1178 |
pRestrictedCommand = |
1179 |
renameField "RestrictedCommand" $ |
1180 |
simpleField "command" [t| NonEmptyString |] |
1181 |
|
1182 |
-- | Replace disks mode. |
1183 |
pReplaceDisksMode :: Field |
1184 |
pReplaceDisksMode = |
1185 |
renameField "ReplaceDisksMode" $ simpleField "mode" [t| ReplaceDisksMode |] |
1186 |
|
1187 |
-- | List of disk indices. |
1188 |
pReplaceDisksList :: Field |
1189 |
pReplaceDisksList = |
1190 |
renameField "ReplaceDisksList" $ simpleField "disks" [t| [DiskIndex] |] |
1191 |
|
1192 |
-- | Whether do allow failover in migrations. |
1193 |
pAllowFailover :: Field |
1194 |
pAllowFailover = defaultFalse "allow_failover" |
1195 |
|
1196 |
-- * Test opcode parameters |
1197 |
|
1198 |
-- | Duration parameter for 'OpTestDelay'. |
1199 |
pDelayDuration :: Field |
1200 |
pDelayDuration = |
1201 |
renameField "DelayDuration "$ simpleField "duration" [t| Double |] |
1202 |
|
1203 |
-- | on_master field for 'OpTestDelay'. |
1204 |
pDelayOnMaster :: Field |
1205 |
pDelayOnMaster = renameField "DelayOnMaster" $ defaultTrue "on_master" |
1206 |
|
1207 |
-- | on_nodes field for 'OpTestDelay'. |
1208 |
pDelayOnNodes :: Field |
1209 |
pDelayOnNodes = |
1210 |
renameField "DelayOnNodes" . |
1211 |
defaultField [| [] |] $ |
1212 |
simpleField "on_nodes" [t| [NonEmptyString] |] |
1213 |
|
1214 |
-- | Repeat parameter for OpTestDelay. |
1215 |
pDelayRepeat :: Field |
1216 |
pDelayRepeat = |
1217 |
renameField "DelayRepeat" . |
1218 |
defaultField [| forceNonNeg (0::Int) |] $ |
1219 |
simpleField "repeat" [t| NonNegative Int |] |
1220 |
|
1221 |
-- | IAllocator test direction. |
1222 |
pIAllocatorDirection :: Field |
1223 |
pIAllocatorDirection = |
1224 |
renameField "IAllocatorDirection" $ |
1225 |
simpleField "direction" [t| IAllocatorTestDir |] |
1226 |
|
1227 |
-- | IAllocator test mode. |
1228 |
pIAllocatorMode :: Field |
1229 |
pIAllocatorMode = |
1230 |
renameField "IAllocatorMode" $ |
1231 |
simpleField "mode" [t| IAllocatorMode |] |
1232 |
|
1233 |
-- | IAllocator target name (new instance, node to evac, etc.). |
1234 |
pIAllocatorReqName :: Field |
1235 |
pIAllocatorReqName = |
1236 |
renameField "IAllocatorReqName" $ simpleField "name" [t| NonEmptyString |] |
1237 |
|
1238 |
-- | Custom OpTestIAllocator nics. |
1239 |
pIAllocatorNics :: Field |
1240 |
pIAllocatorNics = |
1241 |
renameField "IAllocatorNics" $ simpleField "nics" [t| [UncheckedDict] |] |
1242 |
|
1243 |
-- | Custom OpTestAllocator disks. |
1244 |
pIAllocatorDisks :: Field |
1245 |
pIAllocatorDisks = |
1246 |
renameField "IAllocatorDisks" $ simpleField "disks" [t| UncheckedList |] |
1247 |
|
1248 |
-- | IAllocator memory field. |
1249 |
pIAllocatorMemory :: Field |
1250 |
pIAllocatorMemory = |
1251 |
renameField "IAllocatorMem" . |
1252 |
optionalField $ |
1253 |
simpleField "memory" [t| NonNegative Int |] |
1254 |
|
1255 |
-- | IAllocator vcpus field. |
1256 |
pIAllocatorVCpus :: Field |
1257 |
pIAllocatorVCpus = |
1258 |
renameField "IAllocatorVCpus" . |
1259 |
optionalField $ |
1260 |
simpleField "vcpus" [t| NonNegative Int |] |
1261 |
|
1262 |
-- | IAllocator os field. |
1263 |
pIAllocatorOs :: Field |
1264 |
pIAllocatorOs = renameField "IAllocatorOs" $ optionalNEStringField "os" |
1265 |
|
1266 |
-- | IAllocator instances field. |
1267 |
pIAllocatorInstances :: Field |
1268 |
pIAllocatorInstances = |
1269 |
renameField "IAllocatorInstances " . |
1270 |
optionalField $ |
1271 |
simpleField "instances" [t| [NonEmptyString] |] |
1272 |
|
1273 |
-- | IAllocator evac mode. |
1274 |
pIAllocatorEvacMode :: Field |
1275 |
pIAllocatorEvacMode = |
1276 |
renameField "IAllocatorEvacMode" . |
1277 |
optionalField $ |
1278 |
simpleField "evac_mode" [t| NodeEvacMode |] |
1279 |
|
1280 |
-- | IAllocator spindle use. |
1281 |
pIAllocatorSpindleUse :: Field |
1282 |
pIAllocatorSpindleUse = |
1283 |
renameField "IAllocatorSpindleUse" . |
1284 |
defaultField [| forceNonNeg (1::Int) |] $ |
1285 |
simpleField "spindle_use" [t| NonNegative Int |] |
1286 |
|
1287 |
-- | IAllocator count field. |
1288 |
pIAllocatorCount :: Field |
1289 |
pIAllocatorCount = |
1290 |
renameField "IAllocatorCount" . |
1291 |
defaultField [| forceNonNeg (1::Int) |] $ |
1292 |
simpleField "count" [t| NonNegative Int |] |
1293 |
|
1294 |
-- | 'OpTestJqueue' notify_waitlock. |
1295 |
pJQueueNotifyWaitLock :: Field |
1296 |
pJQueueNotifyWaitLock = defaultFalse "notify_waitlock" |
1297 |
|
1298 |
-- | 'OpTestJQueue' notify_exec. |
1299 |
pJQueueNotifyExec :: Field |
1300 |
pJQueueNotifyExec = defaultFalse "notify_exec" |
1301 |
|
1302 |
-- | 'OpTestJQueue' log_messages. |
1303 |
pJQueueLogMessages :: Field |
1304 |
pJQueueLogMessages = |
1305 |
defaultField [| [] |] $ simpleField "log_messages" [t| [String] |] |
1306 |
|
1307 |
-- | 'OpTestJQueue' fail attribute. |
1308 |
pJQueueFail :: Field |
1309 |
pJQueueFail = |
1310 |
renameField "JQueueFail" $ defaultFalse "fail" |
1311 |
|
1312 |
-- | 'OpTestDummy' result field. |
1313 |
pTestDummyResult :: Field |
1314 |
pTestDummyResult = |
1315 |
renameField "TestDummyResult" $ simpleField "result" [t| UncheckedValue |] |
1316 |
|
1317 |
-- | 'OpTestDummy' messages field. |
1318 |
pTestDummyMessages :: Field |
1319 |
pTestDummyMessages = |
1320 |
renameField "TestDummyMessages" $ |
1321 |
simpleField "messages" [t| UncheckedValue |] |
1322 |
|
1323 |
-- | 'OpTestDummy' fail field. |
1324 |
pTestDummyFail :: Field |
1325 |
pTestDummyFail = |
1326 |
renameField "TestDummyFail" $ simpleField "fail" [t| UncheckedValue |] |
1327 |
|
1328 |
-- | 'OpTestDummy' submit_jobs field. |
1329 |
pTestDummySubmitJobs :: Field |
1330 |
pTestDummySubmitJobs = |
1331 |
renameField "TestDummySubmitJobs" $ |
1332 |
simpleField "submit_jobs" [t| UncheckedValue |] |
1333 |
|
1334 |
-- * Network parameters |
1335 |
|
1336 |
-- | Network name. |
1337 |
pNetworkName :: Field |
1338 |
pNetworkName = simpleField "network_name" [t| NonEmptyString |] |
1339 |
|
1340 |
-- | Network type field. |
1341 |
pNetworkType :: Field |
1342 |
pNetworkType = optionalField $ simpleField "network_type" [t| NetworkType |] |
1343 |
|
1344 |
-- | Network address (IPv4 subnet). FIXME: no real type for this. |
1345 |
pNetworkAddress4 :: Field |
1346 |
pNetworkAddress4 = |
1347 |
renameField "NetworkAddress4" $ |
1348 |
simpleField "network" [t| NonEmptyString |] |
1349 |
|
1350 |
-- | Network gateway (IPv4 address). FIXME: no real type for this. |
1351 |
pNetworkGateway4 :: Field |
1352 |
pNetworkGateway4 = |
1353 |
renameField "NetworkGateway4" $ |
1354 |
optionalNEStringField "gateway" |
1355 |
|
1356 |
-- | Network address (IPv6 subnet). FIXME: no real type for this. |
1357 |
pNetworkAddress6 :: Field |
1358 |
pNetworkAddress6 = |
1359 |
renameField "NetworkAddress6" $ |
1360 |
optionalNEStringField "network6" |
1361 |
|
1362 |
-- | Network gateway (IPv6 address). FIXME: no real type for this. |
1363 |
pNetworkGateway6 :: Field |
1364 |
pNetworkGateway6 = |
1365 |
renameField "NetworkGateway6" $ |
1366 |
optionalNEStringField "gateway6" |
1367 |
|
1368 |
-- | Network specific mac prefix (that overrides the cluster one). |
1369 |
pNetworkMacPrefix :: Field |
1370 |
pNetworkMacPrefix = |
1371 |
renameField "NetMacPrefix" $ |
1372 |
optionalNEStringField "mac_prefix" |
1373 |
|
1374 |
-- | Network add reserved IPs. |
1375 |
pNetworkAddRsvdIps :: Field |
1376 |
pNetworkAddRsvdIps = |
1377 |
renameField "NetworkAddRsvdIps" . |
1378 |
optionalField $ |
1379 |
simpleField "add_reserved_ips" [t| [NonEmptyString] |] |
1380 |
|
1381 |
-- | Network remove reserved IPs. |
1382 |
pNetworkRemoveRsvdIps :: Field |
1383 |
pNetworkRemoveRsvdIps = |
1384 |
renameField "NetworkRemoveRsvdIps" . |
1385 |
optionalField $ |
1386 |
simpleField "remove_reserved_ips" [t| [NonEmptyString] |] |
1387 |
|
1388 |
-- | Network mode when connecting to a group. |
1389 |
pNetworkMode :: Field |
1390 |
pNetworkMode = simpleField "network_mode" [t| NICMode |] |
1391 |
|
1392 |
-- | Network link when connecting to a group. |
1393 |
pNetworkLink :: Field |
1394 |
pNetworkLink = simpleField "network_link" [t| NonEmptyString |] |
1395 |
|
1396 |
-- * Entire opcode parameter list |
1397 |
|
1398 |
-- | Old-style query opcode, with locking. |
1399 |
dOldQuery :: [Field] |
1400 |
dOldQuery = |
1401 |
[ pOutputFields |
1402 |
, pNames |
1403 |
, pUseLocking |
1404 |
] |
1405 |
|
1406 |
-- | Old-style query opcode, without locking. |
1407 |
dOldQueryNoLocking :: [Field] |
1408 |
dOldQueryNoLocking = |
1409 |
[ pOutputFields |
1410 |
, pNames |
1411 |
] |