Commit e5b9cb0f by Bach Dániel

Merge branch 'fix-renew' into 'master'

Fix renew 

closes #375

See merge request !334
parents 3122ce02 707287be
...@@ -973,26 +973,48 @@ class RenewOperation(InstanceOperation): ...@@ -973,26 +973,48 @@ class RenewOperation(InstanceOperation):
required_perms = () required_perms = ()
concurrency_check = False concurrency_check = False
def _operation(self, activity, lease=None, force=False, save=False): def set_time_of_suspend(self, activity, suspend, force):
suspend, delete = self.instance.get_renew_times(lease) with activity.sub_activity(
'renew_suspend', concurrency_check=False,
readable_name=ugettext_noop('set time of suspend')):
if (not force and suspend and self.instance.time_of_suspend and if (not force and suspend and self.instance.time_of_suspend and
suspend < self.instance.time_of_suspend): suspend < self.instance.time_of_suspend):
raise HumanReadableException.create(ugettext_noop( raise HumanReadableException.create(ugettext_noop(
"Renewing the machine with the selected lease would result " "Renewing the machine with the selected lease would "
"in its suspension time get earlier than before.")) "result in its suspension time get earlier than before."))
self.instance.time_of_suspend = suspend
def set_time_of_delete(self, activity, delete, force):
with activity.sub_activity(
'renew_delete', concurrency_check=False,
readable_name=ugettext_noop('set time of delete')):
if (not force and delete and self.instance.time_of_delete and if (not force and delete and self.instance.time_of_delete and
delete < self.instance.time_of_delete): delete < self.instance.time_of_delete):
raise HumanReadableException.create(ugettext_noop( raise HumanReadableException.create(ugettext_noop(
"Renewing the machine with the selected lease would result " "Renewing the machine with the selected lease would "
"in its delete time get earlier than before.")) "result in its delete time get earlier than before."))
self.instance.time_of_suspend = suspend
self.instance.time_of_delete = delete self.instance.time_of_delete = delete
def _operation(self, activity, lease=None, force=False, save=False):
suspend, delete = self.instance.get_renew_times(lease)
try:
self.set_time_of_suspend(activity, suspend, force)
except HumanReadableException:
pass
try:
self.set_time_of_delete(activity, delete, force)
except HumanReadableException:
pass
if save: if save:
self.instance.lease = lease self.instance.lease = lease
self.instance.save() self.instance.save()
return create_readable(ugettext_noop( return create_readable(ugettext_noop(
"Renewed to suspend at %(suspend)s and destroy at %(delete)s."), "Renewed to suspend at %(suspend)s and destroy at %(delete)s."),
suspend=suspend, delete=delete) suspend=self.instance.time_of_suspend,
delete=self.instance.time_of_suspend)
@register_operation @register_operation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment