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
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
Show 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):
...
@@ -133,21 +133,20 @@ class Disk(AclBase, TimeStampedModel):
}[
self
.
type
]
}[
self
.
type
]
def
is_deletable
(
self
):
def
is_deletable
(
self
):
"""Returns True if no child and disk is destroyed."""
"""Returns whether the file can be deleted.
time_before
=
timezone
.
now
()
-
timedelta
(
days
=
1
)
if
self
.
destroyed
>
time_before
or
self
.
has_active_child
():
Checks if all children and the disk itself is destroyed.
return
False
"""
else
:
return
True
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
):
def
has_active_child
(
self
):
"""Returns True if disk have iactive childs."""
"""Returns if disk has children that are not destroyed.
time_before
=
timezone
.
now
()
-
timedelta
(
days
=
1
)
"""
for
child
in
self
.
derivatives
.
all
():
if
child
.
destroyed
>
time_before
or
None
:
return
any
((
not
i
.
is_deletable
()
for
i
in
self
.
derivatives
.
all
()))
return
True
else
:
return
False
def
is_in_use
(
self
):
def
is_in_use
(
self
):
"""Returns True if disc is attached to an active VM else False"""
"""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