LGTM, thanks.
On Mon, Oct 7, 2013 at 4:37 PM, Jose A. Lopes <[email protected]> wrote: > Add several groups of storage related constants to the Haskell to Python > constant generation. > > Signed-off-by: Jose A. Lopes <[email protected]> > --- > lib/constants.py | 58 ++++++++++-------------------------------- > src/Ganeti/HsConstants.hs | 65 > +++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 78 insertions(+), 45 deletions(-) > > diff --git a/lib/constants.py b/lib/constants.py > index 0087044..6b54f88 100644 > --- a/lib/constants.py > +++ b/lib/constants.py > @@ -263,10 +263,7 @@ ST_LVM_PV = _constants.ST_LVM_PV > ST_LVM_VG = _constants.ST_LVM_VG > ST_RADOS = _constants.ST_RADOS > STORAGE_TYPES = _constants.STORAGE_TYPES > - > -# the set of storage types for which storage reporting is available > -# FIXME: Remove this, once storage reporting is available for all types. > -STS_REPORT = compat.UniqueFrozenset([ST_FILE, ST_LVM_PV, ST_LVM_VG]) > +STS_REPORT = _constants.STS_REPORT > > # Storage fields > # first two are valid in LU context only, not passed to backend > @@ -278,41 +275,24 @@ SF_SIZE = _constants.SF_SIZE > SF_FREE = _constants.SF_FREE > SF_USED = _constants.SF_USED > SF_ALLOCATABLE = _constants.SF_ALLOCATABLE > +VALID_STORAGE_FIELDS = _constants.VALID_STORAGE_FIELDS > +MODIFIABLE_STORAGE_FIELDS = _constants.MODIFIABLE_STORAGE_FIELDS > > -# Storage operations > -SO_FIX_CONSISTENCY = "fix-consistency" > - > -# Available fields per storage type > -VALID_STORAGE_FIELDS = compat.UniqueFrozenset([ > - SF_NODE, > - SF_NAME, > - SF_TYPE, > - SF_SIZE, > - SF_USED, > - SF_FREE, > - SF_ALLOCATABLE, > - ]) > +SO_FIX_CONSISTENCY = _constants.SO_FIX_CONSISTENCY > +VALID_STORAGE_OPERATIONS = _constants.VALID_STORAGE_OPERATIONS > > -MODIFIABLE_STORAGE_FIELDS = { > - ST_LVM_PV: frozenset([SF_ALLOCATABLE]), > - } > +VF_DEV = _constants.VF_DEV > +VF_INSTANCE = _constants.VF_INSTANCE > +VF_NAME = _constants.VF_NAME > +VF_NODE = _constants.VF_NODE > +VF_PHYS = _constants.VF_PHYS > +VF_SIZE = _constants.VF_SIZE > +VF_VG = _constants.VF_VG > > 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]), > - } > - > -# Volume fields > -VF_DEV = "dev" > -VF_INSTANCE = "instance" > -VF_NAME = "name" > -VF_NODE = "node" > -VF_PHYS = "phys" > -VF_SIZE = "size" > -VF_VG = "vg" > > # disk template types > DT_BLOCK = _constants.DT_BLOCK > @@ -327,19 +307,7 @@ DISK_TEMPLATE_PREFERENCE = > _constants.DISK_TEMPLATE_PREFERENCE > DISK_TEMPLATES = _constants.DISK_TEMPLATES > DEFAULT_ENABLED_DISK_TEMPLATES = _constants.DEFAULT_ENABLED_DISK_TEMPLATES > > -# mapping of disk templates to storage types > -MAP_DISK_TEMPLATE_STORAGE_TYPE = { > - DT_BLOCK: ST_BLOCK, > - DT_DISKLESS: ST_DISKLESS, > - DT_DRBD8: ST_LVM_VG, > - DT_EXT: ST_EXT, > - DT_FILE: ST_FILE, > - DT_PLAIN: ST_LVM_VG, > - DT_RBD: ST_RADOS, > - DT_SHARED_FILE: ST_FILE, > - } > - > - > +MAP_DISK_TEMPLATE_STORAGE_TYPE = _constants.MAP_DISK_TEMPLATE_STORAGE_TYPE > # drbd constants > DRBD_HMAC_ALG = "md5" > DRBD_DEFAULT_NET_PROTOCOL = "C" > diff --git a/src/Ganeti/HsConstants.hs b/src/Ganeti/HsConstants.hs > index 4c20267..31de298 100644 > --- a/src/Ganeti/HsConstants.hs > +++ b/src/Ganeti/HsConstants.hs > @@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, > Boston, MA > -} > module Ganeti.HsConstants where > > +import Control.Arrow ((***)) > import Data.List ((\\)) > import Data.Map (Map) > import qualified Data.Map as Map (fromList, keys, insert) > @@ -639,6 +640,13 @@ stRados = Types.storageTypeToRaw StorageRados > storageTypes :: FrozenSet String > storageTypes = ConstantUtils.mkSet $ map Types.storageTypeToRaw > [minBound..] > > +-- | The set of storage types for which storage reporting is available > +-- > +-- FIXME: Remove this, once storage reporting is available for all > +-- types. > +stsReport :: FrozenSet String > +stsReport = ConstantUtils.mkSet [stFile, stLvmPv, stLvmVg] > + > -- * Storage fields > -- ** First two are valid in LU context only, not passed to backend > > @@ -665,6 +673,49 @@ sfSize = Types.storageFieldToRaw SFSize > sfUsed :: String > sfUsed = Types.storageFieldToRaw SFUsed > > +validStorageFields :: FrozenSet String > +validStorageFields = > + ConstantUtils.mkSet $ map Types.storageFieldToRaw [minBound..] ++ > + [sfNode, sfType] > + > +modifiableStorageFields :: Map String (FrozenSet String) > +modifiableStorageFields = > + Map.fromList [(Types.storageTypeToRaw StorageLvmPv, > + ConstantUtils.mkSet [sfAllocatable])] > + > +-- * Storage operations > + > +soFixConsistency :: String > +soFixConsistency = "fix-consistency" > + > +validStorageOperations :: Map String (FrozenSet String) > +validStorageOperations = > + Map.fromList [(Types.storageTypeToRaw StorageLvmVg, > + ConstantUtils.mkSet [soFixConsistency])] > + > +-- * Volume fields > + > +vfDev :: String > +vfDev = "dev" > + > +vfInstance :: String > +vfInstance = "instance" > + > +vfName :: String > +vfName = "name" > + > +vfNode :: String > +vfNode = "node" > + > +vfPhys :: String > +vfPhys = "phys" > + > +vfSize :: String > +vfSize = "size" > + > +vfVg :: String > +vfVg = "vg" > + > -- * Local disk status > > ldsFaulty :: Int > @@ -724,6 +775,20 @@ diskTemplates = ConstantUtils.mkSet $ map > Types.diskTemplateToRaw [minBound..] > defaultEnabledDiskTemplates :: [String] > defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8, > DTPlain] > > +-- | Mapping of disk templates to storage types > +mapDiskTemplateStorageType :: Map String String > +mapDiskTemplateStorageType = > + Map.fromList $ > + map (Types.diskTemplateToRaw *** Types.storageTypeToRaw) > + [(DTBlock, StorageBlock), > + (DTDrbd8, StorageLvmVg), > + (DTExt, StorageExt), > + (DTSharedFile, StorageFile), > + (DTFile, StorageFile), > + (DTDiskless, StorageDiskless), > + (DTPlain, StorageLvmVg), > + (DTRbd, StorageRados)] > + > -- | The set of network-mirrored disk templates > dtsIntMirror :: FrozenSet String > dtsIntMirror = ConstantUtils.mkSet [dtDrbd8] > -- > 1.8.4 > > -- Thomas Thrainer | Software Engineer | [email protected] | Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
