Commit 6b0da54a by Bach Dániel Committed by Őry Máté

vm: fix disappearing vnc port + node

parent 041646aa
......@@ -389,16 +389,15 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
except ActivityInProgressError:
pass # discard state change if another activity is in progress.
if new_state == 'STOPPED':
self.vnc_port = None
self.node = None
act.finished = act.started
act.resultant_state = new_state
act.succeeded = True
if new_state == 'STOPPED':
self.vnc_port = None
self.node = None
def get_absolute_url(self):
return ('dashboard.views.detail', None, {'pk':})
from django.test import TestCase
from mock import Mock
from mock import Mock, MagicMock, patch
from ..models.common import (
from ..models.instance import (
find_unused_port, InstanceTemplate, Instance
find_unused_port, InstanceTemplate, Instance, ActivityInProgressError
from import (
......@@ -39,6 +39,17 @@ class InstanceTestCase(TestCase):
inst = Mock(state='RUNNING')
assert Instance.is_running.getter(inst)
def test_mon_stopped_while_activity_running(self):
node = Mock()
port = Mock()
inst = MagicMock(spec=Instance, node=node, vnc_port=port) = AssertionError
with patch('vm.models.instance.InstanceActivity') as ia:
ia.create.side_effect = ActivityInProgressError(MagicMock())
Instance.vm_state_changed(inst, 'STOPPED')
self.assertEquals(inst.node, node)
self.assertEquals(inst.vnc_port, port)
class InterfaceTestCase(TestCase):
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