Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
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
a15a814f
authored
Mar 23, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: remove deprecated async methods
parent
b6ba0036
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
82 deletions
+17
-82
circle/dashboard/tests/test_views.py
+3
-2
circle/dashboard/views.py
+12
-12
circle/vm/models/instance.py
+0
-66
circle/vm/tasks/local_periodic_tasks.py
+2
-2
No files found.
circle/dashboard/tests/test_views.py
View file @
a15a814f
...
...
@@ -6,6 +6,7 @@ from django.core.urlresolvers import reverse
from
django.contrib.auth.models
import
Permission
from
vm.models
import
Instance
,
InstanceTemplate
,
Lease
,
Node
from
vm.models.operation
import
WakeUpOperation
from
..models
import
Profile
from
..views
import
VmRenewView
from
storage.models
import
Disk
...
...
@@ -487,7 +488,7 @@ class VmDetailTest(LoginMixin, TestCase):
def
test_permitted_wake_up_wrong_state
(
self
):
c
=
Client
()
self
.
login
(
c
,
"user2"
)
with
patch
.
object
(
Instance
,
'wake_up_
async'
)
as
mock_method
:
with
patch
.
object
(
WakeUpOperation
,
'
async'
)
as
mock_method
:
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
mock_method
.
side_effect
=
inst
.
wake_up
inst
.
manual_state_change
(
'RUNNING'
)
...
...
@@ -501,7 +502,7 @@ class VmDetailTest(LoginMixin, TestCase):
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
.
object
(
WakeUpOperation
,
'
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
...
...
circle/dashboard/views.py
View file @
a15a814f
...
...
@@ -423,7 +423,7 @@ class VmDetailView(CheckedDetailView):
new_name
=
"Saved from
%
s (#
%
d) at
%
s"
%
(
self
.
object
.
name
,
self
.
object
.
pk
,
date
)
self
.
object
.
save_as_template
_
async
(
name
=
new_name
,
self
.
object
.
save_as_template
.
async
(
name
=
new_name
,
user
=
request
.
user
)
messages
.
success
(
request
,
_
(
"Saving instance as template!"
))
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
...
...
@@ -433,7 +433,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
self
.
object
.
shutdown
_async
(
request
.
user
)
self
.
object
.
shutdown
.
async
(
user
=
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
def
__sleep
(
self
,
request
):
...
...
@@ -441,7 +441,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
self
.
object
.
sleep
_async
(
request
.
user
)
self
.
object
.
sleep
.
async
(
user
=
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
def
__wake_up
(
self
,
request
):
...
...
@@ -449,7 +449,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
self
.
object
.
wake_up
_async
(
request
.
user
)
self
.
object
.
wake_up
.
async
(
user
=
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
def
__deploy
(
self
,
request
):
...
...
@@ -457,7 +457,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
self
.
object
.
deploy
_async
(
request
.
user
)
self
.
object
.
deploy
.
async
(
user
=
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
def
__reset
(
self
,
request
):
...
...
@@ -465,7 +465,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
self
.
object
.
reset
_async
(
request
.
user
)
self
.
object
.
reset
.
async
(
user
=
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
def
__reboot
(
self
,
request
):
...
...
@@ -473,7 +473,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
self
.
object
.
reboot
_async
(
request
.
user
)
self
.
object
.
reboot
.
async
(
user
=
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
def
__shut_off
(
self
,
request
):
...
...
@@ -481,7 +481,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
self
.
object
.
shut_off
_async
(
request
.
user
)
self
.
object
.
shut_off
.
async
(
user
=
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
...
...
@@ -1137,7 +1137,7 @@ class VmCreate(LoginRequiredMixin, TemplateView):
raise
PermissionDenied
()
def
__deploy
(
self
,
request
,
instance
,
*
args
,
**
kwargs
):
instance
.
deploy
_
async
(
user
=
request
.
user
)
instance
.
deploy
.
async
(
user
=
request
.
user
)
messages
.
success
(
request
,
_
(
'VM successfully created!'
))
path
=
instance
.
get_absolute_url
()
if
request
.
is_ajax
():
...
...
@@ -1268,7 +1268,7 @@ class VmDelete(LoginRequiredMixin, DeleteView):
if
not
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
object
.
destroy
_
async
(
user
=
request
.
user
)
object
.
destroy
.
async
(
user
=
request
.
user
)
success_url
=
self
.
get_success_url
()
success_message
=
_
(
"VM successfully deleted!"
)
...
...
@@ -1519,7 +1519,7 @@ class VmMassDelete(LoginRequiredMixin, View):
raise
PermissionDenied
()
# no need for rollback or proper
# error message, this can't
# normally happen.
i
.
destroy
_async
(
request
.
user
)
i
.
destroy
.
async
(
user
=
request
.
user
)
names
.
append
(
i
.
name
)
success_message
=
_
(
"Mass delete complete, the following VMs were "
...
...
@@ -2046,7 +2046,7 @@ class VmMigrateView(SuperuserRequiredMixin, TemplateView):
if
node
:
node
=
Node
.
objects
.
get
(
pk
=
node
)
vm
.
migrate
_
async
(
to_node
=
node
,
user
=
self
.
request
.
user
)
vm
.
migrate
.
async
(
to_node
=
node
,
user
=
self
.
request
.
user
)
else
:
messages
.
error
(
self
.
request
,
_
(
"You didn't select a node!"
))
...
...
circle/vm/models/instance.py
View file @
a15a814f
...
...
@@ -775,14 +775,6 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel,
self
.
renew
(
which
=
'both'
,
base_activity
=
act
)
def
deploy_async
(
self
,
user
=
None
):
"""Execute deploy asynchronously.
"""
warn
(
'Use self.deploy.async instead.'
,
DeprecationWarning
)
logger
.
debug
(
'Calling async local_tasks.deploy(
%
s,
%
s)'
,
unicode
(
self
),
unicode
(
user
))
return
self
.
deploy
.
async
(
user
=
user
)
def
_destroy_vm
(
self
,
act
,
timeout
=
15
):
"""Destroy the virtual machine and its associated networks.
...
...
@@ -830,64 +822,6 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel,
self
.
node
=
None
self
.
vnc_port
=
None
def
redeploy_async
(
self
,
user
=
None
):
"""Execute redeploy asynchronously.
"""
warn
(
'Use self.redeploy.async instead.'
,
DeprecationWarning
)
return
self
.
redeploy
.
async
(
user
=
user
)
def
shut_off_async
(
self
,
user
=
None
):
"""Shut off VM. (plug-out)
"""
warn
(
'Use self.shut_off.async instead.'
,
DeprecationWarning
)
return
self
.
shut_off
.
async
(
user
=
user
)
def
destroy_async
(
self
,
user
=
None
):
"""Execute destroy asynchronously.
"""
warn
(
'Use self.destroy.async instead.'
,
DeprecationWarning
)
return
self
.
destroy
.
async
(
user
=
user
)
def
sleep_async
(
self
,
user
=
None
):
"""Execute sleep asynchronously.
"""
warn
(
'Use self.sleep.async instead.'
,
DeprecationWarning
)
return
self
.
sleep
.
async
(
user
=
user
)
def
wake_up_async
(
self
,
user
=
None
):
"""Execute wake_up asynchronously.
"""
warn
(
'Use self.wake_up.async instead.'
,
DeprecationWarning
)
return
self
.
wake_up
.
async
(
user
=
user
)
def
shutdown_async
(
self
,
user
=
None
):
"""Execute shutdown asynchronously.
"""
warn
(
'Use self.shutdown.async instead.'
,
DeprecationWarning
)
return
self
.
shutdown
.
async
(
user
=
user
)
def
reset_async
(
self
,
user
=
None
):
"""Execute reset asynchronously.
"""
warn
(
'Use self.reset.async instead.'
,
DeprecationWarning
)
return
self
.
reset
.
async
(
user
=
user
)
def
reboot_async
(
self
,
user
=
None
):
"""Execute reboot asynchronously. """
warn
(
'Use self.reboot.async instead.'
,
DeprecationWarning
)
return
self
.
reboot
.
async
(
user
=
user
)
def
migrate_async
(
self
,
to_node
,
user
=
None
):
"""Execute migrate asynchronously. """
warn
(
'Use self.shut_off.async instead.'
,
DeprecationWarning
)
return
self
.
migrate
.
async
(
user
=
user
,
to_node
=
to_node
)
def
save_as_template_async
(
self
,
name
,
user
=
None
,
**
kwargs
):
""" Save as template asynchronusly.
"""
warn
(
'Use self.shut_off.async instead.'
,
DeprecationWarning
)
return
self
.
save_as_template
.
async
(
name
=
name
,
user
=
user
,
**
kwargs
)
def
shutdown_and_save_as_template
(
self
,
name
,
user
=
None
,
task_uuid
=
None
,
**
kwargs
):
self
.
shutdown
(
user
=
user
)
...
...
circle/vm/tasks/local_periodic_tasks.py
View file @
a15a814f
...
...
@@ -27,7 +27,7 @@ def garbage_collector(timeout=15):
now
=
timezone
.
now
()
for
i
in
Instance
.
objects
.
filter
(
destroyed_at
=
None
)
.
all
():
if
i
.
time_of_delete
and
now
>
i
.
time_of_delete
:
i
.
destroy
_
async
()
i
.
destroy
.
async
()
logger
.
info
(
"Expired instance
%
d destroyed."
,
i
.
pk
)
try
:
i
.
owner
.
profile
.
notify
(
...
...
@@ -39,7 +39,7 @@ def garbage_collector(timeout=15):
i
.
pk
,
unicode
(
e
))
elif
(
i
.
time_of_suspend
and
now
>
i
.
time_of_suspend
and
i
.
state
==
'RUNNING'
):
i
.
sleep
_
async
()
i
.
sleep
.
async
()
logger
.
info
(
"Expired instance
%
d suspended."
%
i
.
pk
)
try
:
i
.
owner
.
profile
.
notify
(
...
...
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