Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6b0da54a
authored
Mar 16, 2014
by
Bach Dániel
Committed by
Őry Máté
Mar 17, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: fix disappearing vnc port + node
parent
041646aa
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
circle/vm/models/instance.py
+4
-5
circle/vm/tests/test_models.py
+13
-2
No files found.
circle/vm/models/instance.py
View file @
6b0da54a
...
@@ -389,15 +389,14 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -389,15 +389,14 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
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
:
act
.
finished
=
act
.
started
act
.
resultant_state
=
new_state
act
.
succeeded
=
True
act
.
save
()
if
new_state
==
'STOPPED'
:
if
new_state
==
'STOPPED'
:
self
.
vnc_port
=
None
self
.
vnc_port
=
None
self
.
node
=
None
self
.
node
=
None
self
.
save
()
self
.
save
()
act
.
finished
=
act
.
started
act
.
resultant_state
=
new_state
act
.
succeeded
=
True
act
.
save
()
@permalink
@permalink
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
...
...
circle/vm/tests/test_models.py
View file @
6b0da54a
from
django.test
import
TestCase
from
django.test
import
TestCase
from
mock
import
Mock
from
mock
import
Mock
,
MagicMock
,
patch
from
..models.common
import
(
from
..models.common
import
(
Lease
Lease
)
)
from
..models.instance
import
(
from
..models.instance
import
(
find_unused_port
,
InstanceTemplate
,
Instance
find_unused_port
,
InstanceTemplate
,
Instance
,
ActivityInProgressError
)
)
from
..models.network
import
(
from
..models.network
import
(
Interface
Interface
...
@@ -39,6 +39,17 @@ class InstanceTestCase(TestCase):
...
@@ -39,6 +39,17 @@ class InstanceTestCase(TestCase):
inst
=
Mock
(
state
=
'RUNNING'
)
inst
=
Mock
(
state
=
'RUNNING'
)
assert
Instance
.
is_running
.
getter
(
inst
)
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
)
inst
.
save
.
side_effect
=
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
):
class
InterfaceTestCase
(
TestCase
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment