Revision 66d67ad4

b/hbal.hs
1
{-| Solver for N+1 cluster errors
1
{-| Cluster rebalancer
2 2

  
3 3
-}
4 4

  
......
57 57
    , optVerbose   :: Int            -- ^ Verbosity level
58 58
    , optOffline   :: [String]       -- ^ Names of offline nodes
59 59
    , optMinScore  :: Cluster.Score  -- ^ The minimum score we aim for
60
    , optMcpu      :: Double         -- ^ Max cpu ratio for nodes
61
    , optMdsk      :: Double         -- ^ Max disk usage ratio for nodes
60 62
    , optShowVer   :: Bool           -- ^ Just show the program version
61 63
    , optShowHelp  :: Bool           -- ^ Just show the help
62 64
    } deriving Show
......
88 90
 , optVerbose   = 1
89 91
 , optOffline   = []
90 92
 , optMinScore  = 1e-9
93
 , optMcpu      = -1
94
 , optMdsk      = -1
91 95
 , optShowVer   = False
92 96
 , optShowHelp  = False
93 97
 }
......
132 136
    , Option ['e']     ["min-score"]
133 137
      (ReqArg (\ e opts -> opts { optMinScore = read e }) "EPSILON")
134 138
      " mininum score to aim for"
139
    , Option []        ["max-cpu"]
140
      (ReqArg (\ n opts -> opts { optMcpu = read n }) "RATIO")
141
      "maximum virtual-to-physical cpu ratio for nodes"
142
    , Option []        ["max-disk"]
143
      (ReqArg (\ n opts -> opts { optMdsk = read n }) "RATIO")
144
      "minimum free disk space for nodes (between 0 and 1)"
135 145
    , Option ['V']     ["version"]
136 146
      (NoArg (\ opts -> opts { optShowVer = True}))
137 147
      "show the version of the program"
......
210 220
      offline_indices = map Node.idx $
211 221
                        filter (\n -> elem (Node.name n) offline_names)
212 222
                               all_nodes
223
      m_cpu = optMcpu opts
224
      m_dsk = optMdsk opts
213 225

  
214 226
  when (length offline_wrong > 0) $ do
215 227
         printf "Wrong node name(s) set as offline: %s\n"
216 228
                (commaJoin offline_wrong)
217 229
         exitWith $ ExitFailure 1
218 230

  
219
  let nl = Container.map (\n -> if elem (Node.idx n) offline_indices
231
  let nm = Container.map (\n -> if elem (Node.idx n) offline_indices
220 232
                                then Node.setOffline n True
221 233
                                else n) fixed_nl
234
      nl = Container.map (flip Node.setMdsk m_dsk . flip Node.setMcpu m_cpu)
235
           nm
222 236

  
223 237
  when (Container.size il == 0) $ do
224 238
         (if oneline then putStrLn $ formatOneline 0 0 0

Also available in: Unified diff