From b43064d0976299f26d727505b6d69f34894565e5 Mon Sep 17 00:00:00 2001
From: Helga Velroyen <helgav@google.com>
Date: Thu, 24 Jan 2013 15:46:41 +0100
Subject: [PATCH] Extend config by networks and networks by UUIDs

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          | 5 +++++
 test/hs/Test/Ganeti/Objects.hs | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/Ganeti/Objects.hs b/src/Ganeti/Objects.hs
index f86b54d35..26ccea6b5 100644
--- a/src/Ganeti/Objects.hs
+++ b/src/Ganeti/Objects.hs
@@ -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)
 
diff --git a/test/hs/Test/Ganeti/Objects.hs b/test/hs/Test/Ganeti/Objects.hs
index 7b05f9e09..818227993 100644
--- a/test/hs/Test/Ganeti/Objects.hs
+++ b/test/hs/Test/Ganeti/Objects.hs
@@ -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
-- 
GitLab