[Pkg-ganeti-devel] [ganeti] 34/165: Extract a formating function for IAllocResult

Apollon Oikonomopoulos apoikos at moszumanska.debian.org
Tue Aug 11 13:53:10 UTC 2015


This is an automated email from the git hooks/post-receive script.

apoikos pushed a commit to branch master
in repository ganeti.

commit 6ef92594bdd02f3753bb4c4e1d83d8bf78dfeafa
Author: Klaus Aehlig <aehlig at google.com>
Date:   Tue Jan 27 18:05:29 2015 +0100

    Extract a formating function for IAllocResult
    
    ...so that the processing of the request is separated
    from the backend conventions. In particular, support other
    allocation strategies to provide the correct answers for
    that backend.
    
    Signed-off-by: Klaus Aehlig <aehlig at google.com>
    Reviewed-by: Petr Pudlak <pudlak at google.com>
---
 src/Ganeti/HTools/Backend/IAlloc.hs | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/Ganeti/HTools/Backend/IAlloc.hs b/src/Ganeti/HTools/Backend/IAlloc.hs
index f19e522..dab10de 100644
--- a/src/Ganeti/HTools/Backend/IAlloc.hs
+++ b/src/Ganeti/HTools/Backend/IAlloc.hs
@@ -38,6 +38,7 @@ module Ganeti.HTools.Backend.IAlloc
   , processRelocate
   , loadData
   , formatAllocate
+  , formatIAllocResult
   ) where
 
 import Data.Either ()
@@ -445,18 +446,23 @@ readRequest fp = do
     Bad err -> exitErr err
     Ok (fix_msgs, rq) -> maybeShowWarnings fix_msgs >> return rq
 
--- | Main iallocator pipeline.
-runIAllocator :: AlgorithmOptions
-              -> Request -> (Maybe (Node.List, Instance.List), String)
-runIAllocator opts request =
+-- | Format an IAlloc result to maybe the new cluster and a response.
+formatIAllocResult :: Result IAllocResult
+                   -> (Maybe (Node.List, Instance.List), String)
+formatIAllocResult iallocResult =
   let (ok, info, result, cdata) =
-        case processRequest opts request of
+        case iallocResult of
           Ok (msg, r, nl, il) -> (True, "Request successful: " ++ msg, r,
                                   Just (nl, il))
           Bad msg -> (False, "Request failed: " ++ msg, JSArray [], Nothing)
       rstring = formatResponse ok info result
   in (cdata, rstring)
 
+-- | Main iallocator pipeline.
+runIAllocator :: AlgorithmOptions
+              -> Request -> (Maybe (Node.List, Instance.List), String)
+runIAllocator opts request = formatIAllocResult $ processRequest opts request
+
 -- | Load the data from an iallocation request file
 loadData :: FilePath -- ^ The path to the file
          -> IO (Result ClusterData)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ganeti/ganeti.git



More information about the Pkg-ganeti-devel mailing list