Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
43f6f38a
authored
Sep 27, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: refactor get_exclusive method
parent
38633b61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
circle/storage/models.py
+10
-6
No files found.
circle/storage/models.py
View file @
43f6f38a
...
@@ -89,16 +89,20 @@ class Disk(TimeStampedModel):
...
@@ -89,16 +89,20 @@ class Disk(TimeStampedModel):
def
get_exclusive
(
self
):
def
get_exclusive
(
self
):
"""Get an instance of the disk for exclusive usage.
"""Get an instance of the disk for exclusive usage.
"""
if
self
.
type
in
[
'qcow2-snap'
,
'raw-rw'
]:
raise
self
.
WrongDiskTypeError
(
self
.
type
)
filename
=
self
.
filename
if
self
.
type
==
'iso'
else
str
(
uuid
.
uuid4
())
This method manipulates the database only.
new_type
=
{
"""
type_mapping
=
{
'qcow2-norm'
:
'qcow2-snap'
,
'qcow2-norm'
:
'qcow2-snap'
,
'iso'
:
'iso'
,
'iso'
:
'iso'
,
'raw-ro'
:
'raw-rw'
,
'raw-ro'
:
'raw-rw'
,
}[
self
.
type
]
}
if
self
.
type
not
in
type_mapping
.
keys
():
raise
self
.
WrongDiskTypeError
(
self
.
type
)
filename
=
self
.
filename
if
self
.
type
==
'iso'
else
str
(
uuid
.
uuid4
())
new_type
=
type_mapping
[
self
.
type
]
return
Disk
.
objects
.
create
(
base
=
self
,
datastore
=
self
.
datastore
,
return
Disk
.
objects
.
create
(
base
=
self
,
datastore
=
self
.
datastore
,
filename
=
filename
,
name
=
self
.
name
,
filename
=
filename
,
name
=
self
.
name
,
...
...
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