Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6fcdec33
authored
Mar 17, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-108' into 'master'
Issue 108
✅
#108 Renew on wake
parents
e73dbc54
4359b73c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
3 deletions
+45
-3
circle/dashboard/tests/test_views.py
+41
-1
circle/vm/models/instance.py
+4
-2
No files found.
circle/dashboard/tests/test_views.py
View file @
6fcdec33
...
...
@@ -10,7 +10,7 @@ from ..models import Profile
from
..views
import
VmRenewView
from
storage.models
import
Disk
from
firewall.models
import
Vlan
,
Host
,
VlanGroup
from
mock
import
Mock
from
mock
import
Mock
,
patch
import
django.conf
settings
=
django
.
conf
.
settings
.
FIREWALL_SETTINGS
...
...
@@ -481,6 +481,46 @@ class VmDetailTest(LoginMixin, TestCase):
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
Instance
.
objects
.
get
(
pk
=
1
)
.
name
,
'test123'
)
def
test_permitted_wake_up_wrong_state
(
self
):
c
=
Client
()
self
.
login
(
c
,
"user2"
)
with
patch
.
object
(
Instance
,
'wake_up_async'
)
as
mock_method
:
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
mock_method
.
side_effect
=
inst
.
wake_up
inst
.
manual_state_change
(
'RUNNING'
)
inst
.
set_level
(
self
.
u2
,
'owner'
)
self
.
assertRaises
(
inst
.
WrongStateError
,
c
.
post
,
"/dashboard/vm/1/"
,
{
'wake_up'
:
True
})
self
.
assertEqual
(
inst
.
status
,
'RUNNING'
)
assert
mock_method
.
called
def
test_permitted_wake_up
(
self
):
c
=
Client
()
self
.
login
(
c
,
"user2"
)
with
patch
.
object
(
Instance
,
'select_node'
,
return_value
=
None
):
with
patch
.
object
(
Instance
,
'wake_up_async'
)
as
new_wake_up
:
with
patch
(
'vm.tasks.vm_tasks.wake_up.apply_async'
)
as
wuaa
:
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
new_wake_up
.
side_effect
=
inst
.
wake_up
inst
.
get_remote_queue_name
=
Mock
(
return_value
=
'test'
)
inst
.
manual_state_change
(
'SUSPENDED'
)
inst
.
set_level
(
self
.
u2
,
'owner'
)
response
=
c
.
post
(
"/dashboard/vm/1/"
,
{
'wake_up'
:
True
})
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
inst
.
status
,
'RUNNING'
)
assert
new_wake_up
.
called
assert
wuaa
.
called
def
test_unpermitted_wake_up
(
self
):
c
=
Client
()
self
.
login
(
c
,
"user2"
)
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
inst
.
manual_state_change
(
'SUSPENDED'
)
inst
.
set_level
(
self
.
u2
,
'user'
)
response
=
c
.
post
(
"/dashboard/vm/1/"
,
{
'wake_up'
:
True
})
self
.
assertEqual
(
response
.
status_code
,
403
)
self
.
assertEqual
(
inst
.
status
,
'SUSPENDED'
)
class
VmDetailVncTest
(
LoginMixin
,
TestCase
):
fixtures
=
[
'test-vm-fixture.json'
,
'node.json'
]
...
...
circle/vm/models/instance.py
View file @
6fcdec33
...
...
@@ -756,8 +756,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel,
vm_tasks
.
resume
.
apply_async
(
args
=
[
self
.
vm_name
],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
self
.
_do_renew
()
self
.
save
()
self
.
renew
(
which
=
'both'
,
base_activity
=
act
)
def
deploy
(
self
,
user
=
None
,
task_uuid
=
None
):
"""Deploy new virtual machine with network
...
...
@@ -1019,6 +1018,9 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel,
for
net
in
self
.
interface_set
.
all
():
net
.
deploy
()
# Renew vm
self
.
renew
(
which
=
'both'
,
base_activity
=
act
)
def
wake_up_async
(
self
,
user
=
None
):
"""Execute wake_up asynchronously.
"""
...
...
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