Revision 26b5d395
b/Ganeti/HTools/Loader.hs | ||
---|---|---|
79 | 79 |
else accu) |
80 | 80 |
"" $ filter (isPrefixOf ".") (tails x) |
81 | 81 |
|
82 |
-- | Remove tails from the (Int, String) lists |
|
83 |
stripSuffix :: String -> NameList -> NameList |
|
84 |
stripSuffix suffix lst = |
|
85 |
let sflen = length suffix in |
|
86 |
map (\ (key, name) -> (key, take ((length name) - sflen) name)) lst |
|
82 |
-- | Remove tail suffix from a string |
|
83 |
stripSuffix :: Int -> String -> String |
|
84 |
stripSuffix sflen name = take ((length name) - sflen) name |
|
87 | 85 |
|
88 | 86 |
{-| Initializer function that loads the data from a node and list file |
89 | 87 |
and massages it into the correct format. -} |
... | ... | |
101 | 99 |
xtn = swapPairs ktn |
102 | 100 |
xti = swapPairs kti |
103 | 101 |
common_suffix = longestDomain (xti ++ xtn) |
104 |
stn = stripSuffix common_suffix xtn |
|
105 |
sti = stripSuffix common_suffix xti |
|
106 |
return (nl3, il3, common_suffix, stn, sti) |
|
102 |
csl = length common_suffix |
|
103 |
stn = map (\(x, y) -> (x, stripSuffix csl y)) xtn |
|
104 |
sti = map (\(x, y) -> (x, stripSuffix csl y)) xti |
|
105 |
snl = Container.map (\n -> setName n (stripSuffix csl $ name n)) nl3 |
|
106 |
sil = Container.map (\i -> setName i (stripSuffix csl $ name i)) il3 |
|
107 |
return (snl, sil, common_suffix, stn, sti) |
|
107 | 108 |
|
108 | 109 |
-- | Check cluster data for consistency |
109 | 110 |
checkData :: NodeList -> InstanceList -> NameList -> NameList |
Also available in: Unified diff