Revision 3667467d htools/Ganeti/HTools/Rapi.hs
b/htools/Ganeti/HTools/Rapi.hs | ||
---|---|---|
97 | 97 |
getGroups body = loadJSArray "Parsing group data" body >>= |
98 | 98 |
mapM (parseGroup . fromJSObject) |
99 | 99 |
|
100 |
-- | Generates a fake group list. |
|
101 |
getFakeGroups :: Result [(String, Group.Group)] |
|
102 |
getFakeGroups = |
|
103 |
return [(defaultGroupID, |
|
104 |
Group.create "default" defaultGroupID AllocPreferred)] |
|
105 |
|
|
106 | 100 |
-- | Construct an instance from a JSON object. |
107 | 101 |
parseInstance :: NameAssoc |
108 | 102 |
-> JSRecord |
... | ... | |
178 | 172 |
parseData :: (Result String, Result String, Result String, Result String) |
179 | 173 |
-> Result ClusterData |
180 | 174 |
parseData (group_body, node_body, inst_body, tags_body) = do |
181 |
group_data <- |
|
182 |
-- TODO: handle different ganeti versions properly, not via "all |
|
183 |
-- errors mean Ganeti 2.3" |
|
184 |
case group_body of |
|
185 |
Bad _ -> getFakeGroups |
|
186 |
Ok v -> getGroups v |
|
175 |
group_data <- group_body >>= getGroups |
|
187 | 176 |
let (group_names, group_idx) = assignIndices group_data |
188 | 177 |
node_data <- node_body >>= getNodes group_names |
189 | 178 |
let (node_names, node_idx) = assignIndices node_data |
Also available in: Unified diff