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

Hs2Py constants: add local disk status



Add constants related to local disk status to the Haskell to Python
constant generation. A new Haskell type 'LocalDiskStatus' is added
similarly to the constants that have been added previously in other
Hs2Py patches.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent 8397ffde
......@@ -353,6 +353,10 @@ MODIFIABLE_STORAGE_FIELDS = {
ST_LVM_PV: frozenset([SF_ALLOCATABLE]),
}
LDS_OKAY = _constants.LDS_OKAY
LDS_UNKNOWN = _constants.LDS_UNKNOWN
LDS_FAULTY = _constants.LDS_FAULTY
LDS_NAMES = _constants.LDS_NAMES
VALID_STORAGE_OPERATIONS = {
ST_LVM_VG: frozenset([SO_FIX_CONSISTENCY]),
}
......@@ -366,18 +370,6 @@ VF_PHYS = "phys"
VF_SIZE = "size"
VF_VG = "vg"
# Local disk status
# Note: Code depends on LDS_OKAY < LDS_UNKNOWN < LDS_FAULTY
(LDS_OKAY,
LDS_UNKNOWN,
LDS_FAULTY) = range(1, 4)
LDS_NAMES = {
LDS_OKAY: "ok",
LDS_UNKNOWN: "unknown",
LDS_FAULTY: "faulty",
}
# disk template types
DT_BLOCK = _constants.DT_BLOCK
DT_DISKLESS = _constants.DT_DISKLESS
......@@ -514,8 +506,7 @@ RBD_CMD = "rbd"
FD_BLKTAP = _constants.FD_BLKTAP
FD_LOOP = _constants.FD_LOOP
# the set of drbd-like disk types
LDS_DRBD = compat.UniqueFrozenset([DT_DRBD8])
LDS_DRBD = _constants.LDS_DRBD
# disk access mode
DISK_RDONLY = _constants.DISK_RDONLY
......
......@@ -452,6 +452,22 @@ sfSize = Types.storageFieldToRaw SFSize
sfUsed :: String
sfUsed = Types.storageFieldToRaw SFUsed
-- * Local disk status
ldsFaulty :: Int
ldsFaulty = Types.localDiskStatusToRaw DiskStatusFaulty
ldsOkay :: Int
ldsOkay = Types.localDiskStatusToRaw DiskStatusOk
ldsUnknown :: Int
ldsUnknown = Types.localDiskStatusToRaw DiskStatusUnknown
ldsNames :: Map Int String
ldsNames =
Map.fromList [ (Types.localDiskStatusToRaw ds,
localDiskStatusName ds) | ds <- [minBound..] ]
-- * Disk template types
dtDiskless :: String
......@@ -503,6 +519,10 @@ fdBlktap = Types.fileDriverToRaw FileBlktap
fdLoop :: String
fdLoop = Types.fileDriverToRaw FileLoop
-- | The set of drbd-like disk types
ldsDrbd :: FrozenSet String
ldsDrbd = ConstantUtils.mkSet [Types.diskTemplateToRaw DTDrbd8]
-- * Disk access mode
diskRdonly :: String
......
......@@ -143,6 +143,10 @@ module Ganeti.Types
, storageFieldToRaw
, DiskAccessMode(..)
, diskAccessModeToRaw
, LocalDiskStatus(..)
, localDiskStatusFromRaw
, localDiskStatusToRaw
, localDiskStatusName
, ReplaceDisksMode(..)
, replaceDisksModeToRaw
, RpcTimeout(..)
......@@ -398,6 +402,8 @@ $(THH.declareLADT ''String "DdmSimple"
$(THH.makeJSONInstance ''DdmSimple)
-- | Dynamic device modification, all operations version.
--
-- TODO: DDM_SWAP, DDM_MOVE?
$(THH.declareLADT ''String "DdmFull"
[ ("DdmFullAdd", "add")
, ("DdmFullRemove", "remove")
......@@ -724,6 +730,9 @@ $(THH.declareLADT ''String "VType"
])
$(THH.makeJSONInstance ''VType)
instance THH.PyValue VType where
showValue = THH.showValue . vTypeToRaw
-- * Node role type
$(THH.declareLADT ''String "NodeRole"
......@@ -785,6 +794,21 @@ $(THH.declareLADT ''String "DiskAccessMode"
])
$(THH.makeJSONInstance ''DiskAccessMode)
-- | Local disk status
--
-- Python code depends on:
-- DiskStatusOk < DiskStatusUnknown < DiskStatusFaulty
$(THH.declareILADT "LocalDiskStatus"
[ ("DiskStatusFaulty", 3)
, ("DiskStatusOk", 1)
, ("DiskStatusUnknown", 2)
])
localDiskStatusName :: LocalDiskStatus -> String
localDiskStatusName DiskStatusFaulty = "faulty"
localDiskStatusName DiskStatusOk = "ok"
localDiskStatusName DiskStatusUnknown = "unknown"
-- | Replace disks type.
$(THH.declareLADT ''String "ReplaceDisksMode"
[ -- Replace disks on primary
......
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