Revision 16670b57
b/htools/Ganeti/HTools/Cluster.hs | ||
---|---|---|
62 | 62 |
, genAllocNodes |
63 | 63 |
, tryAlloc |
64 | 64 |
, tryMGAlloc |
65 |
, tryReloc |
|
66 | 65 |
, tryNodeEvac |
67 | 66 |
, tryChangeGroup |
68 | 67 |
, collapseFailures |
... | ... | |
808 | 807 |
selmsg = "Selected group: " ++ group_name |
809 | 808 |
return $ solution { asLog = selmsg:all_msgs } |
810 | 809 |
|
811 |
-- | Try to relocate an instance on the cluster. |
|
812 |
tryReloc :: (Monad m) => |
|
813 |
Node.List -- ^ The node list |
|
814 |
-> Instance.List -- ^ The instance list |
|
815 |
-> Idx -- ^ The index of the instance to move |
|
816 |
-> Int -- ^ The number of nodes required |
|
817 |
-> [Ndx] -- ^ Nodes which should not be used |
|
818 |
-> m AllocSolution -- ^ Solution list |
|
819 |
tryReloc nl il xid 1 ex_idx = |
|
820 |
let all_nodes = getOnline nl |
|
821 |
inst = Container.find xid il |
|
822 |
ex_idx' = Instance.pNode inst:ex_idx |
|
823 |
valid_nodes = filter (not . flip elem ex_idx' . Node.idx) all_nodes |
|
824 |
valid_idxes = map Node.idx valid_nodes |
|
825 |
sols1 = foldl' (\cstate x -> |
|
826 |
let em = do |
|
827 |
(mnl, i, _, _) <- |
|
828 |
applyMove nl inst (ReplaceSecondary x) |
|
829 |
return (mnl, i, [Container.find x mnl], |
|
830 |
compCV mnl) |
|
831 |
in concatAllocs cstate em |
|
832 |
) emptyAllocSolution valid_idxes |
|
833 |
in return sols1 |
|
834 |
|
|
835 |
tryReloc _ _ _ reqn _ = fail $ "Unsupported number of relocation \ |
|
836 |
\destinations required (" ++ show reqn ++ |
|
837 |
"), only one supported" |
|
838 |
|
|
839 | 810 |
-- | Function which fails if the requested mode is change secondary. |
840 | 811 |
-- |
841 | 812 |
-- This is useful since except DRBD, no other disk template can |
Also available in: Unified diff