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
498eb828
authored
Apr 01, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: added clone and clone_async functions
parent
be0f030f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
circle/storage/models.py
+49
-0
No files found.
circle/storage/models.py
View file @
498eb828
...
...
@@ -474,6 +474,55 @@ class Disk(AclBase, TimeStampedModel):
local_tasks
.
restore
.
apply_async
(
args
=
[
self
,
user
],
queue
=
'localhost.man'
)
def
clone_async
(
self
,
new_disk
=
None
,
timeout
=
300
,
user
=
None
):
"""Clone a Disk to another Disk
:param new_disk: optional, the new Disk object to clone in
:type new_disk: storage.models.Disk
:param user: Creator of the disk.
:type user: django.contrib.auth.User
:return: AsyncResult
"""
return
local_tasks
.
clone
.
apply_async
(
args
=
[
self
,
new_disk
,
timeout
,
user
],
queue
=
"localhost.man"
)
def
clone
(
self
,
disk
=
None
,
user
=
None
,
task_uuid
=
None
,
timeout
=
300
):
"""Cloning Disk into another Disk.
The Disk.type can'T be snapshot.
:param new_disk: optional, the new Disk object to clone in
:type new_disk: storage.models.Disk
:param user: Creator of the disk.
:type user: django.contrib.auth.User
:return: the cloned Disk object.
"""
banned_types
=
[
'qcow2-snap'
]
if
self
.
type
in
banned_types
:
raise
self
.
WrongDiskTypeError
(
self
.
type
)
if
self
.
is_in_use
:
raise
self
.
DiskInUseError
(
self
)
if
not
self
.
ready
:
raise
self
.
DiskIsNotReady
(
self
)
if
not
disk
:
disk
=
Disk
.
create
(
datastore
=
self
.
datastore
,
name
=
self
.
name
,
size
=
self
.
size
,
type
=
self
.
type
)
with
disk_activity
(
code_suffix
=
"clone"
,
disk
=
self
,
user
=
user
,
task_uuid
=
task_uuid
):
with
disk_activity
(
code_suffix
=
"deploy"
,
disk
=
disk
,
user
=
user
,
task_uuid
=
task_uuid
):
queue_name
=
self
.
get_remote_queue_name
(
'storage'
)
remote_tasks
.
merge
.
apply_async
(
args
=
[
self
.
get_disk_desc
(),
disk
.
get_disk_desc
()],
queue
=
queue_name
)
.
get
()
# Timeout
return
disk
def
save_as_async
(
self
,
disk
,
task_uuid
=
None
,
timeout
=
300
,
user
=
None
):
return
local_tasks
.
save_as
.
apply_async
(
args
=
[
disk
,
timeout
,
user
],
queue
=
"localhost.man"
)
...
...
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