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