Commit 3277b56a authored by Jose A. Lopes's avatar Jose A. Lopes
Browse files

Fix 'IsInstanceRunning' to handle empty 'instance_info'



Instance info might return an empty dictionary in case the instance
does not exist.  Fix 'IsInstanceRunning' to handle that fact.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent ac2f0fb4
......@@ -1034,18 +1034,21 @@ def IsInstanceRunning(lu, instance, check_user_shutdown=False):
if instance.name not in instance_list.payload:
return False
if check_user_shutdown:
# One more check to be made - whether the instance was shutdown by the user
full_hvparams = lu.cfg.GetClusterInfo().FillHV(instance)
inst_info = lu.rpc.call_instance_info(pnode_uuid, instance.name,
instance.hypervisor, full_hvparams)
inst_info.Raise("Can't retrieve instance information for instance %s" %
instance.name, prereq=True, ecode=errors.ECODE_ENVIRON)
if not check_user_shutdown:
return True
# One more check to be made - whether the instance was shutdown by the user
full_hvparams = lu.cfg.GetClusterInfo().FillHV(instance)
inst_info = lu.rpc.call_instance_info(pnode_uuid, instance.name,
instance.hypervisor, full_hvparams)
inst_info.Raise("Can't retrieve instance information for instance %s" %
instance.name, prereq=True, ecode=errors.ECODE_ENVIRON)
if inst_info.payload:
return inst_info.payload["state"] != \
hypervisor.hv_base.HvInstanceState.SHUTDOWN
hypervisor.hv_base.HvInstanceState.SHUTDOWN
else:
return True
return False
def CheckInstanceState(lu, instance, req_states, msg=None):
......
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