LGTM, thanks.

On Wed, Oct 2, 2013 at 11:02 AM, Raffa Santi <[email protected]> wrote:

> Add the "access" parameter to the RBD configuration. Fix test broken
> by this change.
>
> Signed-off-by: Raffa Santi <[email protected]>
> ---
>  lib/constants.py                   |   13 +++++++++++--
>  lib/objects.py                     |    1 +
>  src/Ganeti/HsConstants.hs          |   12 ++++++++++++
>  src/Ganeti/Types.hs                |   16 ++++++++++++++++
>  test/py/cmdlib/cluster_unittest.py |    6 ++++--
>  5 files changed, 44 insertions(+), 4 deletions(-)
>
> diff --git a/lib/constants.py b/lib/constants.py
> index 6e79f85..826a180 100644
> --- a/lib/constants.py
> +++ b/lib/constants.py
> @@ -519,6 +519,9 @@ LDS_DRBD = compat.UniqueFrozenset([DT_DRBD8])
>  DISK_RDONLY = _constants.DISK_RDONLY
>  DISK_RDWR = _constants.DISK_RDWR
>  DISK_ACCESS_SET = _constants.DISK_ACCESS_SET
> +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
> @@ -1103,6 +1106,7 @@ LDP_DELAY_TARGET = "c-delay-target"
>  LDP_MAX_RATE = "c-max-rate"
>  LDP_MIN_RATE = "c-min-rate"
>  LDP_POOL = "pool"
> +LDP_ACCESS = "access"
>  DISK_LD_TYPES = {
>    LDP_RESYNC_RATE: VTYPE_INT,
>    LDP_STRIPES: VTYPE_INT,
> @@ -1119,6 +1123,7 @@ DISK_LD_TYPES = {
>    LDP_MAX_RATE: VTYPE_INT,
>    LDP_MIN_RATE: VTYPE_INT,
>    LDP_POOL: VTYPE_STRING,
> +  LDP_ACCESS: VTYPE_STRING,
>    }
>  DISK_LD_PARAMETERS = frozenset(DISK_LD_TYPES.keys())
>
> @@ -1141,6 +1146,7 @@ DRBD_MAX_RATE = "c-max-rate"
>  DRBD_MIN_RATE = "c-min-rate"
>  LV_STRIPES = "stripes"
>  RBD_POOL = "pool"
> +RBD_ACCESS = "access"
>  DISK_DT_TYPES = {
>    DRBD_RESYNC_RATE: VTYPE_INT,
>    DRBD_DATA_STRIPES: VTYPE_INT,
> @@ -1159,6 +1165,7 @@ DISK_DT_TYPES = {
>    DRBD_MIN_RATE: VTYPE_INT,
>    LV_STRIPES: VTYPE_INT,
>    RBD_POOL: VTYPE_STRING,
> +  RBD_ACCESS: VTYPE_STRING,
>    }
>
>  DISK_DT_PARAMETERS = frozenset(DISK_DT_TYPES.keys())
> @@ -1952,7 +1959,8 @@ DISK_LD_DEFAULTS = {
>    DT_SHARED_FILE: {},
>    DT_BLOCK: {},
>    DT_RBD: {
> -    LDP_POOL: "rbd"
> +    LDP_POOL: "rbd",
> +    LDP_ACCESS: DISK_KERNELSPACE,
>      },
>    DT_EXT: {},
>    }
> @@ -1987,7 +1995,8 @@ DISK_DT_DEFAULTS = {
>    DT_SHARED_FILE: {},
>    DT_BLOCK: {},
>    DT_RBD: {
> -    RBD_POOL: DISK_LD_DEFAULTS[DT_RBD][LDP_POOL]
> +    RBD_POOL: DISK_LD_DEFAULTS[DT_RBD][LDP_POOL],
> +    RBD_ACCESS: DISK_LD_DEFAULTS[DT_RBD][LDP_ACCESS],
>      },
>    DT_EXT: {},
>    }
> diff --git a/lib/objects.py b/lib/objects.py
> index aba3734..406988b 100644
> --- a/lib/objects.py
> +++ b/lib/objects.py
> @@ -897,6 +897,7 @@ class Disk(ConfigObject):
>      elif disk_template == constants.DT_RBD:
>
>  result.append(FillDict(constants.DISK_LD_DEFAULTS[constants.DT_RBD], {
>          constants.LDP_POOL: dt_params[constants.RBD_POOL],
> +        constants.LDP_ACCESS: dt_params[constants.RBD_ACCESS],
>          }))
>
>      elif disk_template == constants.DT_EXT:
> diff --git a/src/Ganeti/HsConstants.hs b/src/Ganeti/HsConstants.hs
> index fd56b27..6826408 100644
> --- a/src/Ganeti/HsConstants.hs
> +++ b/src/Ganeti/HsConstants.hs
> @@ -1381,3 +1381,15 @@ statFile = "/proc/stat"
>  -- | Mond's variable for periodical data collection
>  mondTimeInterval :: Int
>  mondTimeInterval = 5
> +
> +-- * Disk access modes
> +
> +diskUserspace :: String
> +diskUserspace = Types.diskAccessModeToRaw DiskUserspace
> +
> +diskKernelspace :: String
> +diskKernelspace = Types.diskAccessModeToRaw DiskKernelspace
> +
> +diskValidAccessModes :: FrozenSet String
> +diskValidAccessModes =
> +  ConstantUtils.mkSet $ map Types.diskAccessModeToRaw [minBound..]
> diff --git a/src/Ganeti/Types.hs b/src/Ganeti/Types.hs
> index ba9dea7..d208b6d 100644
> --- a/src/Ganeti/Types.hs
> +++ b/src/Ganeti/Types.hs
> @@ -141,6 +141,8 @@ module Ganeti.Types
>    , adminStateToRaw
>    , StorageField(..)
>    , storageFieldToRaw
> +  , DiskAccessMode(..)
> +  , diskAccessModeToRaw
>    ) where
>
>  import Control.Monad (liftM)
> @@ -282,6 +284,9 @@ $(THH.declareLADT ''String "DiskTemplate"
>         ])
>  $(THH.makeJSONInstance ''DiskTemplate)
>
> +instance THH.PyValue DiskTemplate where
> +  showValue = show . diskTemplateToRaw
> +
>  instance HasStringRepr DiskTemplate where
>    fromStringRepr = diskTemplateFromRaw
>    toStringRepr = diskTemplateToRaw
> @@ -406,6 +411,9 @@ $(THH.declareLADT ''String "Hypervisor"
>    ])
>  $(THH.makeJSONInstance ''Hypervisor)
>
> +instance THH.PyValue Hypervisor where
> +  showValue = show . hypervisorToRaw
> +
>  -- | Oob command type.
>  $(THH.declareLADT ''String "OobCommand"
>    [ ("OobHealth",      "health")
> @@ -758,3 +766,11 @@ $(THH.declareLADT ''String "StorageField"
>    , ( "SFSize",        "size")
>    ])
>  $(THH.makeJSONInstance ''StorageField)
> +
> +-- * Disk access protocol
> +
> +$(THH.declareLADT ''String "DiskAccessMode"
> +  [ ( "DiskUserspace",   "userspace")
> +  , ( "DiskKernelspace", "kernelspace")
> +  ])
> +$(THH.makeJSONInstance ''DiskAccessMode)
> diff --git a/test/py/cmdlib/cluster_unittest.py
> b/test/py/cmdlib/cluster_unittest.py
> index 5b8f2e1..e8438a3 100644
> --- a/test/py/cmdlib/cluster_unittest.py
> +++ b/test/py/cmdlib/cluster_unittest.py
> @@ -425,13 +425,15 @@ class TestLUClusterSetParams(CmdlibTestCase):
>
>    def testInvalidDiskparams(self):
>      for diskparams in [{constants.DT_DISKLESS: {constants.LV_STRIPES: 0}},
> -                       {constants.DT_DRBD8: {constants.RBD_POOL:
> "pool"}}]:
> +                       {constants.DT_DRBD8: {constants.RBD_POOL: "pool"}},
> +                       {constants.DT_DRBD8: {constants.RBD_ACCESS:
> "bunny"}}]:
>        self.ResetMocks()
>        op = opcodes.OpClusterSetParams(diskparams=diskparams)
>        self.ExecOpCodeExpectOpPrereqError(op, "verify diskparams")
>
>    def testValidDiskparams(self):
> -    diskparams = {constants.DT_RBD: {constants.RBD_POOL: "mock_pool"}}
> +    diskparams = {constants.DT_RBD: {constants.RBD_POOL: "mock_pool",
> +                                     constants.RBD_ACCESS: "kernelspace"}}
>      op = opcodes.OpClusterSetParams(diskparams=diskparams)
>      self.ExecOpCode(op)
>      self.assertEqual(diskparams[constants.DT_RBD],
> --
> 1.7.10.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