Revision 37fe56e0 src/Ganeti/Types.hs

b/src/Ganeti/Types.hs
11 11

  
12 12
{-
13 13

  
14
Copyright (C) 2012 Google Inc.
14
Copyright (C) 2012, 2013 Google Inc.
15 15

  
16 16
This program is free software; you can redistribute it and/or modify
17 17
it under the terms of the GNU General Public License as published by
......
86 86
  , JobDependency(..)
87 87
  , OpSubmitPriority(..)
88 88
  , opSubmitPriorityToRaw
89
  , parseSubmitPriority
90
  , fmtSubmitPriority
89 91
  , OpStatus(..)
90 92
  , opStatusToRaw
91 93
  , opStatusFromRaw
......
447 449
  ])
448 450
$(THH.makeJSONInstance ''OpSubmitPriority)
449 451

  
452
-- | Parse submit priorities from a string.
453
parseSubmitPriority :: (Monad m) => String -> m OpSubmitPriority
454
parseSubmitPriority "low"    = return OpPrioLow
455
parseSubmitPriority "normal" = return OpPrioNormal
456
parseSubmitPriority "high"   = return OpPrioHigh
457
parseSubmitPriority str      = fail $ "Unknown priority '" ++ str ++ "'"
458

  
459
-- | Format a submit priority as string.
460
fmtSubmitPriority :: OpSubmitPriority -> String
461
fmtSubmitPriority OpPrioLow    = "low"
462
fmtSubmitPriority OpPrioNormal = "normal"
463
fmtSubmitPriority OpPrioHigh   = "high"
464

  
450 465
-- | Our ADT for the OpCode status at runtime (while in a job).
451 466
$(THH.declareSADT "OpStatus"
452 467
  [ ("OP_STATUS_QUEUED",    'C.opStatusQueued)

Also available in: Unified diff