[Kimchi-devel] [PATCH v2][Kimchi 2/3] Fix issue when clone a vm multiple times

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Tue Mar 15 04:16:39 UTC 2016


Use timestamp in "get_next_clone_name" function to avoid problemas with
the incremental number in the new clone names.
This patch also fixes imports of the function from Wok.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 mockmodel.py            | 4 ++--
 model/storagevolumes.py | 4 ++--
 model/vms.py            | 5 +++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/mockmodel.py b/mockmodel.py
index cbeeb5d..c3c6930 100644
--- a/mockmodel.py
+++ b/mockmodel.py
@@ -28,7 +28,7 @@ from lxml.builder import E
 
 from wok.exception import NotFoundError, OperationFailed
 from wok.objectstore import ObjectStore
-from wok.utils import add_task, get_next_clone_name
+from wok.utils import add_task
 from wok.xmlutils.utils import xml_item_update
 
 from wok.plugins.kimchi import imageinfo
@@ -49,7 +49,7 @@ from wok.plugins.kimchi.model import storagevolumes
 from wok.plugins.kimchi.model.templates import LibvirtVMTemplate
 from wok.plugins.kimchi.model.users import PAMUsersModel
 from wok.plugins.kimchi.model.vmhostdevs import VMHostDevsModel
-from wok.plugins.kimchi.utils import pool_name_from_uri
+from wok.plugins.kimchi.utils import get_next_clone_name, pool_name_from_uri
 from wok.plugins.kimchi.vmtemplate import VMTemplate
 
 
diff --git a/model/storagevolumes.py b/model/storagevolumes.py
index f87738f..83f38e2 100644
--- a/model/storagevolumes.py
+++ b/model/storagevolumes.py
@@ -30,8 +30,7 @@ from lxml.builder import E
 
 from wok.exception import InvalidOperation, InvalidParameter, IsoFormatError
 from wok.exception import MissingParameter, NotFoundError, OperationFailed
-from wok.utils import add_task, get_next_clone_name, get_unique_file_name
-from wok.utils import wok_log
+from wok.utils import add_task, get_unique_file_name, wok_log
 from wok.xmlutils.utils import xpath_get_text
 from wok.model.tasks import TaskModel
 
@@ -40,6 +39,7 @@ from wok.plugins.kimchi.isoinfo import IsoImage
 from wok.plugins.kimchi.model.diskutils import get_disk_used_by
 from wok.plugins.kimchi.model.diskutils import set_disk_used_by
 from wok.plugins.kimchi.model.storagepools import StoragePoolModel
+from wok.plugins.kimchi.utils import get_next_clone_name
 
 
 VOLUME_TYPE_MAP = {0: 'file',
diff --git a/model/vms.py b/model/vms.py
index 195c879..9f464f4 100644
--- a/model/vms.py
+++ b/model/vms.py
@@ -39,7 +39,7 @@ from wok.exception import InvalidOperation, InvalidParameter
 from wok.exception import NotFoundError, OperationFailed
 from wok.model.tasks import TaskModel
 from wok.rollbackcontext import RollbackContext
-from wok.utils import add_task, convert_data_size, get_next_clone_name
+from wok.utils import add_task, convert_data_size
 from wok.utils import import_class, run_setfacl_set_attr, run_command, wok_log
 from wok.xmlutils.utils import dictize, xpath_get_text, xml_item_insert
 from wok.xmlutils.utils import xml_item_remove, xml_item_update
@@ -59,6 +59,7 @@ from wok.plugins.kimchi.model.utils import get_metadata_node
 from wok.plugins.kimchi.model.utils import remove_metadata_node
 from wok.plugins.kimchi.model.utils import set_metadata_node
 from wok.plugins.kimchi.screenshot import VMScreenshot
+from wok.plugins.kimchi.utils import get_next_clone_name
 from wok.plugins.kimchi.utils import template_name_from_uri
 from wok.plugins.kimchi.xmlutils.cpu import get_cpu_xml, get_numa_xml
 from wok.plugins.kimchi.xmlutils.cpu import get_topology_xml
@@ -318,7 +319,7 @@ class VMModel(object):
                     vms_being_created.append(uri_name)
 
         current_vm_names = self.vms.get_list() + vms_being_created
-        new_name = get_next_clone_name(current_vm_names, name)
+        new_name = get_next_clone_name(current_vm_names, name, ts=True)
 
         # create a task with the actual clone function
         taskid = add_task(u'/plugins/kimchi/vms/%s/clone' % new_name,
-- 
2.1.0




More information about the Kimchi-devel mailing list