Skip to content
Snippets Groups Projects
Commit ccc817a2 authored by Iustin Pop's avatar Iustin Pop
Browse files

Introduce a type for the ganeti job type


This will be used for easier change later.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent a085d96d
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment