From 8db7ead9e272e2c9536c31e245d2765915bcf1c3 Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Tue, 19 Sep 2017 00:24:06 +0530 Subject: [PATCH] checking VM termination error --- hosting/views.py | 5 +++-- opennebula_api/models.py | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index 8356d5ad..5f123dd4 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -969,11 +969,12 @@ class VirtualMachineView(LoginRequiredMixin, View): kwargs={'pk': opennebula_vm_id}) ) - terminated = manager.delete_vm(vm.id) + terminated, err = manager.delete_vm(vm.id) if not terminated: response['text'] = ugettext( - 'Error terminating VM') + opennebula_vm_id + 'Error terminating VM') + opennebula_vm_id + '\n' + + err else: for t in range(15): try: diff --git a/opennebula_api/models.py b/opennebula_api/models.py index d584bf26..9eb89fdf 100644 --- a/opennebula_api/models.py +++ b/opennebula_api/models.py @@ -324,6 +324,7 @@ class OpenNebulaManager(): def delete_vm(self, vm_id): TERMINATE_ACTION = 'terminate' vm_terminated = False + err = '' try: self.oneadmin_client.call( oca.VirtualMachine.METHODS['action'], @@ -333,15 +334,19 @@ class OpenNebulaManager(): vm_terminated = True except socket.timeout as socket_err: logger.info("Socket timeout error: {0}".format(socket_err)) + err = ("Socket timeout error: {0}".format(socket_err)) except OpenNebulaException as opennebula_err: logger.info( "OpenNebulaException error: {0}".format(opennebula_err)) + err = ("OpenNebulaException error: {0}".format(opennebula_err)) except OSError as os_err: logger.info("OSError : {0}".format(os_err)) + err = ("OSError : {0}".format(os_err)) except ValueError as value_err: logger.info("ValueError : {0}".format(value_err)) + err = ("ValueError : {0}".format(value_err)) - return vm_terminated + return (vm_terminated, err) def _get_template_pool(self): try: