Skip to content
Snippets Groups Projects
Commit e3a684c5 authored by Iustin Pop's avatar Iustin Pop
Browse files

Remove ktn/kti from first half of loader

This patch removes the ktn/kti lists from most parts of the first half
of the loading sequence. Some remain as the [(String, Int)] is the
nicest way to lookup names and get indices back.
parent 8472a321
No related branches found
No related tags found
No related merge requests found
......@@ -101,7 +101,7 @@ parseData body = do
ridx <- lookupNode kti rname rname
return $ Relocate ridx
other -> fail $ ("Invalid request type '" ++ other ++ "'")
(map_n, map_i, csf) <- mergeData (ktn, nl, kti, il)
(map_n, map_i, csf) <- mergeData (nl, il)
return $ Request rqtype map_n map_i csf
formatResponse :: Bool -> String -> [String] -> String
......
......@@ -21,11 +21,6 @@ import qualified Ganeti.HTools.Node as Node
import Ganeti.HTools.Types
-- | Swap a list of @(a, b)@ into @(b, a)@
swapPairs :: [(a, b)] -> [(b, a)]
swapPairs = map (\ (a, b) -> (b, a))
-- | Lookups a node into an assoc list
lookupNode :: (Monad m) => NameAssoc -> String -> String -> m Int
lookupNode ktn inst node =
......@@ -82,12 +77,11 @@ stripSuffix sflen name = take ((length name) - sflen) name
{-| Initializer function that loads the data from a node and list file
and massages it into the correct format. -}
mergeData :: ([(String, Int)], Node.AssocList,
[(String, Int)], Instance.AssocList) -- ^ Data from either
-- Text.loadData
-- or Rapi.loadData
mergeData :: (Node.AssocList,
Instance.AssocList) -- ^ Data from either Text.loadData
-- or Rapi.loadData
-> Result (NodeList, InstanceList, String)
mergeData (ktn, nl, kti, il) = do
mergeData (nl, il) = do
let
nl2 = fixNodes nl il
il3 = Container.fromAssocList il
......
......@@ -84,8 +84,7 @@ parseNode a = do
return (name, node)
loadData :: String -- ^ Cluster/URL to use as source
-> IO (Result (NameAssoc, Node.AssocList,
NameAssoc, Instance.AssocList))
-> IO (Result (Node.AssocList, Instance.AssocList))
loadData master = do -- IO monad
let url = formatHost master
node_body <- getUrl $ printf "%s/2/nodes?bulk=1" url
......@@ -94,5 +93,5 @@ loadData master = do -- IO monad
node_data <- node_body >>= getNodes
let (node_names, node_idx) = assignIndices node_data
inst_data <- inst_body >>= getInstances node_names
let (inst_names, inst_idx) = assignIndices inst_data
return (node_names, node_idx, inst_names, inst_idx)
let (_, inst_idx) = assignIndices inst_data
return (node_idx, inst_idx)
......@@ -75,8 +75,7 @@ loadTabular text_data convert_fn = do
loadData :: String -- ^ Node data in string format
-> String -- ^ Instance data in string format
-> IO (Result (NameAssoc, Node.AssocList,
NameAssoc, Instance.AssocList))
-> IO (Result (Node.AssocList, Instance.AssocList))
loadData nfile ifile = do -- IO monad
ndata <- readFile nfile
idata <- readFile ifile
......@@ -84,5 +83,5 @@ loadData nfile ifile = do -- IO monad
{- node file: name t_mem n_mem f_mem t_disk f_disk -}
(ktn, nl) <- loadTabular ndata loadNode
{- instance file: name mem disk status pnode snode -}
(kti, il) <- loadTabular idata (loadInst ktn)
return (ktn, nl, kti, il)
(_, il) <- loadTabular idata (loadInst ktn)
return (nl, il)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment