Revision 5850e990
b/htools/Ganeti/HTools/Cluster.hs | ||
---|---|---|
1260 | 1260 |
ReplacePrimary _ -> (printf "f r:%s f" c, [mig, rep c, mig]) |
1261 | 1261 |
where morf = if Instance.isRunning i then "migrate" else "failover" |
1262 | 1262 |
mig = printf "%s -f %s" morf inam::String |
1263 |
mig_any = printf "%s -f -n %s %s" morf c inam |
|
1264 |
rep n = printf "replace-disks -n %s %s" n inam |
|
1263 |
mig_any = printf "%s -f -n %s %s" morf c inam::String
|
|
1264 |
rep n = printf "replace-disks -n %s %s" n inam::String
|
|
1265 | 1265 |
|
1266 | 1266 |
-- | Converts a placement to string format. |
1267 | 1267 |
printSolutionLine :: Node.List -- ^ The node list |
... | ... | |
1285 | 1285 |
(moves, cmds) = computeMoves inst inam mv npri nsec |
1286 | 1286 |
-- FIXME: this should check instead/also the disk template |
1287 | 1287 |
ostr = if old_sec == Node.noSecondary |
1288 |
then printf "%s" opri |
|
1289 |
else printf "%s:%s" opri osec |
|
1288 |
then printf "%s" opri::String
|
|
1289 |
else printf "%s:%s" opri osec::String
|
|
1290 | 1290 |
nstr = if s == Node.noSecondary |
1291 |
then printf "%s" npri |
|
1292 |
else printf "%s:%s" npri nsec |
|
1291 |
then printf "%s" npri::String
|
|
1292 |
else printf "%s:%s" npri nsec::String
|
|
1293 | 1293 |
in (printf " %3d. %-*s %-*s => %-*s %12.8f a=%s" |
1294 |
pos imlen inam pmlen (ostr::String) |
|
1295 |
pmlen (nstr::String) c moves, |
|
1294 |
pos imlen inam pmlen ostr pmlen nstr c moves, |
|
1296 | 1295 |
cmds) |
1297 | 1296 |
|
1298 | 1297 |
-- | Return the instance and involved nodes in an instance move. |
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