Revision 7959cbb9 htools/Ganeti/HTools/Instance.hs

b/htools/Ganeti/HTools/Instance.hs
31 31
  , AssocList
32 32
  , List
33 33
  , create
34
  , instanceRunning
35
  , instanceOffline
36
  , instanceNotOffline
34
  , isRunning
35
  , isOffline
36
  , notOffline
37 37
  , instanceDown
38 38
  , usesSecMem
39 39
  , applyIfOnline
......
89 89
  allNames n = [name n, alias n]
90 90

  
91 91
-- | Check if instance is running.
92
instanceRunning :: Instance -> Bool
93
instanceRunning (Instance {runSt = T.Running}) = True
94
instanceRunning (Instance {runSt = T.ErrorUp}) = True
95
instanceRunning _                              = False
92
isRunning :: Instance -> Bool
93
isRunning (Instance {runSt = T.Running}) = True
94
isRunning (Instance {runSt = T.ErrorUp}) = True
95
isRunning _                              = False
96 96

  
97 97
-- | Check if instance is offline.
98
instanceOffline :: Instance -> Bool
99
instanceOffline (Instance {runSt = T.AdminOffline}) = True
100
instanceOffline _                                   = False
98
isOffline :: Instance -> Bool
99
isOffline (Instance {runSt = T.AdminOffline}) = True
100
isOffline _                                   = False
101 101

  
102 102

  
103 103
-- | Helper to check if the instance is not offline.
104
instanceNotOffline :: Instance -> Bool
105
instanceNotOffline = not . instanceOffline
104
notOffline :: Instance -> Bool
105
notOffline = not . isOffline
106 106

  
107 107
-- | Check if instance is down.
108 108
instanceDown :: Instance -> Bool
109
instanceDown inst | instanceRunning inst = False
110
instanceDown inst | instanceOffline inst = False
111
instanceDown _                           = True
109
instanceDown inst | isRunning inst = False
110
instanceDown inst | isOffline inst = False
111
instanceDown _                     = True
112 112

  
113 113
-- | Apply the function if the instance is online. Otherwise use
114 114
-- the initial value
115 115
applyIfOnline :: Instance -> (a -> a) -> a -> a
116
applyIfOnline = applyIf . instanceNotOffline
116
applyIfOnline = applyIf . notOffline
117 117

  
118 118
-- | Helper for determining whether an instance's memory needs to be
119 119
-- taken into account for secondary memory reservation.
120 120
usesSecMem :: Instance -> Bool
121
usesSecMem inst = instanceNotOffline inst && autoBalance inst
121
usesSecMem inst = notOffline inst && autoBalance inst
122 122

  
123 123
-- | Constant holding the local storage templates.
124 124
--

Also available in: Unified diff