Commit cd43c8bd by Guba Sándor

instance/node: fixed monitoring for missin vms

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