Revision 00b15752 Ganeti/HTools/Rapi.hs

b/Ganeti/HTools/Rapi.hs
90 90
                  concatEitherElems running $
91 91
                  concatEitherElems pnode snode
92 92

  
93
boolToYN :: Bool -> Either String String
94
boolToYN True = Right "Y"
95
boolToYN _ = Right "N"
96

  
93 97
parseNode :: JSObject JSValue -> Either String String
94 98
parseNode a =
95 99
    let name = getStringElement "name" a
100
        offline = getBoolElement "offline" a
101
        drained = getBoolElement "drained" a
96 102
        mtotal = getIntElement "mtotal" a
97 103
        mnode = getIntElement "mnode" a
98 104
        mfree = getIntElement "mfree" a
99 105
        dtotal = getIntElement "dtotal" a
100 106
        dfree = getIntElement "dfree" a
101 107
    in concatEitherElems name $
102
       concatEitherElems (show `applyEither1` mtotal) $
103
       concatEitherElems (show `applyEither1` mnode) $
104
       concatEitherElems (show `applyEither1` mfree) $
105
       concatEitherElems (show `applyEither1` dtotal)
106
                             (show `applyEither1` dfree)
108
       (case offline of
109
          Right True -> Right "0|0|0|0|0|Y"
110
          _ ->
111
              concatEitherElems (show `applyEither1` mtotal) $
112
              concatEitherElems (show `applyEither1` mnode) $
113
              concatEitherElems (show `applyEither1` mfree) $
114
              concatEitherElems (show `applyEither1` dtotal) $
115
              concatEitherElems (show `applyEither1` dfree)
116
              ((applyEither2 (||) offline drained) `combineEithers` boolToYN)
117
       )

Also available in: Unified diff