Commit 9b9e088c authored by Raffa Santi's avatar Raffa Santi Committed by Thomas Thrainer
Browse files

Define 'access' disk-parameter type



Add the "access" parameter to the RBD configuration. Fix test broken
by this change.
Signed-off-by: default avatarSanti Raffa <rsanti@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent d067f40b
......@@ -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
......@@ -1105,6 +1108,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,
......@@ -1121,6 +1125,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())
......@@ -1143,6 +1148,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,
......@@ -1161,6 +1167,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())
......@@ -1953,7 +1960,8 @@ DISK_LD_DEFAULTS = {
DT_SHARED_FILE: {},
DT_BLOCK: {},
DT_RBD: {
LDP_POOL: "rbd"
LDP_POOL: "rbd",
LDP_ACCESS: DISK_KERNELSPACE,
},
DT_EXT: {},
}
......@@ -1988,7 +1996,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: {},
}
......
......@@ -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:
......
......@@ -1368,3 +1368,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..]
......@@ -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")
......@@ -763,3 +771,11 @@ $(THH.declareLADT ''String "StorageField"
, ( "SFSize", "size")
])
$(THH.makeJSONInstance ''StorageField)
-- * Disk access protocol
$(THH.declareLADT ''String "DiskAccessMode"
[ ( "DiskUserspace", "userspace")
, ( "DiskKernelspace", "kernelspace")
])
$(THH.makeJSONInstance ''DiskAccessMode)
......@@ -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],
......
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