Revision da4a52a3 src/Ganeti/Config.hs
b/src/Ganeti/Config.hs | ||
---|---|---|
171 | 171 |
(nodeName . (M.!) nodes) nodes |
172 | 172 |
in getItem "Node" name by_name |
173 | 173 |
|
174 |
-- | Looks up an instance. |
|
174 |
-- | Looks up an instance by name or uuid.
|
|
175 | 175 |
getInstance :: ConfigData -> String -> ErrorResult Instance |
176 | 176 |
getInstance cfg name = |
177 |
getItem "Instance" name (fromContainer $ configInstances cfg) |
|
177 |
let instances = fromContainer (configInstances cfg) |
|
178 |
in case getItem "Instance" name instances of |
|
179 |
-- if not found by uuid, we need to look it up by name |
|
180 |
Ok inst -> Ok inst |
|
181 |
Bad _ -> let by_name = M.mapKeys |
|
182 |
(instName . (M.!) instances) instances |
|
183 |
in getItem "Instance" name by_name |
|
178 | 184 |
|
179 |
-- | Looks up a node group. This is more tricky than for |
|
180 |
-- node/instances since the groups map is indexed by uuid, not name. |
|
185 |
-- | Looks up a node group by name or uuid. |
|
181 | 186 |
getGroup :: ConfigData -> String -> ErrorResult NodeGroup |
182 | 187 |
getGroup cfg name = |
183 | 188 |
let groups = fromContainer (configNodegroups cfg) |
... | ... | |
214 | 219 |
-- | Get (primary, secondary) instances of a given node group. |
215 | 220 |
getGroupInstances :: ConfigData -> String -> ([Instance], [Instance]) |
216 | 221 |
getGroupInstances cfg gname = |
217 |
let gnodes = map nodeName (getGroupNodes cfg gname)
|
|
222 |
let gnodes = map nodeUuid (getGroupNodes cfg gname)
|
|
218 | 223 |
ginsts = map (getNodeInstances cfg) gnodes in |
219 | 224 |
(concatMap fst ginsts, concatMap snd ginsts) |
220 | 225 |
|
Also available in: Unified diff