Commit 0cf2b4c6 by Őry Máté

vm: add activity to Instance.renew

parent 42cc6856
...@@ -632,17 +632,23 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel): ...@@ -632,17 +632,23 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
timezone.now() + self.lease.suspend_interval, timezone.now() + self.lease.suspend_interval,
timezone.now() + self.lease.delete_interval) timezone.now() + self.lease.delete_interval)
def renew(self, which='both'): def renew(self, which='both', base_activity=None, user=None):
"""Renew virtual machine instance leases. """Renew virtual machine instance leases.
""" """
if which not in ('suspend', 'delete', 'both'): if base_activity is None:
raise ValueError('No such expiration type.') act = instance_activity(code_suffix='renew', instance=self,
time_of_suspend, time_of_delete = self.get_renew_times() user=user)
if which in ('suspend', 'both'): else:
self.time_of_suspend = time_of_suspend act = base_activity.sub_activity('renew')
if which in ('delete', 'both'): with act:
self.time_of_delete = time_of_delete if which not in ('suspend', 'delete', 'both'):
self.save() raise ValueError('No such expiration type.')
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): def change_password(self, user=None):
"""Generate new password for the vm """Generate new password for the vm
......
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