Revision fd958a3d

b/htools/Ganeti/Types.hs
82 82
  , JobId
83 83
  , fromJobId
84 84
  , makeJobId
85
  , makeJobIdS
85 86
  , RelativeJobId
86 87
  , JobIdDep(..)
87 88
  , JobDependency(..)
88 89
  , OpSubmitPriority(..)
90
  , opSubmitPriorityToRaw
89 91
  , OpStatus(..)
90 92
  , opStatusToRaw
91 93
  , opStatusFromRaw
......
402 404
makeJobId i | i >= 0 = return $ JobId i
403 405
            | otherwise = fail $ "Invalid value for job ID ' " ++ show i ++ "'"
404 406

  
407
-- | Builds a job ID from a string.
408
makeJobIdS :: (Monad m) => String -> m JobId
409
makeJobIdS s = tryRead "parsing job id" s >>= makeJobId
410

  
405 411
-- | Parses a job ID.
406 412
parseJobId :: (Monad m) => JSON.JSValue -> m JobId
407
parseJobId (JSON.JSString x) =
408
  tryRead "parsing job id" (JSON.fromJSString x) >>= makeJobId
413
parseJobId (JSON.JSString x) = makeJobIdS $ JSON.fromJSString x
409 414
parseJobId (JSON.JSRational _ x) =
410 415
  if denominator x /= 1
411 416
    then fail $ "Got fractional job ID from master daemon?! Value:" ++ show x

Also available in: Unified diff