Revision 5850e990 htools/Ganeti/HTools/Utils.hs
b/htools/Ganeti/HTools/Utils.hs | ||
---|---|---|
2 | 2 |
|
3 | 3 |
{- |
4 | 4 |
|
5 |
Copyright (C) 2009, 2010, 2011 Google Inc. |
|
5 |
Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
|
|
6 | 6 |
|
7 | 7 |
This program is free software; you can redistribute it and/or modify |
8 | 8 |
it under the terms of the GNU General Public License as published by |
... | ... | |
40 | 40 |
|
41 | 41 |
import Data.Char (toUpper) |
42 | 42 |
import Data.List |
43 |
import Data.Ratio ((%)) |
|
44 | 43 |
|
45 | 44 |
import Debug.Trace |
46 | 45 |
|
... | ... | |
178 | 177 |
| unit == "T" || upper == "TB" = return $ mbFactor * kbDecimal * kbDecimal |
179 | 178 |
| otherwise = fail $ "Unknown unit '" ++ unit ++ "'" |
180 | 179 |
where upper = map toUpper unit |
181 |
kbBinary = 1024 |
|
182 |
kbDecimal = 1000 |
|
180 |
kbBinary = 1024 :: Rational
|
|
181 |
kbDecimal = 1000 :: Rational
|
|
183 | 182 |
decToBin = kbDecimal / kbBinary -- factor for 1K conversion |
184 | 183 |
mbFactor = decToBin * decToBin -- twice the factor for just 1K |
185 | 184 |
|
Also available in: Unified diff