(2.13) Add DiskParams to Disk object
authorIlias Tsitsimpis <iliastsi@grnet.gr>
Mon, 12 May 2014 08:47:09 +0000 (11:47 +0300)
committerDimitris Aragiorgis <dimara@grnet.gr>
Thu, 29 May 2014 11:07:53 +0000 (14:07 +0300)
The 'DiskParams' slot was missing from Haskell's Disk objects.
Since Wconfd is now responsible for writting the config file this was
causing the 'params' slot to not be written in the config file.

Signed-off-by: Ilias Tsitsimpis <iliastsi@grnet.gr>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

src/Ganeti/Objects.hs
test/hs/Test/Ganeti/Objects.hs

index 7837851..1837c17 100644 (file)
@@ -62,6 +62,7 @@ module Ganeti.Objects
   , PartialIPolicy(..)
   , fillIPolicy
   , GroupDiskParams
+  , DiskParams
   , NodeGroup(..)
   , IpFamily(..)
   , ipFamilyToVersion
@@ -390,6 +391,7 @@ data Disk = Disk
   , diskMode       :: DiskMode
   , diskName       :: Maybe String
   , diskSpindles   :: Maybe Int
+  , diskParams     :: Maybe DiskParams
   , diskUuid       :: String
   } deriving (Show, Eq)
 
@@ -402,6 +404,7 @@ $(buildObjectSerialisation "Disk" $
   , defaultField [| DiskRdWr |] $ simpleField "mode" [t| DiskMode |]
   , optionalField $ simpleField "name" [t| String |]
   , optionalField $ simpleField "spindles" [t| Int |]
+  , optionalField $ simpleField "params" [t| DiskParams |]
   ]
   ++ uuidFields)
 
index a5498ca..6fd7069 100644 (file)
@@ -93,7 +93,7 @@ instance Arbitrary DiskLogicalId where
 instance Arbitrary Disk where
   arbitrary = Disk <$> arbitrary <*> pure [] <*> arbitrary
                    <*> arbitrary <*> 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'
@@ -182,8 +182,9 @@ genDiskWithChildren num_children = do
   mode <- arbitrary
   name <- genMaybe genName
   spindles <- arbitrary
+  params <- arbitrary
   uuid <- genName
-  let disk = Disk logicalid children ivname size mode name spindles uuid
+  let disk = Disk logicalid children ivname size mode name spindles params uuid
   return disk
 
 genDisk :: Gen Disk
@@ -205,6 +206,9 @@ $(genArbitrary ''FilledNDParams)
 $(genArbitrary ''FilledNicParams)
 $(genArbitrary ''FilledBeParams)
 
+instance Arbitrary DiskParams where
+  arbitrary = return $ GenericContainer Map.empty
+
 -- | No real arbitrary instance for 'ClusterHvParams' yet.
 instance Arbitrary ClusterHvParams where
   arbitrary = return $ GenericContainer Map.empty
@@ -539,7 +543,7 @@ caseIncludeLogicalIdPlain =
       lv_name = "1234sdf-qwef-2134-asff-asd2-23145d.data" :: String
       d =
         Disk (LIDPlain vg_name lv_name) [] "diskname" 1000 DiskRdWr
-          Nothing Nothing "asdfgr-1234-5123-daf3-sdfw-134f43"
+          Nothing Nothing Nothing "asdfgr-1234-5123-daf3-sdfw-134f43"
   in
     HUnit.assertBool "Unable to detect that plain Disk includes logical ID" $
       includesLogicalId vg_name lv_name d
@@ -553,10 +557,10 @@ caseIncludeLogicalIdDrbd =
         Disk
           (LIDDrbd8 "node1.example.com" "node2.example.com" 2000 1 5 "secret")
           [ Disk (LIDPlain "onevg" "onelv") [] "disk1" 1000 DiskRdWr Nothing
-              Nothing "145145-asdf-sdf2-2134-asfd-534g2x"
+              Nothing Nothing "145145-asdf-sdf2-2134-asfd-534g2x"
           , Disk (LIDPlain vg_name lv_name) [] "disk2" 1000 DiskRdWr Nothing
-              Nothing "6gd3sd-423f-ag2j-563b-dg34-gj3fse"
-          ] "diskname" 1000 DiskRdWr Nothing Nothing
+              Nothing Nothing "6gd3sd-423f-ag2j-563b-dg34-gj3fse"
+          ] "diskname" 1000 DiskRdWr Nothing Nothing Nothing
           "asdfgr-1234-5123-daf3-sdfw-134f43"
   in
     HUnit.assertBool "Unable to detect that plain Disk includes logical ID" $
@@ -569,7 +573,7 @@ caseNotIncludeLogicalIdPlain =
       lv_name = "1234sdf-qwef-2134-asff-asd2-23145d.data" :: String
       d =
         Disk (LIDPlain "othervg" "otherlv") [] "diskname" 1000 DiskRdWr
-          Nothing Nothing "asdfgr-1234-5123-daf3-sdfw-134f43"
+          Nothing Nothing Nothing "asdfgr-1234-5123-daf3-sdfw-134f43"
   in
     HUnit.assertBool "Unable to detect that plain Disk includes logical ID" $
       not (includesLogicalId vg_name lv_name d)