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
127e1fd8
authored
Sep 27, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: extract disk description generation
parent
85f1f63a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
circle/storage/models.py
+12
-9
No files found.
circle/storage/models.py
View file @
127e1fd8
...
@@ -116,6 +116,16 @@ class Disk(TimeStampedModel):
...
@@ -116,6 +116,16 @@ class Disk(TimeStampedModel):
'target_device'
:
self
.
device_type
+
self
.
dev_num
'target_device'
:
self
.
device_type
+
self
.
dev_num
}
}
def
get_disk_desc
(
self
):
return
{
'name'
:
self
.
filename
,
'dir'
:
self
.
datastore
.
path
,
'format'
:
self
.
format
,
'size'
:
self
.
size
,
'base_name'
:
self
.
base
.
filename
if
self
.
base
else
None
,
'type'
:
'snapshot'
if
self
.
type
==
'qcow2-snap'
else
'normal'
}
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
u"
%
s (#
%
d)"
%
(
self
.
name
,
self
.
id
)
return
u"
%
s (#
%
d)"
%
(
self
.
name
,
self
.
id
)
...
@@ -137,16 +147,8 @@ class Disk(TimeStampedModel):
...
@@ -137,16 +147,8 @@ class Disk(TimeStampedModel):
if
self
.
ready
:
if
self
.
ready
:
return
False
return
False
disk_desc
=
{
'name'
:
self
.
filename
,
'dir'
:
self
.
datastore
.
path
,
'format'
:
self
.
format
,
'size'
:
self
.
size
,
'base_name'
:
self
.
base
.
filename
if
self
.
base
else
None
,
'type'
:
'snapshot'
if
self
.
type
==
'qcow2-snap'
else
'normal'
}
# Delegate create / snapshot jobs
# Delegate create / snapshot jobs
disk_desc
=
self
.
get_disk_desc
()
if
self
.
type
==
'qcow2-snap'
:
if
self
.
type
==
'qcow2-snap'
:
remote_tasks
.
snapshot
.
apply_async
(
remote_tasks
.
snapshot
.
apply_async
(
args
=
[
disk_desc
],
args
=
[
disk_desc
],
...
@@ -155,6 +157,7 @@ class Disk(TimeStampedModel):
...
@@ -155,6 +157,7 @@ class Disk(TimeStampedModel):
remote_tasks
.
create
.
apply_async
(
remote_tasks
.
create
.
apply_async
(
args
=
[
disk_desc
],
args
=
[
disk_desc
],
queue
=
self
.
datastore
.
hostname
+
".storage"
)
.
get
()
queue
=
self
.
datastore
.
hostname
+
".storage"
)
.
get
()
self
.
ready
=
True
self
.
ready
=
True
self
.
save
()
self
.
save
()
return
True
return
True
...
...
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