From 48371ff92d150fb0a8ae1cd3e47643340b6646e5 Mon Sep 17 00:00:00 2001
From: "Ing. Jan KRCMAR" <honza801@civ.zcu.cz>
Date: Fri, 4 Nov 2016 09:33:49 +0100
Subject: [PATCH] deleting instance with disk causes also delete of all
 corresponding snapshots. previously deleting instance with snapshots ended
 with error and probably also database inconsistency.

---
 instances/views.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/instances/views.py b/instances/views.py
index c5eb1a7..4dfe4e5 100644
--- a/instances/views.py
+++ b/instances/views.py
@@ -347,6 +347,8 @@ def instance(request, compute_id, vname):
                 if conn.get_status() == 1:
                     conn.force_shutdown()
                 if request.POST.get('delete_disk', ''):
+                    for snap in snapshots:
+                        conn.snapshot_delete(snap['name'])
                     conn.delete_disk()
                 conn.delete()