Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
bab152d4
authored
Jan 31, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: make lease intervals optional
parent
3307b2b4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
6 deletions
+34
-6
circle/vm/migrations/0013_auto__chg_field_lease_suspend_interval_seconds__chg_field_lease_delete.py
+0
-0
circle/vm/models/common.py
+34
-6
No files found.
circle/vm/migrations/0013_auto__chg_field_lease_suspend_interval_seconds__chg_field_lease_delete.py
0 → 100644
View file @
bab152d4
This diff is collapsed.
Click to expand it.
circle/vm/models/common.py
View file @
bab152d4
...
@@ -58,8 +58,14 @@ class Lease(Model):
...
@@ -58,8 +58,14 @@ class Lease(Model):
"""
"""
name
=
CharField
(
max_length
=
100
,
unique
=
True
,
name
=
CharField
(
max_length
=
100
,
unique
=
True
,
verbose_name
=
_
(
'name'
))
verbose_name
=
_
(
'name'
))
suspend_interval_seconds
=
IntegerField
(
verbose_name
=
_
(
'suspend interval'
))
suspend_interval_seconds
=
IntegerField
(
delete_interval_seconds
=
IntegerField
(
verbose_name
=
_
(
'delete interval'
))
verbose_name
=
_
(
'suspend interval'
),
help_text
=
_
(
'Number of seconds after the an instance is suspended.'
),
null
=
True
,
blank
=
True
)
delete_interval_seconds
=
IntegerField
(
verbose_name
=
_
(
'delete interval'
),
help_text
=
_
(
'Number of seconds after the an instance is deleted.'
),
null
=
True
,
blank
=
True
)
class
Meta
:
class
Meta
:
app_label
=
'vm'
app_label
=
'vm'
...
@@ -68,27 +74,49 @@ class Lease(Model):
...
@@ -68,27 +74,49 @@ class Lease(Model):
@property
@property
def
suspend_interval
(
self
):
def
suspend_interval
(
self
):
return
timedelta
(
seconds
=
self
.
suspend_interval_seconds
)
v
=
self
.
suspend_interval_seconds
if
v
is
not
None
:
return
timedelta
(
seconds
=
v
)
else
:
return
None
@suspend_interval.setter
@suspend_interval.setter
def
suspend_interval
(
self
,
value
):
def
suspend_interval
(
self
,
value
):
if
value
is
not
None
:
self
.
suspend_interval_seconds
=
value
.
total_seconds
()
self
.
suspend_interval_seconds
=
value
.
total_seconds
()
else
:
self
.
suspend_interval_seconds
=
None
@property
@property
def
delete_interval
(
self
):
def
delete_interval
(
self
):
return
timedelta
(
seconds
=
self
.
delete_interval_seconds
)
v
=
self
.
delete_interval_seconds
if
v
is
not
None
:
return
timedelta
(
seconds
=
v
)
else
:
return
None
@delete_interval.setter
@delete_interval.setter
def
delete_interval
(
self
,
value
):
def
delete_interval
(
self
,
value
):
if
value
is
not
None
:
self
.
delete_interval_seconds
=
value
.
total_seconds
()
self
.
delete_interval_seconds
=
value
.
total_seconds
()
else
:
self
.
delete_interval_seconds
=
None
def
get_readable_suspend_time
(
self
):
def
get_readable_suspend_time
(
self
):
v
=
self
.
suspend_interval
if
v
is
not
None
:
n
=
datetime
.
utcnow
()
n
=
datetime
.
utcnow
()
return
timeuntil
(
n
+
self
.
suspend_interval
,
n
)
return
timeuntil
(
n
+
v
,
n
)
else
:
return
_
(
"never"
)
def
get_readable_delete_time
(
self
):
def
get_readable_delete_time
(
self
):
v
=
self
.
delete_interval
if
v
is
not
None
:
n
=
datetime
.
utcnow
()
n
=
datetime
.
utcnow
()
return
timeuntil
(
n
+
self
.
delete_interval
,
n
)
return
timeuntil
(
n
+
v
,
n
)
else
:
return
_
(
"never"
)
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
_
(
"
%
s (suspend:
%
s, remove:
%
s)"
)
%
(
return
_
(
"
%
s (suspend:
%
s, remove:
%
s)"
)
%
(
...
...
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