Commit 8a8ed513 authored by Agata Murawska's avatar Agata Murawska
Browse files

htools: remove 'running' from instance options


Signed-off-by: default avatarAgata Murawska <agatamurawska@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 7dd14211
......@@ -1225,7 +1225,7 @@ computeMoves i inam mv c d =
ReplaceSecondary _ -> (printf "r:%s" d, [rep d])
ReplaceAndFailover _ -> (printf "r:%s f" c, [rep c, mig])
ReplacePrimary _ -> (printf "f r:%s f" c, [mig, rep c, mig])
where morf = if Instance.running i then "migrate" else "failover"
where morf = if Instance.instanceRunning i then "migrate" else "failover"
mig = printf "%s -f %s" morf inam::String
rep n = printf "replace-disks -n %s %s" n inam
......@@ -1325,7 +1325,7 @@ printNodes nl fs =
printInsts :: Node.List -> Instance.List -> String
printInsts nl il =
let sil = sortBy (comparing Instance.idx) (Container.elems il)
helper inst = [ if Instance.running inst then "R" else " "
helper inst = [ if Instance.instanceRunning inst then "R" else " "
, Instance.name inst
, Container.nameOf nl (Instance.pNode inst)
, let sdx = Instance.sNode inst
......
......@@ -31,6 +31,7 @@ module Ganeti.HTools.Instance
, AssocList
, List
, create
, instanceRunning
, setIdx
, setName
, setAlias
......@@ -40,7 +41,6 @@ module Ganeti.HTools.Instance
, setMovable
, specOf
, shrinkByType
, runningStates
, localStorageTemplates
, hasSecondary
, requiredNodes
......@@ -61,7 +61,6 @@ data Instance = Instance
, mem :: Int -- ^ Memory of the instance
, dsk :: Int -- ^ Disk size of instance
, vcpus :: Int -- ^ Number of VCPUs
, running :: Bool -- ^ Is the instance running?
, runSt :: T.InstanceStatus -- ^ Original run status
, pNode :: T.Ndx -- ^ Original primary node
, sNode :: T.Ndx -- ^ Original secondary node
......@@ -80,9 +79,11 @@ instance T.Element Instance where
setIdx = setIdx
allNames n = [name n, alias n]
-- | Constant holding the running instance states.
runningStates :: [T.InstanceStatus]
runningStates = [T.Running, T.ErrorUp]
-- | Check if instance is running.
instanceRunning :: Instance -> Bool
instanceRunning (Instance {runSt = T.Running}) = True
instanceRunning (Instance {runSt = T.ErrorUp}) = True
instanceRunning _ = False
-- | Constant holding the local storage templates.
--
......@@ -124,7 +125,6 @@ create name_init mem_init dsk_init vcpus_init run_init tags_init
, mem = mem_init
, dsk = dsk_init
, vcpus = vcpus_init
, running = run_init `elem` runningStates
, runSt = run_init
, pNode = pn
, sNode = sn
......
......@@ -306,7 +306,7 @@ checkData nl il =
(\ msgs node ->
let nname = Node.name node
nilst = map (`Container.find` il) (Node.pList node)
dilst = filter (not . Instance.running) nilst
dilst = filter (not . Instance.instanceRunning) nilst
adj_mem = sum . map Instance.mem $ dilst
delta_mem = truncate (Node.tMem node)
- Node.nMem node
......
......@@ -513,17 +513,6 @@ prop_Instance_setBoth inst pdx sdx =
where _types = (inst::Instance.Instance, pdx::Types.Ndx, sdx::Types.Ndx)
si = Instance.setBoth inst pdx sdx
prop_Instance_runStatus_True =
forAll (arbitrary `suchThat`
((`elem` Instance.runningStates) . Instance.runSt))
Instance.running
prop_Instance_runStatus_False inst =
let run_st = Instance.running inst
run_tx = Instance.runSt inst
in
run_tx `notElem` Instance.runningStates ==> not run_st
prop_Instance_shrinkMG inst =
Instance.mem inst >= 2 * Types.unitMem ==>
case Instance.shrinkByType inst Types.FailMem of
......@@ -572,8 +561,6 @@ testSuite "Instance"
, 'prop_Instance_setPri
, 'prop_Instance_setSec
, 'prop_Instance_setBoth
, 'prop_Instance_runStatus_True
, 'prop_Instance_runStatus_False
, 'prop_Instance_shrinkMG
, 'prop_Instance_shrinkMF
, 'prop_Instance_shrinkCG
......
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