LGTM, thanks.

On Mon, Oct 7, 2013 at 4:37 PM, Jose A. Lopes <[email protected]> wrote:

> Add network mirrored disk template constants to the Haskell to Python
> constant generation.
>
> Signed-off-by: Jose A. Lopes <[email protected]>
> ---
>  lib/constants.py            | 88
> +++++++--------------------------------------
>  src/Ganeti/ConstantUtils.hs |  5 ++-
>  src/Ganeti/HsConstants.hs   | 65 +++++++++++++++++++++++++++++++++
>  3 files changed, 81 insertions(+), 77 deletions(-)
>
> diff --git a/lib/constants.py b/lib/constants.py
> index ba8d4bb..24c52f4 100644
> --- a/lib/constants.py
> +++ b/lib/constants.py
> @@ -392,82 +392,6 @@ MAP_DISK_TEMPLATE_STORAGE_TYPE = {
>    DT_SHARED_FILE: ST_FILE,
>    }
>
> -# the set of network-mirrored disk templates
> -DTS_INT_MIRROR = compat.UniqueFrozenset([DT_DRBD8])
> -
> -# the set of externally-mirrored disk templates (e.g. SAN, NAS)
> -DTS_EXT_MIRROR = compat.UniqueFrozenset([
> -  DT_DISKLESS, # 'trivially' externally mirrored
> -  DT_SHARED_FILE,
> -  DT_BLOCK,
> -  DT_RBD,
> -  DT_EXT,
> -  ])
> -
> -# the set of non-lvm-based disk templates
> -DTS_NOT_LVM = compat.UniqueFrozenset([
> -  DT_DISKLESS,
> -  DT_FILE,
> -  DT_SHARED_FILE,
> -  DT_BLOCK,
> -  DT_RBD,
> -  DT_EXT,
> -  ])
> -
> -# the set of disk templates which can be grown
> -DTS_GROWABLE = compat.UniqueFrozenset([
> -  DT_PLAIN,
> -  DT_DRBD8,
> -  DT_FILE,
> -  DT_SHARED_FILE,
> -  DT_RBD,
> -  DT_EXT,
> -  ])
> -
> -# the set of disk templates that allow adoption
> -DTS_MAY_ADOPT = compat.UniqueFrozenset([
> -  DT_PLAIN,
> -  DT_BLOCK,
> -  ])
> -
> -# the set of disk templates that *must* use adoption
> -DTS_MUST_ADOPT = compat.UniqueFrozenset([DT_BLOCK])
> -
> -# the set of disk templates that allow migrations
> -DTS_MIRRORED = frozenset.union(DTS_INT_MIRROR, DTS_EXT_MIRROR)
> -
> -# the set of file based disk templates
> -DTS_FILEBASED = compat.UniqueFrozenset([
> -  DT_FILE,
> -  DT_SHARED_FILE,
> -  ])
> -
> -# the set of disk templates that can be moved by copying
> -# Note: a requirement is that they're not accessed externally or shared
> between
> -# nodes; in particular, sharedfile is not suitable.
> -DTS_COPYABLE = compat.UniqueFrozenset([
> -  DT_FILE,
> -  DT_PLAIN,
> -  ])
> -
> -# the set of disk templates that are supported by exclusive_storage
> -DTS_EXCL_STORAGE = compat.UniqueFrozenset([DT_PLAIN])
> -
> -# templates for which we don't perform checks on free space
> -DTS_NO_FREE_SPACE_CHECK = compat.UniqueFrozenset([
> -  DT_FILE,
> -  DT_SHARED_FILE,
> -  DT_RBD,
> -  DT_EXT,
> -  ])
> -
> -DTS_BLOCK = compat.UniqueFrozenset([
> -  DT_PLAIN,
> -  DT_DRBD8,
> -  DT_BLOCK,
> -  DT_RBD,
> -  DT_EXT,
> -  ])
>
>  # drbd constants
>  DRBD_HMAC_ALG = "md5"
> @@ -478,6 +402,18 @@ DRBD_STATUS_FILE = "/proc/drbd"
>  #: Size of DRBD meta block device
>  DRBD_META_SIZE = 128
>
> +DTS_INT_MIRROR = _constants.DTS_INT_MIRROR
> +DTS_EXT_MIRROR = _constants.DTS_EXT_MIRROR
> +DTS_NOT_LVM = _constants.DTS_NOT_LVM
> +DTS_GROWABLE = _constants.DTS_GROWABLE
> +DTS_MAY_ADOPT = _constants.DTS_MAY_ADOPT
> +DTS_MUST_ADOPT = _constants.DTS_MUST_ADOPT
> +DTS_MIRRORED = _constants.DTS_MIRRORED
> +DTS_FILEBASED = _constants.DTS_FILEBASED
> +DTS_COPYABLE = _constants.DTS_COPYABLE
> +DTS_EXCL_STORAGE = _constants.DTS_EXCL_STORAGE
> +DTS_NO_FREE_SPACE_CHECK = _constants.DTS_NO_FREE_SPACE_CHECK
> +DTS_BLOCK = _constants.DTS_BLOCK
>  # drbd barrier types
>  DRBD_B_NONE = "n"
>  DRBD_B_DISK_BARRIERS = "b"
> diff --git a/src/Ganeti/ConstantUtils.hs b/src/Ganeti/ConstantUtils.hs
> index 0c3dd0c..2eb8518 100644
> --- a/src/Ganeti/ConstantUtils.hs
> +++ b/src/Ganeti/ConstantUtils.hs
> @@ -30,7 +30,7 @@ module Ganeti.ConstantUtils where
>
>  import Data.Char (ord)
>  import Data.Set (Set)
> -import qualified Data.Set as Set (fromList, toList)
> +import qualified Data.Set as Set (fromList, toList, union)
>
>  import Ganeti.THH (PyValue(..))
>  import Ganeti.PyValueInstances ()
> @@ -61,6 +61,9 @@ instance PyValue a => PyValue (FrozenSet a) where
>  mkSet :: Ord a => [a] -> FrozenSet a
>  mkSet = FrozenSet . Set.fromList
>
> +union :: Ord a => FrozenSet a -> FrozenSet a -> FrozenSet a
> +union x y = FrozenSet (unFrozenSet x `Set.union` unFrozenSet y)
> +
>  -- | 'Protocol' represents the protocols used by the daemons
>  data Protocol = Tcp | Udp
>    deriving (Show)
> diff --git a/src/Ganeti/HsConstants.hs b/src/Ganeti/HsConstants.hs
> index 4bd9139..bd8e066 100644
> --- a/src/Ganeti/HsConstants.hs
> +++ b/src/Ganeti/HsConstants.hs
> @@ -530,6 +530,71 @@ diskTemplates = ConstantUtils.mkSet $ map
> Types.diskTemplateToRaw [minBound..]
>  defaultEnabledDiskTemplates :: [String]
>  defaultEnabledDiskTemplates = map Types.diskTemplateToRaw [DTDrbd8,
> DTPlain]
>
> +-- | The set of network-mirrored disk templates
> +dtsIntMirror :: FrozenSet String
> +dtsIntMirror = ConstantUtils.mkSet [dtDrbd8]
> +
> +-- | 'DTDiskless' is 'trivially' externally mirrored
> +dtsExtMirror :: FrozenSet String
> +dtsExtMirror =
> +  ConstantUtils.mkSet $
> +  map Types.diskTemplateToRaw [DTDiskless, DTBlock, DTExt, DTSharedFile,
> DTRbd]
> +
> +-- | The set of non-lvm-based disk templates
> +dtsNotLvm :: FrozenSet String
> +dtsNotLvm =
> +  ConstantUtils.mkSet $
> +  map Types.diskTemplateToRaw
> +  [DTSharedFile, DTDiskless, DTBlock, DTExt, DTFile, DTRbd]
> +
> +-- | The set of disk templates which can be grown
> +dtsGrowable :: FrozenSet String
> +dtsGrowable =
> +  ConstantUtils.mkSet $
> +  map Types.diskTemplateToRaw
> +  [DTSharedFile, DTDrbd8, DTPlain, DTExt, DTFile, DTRbd]
> +
> +-- | The set of disk templates that allow adoption
> +dtsMayAdopt :: FrozenSet String
> +dtsMayAdopt =
> +  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTBlock, DTPlain]
> +
> +-- | The set of disk templates that *must* use adoption
> +dtsMustAdopt :: FrozenSet String
> +dtsMustAdopt = ConstantUtils.mkSet [Types.diskTemplateToRaw DTBlock]
> +
> +-- | The set of disk templates that allow migrations
> +dtsMirrored :: FrozenSet String
> +dtsMirrored = dtsIntMirror `ConstantUtils.union` dtsExtMirror
> +
> +-- | The set of file based disk templates
> +dtsFilebased :: FrozenSet String
> +dtsFilebased =
> +  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTSharedFile, DTFile]
> +
> +-- | The set of disk templates that can be moved by copying
> +--
> +-- Note: a requirement is that they're not accessed externally or
> +-- shared between nodes; in particular, sharedfile is not suitable.
> +dtsCopyable :: FrozenSet String
> +dtsCopyable =
> +  ConstantUtils.mkSet $ map Types.diskTemplateToRaw [DTPlain, DTFile]
> +
> +-- | The set of disk templates that are supported by exclusive_storage
> +dtsExclStorage :: FrozenSet String
> +dtsExclStorage = ConstantUtils.mkSet $ map Types.diskTemplateToRaw
> [DTPlain]
> +
> +-- | Templates for which we don't perform checks on free space
> +dtsNoFreeSpaceCheck :: FrozenSet String
> +dtsNoFreeSpaceCheck =
> +  ConstantUtils.mkSet $
> +  map Types.diskTemplateToRaw [DTExt, DTSharedFile, DTFile, DTRbd]
> +
> +dtsBlock :: FrozenSet String
> +dtsBlock =
> +  ConstantUtils.mkSet $
> +  map Types.diskTemplateToRaw [DTPlain, DTDrbd8, DTBlock, DTRbd, DTExt]
> +
>  -- * File backend driver
>
>  fdBlktap :: String
> --
> 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

Reply via email to