From a808f3bf7e2173fbf44e0521591981f2e38e4d57 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Thu, 14 Sep 2017 02:48:56 +0530 Subject: [PATCH] error fix on termination --- hosting/views.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index ca80a8d1..685fe0b4 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -965,13 +965,17 @@ class VirtualMachineView(LoginRequiredMixin, View): # _('VM %(VM_ID)s terminated successfully') % { # 'VM_ID': opennebula_vm_id} # ) - deleting = True t = 0 - while deleting: - if t < 150 and manager.get_vm(self.kwargs.get('pk')): - sleep(2) + while True: + if t > 150: + break + try: + manager.get_vm(self.kwargs.get('pk')) + except: + break else: - deleting = False + sleep(2) + response['status'] = True response['redirect'] = self.get_success_url() response['text'] = ugettext('Terminated')