code reformating

This commit is contained in:
Arvind Tiwari 2017-09-15 00:57:59 +05:30
parent 8402fd4fd3
commit a935871722
2 changed files with 56 additions and 68 deletions

View file

@ -1,4 +1,3 @@
$(document).ready(function() { $(document).ready(function() {
$('#confirm-cancel').on('click', '.btn-ok', function(e) { $('#confirm-cancel').on('click', '.btn-ok', function(e) {
@ -22,8 +21,7 @@ $( document ).ready(function() {
.find('.vm-item-lg').text(data.text); .find('.vm-item-lg').text(data.text);
$btn.remove(); $btn.remove();
window.location = data.redirect; window.location = data.redirect;
} } else {
else {
$container.addClass('terminate-fail') $container.addClass('terminate-fail')
.find('.vm-item-lg').text(text); .find('.vm-item-lg').text(text);
$container.find('.btn').prop('disabled', false); $container.find('.btn').prop('disabled', false);

View file

@ -957,6 +957,14 @@ class VirtualMachineView(LoginRequiredMixin, View):
response['text'] = ugettext( response['text'] = ugettext(
'Error terminating VM') + opennebula_vm_id 'Error terminating VM') + opennebula_vm_id
else: else:
for t in range(150):
try:
manager.get_vm(self.kwargs.get('pk'))
except BaseException:
break
else:
sleep(2)
context = { context = {
'vm': vm_data, 'vm': vm_data,
'base_url': "{0}://{1}".format(self.request.scheme, 'base_url': "{0}://{1}".format(self.request.scheme,
@ -973,28 +981,10 @@ class VirtualMachineView(LoginRequiredMixin, View):
} }
email = BaseEmail(**email_data) email = BaseEmail(**email_data)
email.send() 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['status'] = True
response['redirect'] = self.get_success_url() response['redirect'] = self.get_success_url()
response['text'] = ugettext('Terminated') response['text'] = ugettext('Terminated')
return HttpResponse( return HttpResponse(
json.dumps(response), json.dumps(response),
content_type="application/json" content_type="application/json"