code reformating
This commit is contained in:
parent
8402fd4fd3
commit
a935871722
2 changed files with 56 additions and 68 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#confirm-cancel').on('click', '.btn-ok', function(e) {
|
||||
|
@ -22,8 +21,7 @@ $( document ).ready(function() {
|
|||
.find('.vm-item-lg').text(data.text);
|
||||
$btn.remove();
|
||||
window.location = data.redirect;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$container.addClass('terminate-fail')
|
||||
.find('.vm-item-lg').text(text);
|
||||
$container.find('.btn').prop('disabled', false);
|
||||
|
|
|
@ -957,6 +957,14 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
|||
response['text'] = ugettext(
|
||||
'Error terminating VM') + opennebula_vm_id
|
||||
else:
|
||||
for t in range(150):
|
||||
try:
|
||||
manager.get_vm(self.kwargs.get('pk'))
|
||||
except BaseException:
|
||||
break
|
||||
else:
|
||||
sleep(2)
|
||||
|
||||
context = {
|
||||
'vm': vm_data,
|
||||
'base_url': "{0}://{1}".format(self.request.scheme,
|
||||
|
@ -973,28 +981,10 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
|||
}
|
||||
email = BaseEmail(**email_data)
|
||||
email.send()
|
||||
|
||||
# messages.error(
|
||||
# request,
|
||||
# _('VM %(VM_ID)s terminated successfully') % {
|
||||
# 'VM_ID': opennebula_vm_id}
|
||||
# )
|
||||
t = 0
|
||||
while True:
|
||||
if t < 150:
|
||||
t += 1
|
||||
try:
|
||||
manager.get_vm(self.kwargs.get('pk'))
|
||||
except BaseException:
|
||||
break
|
||||
else:
|
||||
sleep(2)
|
||||
else:
|
||||
break
|
||||
|
||||
response['status'] = True
|
||||
response['redirect'] = self.get_success_url()
|
||||
response['text'] = ugettext('Terminated')
|
||||
|
||||
return HttpResponse(
|
||||
json.dumps(response),
|
||||
content_type="application/json"
|
||||
|
|
Loading…
Reference in a new issue