Revision e77bc89b htools/Ganeti/HTools/Luxi.hs

b/htools/Ganeti/HTools/Luxi.hs
199 199
parseNode _ v = fail ("Invalid node query result: " ++ show v)
200 200

  
201 201
-- | Parses the cluster tags.
202
getClusterTags :: JSValue -> Result [String]
203
getClusterTags v = do
202
getClusterData :: JSValue -> Result ([String], IPolicy)
203
getClusterData (JSObject obj) = do
204 204
  let errmsg = "Parsing cluster info"
205
  obj <- annotateResult errmsg $ asJSObject v
206
  tryFromObj errmsg (fromJSObject obj) "tags"
205
      obj' = fromJSObject obj
206
  ctags <- tryFromObj errmsg obj' "tags"
207
  cpol <- tryFromObj errmsg obj' "ipolicy"
208
  return (ctags, cpol)
209

  
210
getClusterData _ = Bad $ "Cannot parse cluster info, not a JSON record"
207 211

  
208 212
-- | Parses the cluster groups.
209 213
getGroups :: JSValue -> Result [(String, Group.Group)]
......
248 252
  let (node_names, node_idx) = assignIndices node_data
249 253
  inst_data <- instances >>= getInstances node_names
250 254
  let (_, inst_idx) = assignIndices inst_data
251
  ctags <- cinfo >>= getClusterTags
252
  return (ClusterData group_idx node_idx inst_idx ctags defIPolicy)
255
  (ctags, cpol) <- cinfo >>= getClusterData
256
  return (ClusterData group_idx node_idx inst_idx ctags cpol)
253 257

  
254 258
-- | Top level function for data loading.
255 259
loadData :: String -- ^ Unix socket to use as source

Also available in: Unified diff