Merge 'EvacNode' and 'NodeEvacMode'
[ganeti-local] / src / Ganeti / OpParams.hs
index 158b317..ed06a02 100644 (file)
@@ -52,6 +52,7 @@ module Ganeti.OpParams
   , pTagsName
   , pOutputFields
   , pShutdownTimeout
+  , pShutdownTimeout'
   , pShutdownInstance
   , pForce
   , pIgnoreOfflineNodes
@@ -100,6 +101,7 @@ module Ganeti.OpParams
   , pFileDriver
   , pFileStorageDir
   , pGlobalFileStorageDir
+  , pGlobalSharedFileStorageDir
   , pVgName
   , pEnabledHypervisors
   , pHypervisor
@@ -250,8 +252,6 @@ module Ganeti.OpParams
   ) where
 
 import Control.Monad (liftM)
-import Data.Set (Set)
-import qualified Data.Set as Set
 import Text.JSON (JSON, JSValue(..), JSObject (..), readJSON, showJSON,
                   fromJSString, toJSObject)
 import qualified Text.JSON
@@ -264,7 +264,6 @@ import Ganeti.JSON
 import Ganeti.Types
 import qualified Ganeti.Query.Language as Qlang
 
-
 -- * Helper functions and types
 
 -- | Build a boolean field.
@@ -446,7 +445,6 @@ instance JSON ExportTarget where
   showJSON (ExportTargetRemote l) = showJSON l
   readJSON = readExportTarget
 
-
 -- * Common opcode parameters
 
 pDryRun :: Field
@@ -481,7 +479,6 @@ pReason =
   withDoc "Reason trail field" $
   simpleField C.opcodeReason [t| ReasonTrail |]
 
-
 -- * Parameters
 
 pDebugSimulateErrors :: Field
@@ -497,14 +494,14 @@ pErrorCodes =
 pSkipChecks :: Field
 pSkipChecks = 
   withDoc "Which checks to skip" .
-  defaultField [| Set.empty |] $
-  simpleField "skip_checks" [t| Set VerifyOptionalChecks |]
+  defaultField [| emptyListSet |] $
+  simpleField "skip_checks" [t| ListSet VerifyOptionalChecks |]
 
 pIgnoreErrors :: Field
 pIgnoreErrors =
   withDoc "List of error codes that should be treated as warnings" .
-  defaultField [| Set.empty |] $
-  simpleField "ignore_errors" [t| Set CVErrorCode |]
+  defaultField [| emptyListSet |] $
+  simpleField "ignore_errors" [t| ListSet CVErrorCode |]
 
 pVerbose :: Field
 pVerbose =
@@ -557,6 +554,10 @@ pDiskState =
 pGlobalFileStorageDir :: Field
 pGlobalFileStorageDir = optionalNEStringField "file_storage_dir"
 
+-- | Global directory for storing shared-file-backed disks.
+pGlobalSharedFileStorageDir :: Field
+pGlobalSharedFileStorageDir = optionalNEStringField "shared_file_storage_dir"
+
 -- | Volume group name.
 pVgName :: Field
 pVgName =
@@ -567,7 +568,7 @@ pEnabledHypervisors :: Field
 pEnabledHypervisors =
   withDoc "List of enabled hypervisors" .
   optionalField $
-  simpleField "enabled_hypervisors" [t| Hypervisor |]
+  simpleField "enabled_hypervisors" [t| [Hypervisor] |]
 
 pClusterHvParams :: Field
 pClusterHvParams =
@@ -611,19 +612,19 @@ pUidPool :: Field
 pUidPool =
   withDoc "Set UID pool, must be list of lists describing UID ranges\
           \ (two items, start and end inclusive)" .
-  optionalField $ simpleField "uid_pool" [t| [[(Int, Int)]] |]
+  optionalField $ simpleField "uid_pool" [t| [(Int, Int)] |]
 
 pAddUids :: Field
 pAddUids =
   withDoc "Extend UID pool, must be list of lists describing UID\
           \ ranges (two items, start and end inclusive)" .
-  optionalField $ simpleField "add_uids" [t| [[(Int, Int)]] |]
+  optionalField $ simpleField "add_uids" [t| [(Int, Int)] |]
 
 pRemoveUids :: Field
 pRemoveUids =
   withDoc "Shrink UID pool, must be list of lists describing UID\
           \ ranges (two items, start and end inclusive) to be removed" .
-  optionalField $ simpleField "remove_uids" [t| [[(Int, Int)]] |]
+  optionalField $ simpleField "remove_uids" [t| [(Int, Int)] |]
 
 pMaintainNodeHealth :: Field
 pMaintainNodeHealth =
@@ -699,7 +700,7 @@ pEnabledDiskTemplates :: Field
 pEnabledDiskTemplates =
   withDoc "List of enabled disk templates" .
   optionalField $
-  simpleField "enabled_disk_templates" [t| DiskTemplate |]
+  simpleField "enabled_disk_templates" [t| [DiskTemplate] |]
 
 pQueryWhat :: Field
 pQueryWhat =
@@ -791,7 +792,8 @@ pNodeUuid =
 
 pPrimaryIp :: Field
 pPrimaryIp =
-  withDoc "Primary IP address" $
+  withDoc "Primary IP address" .
+  optionalField $
   simpleField "primary_ip" [t| NonEmptyString |]
 
 pSecondaryIp :: Field
@@ -938,7 +940,7 @@ pRemoteNodeUuid =
 pEvacMode :: Field
 pEvacMode =
   withDoc "Node evacuation mode" .
-  renameField "EvacMode" $ simpleField "mode" [t| NodeEvacMode |]
+  renameField "EvacMode" $ simpleField "mode" [t| EvacMode |]
 
 pInstanceName :: Field
 pInstanceName =
@@ -974,7 +976,7 @@ pInstDisks =
 
 pDiskTemplate :: Field
 pDiskTemplate =
-  withDoc "List of instance disks" $
+  withDoc "Disk template" $
   simpleField "disk_template" [t| DiskTemplate |]
 
 pFileDriver :: Field
@@ -1146,6 +1148,15 @@ pShutdownTimeout =
   defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
   simpleField "shutdown_timeout" [t| NonNegative Int |]
 
+-- | Another name for the shutdown timeout, because we like to be
+-- inconsistent.
+pShutdownTimeout' :: Field
+pShutdownTimeout' =
+  withDoc "How long to wait for instance to shut down" .
+  renameField "InstShutdownTimeout" .
+  defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
+  simpleField "timeout" [t| NonNegative Int |]
+
 pIgnoreFailures :: Field
 pIgnoreFailures =
   withDoc "Whether to ignore failures during removal" $
@@ -1368,7 +1379,7 @@ pTagsName :: Field
 pTagsName =
   withDoc "Name of object" .
   renameField "TagsGetName" .
-  optionalField $ simpleField "name" [t| NonEmptyString |]
+  optionalField $ simpleField "name" [t| String |]
 
 pTagsList :: Field
 pTagsList =
@@ -1474,7 +1485,7 @@ pIAllocatorEvacMode =
   withDoc "IAllocator evac mode" .
   renameField "IAllocatorEvacMode" .
   optionalField $
-  simpleField "evac_mode" [t| NodeEvacMode |]
+  simpleField "evac_mode" [t| EvacMode |]
 
 pIAllocatorSpindleUse :: Field
 pIAllocatorSpindleUse =