1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-01-23 13:45:21 +00:00

convert django.core.urlresolver to django.urls. fix i18n. fix identation

This commit is contained in:
catborise 2020-01-24 10:09:46 +03:00
parent 39b53dbfc7
commit a6f7618854
10 changed files with 23 additions and 26 deletions

View file

@ -1,6 +1,6 @@
from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.decorators import login_required
from accounts.models import *

View file

@ -1,7 +1,7 @@
import json
from django.utils import timezone
from django.http import HttpResponse, HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.shortcuts import render, get_object_or_404
from django.contrib.auth.decorators import login_required
from computes.models import Compute

View file

@ -25,8 +25,8 @@ import socket
from webvirtcloud.settings import WS_PORT, WS_HOST, WS_CERT
from vrtManager.connection import CONN_SSH, CONN_SOCKET
from tunnel import Tunnel
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-v",
@ -66,7 +66,6 @@ parser.add_option("-c",
(options, args) = parser.parse_args()
FORMAT = "%(asctime)s - %(name)s - %(levelname)s : %(message)s"
if options.debug:
logging.basicConfig(level=logging.DEBUG, format=FORMAT)
@ -88,8 +87,7 @@ except ImportError:
try:
from novnc.wsproxy import WebSocketProxy
except ImportError:
print('Unable to import a websockify implementation, ' +
'please install one')
print('Unable to import a websockify implementation,\n please install one')
sys.exit(1)
else:
USE_HANDLER = False
@ -220,7 +218,6 @@ if USE_HANDLER:
socket_factory = self.server.socket
self._new_client(daemon, socket_factory)
else:
class NovaWebSocketProxy(WebSocketProxy, CompatibilityMixIn):

View file

@ -1,7 +1,7 @@
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.contrib.auth.decorators import login_required
from computes.models import Compute
from create.models import Flavor

View file

@ -8,7 +8,7 @@ import string
import random
from bisect import insort
from django.http import HttpResponse, HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.shortcuts import render, get_object_or_404
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.decorators import login_required

View file

@ -1,6 +1,6 @@
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.contrib.auth.decorators import login_required
from computes.models import Compute
from interfaces.forms import AddInterface

View file

@ -1,6 +1,6 @@
from django.shortcuts import render
from django.http import HttpResponse, HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.contrib.auth.decorators import login_required
from instances.models import Instance
from logs.models import Logs

View file

@ -1,7 +1,7 @@
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.contrib.auth.decorators import login_required
from computes.models import Compute
from networks.forms import AddNetPool
@ -44,7 +44,7 @@ def networks(request, compute_id):
msg = _("Network pool name already in use")
error_messages.append(msg)
if data['forward'] == 'bridge' and data['bridge_name'] == '':
error_messages.append('Please enter bridge name')
error_messages.append(_('Please enter bridge name'))
if data['subnet']:
ipv4 = True
gateway4, netmask4, dhcp4 = network_size(data['subnet'], data['dhcp4'])
@ -52,7 +52,7 @@ def networks(request, compute_id):
ipv6 = True
gateway6, prefix6, dhcp6 = network_size(data['subnet6'], data['dhcp6'])
if prefix6 != '64':
error_messages.append('For libvirt, the IPv6 network prefix must be /64')
error_messages.append(_('For libvirt, the IPv6 network prefix must be /64'))
if not error_messages:
conn.create_network(data['name'],
data['forward'],
@ -113,7 +113,7 @@ def network(request, compute_id, pool):
ipv6_network = ip_network
ipv6_fixed_address = conn.get_dhcp_host_addr(family)
else:
raise Exception("Unknown Network Family")
raise Exception(_("Unknown Network Family"))
xml = conn._XMLDesc(0)
except libvirtError as lib_err:
@ -163,7 +163,7 @@ def network(request, compute_id, pool):
try:
ret_val = conn.modify_fixed_address(name, address, mac_duid, family)
messages.success(request, "{} Fixed Address Operation Completed.".format(family.upper()))
messages.success(request, _("{} Fixed Address Operation Completed.").format(family.upper()))
return HttpResponseRedirect(request.get_full_path())
except libvirtError as lib_err:
error_messages.append(lib_err.message)
@ -173,7 +173,7 @@ def network(request, compute_id, pool):
ip = request.POST.get('address', '')
family = request.POST.get('family', 'ipv4')
conn.delete_fixed_address(ip, family)
messages.success(request, "{} Fixed Address is Deleted.".format(family.upper()))
messages.success(request, _("{} Fixed Address is Deleted.").format(family.upper()))
return HttpResponseRedirect(request.get_full_path())
if 'modify_dhcp_range' in request.POST:
range_start = request.POST.get('range_start', '')
@ -181,7 +181,7 @@ def network(request, compute_id, pool):
family = request.POST.get('family', 'ipv4')
try:
conn.modify_dhcp_range(range_start, range_end, family)
messages.success(request, "{} DHCP Range is Changed.".format(family.upper()))
messages.success(request, _("{} DHCP Range is Changed.").format(family.upper()))
return HttpResponseRedirect(request.get_full_path())
except libvirtError as lib_err:
error_messages.append(lib_err.message)
@ -204,10 +204,10 @@ def network(request, compute_id, pool):
try:
conn.set_qos(qos_dir, average, peak, burst)
if conn.is_active():
messages.success(request, "{} Qos is set. Network XML is changed.".format(qos_dir.capitalize()) +
"Stop and start network to activate new config")
messages.success(request, _("{} Qos is set. Network XML is changed.").format(qos_dir.capitalize()) +
_("Stop and start network to activate new config"))
else:
messages.success(request, "{} Qos is set".format(qos_dir.capitalize()))
messages.success(request, _("{} Qos is set").format(qos_dir.capitalize()))
except libvirtError as le:
messages.error(request, le.message)
return HttpResponseRedirect(request.get_full_path())
@ -216,10 +216,10 @@ def network(request, compute_id, pool):
conn.unset_qos(qos_dir)
if conn.is_active():
messages.success(request, "{} Qos is deleted. Network XML is changed. ".format(qos_dir.capitalize()) +
"Stop and start network to activate new config.")
messages.success(request, _("{} Qos is deleted. Network XML is changed. ").format(qos_dir.capitalize()) +
_("Stop and start network to activate new config."))
else:
messages.success(request, "{} Qos is deleted".format(qos_dir.capitalize()))
messages.success(request, _("{} Qos is deleted").format(qos_dir.capitalize()))
return HttpResponseRedirect(request.get_full_path())
conn.close()

View file

@ -4,7 +4,7 @@ from __future__ import unicode_literals
from django.http import HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.contrib.auth.decorators import login_required
from computes.models import Compute
from vrtManager import util

View file

@ -1,6 +1,6 @@
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.contrib.auth.decorators import login_required
from computes.models import Compute
from secrets.forms import AddSecret