Commit cd43c8bd by Guba Sándor

instance/node: fixed monitoring for missin vms

parent e056cb01
......@@ -286,8 +286,13 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
def vm_state_changed(self, new_state):
try:
act = InstanceActivity.create(code_suffix='vm_state_changed',
instance=self)
act = InstanceActivity.create(
code_suffix='monitor_event_%s' % new_state,
instance=self)
if new_state == "STOPPED":
self.vnc_port = None
self.node = None
self.save()
except ActivityInProgressError:
pass # discard state change if another activity is in progress.
else:
......
......@@ -194,6 +194,8 @@ class Node(TimeStampedModel):
except KeyError:
logger.info('Node %s update: instance %s missing from '
'libvirt', self, i['id'])
# Set state to STOPPED when instance is missing
self.instance_set.get(id=i['id']).vm_state_changed('STOPPED')
else:
if d != i['state']:
logger.info('Node %s update: instance %s state changed '
......
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 sign in to comment