From b401abe7be43c9098ce03138a4296dfbe8fda8e8 Mon Sep 17 00:00:00 2001
From: "Ruben S. Montero" <rsmontero@opennebula.org>
Date: Tue, 4 Jul 2017 16:19:51 +0200
Subject: [PATCH] F #4894: Terminate action when a VM is in a failure state
 invokes delete action

---
 src/dm/DispatchManagerActions.cc | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc
index 09412b0f6b..d4ce82ee0b 100644
--- a/src/dm/DispatchManagerActions.cc
+++ b/src/dm/DispatchManagerActions.cc
@@ -322,6 +322,23 @@ int DispatchManager::terminate(int vid, bool hard, const RequestAttributes& ra,
                     }
                     break;
 
+                case VirtualMachine::BOOT_FAILURE:
+                case VirtualMachine::BOOT_MIGRATE_FAILURE:
+                case VirtualMachine::PROLOG_MIGRATE_FAILURE:
+                case VirtualMachine::PROLOG_FAILURE:
+                case VirtualMachine::EPILOG_FAILURE:
+                case VirtualMachine::EPILOG_STOP_FAILURE:
+                case VirtualMachine::EPILOG_UNDEPLOY_FAILURE:
+                case VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE:
+                case VirtualMachine::PROLOG_MIGRATE_SUSPEND_FAILURE:
+                case VirtualMachine::BOOT_UNDEPLOY_FAILURE:
+                case VirtualMachine::BOOT_STOPPED_FAILURE:
+                case VirtualMachine::PROLOG_RESUME_FAILURE:
+                case VirtualMachine::PROLOG_UNDEPLOY_FAILURE:
+                case VirtualMachine::PROLOG_MIGRATE_UNKNOWN_FAILURE:
+                    lcm->trigger(LCMAction::DELETE, vid, ra);
+                    break;
+
                 default:
                     oss.str("");
                     oss << "Could not terminate VM " << vid