Commit 9cd6c325 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add a helper function for 'not offline' instances


Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 00b70680
......@@ -33,6 +33,7 @@ module Ganeti.HTools.Instance
, create
, instanceRunning
, instanceOffline
, instanceNotOffline
, instanceDown
, applyIfOnline
, setIdx
......@@ -97,6 +98,11 @@ instanceOffline :: Instance -> Bool
instanceOffline (Instance {runSt = T.AdminOffline}) = True
instanceOffline _ = False
-- | Helper to check if the instance is not offline.
instanceNotOffline :: Instance -> Bool
instanceNotOffline = not . instanceOffline
-- | Check if instance is down.
instanceDown :: Instance -> Bool
instanceDown inst | instanceRunning inst = False
......@@ -106,7 +112,7 @@ instanceDown _ = True
-- | Apply the function if the instance is online. Otherwise use
-- the initial value
applyIfOnline :: Instance -> (a -> a) -> a -> a
applyIfOnline = applyIf . not . instanceOffline
applyIfOnline = applyIf . instanceNotOffline
-- | Constant holding the local storage templates.
--
......
......@@ -341,7 +341,7 @@ nodeImem :: Node.Node -> Instance.List -> Int
nodeImem node il =
let rfind = flip Container.find il
il' = map rfind $ Node.pList node
oil' = filter (not . Instance.instanceOffline) il'
oil' = filter Instance.instanceNotOffline il'
in sum . map Instance.mem $ oil'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment