Revision 268fb0bd

b/src/Ganeti/HTools/Program/Hsqueeze.hs
35 35
import Data.List
36 36
import Data.Maybe
37 37
import qualified Data.IntMap as IntMap
38
import Text.Printf (printf)
38 39

  
39 40
import Ganeti.BasicTypes
40 41
import Ganeti.Common
......
58 59
    , oMinResources
59 60
    , oTargetResources
60 61
    , oSaveCluster
62
    , oPrintCommands
61 63
    , oVerbose
62 64
    , oNoHeaders
63 65
    ]
......
218 220
      targetInstance = instanceFromSpecAndFactor "targetInstance" targetf std
219 221
      minInstance = instanceFromSpecAndFactor "targetInstance" minf std
220 222
      toOffline = greedyOfflineNodes targetInstance conf offlineCandidates
221
      (fin_off_nl, fin_off_il) =
222
        fst $ offlineNodes (map Node.idx toOffline) conf
223
      ((fin_off_nl, fin_off_il), off_mvs) =
224
        offlineNodes (map Node.idx toOffline) conf
223 225
      final_off_cdata =
224 226
        ini_cdata { cdNodes = fin_off_nl, cdInstances = fin_off_il }
227
      off_jobs = Cluster.splitJobs off_mvs
228
      off_cmd =
229
        Cluster.formatCmds off_jobs
230
        ++ "\necho Power Commands\n"
231
        ++ (toOffline >>= printf "  gnt-node power off -f %s\n" . Node.alias)
225 232
      toOnline = tryOnline minInstance conf onlineCandidates
226 233
      nodesToOnline = fromMaybe onlineCandidates toOnline
227
      (fin_on_nl, fin_on_il) =
228
        fst $ onlineNodes (map Node.idx nodesToOnline) conf
234
      ((fin_on_nl, fin_on_il), on_mvs) =
235
        onlineNodes (map Node.idx nodesToOnline) conf
229 236
      final_on_cdata =
230 237
        ini_cdata { cdNodes = fin_on_nl, cdInstances = fin_on_il }
238
      on_jobs = Cluster.splitJobs on_mvs
239
      on_cmd =
240
        "echo Power Commands\n"
241
        ++ (nodesToOnline >>= printf "  gnt-node power on -f %s\n" . Node.alias)
242
        ++ Cluster.formatCmds on_jobs
231 243

  
232 244
  when (verbose > 1) . putStrLn 
233 245
    $ "Offline candidates: " ++ commaJoin (map Node.name offlineCandidates)
......
242 254
      mapM_ (putStrLn . Node.name) nodesToOnline
243 255
      when (verbose > 1 && isNothing toOnline) . putStrLn $
244 256
        "Onlining all nodes will not yield enough capacity"
257
      maybeSaveCommands "Commands to run:" opts on_cmd
245 258
      maybeSaveData (optSaveCluster opts)
246 259
         "squeezed" "after hsqueeze expansion" final_on_cdata
247 260
    else
......
249 262
        then do      
250 263
          unless (optNoHeaders opts) $
251 264
            putStrLn "'No action'"
265
          maybeSaveCommands "Commands to run:" opts "echo Nothing to do"
252 266
          maybeSaveData (optSaveCluster opts)
253 267
            "squeezed" "after hsqueeze doing nothing" ini_cdata
254 268
        else do
255 269
          unless (optNoHeaders opts) $
256 270
            putStrLn "'Nodes to offline'"
257

  
258 271
          mapM_ (putStrLn . Node.name) toOffline
259

  
272
          maybeSaveCommands "Commands to run:" opts off_cmd
260 273
          maybeSaveData (optSaveCluster opts)
261 274
            "squeezed" "after hsqueeze run" final_off_cdata

Also available in: Unified diff