LGTM

On Mon, Jul 14, 2014 at 3:29 PM, Dimitris Bliablias <[email protected]>
wrote:

> Currently, the 'gluster' and 'sharedfile' disk templates are both mapped
> to the Shared File storage type. This compromise causes the Gluster block
> devices to be interpreted in the config as 'sharedfile' devices, instead
> of 'gluster', and subsequently to be wrongly handled as Shared File
> disks. This behavior, currently makes the 'gluster' disk template not
> functional.
>
> This patch, fixes this issue by introducing the Gluster storage type,
> which will be exclusively used by the 'gluster' disk template.
>
> Signed-off-by: Dimitris Bliablias <[email protected]>
> ---
>  lib/backend.py          |    1 +
>  src/Ganeti/Constants.hs |    5 ++++-
>  src/Ganeti/Objects.hs   |    5 ++++-
>  src/Ganeti/Types.hs     |    7 ++++++-
>  4 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/lib/backend.py b/lib/backend.py
> index 4b98e22..d28b389 100644
> --- a/lib/backend.py
> +++ b/lib/backend.py
> @@ -777,6 +777,7 @@ _STORAGE_TYPE_INFO_FN = {
>    constants.ST_LVM_PV: _GetLvmPvSpaceInfo,
>    constants.ST_LVM_VG: _GetLvmVgSpaceInfo,
>    constants.ST_SHARED_FILE: None,
> +  constants.ST_GLUSTER: None,
>    constants.ST_RADOS: None,
>  }
>
> diff --git a/src/Ganeti/Constants.hs b/src/Ganeti/Constants.hs
> index 928b45d..e9de6bb 100644
> --- a/src/Ganeti/Constants.hs
> +++ b/src/Ganeti/Constants.hs
> @@ -711,6 +711,9 @@ stFile = Types.storageTypeToRaw StorageFile
>  stSharedFile :: String
>  stSharedFile = Types.storageTypeToRaw StorageSharedFile
>
> +stGluster :: String
> +stGluster = Types.storageTypeToRaw StorageGluster
> +
>  stLvmPv :: String
>  stLvmPv = Types.storageTypeToRaw StorageLvmPv
>
> @@ -878,7 +881,7 @@ mapDiskTemplateStorageType =
>     (DTDiskless, StorageDiskless),
>     (DTPlain, StorageLvmVg),
>     (DTRbd, StorageRados),
> -   (DTGluster, StorageSharedFile)]
> +   (DTGluster, StorageGluster)]
>
>  -- | The set of network-mirrored disk templates
>  dtsIntMirror :: FrozenSet String
> diff --git a/src/Ganeti/Objects.hs b/src/Ganeti/Objects.hs
> index 77e307f..fbbfc83 100644
> --- a/src/Ganeti/Objects.hs
> +++ b/src/Ganeti/Objects.hs
> @@ -392,6 +392,7 @@ data DiskLogicalId
>    -- ^ NodeA, NodeB, Port, MinorA, MinorB, Secret
>    | LIDFile FileDriver String -- ^ Driver, path
>    | LIDSharedFile FileDriver String -- ^ Driver, path
> +  | LIDGluster FileDriver String -- ^ Driver, path
>    | LIDBlockDev BlockDriver String -- ^ Driver, path (must be under /dev)
>    | LIDRados String String -- ^ Unused, path
>    | LIDExt String String -- ^ ExtProvider, unique name
> @@ -403,6 +404,7 @@ lidDiskType (LIDPlain {}) = DTPlain
>  lidDiskType (LIDDrbd8 {}) = DTDrbd8
>  lidDiskType (LIDFile  {}) = DTFile
>  lidDiskType (LIDSharedFile  {}) = DTSharedFile
> +lidDiskType (LIDGluster  {}) = DTGluster
>  lidDiskType (LIDBlockDev {}) = DTBlock
>  lidDiskType (LIDRados {}) = DTRbd
>  lidDiskType (LIDExt {}) = DTExt
> @@ -422,6 +424,7 @@ encodeDLId (LIDRados pool name) = JSArray [showJSON
> pool, showJSON name]
>  encodeDLId (LIDFile driver name) = JSArray [showJSON driver, showJSON
> name]
>  encodeDLId (LIDSharedFile driver name) =
>    JSArray [showJSON driver, showJSON name]
> +encodeDLId (LIDGluster driver name) = JSArray [showJSON driver, showJSON
> name]
>  encodeDLId (LIDBlockDev driver name) = JSArray [showJSON driver, showJSON
> name]
>  encodeDLId (LIDExt extprovider name) =
>    JSArray [showJSON extprovider, showJSON name]
> @@ -474,7 +477,7 @@ decodeDLId obj lid = do
>          JSArray [driver, path] -> do
>            driver' <- readJSON driver
>            path'   <- readJSON path
> -          return $ LIDSharedFile driver' path'
> +          return $ LIDGluster driver' path'
>          _ -> fail "Can't read logical_id for shared file type"
>      DTBlock ->
>        case lid of
> diff --git a/src/Ganeti/Types.hs b/src/Ganeti/Types.hs
> index 48b174c..e6c7d74 100644
> --- a/src/Ganeti/Types.hs
> +++ b/src/Ganeti/Types.hs
> @@ -466,6 +466,7 @@ $(THH.makeJSONInstance ''OobStatus)
>  $(THH.declareLADT ''String "StorageType"
>    [ ("StorageFile", "file")
>    , ("StorageSharedFile", "sharedfile")
> +  , ("StorageGluster", "gluster")
>    , ("StorageLvmPv", "lvm-pv")
>    , ("StorageLvmVg", "lvm-vg")
>    , ("StorageDiskless", "diskless")
> @@ -489,6 +490,7 @@ data StorageUnitRaw = SURaw StorageType StorageKey
>  -- | Full storage unit with storage-type-specific parameters
>  data StorageUnit = SUFile StorageKey
>                   | SUSharedFile StorageKey
> +                 | SUGluster StorageKey
>                   | SULvmPv StorageKey SPExclusiveStorage
>                   | SULvmVg StorageKey SPExclusiveStorage
>                   | SUDiskless StorageKey
> @@ -500,6 +502,7 @@ data StorageUnit = SUFile StorageKey
>  instance Show StorageUnit where
>    show (SUFile key) = showSUSimple StorageFile key
>    show (SUSharedFile key) = showSUSimple StorageSharedFile key
> +  show (SUGluster key) = showSUSimple StorageGluster key
>    show (SULvmPv key es) = showSULvm StorageLvmPv key es
>    show (SULvmVg key es) = showSULvm StorageLvmVg key es
>    show (SUDiskless key) = showSUSimple StorageDiskless key
> @@ -510,6 +513,7 @@ instance Show StorageUnit where
>  instance JSON StorageUnit where
>    showJSON (SUFile key) = showJSON (StorageFile, key, []::[String])
>    showJSON (SUSharedFile key) = showJSON (StorageSharedFile, key,
> []::[String])
> +  showJSON (SUGluster key) = showJSON (StorageGluster, key, []::[String])
>    showJSON (SULvmPv key es) = showJSON (StorageLvmPv, key, [es])
>    showJSON (SULvmVg key es) = showJSON (StorageLvmVg, key, [es])
>    showJSON (SUDiskless key) = showJSON (StorageDiskless, key,
> []::[String])
> @@ -541,7 +545,7 @@ diskTemplateToStorageType DTPlain = StorageLvmVg
>  diskTemplateToStorageType DTRbd = StorageRados
>  diskTemplateToStorageType DTDiskless = StorageDiskless
>  diskTemplateToStorageType DTBlock = StorageBlock
> -diskTemplateToStorageType DTGluster = StorageSharedFile
> +diskTemplateToStorageType DTGluster = StorageGluster
>
>  -- | Equips a raw storage unit with its parameters
>  addParamsToStorageUnit :: SPExclusiveStorage -> StorageUnitRaw ->
> StorageUnit
> @@ -550,6 +554,7 @@ addParamsToStorageUnit _ (SURaw StorageDiskless key) =
> SUDiskless key
>  addParamsToStorageUnit _ (SURaw StorageExt key) = SUExt key
>  addParamsToStorageUnit _ (SURaw StorageFile key) = SUFile key
>  addParamsToStorageUnit _ (SURaw StorageSharedFile key) = SUSharedFile key
> +addParamsToStorageUnit _ (SURaw StorageGluster key) = SUGluster key
>  addParamsToStorageUnit es (SURaw StorageLvmPv key) = SULvmPv key es
>  addParamsToStorageUnit es (SURaw StorageLvmVg key) = SULvmVg key es
>  addParamsToStorageUnit _ (SURaw StorageRados key) = SURados key
> --
> 1.7.10.4
>
>

Reply via email to