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 , pGlobalFileStorageDir
104 , pGlobalSharedFileStorageDir
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 -- | Replace disks type.
305 $(declareSADT "ReplaceDisksMode"
306 [ ("ReplaceOnPrimary", 'C.replaceDiskPri)
307 , ("ReplaceOnSecondary", 'C.replaceDiskSec)
308 , ("ReplaceNewSecondary", 'C.replaceDiskChg)
309 , ("ReplaceAuto", 'C.replaceDiskAuto)
311 $(makeJSONInstance ''ReplaceDisksMode)
313 -- | Disk index type (embedding constraints on the index value via a
314 -- smart constructor).
315 newtype DiskIndex = DiskIndex { unDiskIndex :: Int }
316 deriving (Show, Eq, Ord)
318 -- | Smart constructor for 'DiskIndex'.
319 mkDiskIndex :: (Monad m) => Int -> m DiskIndex
320 mkDiskIndex i | i >= 0 && i < C.maxDisks = return (DiskIndex i)
321 | otherwise = fail $ "Invalid value for disk index '" ++
322 show i ++ "', required between 0 and " ++
325 instance JSON DiskIndex where
326 readJSON v = readJSON v >>= mkDiskIndex
327 showJSON = showJSON . unDiskIndex
331 -- | Type holding disk access modes.
332 $(declareSADT "DiskAccess"
333 [ ("DiskReadOnly", 'C.diskRdonly)
334 , ("DiskReadWrite", 'C.diskRdwr)
336 $(makeJSONInstance ''DiskAccess)
338 -- | NIC modification definition.
339 $(buildObject "INicParams" "inic"
340 [ optionalField $ simpleField C.inicMac [t| NonEmptyString |]
341 , optionalField $ simpleField C.inicIp [t| String |]
342 , optionalField $ simpleField C.inicMode [t| NonEmptyString |]
343 , optionalField $ simpleField C.inicLink [t| NonEmptyString |]
344 , optionalField $ simpleField C.inicName [t| NonEmptyString |]
345 , optionalField $ simpleField C.inicVlan [t| NonEmptyString |]
346 , optionalField $ simpleField C.inicBridge [t| NonEmptyString |]
349 -- | Disk modification definition. FIXME: disksize should be VTYPE_UNIT.
350 $(buildObject "IDiskParams" "idisk"
351 [ optionalField $ simpleField C.idiskSize [t| Int |]
352 , optionalField $ simpleField C.idiskMode [t| DiskAccess |]
353 , optionalField $ simpleField C.idiskAdopt [t| NonEmptyString |]
354 , optionalField $ simpleField C.idiskVg [t| NonEmptyString |]
355 , optionalField $ simpleField C.idiskMetavg [t| NonEmptyString |]
356 , optionalField $ simpleField C.idiskName [t| NonEmptyString |]
359 -- | Disk changes type for OpInstanceRecreateDisks. This is a bit
360 -- strange, because the type in Python is something like Either
361 -- [DiskIndex] [DiskChanges], but we can't represent the type of an
362 -- empty list in JSON, so we have to add a custom case for the empty
364 data RecreateDisksInfo
366 | RecreateDisksIndices (NonEmpty DiskIndex)
367 | RecreateDisksParams (NonEmpty (DiskIndex, IDiskParams))
370 readRecreateDisks :: JSValue -> Text.JSON.Result RecreateDisksInfo
371 readRecreateDisks (JSArray []) = return RecreateDisksAll
372 readRecreateDisks v =
373 case readJSON v::Text.JSON.Result [DiskIndex] of
374 Text.JSON.Ok indices -> liftM RecreateDisksIndices (mkNonEmpty indices)
375 _ -> case readJSON v::Text.JSON.Result [(DiskIndex, IDiskParams)] of
376 Text.JSON.Ok params -> liftM RecreateDisksParams (mkNonEmpty params)
377 _ -> fail $ "Can't parse disk information as either list of disk"
378 ++ " indices or list of disk parameters; value received:"
381 instance JSON RecreateDisksInfo where
382 readJSON = readRecreateDisks
383 showJSON RecreateDisksAll = showJSON ()
384 showJSON (RecreateDisksIndices idx) = showJSON idx
385 showJSON (RecreateDisksParams params) = showJSON params
387 -- | Simple type for old-style ddm changes.
388 data DdmOldChanges = DdmOldIndex (NonNegative Int)
389 | DdmOldMod DdmSimple
392 readDdmOldChanges :: JSValue -> Text.JSON.Result DdmOldChanges
393 readDdmOldChanges v =
394 case readJSON v::Text.JSON.Result (NonNegative Int) of
395 Text.JSON.Ok nn -> return $ DdmOldIndex nn
396 _ -> case readJSON v::Text.JSON.Result DdmSimple of
397 Text.JSON.Ok ddms -> return $ DdmOldMod ddms
398 _ -> fail $ "Can't parse value '" ++ show (pp_value v) ++ "' as"
399 ++ " either index or modification"
401 instance JSON DdmOldChanges where
402 showJSON (DdmOldIndex i) = showJSON i
403 showJSON (DdmOldMod m) = showJSON m
404 readJSON = readDdmOldChanges
406 -- | Instance disk or nic modifications.
409 | SetParamsDeprecated (NonEmpty (DdmOldChanges, a))
410 | SetParamsNew (NonEmpty (DdmFull, Int, a))
413 -- | Custom deserialiser for 'SetParamsMods'.
414 readSetParams :: (JSON a) => JSValue -> Text.JSON.Result (SetParamsMods a)
415 readSetParams (JSArray []) = return SetParamsEmpty
417 case readJSON v::Text.JSON.Result [(DdmOldChanges, JSValue)] of
418 Text.JSON.Ok _ -> liftM SetParamsDeprecated $ readJSON v
419 _ -> liftM SetParamsNew $ readJSON v
421 instance (JSON a) => JSON (SetParamsMods a) where
422 showJSON SetParamsEmpty = showJSON ()
423 showJSON (SetParamsDeprecated v) = showJSON v
424 showJSON (SetParamsNew v) = showJSON v
425 readJSON = readSetParams
427 -- | Custom type for target_node parameter of OpBackupExport, which
428 -- varies depending on mode. FIXME: this uses an [JSValue] since
429 -- we don't care about individual rows (just like the Python code
430 -- tests). But the proper type could be parsed if we wanted.
431 data ExportTarget = ExportTargetLocal NonEmptyString
432 | ExportTargetRemote [JSValue]
435 -- | Custom reader for 'ExportTarget'.
436 readExportTarget :: JSValue -> Text.JSON.Result ExportTarget
437 readExportTarget (JSString s) = liftM ExportTargetLocal $
438 mkNonEmpty (fromJSString s)
439 readExportTarget (JSArray arr) = return $ ExportTargetRemote arr
440 readExportTarget v = fail $ "Invalid value received for 'target_node': " ++
443 instance JSON ExportTarget where
444 showJSON (ExportTargetLocal s) = showJSON s
445 showJSON (ExportTargetRemote l) = showJSON l
446 readJSON = readExportTarget
448 -- * Common opcode parameters
452 withDoc "Run checks only, don't execute" .
453 optionalField $ booleanField "dry_run"
457 withDoc "Debug level" .
458 optionalField $ simpleField "debug_level" [t| NonNegative Int |]
462 withDoc "Opcode priority. Note: python uses a separate constant,\
463 \ we're using the actual value we know it's the default" .
464 defaultField [| OpPrioNormal |] $
465 simpleField "priority" [t| OpSubmitPriority |]
467 pDependencies :: Field
469 withDoc "Job dependencies" .
470 optionalNullSerField $ simpleField "depends" [t| [JobDependency] |]
474 withDoc "Comment field" .
475 optionalNullSerField $ stringField "comment"
479 withDoc "Reason trail field" $
480 simpleField C.opcodeReason [t| ReasonTrail |]
484 pDebugSimulateErrors :: Field
485 pDebugSimulateErrors =
486 withDoc "Whether to simulate errors (useful for debugging)" $
487 defaultFalse "debug_simulate_errors"
491 withDoc "Error codes" $
492 defaultFalse "error_codes"
496 withDoc "Which checks to skip" .
497 defaultField [| emptyListSet |] $
498 simpleField "skip_checks" [t| ListSet VerifyOptionalChecks |]
500 pIgnoreErrors :: Field
502 withDoc "List of error codes that should be treated as warnings" .
503 defaultField [| emptyListSet |] $
504 simpleField "ignore_errors" [t| ListSet CVErrorCode |]
508 withDoc "Verbose mode" $
509 defaultFalse "verbose"
511 pOptGroupName :: Field
513 withDoc "Optional group name" .
514 renameField "OptGroupName" .
515 optionalField $ simpleField "group_name" [t| NonEmptyString |]
519 withDoc "Group name" $
520 simpleField "group_name" [t| NonEmptyString |]
524 withDoc "List of instances" .
525 defaultField [| [] |] $
526 simpleField "instances" [t| [NonEmptyString] |]
528 pOutputFields :: Field
530 withDoc "Selected output fields" $
531 simpleField "output_fields" [t| [NonEmptyString] |]
535 withDoc "A generic name" $
536 simpleField "name" [t| NonEmptyString |]
540 withDoc "Whether to force the operation" $
545 withDoc "Set hypervisor states" .
546 optionalField $ simpleField "hv_state" [t| JSObject JSValue |]
550 withDoc "Set disk states" .
551 optionalField $ simpleField "disk_state" [t| JSObject JSValue |]
553 -- | Global directory for storing file-backed disks.
554 pGlobalFileStorageDir :: Field
555 pGlobalFileStorageDir = optionalNEStringField "file_storage_dir"
557 -- | Global directory for storing shared-file-backed disks.
558 pGlobalSharedFileStorageDir :: Field
559 pGlobalSharedFileStorageDir = optionalNEStringField "shared_file_storage_dir"
561 -- | Volume group name.
564 withDoc "Volume group name" $
565 optionalStringField "vg_name"
567 pEnabledHypervisors :: Field
568 pEnabledHypervisors =
569 withDoc "List of enabled hypervisors" .
571 simpleField "enabled_hypervisors" [t| [Hypervisor] |]
573 pClusterHvParams :: Field
575 withDoc "Cluster-wide hypervisor parameters, hypervisor-dependent" .
576 renameField "ClusterHvParams" .
578 simpleField "hvparams" [t| GenericContainer String (JSObject JSValue) |]
580 pClusterBeParams :: Field
582 withDoc "Cluster-wide backend parameter defaults" .
583 renameField "ClusterBeParams" .
584 optionalField $ simpleField "beparams" [t| JSObject JSValue |]
588 withDoc "Cluster-wide per-OS hypervisor parameter defaults" .
590 simpleField "os_hvp" [t| GenericContainer String (JSObject JSValue) |]
592 pClusterOsParams :: Field
594 withDoc "Cluster-wide OS parameter defaults" .
595 renameField "ClusterOsParams" .
597 simpleField "osparams" [t| GenericContainer String (JSObject JSValue) |]
601 withDoc "Disk templates' parameter defaults" .
603 simpleField "diskparams"
604 [t| GenericContainer DiskTemplate (JSObject JSValue) |]
606 pCandidatePoolSize :: Field
608 withDoc "Master candidate pool size" .
609 optionalField $ simpleField "candidate_pool_size" [t| Positive Int |]
613 withDoc "Set UID pool, must be list of lists describing UID ranges\
614 \ (two items, start and end inclusive)" .
615 optionalField $ simpleField "uid_pool" [t| [(Int, Int)] |]
619 withDoc "Extend UID pool, must be list of lists describing UID\
620 \ ranges (two items, start and end inclusive)" .
621 optionalField $ simpleField "add_uids" [t| [(Int, Int)] |]
625 withDoc "Shrink UID pool, must be list of lists describing UID\
626 \ ranges (two items, start and end inclusive) to be removed" .
627 optionalField $ simpleField "remove_uids" [t| [(Int, Int)] |]
629 pMaintainNodeHealth :: Field
630 pMaintainNodeHealth =
631 withDoc "Whether to automatically maintain node health" .
632 optionalField $ booleanField "maintain_node_health"
634 -- | Whether to modify and keep in sync the @/etc/hosts@ files of nodes.
635 pModifyEtcHosts :: Field
636 pModifyEtcHosts = optionalField $ booleanField "modify_etc_hosts"
638 -- | Whether to wipe disks before allocating them to instances.
639 pPreallocWipeDisks :: Field
641 withDoc "Whether to wipe disks before allocating them to instances" .
642 optionalField $ booleanField "prealloc_wipe_disks"
646 withDoc "Cluster-wide NIC parameter defaults" .
647 optionalField $ simpleField "nicparams" [t| INicParams |]
651 withDoc "Ipolicy specs" .
652 optionalField $ simpleField "ipolicy" [t| JSObject JSValue |]
656 withDoc "DRBD helper program" $
657 optionalStringField "drbd_helper"
659 pDefaultIAllocator :: Field
661 withDoc "Default iallocator for cluster" $
662 optionalStringField "default_iallocator"
664 pMasterNetdev :: Field
666 withDoc "Master network device" $
667 optionalStringField "master_netdev"
669 pMasterNetmask :: Field
671 withDoc "Netmask of the master IP" .
672 optionalField $ simpleField "master_netmask" [t| NonNegative Int |]
674 pReservedLvs :: Field
676 withDoc "List of reserved LVs" .
677 optionalField $ simpleField "reserved_lvs" [t| [NonEmptyString] |]
681 withDoc "Modify list of hidden operating systems: each modification\
682 \ must have two items, the operation and the OS name; the operation\
683 \ can be add or remove" .
684 optionalField $ simpleField "hidden_os" [t| [(DdmSimple, NonEmptyString)] |]
686 pBlacklistedOs :: Field
688 withDoc "Modify list of blacklisted operating systems: each\
689 \ modification must have two items, the operation and the OS name;\
690 \ the operation can be add or remove" .
692 simpleField "blacklisted_os" [t| [(DdmSimple, NonEmptyString)] |]
694 pUseExternalMipScript :: Field
695 pUseExternalMipScript =
696 withDoc "Whether to use an external master IP address setup script" .
697 optionalField $ booleanField "use_external_mip_script"
699 pEnabledDiskTemplates :: Field
700 pEnabledDiskTemplates =
701 withDoc "List of enabled disk templates" .
703 simpleField "enabled_disk_templates" [t| [DiskTemplate] |]
707 withDoc "Resource(s) to query for" $
708 simpleField "what" [t| Qlang.QueryTypeOp |]
712 withDoc "Whether to use synchronization" $
713 defaultFalse "use_locking"
715 pQueryFields :: Field
717 withDoc "Requested fields" $
718 simpleField "fields" [t| [NonEmptyString] |]
720 pQueryFilter :: Field
722 withDoc "Query filter" .
723 optionalField $ simpleField "qfilter" [t| [JSValue] |]
725 pQueryFieldsFields :: Field
727 withDoc "Requested fields; if not given, all are returned" .
728 renameField "QueryFieldsFields" $
729 optionalField pQueryFields
733 withDoc "List of node names to run the OOB command against" .
734 defaultField [| [] |] $ simpleField "node_names" [t| [NonEmptyString] |]
738 withDoc "List of node UUIDs" .
739 optionalField $ simpleField "node_uuids" [t| [NonEmptyString] |]
743 withDoc "OOB command to run" $
744 simpleField "command" [t| OobCommand |]
748 withDoc "Timeout before the OOB helper will be terminated" .
749 defaultField [| C.oobTimeout |] $
750 simpleField "timeout" [t| Int |]
752 pIgnoreStatus :: Field
754 withDoc "Ignores the node offline status for power off" $
755 defaultFalse "ignore_status"
759 -- FIXME: we can't use the proper type "NonNegative Double", since
760 -- the default constant is a plain Double, not a non-negative one.
761 -- And trying to fix the constant introduces a cyclic import.
762 withDoc "Time in seconds to wait between powering on nodes" .
763 defaultField [| C.oobPowerDelay |] $
764 simpleField "power_delay" [t| Double |]
766 pRequiredNodes :: Field
768 withDoc "Required list of node names" .
769 renameField "ReqNodes " $ simpleField "nodes" [t| [NonEmptyString] |]
771 pRequiredNodeUuids :: Field
773 withDoc "Required list of node UUIDs" .
774 renameField "ReqNodeUuids " . optionalField $
775 simpleField "node_uuids" [t| [NonEmptyString] |]
777 pRestrictedCommand :: Field
779 withDoc "Restricted command name" .
780 renameField "RestrictedCommand" $
781 simpleField "command" [t| NonEmptyString |]
785 withDoc "A required node name (for single-node LUs)" $
786 simpleField "node_name" [t| NonEmptyString |]
790 withDoc "A node UUID (for single-node LUs)" .
791 optionalField $ simpleField "node_uuid" [t| NonEmptyString |]
795 withDoc "Primary IP address" .
797 simpleField "primary_ip" [t| NonEmptyString |]
799 pSecondaryIp :: Field
801 withDoc "Secondary IP address" $
802 optionalNEStringField "secondary_ip"
806 withDoc "Whether node is re-added to cluster" $
811 withDoc "Initial node group" $
812 optionalNEStringField "group"
814 pMasterCapable :: Field
816 withDoc "Whether node can become master or master candidate" .
817 optionalField $ booleanField "master_capable"
821 withDoc "Whether node can host instances" .
822 optionalField $ booleanField "vm_capable"
826 withDoc "Node parameters" .
827 renameField "genericNdParams" .
828 optionalField $ simpleField "ndparams" [t| JSObject JSValue |]
832 withDoc "List of names" .
833 defaultField [| [] |] $ simpleField "names" [t| [NonEmptyString] |]
837 withDoc "List of nodes" .
838 defaultField [| [] |] $ simpleField "nodes" [t| [NonEmptyString] |]
840 pStorageType :: Field
842 withDoc "Storage type" $
843 simpleField "storage_type" [t| StorageType |]
845 pStorageName :: Field
847 withDoc "Storage name" .
848 renameField "StorageName" .
849 optionalField $ simpleField "name" [t| NonEmptyString |]
851 pStorageChanges :: Field
853 withDoc "Requested storage changes" $
854 simpleField "changes" [t| JSObject JSValue |]
856 pIgnoreConsistency :: Field
858 withDoc "Whether to ignore disk consistency" $
859 defaultFalse "ignore_consistency"
861 pMasterCandidate :: Field
863 withDoc "Whether the node should become a master candidate" .
864 optionalField $ booleanField "master_candidate"
868 withDoc "Whether to mark the node or instance offline" .
869 optionalField $ booleanField "offline"
873 withDoc "Whether to mark the node as drained" .
874 optionalField $ booleanField "drained"
876 pAutoPromote :: Field
878 withDoc "Whether node(s) should be promoted to master candidate if\
880 defaultFalse "auto_promote"
884 withDoc "Whether the node should be marked as powered" .
885 optionalField $ booleanField "powered"
887 pMigrationMode :: Field
889 withDoc "Migration type (live/non-live)" .
890 renameField "MigrationMode" .
892 simpleField "mode" [t| MigrationMode |]
894 pMigrationLive :: Field
896 withDoc "Obsolete \'live\' migration mode (do not use)" .
897 renameField "OldLiveMode" . optionalField $ booleanField "live"
899 pMigrationTargetNode :: Field
900 pMigrationTargetNode =
901 withDoc "Target node for instance migration/failover" $
902 optionalNEStringField "target_node"
904 pMigrationTargetNodeUuid :: Field
905 pMigrationTargetNodeUuid =
906 withDoc "Target node UUID for instance migration/failover" $
907 optionalNEStringField "target_node_uuid"
909 pAllowRuntimeChgs :: Field
911 withDoc "Whether to allow runtime changes while migrating" $
912 defaultTrue "allow_runtime_changes"
914 pIgnoreIpolicy :: Field
916 withDoc "Whether to ignore ipolicy violations" $
917 defaultFalse "ignore_ipolicy"
921 withDoc "Iallocator for deciding the target node for shared-storage\
923 optionalNEStringField "iallocator"
925 pEarlyRelease :: Field
927 withDoc "Whether to release locks as soon as possible" $
928 defaultFalse "early_release"
932 withDoc "New secondary node" $
933 optionalNEStringField "remote_node"
935 pRemoteNodeUuid :: Field
937 withDoc "New secondary node UUID" $
938 optionalNEStringField "remote_node_uuid"
942 withDoc "Node evacuation mode" .
943 renameField "EvacMode" $ simpleField "mode" [t| EvacMode |]
945 pInstanceName :: Field
947 withDoc "A required instance name (for single-instance LUs)" $
948 simpleField "instance_name" [t| String |]
950 pForceVariant :: Field
952 withDoc "Whether to force an unknown OS variant" $
953 defaultFalse "force_variant"
955 pWaitForSync :: Field
957 withDoc "Whether to wait for the disk to synchronize" $
958 defaultTrue "wait_for_sync"
962 withDoc "Whether to check name" $
963 defaultTrue "name_check"
965 pInstBeParams :: Field
967 withDoc "Backend parameters for instance" .
968 renameField "InstBeParams" .
969 defaultField [| toJSObject [] |] $
970 simpleField "beparams" [t| JSObject JSValue |]
974 withDoc "List of instance disks" .
975 renameField "instDisks" $ simpleField "disks" [t| [IDiskParams] |]
977 pDiskTemplate :: Field
979 withDoc "Disk template" $
980 simpleField "disk_template" [t| DiskTemplate |]
984 withDoc "Driver for file-backed disks" .
985 optionalField $ simpleField "file_driver" [t| FileDriver |]
987 pFileStorageDir :: Field
989 withDoc "Directory for storing file-backed disks" $
990 optionalNEStringField "file_storage_dir"
992 pInstHvParams :: Field
994 withDoc "Hypervisor parameters for instance, hypervisor-dependent" .
995 renameField "InstHvParams" .
996 defaultField [| toJSObject [] |] $
997 simpleField "hvparams" [t| JSObject JSValue |]
1001 withDoc "Selected hypervisor for an instance" .
1003 simpleField "hypervisor" [t| Hypervisor |]
1005 pResetDefaults :: Field
1007 withDoc "Reset instance parameters to default if equal" $
1008 defaultFalse "identify_defaults"
1012 withDoc "Whether to ensure instance's IP address is inactive" $
1013 defaultTrue "ip_check"
1015 pIpConflictsCheck :: Field
1017 withDoc "Whether to check for conflicting IP addresses" $
1018 defaultTrue "conflicts_check"
1020 pInstCreateMode :: Field
1022 withDoc "Instance creation mode" .
1023 renameField "InstCreateMode" $ simpleField "mode" [t| InstCreateMode |]
1027 withDoc "List of NIC (network interface) definitions" $
1028 simpleField "nics" [t| [INicParams] |]
1032 withDoc "Do not install the OS (will disable automatic start)" .
1033 optionalField $ booleanField "no_install"
1037 withDoc "OS type for instance installation" $
1038 optionalNEStringField "os_type"
1040 pInstOsParams :: Field
1042 withDoc "OS parameters for instance" .
1043 renameField "InstOsParams" .
1044 defaultField [| toJSObject [] |] $
1045 simpleField "osparams" [t| JSObject JSValue |]
1047 pPrimaryNode :: Field
1049 withDoc "Primary node for an instance" $
1050 optionalNEStringField "pnode"
1052 pPrimaryNodeUuid :: Field
1054 withDoc "Primary node UUID for an instance" $
1055 optionalNEStringField "pnode_uuid"
1057 pSecondaryNode :: Field
1059 withDoc "Secondary node for an instance" $
1060 optionalNEStringField "snode"
1062 pSecondaryNodeUuid :: Field
1063 pSecondaryNodeUuid =
1064 withDoc "Secondary node UUID for an instance" $
1065 optionalNEStringField "snode_uuid"
1067 pSourceHandshake :: Field
1069 withDoc "Signed handshake from source (remote import only)" .
1070 optionalField $ simpleField "source_handshake" [t| [JSValue] |]
1072 pSourceInstance :: Field
1074 withDoc "Source instance name (remote import only)" $
1075 optionalNEStringField "source_instance_name"
1077 -- FIXME: non-negative int, whereas the constant is a plain int.
1078 pSourceShutdownTimeout :: Field
1079 pSourceShutdownTimeout =
1080 withDoc "How long source instance was given to shut down (remote import\
1082 defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
1083 simpleField "source_shutdown_timeout" [t| NonNegative Int |]
1085 pSourceX509Ca :: Field
1087 withDoc "Source X509 CA in PEM format (remote import only)" $
1088 optionalNEStringField "source_x509_ca"
1092 withDoc "Source node for import" $
1093 optionalNEStringField "src_node"
1095 pSrcNodeUuid :: Field
1097 withDoc "Source node UUID for import" $
1098 optionalNEStringField "src_node_uuid"
1102 withDoc "Source directory for import" $
1103 optionalNEStringField "src_path"
1105 pStartInstance :: Field
1107 withDoc "Whether to start instance after creation" $
1110 -- FIXME: unify/simplify with pTags, once that migrates to NonEmpty String"
1113 withDoc "Instance tags" .
1114 renameField "InstTags" .
1115 defaultField [| [] |] $
1116 simpleField "tags" [t| [NonEmptyString] |]
1118 pMultiAllocInstances :: Field
1119 pMultiAllocInstances =
1120 withDoc "List of instance create opcodes describing the instances to\
1122 renameField "InstMultiAlloc" .
1123 defaultField [| [] |] $
1124 simpleField "instances"[t| [JSValue] |]
1126 pOpportunisticLocking :: Field
1127 pOpportunisticLocking =
1128 withDoc "Whether to employ opportunistic locking for nodes, meaning\
1129 \ nodes already locked by another opcode won't be considered for\
1130 \ instance allocation (only when an iallocator is used)" $
1131 defaultFalse "opportunistic_locking"
1133 pInstanceUuid :: Field
1135 withDoc "An instance UUID (for single-instance LUs)" .
1136 optionalField $ simpleField "instance_uuid" [t| NonEmptyString |]
1138 pTempOsParams :: Field
1140 withDoc "Temporary OS parameters (currently only in reinstall, might be\
1141 \ added to install as well)" .
1142 renameField "TempOsParams" .
1143 optionalField $ simpleField "osparams" [t| JSObject JSValue |]
1145 pShutdownTimeout :: Field
1147 withDoc "How long to wait for instance to shut down" .
1148 defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
1149 simpleField "shutdown_timeout" [t| NonNegative Int |]
1151 -- | Another name for the shutdown timeout, because we like to be
1153 pShutdownTimeout' :: Field
1155 withDoc "How long to wait for instance to shut down" .
1156 renameField "InstShutdownTimeout" .
1157 defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
1158 simpleField "timeout" [t| NonNegative Int |]
1160 pIgnoreFailures :: Field
1162 withDoc "Whether to ignore failures during removal" $
1163 defaultFalse "ignore_failures"
1167 withDoc "New group or instance name" $
1168 simpleField "new_name" [t| NonEmptyString |]
1170 pIgnoreOfflineNodes :: Field
1171 pIgnoreOfflineNodes =
1172 withDoc "Whether to ignore offline nodes" $
1173 defaultFalse "ignore_offline_nodes"
1175 pTempHvParams :: Field
1177 withDoc "Temporary hypervisor parameters, hypervisor-dependent" .
1178 renameField "TempHvParams" .
1179 defaultField [| toJSObject [] |] $
1180 simpleField "hvparams" [t| JSObject JSValue |]
1182 pTempBeParams :: Field
1184 withDoc "Temporary backend parameters" .
1185 renameField "TempBeParams" .
1186 defaultField [| toJSObject [] |] $
1187 simpleField "beparams" [t| JSObject JSValue |]
1189 pNoRemember :: Field
1191 withDoc "Do not remember instance state changes" $
1192 defaultFalse "no_remember"
1194 pStartupPaused :: Field
1196 withDoc "Pause instance at startup" $
1197 defaultFalse "startup_paused"
1199 pIgnoreSecondaries :: Field
1200 pIgnoreSecondaries =
1201 withDoc "Whether to start the instance even if secondary disks are failing" $
1202 defaultFalse "ignore_secondaries"
1204 pRebootType :: Field
1206 withDoc "How to reboot the instance" $
1207 simpleField "reboot_type" [t| RebootType |]
1209 pReplaceDisksMode :: Field
1211 withDoc "Replacement mode" .
1212 renameField "ReplaceDisksMode" $ simpleField "mode" [t| ReplaceDisksMode |]
1214 pReplaceDisksList :: Field
1216 withDoc "List of disk indices" .
1217 renameField "ReplaceDisksList" .
1218 defaultField [| [] |] $
1219 simpleField "disks" [t| [DiskIndex] |]
1221 pMigrationCleanup :: Field
1223 withDoc "Whether a previously failed migration should be cleaned up" .
1224 renameField "MigrationCleanup" $ defaultFalse "cleanup"
1226 pAllowFailover :: Field
1228 withDoc "Whether we can fallback to failover if migration is not possible" $
1229 defaultFalse "allow_failover"
1231 pMoveTargetNode :: Field
1233 withDoc "Target node for instance move" .
1234 renameField "MoveTargetNode" $
1235 simpleField "target_node" [t| NonEmptyString |]
1237 pMoveTargetNodeUuid :: Field
1238 pMoveTargetNodeUuid =
1239 withDoc "Target node UUID for instance move" .
1240 renameField "MoveTargetNodeUuid" . optionalField $
1241 simpleField "target_node_uuid" [t| NonEmptyString |]
1243 pIgnoreDiskSize :: Field
1245 withDoc "Whether to ignore recorded disk size" $
1246 defaultFalse "ignore_size"
1248 pWaitForSyncFalse :: Field
1250 withDoc "Whether to wait for the disk to synchronize (defaults to false)" $
1251 defaultField [| False |] pWaitForSync
1253 pRecreateDisksInfo :: Field
1254 pRecreateDisksInfo =
1255 withDoc "Disk list for recreate disks" .
1256 renameField "RecreateDisksInfo" .
1257 defaultField [| RecreateDisksAll |] $
1258 simpleField "disks" [t| RecreateDisksInfo |]
1262 withDoc "Whether to only return configuration data without querying nodes" $
1263 defaultFalse "static"
1265 pInstParamsNicChanges :: Field
1266 pInstParamsNicChanges =
1267 withDoc "List of NIC changes" .
1268 renameField "InstNicChanges" .
1269 defaultField [| SetParamsEmpty |] $
1270 simpleField "nics" [t| SetParamsMods INicParams |]
1272 pInstParamsDiskChanges :: Field
1273 pInstParamsDiskChanges =
1274 withDoc "List of disk changes" .
1275 renameField "InstDiskChanges" .
1276 defaultField [| SetParamsEmpty |] $
1277 simpleField "disks" [t| SetParamsMods IDiskParams |]
1279 pRuntimeMem :: Field
1281 withDoc "New runtime memory" .
1282 optionalField $ simpleField "runtime_mem" [t| Positive Int |]
1284 pOptDiskTemplate :: Field
1286 withDoc "Instance disk template" .
1288 renameField "OptDiskTemplate" $
1289 simpleField "disk_template" [t| DiskTemplate |]
1291 pOsNameChange :: Field
1293 withDoc "Change the instance's OS without reinstalling the instance" $
1294 optionalNEStringField "os_name"
1298 withDoc "Disk index for e.g. grow disk" .
1299 renameField "DiskIndex " $ simpleField "disk" [t| DiskIndex |]
1301 pDiskChgAmount :: Field
1303 withDoc "Disk amount to add or grow to" .
1304 renameField "DiskChgAmount" $ simpleField "amount" [t| NonNegative Int |]
1306 pDiskChgAbsolute :: Field
1309 "Whether the amount parameter is an absolute target or a relative one" .
1310 renameField "DiskChkAbsolute" $ defaultFalse "absolute"
1312 pTargetGroups :: Field
1315 "Destination group names or UUIDs (defaults to \"all but current group\")" .
1316 optionalField $ simpleField "target_groups" [t| [NonEmptyString] |]
1318 pNodeGroupAllocPolicy :: Field
1319 pNodeGroupAllocPolicy =
1320 withDoc "Instance allocation policy" .
1322 simpleField "alloc_policy" [t| AllocPolicy |]
1324 pGroupNodeParams :: Field
1326 withDoc "Default node parameters for group" .
1327 optionalField $ simpleField "ndparams" [t| JSObject JSValue |]
1329 pExportMode :: Field
1331 withDoc "Export mode" .
1332 renameField "ExportMode" $ simpleField "mode" [t| ExportMode |]
1334 -- FIXME: Rename target_node as it changes meaning for different
1335 -- export modes (e.g. "destination")
1336 pExportTargetNode :: Field
1338 withDoc "Target node (depends on export mode)" .
1339 renameField "ExportTarget" $
1340 simpleField "target_node" [t| ExportTarget |]
1342 pExportTargetNodeUuid :: Field
1343 pExportTargetNodeUuid =
1344 withDoc "Target node UUID (if local export)" .
1345 renameField "ExportTargetNodeUuid" . optionalField $
1346 simpleField "target_node_uuid" [t| NonEmptyString |]
1348 pShutdownInstance :: Field
1350 withDoc "Whether to shutdown the instance before export" $
1351 defaultTrue "shutdown"
1353 pRemoveInstance :: Field
1355 withDoc "Whether to remove instance after export" $
1356 defaultFalse "remove_instance"
1358 pIgnoreRemoveFailures :: Field
1359 pIgnoreRemoveFailures =
1360 withDoc "Whether to ignore failures while removing instances" $
1361 defaultFalse "ignore_remove_failures"
1363 pX509KeyName :: Field
1365 withDoc "Name of X509 key (remote export only)" .
1366 optionalField $ simpleField "x509_key_name" [t| [JSValue] |]
1368 pX509DestCA :: Field
1370 withDoc "Destination X509 CA (remote export only)" $
1371 optionalNEStringField "destination_x509_ca"
1373 pTagsObject :: Field
1375 withDoc "Tag kind" $
1376 simpleField "kind" [t| TagKind |]
1380 withDoc "Name of object" .
1381 renameField "TagsGetName" .
1382 optionalField $ simpleField "name" [t| String |]
1386 withDoc "List of tag names" $
1387 simpleField "tags" [t| [String] |]
1389 -- FIXME: this should be compiled at load time?
1390 pTagSearchPattern :: Field
1392 withDoc "Search pattern (regular expression)" .
1393 renameField "TagSearchPattern" $
1394 simpleField "pattern" [t| NonEmptyString |]
1396 pDelayDuration :: Field
1398 withDoc "Duration parameter for 'OpTestDelay'" .
1399 renameField "DelayDuration" $
1400 simpleField "duration" [t| Double |]
1402 pDelayOnMaster :: Field
1404 withDoc "on_master field for 'OpTestDelay'" .
1405 renameField "DelayOnMaster" $
1406 defaultTrue "on_master"
1408 pDelayOnNodes :: Field
1410 withDoc "on_nodes field for 'OpTestDelay'" .
1411 renameField "DelayOnNodes" .
1412 defaultField [| [] |] $
1413 simpleField "on_nodes" [t| [NonEmptyString] |]
1415 pDelayOnNodeUuids :: Field
1417 withDoc "on_node_uuids field for 'OpTestDelay'" .
1418 renameField "DelayOnNodeUuids" . optionalField $
1419 simpleField "on_node_uuids" [t| [NonEmptyString] |]
1421 pDelayRepeat :: Field
1423 withDoc "Repeat parameter for OpTestDelay" .
1424 renameField "DelayRepeat" .
1425 defaultField [| forceNonNeg (0::Int) |] $
1426 simpleField "repeat" [t| NonNegative Int |]
1428 pIAllocatorDirection :: Field
1429 pIAllocatorDirection =
1430 withDoc "IAllocator test direction" .
1431 renameField "IAllocatorDirection" $
1432 simpleField "direction" [t| IAllocatorTestDir |]
1434 pIAllocatorMode :: Field
1436 withDoc "IAllocator test mode" .
1437 renameField "IAllocatorMode" $
1438 simpleField "mode" [t| IAllocatorMode |]
1440 pIAllocatorReqName :: Field
1441 pIAllocatorReqName =
1442 withDoc "IAllocator target name (new instance, node to evac, etc.)" .
1443 renameField "IAllocatorReqName" $ simpleField "name" [t| NonEmptyString |]
1445 pIAllocatorNics :: Field
1447 withDoc "Custom OpTestIAllocator nics" .
1448 renameField "IAllocatorNics" .
1449 optionalField $ simpleField "nics" [t| [INicParams] |]
1451 pIAllocatorDisks :: Field
1453 withDoc "Custom OpTestAllocator disks" .
1454 renameField "IAllocatorDisks" .
1455 optionalField $ simpleField "disks" [t| [JSValue] |]
1457 pIAllocatorMemory :: Field
1459 withDoc "IAllocator memory field" .
1460 renameField "IAllocatorMem" .
1462 simpleField "memory" [t| NonNegative Int |]
1464 pIAllocatorVCpus :: Field
1466 withDoc "IAllocator vcpus field" .
1467 renameField "IAllocatorVCpus" .
1469 simpleField "vcpus" [t| NonNegative Int |]
1471 pIAllocatorOs :: Field
1473 withDoc "IAllocator os field" .
1474 renameField "IAllocatorOs" $ optionalNEStringField "os"
1476 pIAllocatorInstances :: Field
1477 pIAllocatorInstances =
1478 withDoc "IAllocator instances field" .
1479 renameField "IAllocatorInstances " .
1481 simpleField "instances" [t| [NonEmptyString] |]
1483 pIAllocatorEvacMode :: Field
1484 pIAllocatorEvacMode =
1485 withDoc "IAllocator evac mode" .
1486 renameField "IAllocatorEvacMode" .
1488 simpleField "evac_mode" [t| EvacMode |]
1490 pIAllocatorSpindleUse :: Field
1491 pIAllocatorSpindleUse =
1492 withDoc "IAllocator spindle use" .
1493 renameField "IAllocatorSpindleUse" .
1494 defaultField [| forceNonNeg (1::Int) |] $
1495 simpleField "spindle_use" [t| NonNegative Int |]
1497 pIAllocatorCount :: Field
1499 withDoc "IAllocator count field" .
1500 renameField "IAllocatorCount" .
1501 defaultField [| forceNonNeg (1::Int) |] $
1502 simpleField "count" [t| NonNegative Int |]
1504 pJQueueNotifyWaitLock :: Field
1505 pJQueueNotifyWaitLock =
1506 withDoc "'OpTestJqueue' notify_waitlock" $
1507 defaultFalse "notify_waitlock"
1509 pJQueueNotifyExec :: Field
1511 withDoc "'OpTestJQueue' notify_exec" $
1512 defaultFalse "notify_exec"
1514 pJQueueLogMessages :: Field
1515 pJQueueLogMessages =
1516 withDoc "'OpTestJQueue' log_messages" .
1517 defaultField [| [] |] $ simpleField "log_messages" [t| [String] |]
1519 pJQueueFail :: Field
1521 withDoc "'OpTestJQueue' fail attribute" .
1522 renameField "JQueueFail" $ defaultFalse "fail"
1524 pTestDummyResult :: Field
1526 withDoc "'OpTestDummy' result field" .
1527 renameField "TestDummyResult" $ simpleField "result" [t| JSValue |]
1529 pTestDummyMessages :: Field
1530 pTestDummyMessages =
1531 withDoc "'OpTestDummy' messages field" .
1532 renameField "TestDummyMessages" $
1533 simpleField "messages" [t| JSValue |]
1535 pTestDummyFail :: Field
1537 withDoc "'OpTestDummy' fail field" .
1538 renameField "TestDummyFail" $ simpleField "fail" [t| JSValue |]
1540 pTestDummySubmitJobs :: Field
1541 pTestDummySubmitJobs =
1542 withDoc "'OpTestDummy' submit_jobs field" .
1543 renameField "TestDummySubmitJobs" $
1544 simpleField "submit_jobs" [t| JSValue |]
1546 pNetworkName :: Field
1548 withDoc "Network name" $
1549 simpleField "network_name" [t| NonEmptyString |]
1551 pNetworkAddress4 :: Field
1553 withDoc "Network address (IPv4 subnet)" .
1554 renameField "NetworkAddress4" $
1555 simpleField "network" [t| IPv4Network |]
1557 pNetworkGateway4 :: Field
1559 withDoc "Network gateway (IPv4 address)" .
1560 renameField "NetworkGateway4" .
1561 optionalField $ simpleField "gateway" [t| IPv4Address |]
1563 pNetworkAddress6 :: Field
1565 withDoc "Network address (IPv6 subnet)" .
1566 renameField "NetworkAddress6" .
1567 optionalField $ simpleField "network6" [t| IPv6Network |]
1569 pNetworkGateway6 :: Field
1571 withDoc "Network gateway (IPv6 address)" .
1572 renameField "NetworkGateway6" .
1573 optionalField $ simpleField "gateway6" [t| IPv6Address |]
1575 pNetworkMacPrefix :: Field
1577 withDoc "Network specific mac prefix (that overrides the cluster one)" .
1578 renameField "NetMacPrefix" $
1579 optionalNEStringField "mac_prefix"
1581 pNetworkAddRsvdIps :: Field
1582 pNetworkAddRsvdIps =
1583 withDoc "Which IP addresses to reserve" .
1584 renameField "NetworkAddRsvdIps" .
1586 simpleField "add_reserved_ips" [t| [IPv4Address] |]
1588 pNetworkRemoveRsvdIps :: Field
1589 pNetworkRemoveRsvdIps =
1590 withDoc "Which external IP addresses to release" .
1591 renameField "NetworkRemoveRsvdIps" .
1593 simpleField "remove_reserved_ips" [t| [IPv4Address] |]
1595 pNetworkMode :: Field
1597 withDoc "Network mode when connecting to a group" $
1598 simpleField "network_mode" [t| NICMode |]
1600 pNetworkLink :: Field
1602 withDoc "Network link when connecting to a group" $
1603 simpleField "network_link" [t| NonEmptyString |]