Cleanup AllocSolution after AllocElement changes
[ganeti-local] / Ganeti / HTools / Rapi.hs
index d061920..58df9bd 100644 (file)
@@ -4,7 +4,7 @@
 
 {-
 
-Copyright (C) 2009 Google Inc.
+Copyright (C) 2009, 2010 Google Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -75,7 +75,7 @@ getNodes body = loadJSArray "Parsing node data" body >>=
                 mapM (parseNode . fromJSObject)
 
 -- | Construct an instance from a JSON object.
-parseInstance :: [(String, Ndx)]
+parseInstance :: NameAssoc
               -> [(String, JSValue)]
               -> Result (String, Instance.Instance)
 parseInstance ktn a = do
@@ -105,8 +105,9 @@ parseNode a = do
   let extract s = tryFromObj ("Node '" ++ name ++ "'") a s
   offline <- extract "offline"
   drained <- extract "drained"
+  guuid   <- extract "group.uuid"
   node <- (if offline || drained
-           then return $ Node.create name 0 0 0 0 0 0 True
+           then return $ Node.create name 0 0 0 0 0 0 True guuid
            else do
              mtotal  <- extract "mtotal"
              mnode   <- extract "mnode"
@@ -115,7 +116,7 @@ parseNode a = do
              dfree   <- extract "dfree"
              ctotal  <- extract "ctotal"
              return $ Node.create name mtotal mnode mfree
-                    dtotal dfree ctotal False)
+                    dtotal dfree ctotal False guuid)
   return (name, node)
 
 -- | Loads the raw cluster data from an URL.
@@ -130,7 +131,7 @@ readData master = do
 
 -- | Builds the cluster data from the raw Rapi content
 parseData :: (Result String, Result String, Result String)
-          -> Result (Node.AssocList, Instance.AssocList, [String])
+          -> Result (Node.List, Instance.List, [String])
 parseData (node_body, inst_body, tags_body) = do
   node_data <- node_body >>= getNodes
   let (node_names, node_idx) = assignIndices node_data
@@ -141,5 +142,5 @@ parseData (node_body, inst_body, tags_body) = do
 
 -- | Top level function for data loading
 loadData :: String -- ^ Cluster or URL to use as source
-            -> IO (Result (Node.AssocList, Instance.AssocList, [String]))
+            -> IO (Result (Node.List, Instance.List, [String]))
 loadData master = readData master >>= return . parseData