Revision 41044e04 src/Ganeti/HTools/Instance.hs
b/src/Ganeti/HTools/Instance.hs | ||
---|---|---|
279 | 279 |
| vcpus inst < T.iSpecCpuCount ispec = Bad T.FailCPU |
280 | 280 |
| otherwise = Ok () |
281 | 281 |
|
282 |
-- | Checks if an instance matches a min/max specs pair |
|
283 |
instMatchesMinMaxSpecs :: Instance -> T.MinMaxISpecs -> T.OpResult () |
|
284 |
instMatchesMinMaxSpecs inst minmax = do |
|
285 |
instAboveISpec inst (T.minMaxISpecsMinSpec minmax) |
|
286 |
instBelowISpec inst (T.minMaxISpecsMaxSpec minmax) |
|
287 |
|
|
288 |
-- | Checks if an instance matches any specs of a policy |
|
289 |
instMatchesSpecs :: Instance -> [T.MinMaxISpecs] -> T.OpResult () |
|
290 |
-- Return Ok for no constraints, though this should never happen |
|
291 |
instMatchesSpecs _ [] = Ok () |
|
292 |
instMatchesSpecs inst (minmax:minmaxes) = |
|
293 |
foldr eithermatch (instMatchesMinMaxSpecs inst minmax) minmaxes |
|
294 |
where eithermatch mm (Bad _) = instMatchesMinMaxSpecs inst mm |
|
295 |
eithermatch _ y@(Ok ()) = y |
|
296 |
-- # See 04f231771 |
|
297 |
|
|
282 | 298 |
-- | Checks if an instance matches a policy. |
283 | 299 |
instMatchesPolicy :: Instance -> T.IPolicy -> T.OpResult () |
284 | 300 |
instMatchesPolicy inst ipol = do |
285 |
let minmax = T.iPolicyMinMaxISpecs ipol |
|
286 |
instAboveISpec inst (T.minMaxISpecsMinSpec minmax) |
|
287 |
instBelowISpec inst (T.minMaxISpecsMaxSpec minmax) |
|
301 |
instMatchesSpecs inst $ T.iPolicyMinMaxISpecs ipol |
|
288 | 302 |
if diskTemplate inst `elem` T.iPolicyDiskTemplates ipol |
289 | 303 |
then Ok () |
290 | 304 |
else Bad T.FailDisk |
Also available in: Unified diff