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
d9deb891
authored
Mar 05, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: extract Instance.get_renew_times from .renew
parent
9403e818
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
circle/vm/models/instance.py
+13
-5
No files found.
circle/vm/models/instance.py
View file @
d9deb891
...
...
@@ -562,15 +562,23 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
else
:
raise
Node
.
DoesNotExist
()
def
get_renew_times
(
self
):
"""Returns new suspend and delete times if renew would be called.
"""
return
(
timezone
.
now
()
+
self
.
lease
.
suspend_interval
,
timezone
.
now
()
+
self
.
lease
.
delete_interval
)
def
renew
(
self
,
which
=
'both'
):
"""Renew virtual machine instance leases.
"""
if
which
not
in
[
'suspend'
,
'delete'
,
'both'
]
:
if
which
not
in
(
'suspend'
,
'delete'
,
'both'
)
:
raise
ValueError
(
'No such expiration type.'
)
if
which
in
[
'suspend'
,
'both'
]:
self
.
time_of_suspend
=
timezone
.
now
()
+
self
.
lease
.
suspend_interval
if
which
in
[
'delete'
,
'both'
]:
self
.
time_of_delete
=
timezone
.
now
()
+
self
.
lease
.
delete_interval
time_of_suspend
,
time_of_delete
=
self
.
get_renew_times
()
if
which
in
(
'suspend'
,
'both'
):
self
.
time_of_suspend
=
time_of_suspend
if
which
in
(
'delete'
,
'both'
):
self
.
time_of_delete
=
time_of_delete
self
.
save
()
def
change_password
(
self
,
user
=
None
):
...
...
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