From 734b1ff175fe11206f6e7e9079c0382066b1f433 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 10 Jun 2009 21:31:05 +0200
Subject: [PATCH] Fix reading of total disk space in iallocator
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

IAllocator currently uses a wrong key name for reading the total disk
space (β€˜disk_usage’ which was copied from RAPI, but the actual
iallocator key is β€˜disk_space_total’).

This patch fixes that and also makes iallocator always use this key,
instead of computing the size by itselfβ€”with Ganeti 2.0 this is
key is always available.
---
 Ganeti/HTools/IAlloc.hs | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/Ganeti/HTools/IAlloc.hs b/Ganeti/HTools/IAlloc.hs
index b2f8e2a67..37791af7a 100644
--- a/Ganeti/HTools/IAlloc.hs
+++ b/Ganeti/HTools/IAlloc.hs
@@ -49,14 +49,7 @@ parseBaseInstance :: String
                   -> JSObject JSValue
                   -> Result (String, Instance.Instance)
 parseBaseInstance n a = do
-  disk <- case fromObj "disk_usage" a of
-            Bad _ -> do
-                all_d <- fromObj "disks" a >>= asObjectList
-                szd <- mapM (fromObj "size") all_d
-                let sze = map (+128) szd
-                    szf = (sum sze)::Int
-                return szf
-            x@(Ok _) -> x
+  disk <- fromObj "disk_space_total" a
   mem <- fromObj "memory" a
   let running = "running"
   return $ (n, Instance.create n mem disk running 0 0)
-- 
GitLab