From 323e0a10d59e771eda6f7b07cb4b147ff6dd8948 Mon Sep 17 00:00:00 2001 From: Jan Krcmar Date: Mon, 8 Feb 2016 10:13:19 +0100 Subject: [PATCH] show_clone_disk generates cloned images name with "-*" suffix. fe: vname=vm1 vm1-root becomes vm1-clone-root (was vm1-root-clone) --- instances/views.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/instances/views.py b/instances/views.py index abb8653..34bf678 100644 --- a/instances/views.py +++ b/instances/views.py @@ -168,12 +168,15 @@ def instance(request, compute_id, vname): if not userinstace: return HttpResponseRedirect(reverse('index')) - def show_clone_disk(disks): + def show_clone_disk(disks, vname=''): clone_disk = [] for disk in disks: if disk['image'] is None: continue - if disk['image'].count(".") and len(disk['image'].rsplit(".", 1)[1]) <= 7: + if disk['image'].count("-") and disk['image'].rsplit("-", 1)[0] == vname: + name, suffix = disk['image'].rsplit("-", 1) + image = name + "-clone" + "-" + suffix + elif disk['image'].count(".") and len(disk['image'].rsplit(".", 1)[1]) <= 7: name, suffix = disk['image'].rsplit(".", 1) image = name + "-clone" + "." + suffix else: @@ -234,7 +237,7 @@ def instance(request, compute_id, vname): snapshots = sorted(conn.get_snapshot(), reverse=True) inst_xml = conn._XMLDesc(VIR_DOMAIN_XML_SECURE) has_managed_save_image = conn.get_managed_save_image() - clone_disks = show_clone_disk(disks) + clone_disks = show_clone_disk(disks, vname) console_passwd = conn.get_console_passwd() try: