Commit cef3f99f authored by Klaus Aehlig's avatar Klaus Aehlig

Provide method to read job serial number

This methods allows reading the maximal job serial number from
disk.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 1c1132f4
......@@ -45,6 +45,7 @@ module Ganeti.JQueue
, sortJobIDs
, loadJobFromDisk
, noSuchJob
, readSerialFromDisk
) where
import Control.Exception
......@@ -69,6 +70,7 @@ import Ganeti.OpCodes
import Ganeti.Path
import Ganeti.THH
import Ganeti.Types
import Ganeti.Utils
-- * Data types
......@@ -329,3 +331,10 @@ loadJobFromDisk rootdir archived jid = do
Just (str, arch) ->
liftM (\qj -> (qj, arch)) .
fromJResult "Parsing job file" $ Text.JSON.decode str
-- | Read the job serial number from disk.
readSerialFromDisk :: IO (Result JobId)
readSerialFromDisk = do
filename <- jobQueueSerialFile
tryAndLogIOError (readFile filename) "Failed to read serial file"
(makeJobIdS . rStripSpace)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment