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
f7488817
authored
Jul 07, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-recover' into 'master'
Feature: Recover destroyed vm
parents
e0fb01fd
cab4ad49
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
3 deletions
+41
-3
circle/dashboard/views.py
+2
-0
circle/storage/models.py
+8
-3
circle/storage/tasks/storage_tasks.py
+3
-0
circle/vm/models/instance.py
+1
-0
circle/vm/operations.py
+27
-0
No files found.
circle/dashboard/views.py
View file @
f7488817
...
@@ -716,6 +716,8 @@ vm_ops = OrderedDict([
...
@@ -716,6 +716,8 @@ vm_ops = OrderedDict([
op
=
'shutdown'
,
icon
=
'off'
,
effect
=
'warning'
)),
op
=
'shutdown'
,
icon
=
'off'
,
effect
=
'warning'
)),
(
'shut_off'
,
VmOperationView
.
factory
(
(
'shut_off'
,
VmOperationView
.
factory
(
op
=
'shut_off'
,
icon
=
'ban-circle'
,
effect
=
'warning'
)),
op
=
'shut_off'
,
icon
=
'ban-circle'
,
effect
=
'warning'
)),
(
'recover'
,
VmOperationView
.
factory
(
op
=
'recover'
,
icon
=
'medkit'
,
effect
=
'warning'
)),
(
'destroy'
,
VmOperationView
.
factory
(
(
'destroy'
,
VmOperationView
.
factory
(
op
=
'destroy'
,
icon
=
'remove'
,
effect
=
'danger'
)),
op
=
'destroy'
,
icon
=
'remove'
,
effect
=
'danger'
)),
(
'create_disk'
,
VmCreateDiskView
),
(
'create_disk'
,
VmCreateDiskView
),
...
...
circle/storage/models.py
View file @
f7488817
...
@@ -380,11 +380,16 @@ class Disk(AclBase, TimeStampedModel):
...
@@ -380,11 +380,16 @@ class Disk(AclBase, TimeStampedModel):
self
.
save
()
self
.
save
()
return
True
return
True
def
restore
(
self
,
user
=
None
,
task_uuid
=
None
):
def
restore
(
self
,
user
=
None
,
task_uuid
=
None
,
timeout
=
15
):
"""Recover destroyed disk from trash if possible.
"""Recover destroyed disk from trash if possible.
"""
"""
# TODO
queue_name
=
self
.
datastore
.
get_remote_queue_name
(
pass
'storage'
,
priority
=
'slow'
)
logger
.
info
(
"Image:
%
s at Datastore:
%
s recovered from trash."
%
(
self
.
filename
,
self
.
datastore
.
path
))
storage_tasks
.
recover_from_trash
.
apply_async
(
args
=
[
self
.
datastore
.
path
,
self
.
filename
],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
def
save_as
(
self
,
user
=
None
,
task_uuid
=
None
,
timeout
=
300
):
def
save_as
(
self
,
user
=
None
,
task_uuid
=
None
,
timeout
=
300
):
"""Save VM as template.
"""Save VM as template.
...
...
circle/storage/tasks/storage_tasks.py
View file @
f7488817
...
@@ -72,6 +72,9 @@ def make_free_space(datastore, percent):
...
@@ -72,6 +72,9 @@ def make_free_space(datastore, percent):
def
move_to_trash
(
datastore
,
disk_path
):
def
move_to_trash
(
datastore
,
disk_path
):
pass
pass
@celery.task
(
name
=
'storagedriver.recover_from_trash'
)
def
recover_from_trash
(
datastore
,
disk_path
):
pass
@celery.task
(
name
=
'storagedriver.get_storage_stat'
)
@celery.task
(
name
=
'storagedriver.get_storage_stat'
)
def
get_storage_stat
(
path
):
def
get_storage_stat
(
path
):
...
...
circle/vm/models/instance.py
View file @
f7488817
...
@@ -264,6 +264,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -264,6 +264,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
(
'change_resources'
,
_
(
'Can change resources of a running VM.'
)),
(
'change_resources'
,
_
(
'Can change resources of a running VM.'
)),
(
'set_resources'
,
_
(
'Can change resources of a new VM.'
)),
(
'set_resources'
,
_
(
'Can change resources of a new VM.'
)),
(
'config_ports'
,
_
(
'Can configure port forwards.'
)),
(
'config_ports'
,
_
(
'Can configure port forwards.'
)),
(
'recover'
,
_
(
'Can recover a destroyed VM.'
)),
)
)
verbose_name
=
_
(
'instance'
)
verbose_name
=
_
(
'instance'
)
verbose_name_plural
=
_
(
'instances'
)
verbose_name_plural
=
_
(
'instances'
)
...
...
circle/vm/operations.py
View file @
f7488817
...
@@ -628,3 +628,30 @@ class ScreenshotOperation(InstanceOperation):
...
@@ -628,3 +628,30 @@ class ScreenshotOperation(InstanceOperation):
register_operation
(
ScreenshotOperation
)
register_operation
(
ScreenshotOperation
)
class
RecoverOperation
(
InstanceOperation
):
activity_code_suffix
=
'recover'
id
=
'recover'
name
=
_
(
"recover"
)
description
=
_
(
"Recover virtual machine from destroyed state."
)
acl_level
=
"owner"
required_perms
=
(
'vm.recover'
,
)
def
check_precond
(
self
):
if
not
self
.
instance
.
destroyed_at
:
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
def
on_commit
(
self
,
activity
):
activity
.
resultant_state
=
'PENDING'
def
_operation
(
self
):
for
disk
in
self
.
instance
.
disks
.
all
():
disk
.
destroyed
=
None
disk
.
restore
()
disk
.
save
()
self
.
instance
.
destroyed_at
=
None
self
.
instance
.
save
()
register_operation
(
RecoverOperation
)
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