3b1aab015e8d63fdb2778e138b5ce0a1f2df2850
[ganeti-github.git] / src / Ganeti / OpParams.hs
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, 2014 Google Inc.
16 All rights reserved.
17
18 Redistribution and use in source and binary forms, with or without
19 modification, are permitted provided that the following conditions are
20 met:
21
22 1. Redistributions of source code must retain the above copyright notice,
23 this list of conditions and the following disclaimer.
24
25 2. Redistributions in binary form must reproduce the above copyright
26 notice, this list of conditions and the following disclaimer in the
27 documentation and/or other materials provided with the distribution.
28
29 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
30 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
31 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
33 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
34 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
36 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
37 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
38 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
41 -}
42
43 module Ganeti.OpParams
44 ( ReplaceDisksMode(..)
45 , DiskIndex
46 , mkDiskIndex
47 , unDiskIndex
48 , DiskAccess(..)
49 , INicParams(..)
50 , IDiskParams(..)
51 , RecreateDisksInfo(..)
52 , DdmOldChanges(..)
53 , SetParamsMods(..)
54 , ExportTarget(..)
55 , pInstanceName
56 , pInstallImage
57 , pInstanceCommunication
58 , pOptInstanceCommunication
59 , pInstanceUuid
60 , pInstances
61 , pName
62 , pTagsList
63 , pTagsObject
64 , pTagsName
65 , pOutputFields
66 , pShutdownTimeout
67 , pShutdownTimeout'
68 , pShutdownInstance
69 , pForce
70 , pIgnoreOfflineNodes
71 , pNodeName
72 , pNodeUuid
73 , pNodeNames
74 , pNodeUuids
75 , pGroupName
76 , pMigrationMode
77 , pMigrationLive
78 , pMigrationCleanup
79 , pForceVariant
80 , pWaitForSync
81 , pWaitForSyncFalse
82 , pIgnoreConsistency
83 , pStorageName
84 , pUseLocking
85 , pOpportunisticLocking
86 , pNameCheck
87 , pNodeGroupAllocPolicy
88 , pGroupNodeParams
89 , pQueryWhat
90 , pEarlyRelease
91 , pIpCheck
92 , pIpConflictsCheck
93 , pNoRemember
94 , pMigrationTargetNode
95 , pMigrationTargetNodeUuid
96 , pMoveTargetNode
97 , pMoveTargetNodeUuid
98 , pMoveCompress
99 , pBackupCompress
100 , pStartupPaused
101 , pVerbose
102 , pDebugSimulateErrors
103 , pErrorCodes
104 , pSkipChecks
105 , pIgnoreErrors
106 , pOptGroupName
107 , pGroupDiskParams
108 , pHvState
109 , pDiskState
110 , pIgnoreIpolicy
111 , pHotplug
112 , pHotplugIfPossible
113 , pAllowRuntimeChgs
114 , pInstDisks
115 , pDiskTemplate
116 , pOptDiskTemplate
117 , pFileDriver
118 , pFileStorageDir
119 , pClusterFileStorageDir
120 , pClusterSharedFileStorageDir
121 , pClusterGlusterStorageDir
122 , pInstanceCommunicationNetwork
123 , pZeroingImage
124 , pCompressionTools
125 , pVgName
126 , pEnabledHypervisors
127 , pHypervisor
128 , pClusterHvParams
129 , pInstHvParams
130 , pClusterBeParams
131 , pInstBeParams
132 , pResetDefaults
133 , pOsHvp
134 , pClusterOsParams
135 , pClusterOsParamsPrivate
136 , pInstOsParams
137 , pInstOsParamsPrivate
138 , pInstOsParamsSecret
139 , pCandidatePoolSize
140 , pMaxRunningJobs
141 , pMaxTrackedJobs
142 , pUidPool
143 , pAddUids
144 , pRemoveUids
145 , pMaintainNodeHealth
146 , pModifyEtcHosts
147 , pPreallocWipeDisks
148 , pNicParams
149 , pInstNics
150 , pNdParams
151 , pIpolicy
152 , pDrbdHelper
153 , pDefaultIAllocator
154 , pDefaultIAllocatorParams
155 , pMasterNetdev
156 , pMasterNetmask
157 , pReservedLvs
158 , pHiddenOs
159 , pBlacklistedOs
160 , pUseExternalMipScript
161 , pQueryFields
162 , pQueryFilter
163 , pQueryFieldsFields
164 , pOobCommand
165 , pOobTimeout
166 , pIgnoreStatus
167 , pPowerDelay
168 , pPrimaryIp
169 , pSecondaryIp
170 , pReadd
171 , pNodeGroup
172 , pMasterCapable
173 , pVmCapable
174 , pNames
175 , pNodes
176 , pRequiredNodes
177 , pRequiredNodeUuids
178 , pStorageType
179 , pOptStorageType
180 , pStorageChanges
181 , pMasterCandidate
182 , pOffline
183 , pDrained
184 , pAutoPromote
185 , pPowered
186 , pIallocator
187 , pRemoteNode
188 , pRemoteNodeUuid
189 , pEvacMode
190 , pInstCreateMode
191 , pNoInstall
192 , pInstOs
193 , pPrimaryNode
194 , pPrimaryNodeUuid
195 , pSecondaryNode
196 , pSecondaryNodeUuid
197 , pSourceHandshake
198 , pSourceInstance
199 , pSourceShutdownTimeout
200 , pSourceX509Ca
201 , pSrcNode
202 , pSrcNodeUuid
203 , pSrcPath
204 , pStartInstance
205 , pInstTags
206 , pMultiAllocInstances
207 , pTempOsParams
208 , pTempOsParamsPrivate
209 , pTempOsParamsSecret
210 , pTempHvParams
211 , pTempBeParams
212 , pIgnoreFailures
213 , pNewName
214 , pIgnoreSecondaries
215 , pRebootType
216 , pIgnoreDiskSize
217 , pRecreateDisksInfo
218 , pStatic
219 , pInstParamsNicChanges
220 , pInstParamsDiskChanges
221 , pRuntimeMem
222 , pOsNameChange
223 , pDiskIndex
224 , pDiskChgAmount
225 , pDiskChgAbsolute
226 , pTargetGroups
227 , pExportMode
228 , pExportTargetNode
229 , pExportTargetNodeUuid
230 , pRemoveInstance
231 , pIgnoreRemoveFailures
232 , pX509KeyName
233 , pX509DestCA
234 , pZeroFreeSpace
235 , pHelperStartupTimeout
236 , pHelperShutdownTimeout
237 , pZeroingTimeoutFixed
238 , pZeroingTimeoutPerMiB
239 , pTagSearchPattern
240 , pRestrictedCommand
241 , pReplaceDisksMode
242 , pReplaceDisksList
243 , pAllowFailover
244 , pForceFailover
245 , pDelayDuration
246 , pDelayOnMaster
247 , pDelayOnNodes
248 , pDelayOnNodeUuids
249 , pDelayRepeat
250 , pDelayInterruptible
251 , pDelayNoLocks
252 , pIAllocatorDirection
253 , pIAllocatorMode
254 , pIAllocatorReqName
255 , pIAllocatorNics
256 , pIAllocatorDisks
257 , pIAllocatorMemory
258 , pIAllocatorVCpus
259 , pIAllocatorOs
260 , pIAllocatorInstances
261 , pIAllocatorEvacMode
262 , pIAllocatorSpindleUse
263 , pIAllocatorCount
264 , pJQueueNotifyWaitLock
265 , pJQueueNotifyExec
266 , pJQueueLogMessages
267 , pJQueueFail
268 , pTestDummyResult
269 , pTestDummyMessages
270 , pTestDummyFail
271 , pTestDummySubmitJobs
272 , pNetworkName
273 , pNetworkAddress4
274 , pNetworkGateway4
275 , pNetworkAddress6
276 , pNetworkGateway6
277 , pNetworkMacPrefix
278 , pNetworkAddRsvdIps
279 , pNetworkRemoveRsvdIps
280 , pNetworkMode
281 , pNetworkLink
282 , pNetworkVlan
283 , pDryRun
284 , pDebugLevel
285 , pOpPriority
286 , pDependencies
287 , pComment
288 , pReason
289 , pSequential
290 , pEnabledDiskTemplates
291 , pEnabledUserShutdown
292 , pAdminStateSource
293 ) where
294
295 import Control.Monad (liftM, mplus)
296 import Text.JSON (JSON, JSValue(..), JSObject (..), readJSON, showJSON,
297 fromJSString, toJSObject)
298 import qualified Text.JSON
299 import Text.JSON.Pretty (pp_value)
300
301 import Ganeti.BasicTypes
302 import qualified Ganeti.Constants as C
303 import Ganeti.THH
304 import Ganeti.THH.Field
305 import Ganeti.Utils
306 import Ganeti.JSON
307 import Ganeti.Types
308 import qualified Ganeti.Query.Language as Qlang
309
310 -- * Helper functions and types
311
312 -- | Build a boolean field.
313 booleanField :: String -> Field
314 booleanField = flip simpleField [t| Bool |]
315
316 -- | Default a field to 'False'.
317 defaultFalse :: String -> Field
318 defaultFalse = defaultField [| False |] . booleanField
319
320 -- | Default a field to 'True'.
321 defaultTrue :: String -> Field
322 defaultTrue = defaultField [| True |] . booleanField
323
324 -- | An alias for a 'String' field.
325 stringField :: String -> Field
326 stringField = flip simpleField [t| String |]
327
328 -- | An alias for an optional string field.
329 optionalStringField :: String -> Field
330 optionalStringField = optionalField . stringField
331
332 -- | An alias for an optional non-empty string field.
333 optionalNEStringField :: String -> Field
334 optionalNEStringField = optionalField . flip simpleField [t| NonEmptyString |]
335
336 -- | Function to force a non-negative value, without returning via a
337 -- monad. This is needed for, and should be used /only/ in the case of
338 -- forcing constants. In case the constant is wrong (< 0), this will
339 -- become a runtime error.
340 forceNonNeg :: (Num a, Ord a, Show a) => a -> NonNegative a
341 forceNonNeg i = case mkNonNegative i of
342 Ok n -> n
343 Bad msg -> error msg
344
345 -- ** Disks
346
347 -- | Disk index type (embedding constraints on the index value via a
348 -- smart constructor).
349 newtype DiskIndex = DiskIndex { unDiskIndex :: Int }
350 deriving (Show, Eq, Ord)
351
352 -- | Smart constructor for 'DiskIndex'.
353 mkDiskIndex :: (Monad m) => Int -> m DiskIndex
354 mkDiskIndex i | i >= 0 && i < C.maxDisks = return (DiskIndex i)
355 | otherwise = fail $ "Invalid value for disk index '" ++
356 show i ++ "', required between 0 and " ++
357 show C.maxDisks
358
359 instance JSON DiskIndex where
360 readJSON v = readJSON v >>= mkDiskIndex
361 showJSON = showJSON . unDiskIndex
362
363 -- ** I* param types
364
365 -- | Type holding disk access modes.
366 $(declareSADT "DiskAccess"
367 [ ("DiskReadOnly", 'C.diskRdonly)
368 , ("DiskReadWrite", 'C.diskRdwr)
369 ])
370 $(makeJSONInstance ''DiskAccess)
371
372 -- | NIC modification definition.
373 $(buildObject "INicParams" "inic"
374 [ optionalField $ simpleField C.inicMac [t| NonEmptyString |]
375 , optionalField $ simpleField C.inicIp [t| String |]
376 , optionalField $ simpleField C.inicMode [t| NonEmptyString |]
377 , optionalField $ simpleField C.inicLink [t| NonEmptyString |]
378 , optionalField $ simpleField C.inicName [t| NonEmptyString |]
379 , optionalField $ simpleField C.inicVlan [t| String |]
380 , optionalField $ simpleField C.inicBridge [t| NonEmptyString |]
381 , optionalField $ simpleField C.inicNetwork [t| NonEmptyString |]
382 ])
383
384 -- | Disk modification definition.
385 $(buildObject "IDiskParams" "idisk"
386 [ specialNumericalField 'parseUnitAssumeBinary . optionalField
387 $ simpleField C.idiskSize [t| Int |]
388 , optionalField $ simpleField C.idiskMode [t| DiskAccess |]
389 , optionalField $ simpleField C.idiskAdopt [t| NonEmptyString |]
390 , optionalField $ simpleField C.idiskVg [t| NonEmptyString |]
391 , optionalField $ simpleField C.idiskMetavg [t| NonEmptyString |]
392 , optionalField $ simpleField C.idiskName [t| NonEmptyString |]
393 , optionalField $ simpleField C.idiskProvider [t| NonEmptyString |]
394 , optionalField $ simpleField C.idiskSpindles [t| Int |]
395 , andRestArguments "opaque"
396 ])
397
398 -- | Disk changes type for OpInstanceRecreateDisks. This is a bit
399 -- strange, because the type in Python is something like Either
400 -- [DiskIndex] [DiskChanges], but we can't represent the type of an
401 -- empty list in JSON, so we have to add a custom case for the empty
402 -- list.
403 data RecreateDisksInfo
404 = RecreateDisksAll
405 | RecreateDisksIndices (NonEmpty DiskIndex)
406 | RecreateDisksParams (NonEmpty (DiskIndex, IDiskParams))
407 deriving (Eq, Show)
408
409 readRecreateDisks :: JSValue -> Text.JSON.Result RecreateDisksInfo
410 readRecreateDisks (JSArray []) = return RecreateDisksAll
411 readRecreateDisks v =
412 case readJSON v::Text.JSON.Result [DiskIndex] of
413 Text.JSON.Ok indices -> liftM RecreateDisksIndices (mkNonEmpty indices)
414 _ -> case readJSON v::Text.JSON.Result [(DiskIndex, IDiskParams)] of
415 Text.JSON.Ok params -> liftM RecreateDisksParams (mkNonEmpty params)
416 _ -> fail $ "Can't parse disk information as either list of disk"
417 ++ " indices or list of disk parameters; value received:"
418 ++ show (pp_value v)
419
420 instance JSON RecreateDisksInfo where
421 readJSON = readRecreateDisks
422 showJSON RecreateDisksAll = showJSON ()
423 showJSON (RecreateDisksIndices idx) = showJSON idx
424 showJSON (RecreateDisksParams params) = showJSON params
425
426 -- | Simple type for old-style ddm changes.
427 data DdmOldChanges = DdmOldIndex (NonNegative Int)
428 | DdmOldMod DdmSimple
429 deriving (Eq, Show)
430
431 readDdmOldChanges :: JSValue -> Text.JSON.Result DdmOldChanges
432 readDdmOldChanges v =
433 case readJSON v::Text.JSON.Result (NonNegative Int) of
434 Text.JSON.Ok nn -> return $ DdmOldIndex nn
435 _ -> case readJSON v::Text.JSON.Result DdmSimple of
436 Text.JSON.Ok ddms -> return $ DdmOldMod ddms
437 _ -> fail $ "Can't parse value '" ++ show (pp_value v) ++ "' as"
438 ++ " either index or modification"
439
440 instance JSON DdmOldChanges where
441 showJSON (DdmOldIndex i) = showJSON i
442 showJSON (DdmOldMod m) = showJSON m
443 readJSON = readDdmOldChanges
444
445 -- | Instance disk or nic modifications.
446 data SetParamsMods a
447 = SetParamsEmpty
448 | SetParamsDeprecated (NonEmpty (DdmOldChanges, a))
449 | SetParamsNew (NonEmpty (DdmFull, Int, a))
450 | SetParamsNewName (NonEmpty (DdmFull, String, a))
451 deriving (Eq, Show)
452
453 -- | Custom deserialiser for 'SetParamsMods'.
454 readSetParams :: (JSON a) => JSValue -> Text.JSON.Result (SetParamsMods a)
455 readSetParams (JSArray []) = return SetParamsEmpty
456 readSetParams v =
457 liftM SetParamsDeprecated (readJSON v)
458 `mplus` liftM SetParamsNew (readJSON v)
459 `mplus` liftM SetParamsNewName (readJSON v)
460
461 instance (JSON a) => JSON (SetParamsMods a) where
462 showJSON SetParamsEmpty = showJSON ()
463 showJSON (SetParamsDeprecated v) = showJSON v
464 showJSON (SetParamsNew v) = showJSON v
465 showJSON (SetParamsNewName v) = showJSON v
466 readJSON = readSetParams
467
468 -- | Custom type for target_node parameter of OpBackupExport, which
469 -- varies depending on mode. FIXME: this uses an [JSValue] since
470 -- we don't care about individual rows (just like the Python code
471 -- tests). But the proper type could be parsed if we wanted.
472 data ExportTarget = ExportTargetLocal NonEmptyString
473 | ExportTargetRemote [JSValue]
474 deriving (Eq, Show)
475
476 -- | Custom reader for 'ExportTarget'.
477 readExportTarget :: JSValue -> Text.JSON.Result ExportTarget
478 readExportTarget (JSString s) = liftM ExportTargetLocal $
479 mkNonEmpty (fromJSString s)
480 readExportTarget (JSArray arr) = return $ ExportTargetRemote arr
481 readExportTarget v = fail $ "Invalid value received for 'target_node': " ++
482 show (pp_value v)
483
484 instance JSON ExportTarget where
485 showJSON (ExportTargetLocal s) = showJSON s
486 showJSON (ExportTargetRemote l) = showJSON l
487 readJSON = readExportTarget
488
489 -- * Common opcode parameters
490
491 pDryRun :: Field
492 pDryRun =
493 withDoc "Run checks only, don't execute" .
494 optionalField $ booleanField "dry_run"
495
496 pDebugLevel :: Field
497 pDebugLevel =
498 withDoc "Debug level" .
499 optionalField $ simpleField "debug_level" [t| NonNegative Int |]
500
501 pOpPriority :: Field
502 pOpPriority =
503 withDoc "Opcode priority. Note: python uses a separate constant,\
504 \ we're using the actual value we know it's the default" .
505 defaultField [| OpPrioNormal |] $
506 simpleField "priority" [t| OpSubmitPriority |]
507
508 pDependencies :: Field
509 pDependencies =
510 withDoc "Job dependencies" .
511 optionalNullSerField $ simpleField "depends" [t| [JobDependency] |]
512
513 pComment :: Field
514 pComment =
515 withDoc "Comment field" .
516 optionalNullSerField $ stringField "comment"
517
518 pReason :: Field
519 pReason =
520 withDoc "Reason trail field" $
521 simpleField C.opcodeReason [t| ReasonTrail |]
522
523 pSequential :: Field
524 pSequential =
525 withDoc "Sequential job execution" $
526 defaultFalse C.opcodeSequential
527
528 -- * Parameters
529
530 pDebugSimulateErrors :: Field
531 pDebugSimulateErrors =
532 withDoc "Whether to simulate errors (useful for debugging)" $
533 defaultFalse "debug_simulate_errors"
534
535 pErrorCodes :: Field
536 pErrorCodes =
537 withDoc "Error codes" $
538 defaultFalse "error_codes"
539
540 pSkipChecks :: Field
541 pSkipChecks =
542 withDoc "Which checks to skip" .
543 defaultField [| emptyListSet |] $
544 simpleField "skip_checks" [t| ListSet VerifyOptionalChecks |]
545
546 pIgnoreErrors :: Field
547 pIgnoreErrors =
548 withDoc "List of error codes that should be treated as warnings" .
549 defaultField [| emptyListSet |] $
550 simpleField "ignore_errors" [t| ListSet CVErrorCode |]
551
552 pVerbose :: Field
553 pVerbose =
554 withDoc "Verbose mode" $
555 defaultFalse "verbose"
556
557 pOptGroupName :: Field
558 pOptGroupName =
559 withDoc "Optional group name" .
560 renameField "OptGroupName" .
561 optionalField $ simpleField "group_name" [t| NonEmptyString |]
562
563 pGroupName :: Field
564 pGroupName =
565 withDoc "Group name" $
566 simpleField "group_name" [t| NonEmptyString |]
567
568 -- | Whether to hotplug device.
569 pHotplug :: Field
570 pHotplug = defaultFalse "hotplug"
571
572 pHotplugIfPossible :: Field
573 pHotplugIfPossible = defaultFalse "hotplug_if_possible"
574
575 pInstances :: Field
576 pInstances =
577 withDoc "List of instances" .
578 defaultField [| [] |] $
579 simpleField "instances" [t| [NonEmptyString] |]
580
581 pOutputFields :: Field
582 pOutputFields =
583 withDoc "Selected output fields" $
584 simpleField "output_fields" [t| [NonEmptyString] |]
585
586 pName :: Field
587 pName =
588 withDoc "A generic name" $
589 simpleField "name" [t| NonEmptyString |]
590
591 pForce :: Field
592 pForce =
593 withDoc "Whether to force the operation" $
594 defaultFalse "force"
595
596 pHvState :: Field
597 pHvState =
598 withDoc "Set hypervisor states" .
599 optionalField $ simpleField "hv_state" [t| JSObject JSValue |]
600
601 pDiskState :: Field
602 pDiskState =
603 withDoc "Set disk states" .
604 optionalField $ simpleField "disk_state" [t| JSObject JSValue |]
605
606 -- | Cluster-wide default directory for storing file-backed disks.
607 pClusterFileStorageDir :: Field
608 pClusterFileStorageDir =
609 renameField "ClusterFileStorageDir" $
610 optionalStringField "file_storage_dir"
611
612 -- | Cluster-wide default directory for storing shared-file-backed disks.
613 pClusterSharedFileStorageDir :: Field
614 pClusterSharedFileStorageDir =
615 renameField "ClusterSharedFileStorageDir" $
616 optionalStringField "shared_file_storage_dir"
617
618 -- | Cluster-wide default directory for storing Gluster-backed disks.
619 pClusterGlusterStorageDir :: Field
620 pClusterGlusterStorageDir =
621 renameField "ClusterGlusterStorageDir" $
622 optionalStringField "gluster_storage_dir"
623
624 pInstallImage :: Field
625 pInstallImage =
626 withDoc "OS image for running OS scripts in a safe environment" $
627 optionalStringField "install_image"
628
629 pInstanceCommunicationNetwork :: Field
630 pInstanceCommunicationNetwork =
631 optionalStringField "instance_communication_network"
632
633 -- | The OS to use when zeroing instance disks.
634 pZeroingImage :: Field
635 pZeroingImage =
636 optionalStringField "zeroing_image"
637
638 -- | The additional tools that can be used to compress data in transit
639 pCompressionTools :: Field
640 pCompressionTools =
641 withDoc "List of enabled compression tools" . optionalField $
642 simpleField "compression_tools" [t| [NonEmptyString] |]
643
644 -- | Volume group name.
645 pVgName :: Field
646 pVgName =
647 withDoc "Volume group name" $
648 optionalStringField "vg_name"
649
650 pEnabledHypervisors :: Field
651 pEnabledHypervisors =
652 withDoc "List of enabled hypervisors" .
653 optionalField $
654 simpleField "enabled_hypervisors" [t| [Hypervisor] |]
655
656 pClusterHvParams :: Field
657 pClusterHvParams =
658 withDoc "Cluster-wide hypervisor parameters, hypervisor-dependent" .
659 renameField "ClusterHvParams" .
660 optionalField $
661 simpleField "hvparams" [t| GenericContainer String (JSObject JSValue) |]
662
663 pClusterBeParams :: Field
664 pClusterBeParams =
665 withDoc "Cluster-wide backend parameter defaults" .
666 renameField "ClusterBeParams" .
667 optionalField $ simpleField "beparams" [t| JSObject JSValue |]
668
669 pOsHvp :: Field
670 pOsHvp =
671 withDoc "Cluster-wide per-OS hypervisor parameter defaults" .
672 optionalField $
673 simpleField "os_hvp" [t| GenericContainer String (JSObject JSValue) |]
674
675 pClusterOsParams :: Field
676 pClusterOsParams =
677 withDoc "Cluster-wide OS parameter defaults" .
678 renameField "ClusterOsParams" .
679 optionalField $
680 simpleField "osparams" [t| GenericContainer String (JSObject JSValue) |]
681
682 pClusterOsParamsPrivate :: Field
683 pClusterOsParamsPrivate =
684 withDoc "Cluster-wide private OS parameter defaults" .
685 renameField "ClusterOsParamsPrivate" .
686 optionalField $
687 -- This field needs an unique name to aid Python deserialization
688 simpleField "osparams_private_cluster"
689 [t| GenericContainer String (JSObject (Private JSValue)) |]
690
691 pGroupDiskParams :: Field
692 pGroupDiskParams =
693 withDoc "Disk templates' parameter defaults" .
694 optionalField $
695 simpleField "diskparams"
696 [t| GenericContainer DiskTemplate (JSObject JSValue) |]
697
698 pCandidatePoolSize :: Field
699 pCandidatePoolSize =
700 withDoc "Master candidate pool size" .
701 optionalField $ simpleField "candidate_pool_size" [t| Positive Int |]
702
703 pMaxRunningJobs :: Field
704 pMaxRunningJobs =
705 withDoc "Maximal number of jobs to run simultaneously" .
706 optionalField $ simpleField "max_running_jobs" [t| Positive Int |]
707
708 pMaxTrackedJobs :: Field
709 pMaxTrackedJobs =
710 withDoc "Maximal number of jobs tracked in the job queue" .
711 optionalField $ simpleField "max_tracked_jobs" [t| Positive Int |]
712
713
714 pUidPool :: Field
715 pUidPool =
716 withDoc "Set UID pool, must be list of lists describing UID ranges\
717 \ (two items, start and end inclusive)" .
718 optionalField $ simpleField "uid_pool" [t| [(Int, Int)] |]
719
720 pAddUids :: Field
721 pAddUids =
722 withDoc "Extend UID pool, must be list of lists describing UID\
723 \ ranges (two items, start and end inclusive)" .
724 optionalField $ simpleField "add_uids" [t| [(Int, Int)] |]
725
726 pRemoveUids :: Field
727 pRemoveUids =
728 withDoc "Shrink UID pool, must be list of lists describing UID\
729 \ ranges (two items, start and end inclusive) to be removed" .
730 optionalField $ simpleField "remove_uids" [t| [(Int, Int)] |]
731
732 pMaintainNodeHealth :: Field
733 pMaintainNodeHealth =
734 withDoc "Whether to automatically maintain node health" .
735 optionalField $ booleanField "maintain_node_health"
736
737 -- | Whether to modify and keep in sync the @/etc/hosts@ files of nodes.
738 pModifyEtcHosts :: Field
739 pModifyEtcHosts = optionalField $ booleanField "modify_etc_hosts"
740
741 -- | Whether to wipe disks before allocating them to instances.
742 pPreallocWipeDisks :: Field
743 pPreallocWipeDisks =
744 withDoc "Whether to wipe disks before allocating them to instances" .
745 optionalField $ booleanField "prealloc_wipe_disks"
746
747 pNicParams :: Field
748 pNicParams =
749 withDoc "Cluster-wide NIC parameter defaults" .
750 optionalField $ simpleField "nicparams" [t| INicParams |]
751
752 pIpolicy :: Field
753 pIpolicy =
754 withDoc "Ipolicy specs" .
755 optionalField $ simpleField "ipolicy" [t| JSObject JSValue |]
756
757 pDrbdHelper :: Field
758 pDrbdHelper =
759 withDoc "DRBD helper program" $
760 optionalStringField "drbd_helper"
761
762 pDefaultIAllocator :: Field
763 pDefaultIAllocator =
764 withDoc "Default iallocator for cluster" $
765 optionalStringField "default_iallocator"
766
767 pDefaultIAllocatorParams :: Field
768 pDefaultIAllocatorParams =
769 withDoc "Default iallocator parameters for cluster" . optionalField
770 $ simpleField "default_iallocator_params" [t| JSObject JSValue |]
771
772 pMasterNetdev :: Field
773 pMasterNetdev =
774 withDoc "Master network device" $
775 optionalStringField "master_netdev"
776
777 pMasterNetmask :: Field
778 pMasterNetmask =
779 withDoc "Netmask of the master IP" .
780 optionalField $ simpleField "master_netmask" [t| NonNegative Int |]
781
782 pReservedLvs :: Field
783 pReservedLvs =
784 withDoc "List of reserved LVs" .
785 optionalField $ simpleField "reserved_lvs" [t| [NonEmptyString] |]
786
787 pHiddenOs :: Field
788 pHiddenOs =
789 withDoc "Modify list of hidden operating systems: each modification\
790 \ must have two items, the operation and the OS name; the operation\
791 \ can be add or remove" .
792 optionalField $ simpleField "hidden_os" [t| [(DdmSimple, NonEmptyString)] |]
793
794 pBlacklistedOs :: Field
795 pBlacklistedOs =
796 withDoc "Modify list of blacklisted operating systems: each\
797 \ modification must have two items, the operation and the OS name;\
798 \ the operation can be add or remove" .
799 optionalField $
800 simpleField "blacklisted_os" [t| [(DdmSimple, NonEmptyString)] |]
801
802 pUseExternalMipScript :: Field
803 pUseExternalMipScript =
804 withDoc "Whether to use an external master IP address setup script" .
805 optionalField $ booleanField "use_external_mip_script"
806
807 pEnabledDiskTemplates :: Field
808 pEnabledDiskTemplates =
809 withDoc "List of enabled disk templates" .
810 optionalField $
811 simpleField "enabled_disk_templates" [t| [DiskTemplate] |]
812
813 pEnabledUserShutdown :: Field
814 pEnabledUserShutdown =
815 withDoc "Whether user shutdown is enabled cluster wide" .
816 optionalField $
817 simpleField "enabled_user_shutdown" [t| Bool |]
818
819 pQueryWhat :: Field
820 pQueryWhat =
821 withDoc "Resource(s) to query for" $
822 simpleField "what" [t| Qlang.QueryTypeOp |]
823
824 pUseLocking :: Field
825 pUseLocking =
826 withDoc "Whether to use synchronization" $
827 defaultFalse "use_locking"
828
829 pQueryFields :: Field
830 pQueryFields =
831 withDoc "Requested fields" $
832 simpleField "fields" [t| [NonEmptyString] |]
833
834 pQueryFilter :: Field
835 pQueryFilter =
836 withDoc "Query filter" .
837 optionalField $ simpleField "qfilter" [t| [JSValue] |]
838
839 pQueryFieldsFields :: Field
840 pQueryFieldsFields =
841 withDoc "Requested fields; if not given, all are returned" .
842 renameField "QueryFieldsFields" $
843 optionalField pQueryFields
844
845 pNodeNames :: Field
846 pNodeNames =
847 withDoc "List of node names to run the OOB command against" .
848 defaultField [| [] |] $ simpleField "node_names" [t| [NonEmptyString] |]
849
850 pNodeUuids :: Field
851 pNodeUuids =
852 withDoc "List of node UUIDs" .
853 optionalField $ simpleField "node_uuids" [t| [NonEmptyString] |]
854
855 pOobCommand :: Field
856 pOobCommand =
857 withDoc "OOB command to run" $
858 simpleField "command" [t| OobCommand |]
859
860 pOobTimeout :: Field
861 pOobTimeout =
862 withDoc "Timeout before the OOB helper will be terminated" .
863 defaultField [| C.oobTimeout |] $
864 simpleField "timeout" [t| Int |]
865
866 pIgnoreStatus :: Field
867 pIgnoreStatus =
868 withDoc "Ignores the node offline status for power off" $
869 defaultFalse "ignore_status"
870
871 pPowerDelay :: Field
872 pPowerDelay =
873 -- FIXME: we can't use the proper type "NonNegative Double", since
874 -- the default constant is a plain Double, not a non-negative one.
875 -- And trying to fix the constant introduces a cyclic import.
876 withDoc "Time in seconds to wait between powering on nodes" .
877 defaultField [| C.oobPowerDelay |] $
878 simpleField "power_delay" [t| Double |]
879
880 pRequiredNodes :: Field
881 pRequiredNodes =
882 withDoc "Required list of node names" .
883 renameField "ReqNodes " $ simpleField "nodes" [t| [NonEmptyString] |]
884
885 pRequiredNodeUuids :: Field
886 pRequiredNodeUuids =
887 withDoc "Required list of node UUIDs" .
888 renameField "ReqNodeUuids " . optionalField $
889 simpleField "node_uuids" [t| [NonEmptyString] |]
890
891 pRestrictedCommand :: Field
892 pRestrictedCommand =
893 withDoc "Restricted command name" .
894 renameField "RestrictedCommand" $
895 simpleField "command" [t| NonEmptyString |]
896
897 pNodeName :: Field
898 pNodeName =
899 withDoc "A required node name (for single-node LUs)" $
900 simpleField "node_name" [t| NonEmptyString |]
901
902 pNodeUuid :: Field
903 pNodeUuid =
904 withDoc "A node UUID (for single-node LUs)" .
905 optionalField $ simpleField "node_uuid" [t| NonEmptyString |]
906
907 pPrimaryIp :: Field
908 pPrimaryIp =
909 withDoc "Primary IP address" .
910 optionalField $
911 simpleField "primary_ip" [t| NonEmptyString |]
912
913 pSecondaryIp :: Field
914 pSecondaryIp =
915 withDoc "Secondary IP address" $
916 optionalNEStringField "secondary_ip"
917
918 pReadd :: Field
919 pReadd =
920 withDoc "Whether node is re-added to cluster" $
921 defaultFalse "readd"
922
923 pNodeGroup :: Field
924 pNodeGroup =
925 withDoc "Initial node group" $
926 optionalNEStringField "group"
927
928 pMasterCapable :: Field
929 pMasterCapable =
930 withDoc "Whether node can become master or master candidate" .
931 optionalField $ booleanField "master_capable"
932
933 pVmCapable :: Field
934 pVmCapable =
935 withDoc "Whether node can host instances" .
936 optionalField $ booleanField "vm_capable"
937
938 pNdParams :: Field
939 pNdParams =
940 withDoc "Node parameters" .
941 renameField "genericNdParams" .
942 optionalField $ simpleField "ndparams" [t| JSObject JSValue |]
943
944 pNames :: Field
945 pNames =
946 withDoc "List of names" .
947 defaultField [| [] |] $ simpleField "names" [t| [NonEmptyString] |]
948
949 pNodes :: Field
950 pNodes =
951 withDoc "List of nodes" .
952 defaultField [| [] |] $ simpleField "nodes" [t| [NonEmptyString] |]
953
954 pStorageType :: Field
955 pStorageType =
956 withDoc "Storage type" $ simpleField "storage_type" [t| StorageType |]
957
958 pOptStorageType :: Field
959 pOptStorageType =
960 withDoc "Storage type" .
961 renameField "OptStorageType" .
962 optionalField $ simpleField "storage_type" [t| StorageType |]
963
964 pStorageName :: Field
965 pStorageName =
966 withDoc "Storage name" .
967 renameField "StorageName" .
968 optionalField $ simpleField "name" [t| NonEmptyString |]
969
970 pStorageChanges :: Field
971 pStorageChanges =
972 withDoc "Requested storage changes" $
973 simpleField "changes" [t| JSObject JSValue |]
974
975 pIgnoreConsistency :: Field
976 pIgnoreConsistency =
977 withDoc "Whether to ignore disk consistency" $
978 defaultFalse "ignore_consistency"
979
980 pMasterCandidate :: Field
981 pMasterCandidate =
982 withDoc "Whether the node should become a master candidate" .
983 optionalField $ booleanField "master_candidate"
984
985 pOffline :: Field
986 pOffline =
987 withDoc "Whether to mark the node or instance offline" .
988 optionalField $ booleanField "offline"
989
990 pDrained ::Field
991 pDrained =
992 withDoc "Whether to mark the node as drained" .
993 optionalField $ booleanField "drained"
994
995 pAutoPromote :: Field
996 pAutoPromote =
997 withDoc "Whether node(s) should be promoted to master candidate if\
998 \ necessary" $
999 defaultFalse "auto_promote"
1000
1001 pPowered :: Field
1002 pPowered =
1003 withDoc "Whether the node should be marked as powered" .
1004 optionalField $ booleanField "powered"
1005
1006 pMigrationMode :: Field
1007 pMigrationMode =
1008 withDoc "Migration type (live/non-live)" .
1009 renameField "MigrationMode" .
1010 optionalField $
1011 simpleField "mode" [t| MigrationMode |]
1012
1013 pMigrationLive :: Field
1014 pMigrationLive =
1015 withDoc "Obsolete \'live\' migration mode (do not use)" .
1016 renameField "OldLiveMode" . optionalField $ booleanField "live"
1017
1018 pMigrationTargetNode :: Field
1019 pMigrationTargetNode =
1020 withDoc "Target node for instance migration/failover" $
1021 optionalNEStringField "target_node"
1022
1023 pMigrationTargetNodeUuid :: Field
1024 pMigrationTargetNodeUuid =
1025 withDoc "Target node UUID for instance migration/failover" $
1026 optionalNEStringField "target_node_uuid"
1027
1028 pAllowRuntimeChgs :: Field
1029 pAllowRuntimeChgs =
1030 withDoc "Whether to allow runtime changes while migrating" $
1031 defaultTrue "allow_runtime_changes"
1032
1033 pIgnoreIpolicy :: Field
1034 pIgnoreIpolicy =
1035 withDoc "Whether to ignore ipolicy violations" $
1036 defaultFalse "ignore_ipolicy"
1037
1038 pIallocator :: Field
1039 pIallocator =
1040 withDoc "Iallocator for deciding the target node for shared-storage\
1041 \ instances" $
1042 optionalNEStringField "iallocator"
1043
1044 pEarlyRelease :: Field
1045 pEarlyRelease =
1046 withDoc "Whether to release locks as soon as possible" $
1047 defaultFalse "early_release"
1048
1049 pRemoteNode :: Field
1050 pRemoteNode =
1051 withDoc "New secondary node" $
1052 optionalNEStringField "remote_node"
1053
1054 pRemoteNodeUuid :: Field
1055 pRemoteNodeUuid =
1056 withDoc "New secondary node UUID" $
1057 optionalNEStringField "remote_node_uuid"
1058
1059 pEvacMode :: Field
1060 pEvacMode =
1061 withDoc "Node evacuation mode" .
1062 renameField "EvacMode" $ simpleField "mode" [t| EvacMode |]
1063
1064 pInstanceName :: Field
1065 pInstanceName =
1066 withDoc "A required instance name (for single-instance LUs)" $
1067 simpleField "instance_name" [t| String |]
1068
1069 pInstanceCommunication :: Field
1070 pInstanceCommunication =
1071 withDoc C.instanceCommunicationDoc $
1072 defaultFalse "instance_communication"
1073
1074 pOptInstanceCommunication :: Field
1075 pOptInstanceCommunication =
1076 withDoc C.instanceCommunicationDoc .
1077 renameField "OptInstanceCommunication" .
1078 optionalField $
1079 booleanField "instance_communication"
1080
1081 pForceVariant :: Field
1082 pForceVariant =
1083 withDoc "Whether to force an unknown OS variant" $
1084 defaultFalse "force_variant"
1085
1086 pWaitForSync :: Field
1087 pWaitForSync =
1088 withDoc "Whether to wait for the disk to synchronize" $
1089 defaultTrue "wait_for_sync"
1090
1091 pNameCheck :: Field
1092 pNameCheck =
1093 withDoc "Whether to check name" $
1094 defaultTrue "name_check"
1095
1096 pInstBeParams :: Field
1097 pInstBeParams =
1098 withDoc "Backend parameters for instance" .
1099 renameField "InstBeParams" .
1100 defaultField [| toJSObject [] |] $
1101 simpleField "beparams" [t| JSObject JSValue |]
1102
1103 pInstDisks :: Field
1104 pInstDisks =
1105 withDoc "List of instance disks" .
1106 renameField "instDisks" $ simpleField "disks" [t| [IDiskParams] |]
1107
1108 pDiskTemplate :: Field
1109 pDiskTemplate =
1110 withDoc "Disk template" $
1111 simpleField "disk_template" [t| DiskTemplate |]
1112
1113 pFileDriver :: Field
1114 pFileDriver =
1115 withDoc "Driver for file-backed disks" .
1116 optionalField $ simpleField "file_driver" [t| FileDriver |]
1117
1118 pFileStorageDir :: Field
1119 pFileStorageDir =
1120 withDoc "Directory for storing file-backed disks" $
1121 optionalNEStringField "file_storage_dir"
1122
1123 pInstHvParams :: Field
1124 pInstHvParams =
1125 withDoc "Hypervisor parameters for instance, hypervisor-dependent" .
1126 renameField "InstHvParams" .
1127 defaultField [| toJSObject [] |] $
1128 simpleField "hvparams" [t| JSObject JSValue |]
1129
1130 pHypervisor :: Field
1131 pHypervisor =
1132 withDoc "Selected hypervisor for an instance" .
1133 optionalField $
1134 simpleField "hypervisor" [t| Hypervisor |]
1135
1136 pResetDefaults :: Field
1137 pResetDefaults =
1138 withDoc "Reset instance parameters to default if equal" $
1139 defaultFalse "identify_defaults"
1140
1141 pIpCheck :: Field
1142 pIpCheck =
1143 withDoc "Whether to ensure instance's IP address is inactive" $
1144 defaultTrue "ip_check"
1145
1146 pIpConflictsCheck :: Field
1147 pIpConflictsCheck =
1148 withDoc "Whether to check for conflicting IP addresses" $
1149 defaultTrue "conflicts_check"
1150
1151 pInstCreateMode :: Field
1152 pInstCreateMode =
1153 withDoc "Instance creation mode" .
1154 renameField "InstCreateMode" $ simpleField "mode" [t| InstCreateMode |]
1155
1156 pInstNics :: Field
1157 pInstNics =
1158 withDoc "List of NIC (network interface) definitions" $
1159 simpleField "nics" [t| [INicParams] |]
1160
1161 pNoInstall :: Field
1162 pNoInstall =
1163 withDoc "Do not install the OS (will disable automatic start)" .
1164 optionalField $ booleanField "no_install"
1165
1166 pInstOs :: Field
1167 pInstOs =
1168 withDoc "OS type for instance installation" $
1169 optionalNEStringField "os_type"
1170
1171 pInstOsParams :: Field
1172 pInstOsParams =
1173 withDoc "OS parameters for instance" .
1174 renameField "InstOsParams" .
1175 defaultField [| toJSObject [] |] $
1176 simpleField "osparams" [t| JSObject JSValue |]
1177
1178 pInstOsParamsPrivate :: Field
1179 pInstOsParamsPrivate =
1180 withDoc "Private OS parameters for instance" .
1181 optionalField $
1182 simpleField "osparams_private" [t| JSObject (Private JSValue) |]
1183
1184 pInstOsParamsSecret :: Field
1185 pInstOsParamsSecret =
1186 withDoc "Secret OS parameters for instance" .
1187 optionalField $
1188 simpleField "osparams_secret" [t| JSObject (Private JSValue) |]
1189
1190 pPrimaryNode :: Field
1191 pPrimaryNode =
1192 withDoc "Primary node for an instance" $
1193 optionalNEStringField "pnode"
1194
1195 pPrimaryNodeUuid :: Field
1196 pPrimaryNodeUuid =
1197 withDoc "Primary node UUID for an instance" $
1198 optionalNEStringField "pnode_uuid"
1199
1200 pSecondaryNode :: Field
1201 pSecondaryNode =
1202 withDoc "Secondary node for an instance" $
1203 optionalNEStringField "snode"
1204
1205 pSecondaryNodeUuid :: Field
1206 pSecondaryNodeUuid =
1207 withDoc "Secondary node UUID for an instance" $
1208 optionalNEStringField "snode_uuid"
1209
1210 pSourceHandshake :: Field
1211 pSourceHandshake =
1212 withDoc "Signed handshake from source (remote import only)" .
1213 optionalField $ simpleField "source_handshake" [t| [JSValue] |]
1214
1215 pSourceInstance :: Field
1216 pSourceInstance =
1217 withDoc "Source instance name (remote import only)" $
1218 optionalNEStringField "source_instance_name"
1219
1220 -- FIXME: non-negative int, whereas the constant is a plain int.
1221 pSourceShutdownTimeout :: Field
1222 pSourceShutdownTimeout =
1223 withDoc "How long source instance was given to shut down (remote import\
1224 \ only)" .
1225 defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
1226 simpleField "source_shutdown_timeout" [t| NonNegative Int |]
1227
1228 pSourceX509Ca :: Field
1229 pSourceX509Ca =
1230 withDoc "Source X509 CA in PEM format (remote import only)" $
1231 optionalNEStringField "source_x509_ca"
1232
1233 pSrcNode :: Field
1234 pSrcNode =
1235 withDoc "Source node for import" $
1236 optionalNEStringField "src_node"
1237
1238 pSrcNodeUuid :: Field
1239 pSrcNodeUuid =
1240 withDoc "Source node UUID for import" $
1241 optionalNEStringField "src_node_uuid"
1242
1243 pSrcPath :: Field
1244 pSrcPath =
1245 withDoc "Source directory for import" $
1246 optionalNEStringField "src_path"
1247
1248 pStartInstance :: Field
1249 pStartInstance =
1250 withDoc "Whether to start instance after creation" $
1251 defaultTrue "start"
1252
1253 -- FIXME: unify/simplify with pTags, once that migrates to NonEmpty String"
1254 pInstTags :: Field
1255 pInstTags =
1256 withDoc "Instance tags" .
1257 renameField "InstTags" .
1258 defaultField [| [] |] $
1259 simpleField "tags" [t| [NonEmptyString] |]
1260
1261 pMultiAllocInstances :: Field
1262 pMultiAllocInstances =
1263 withDoc "List of instance create opcodes describing the instances to\
1264 \ allocate" .
1265 renameField "InstMultiAlloc" .
1266 defaultField [| [] |] $
1267 simpleField "instances"[t| [JSValue] |]
1268
1269 pOpportunisticLocking :: Field
1270 pOpportunisticLocking =
1271 withDoc "Whether to employ opportunistic locking for nodes, meaning\
1272 \ nodes already locked by another opcode won't be considered for\
1273 \ instance allocation (only when an iallocator is used)" $
1274 defaultFalse "opportunistic_locking"
1275
1276 pInstanceUuid :: Field
1277 pInstanceUuid =
1278 withDoc "An instance UUID (for single-instance LUs)" .
1279 optionalField $ simpleField "instance_uuid" [t| NonEmptyString |]
1280
1281 pTempOsParams :: Field
1282 pTempOsParams =
1283 withDoc "Temporary OS parameters (currently only in reinstall, might be\
1284 \ added to install as well)" .
1285 renameField "TempOsParams" .
1286 optionalField $ simpleField "osparams" [t| JSObject JSValue |]
1287
1288 pTempOsParamsPrivate :: Field
1289 pTempOsParamsPrivate =
1290 withDoc "Private OS parameters for instance reinstalls" .
1291 optionalField $
1292 simpleField "osparams_private" [t| JSObject (Private JSValue) |]
1293
1294 pTempOsParamsSecret :: Field
1295 pTempOsParamsSecret =
1296 withDoc "Secret OS parameters for instance reinstalls" .
1297 optionalField $
1298 simpleField "osparams_secret" [t| JSObject (Private JSValue) |]
1299
1300 pShutdownTimeout :: Field
1301 pShutdownTimeout =
1302 withDoc "How long to wait for instance to shut down" .
1303 defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
1304 simpleField "shutdown_timeout" [t| NonNegative Int |]
1305
1306 -- | Another name for the shutdown timeout, because we like to be
1307 -- inconsistent.
1308 pShutdownTimeout' :: Field
1309 pShutdownTimeout' =
1310 withDoc "How long to wait for instance to shut down" .
1311 renameField "InstShutdownTimeout" .
1312 defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
1313 simpleField "timeout" [t| NonNegative Int |]
1314
1315 pIgnoreFailures :: Field
1316 pIgnoreFailures =
1317 withDoc "Whether to ignore failures during removal" $
1318 defaultFalse "ignore_failures"
1319
1320 pNewName :: Field
1321 pNewName =
1322 withDoc "New group or instance name" $
1323 simpleField "new_name" [t| NonEmptyString |]
1324
1325 pIgnoreOfflineNodes :: Field
1326 pIgnoreOfflineNodes =
1327 withDoc "Whether to ignore offline nodes" $
1328 defaultFalse "ignore_offline_nodes"
1329
1330 pTempHvParams :: Field
1331 pTempHvParams =
1332 withDoc "Temporary hypervisor parameters, hypervisor-dependent" .
1333 renameField "TempHvParams" .
1334 defaultField [| toJSObject [] |] $
1335 simpleField "hvparams" [t| JSObject JSValue |]
1336
1337 pTempBeParams :: Field
1338 pTempBeParams =
1339 withDoc "Temporary backend parameters" .
1340 renameField "TempBeParams" .
1341 defaultField [| toJSObject [] |] $
1342 simpleField "beparams" [t| JSObject JSValue |]
1343
1344 pNoRemember :: Field
1345 pNoRemember =
1346 withDoc "Do not remember instance state changes" $
1347 defaultFalse "no_remember"
1348
1349 pStartupPaused :: Field
1350 pStartupPaused =
1351 withDoc "Pause instance at startup" $
1352 defaultFalse "startup_paused"
1353
1354 pIgnoreSecondaries :: Field
1355 pIgnoreSecondaries =
1356 withDoc "Whether to start the instance even if secondary disks are failing" $
1357 defaultFalse "ignore_secondaries"
1358
1359 pRebootType :: Field
1360 pRebootType =
1361 withDoc "How to reboot the instance" $
1362 simpleField "reboot_type" [t| RebootType |]
1363
1364 pReplaceDisksMode :: Field
1365 pReplaceDisksMode =
1366 withDoc "Replacement mode" .
1367 renameField "ReplaceDisksMode" $ simpleField "mode" [t| ReplaceDisksMode |]
1368
1369 pReplaceDisksList :: Field
1370 pReplaceDisksList =
1371 withDoc "List of disk indices" .
1372 renameField "ReplaceDisksList" .
1373 defaultField [| [] |] $
1374 simpleField "disks" [t| [DiskIndex] |]
1375
1376 pMigrationCleanup :: Field
1377 pMigrationCleanup =
1378 withDoc "Whether a previously failed migration should be cleaned up" .
1379 renameField "MigrationCleanup" $ defaultFalse "cleanup"
1380
1381 pAllowFailover :: Field
1382 pAllowFailover =
1383 withDoc "Whether we can fallback to failover if migration is not possible" $
1384 defaultFalse "allow_failover"
1385
1386 pForceFailover :: Field
1387 pForceFailover =
1388 withDoc "Disallow migration moves and always use failovers" $
1389 defaultFalse "force_failover"
1390
1391 pMoveTargetNode :: Field
1392 pMoveTargetNode =
1393 withDoc "Target node for instance move" .
1394 renameField "MoveTargetNode" $
1395 simpleField "target_node" [t| NonEmptyString |]
1396
1397 pMoveTargetNodeUuid :: Field
1398 pMoveTargetNodeUuid =
1399 withDoc "Target node UUID for instance move" .
1400 renameField "MoveTargetNodeUuid" . optionalField $
1401 simpleField "target_node_uuid" [t| NonEmptyString |]
1402
1403 pMoveCompress :: Field
1404 pMoveCompress =
1405 withDoc "Compression mode to use during instance moves" .
1406 defaultField [| C.iecNone |] $
1407 simpleField "compress" [t| String |]
1408
1409 pBackupCompress :: Field
1410 pBackupCompress =
1411 withDoc "Compression mode to use for moves during backups/imports" .
1412 defaultField [| C.iecNone |] $
1413 simpleField "compress" [t| String |]
1414
1415 pIgnoreDiskSize :: Field
1416 pIgnoreDiskSize =
1417 withDoc "Whether to ignore recorded disk size" $
1418 defaultFalse "ignore_size"
1419
1420 pWaitForSyncFalse :: Field
1421 pWaitForSyncFalse =
1422 withDoc "Whether to wait for the disk to synchronize (defaults to false)" $
1423 defaultField [| False |] pWaitForSync
1424
1425 pRecreateDisksInfo :: Field
1426 pRecreateDisksInfo =
1427 withDoc "Disk list for recreate disks" .
1428 renameField "RecreateDisksInfo" .
1429 defaultField [| RecreateDisksAll |] $
1430 simpleField "disks" [t| RecreateDisksInfo |]
1431
1432 pStatic :: Field
1433 pStatic =
1434 withDoc "Whether to only return configuration data without querying nodes" $
1435 defaultFalse "static"
1436
1437 pInstParamsNicChanges :: Field
1438 pInstParamsNicChanges =
1439 withDoc "List of NIC changes" .
1440 renameField "InstNicChanges" .
1441 defaultField [| SetParamsEmpty |] $
1442 simpleField "nics" [t| SetParamsMods INicParams |]
1443
1444 pInstParamsDiskChanges :: Field
1445 pInstParamsDiskChanges =
1446 withDoc "List of disk changes" .
1447 renameField "InstDiskChanges" .
1448 defaultField [| SetParamsEmpty |] $
1449 simpleField "disks" [t| SetParamsMods IDiskParams |]
1450
1451 pRuntimeMem :: Field
1452 pRuntimeMem =
1453 withDoc "New runtime memory" .
1454 optionalField $ simpleField "runtime_mem" [t| Positive Int |]
1455
1456 pOptDiskTemplate :: Field
1457 pOptDiskTemplate =
1458 withDoc "Instance disk template" .
1459 optionalField .
1460 renameField "OptDiskTemplate" $
1461 simpleField "disk_template" [t| DiskTemplate |]
1462
1463 pOsNameChange :: Field
1464 pOsNameChange =
1465 withDoc "Change the instance's OS without reinstalling the instance" $
1466 optionalNEStringField "os_name"
1467
1468 pDiskIndex :: Field
1469 pDiskIndex =
1470 withDoc "Disk index for e.g. grow disk" .
1471 renameField "DiskIndex " $ simpleField "disk" [t| DiskIndex |]
1472
1473 pDiskChgAmount :: Field
1474 pDiskChgAmount =
1475 withDoc "Disk amount to add or grow to" .
1476 renameField "DiskChgAmount" $ simpleField "amount" [t| NonNegative Int |]
1477
1478 pDiskChgAbsolute :: Field
1479 pDiskChgAbsolute =
1480 withDoc
1481 "Whether the amount parameter is an absolute target or a relative one" .
1482 renameField "DiskChkAbsolute" $ defaultFalse "absolute"
1483
1484 pTargetGroups :: Field
1485 pTargetGroups =
1486 withDoc
1487 "Destination group names or UUIDs (defaults to \"all but current group\")" .
1488 optionalField $ simpleField "target_groups" [t| [NonEmptyString] |]
1489
1490 pNodeGroupAllocPolicy :: Field
1491 pNodeGroupAllocPolicy =
1492 withDoc "Instance allocation policy" .
1493 optionalField $
1494 simpleField "alloc_policy" [t| AllocPolicy |]
1495
1496 pGroupNodeParams :: Field
1497 pGroupNodeParams =
1498 withDoc "Default node parameters for group" .
1499 optionalField $ simpleField "ndparams" [t| JSObject JSValue |]
1500
1501 pExportMode :: Field
1502 pExportMode =
1503 withDoc "Export mode" .
1504 renameField "ExportMode" $ simpleField "mode" [t| ExportMode |]
1505
1506 -- FIXME: Rename target_node as it changes meaning for different
1507 -- export modes (e.g. "destination")
1508 pExportTargetNode :: Field
1509 pExportTargetNode =
1510 withDoc "Target node (depends on export mode)" .
1511 renameField "ExportTarget" $
1512 simpleField "target_node" [t| ExportTarget |]
1513
1514 pExportTargetNodeUuid :: Field
1515 pExportTargetNodeUuid =
1516 withDoc "Target node UUID (if local export)" .
1517 renameField "ExportTargetNodeUuid" . optionalField $
1518 simpleField "target_node_uuid" [t| NonEmptyString |]
1519
1520 pShutdownInstance :: Field
1521 pShutdownInstance =
1522 withDoc "Whether to shutdown the instance before export" $
1523 defaultTrue "shutdown"
1524
1525 pRemoveInstance :: Field
1526 pRemoveInstance =
1527 withDoc "Whether to remove instance after export" $
1528 defaultFalse "remove_instance"
1529
1530 pIgnoreRemoveFailures :: Field
1531 pIgnoreRemoveFailures =
1532 withDoc "Whether to ignore failures while removing instances" $
1533 defaultFalse "ignore_remove_failures"
1534
1535 pX509KeyName :: Field
1536 pX509KeyName =
1537 withDoc "Name of X509 key (remote export only)" .
1538 optionalField $ simpleField "x509_key_name" [t| [JSValue] |]
1539
1540 pX509DestCA :: Field
1541 pX509DestCA =
1542 withDoc "Destination X509 CA (remote export only)" $
1543 optionalNEStringField "destination_x509_ca"
1544
1545 pZeroFreeSpace :: Field
1546 pZeroFreeSpace =
1547 withDoc "Whether to zero the free space on the disks of the instance" $
1548 defaultFalse "zero_free_space"
1549
1550 pHelperStartupTimeout :: Field
1551 pHelperStartupTimeout =
1552 withDoc "Startup timeout for the helper VM" .
1553 optionalField $ simpleField "helper_startup_timeout" [t| Int |]
1554
1555 pHelperShutdownTimeout :: Field
1556 pHelperShutdownTimeout =
1557 withDoc "Shutdown timeout for the helper VM" .
1558 optionalField $ simpleField "helper_shutdown_timeout" [t| Int |]
1559
1560 pZeroingTimeoutFixed :: Field
1561 pZeroingTimeoutFixed =
1562 withDoc "The fixed part of time to wait before declaring the zeroing\
1563 \ operation to have failed" .
1564 optionalField $ simpleField "zeroing_timeout_fixed" [t| Int |]
1565
1566 pZeroingTimeoutPerMiB :: Field
1567 pZeroingTimeoutPerMiB =
1568 withDoc "The variable part of time to wait before declaring the zeroing\
1569 \ operation to have failed, dependent on total size of disks" .
1570 optionalField $ simpleField "zeroing_timeout_per_mib" [t| Double |]
1571
1572 pTagsObject :: Field
1573 pTagsObject =
1574 withDoc "Tag kind" $
1575 simpleField "kind" [t| TagKind |]
1576
1577 pTagsName :: Field
1578 pTagsName =
1579 withDoc "Name of object" .
1580 renameField "TagsGetName" .
1581 optionalField $ simpleField "name" [t| String |]
1582
1583 pTagsList :: Field
1584 pTagsList =
1585 withDoc "List of tag names" $
1586 simpleField "tags" [t| [String] |]
1587
1588 -- FIXME: this should be compiled at load time?
1589 pTagSearchPattern :: Field
1590 pTagSearchPattern =
1591 withDoc "Search pattern (regular expression)" .
1592 renameField "TagSearchPattern" $
1593 simpleField "pattern" [t| NonEmptyString |]
1594
1595 pDelayDuration :: Field
1596 pDelayDuration =
1597 withDoc "Duration parameter for 'OpTestDelay'" .
1598 renameField "DelayDuration" $
1599 simpleField "duration" [t| Double |]
1600
1601 pDelayOnMaster :: Field
1602 pDelayOnMaster =
1603 withDoc "on_master field for 'OpTestDelay'" .
1604 renameField "DelayOnMaster" $
1605 defaultTrue "on_master"
1606
1607 pDelayOnNodes :: Field
1608 pDelayOnNodes =
1609 withDoc "on_nodes field for 'OpTestDelay'" .
1610 renameField "DelayOnNodes" .
1611 defaultField [| [] |] $
1612 simpleField "on_nodes" [t| [NonEmptyString] |]
1613
1614 pDelayOnNodeUuids :: Field
1615 pDelayOnNodeUuids =
1616 withDoc "on_node_uuids field for 'OpTestDelay'" .
1617 renameField "DelayOnNodeUuids" . optionalField $
1618 simpleField "on_node_uuids" [t| [NonEmptyString] |]
1619
1620 pDelayRepeat :: Field
1621 pDelayRepeat =
1622 withDoc "Repeat parameter for OpTestDelay" .
1623 renameField "DelayRepeat" .
1624 defaultField [| forceNonNeg (0::Int) |] $
1625 simpleField "repeat" [t| NonNegative Int |]
1626
1627 pDelayInterruptible :: Field
1628 pDelayInterruptible =
1629 withDoc "Allows socket-based interruption of a running OpTestDelay" .
1630 renameField "DelayInterruptible" .
1631 defaultField [| False |] $
1632 simpleField "interruptible" [t| Bool |]
1633
1634 pDelayNoLocks :: Field
1635 pDelayNoLocks =
1636 withDoc "Don't take locks during the delay" .
1637 renameField "DelayNoLocks" $
1638 defaultTrue "no_locks"
1639
1640 pIAllocatorDirection :: Field
1641 pIAllocatorDirection =
1642 withDoc "IAllocator test direction" .
1643 renameField "IAllocatorDirection" $
1644 simpleField "direction" [t| IAllocatorTestDir |]
1645
1646 pIAllocatorMode :: Field
1647 pIAllocatorMode =
1648 withDoc "IAllocator test mode" .
1649 renameField "IAllocatorMode" $
1650 simpleField "mode" [t| IAllocatorMode |]
1651
1652 pIAllocatorReqName :: Field
1653 pIAllocatorReqName =
1654 withDoc "IAllocator target name (new instance, node to evac, etc.)" .
1655 renameField "IAllocatorReqName" $ simpleField "name" [t| NonEmptyString |]
1656
1657 pIAllocatorNics :: Field
1658 pIAllocatorNics =
1659 withDoc "Custom OpTestIAllocator nics" .
1660 renameField "IAllocatorNics" .
1661 optionalField $ simpleField "nics" [t| [INicParams] |]
1662
1663 pIAllocatorDisks :: Field
1664 pIAllocatorDisks =
1665 withDoc "Custom OpTestAllocator disks" .
1666 renameField "IAllocatorDisks" .
1667 optionalField $ simpleField "disks" [t| [JSValue] |]
1668
1669 pIAllocatorMemory :: Field
1670 pIAllocatorMemory =
1671 withDoc "IAllocator memory field" .
1672 renameField "IAllocatorMem" .
1673 optionalField $
1674 simpleField "memory" [t| NonNegative Int |]
1675
1676 pIAllocatorVCpus :: Field
1677 pIAllocatorVCpus =
1678 withDoc "IAllocator vcpus field" .
1679 renameField "IAllocatorVCpus" .
1680 optionalField $
1681 simpleField "vcpus" [t| NonNegative Int |]
1682
1683 pIAllocatorOs :: Field
1684 pIAllocatorOs =
1685 withDoc "IAllocator os field" .
1686 renameField "IAllocatorOs" $ optionalNEStringField "os"
1687
1688 pIAllocatorInstances :: Field
1689 pIAllocatorInstances =
1690 withDoc "IAllocator instances field" .
1691 renameField "IAllocatorInstances " .
1692 optionalField $
1693 simpleField "instances" [t| [NonEmptyString] |]
1694
1695 pIAllocatorEvacMode :: Field
1696 pIAllocatorEvacMode =
1697 withDoc "IAllocator evac mode" .
1698 renameField "IAllocatorEvacMode" .
1699 optionalField $
1700 simpleField "evac_mode" [t| EvacMode |]
1701
1702 pIAllocatorSpindleUse :: Field
1703 pIAllocatorSpindleUse =
1704 withDoc "IAllocator spindle use" .
1705 renameField "IAllocatorSpindleUse" .
1706 defaultField [| forceNonNeg (1::Int) |] $
1707 simpleField "spindle_use" [t| NonNegative Int |]
1708
1709 pIAllocatorCount :: Field
1710 pIAllocatorCount =
1711 withDoc "IAllocator count field" .
1712 renameField "IAllocatorCount" .
1713 defaultField [| forceNonNeg (1::Int) |] $
1714 simpleField "count" [t| NonNegative Int |]
1715
1716 pJQueueNotifyWaitLock :: Field
1717 pJQueueNotifyWaitLock =
1718 withDoc "'OpTestJqueue' notify_waitlock" $
1719 defaultFalse "notify_waitlock"
1720
1721 pJQueueNotifyExec :: Field
1722 pJQueueNotifyExec =
1723 withDoc "'OpTestJQueue' notify_exec" $
1724 defaultFalse "notify_exec"
1725
1726 pJQueueLogMessages :: Field
1727 pJQueueLogMessages =
1728 withDoc "'OpTestJQueue' log_messages" .
1729 defaultField [| [] |] $ simpleField "log_messages" [t| [String] |]
1730
1731 pJQueueFail :: Field
1732 pJQueueFail =
1733 withDoc "'OpTestJQueue' fail attribute" .
1734 renameField "JQueueFail" $ defaultFalse "fail"
1735
1736 pTestDummyResult :: Field
1737 pTestDummyResult =
1738 withDoc "'OpTestDummy' result field" .
1739 renameField "TestDummyResult" $ simpleField "result" [t| JSValue |]
1740
1741 pTestDummyMessages :: Field
1742 pTestDummyMessages =
1743 withDoc "'OpTestDummy' messages field" .
1744 renameField "TestDummyMessages" $
1745 simpleField "messages" [t| JSValue |]
1746
1747 pTestDummyFail :: Field
1748 pTestDummyFail =
1749 withDoc "'OpTestDummy' fail field" .
1750 renameField "TestDummyFail" $ simpleField "fail" [t| JSValue |]
1751
1752 pTestDummySubmitJobs :: Field
1753 pTestDummySubmitJobs =
1754 withDoc "'OpTestDummy' submit_jobs field" .
1755 renameField "TestDummySubmitJobs" $
1756 simpleField "submit_jobs" [t| JSValue |]
1757
1758 pNetworkName :: Field
1759 pNetworkName =
1760 withDoc "Network name" $
1761 simpleField "network_name" [t| NonEmptyString |]
1762
1763 pNetworkAddress4 :: Field
1764 pNetworkAddress4 =
1765 withDoc "Network address (IPv4 subnet)" .
1766 renameField "NetworkAddress4" $
1767 simpleField "network" [t| IPv4Network |]
1768
1769 pNetworkGateway4 :: Field
1770 pNetworkGateway4 =
1771 withDoc "Network gateway (IPv4 address)" .
1772 renameField "NetworkGateway4" .
1773 optionalField $ simpleField "gateway" [t| IPv4Address |]
1774
1775 pNetworkAddress6 :: Field
1776 pNetworkAddress6 =
1777 withDoc "Network address (IPv6 subnet)" .
1778 renameField "NetworkAddress6" .
1779 optionalField $ simpleField "network6" [t| IPv6Network |]
1780
1781 pNetworkGateway6 :: Field
1782 pNetworkGateway6 =
1783 withDoc "Network gateway (IPv6 address)" .
1784 renameField "NetworkGateway6" .
1785 optionalField $ simpleField "gateway6" [t| IPv6Address |]
1786
1787 pNetworkMacPrefix :: Field
1788 pNetworkMacPrefix =
1789 withDoc "Network specific mac prefix (that overrides the cluster one)" .
1790 renameField "NetMacPrefix" $
1791 optionalNEStringField "mac_prefix"
1792
1793 pNetworkAddRsvdIps :: Field
1794 pNetworkAddRsvdIps =
1795 withDoc "Which IP addresses to reserve" .
1796 renameField "NetworkAddRsvdIps" .
1797 optionalField $
1798 simpleField "add_reserved_ips" [t| [IPv4Address] |]
1799
1800 pNetworkRemoveRsvdIps :: Field
1801 pNetworkRemoveRsvdIps =
1802 withDoc "Which external IP addresses to release" .
1803 renameField "NetworkRemoveRsvdIps" .
1804 optionalField $
1805 simpleField "remove_reserved_ips" [t| [IPv4Address] |]
1806
1807 pNetworkMode :: Field
1808 pNetworkMode =
1809 withDoc "Network mode when connecting to a group" $
1810 simpleField "network_mode" [t| NICMode |]
1811
1812 pNetworkLink :: Field
1813 pNetworkLink =
1814 withDoc "Network link when connecting to a group" $
1815 simpleField "network_link" [t| NonEmptyString |]
1816
1817 pAdminStateSource :: Field
1818 pAdminStateSource =
1819 withDoc "Who last changed the instance admin state" .
1820 optionalField $
1821 simpleField "admin_state_source" [t| AdminStateSource |]
1822
1823 pNetworkVlan :: Field
1824 pNetworkVlan =
1825 withDoc "Network vlan when connecting to a group" .
1826 defaultField [| "" |] $ stringField "network_vlan"