Revision e3a684c5
b/Ganeti/HTools/IAlloc.hs | ||
---|---|---|
101 | 101 |
ridx <- lookupNode kti rname rname |
102 | 102 |
return $ Relocate ridx |
103 | 103 |
other -> fail $ ("Invalid request type '" ++ other ++ "'") |
104 |
(map_n, map_i, csf) <- mergeData (ktn, nl, kti, il)
|
|
104 |
(map_n, map_i, csf) <- mergeData (nl, il)
|
|
105 | 105 |
return $ Request rqtype map_n map_i csf |
106 | 106 |
|
107 | 107 |
formatResponse :: Bool -> String -> [String] -> String |
b/Ganeti/HTools/Loader.hs | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import Ganeti.HTools.Types |
23 | 23 |
|
24 |
|
|
25 |
-- | Swap a list of @(a, b)@ into @(b, a)@ |
|
26 |
swapPairs :: [(a, b)] -> [(b, a)] |
|
27 |
swapPairs = map (\ (a, b) -> (b, a)) |
|
28 |
|
|
29 | 24 |
-- | Lookups a node into an assoc list |
30 | 25 |
lookupNode :: (Monad m) => NameAssoc -> String -> String -> m Int |
31 | 26 |
lookupNode ktn inst node = |
... | ... | |
82 | 77 |
|
83 | 78 |
{-| Initializer function that loads the data from a node and list file |
84 | 79 |
and massages it into the correct format. -} |
85 |
mergeData :: ([(String, Int)], Node.AssocList, |
|
86 |
[(String, Int)], Instance.AssocList) -- ^ Data from either |
|
87 |
-- Text.loadData |
|
88 |
-- or Rapi.loadData |
|
80 |
mergeData :: (Node.AssocList, |
|
81 |
Instance.AssocList) -- ^ Data from either Text.loadData |
|
82 |
-- or Rapi.loadData |
|
89 | 83 |
-> Result (NodeList, InstanceList, String) |
90 |
mergeData (ktn, nl, kti, il) = do
|
|
84 |
mergeData (nl, il) = do
|
|
91 | 85 |
let |
92 | 86 |
nl2 = fixNodes nl il |
93 | 87 |
il3 = Container.fromAssocList il |
b/Ganeti/HTools/Rapi.hs | ||
---|---|---|
84 | 84 |
return (name, node) |
85 | 85 |
|
86 | 86 |
loadData :: String -- ^ Cluster/URL to use as source |
87 |
-> IO (Result (NameAssoc, Node.AssocList, |
|
88 |
NameAssoc, Instance.AssocList)) |
|
87 |
-> IO (Result (Node.AssocList, Instance.AssocList)) |
|
89 | 88 |
loadData master = do -- IO monad |
90 | 89 |
let url = formatHost master |
91 | 90 |
node_body <- getUrl $ printf "%s/2/nodes?bulk=1" url |
... | ... | |
94 | 93 |
node_data <- node_body >>= getNodes |
95 | 94 |
let (node_names, node_idx) = assignIndices node_data |
96 | 95 |
inst_data <- inst_body >>= getInstances node_names |
97 |
let (inst_names, inst_idx) = assignIndices inst_data |
|
98 |
return (node_names, node_idx, inst_names, inst_idx) |
|
96 |
let (_, inst_idx) = assignIndices inst_data |
|
97 |
return (node_idx, inst_idx) |
b/Ganeti/HTools/Text.hs | ||
---|---|---|
75 | 75 |
|
76 | 76 |
loadData :: String -- ^ Node data in string format |
77 | 77 |
-> String -- ^ Instance data in string format |
78 |
-> IO (Result (NameAssoc, Node.AssocList, |
|
79 |
NameAssoc, Instance.AssocList)) |
|
78 |
-> IO (Result (Node.AssocList, Instance.AssocList)) |
|
80 | 79 |
loadData nfile ifile = do -- IO monad |
81 | 80 |
ndata <- readFile nfile |
82 | 81 |
idata <- readFile ifile |
... | ... | |
84 | 83 |
{- node file: name t_mem n_mem f_mem t_disk f_disk -} |
85 | 84 |
(ktn, nl) <- loadTabular ndata loadNode |
86 | 85 |
{- instance file: name mem disk status pnode snode -} |
87 |
(kti, il) <- loadTabular idata (loadInst ktn) |
|
88 |
return (ktn, nl, kti, il) |
|
86 |
(_, il) <- loadTabular idata (loadInst ktn) |
|
87 |
return (nl, il) |
Also available in: Unified diff