Extend config by networks and networks by UUIDs
authorHelga Velroyen <helgav@google.com>
Thu, 24 Jan 2013 14:46:41 +0000 (15:46 +0100)
committerHelga Velroyen <helgav@google.com>
Thu, 24 Jan 2013 18:30:04 +0000 (19:30 +0100)
For network queries to work, we need to extend the general
config type to include all available networks. Additionally,
we add UUIDs to the network type itself.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

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

index f86b54d..26ccea6 100644 (file)
@@ -192,6 +192,7 @@ $(buildObject "Network" "network" $
   , optionalField $
     simpleField "ext_reservations" [t| String |]
   ]
+  ++ uuidFields
   ++ serialFields
   ++ tagsFields)
 
@@ -201,6 +202,9 @@ instance SerialNoObject Network where
 instance TagsObject Network where
   tagsOf = networkTags
 
+instance UuidObject Network where
+  uuidOf = networkUuid
+
 -- * NIC definitions
 
 $(buildParam "Nic" "nicp"
@@ -639,6 +643,7 @@ $(buildObject "ConfigData" "config" $
   , simpleField "nodes"      [t| Container Node      |]
   , simpleField "nodegroups" [t| Container NodeGroup |]
   , simpleField "instances"  [t| Container Instance  |]
+  , simpleField "networks"   [t| Container Network   |]
   ]
   ++ serialFields)
 
index 7b05f9e..8182279 100644 (file)
@@ -179,8 +179,9 @@ genValidNetwork = do
   size <- genMaybe genJSValue
   res <- liftM Just (genBitString $ netmask2NumHosts netmask)
   ext_res <- liftM Just (genBitString $ netmask2NumHosts netmask)
+  uuid <- arbitrary
   let n = Network name network_type mac_prefix net_family net net6 gateway
-          gateway6 size res ext_res 0 Set.empty
+          gateway6 size res ext_res uuid 0 Set.empty
   return n
 
 -- | Generates an arbitrary network type.
@@ -215,11 +216,13 @@ genEmptyCluster ncount = do
                                 show (map fst nodes'))
                     else GenericContainer nodemap
       continsts = GenericContainer Map.empty
+      networks = GenericContainer Map.empty
   grp <- arbitrary
   let contgroups = GenericContainer $ Map.singleton guuid grp
   serial <- arbitrary
   cluster <- resize 8 arbitrary
-  let c = ConfigData version cluster contnodes contgroups continsts serial
+  let c = ConfigData version cluster contnodes contgroups continsts networks
+            serial
   return c
 
 -- * Test properties