Revision 5b658b83 src/Ganeti/HTools/Program/Hroller.hs
b/src/Ganeti/HTools/Program/Hroller.hs | ||
---|---|---|
98 | 98 |
nonNullOnly = filter (not . null) |
99 | 99 |
in nonNullOnly (map (onlineOnly . byGroupOnly g) l) |
100 | 100 |
|
101 |
-- | Put the master node last. |
|
102 |
-- Reorder a list of lists of nodes such that the master node (if present) |
|
103 |
-- is the last node of the last group. |
|
104 |
masterLast :: [[Node.Node]] -> [[Node.Node]] |
|
105 |
masterLast rebootgroups = |
|
106 |
map (uncurry (++)) . uncurry (++) . partition (null . snd) $ |
|
107 |
map (partition (not . Node.isMaster)) rebootgroups |
|
108 |
|
|
101 | 109 |
-- | Main function. |
102 | 110 |
main :: Options -> [String] -> IO () |
103 | 111 |
main opts args = do |
... | ... | |
121 | 129 |
Just grp -> return (Just grp) |
122 | 130 |
|
123 | 131 |
-- TODO: fail if instances are running (with option to warn only) |
124 |
-- TODO: identify master node, and put it last |
|
125 | 132 |
|
126 | 133 |
nodeGraph <- case Node.mkNodeGraph nlf ilf of |
127 | 134 |
Nothing -> exitErr "Cannot create node graph" |
... | ... | |
138 | 145 |
(snd . minimumBy (comparing (IntMap.size . snd))) colorings |
139 | 146 |
idToNode = (`Container.find` nlf) |
140 | 147 |
nodesRebootGroups = map (map idToNode) $ IntMap.elems smallestColoring |
141 |
outputRebootGroups = filterOutput wantedGroup nodesRebootGroups |
|
148 |
outputRebootGroups = masterLast $ |
|
149 |
filterOutput wantedGroup nodesRebootGroups |
|
142 | 150 |
outputRebootNames = map (map Node.name) outputRebootGroups |
143 | 151 |
|
144 | 152 |
when (verbose > 1) . putStrLn $ getStats colorings |
Also available in: Unified diff