Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
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
Show 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
...
@@ -6,6 +6,7 @@ from django.core.urlresolvers import reverse
from
django.contrib.auth.models
import
Permission
from
django.contrib.auth.models
import
Permission
from
vm.models
import
Instance
,
InstanceTemplate
,
Lease
,
Node
from
vm.models
import
Instance
,
InstanceTemplate
,
Lease
,
Node
from
vm.models.operation
import
WakeUpOperation
from
..models
import
Profile
from
..models
import
Profile
from
..views
import
VmRenewView
from
..views
import
VmRenewView
from
storage.models
import
Disk
from
storage.models
import
Disk
...
@@ -487,7 +488,7 @@ class VmDetailTest(LoginMixin, TestCase):
...
@@ -487,7 +488,7 @@ class VmDetailTest(LoginMixin, TestCase):
def
test_permitted_wake_up_wrong_state
(
self
):
def
test_permitted_wake_up_wrong_state
(
self
):
c
=
Client
()
c
=
Client
()
self
.
login
(
c
,
"user2"
)
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
)
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
mock_method
.
side_effect
=
inst
.
wake_up
mock_method
.
side_effect
=
inst
.
wake_up
inst
.
manual_state_change
(
'RUNNING'
)
inst
.
manual_state_change
(
'RUNNING'
)
...
@@ -501,7 +502,7 @@ class VmDetailTest(LoginMixin, TestCase):
...
@@ -501,7 +502,7 @@ class VmDetailTest(LoginMixin, TestCase):
c
=
Client
()
c
=
Client
()
self
.
login
(
c
,
"user2"
)
self
.
login
(
c
,
"user2"
)
with
patch
.
object
(
Instance
,
'select_node'
,
return_value
=
None
):
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
:
with
patch
(
'vm.tasks.vm_tasks.wake_up.apply_async'
)
as
wuaa
:
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
new_wake_up
.
side_effect
=
inst
.
wake_up
new_wake_up
.
side_effect
=
inst
.
wake_up
...
...
circle/dashboard/views.py
View file @
a15a814f
...
@@ -423,7 +423,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -423,7 +423,7 @@ class VmDetailView(CheckedDetailView):
new_name
=
"Saved from
%
s (#
%
d) at
%
s"
%
(
new_name
=
"Saved from
%
s (#
%
d) at
%
s"
%
(
self
.
object
.
name
,
self
.
object
.
pk
,
date
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
)
user
=
request
.
user
)
messages
.
success
(
request
,
_
(
"Saving instance as template!"
))
messages
.
success
(
request
,
_
(
"Saving instance as template!"
))
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
...
@@ -433,7 +433,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -433,7 +433,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
raise
PermissionDenied
()
self
.
object
.
shutdown
_async
(
request
.
user
)
self
.
object
.
shutdown
.
async
(
user
=
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
def
__sleep
(
self
,
request
):
def
__sleep
(
self
,
request
):
...
@@ -441,7 +441,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -441,7 +441,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
raise
PermissionDenied
()
self
.
object
.
sleep
_async
(
request
.
user
)
self
.
object
.
sleep
.
async
(
user
=
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
def
__wake_up
(
self
,
request
):
def
__wake_up
(
self
,
request
):
...
@@ -449,7 +449,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -449,7 +449,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
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
())
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
def
__deploy
(
self
,
request
):
def
__deploy
(
self
,
request
):
...
@@ -457,7 +457,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -457,7 +457,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
raise
PermissionDenied
()
self
.
object
.
deploy
_async
(
request
.
user
)
self
.
object
.
deploy
.
async
(
user
=
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
def
__reset
(
self
,
request
):
def
__reset
(
self
,
request
):
...
@@ -465,7 +465,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -465,7 +465,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
raise
PermissionDenied
()
self
.
object
.
reset
_async
(
request
.
user
)
self
.
object
.
reset
.
async
(
user
=
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
def
__reboot
(
self
,
request
):
def
__reboot
(
self
,
request
):
...
@@ -473,7 +473,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -473,7 +473,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
raise
PermissionDenied
()
self
.
object
.
reboot
_async
(
request
.
user
)
self
.
object
.
reboot
.
async
(
user
=
request
.
user
)
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
def
__shut_off
(
self
,
request
):
def
__shut_off
(
self
,
request
):
...
@@ -481,7 +481,7 @@ class VmDetailView(CheckedDetailView):
...
@@ -481,7 +481,7 @@ class VmDetailView(CheckedDetailView):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
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
())
return
redirect
(
"
%
s#activity"
%
self
.
object
.
get_absolute_url
())
...
@@ -1137,7 +1137,7 @@ class VmCreate(LoginRequiredMixin, TemplateView):
...
@@ -1137,7 +1137,7 @@ class VmCreate(LoginRequiredMixin, TemplateView):
raise
PermissionDenied
()
raise
PermissionDenied
()
def
__deploy
(
self
,
request
,
instance
,
*
args
,
**
kwargs
):
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!'
))
messages
.
success
(
request
,
_
(
'VM successfully created!'
))
path
=
instance
.
get_absolute_url
()
path
=
instance
.
get_absolute_url
()
if
request
.
is_ajax
():
if
request
.
is_ajax
():
...
@@ -1268,7 +1268,7 @@ class VmDelete(LoginRequiredMixin, DeleteView):
...
@@ -1268,7 +1268,7 @@ class VmDelete(LoginRequiredMixin, DeleteView):
if
not
object
.
has_level
(
request
.
user
,
'owner'
):
if
not
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
raise
PermissionDenied
()
object
.
destroy
_
async
(
user
=
request
.
user
)
object
.
destroy
.
async
(
user
=
request
.
user
)
success_url
=
self
.
get_success_url
()
success_url
=
self
.
get_success_url
()
success_message
=
_
(
"VM successfully deleted!"
)
success_message
=
_
(
"VM successfully deleted!"
)
...
@@ -1519,7 +1519,7 @@ class VmMassDelete(LoginRequiredMixin, View):
...
@@ -1519,7 +1519,7 @@ class VmMassDelete(LoginRequiredMixin, View):
raise
PermissionDenied
()
# no need for rollback or proper
raise
PermissionDenied
()
# no need for rollback or proper
# error message, this can't
# error message, this can't
# normally happen.
# normally happen.
i
.
destroy
_async
(
request
.
user
)
i
.
destroy
.
async
(
user
=
request
.
user
)
names
.
append
(
i
.
name
)
names
.
append
(
i
.
name
)
success_message
=
_
(
"Mass delete complete, the following VMs were "
success_message
=
_
(
"Mass delete complete, the following VMs were "
...
@@ -2046,7 +2046,7 @@ class VmMigrateView(SuperuserRequiredMixin, TemplateView):
...
@@ -2046,7 +2046,7 @@ class VmMigrateView(SuperuserRequiredMixin, TemplateView):
if
node
:
if
node
:
node
=
Node
.
objects
.
get
(
pk
=
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
:
else
:
messages
.
error
(
self
.
request
,
_
(
"You didn't select a node!"
))
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,
...
@@ -775,14 +775,6 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel,
self
.
renew
(
which
=
'both'
,
base_activity
=
act
)
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
):
def
_destroy_vm
(
self
,
act
,
timeout
=
15
):
"""Destroy the virtual machine and its associated networks.
"""Destroy the virtual machine and its associated networks.
...
@@ -830,64 +822,6 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel,
...
@@ -830,64 +822,6 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel,
self
.
node
=
None
self
.
node
=
None
self
.
vnc_port
=
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
,
def
shutdown_and_save_as_template
(
self
,
name
,
user
=
None
,
task_uuid
=
None
,
**
kwargs
):
**
kwargs
):
self
.
shutdown
(
user
=
user
)
self
.
shutdown
(
user
=
user
)
...
...
circle/vm/tasks/local_periodic_tasks.py
View file @
a15a814f
...
@@ -27,7 +27,7 @@ def garbage_collector(timeout=15):
...
@@ -27,7 +27,7 @@ def garbage_collector(timeout=15):
now
=
timezone
.
now
()
now
=
timezone
.
now
()
for
i
in
Instance
.
objects
.
filter
(
destroyed_at
=
None
)
.
all
():
for
i
in
Instance
.
objects
.
filter
(
destroyed_at
=
None
)
.
all
():
if
i
.
time_of_delete
and
now
>
i
.
time_of_delete
:
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
)
logger
.
info
(
"Expired instance
%
d destroyed."
,
i
.
pk
)
try
:
try
:
i
.
owner
.
profile
.
notify
(
i
.
owner
.
profile
.
notify
(
...
@@ -39,7 +39,7 @@ def garbage_collector(timeout=15):
...
@@ -39,7 +39,7 @@ def garbage_collector(timeout=15):
i
.
pk
,
unicode
(
e
))
i
.
pk
,
unicode
(
e
))
elif
(
i
.
time_of_suspend
and
now
>
i
.
time_of_suspend
and
elif
(
i
.
time_of_suspend
and
now
>
i
.
time_of_suspend
and
i
.
state
==
'RUNNING'
):
i
.
state
==
'RUNNING'
):
i
.
sleep
_
async
()
i
.
sleep
.
async
()
logger
.
info
(
"Expired instance
%
d suspended."
%
i
.
pk
)
logger
.
info
(
"Expired instance
%
d suspended."
%
i
.
pk
)
try
:
try
:
i
.
owner
.
profile
.
notify
(
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