Commit a5450d2a authored by Jose A. Lopes's avatar Jose A. Lopes
Browse files

Hs2Py constants: add 'ReplaceDisksMode' related constants



Add constants related to the Haskell type 'ReplaceDisksMode'.  The
data type declaration for 'ReplaceDisksMode' is also moved from
'Ganeti.OpParams' to 'Ganeti.Types' because it used to be used only by
the opcodes and now it is also needed for the constants.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent c87997d2
......@@ -525,17 +525,11 @@ DISK_USERSPACE = _constants.DISK_USERSPACE
DISK_KERNELSPACE = _constants.DISK_KERNELSPACE
DISK_VALID_ACCESS_MODES = _constants.DISK_VALID_ACCESS_MODES
# disk replacement mode
REPLACE_DISK_PRI = "replace_on_primary" # replace disks on primary
REPLACE_DISK_SEC = "replace_on_secondary" # replace disks on secondary
REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node
REPLACE_DISK_AUTO = "replace_auto"
REPLACE_MODES = compat.UniqueFrozenset([
REPLACE_DISK_PRI,
REPLACE_DISK_SEC,
REPLACE_DISK_CHG,
REPLACE_DISK_AUTO,
])
REPLACE_DISK_PRI = _constants.REPLACE_DISK_PRI
REPLACE_DISK_SEC = _constants.REPLACE_DISK_SEC
REPLACE_DISK_CHG = _constants.REPLACE_DISK_CHG
REPLACE_DISK_AUTO = _constants.REPLACE_DISK_AUTO
REPLACE_MODES = _constants.REPLACE_MODES
# Instance export mode
EXPORT_MODE_LOCAL = _constants.EXPORT_MODE_LOCAL
......
......@@ -510,6 +510,24 @@ diskRdwr = Types.diskModeToRaw DiskRdWr
diskAccessSet :: FrozenSet String
diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..]
-- * Disk replacement mode
replaceDiskAuto :: String
replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto
replaceDiskChg :: String
replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary
replaceDiskPri :: String
replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary
replaceDiskSec :: String
replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary
replaceModes :: FrozenSet String
replaceModes =
ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..]
-- * Instance export mode
exportModeLocal :: String
......
......@@ -301,15 +301,6 @@ forceNonNeg i = case mkNonNegative i of
-- ** Disks
-- | Replace disks type.
$(declareSADT "ReplaceDisksMode"
[ ("ReplaceOnPrimary", 'C.replaceDiskPri)
, ("ReplaceOnSecondary", 'C.replaceDiskSec)
, ("ReplaceNewSecondary", 'C.replaceDiskChg)
, ("ReplaceAuto", 'C.replaceDiskAuto)
])
$(makeJSONInstance ''ReplaceDisksMode)
-- | Disk index type (embedding constraints on the index value via a
-- smart constructor).
newtype DiskIndex = DiskIndex { unDiskIndex :: Int }
......
......@@ -143,6 +143,8 @@ module Ganeti.Types
, storageFieldToRaw
, DiskAccessMode(..)
, diskAccessModeToRaw
, ReplaceDisksMode(..)
, replaceDisksModeToRaw
) where
import Control.Monad (liftM)
......@@ -779,3 +781,15 @@ $(THH.declareLADT ''String "DiskAccessMode"
, ( "DiskKernelspace", "kernelspace")
])
$(THH.makeJSONInstance ''DiskAccessMode)
-- | Replace disks type.
$(THH.declareLADT ''String "ReplaceDisksMode"
[ -- Replace disks on primary
("ReplaceOnPrimary", "replace_on_primary")
-- Replace disks on secondary
, ("ReplaceOnSecondary", "replace_on_secondary")
-- Change secondary node
, ("ReplaceNewSecondary", "replace_new_secondary")
, ("ReplaceAuto", "replace_auto")
])
$(THH.makeJSONInstance ''ReplaceDisksMode)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment