Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
31cb5abf
authored
Mar 09, 2014
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: make is_in_use into property
parent
b88a5c9f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
circle/storage/models.py
+4
-3
No files found.
circle/storage/models.py
View file @
31cb5abf
...
@@ -175,13 +175,14 @@ class Disk(AclBase, TimeStampedModel):
...
@@ -175,13 +175,14 @@ class Disk(AclBase, TimeStampedModel):
return
any
((
not
i
.
is_deletable
()
for
i
in
self
.
derivatives
.
all
()))
return
any
((
not
i
.
is_deletable
()
for
i
in
self
.
derivatives
.
all
()))
@property
def
is_in_use
(
self
):
def
is_in_use
(
self
):
"""
Returns
if disk is attached to an active VM.
"""
True
if disk is attached to an active VM.
'In use' means the disk is attached to a VM which is not STOPPED, as
'In use' means the disk is attached to a VM which is not STOPPED, as
any other VMs leave the disk in an inconsistent state.
any other VMs leave the disk in an inconsistent state.
"""
"""
return
any
(
[
i
.
state
!=
'STOPPED'
for
i
in
self
.
instance_set
.
all
()]
)
return
any
(
i
.
state
!=
'STOPPED'
for
i
in
self
.
instance_set
.
all
()
)
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.
...
@@ -432,7 +433,7 @@ class Disk(AclBase, TimeStampedModel):
...
@@ -432,7 +433,7 @@ class Disk(AclBase, TimeStampedModel):
if
self
.
type
not
in
mapping
.
keys
():
if
self
.
type
not
in
mapping
.
keys
():
raise
self
.
WrongDiskTypeError
(
self
.
type
)
raise
self
.
WrongDiskTypeError
(
self
.
type
)
if
self
.
is_in_use
()
:
if
self
.
is_in_use
:
raise
self
.
DiskInUseError
(
self
)
raise
self
.
DiskInUseError
(
self
)
# from this point on, the caller has to guarantee that the disk is not
# from this point on, the caller has to guarantee that the disk is not
...
...
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