Revision dd4c56ed src/hn1.hs
b/src/hn1.hs | ||
---|---|---|
17 | 17 |
import qualified Container |
18 | 18 |
import qualified Instance |
19 | 19 |
import qualified Cluster |
20 |
import Utils |
|
21 |
import Rapi |
|
20 | 22 |
|
21 | 23 |
-- | Command line options structure. |
22 | 24 |
data Options = Options |
... | ... | |
28 | 30 |
, optMaxRemovals :: Int |
29 | 31 |
, optMinDelta :: Int |
30 | 32 |
, optMaxDelta :: Int |
33 |
, optMaster :: String |
|
31 | 34 |
} deriving Show |
32 | 35 |
|
33 | 36 |
-- | Default values for the command line options. |
... | ... | |
41 | 44 |
, optMaxRemovals = -1 |
42 | 45 |
, optMinDelta = 0 |
43 | 46 |
, optMaxDelta = -1 |
47 |
, optMaster = "" |
|
44 | 48 |
} |
45 | 49 |
|
46 | 50 |
{- | Start computing the solution at the given depth and recurse until |
... | ... | |
99 | 103 |
, Option ['l'] ["min-delta"] |
100 | 104 |
(ReqArg (\ i opts -> opts { optMinDelta = (read i)::Int }) "L") |
101 | 105 |
"return once a solution with delta L or lower has been found" |
106 |
, Option ['m'] ["master"] |
|
107 |
(ReqArg (\ m opts -> opts { optMaster = m }) "ADDRESS") |
|
108 |
"collect data via RAPI at the given ADDRESS" |
|
102 | 109 |
] |
103 | 110 |
|
104 | 111 |
-- | Command line parser, using the 'options' structure. |
... | ... | |
117 | 124 |
cmd_args <- System.getArgs |
118 | 125 |
(opts, _) <- parseOpts cmd_args |
119 | 126 |
let min_depth = optMinDepth opts |
120 |
(nl, il, ktn, kti) <- liftM2 Cluster.loadData |
|
121 |
(readFile $ optNodef opts) |
|
122 |
(readFile $ optInstf opts) |
|
127 |
let (node_data, inst_data) = |
|
128 |
case optMaster opts of |
|
129 |
"" -> (readFile $ optNodef opts, |
|
130 |
readFile $ optInstf opts) |
|
131 |
host -> (readData getNodes host, |
|
132 |
readData getInstances host) |
|
133 |
|
|
134 |
(nl, il, ktn, kti) <- liftM2 Cluster.loadData node_data inst_data |
|
135 |
|
|
123 | 136 |
printf "Loaded %d nodes, %d instances\n" |
124 | 137 |
(Container.size nl) |
125 | 138 |
(Container.size il) |
Also available in: Unified diff