Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b8eff33b
authored
Feb 26, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: refactor Disk.is_deletable
parent
8703382d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
13 deletions
+12
-13
circle/storage/models.py
+12
-13
No files found.
circle/storage/models.py
View file @
b8eff33b
...
...
@@ -133,21 +133,20 @@ class Disk(AclBase, TimeStampedModel):
}[
self
.
type
]
def
is_deletable
(
self
):
"""Returns True if no child and disk is destroyed."""
time_before
=
timezone
.
now
()
-
timedelta
(
days
=
1
)
if
self
.
destroyed
>
time_before
or
self
.
has_active_child
():
return
False
else
:
return
True
"""Returns whether the file can be deleted.
Checks if all children and the disk itself is destroyed.
"""
yesterday
=
timezone
.
now
()
-
timedelta
(
days
=
1
)
return
(
self
.
destroyed
is
not
None
and
self
.
destroyed
<
yesterday
)
and
not
self
.
has_active_child
()
def
has_active_child
(
self
):
"""Returns True if disk have iactive childs."""
time_before
=
timezone
.
now
()
-
timedelta
(
days
=
1
)
for
child
in
self
.
derivatives
.
all
():
if
child
.
destroyed
>
time_before
or
None
:
return
True
else
:
return
False
"""Returns if disk has children that are not destroyed.
"""
return
any
((
not
i
.
is_deletable
()
for
i
in
self
.
derivatives
.
all
()))
def
is_in_use
(
self
):
"""Returns True if disc is attached to an active VM else False"""
...
...
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