The field is filled with the value provided on the command line.

Signed-off-by: Bernardo Dal Seno <[email protected]>
---
 lib/cmdlib/instance_storage.py |  6 ++++--
 lib/objects.py                 | 13 +++++++++----
 src/Ganeti/Objects.hs          |  2 ++
 test/hs/Test/Ganeti/Objects.hs |  5 +++--
 4 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/lib/cmdlib/instance_storage.py b/lib/cmdlib/instance_storage.py
index 6669404..d1b3cca 100644
--- a/lib/cmdlib/instance_storage.py
+++ b/lib/cmdlib/instance_storage.py
@@ -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)
@@ -821,7 +822,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:
diff --git a/lib/objects.py b/lib/objects.py
index 8d809c4..c67ac9f 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -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:
diff --git a/src/Ganeti/Objects.hs b/src/Ganeti/Objects.hs
index 1550309..382205d 100644
--- a/src/Ganeti/Objects.hs
+++ b/src/Ganeti/Objects.hs
@@ -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)
 
diff --git a/test/hs/Test/Ganeti/Objects.hs b/test/hs/Test/Ganeti/Objects.hs
index 1cb33e1..bb849ed 100644
--- a/test/hs/Test/Ganeti/Objects.hs
+++ b/test/hs/Test/Ganeti/Objects.hs
@@ -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
-- 
1.8.2.1

Reply via email to