Revision e7724ccc
b/Ganeti/HTools/Container.hs | ||
---|---|---|
105 | 105 |
|
106 | 106 |
-- | Find an element by name in a Container; this is a very slow function. |
107 | 107 |
findByName :: (T.Element a, Monad m) => |
108 |
Container a -> String -> m Key
|
|
108 |
Container a -> String -> m a
|
|
109 | 109 |
findByName c n = |
110 | 110 |
let all_elems = elems c |
111 | 111 |
result = filter ((== n) . T.nameOf) all_elems |
112 |
nems = length result |
|
113 |
in |
|
114 |
if nems /= 1 then |
|
115 |
fail $ "Wrong number of elems (" ++ show nems ++ |
|
116 |
") found with name " ++ n |
|
117 |
else |
|
118 |
return $ T.idxOf $ head result |
|
112 |
in case result of |
|
113 |
[item] -> return item |
|
114 |
_ -> fail $ "Wrong number of elems found with name " ++ n |
b/Ganeti/HTools/IAlloc.hs | ||
---|---|---|
126 | 126 |
ex_nodes <- fromObj "relocate_from" request |
127 | 127 |
let ex_nodes' = map (stripSuffix $ length csf) ex_nodes |
128 | 128 |
ex_idex <- mapM (Container.findByName map_n) ex_nodes' |
129 |
return $ Relocate ridx req_nodes ex_idex
|
|
129 |
return $ Relocate ridx req_nodes (map Node.idx ex_idex)
|
|
130 | 130 |
other -> fail ("Invalid request type '" ++ other ++ "'") |
131 | 131 |
return $ Request rqtype map_n map_i csf |
132 | 132 |
|
b/Ganeti/HTools/Loader.hs | ||
---|---|---|
139 | 139 |
mergeData um (nl, il) = do |
140 | 140 |
let il2 = Container.fromAssocList il |
141 | 141 |
il3 <- foldM (\im (name, n_util) -> do |
142 |
idx <- Container.findByName im name |
|
143 |
let inst = Container.find idx im |
|
144 |
new_i = inst { Instance.util = n_util } |
|
145 |
return $ Container.add idx new_i im |
|
142 |
inst <- Container.findByName im name |
|
143 |
let new_i = inst { Instance.util = n_util } |
|
144 |
return $ Container.add (Instance.idx inst) new_i im |
|
146 | 145 |
) il2 um |
147 | 146 |
let nl2 = foldl' fixNodes nl (Container.elems il3) |
148 | 147 |
let nl3 = Container.fromAssocList |
Also available in: Unified diff