Send an email to admin if the VM is still there after 30 seconds
of the VM terminate calll
This commit is contained in:
parent
59b020c0d4
commit
a5cdfab306
1 changed files with 16 additions and 0 deletions
|
@ -1404,6 +1404,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(
|
||||||
|
@ -1421,6 +1424,19 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
sleep(2)
|
sleep(2)
|
||||||
|
if 'status' not in response:
|
||||||
|
vm_msg = "VM {} has not terminated yet!".format(vm.id)
|
||||||
|
admin_email_body['status'] = vm_msg
|
||||||
|
logger.error(vm_msg)
|
||||||
|
err_email_data = {
|
||||||
|
'subject': vm_msg,
|
||||||
|
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
||||||
|
'to': ['info@ungleich.ch'],
|
||||||
|
'body': "Called VM terminate xml-rpc and waited for over "
|
||||||
|
"30 seconds for the VM to disappear. But, it did "
|
||||||
|
"not happen. So, please verify!",
|
||||||
|
}
|
||||||
|
send_plain_email_task.delay(err_email_data)
|
||||||
context = {
|
context = {
|
||||||
'vm_name': vm_name,
|
'vm_name': vm_name,
|
||||||
'base_url': "{0}://{1}".format(
|
'base_url': "{0}://{1}".format(
|
||||||
|
|
Loading…
Reference in a new issue