Revision 96e3dfa7 src/Ganeti/Query/Node.hs

b/src/Ganeti/Query/Node.hs
218 218
  -- FIXME: the below could be generalised a bit, like in Python
219 219
  , (FieldDefinition "pinst_cnt" "Pinst" QFTNumber
220 220
       "Number of instances with this node as primary",
221
     FieldConfig (\cfg ->
222
                    rsNormal . length . fst . getNodeInstances cfg . nodeUuid),
223
     QffNormal)
221
     FieldConfig (\cfg -> rsNormal . getNumInstances fst cfg), QffNormal)
224 222
  , (FieldDefinition "sinst_cnt" "Sinst" QFTNumber
225 223
       "Number of instances with this node as secondary",
226
     FieldConfig (\cfg ->
227
                    rsNormal . length . snd . getNodeInstances cfg . nodeUuid),
228
     QffNormal)
224
     FieldConfig (\cfg -> rsNormal . getNumInstances snd cfg), QffNormal)
229 225
  , (FieldDefinition "pinst_list" "PriInstances" QFTOther
230 226
       "List of instances with this node as primary",
231 227
     FieldConfig (\cfg -> rsNormal . niceSort . map instName . fst .
......
254 250
  serialFields "Node" ++
255 251
  tagsFields
256 252

  
253
-- | Helper function to retrieve the number of (primary or secondary) instances
254
getNumInstances :: (([Instance], [Instance]) -> [Instance])
255
                -> ConfigData -> Node -> Int
256
getNumInstances get_fn cfg = length . get_fn . getNodeInstances cfg . nodeUuid
257

  
257 258
-- | The node fields map.
258 259
fieldsMap :: FieldMap Node Runtime
259 260
fieldsMap =

Also available in: Unified diff