Revision 8b5a517a htools/Ganeti/HTools/CLI.hs
b/htools/Ganeti/HTools/CLI.hs | ||
---|---|---|
8 | 8 |
|
9 | 9 |
{- |
10 | 10 |
|
11 |
Copyright (C) 2009, 2010, 2011 Google Inc. |
|
11 |
Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
|
|
12 | 12 |
|
13 | 13 |
This program is free software; you can redistribute it and/or modify |
14 | 14 |
it under the terms of the GNU General Public License as published by |
... | ... | |
31 | 31 |
( Options(..) |
32 | 32 |
, OptType |
33 | 33 |
, parseOpts |
34 |
, parseISpecString |
|
34 | 35 |
, shTemplate |
35 | 36 |
, defaultLuxiSocket |
36 | 37 |
, maybePrintNodes |
... | ... | |
187 | 188 |
parseISpecString :: String -> String -> Result RSpec |
188 | 189 |
parseISpecString descr inp = do |
189 | 190 |
let sp = sepSplit ',' inp |
191 |
err = Bad ("Invalid " ++ descr ++ " specification: '" ++ inp ++ |
|
192 |
"', expected disk,ram,cpu") |
|
193 |
when (length sp /= 3) err |
|
190 | 194 |
prs <- mapM (\(fn, val) -> fn val) $ |
191 |
zip [ annotateResult (descr ++ " specs memory") . parseUnit
|
|
192 |
, annotateResult (descr ++ " specs disk") . parseUnit
|
|
195 |
zip [ annotateResult (descr ++ " specs disk") . parseUnit
|
|
196 |
, annotateResult (descr ++ " specs memory") . parseUnit
|
|
193 | 197 |
, tryRead (descr ++ " specs cpus") |
194 | 198 |
] sp |
195 | 199 |
case prs of |
196 | 200 |
[dsk, ram, cpu] -> return $ RSpec cpu ram dsk |
197 |
_ -> Bad $ "Invalid " ++ descr ++ " specification: '" ++ inp ++ |
|
198 |
"', expected disk,ram,cpu" |
|
201 |
_ -> err |
|
199 | 202 |
|
200 | 203 |
-- * Command line options |
201 | 204 |
|
Also available in: Unified diff