From ccc817a277a1080b5970849300fd918ddaebd5de Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 25 Jul 2012 16:16:38 +0200
Subject: [PATCH] Introduce a type for the ganeti job type

This will be used for easier change later.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 htools/Ganeti/HTools/Program/Hbal.hs | 2 +-
 htools/Ganeti/Luxi.hs                | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/htools/Ganeti/HTools/Program/Hbal.hs b/htools/Ganeti/HTools/Program/Hbal.hs
index daa51b36c..bbc62c32e 100644
--- a/htools/Ganeti/HTools/Program/Hbal.hs
+++ b/htools/Ganeti/HTools/Program/Hbal.hs
@@ -160,7 +160,7 @@ saveBalanceCommands opts cmd_data = do
 
 -- | Polls a set of jobs at a fixed interval until all are finished
 -- one way or another.
-waitForJobs :: L.Client -> [String] -> IO (Result [JobStatus])
+waitForJobs :: L.Client -> [L.JobId] -> IO (Result [JobStatus])
 waitForJobs client jids = do
   sts <- L.queryJobsStatus client jids
   case sts of
diff --git a/htools/Ganeti/Luxi.hs b/htools/Ganeti/Luxi.hs
index 4c0daedee..03f2ef0f6 100644
--- a/htools/Ganeti/Luxi.hs
+++ b/htools/Ganeti/Luxi.hs
@@ -31,6 +31,7 @@ module Ganeti.Luxi
   , ResultStatus(..)
   , LuxiReq(..)
   , Client
+  , JobId
   , checkRS
   , getClient
   , closeClient
@@ -71,6 +72,9 @@ withTimeout secs descr action = do
 
 -- * Generic protocol functionality
 
+-- | The Ganeti job type.
+type JobId = String
+
 $(declareSADT "QrViaLuxi"
   [ ("QRLock", 'qrLock)
   , ("QRInstance", 'qrInstance)
@@ -354,7 +358,7 @@ callMethod method s = do
   return rval
 
 -- | Specialized submitManyJobs call.
-submitManyJobs :: Client -> [[OpCode]] -> IO (Result [String])
+submitManyJobs :: Client -> [[OpCode]] -> IO (Result [JobId])
 submitManyJobs s jobs = do
   rval <- callMethod (SubmitManyJobs jobs) s
   -- map each result (status, payload) pair into a nice Result ADT
@@ -371,7 +375,7 @@ submitManyJobs s jobs = do
              x -> Bad ("Cannot parse response from Ganeti: " ++ show x)
 
 -- | Custom queryJobs call.
-queryJobsStatus :: Client -> [String] -> IO (Result [JobStatus])
+queryJobsStatus :: Client -> [JobId] -> IO (Result [JobStatus])
 queryJobsStatus s jids = do
   rval <- callMethod (QueryJobs (map read jids) ["status"]) s
   return $ case rval of
-- 
GitLab