Revision 179c0828 htools/Ganeti/HTools/Program/Hbal.hs

b/htools/Ganeti/HTools/Program/Hbal.hs
54 54
import qualified Ganeti.Luxi as L
55 55
import Ganeti.Jobs
56 56

  
57
-- | Options list and functions
57
-- | Options list and functions.
58 58
options :: [OptType]
59 59
options =
60 60
    [ oPrintNodes
......
133 133
                           mg_limit min_gain evac_mode
134 134
        Nothing -> return (ini_tbl, cmd_strs)
135 135

  
136
-- | Formats the solution for the oneline display
136
-- | Formats the solution for the oneline display.
137 137
formatOneline :: Double -> Int -> Double -> String
138 138
formatOneline ini_cv plc_len fin_cv =
139 139
    printf "%.8f %d %.8f %8.3f" ini_cv plc_len fin_cv
140 140
               (if fin_cv == 0 then 1 else ini_cv / fin_cv)
141 141

  
142 142
-- | Polls a set of jobs at a fixed interval until all are finished
143
-- one way or another
143
-- one way or another.
144 144
waitForJobs :: L.Client -> [String] -> IO (Result [JobStatus])
145 145
waitForJobs client jids = do
146 146
  sts <- L.queryJobsStatus client jids
......
153 153
              waitForJobs client jids
154 154
            else return $ Ok s
155 155

  
156
-- | Check that a set of job statuses is all success
156
-- | Check that a set of job statuses is all success.
157 157
checkJobsStatus :: [JobStatus] -> Bool
158 158
checkJobsStatus = all (== JOB_STATUS_SUCCESS)
159 159

  
160
-- | Wrapper over execJobSet checking for early termination
160
-- | Wrapper over execJobSet checking for early termination.
161 161
execWrapper :: String -> Node.List
162 162
           -> Instance.List -> IORef Int -> [JobSet] -> IO Bool
163 163
execWrapper _      _  _  _    [] = return True
......
170 170
     return False
171 171
   else execJobSet master nl il cref alljss)
172 172

  
173
-- | Execute an entire jobset
173
-- | Execute an entire jobset.
174 174
execJobSet :: String -> Node.List
175 175
           -> Instance.List -> IORef Int -> [JobSet] -> IO Bool
176 176
execJobSet _      _  _  _    [] = return True
......
201 201
               hPutStrLn stderr "Aborting."
202 202
               return False)
203 203

  
204
-- | Signal handler for graceful termination
204
-- | Signal handler for graceful termination.
205 205
hangleSigInt :: IORef Int -> IO ()
206 206
hangleSigInt cref = do
207 207
  writeIORef cref 1
208 208
  putStrLn ("Cancel request registered, will exit at" ++
209 209
            " the end of the current job set...")
210 210

  
211
-- | Signal handler for immediate termination
211
-- | Signal handler for immediate termination.
212 212
hangleSigTerm :: IORef Int -> IO ()
213 213
hangleSigTerm cref = do
214 214
  -- update the cref to 2, just for consistency
......
216 216
  putStrLn "Double cancel request, exiting now..."
217 217
  exitImmediately $ ExitFailure 2
218 218

  
219
-- | Runs a job set with handling of signals.
219 220
runJobSet :: String -> Node.List -> Instance.List -> [JobSet] -> IO Bool
220 221
runJobSet master fin_nl il cmd_jobs = do
221 222
  cref <- newIORef 0

Also available in: Unified diff