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