Commit 8595c190 by Őry Máté

vm: add default name to save_as_template

parent d3889c7e
from __future__ import absolute_import, unicode_literals
from logging import getLogger
from re import match
from django.core.exceptions import PermissionDenied
from django.utils import timezone
......@@ -206,7 +207,15 @@ class SaveAsTemplateOperation(InstanceOperation):
icon = 'save'
def _operation(self, activity, name, user, system, timeout=300,
def _rename(self, name):
m = match("^(.*)( v(\d+))?$", name)
if is None:
v = 2
v = int(v) + 1
return "%s v%d" % (, v)
def _operation(self, activity, user, system, timeout=300,
with_shutdown=True, **kwargs):
if with_shutdown:
......@@ -219,7 +228,7 @@ class SaveAsTemplateOperation(InstanceOperation):
'description': self.instance.description,
'lease':, # Can be problem in new VM
'max_ram_size': self.instance.max_ram_size,
'name': name,
'name': self._rename(,
'num_cores': self.instance.num_cores,
'owner': user,
'parent': self.instance.template, # Can be problem
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