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

Strip the suffix from the names in the objects

This strips the suffix from the objects themselves, not only from the
ktn/kti vars.
parent b513faa1
No related branches found
No related tags found
No related merge requests found
...@@ -79,11 +79,9 @@ longestDomain ((_,x):xs) = ...@@ -79,11 +79,9 @@ longestDomain ((_,x):xs) =
else accu) else accu)
"" $ filter (isPrefixOf ".") (tails x) "" $ filter (isPrefixOf ".") (tails x)
-- | Remove tails from the (Int, String) lists -- | Remove tail suffix from a string
stripSuffix :: String -> NameList -> NameList stripSuffix :: Int -> String -> String
stripSuffix suffix lst = stripSuffix sflen name = take ((length name) - sflen) name
let sflen = length suffix in
map (\ (key, name) -> (key, take ((length name) - sflen) name)) lst
{-| Initializer function that loads the data from a node and list file {-| Initializer function that loads the data from a node and list file
and massages it into the correct format. -} and massages it into the correct format. -}
...@@ -101,9 +99,12 @@ mergeData (ktn, nl, kti, il) = do ...@@ -101,9 +99,12 @@ mergeData (ktn, nl, kti, il) = do
xtn = swapPairs ktn xtn = swapPairs ktn
xti = swapPairs kti xti = swapPairs kti
common_suffix = longestDomain (xti ++ xtn) common_suffix = longestDomain (xti ++ xtn)
stn = stripSuffix common_suffix xtn csl = length common_suffix
sti = stripSuffix common_suffix xti stn = map (\(x, y) -> (x, stripSuffix csl y)) xtn
return (nl3, il3, common_suffix, stn, sti) sti = map (\(x, y) -> (x, stripSuffix csl y)) xti
snl = Container.map (\n -> setName n (stripSuffix csl $ name n)) nl3
sil = Container.map (\i -> setName i (stripSuffix csl $ name i)) il3
return (snl, sil, common_suffix, stn, sti)
-- | Check cluster data for consistency -- | Check cluster data for consistency
checkData :: NodeList -> InstanceList -> NameList -> NameList checkData :: NodeList -> InstanceList -> NameList -> NameList
......
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