Revision 61bbbed7 htools/Ganeti/HTools/Instance.hs

b/htools/Ganeti/HTools/Instance.hs
32 32
    , List
33 33
    , create
34 34
    , instanceRunning
35
    , instanceOffline
36
    , instanceDown
37
    , applyIfOnline
35 38
    , setIdx
36 39
    , setName
37 40
    , setAlias
......
52 55
import qualified Ganeti.HTools.Container as Container
53 56
import qualified Ganeti.Constants as C
54 57

  
58
import Ganeti.HTools.Utils
59

  
55 60
-- * Type declarations
56 61

  
57 62
-- | The instance type.
......
85 90
instanceRunning (Instance {runSt = T.ErrorUp}) = True
86 91
instanceRunning _                               = False
87 92

  
93
-- | Check if instance is offline.
94
instanceOffline :: Instance -> Bool
95
instanceOffline (Instance {runSt = T.AdminOffline}) = True
96
instanceOffline _                                    = False
97

  
98
-- | Check if instance is down.
99
instanceDown :: Instance -> Bool
100
instanceDown inst | instanceRunning inst = False
101
instanceDown inst | instanceOffline inst = False
102
instanceDown _                           = True
103

  
104
-- | Apply the function if the instance is online. Otherwise use
105
-- the initial value
106
applyIfOnline :: Instance -> (a -> a) -> a -> a
107
applyIfOnline = applyIf . not . instanceOffline
108

  
88 109
-- | Constant holding the local storage templates.
89 110
--
90 111
-- /Note:/ Currently Ganeti only exports node total/free disk space

Also available in: Unified diff