Revision 7e7f6ca2
b/Ganeti/HTools/Cluster.hs | ||
---|---|---|
85 | 85 |
data Table = Table NodeList InstanceList Score [Placement] |
86 | 86 |
deriving (Show) |
87 | 87 |
|
88 |
-- | Constant node index for a non-moveable instance |
|
89 |
noSecondary :: Int |
|
90 |
noSecondary = -1 |
|
91 |
|
|
88 | 92 |
-- General functions |
89 | 93 |
|
90 | 94 |
-- | Cap the removal list if needed. |
... | ... | |
475 | 479 |
-- iterate over all instances, computing the best move |
476 | 480 |
best_tbl = |
477 | 481 |
foldl' |
478 |
(\ step_tbl elem -> compareTables step_tbl $ |
|
479 |
checkInstanceMove nodes_idx ini_tbl elem) |
|
482 |
(\ step_tbl elem -> |
|
483 |
if Instance.snode elem == noSecondary then step_tbl |
|
484 |
else compareTables step_tbl $ |
|
485 |
checkInstanceMove nodes_idx ini_tbl elem) |
|
480 | 486 |
ini_tbl victims |
481 | 487 |
Table _ _ _ best_plc = best_tbl |
482 | 488 |
in |
... | ... | |
716 | 722 |
pdx = Instance.pnode inst |
717 | 723 |
sdx = Instance.snode inst |
718 | 724 |
pold = fromJust $ lookup pdx accu |
719 |
sold = fromJust $ lookup sdx accu |
|
720 | 725 |
pnew = Node.setPri pold idx |
721 |
snew = Node.setSec sold idx |
|
722 | 726 |
ac1 = deleteBy assocEqual (pdx, pold) accu |
723 |
ac2 = deleteBy assocEqual (sdx, sold) ac1 |
|
724 |
ac3 = (pdx, pnew):(sdx, snew):ac2 |
|
725 |
in ac3) nl il |
|
727 |
ac2 = (pdx, pnew):ac1 |
|
728 |
in |
|
729 |
if sdx /= noSecondary then |
|
730 |
let |
|
731 |
sold = fromJust $ lookup sdx accu |
|
732 |
snew = Node.setSec sold idx |
|
733 |
ac3 = deleteBy assocEqual (sdx, sold) ac2 |
|
734 |
ac4 = (sdx, snew):ac3 |
|
735 |
in ac4 |
|
736 |
else |
|
737 |
ac2 |
|
738 |
) nl il |
|
726 | 739 |
|
727 | 740 |
-- | Compute the longest common suffix of a NameList list that |
728 | 741 |
-- | starts with a dot |
... | ... | |
781 | 794 |
[(String, Int)] -> [String] -> m (String, Instance.Instance) |
782 | 795 |
loadInst ktn (name:mem:dsk:status:pnode:snode:[]) = do |
783 | 796 |
pidx <- lookupNode pnode name ktn |
784 |
sidx <- lookupNode snode name ktn |
|
797 |
sidx <- (if null snode then return noSecondary |
|
798 |
else lookupNode snode name ktn) |
|
785 | 799 |
vmem <- tryRead name mem |
786 | 800 |
vdsk <- tryRead name dsk |
787 | 801 |
when (sidx == pidx) $ fail $ "Instance " ++ name ++ |
Also available in: Unified diff