Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
7e755c8f
authored
Jul 07, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: add RecoverOperation
parent
553a35a4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
circle/vm/models/instance.py
+1
-0
circle/vm/operations.py
+27
-0
No files found.
circle/vm/models/instance.py
View file @
7e755c8f
...
...
@@ -264,6 +264,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
(
'change_resources'
,
_
(
'Can change resources of a running VM.'
)),
(
'set_resources'
,
_
(
'Can change resources of a new VM.'
)),
(
'config_ports'
,
_
(
'Can configure port forwards.'
)),
(
'recover'
,
_
(
'Can recover a destroyed VM.'
)),
)
verbose_name
=
_
(
'instance'
)
verbose_name_plural
=
_
(
'instances'
)
...
...
circle/vm/operations.py
View file @
7e755c8f
...
...
@@ -628,3 +628,30 @@ class ScreenshotOperation(InstanceOperation):
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