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
bb695789
authored
Aug 01, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-renew-conditionally' into 'master'
Feature Renew Conditionally
parents
9ea843e9
0ca705cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
12 deletions
+35
-12
circle/dashboard/forms.py
+7
-5
circle/vm/operations.py
+28
-7
No files found.
circle/dashboard/forms.py
View file @
bb695789
...
...
@@ -697,16 +697,18 @@ class LeaseForm(forms.ModelForm):
class
VmRenewForm
(
forms
.
Form
):
force
=
forms
.
BooleanField
(
required
=
False
,
label
=
_
(
"Set expiration times even if they are shorter than "
"the current value."
))
def
__init__
(
self
,
*
args
,
**
kwargs
):
choices
=
kwargs
.
pop
(
'choices'
)
default
=
kwargs
.
pop
(
'default'
)
super
(
VmRenewForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'lease'
]
=
forms
.
ModelChoiceField
(
queryset
=
choices
,
initial
=
default
,
required
=
False
,
empty_label
=
None
,
label
=
_
(
'Length'
))
self
.
fields
.
insert
(
0
,
'lease'
,
forms
.
ModelChoiceField
(
queryset
=
choices
,
initial
=
default
,
required
=
False
,
empty_label
=
None
,
label
=
_
(
'Length'
)))
if
len
(
choices
)
<
2
:
self
.
fields
[
'lease'
]
.
widget
=
HiddenInput
()
...
...
circle/vm/operations.py
View file @
bb695789
...
...
@@ -28,7 +28,9 @@ from sizefield.utils import filesizeformat
from
celery.exceptions
import
TimeLimitExceeded
from
common.models
import
create_readable
,
humanize_exception
from
common.models
import
(
create_readable
,
humanize_exception
,
HumanReadableException
)
from
common.operations
import
Operation
,
register_operation
from
.tasks.local_tasks
import
(
abortable_async_instance_operation
,
abortable_async_node_operation
,
...
...
@@ -279,7 +281,10 @@ class DeployOperation(InstanceOperation):
"boot virtual machine"
)):
self
.
instance
.
resume_vm
(
timeout
=
timeout
)
self
.
instance
.
renew
(
parent_activity
=
activity
)
try
:
self
.
instance
.
renew
(
parent_activity
=
activity
)
except
:
pass
register_operation
(
DeployOperation
)
...
...
@@ -700,8 +705,10 @@ class WakeUpOperation(InstanceOperation):
"deploy network"
)):
self
.
instance
.
deploy_net
()
# Renew vm
self
.
instance
.
renew
(
parent_activity
=
activity
)
try
:
self
.
instance
.
renew
(
parent_activity
=
activity
)
except
:
pass
register_operation
(
WakeUpOperation
)
...
...
@@ -716,10 +723,24 @@ class RenewOperation(InstanceOperation):
required_perms
=
()
concurrency_check
=
False
def
_operation
(
self
,
lease
=
None
):
(
self
.
instance
.
time_of_suspend
,
self
.
instance
.
time_of_delete
)
=
self
.
instance
.
get_renew_times
(
lease
)
def
_operation
(
self
,
activity
,
lease
=
None
,
force
=
False
):
suspend
,
delete
=
self
.
instance
.
get_renew_times
(
lease
)
if
(
not
force
and
suspend
and
self
.
instance
.
time_of_suspend
and
suspend
<
self
.
instance
.
time_of_suspend
):
raise
HumanReadableException
.
create
(
ugettext_noop
(
"Renewing the machine with the selected lease would result "
"in its suspension time get earlier than before."
))
if
(
not
force
and
delete
and
self
.
instance
.
time_of_delete
and
delete
<
self
.
instance
.
time_of_delete
):
raise
HumanReadableException
.
create
(
ugettext_noop
(
"Renewing the machine with the selected lease would result "
"in its delete time get earlier than before."
))
self
.
instance
.
time_of_suspend
=
suspend
self
.
instance
.
time_of_delete
=
delete
self
.
instance
.
save
()
activity
.
result
=
create_readable
(
ugettext_noop
(
"Renewed to suspend at
%(suspend)
s and destroy at
%(delete)
s."
),
suspend
=
suspend
,
delete
=
delete
)
register_operation
(
RenewOperation
)
...
...
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