Commit b54ecf12 authored by Bernardo Dal Seno's avatar Bernardo Dal Seno
Browse files

Add spindles field to disk object



The field is filled with the value provided on the command line.
Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent 3f3ea14c
......@@ -510,7 +510,8 @@ def GenerateDiskTemplate(
logical_id=logical_id_fn(idx, disk_index, disk),
iv_name="disk/%d" % disk_index,
mode=disk[constants.IDISK_MODE],
params=params)
params=params,
spindles=disk.get(constants.IDISK_SPINDLES))
disk_dev.name = disk.get(constants.IDISK_NAME, None)
disk_dev.uuid = lu.cfg.GenerateUniqueID(lu.proc.GetECId())
disks.append(disk_dev)
......@@ -833,7 +834,8 @@ class LUInstanceRecreateDisks(LogicalUnit):
disk.logical_id = new_id
if changes:
disk.Update(size=changes.get(constants.IDISK_SIZE, None),
mode=changes.get(constants.IDISK_MODE, None))
mode=changes.get(constants.IDISK_MODE, None),
spindles=changes.get(constants.IDISK_SPINDLES, None))
# change primary node, if needed
if self.op.nodes:
......
......@@ -512,8 +512,9 @@ class NIC(ConfigObject):
class Disk(ConfigObject):
"""Config object representing a block device."""
__slots__ = ["name", "dev_type", "logical_id", "physical_id",
"children", "iv_name", "size", "mode", "params"] + _UUID
__slots__ = (["name", "dev_type", "logical_id", "physical_id",
"children", "iv_name", "size", "mode", "params", "spindles"] +
_UUID)
def CreateOnSecondary(self):
"""Test if this device needs to be created on a secondary node."""
......@@ -674,8 +675,8 @@ class Disk(ConfigObject):
raise errors.ProgrammerError("Disk.RecordGrow called for unsupported"
" disk type %s" % self.dev_type)
def Update(self, size=None, mode=None):
"""Apply changes to size and mode.
def Update(self, size=None, mode=None, spindles=None):
"""Apply changes to size, spindles and mode.
"""
if self.dev_type == constants.LD_DRBD8:
......@@ -688,6 +689,8 @@ class Disk(ConfigObject):
self.size = size
if mode is not None:
self.mode = mode
if spindles is not None:
self.spindles = spindles
def UnsetSize(self):
"""Sets recursively the size to zero for the disk and its children.
......@@ -804,6 +807,8 @@ class Disk(ConfigObject):
val += ", not visible"
else:
val += ", visible as /dev/%s" % self.iv_name
if self.spindles is not None:
val += ", spindles=%s" % self.spindles
if isinstance(self.size, int):
val += ", size=%dm)>" % self.size
else:
......
......@@ -426,6 +426,7 @@ data Disk = Disk
, diskSize :: Int
, diskMode :: DiskMode
, diskName :: Maybe String
, diskSpindles :: Maybe Int
, diskUuid :: String
} deriving (Show, Eq)
......@@ -438,6 +439,7 @@ $(buildObjectSerialisation "Disk" $
, simpleField "size" [t| Int |]
, defaultField [| DiskRdWr |] $ simpleField "mode" [t| DiskMode |]
, optionalField $ simpleField "name" [t| String |]
, optionalField $ simpleField "spindles" [t| Int |]
]
++ uuidFields)
......
......@@ -93,7 +93,7 @@ instance Arbitrary DiskLogicalId where
instance Arbitrary Disk where
arbitrary = Disk <$> arbitrary <*> pure [] <*> arbitrary
<*> arbitrary <*> arbitrary <*> arbitrary
<*> arbitrary
<*> arbitrary <*> arbitrary
-- FIXME: we should generate proper values, >=0, etc., but this is
-- hard for partial ones, where all must be wrapped in a 'Maybe'
......@@ -179,8 +179,9 @@ genDiskWithChildren num_children = do
size <- arbitrary
mode <- arbitrary
name <- genMaybe genName
spindles <- arbitrary
uuid <- genName
let disk = Disk logicalid children ivname size mode name uuid
let disk = Disk logicalid children ivname size mode name spindles uuid
return disk
genDisk :: Gen Disk
......
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