1 {-# LANGUAGE TemplateHaskell #-}
3 {-| Implementation of opcodes parameters.
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
15 Copyright (C) 2012 Google Inc.
17 This program is free software; you can redistribute it and/or modify
18 it under the terms of the GNU General Public License as published by
19 the Free Software Foundation; either version 2 of the License, or
20 (at your option) any later version.
22 This program is distributed in the hope that it will be useful, but
23 WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 General Public License for more details.
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, write to the Free Software
29 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
34 module Ganeti.OpParams
35 ( ReplaceDisksMode(..)
42 , RecreateDisksInfo(..)
73 , pOpportunisticLocking
75 , pNodeGroupAllocPolicy
82 , pMigrationTargetNode
83 , pMigrationTargetNodeUuid
88 , pDebugSimulateErrors
103 , pClusterFileStorageDir
104 , pClusterSharedFileStorageDir
106 , pEnabledHypervisors
120 , pMaintainNodeHealth
134 , pUseExternalMipScript
172 , pSourceShutdownTimeout
179 , pMultiAllocInstances
190 , pInstParamsNicChanges
191 , pInstParamsDiskChanges
200 , pExportTargetNodeUuid
202 , pIgnoreRemoveFailures
215 , pIAllocatorDirection
223 , pIAllocatorInstances
224 , pIAllocatorEvacMode
225 , pIAllocatorSpindleUse
227 , pJQueueNotifyWaitLock
234 , pTestDummySubmitJobs
242 , pNetworkRemoveRsvdIps
251 , pEnabledDiskTemplates
254 import Control.Monad (liftM)
255 import Text.JSON (JSON, JSValue(..), JSObject (..), readJSON, showJSON,
256 fromJSString, toJSObject)
257 import qualified Text.JSON
258 import Text.JSON.Pretty (pp_value)
260 import Ganeti.BasicTypes
261 import qualified Ganeti.Constants as C
265 import qualified Ganeti.Query.Language as Qlang
267 -- * Helper functions and types
269 -- | Build a boolean field.
270 booleanField :: String -> Field
271 booleanField = flip simpleField [t| Bool |]
273 -- | Default a field to 'False'.
274 defaultFalse :: String -> Field
275 defaultFalse = defaultField [| False |] . booleanField
277 -- | Default a field to 'True'.
278 defaultTrue :: String -> Field
279 defaultTrue = defaultField [| True |] . booleanField
281 -- | An alias for a 'String' field.
282 stringField :: String -> Field
283 stringField = flip simpleField [t| String |]
285 -- | An alias for an optional string field.
286 optionalStringField :: String -> Field
287 optionalStringField = optionalField . stringField
289 -- | An alias for an optional non-empty string field.
290 optionalNEStringField :: String -> Field
291 optionalNEStringField = optionalField . flip simpleField [t| NonEmptyString |]
293 -- | Function to force a non-negative value, without returning via a
294 -- monad. This is needed for, and should be used /only/ in the case of
295 -- forcing constants. In case the constant is wrong (< 0), this will
296 -- become a runtime error.
297 forceNonNeg :: (Num a, Ord a, Show a) => a -> NonNegative a
298 forceNonNeg i = case mkNonNegative i of
304 -- | Disk index type (embedding constraints on the index value via a
305 -- smart constructor).
306 newtype DiskIndex = DiskIndex { unDiskIndex :: Int }
307 deriving (Show, Eq, Ord)
309 -- | Smart constructor for 'DiskIndex'.
310 mkDiskIndex :: (Monad m) => Int -> m DiskIndex
311 mkDiskIndex i | i >= 0 && i < C.maxDisks = return (DiskIndex i)
312 | otherwise = fail $ "Invalid value for disk index '" ++
313 show i ++ "', required between 0 and " ++
316 instance JSON DiskIndex where
317 readJSON v = readJSON v >>= mkDiskIndex
318 showJSON = showJSON . unDiskIndex
322 -- | Type holding disk access modes.
323 $(declareSADT "DiskAccess"
324 [ ("DiskReadOnly", 'C.diskRdonly)
325 , ("DiskReadWrite", 'C.diskRdwr)
327 $(makeJSONInstance ''DiskAccess)
329 -- | NIC modification definition.
330 $(buildObject "INicParams" "inic"
331 [ optionalField $ simpleField C.inicMac [t| NonEmptyString |]
332 , optionalField $ simpleField C.inicIp [t| String |]
333 , optionalField $ simpleField C.inicMode [t| NonEmptyString |]
334 , optionalField $ simpleField C.inicLink [t| NonEmptyString |]
335 , optionalField $ simpleField C.inicName [t| NonEmptyString |]
336 , optionalField $ simpleField C.inicVlan [t| NonEmptyString |]
337 , optionalField $ simpleField C.inicBridge [t| NonEmptyString |]
340 -- | Disk modification definition. FIXME: disksize should be VTYPE_UNIT.
341 $(buildObject "IDiskParams" "idisk"
342 [ optionalField $ simpleField C.idiskSize [t| Int |]
343 , optionalField $ simpleField C.idiskMode [t| DiskAccess |]
344 , optionalField $ simpleField C.idiskAdopt [t| NonEmptyString |]
345 , optionalField $ simpleField C.idiskVg [t| NonEmptyString |]
346 , optionalField $ simpleField C.idiskMetavg [t| NonEmptyString |]
347 , optionalField $ simpleField C.idiskName [t| NonEmptyString |]
350 -- | Disk changes type for OpInstanceRecreateDisks. This is a bit
351 -- strange, because the type in Python is something like Either
352 -- [DiskIndex] [DiskChanges], but we can't represent the type of an
353 -- empty list in JSON, so we have to add a custom case for the empty
355 data RecreateDisksInfo
357 | RecreateDisksIndices (NonEmpty DiskIndex)
358 | RecreateDisksParams (NonEmpty (DiskIndex, IDiskParams))
361 readRecreateDisks :: JSValue -> Text.JSON.Result RecreateDisksInfo
362 readRecreateDisks (JSArray []) = return RecreateDisksAll
363 readRecreateDisks v =
364 case readJSON v::Text.JSON.Result [DiskIndex] of
365 Text.JSON.Ok indices -> liftM RecreateDisksIndices (mkNonEmpty indices)
366 _ -> case readJSON v::Text.JSON.Result [(DiskIndex, IDiskParams)] of
367 Text.JSON.Ok params -> liftM RecreateDisksParams (mkNonEmpty params)
368 _ -> fail $ "Can't parse disk information as either list of disk"
369 ++ " indices or list of disk parameters; value received:"
372 instance JSON RecreateDisksInfo where
373 readJSON = readRecreateDisks
374 showJSON RecreateDisksAll = showJSON ()
375 showJSON (RecreateDisksIndices idx) = showJSON idx
376 showJSON (RecreateDisksParams params) = showJSON params
378 -- | Simple type for old-style ddm changes.
379 data DdmOldChanges = DdmOldIndex (NonNegative Int)
380 | DdmOldMod DdmSimple
383 readDdmOldChanges :: JSValue -> Text.JSON.Result DdmOldChanges
384 readDdmOldChanges v =
385 case readJSON v::Text.JSON.Result (NonNegative Int) of
386 Text.JSON.Ok nn -> return $ DdmOldIndex nn
387 _ -> case readJSON v::Text.JSON.Result DdmSimple of
388 Text.JSON.Ok ddms -> return $ DdmOldMod ddms
389 _ -> fail $ "Can't parse value '" ++ show (pp_value v) ++ "' as"
390 ++ " either index or modification"
392 instance JSON DdmOldChanges where
393 showJSON (DdmOldIndex i) = showJSON i
394 showJSON (DdmOldMod m) = showJSON m
395 readJSON = readDdmOldChanges
397 -- | Instance disk or nic modifications.
400 | SetParamsDeprecated (NonEmpty (DdmOldChanges, a))
401 | SetParamsNew (NonEmpty (DdmFull, Int, a))
404 -- | Custom deserialiser for 'SetParamsMods'.
405 readSetParams :: (JSON a) => JSValue -> Text.JSON.Result (SetParamsMods a)
406 readSetParams (JSArray []) = return SetParamsEmpty
408 case readJSON v::Text.JSON.Result [(DdmOldChanges, JSValue)] of
409 Text.JSON.Ok _ -> liftM SetParamsDeprecated $ readJSON v
410 _ -> liftM SetParamsNew $ readJSON v
412 instance (JSON a) => JSON (SetParamsMods a) where
413 showJSON SetParamsEmpty = showJSON ()
414 showJSON (SetParamsDeprecated v) = showJSON v
415 showJSON (SetParamsNew v) = showJSON v
416 readJSON = readSetParams
418 -- | Custom type for target_node parameter of OpBackupExport, which
419 -- varies depending on mode. FIXME: this uses an [JSValue] since
420 -- we don't care about individual rows (just like the Python code
421 -- tests). But the proper type could be parsed if we wanted.
422 data ExportTarget = ExportTargetLocal NonEmptyString
423 | ExportTargetRemote [JSValue]
426 -- | Custom reader for 'ExportTarget'.
427 readExportTarget :: JSValue -> Text.JSON.Result ExportTarget
428 readExportTarget (JSString s) = liftM ExportTargetLocal $
429 mkNonEmpty (fromJSString s)
430 readExportTarget (JSArray arr) = return $ ExportTargetRemote arr
431 readExportTarget v = fail $ "Invalid value received for 'target_node': " ++
434 instance JSON ExportTarget where
435 showJSON (ExportTargetLocal s) = showJSON s
436 showJSON (ExportTargetRemote l) = showJSON l
437 readJSON = readExportTarget
439 -- * Common opcode parameters
443 withDoc "Run checks only, don't execute" .
444 optionalField $ booleanField "dry_run"
448 withDoc "Debug level" .
449 optionalField $ simpleField "debug_level" [t| NonNegative Int |]
453 withDoc "Opcode priority. Note: python uses a separate constant,\
454 \ we're using the actual value we know it's the default" .
455 defaultField [| OpPrioNormal |] $
456 simpleField "priority" [t| OpSubmitPriority |]
458 pDependencies :: Field
460 withDoc "Job dependencies" .
461 optionalNullSerField $ simpleField "depends" [t| [JobDependency] |]
465 withDoc "Comment field" .
466 optionalNullSerField $ stringField "comment"
470 withDoc "Reason trail field" $
471 simpleField C.opcodeReason [t| ReasonTrail |]
475 pDebugSimulateErrors :: Field
476 pDebugSimulateErrors =
477 withDoc "Whether to simulate errors (useful for debugging)" $
478 defaultFalse "debug_simulate_errors"
482 withDoc "Error codes" $
483 defaultFalse "error_codes"
487 withDoc "Which checks to skip" .
488 defaultField [| emptyListSet |] $
489 simpleField "skip_checks" [t| ListSet VerifyOptionalChecks |]
491 pIgnoreErrors :: Field
493 withDoc "List of error codes that should be treated as warnings" .
494 defaultField [| emptyListSet |] $
495 simpleField "ignore_errors" [t| ListSet CVErrorCode |]
499 withDoc "Verbose mode" $
500 defaultFalse "verbose"
502 pOptGroupName :: Field
504 withDoc "Optional group name" .
505 renameField "OptGroupName" .
506 optionalField $ simpleField "group_name" [t| NonEmptyString |]
510 withDoc "Group name" $
511 simpleField "group_name" [t| NonEmptyString |]
515 withDoc "List of instances" .
516 defaultField [| [] |] $
517 simpleField "instances" [t| [NonEmptyString] |]
519 pOutputFields :: Field
521 withDoc "Selected output fields" $
522 simpleField "output_fields" [t| [NonEmptyString] |]
526 withDoc "A generic name" $
527 simpleField "name" [t| NonEmptyString |]
531 withDoc "Whether to force the operation" $
536 withDoc "Set hypervisor states" .
537 optionalField $ simpleField "hv_state" [t| JSObject JSValue |]
541 withDoc "Set disk states" .
542 optionalField $ simpleField "disk_state" [t| JSObject JSValue |]
544 -- | Cluster-wide default directory for storing file-backed disks.
545 pClusterFileStorageDir :: Field
546 pClusterFileStorageDir =
547 renameField "ClusterFileStorageDir" $
548 optionalStringField "file_storage_dir"
550 -- | Cluster-wide default directory for storing shared-file-backed disks.
551 pClusterSharedFileStorageDir :: Field
552 pClusterSharedFileStorageDir =
553 renameField "ClusterSharedFileStorageDir" $
554 optionalStringField "shared_file_storage_dir"
556 -- | Volume group name.
559 withDoc "Volume group name" $
560 optionalStringField "vg_name"
562 pEnabledHypervisors :: Field
563 pEnabledHypervisors =
564 withDoc "List of enabled hypervisors" .
566 simpleField "enabled_hypervisors" [t| [Hypervisor] |]
568 pClusterHvParams :: Field
570 withDoc "Cluster-wide hypervisor parameters, hypervisor-dependent" .
571 renameField "ClusterHvParams" .
573 simpleField "hvparams" [t| GenericContainer String (JSObject JSValue) |]
575 pClusterBeParams :: Field
577 withDoc "Cluster-wide backend parameter defaults" .
578 renameField "ClusterBeParams" .
579 optionalField $ simpleField "beparams" [t| JSObject JSValue |]
583 withDoc "Cluster-wide per-OS hypervisor parameter defaults" .
585 simpleField "os_hvp" [t| GenericContainer String (JSObject JSValue) |]
587 pClusterOsParams :: Field
589 withDoc "Cluster-wide OS parameter defaults" .
590 renameField "ClusterOsParams" .
592 simpleField "osparams" [t| GenericContainer String (JSObject JSValue) |]
596 withDoc "Disk templates' parameter defaults" .
598 simpleField "diskparams"
599 [t| GenericContainer DiskTemplate (JSObject JSValue) |]
601 pCandidatePoolSize :: Field
603 withDoc "Master candidate pool size" .
604 optionalField $ simpleField "candidate_pool_size" [t| Positive Int |]
608 withDoc "Set UID pool, must be list of lists describing UID ranges\
609 \ (two items, start and end inclusive)" .
610 optionalField $ simpleField "uid_pool" [t| [(Int, Int)] |]
614 withDoc "Extend UID pool, must be list of lists describing UID\
615 \ ranges (two items, start and end inclusive)" .
616 optionalField $ simpleField "add_uids" [t| [(Int, Int)] |]
620 withDoc "Shrink UID pool, must be list of lists describing UID\
621 \ ranges (two items, start and end inclusive) to be removed" .
622 optionalField $ simpleField "remove_uids" [t| [(Int, Int)] |]
624 pMaintainNodeHealth :: Field
625 pMaintainNodeHealth =
626 withDoc "Whether to automatically maintain node health" .
627 optionalField $ booleanField "maintain_node_health"
629 -- | Whether to modify and keep in sync the @/etc/hosts@ files of nodes.
630 pModifyEtcHosts :: Field
631 pModifyEtcHosts = optionalField $ booleanField "modify_etc_hosts"
633 -- | Whether to wipe disks before allocating them to instances.
634 pPreallocWipeDisks :: Field
636 withDoc "Whether to wipe disks before allocating them to instances" .
637 optionalField $ booleanField "prealloc_wipe_disks"
641 withDoc "Cluster-wide NIC parameter defaults" .
642 optionalField $ simpleField "nicparams" [t| INicParams |]
646 withDoc "Ipolicy specs" .
647 optionalField $ simpleField "ipolicy" [t| JSObject JSValue |]
651 withDoc "DRBD helper program" $
652 optionalStringField "drbd_helper"
654 pDefaultIAllocator :: Field
656 withDoc "Default iallocator for cluster" $
657 optionalStringField "default_iallocator"
659 pMasterNetdev :: Field
661 withDoc "Master network device" $
662 optionalStringField "master_netdev"
664 pMasterNetmask :: Field
666 withDoc "Netmask of the master IP" .
667 optionalField $ simpleField "master_netmask" [t| NonNegative Int |]
669 pReservedLvs :: Field
671 withDoc "List of reserved LVs" .
672 optionalField $ simpleField "reserved_lvs" [t| [NonEmptyString] |]
676 withDoc "Modify list of hidden operating systems: each modification\
677 \ must have two items, the operation and the OS name; the operation\
678 \ can be add or remove" .
679 optionalField $ simpleField "hidden_os" [t| [(DdmSimple, NonEmptyString)] |]
681 pBlacklistedOs :: Field
683 withDoc "Modify list of blacklisted operating systems: each\
684 \ modification must have two items, the operation and the OS name;\
685 \ the operation can be add or remove" .
687 simpleField "blacklisted_os" [t| [(DdmSimple, NonEmptyString)] |]
689 pUseExternalMipScript :: Field
690 pUseExternalMipScript =
691 withDoc "Whether to use an external master IP address setup script" .
692 optionalField $ booleanField "use_external_mip_script"
694 pEnabledDiskTemplates :: Field
695 pEnabledDiskTemplates =
696 withDoc "List of enabled disk templates" .
698 simpleField "enabled_disk_templates" [t| [DiskTemplate] |]
702 withDoc "Resource(s) to query for" $
703 simpleField "what" [t| Qlang.QueryTypeOp |]
707 withDoc "Whether to use synchronization" $
708 defaultFalse "use_locking"
710 pQueryFields :: Field
712 withDoc "Requested fields" $
713 simpleField "fields" [t| [NonEmptyString] |]
715 pQueryFilter :: Field
717 withDoc "Query filter" .
718 optionalField $ simpleField "qfilter" [t| [JSValue] |]
720 pQueryFieldsFields :: Field
722 withDoc "Requested fields; if not given, all are returned" .
723 renameField "QueryFieldsFields" $
724 optionalField pQueryFields
728 withDoc "List of node names to run the OOB command against" .
729 defaultField [| [] |] $ simpleField "node_names" [t| [NonEmptyString] |]
733 withDoc "List of node UUIDs" .
734 optionalField $ simpleField "node_uuids" [t| [NonEmptyString] |]
738 withDoc "OOB command to run" $
739 simpleField "command" [t| OobCommand |]
743 withDoc "Timeout before the OOB helper will be terminated" .
744 defaultField [| C.oobTimeout |] $
745 simpleField "timeout" [t| Int |]
747 pIgnoreStatus :: Field
749 withDoc "Ignores the node offline status for power off" $
750 defaultFalse "ignore_status"
754 -- FIXME: we can't use the proper type "NonNegative Double", since
755 -- the default constant is a plain Double, not a non-negative one.
756 -- And trying to fix the constant introduces a cyclic import.
757 withDoc "Time in seconds to wait between powering on nodes" .
758 defaultField [| C.oobPowerDelay |] $
759 simpleField "power_delay" [t| Double |]
761 pRequiredNodes :: Field
763 withDoc "Required list of node names" .
764 renameField "ReqNodes " $ simpleField "nodes" [t| [NonEmptyString] |]
766 pRequiredNodeUuids :: Field
768 withDoc "Required list of node UUIDs" .
769 renameField "ReqNodeUuids " . optionalField $
770 simpleField "node_uuids" [t| [NonEmptyString] |]
772 pRestrictedCommand :: Field
774 withDoc "Restricted command name" .
775 renameField "RestrictedCommand" $
776 simpleField "command" [t| NonEmptyString |]
780 withDoc "A required node name (for single-node LUs)" $
781 simpleField "node_name" [t| NonEmptyString |]
785 withDoc "A node UUID (for single-node LUs)" .
786 optionalField $ simpleField "node_uuid" [t| NonEmptyString |]
790 withDoc "Primary IP address" .
792 simpleField "primary_ip" [t| NonEmptyString |]
794 pSecondaryIp :: Field
796 withDoc "Secondary IP address" $
797 optionalNEStringField "secondary_ip"
801 withDoc "Whether node is re-added to cluster" $
806 withDoc "Initial node group" $
807 optionalNEStringField "group"
809 pMasterCapable :: Field
811 withDoc "Whether node can become master or master candidate" .
812 optionalField $ booleanField "master_capable"
816 withDoc "Whether node can host instances" .
817 optionalField $ booleanField "vm_capable"
821 withDoc "Node parameters" .
822 renameField "genericNdParams" .
823 optionalField $ simpleField "ndparams" [t| JSObject JSValue |]
827 withDoc "List of names" .
828 defaultField [| [] |] $ simpleField "names" [t| [NonEmptyString] |]
832 withDoc "List of nodes" .
833 defaultField [| [] |] $ simpleField "nodes" [t| [NonEmptyString] |]
835 pStorageType :: Field
837 withDoc "Storage type" $
838 simpleField "storage_type" [t| StorageType |]
840 pStorageName :: Field
842 withDoc "Storage name" .
843 renameField "StorageName" .
844 optionalField $ simpleField "name" [t| NonEmptyString |]
846 pStorageChanges :: Field
848 withDoc "Requested storage changes" $
849 simpleField "changes" [t| JSObject JSValue |]
851 pIgnoreConsistency :: Field
853 withDoc "Whether to ignore disk consistency" $
854 defaultFalse "ignore_consistency"
856 pMasterCandidate :: Field
858 withDoc "Whether the node should become a master candidate" .
859 optionalField $ booleanField "master_candidate"
863 withDoc "Whether to mark the node or instance offline" .
864 optionalField $ booleanField "offline"
868 withDoc "Whether to mark the node as drained" .
869 optionalField $ booleanField "drained"
871 pAutoPromote :: Field
873 withDoc "Whether node(s) should be promoted to master candidate if\
875 defaultFalse "auto_promote"
879 withDoc "Whether the node should be marked as powered" .
880 optionalField $ booleanField "powered"
882 pMigrationMode :: Field
884 withDoc "Migration type (live/non-live)" .
885 renameField "MigrationMode" .
887 simpleField "mode" [t| MigrationMode |]
889 pMigrationLive :: Field
891 withDoc "Obsolete \'live\' migration mode (do not use)" .
892 renameField "OldLiveMode" . optionalField $ booleanField "live"
894 pMigrationTargetNode :: Field
895 pMigrationTargetNode =
896 withDoc "Target node for instance migration/failover" $
897 optionalNEStringField "target_node"
899 pMigrationTargetNodeUuid :: Field
900 pMigrationTargetNodeUuid =
901 withDoc "Target node UUID for instance migration/failover" $
902 optionalNEStringField "target_node_uuid"
904 pAllowRuntimeChgs :: Field
906 withDoc "Whether to allow runtime changes while migrating" $
907 defaultTrue "allow_runtime_changes"
909 pIgnoreIpolicy :: Field
911 withDoc "Whether to ignore ipolicy violations" $
912 defaultFalse "ignore_ipolicy"
916 withDoc "Iallocator for deciding the target node for shared-storage\
918 optionalNEStringField "iallocator"
920 pEarlyRelease :: Field
922 withDoc "Whether to release locks as soon as possible" $
923 defaultFalse "early_release"
927 withDoc "New secondary node" $
928 optionalNEStringField "remote_node"
930 pRemoteNodeUuid :: Field
932 withDoc "New secondary node UUID" $
933 optionalNEStringField "remote_node_uuid"
937 withDoc "Node evacuation mode" .
938 renameField "EvacMode" $ simpleField "mode" [t| EvacMode |]
940 pInstanceName :: Field
942 withDoc "A required instance name (for single-instance LUs)" $
943 simpleField "instance_name" [t| String |]
945 pForceVariant :: Field
947 withDoc "Whether to force an unknown OS variant" $
948 defaultFalse "force_variant"
950 pWaitForSync :: Field
952 withDoc "Whether to wait for the disk to synchronize" $
953 defaultTrue "wait_for_sync"
957 withDoc "Whether to check name" $
958 defaultTrue "name_check"
960 pInstBeParams :: Field
962 withDoc "Backend parameters for instance" .
963 renameField "InstBeParams" .
964 defaultField [| toJSObject [] |] $
965 simpleField "beparams" [t| JSObject JSValue |]
969 withDoc "List of instance disks" .
970 renameField "instDisks" $ simpleField "disks" [t| [IDiskParams] |]
972 pDiskTemplate :: Field
974 withDoc "Disk template" $
975 simpleField "disk_template" [t| DiskTemplate |]
979 withDoc "Driver for file-backed disks" .
980 optionalField $ simpleField "file_driver" [t| FileDriver |]
982 pFileStorageDir :: Field
984 withDoc "Directory for storing file-backed disks" $
985 optionalNEStringField "file_storage_dir"
987 pInstHvParams :: Field
989 withDoc "Hypervisor parameters for instance, hypervisor-dependent" .
990 renameField "InstHvParams" .
991 defaultField [| toJSObject [] |] $
992 simpleField "hvparams" [t| JSObject JSValue |]
996 withDoc "Selected hypervisor for an instance" .
998 simpleField "hypervisor" [t| Hypervisor |]
1000 pResetDefaults :: Field
1002 withDoc "Reset instance parameters to default if equal" $
1003 defaultFalse "identify_defaults"
1007 withDoc "Whether to ensure instance's IP address is inactive" $
1008 defaultTrue "ip_check"
1010 pIpConflictsCheck :: Field
1012 withDoc "Whether to check for conflicting IP addresses" $
1013 defaultTrue "conflicts_check"
1015 pInstCreateMode :: Field
1017 withDoc "Instance creation mode" .
1018 renameField "InstCreateMode" $ simpleField "mode" [t| InstCreateMode |]
1022 withDoc "List of NIC (network interface) definitions" $
1023 simpleField "nics" [t| [INicParams] |]
1027 withDoc "Do not install the OS (will disable automatic start)" .
1028 optionalField $ booleanField "no_install"
1032 withDoc "OS type for instance installation" $
1033 optionalNEStringField "os_type"
1035 pInstOsParams :: Field
1037 withDoc "OS parameters for instance" .
1038 renameField "InstOsParams" .
1039 defaultField [| toJSObject [] |] $
1040 simpleField "osparams" [t| JSObject JSValue |]
1042 pPrimaryNode :: Field
1044 withDoc "Primary node for an instance" $
1045 optionalNEStringField "pnode"
1047 pPrimaryNodeUuid :: Field
1049 withDoc "Primary node UUID for an instance" $
1050 optionalNEStringField "pnode_uuid"
1052 pSecondaryNode :: Field
1054 withDoc "Secondary node for an instance" $
1055 optionalNEStringField "snode"
1057 pSecondaryNodeUuid :: Field
1058 pSecondaryNodeUuid =
1059 withDoc "Secondary node UUID for an instance" $
1060 optionalNEStringField "snode_uuid"
1062 pSourceHandshake :: Field
1064 withDoc "Signed handshake from source (remote import only)" .
1065 optionalField $ simpleField "source_handshake" [t| [JSValue] |]
1067 pSourceInstance :: Field
1069 withDoc "Source instance name (remote import only)" $
1070 optionalNEStringField "source_instance_name"
1072 -- FIXME: non-negative int, whereas the constant is a plain int.
1073 pSourceShutdownTimeout :: Field
1074 pSourceShutdownTimeout =
1075 withDoc "How long source instance was given to shut down (remote import\
1077 defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
1078 simpleField "source_shutdown_timeout" [t| NonNegative Int |]
1080 pSourceX509Ca :: Field
1082 withDoc "Source X509 CA in PEM format (remote import only)" $
1083 optionalNEStringField "source_x509_ca"
1087 withDoc "Source node for import" $
1088 optionalNEStringField "src_node"
1090 pSrcNodeUuid :: Field
1092 withDoc "Source node UUID for import" $
1093 optionalNEStringField "src_node_uuid"
1097 withDoc "Source directory for import" $
1098 optionalNEStringField "src_path"
1100 pStartInstance :: Field
1102 withDoc "Whether to start instance after creation" $
1105 -- FIXME: unify/simplify with pTags, once that migrates to NonEmpty String"
1108 withDoc "Instance tags" .
1109 renameField "InstTags" .
1110 defaultField [| [] |] $
1111 simpleField "tags" [t| [NonEmptyString] |]
1113 pMultiAllocInstances :: Field
1114 pMultiAllocInstances =
1115 withDoc "List of instance create opcodes describing the instances to\
1117 renameField "InstMultiAlloc" .
1118 defaultField [| [] |] $
1119 simpleField "instances"[t| [JSValue] |]
1121 pOpportunisticLocking :: Field
1122 pOpportunisticLocking =
1123 withDoc "Whether to employ opportunistic locking for nodes, meaning\
1124 \ nodes already locked by another opcode won't be considered for\
1125 \ instance allocation (only when an iallocator is used)" $
1126 defaultFalse "opportunistic_locking"
1128 pInstanceUuid :: Field
1130 withDoc "An instance UUID (for single-instance LUs)" .
1131 optionalField $ simpleField "instance_uuid" [t| NonEmptyString |]
1133 pTempOsParams :: Field
1135 withDoc "Temporary OS parameters (currently only in reinstall, might be\
1136 \ added to install as well)" .
1137 renameField "TempOsParams" .
1138 optionalField $ simpleField "osparams" [t| JSObject JSValue |]
1140 pShutdownTimeout :: Field
1142 withDoc "How long to wait for instance to shut down" .
1143 defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
1144 simpleField "shutdown_timeout" [t| NonNegative Int |]
1146 -- | Another name for the shutdown timeout, because we like to be
1148 pShutdownTimeout' :: Field
1150 withDoc "How long to wait for instance to shut down" .
1151 renameField "InstShutdownTimeout" .
1152 defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
1153 simpleField "timeout" [t| NonNegative Int |]
1155 pIgnoreFailures :: Field
1157 withDoc "Whether to ignore failures during removal" $
1158 defaultFalse "ignore_failures"
1162 withDoc "New group or instance name" $
1163 simpleField "new_name" [t| NonEmptyString |]
1165 pIgnoreOfflineNodes :: Field
1166 pIgnoreOfflineNodes =
1167 withDoc "Whether to ignore offline nodes" $
1168 defaultFalse "ignore_offline_nodes"
1170 pTempHvParams :: Field
1172 withDoc "Temporary hypervisor parameters, hypervisor-dependent" .
1173 renameField "TempHvParams" .
1174 defaultField [| toJSObject [] |] $
1175 simpleField "hvparams" [t| JSObject JSValue |]
1177 pTempBeParams :: Field
1179 withDoc "Temporary backend parameters" .
1180 renameField "TempBeParams" .
1181 defaultField [| toJSObject [] |] $
1182 simpleField "beparams" [t| JSObject JSValue |]
1184 pNoRemember :: Field
1186 withDoc "Do not remember instance state changes" $
1187 defaultFalse "no_remember"
1189 pStartupPaused :: Field
1191 withDoc "Pause instance at startup" $
1192 defaultFalse "startup_paused"
1194 pIgnoreSecondaries :: Field
1195 pIgnoreSecondaries =
1196 withDoc "Whether to start the instance even if secondary disks are failing" $
1197 defaultFalse "ignore_secondaries"
1199 pRebootType :: Field
1201 withDoc "How to reboot the instance" $
1202 simpleField "reboot_type" [t| RebootType |]
1204 pReplaceDisksMode :: Field
1206 withDoc "Replacement mode" .
1207 renameField "ReplaceDisksMode" $ simpleField "mode" [t| ReplaceDisksMode |]
1209 pReplaceDisksList :: Field
1211 withDoc "List of disk indices" .
1212 renameField "ReplaceDisksList" .
1213 defaultField [| [] |] $
1214 simpleField "disks" [t| [DiskIndex] |]
1216 pMigrationCleanup :: Field
1218 withDoc "Whether a previously failed migration should be cleaned up" .
1219 renameField "MigrationCleanup" $ defaultFalse "cleanup"
1221 pAllowFailover :: Field
1223 withDoc "Whether we can fallback to failover if migration is not possible" $
1224 defaultFalse "allow_failover"
1226 pMoveTargetNode :: Field
1228 withDoc "Target node for instance move" .
1229 renameField "MoveTargetNode" $
1230 simpleField "target_node" [t| NonEmptyString |]
1232 pMoveTargetNodeUuid :: Field
1233 pMoveTargetNodeUuid =
1234 withDoc "Target node UUID for instance move" .
1235 renameField "MoveTargetNodeUuid" . optionalField $
1236 simpleField "target_node_uuid" [t| NonEmptyString |]
1238 pIgnoreDiskSize :: Field
1240 withDoc "Whether to ignore recorded disk size" $
1241 defaultFalse "ignore_size"
1243 pWaitForSyncFalse :: Field
1245 withDoc "Whether to wait for the disk to synchronize (defaults to false)" $
1246 defaultField [| False |] pWaitForSync
1248 pRecreateDisksInfo :: Field
1249 pRecreateDisksInfo =
1250 withDoc "Disk list for recreate disks" .
1251 renameField "RecreateDisksInfo" .
1252 defaultField [| RecreateDisksAll |] $
1253 simpleField "disks" [t| RecreateDisksInfo |]
1257 withDoc "Whether to only return configuration data without querying nodes" $
1258 defaultFalse "static"
1260 pInstParamsNicChanges :: Field
1261 pInstParamsNicChanges =
1262 withDoc "List of NIC changes" .
1263 renameField "InstNicChanges" .
1264 defaultField [| SetParamsEmpty |] $
1265 simpleField "nics" [t| SetParamsMods INicParams |]
1267 pInstParamsDiskChanges :: Field
1268 pInstParamsDiskChanges =
1269 withDoc "List of disk changes" .
1270 renameField "InstDiskChanges" .
1271 defaultField [| SetParamsEmpty |] $
1272 simpleField "disks" [t| SetParamsMods IDiskParams |]
1274 pRuntimeMem :: Field
1276 withDoc "New runtime memory" .
1277 optionalField $ simpleField "runtime_mem" [t| Positive Int |]
1279 pOptDiskTemplate :: Field
1281 withDoc "Instance disk template" .
1283 renameField "OptDiskTemplate" $
1284 simpleField "disk_template" [t| DiskTemplate |]
1286 pOsNameChange :: Field
1288 withDoc "Change the instance's OS without reinstalling the instance" $
1289 optionalNEStringField "os_name"
1293 withDoc "Disk index for e.g. grow disk" .
1294 renameField "DiskIndex " $ simpleField "disk" [t| DiskIndex |]
1296 pDiskChgAmount :: Field
1298 withDoc "Disk amount to add or grow to" .
1299 renameField "DiskChgAmount" $ simpleField "amount" [t| NonNegative Int |]
1301 pDiskChgAbsolute :: Field
1304 "Whether the amount parameter is an absolute target or a relative one" .
1305 renameField "DiskChkAbsolute" $ defaultFalse "absolute"
1307 pTargetGroups :: Field
1310 "Destination group names or UUIDs (defaults to \"all but current group\")" .
1311 optionalField $ simpleField "target_groups" [t| [NonEmptyString] |]
1313 pNodeGroupAllocPolicy :: Field
1314 pNodeGroupAllocPolicy =
1315 withDoc "Instance allocation policy" .
1317 simpleField "alloc_policy" [t| AllocPolicy |]
1319 pGroupNodeParams :: Field
1321 withDoc "Default node parameters for group" .
1322 optionalField $ simpleField "ndparams" [t| JSObject JSValue |]
1324 pExportMode :: Field
1326 withDoc "Export mode" .
1327 renameField "ExportMode" $ simpleField "mode" [t| ExportMode |]
1329 -- FIXME: Rename target_node as it changes meaning for different
1330 -- export modes (e.g. "destination")
1331 pExportTargetNode :: Field
1333 withDoc "Target node (depends on export mode)" .
1334 renameField "ExportTarget" $
1335 simpleField "target_node" [t| ExportTarget |]
1337 pExportTargetNodeUuid :: Field
1338 pExportTargetNodeUuid =
1339 withDoc "Target node UUID (if local export)" .
1340 renameField "ExportTargetNodeUuid" . optionalField $
1341 simpleField "target_node_uuid" [t| NonEmptyString |]
1343 pShutdownInstance :: Field
1345 withDoc "Whether to shutdown the instance before export" $
1346 defaultTrue "shutdown"
1348 pRemoveInstance :: Field
1350 withDoc "Whether to remove instance after export" $
1351 defaultFalse "remove_instance"
1353 pIgnoreRemoveFailures :: Field
1354 pIgnoreRemoveFailures =
1355 withDoc "Whether to ignore failures while removing instances" $
1356 defaultFalse "ignore_remove_failures"
1358 pX509KeyName :: Field
1360 withDoc "Name of X509 key (remote export only)" .
1361 optionalField $ simpleField "x509_key_name" [t| [JSValue] |]
1363 pX509DestCA :: Field
1365 withDoc "Destination X509 CA (remote export only)" $
1366 optionalNEStringField "destination_x509_ca"
1368 pTagsObject :: Field
1370 withDoc "Tag kind" $
1371 simpleField "kind" [t| TagKind |]
1375 withDoc "Name of object" .
1376 renameField "TagsGetName" .
1377 optionalField $ simpleField "name" [t| String |]
1381 withDoc "List of tag names" $
1382 simpleField "tags" [t| [String] |]
1384 -- FIXME: this should be compiled at load time?
1385 pTagSearchPattern :: Field
1387 withDoc "Search pattern (regular expression)" .
1388 renameField "TagSearchPattern" $
1389 simpleField "pattern" [t| NonEmptyString |]
1391 pDelayDuration :: Field
1393 withDoc "Duration parameter for 'OpTestDelay'" .
1394 renameField "DelayDuration" $
1395 simpleField "duration" [t| Double |]
1397 pDelayOnMaster :: Field
1399 withDoc "on_master field for 'OpTestDelay'" .
1400 renameField "DelayOnMaster" $
1401 defaultTrue "on_master"
1403 pDelayOnNodes :: Field
1405 withDoc "on_nodes field for 'OpTestDelay'" .
1406 renameField "DelayOnNodes" .
1407 defaultField [| [] |] $
1408 simpleField "on_nodes" [t| [NonEmptyString] |]
1410 pDelayOnNodeUuids :: Field
1412 withDoc "on_node_uuids field for 'OpTestDelay'" .
1413 renameField "DelayOnNodeUuids" . optionalField $
1414 simpleField "on_node_uuids" [t| [NonEmptyString] |]
1416 pDelayRepeat :: Field
1418 withDoc "Repeat parameter for OpTestDelay" .
1419 renameField "DelayRepeat" .
1420 defaultField [| forceNonNeg (0::Int) |] $
1421 simpleField "repeat" [t| NonNegative Int |]
1423 pIAllocatorDirection :: Field
1424 pIAllocatorDirection =
1425 withDoc "IAllocator test direction" .
1426 renameField "IAllocatorDirection" $
1427 simpleField "direction" [t| IAllocatorTestDir |]
1429 pIAllocatorMode :: Field
1431 withDoc "IAllocator test mode" .
1432 renameField "IAllocatorMode" $
1433 simpleField "mode" [t| IAllocatorMode |]
1435 pIAllocatorReqName :: Field
1436 pIAllocatorReqName =
1437 withDoc "IAllocator target name (new instance, node to evac, etc.)" .
1438 renameField "IAllocatorReqName" $ simpleField "name" [t| NonEmptyString |]
1440 pIAllocatorNics :: Field
1442 withDoc "Custom OpTestIAllocator nics" .
1443 renameField "IAllocatorNics" .
1444 optionalField $ simpleField "nics" [t| [INicParams] |]
1446 pIAllocatorDisks :: Field
1448 withDoc "Custom OpTestAllocator disks" .
1449 renameField "IAllocatorDisks" .
1450 optionalField $ simpleField "disks" [t| [JSValue] |]
1452 pIAllocatorMemory :: Field
1454 withDoc "IAllocator memory field" .
1455 renameField "IAllocatorMem" .
1457 simpleField "memory" [t| NonNegative Int |]
1459 pIAllocatorVCpus :: Field
1461 withDoc "IAllocator vcpus field" .
1462 renameField "IAllocatorVCpus" .
1464 simpleField "vcpus" [t| NonNegative Int |]
1466 pIAllocatorOs :: Field
1468 withDoc "IAllocator os field" .
1469 renameField "IAllocatorOs" $ optionalNEStringField "os"
1471 pIAllocatorInstances :: Field
1472 pIAllocatorInstances =
1473 withDoc "IAllocator instances field" .
1474 renameField "IAllocatorInstances " .
1476 simpleField "instances" [t| [NonEmptyString] |]
1478 pIAllocatorEvacMode :: Field
1479 pIAllocatorEvacMode =
1480 withDoc "IAllocator evac mode" .
1481 renameField "IAllocatorEvacMode" .
1483 simpleField "evac_mode" [t| EvacMode |]
1485 pIAllocatorSpindleUse :: Field
1486 pIAllocatorSpindleUse =
1487 withDoc "IAllocator spindle use" .
1488 renameField "IAllocatorSpindleUse" .
1489 defaultField [| forceNonNeg (1::Int) |] $
1490 simpleField "spindle_use" [t| NonNegative Int |]
1492 pIAllocatorCount :: Field
1494 withDoc "IAllocator count field" .
1495 renameField "IAllocatorCount" .
1496 defaultField [| forceNonNeg (1::Int) |] $
1497 simpleField "count" [t| NonNegative Int |]
1499 pJQueueNotifyWaitLock :: Field
1500 pJQueueNotifyWaitLock =
1501 withDoc "'OpTestJqueue' notify_waitlock" $
1502 defaultFalse "notify_waitlock"
1504 pJQueueNotifyExec :: Field
1506 withDoc "'OpTestJQueue' notify_exec" $
1507 defaultFalse "notify_exec"
1509 pJQueueLogMessages :: Field
1510 pJQueueLogMessages =
1511 withDoc "'OpTestJQueue' log_messages" .
1512 defaultField [| [] |] $ simpleField "log_messages" [t| [String] |]
1514 pJQueueFail :: Field
1516 withDoc "'OpTestJQueue' fail attribute" .
1517 renameField "JQueueFail" $ defaultFalse "fail"
1519 pTestDummyResult :: Field
1521 withDoc "'OpTestDummy' result field" .
1522 renameField "TestDummyResult" $ simpleField "result" [t| JSValue |]
1524 pTestDummyMessages :: Field
1525 pTestDummyMessages =
1526 withDoc "'OpTestDummy' messages field" .
1527 renameField "TestDummyMessages" $
1528 simpleField "messages" [t| JSValue |]
1530 pTestDummyFail :: Field
1532 withDoc "'OpTestDummy' fail field" .
1533 renameField "TestDummyFail" $ simpleField "fail" [t| JSValue |]
1535 pTestDummySubmitJobs :: Field
1536 pTestDummySubmitJobs =
1537 withDoc "'OpTestDummy' submit_jobs field" .
1538 renameField "TestDummySubmitJobs" $
1539 simpleField "submit_jobs" [t| JSValue |]
1541 pNetworkName :: Field
1543 withDoc "Network name" $
1544 simpleField "network_name" [t| NonEmptyString |]
1546 pNetworkAddress4 :: Field
1548 withDoc "Network address (IPv4 subnet)" .
1549 renameField "NetworkAddress4" $
1550 simpleField "network" [t| IPv4Network |]
1552 pNetworkGateway4 :: Field
1554 withDoc "Network gateway (IPv4 address)" .
1555 renameField "NetworkGateway4" .
1556 optionalField $ simpleField "gateway" [t| IPv4Address |]
1558 pNetworkAddress6 :: Field
1560 withDoc "Network address (IPv6 subnet)" .
1561 renameField "NetworkAddress6" .
1562 optionalField $ simpleField "network6" [t| IPv6Network |]
1564 pNetworkGateway6 :: Field
1566 withDoc "Network gateway (IPv6 address)" .
1567 renameField "NetworkGateway6" .
1568 optionalField $ simpleField "gateway6" [t| IPv6Address |]
1570 pNetworkMacPrefix :: Field
1572 withDoc "Network specific mac prefix (that overrides the cluster one)" .
1573 renameField "NetMacPrefix" $
1574 optionalNEStringField "mac_prefix"
1576 pNetworkAddRsvdIps :: Field
1577 pNetworkAddRsvdIps =
1578 withDoc "Which IP addresses to reserve" .
1579 renameField "NetworkAddRsvdIps" .
1581 simpleField "add_reserved_ips" [t| [IPv4Address] |]
1583 pNetworkRemoveRsvdIps :: Field
1584 pNetworkRemoveRsvdIps =
1585 withDoc "Which external IP addresses to release" .
1586 renameField "NetworkRemoveRsvdIps" .
1588 simpleField "remove_reserved_ips" [t| [IPv4Address] |]
1590 pNetworkMode :: Field
1592 withDoc "Network mode when connecting to a group" $
1593 simpleField "network_mode" [t| NICMode |]
1595 pNetworkLink :: Field
1597 withDoc "Network link when connecting to a group" $
1598 simpleField "network_link" [t| NonEmptyString |]