Revision 525bfb36 htools/Ganeti/HTools/Loader.hs
b/htools/Ganeti/HTools/Loader.hs | ||
---|---|---|
1 |
{-| Generic data loader |
|
1 |
{-| Generic data loader.
|
|
2 | 2 |
|
3 | 3 |
This module holds the common code for parsing the input data after it |
4 | 4 |
has been loaded from external sources. |
... | ... | |
54 | 54 |
|
55 | 55 |
-- * Constants |
56 | 56 |
|
57 |
-- | The exclusion tag prefix |
|
57 |
-- | The exclusion tag prefix.
|
|
58 | 58 |
exTagsPrefix :: String |
59 | 59 |
exTagsPrefix = "htools:iextags:" |
60 | 60 |
|
... | ... | |
147 | 147 |
in Container.add sdx snew ac2 |
148 | 148 |
else ac2 |
149 | 149 |
|
150 |
-- | Remove non-selected tags from the exclusion list |
|
150 |
-- | Remove non-selected tags from the exclusion list.
|
|
151 | 151 |
filterExTags :: [String] -> Instance.Instance -> Instance.Instance |
152 | 152 |
filterExTags tl inst = |
153 | 153 |
let old_tags = Instance.tags inst |
... | ... | |
155 | 155 |
old_tags |
156 | 156 |
in inst { Instance.tags = new_tags } |
157 | 157 |
|
158 |
-- | Update the movable attribute |
|
158 |
-- | Update the movable attribute.
|
|
159 | 159 |
updateMovable :: [String] -- ^ Selected instances (if not empty) |
160 | 160 |
-> [String] -- ^ Excluded instances |
161 | 161 |
-> Instance.Instance -- ^ Target Instance |
... | ... | |
168 | 168 |
else inst |
169 | 169 |
|
170 | 170 |
-- | Compute the longest common suffix of a list of strings that |
171 |
-- | starts with a dot.
|
|
171 |
-- starts with a dot. |
|
172 | 172 |
longestDomain :: [String] -> String |
173 | 173 |
longestDomain [] = "" |
174 | 174 |
longestDomain (x:xs) = |
... | ... | |
177 | 177 |
else accu) |
178 | 178 |
"" $ filter (isPrefixOf ".") (tails x) |
179 | 179 |
|
180 |
-- | Extracts the exclusion tags from the cluster configuration |
|
180 |
-- | Extracts the exclusion tags from the cluster configuration.
|
|
181 | 181 |
extractExTags :: [String] -> [String] |
182 | 182 |
extractExTags = |
183 | 183 |
map (drop (length exTagsPrefix)) . |
184 | 184 |
filter (isPrefixOf exTagsPrefix) |
185 | 185 |
|
186 |
-- | Extracts the common suffix from node\/instance names |
|
186 |
-- | Extracts the common suffix from node\/instance names.
|
|
187 | 187 |
commonSuffix :: Node.List -> Instance.List -> String |
188 | 188 |
commonSuffix nl il = |
189 | 189 |
let node_names = map Node.name $ Container.elems nl |
Also available in: Unified diff