Merge pull request #648 from pcoder/bugfix/log_vm_terminate_errors
Bugfix/log vm terminate errors
This commit is contained in:
commit
743ce4ed70
3 changed files with 27 additions and 16 deletions
|
@ -1400,7 +1400,7 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
terminated = manager.delete_vm(vm.id)
|
terminated = manager.delete_vm(vm.id)
|
||||||
|
|
||||||
if not terminated:
|
if not terminated:
|
||||||
logger.debug(
|
logger.error(
|
||||||
"manager.delete_vm returned False. Hence, error making "
|
"manager.delete_vm returned False. Hence, error making "
|
||||||
"xml-rpc call to delete vm failed."
|
"xml-rpc call to delete vm failed."
|
||||||
)
|
)
|
||||||
|
@ -1410,6 +1410,9 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
try:
|
try:
|
||||||
manager.get_vm(vm.id)
|
manager.get_vm(vm.id)
|
||||||
except WrongIdError:
|
except WrongIdError:
|
||||||
|
logger.error(
|
||||||
|
"VM {} not found. So, its terminated.".format(vm.id)
|
||||||
|
)
|
||||||
response['status'] = True
|
response['status'] = True
|
||||||
response['text'] = ugettext('Terminated')
|
response['text'] = ugettext('Terminated')
|
||||||
vm_detail_obj = VMDetail.objects.filter(
|
vm_detail_obj = VMDetail.objects.filter(
|
||||||
|
@ -1427,6 +1430,12 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
sleep(2)
|
sleep(2)
|
||||||
|
if not response['status']:
|
||||||
|
response['details'] = (
|
||||||
|
"Called VM terminate xml-rpc and waited for over "
|
||||||
|
"30 seconds for the VM to disappear. But, it did "
|
||||||
|
"not happen. So, please verify!"
|
||||||
|
)
|
||||||
context = {
|
context = {
|
||||||
'vm_name': vm_name,
|
'vm_name': vm_name,
|
||||||
'base_url': "{0}://{1}".format(
|
'base_url': "{0}://{1}".format(
|
||||||
|
@ -1447,11 +1456,13 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
email = BaseEmail(**email_data)
|
email = BaseEmail(**email_data)
|
||||||
email.send()
|
email.send()
|
||||||
admin_email_body.update(response)
|
admin_email_body.update(response)
|
||||||
|
admin_msg_sub = "VM and Subscription for VM {} and user: {}".format(
|
||||||
|
vm.id,
|
||||||
|
owner.email
|
||||||
|
)
|
||||||
email_to_admin_data = {
|
email_to_admin_data = {
|
||||||
'subject': "Deleted VM and Subscription for VM {vm_id} and "
|
'subject': ("Deleted " if response['status']
|
||||||
"user: {user}".format(
|
else "ERROR deleting ") + admin_msg_sub,
|
||||||
vm_id=vm.id, user=owner.email
|
|
||||||
),
|
|
||||||
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
||||||
'to': ['info@ungleich.ch'],
|
'to': ['info@ungleich.ch'],
|
||||||
'body': "\n".join(
|
'body': "\n".join(
|
||||||
|
|
|
@ -110,7 +110,7 @@ class OpenNebulaManager():
|
||||||
raise UserExistsError()
|
raise UserExistsError()
|
||||||
except OpenNebulaException as err:
|
except OpenNebulaException as err:
|
||||||
logger.error('OpenNebulaException error: {0}'.format(err))
|
logger.error('OpenNebulaException error: {0}'.format(err))
|
||||||
logger.debug('User exists but password is wrong')
|
logger.error('User exists but password is wrong')
|
||||||
raise UserCredentialError()
|
raise UserCredentialError()
|
||||||
|
|
||||||
except WrongNameError:
|
except WrongNameError:
|
||||||
|
@ -148,7 +148,7 @@ class OpenNebulaManager():
|
||||||
)
|
)
|
||||||
return opennebula_user
|
return opennebula_user
|
||||||
except ConnectionRefusedError:
|
except ConnectionRefusedError:
|
||||||
logger.info(
|
logger.error(
|
||||||
'Could not connect to host: {host} via protocol {protocol}'.format(
|
'Could not connect to host: {host} via protocol {protocol}'.format(
|
||||||
host=settings.OPENNEBULA_DOMAIN,
|
host=settings.OPENNEBULA_DOMAIN,
|
||||||
protocol=settings.OPENNEBULA_PROTOCOL)
|
protocol=settings.OPENNEBULA_PROTOCOL)
|
||||||
|
@ -160,7 +160,7 @@ class OpenNebulaManager():
|
||||||
user_pool = oca.UserPool(self.oneadmin_client)
|
user_pool = oca.UserPool(self.oneadmin_client)
|
||||||
user_pool.info()
|
user_pool.info()
|
||||||
except ConnectionRefusedError:
|
except ConnectionRefusedError:
|
||||||
logger.info(
|
logger.error(
|
||||||
'Could not connect to host: {host} via protocol {protocol}'.format(
|
'Could not connect to host: {host} via protocol {protocol}'.format(
|
||||||
host=settings.OPENNEBULA_DOMAIN,
|
host=settings.OPENNEBULA_DOMAIN,
|
||||||
protocol=settings.OPENNEBULA_PROTOCOL)
|
protocol=settings.OPENNEBULA_PROTOCOL)
|
||||||
|
@ -174,7 +174,7 @@ class OpenNebulaManager():
|
||||||
vm_pool.info()
|
vm_pool.info()
|
||||||
return vm_pool
|
return vm_pool
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
logger.info('Could not connect via client, using oneadmin instead')
|
logger.error('Could not connect via client, using oneadmin instead')
|
||||||
try:
|
try:
|
||||||
vm_pool = oca.VirtualMachinePool(self.oneadmin_client)
|
vm_pool = oca.VirtualMachinePool(self.oneadmin_client)
|
||||||
vm_pool.info(filter=-2)
|
vm_pool.info(filter=-2)
|
||||||
|
@ -183,7 +183,7 @@ class OpenNebulaManager():
|
||||||
raise ConnectionRefusedError
|
raise ConnectionRefusedError
|
||||||
|
|
||||||
except ConnectionRefusedError:
|
except ConnectionRefusedError:
|
||||||
logger.info(
|
logger.error(
|
||||||
'Could not connect to host: {host} via protocol {protocol}'.format(
|
'Could not connect to host: {host} via protocol {protocol}'.format(
|
||||||
host=settings.OPENNEBULA_DOMAIN,
|
host=settings.OPENNEBULA_DOMAIN,
|
||||||
protocol=settings.OPENNEBULA_PROTOCOL)
|
protocol=settings.OPENNEBULA_PROTOCOL)
|
||||||
|
@ -325,14 +325,14 @@ class OpenNebulaManager():
|
||||||
)
|
)
|
||||||
vm_terminated = True
|
vm_terminated = True
|
||||||
except socket.timeout as socket_err:
|
except socket.timeout as socket_err:
|
||||||
logger.info("Socket timeout error: {0}".format(socket_err))
|
logger.error("Socket timeout error: {0}".format(socket_err))
|
||||||
except OpenNebulaException as opennebula_err:
|
except OpenNebulaException as opennebula_err:
|
||||||
logger.info(
|
logger.error(
|
||||||
"OpenNebulaException error: {0}".format(opennebula_err))
|
"OpenNebulaException error: {0}".format(opennebula_err))
|
||||||
except OSError as os_err:
|
except OSError as os_err:
|
||||||
logger.info("OSError : {0}".format(os_err))
|
logger.error("OSError : {0}".format(os_err))
|
||||||
except ValueError as value_err:
|
except ValueError as value_err:
|
||||||
logger.info("ValueError : {0}".format(value_err))
|
logger.error("ValueError : {0}".format(value_err))
|
||||||
|
|
||||||
return vm_terminated
|
return vm_terminated
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ class OpenNebulaManager():
|
||||||
template_pool.info()
|
template_pool.info()
|
||||||
return template_pool
|
return template_pool
|
||||||
except ConnectionRefusedError:
|
except ConnectionRefusedError:
|
||||||
logger.info(
|
logger.error(
|
||||||
"""Could not connect to host: {host} via protocol
|
"""Could not connect to host: {host} via protocol
|
||||||
{protocol}""".format(
|
{protocol}""".format(
|
||||||
host=settings.OPENNEBULA_DOMAIN,
|
host=settings.OPENNEBULA_DOMAIN,
|
||||||
|
|
Loading…
Reference in a new issue