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