mirror of
https://github.com/retspen/webvirtcloud
synced 2025-01-23 21:55:20 +00:00
convert django.core.urlresolver to django.urls. fix i18n. fix identation
This commit is contained in:
parent
39b53dbfc7
commit
a6f7618854
10 changed files with 23 additions and 26 deletions
|
@ -1,6 +1,6 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.http import HttpResponseRedirect
|
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.utils.translation import ugettext_lazy as _
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from accounts.models import *
|
from accounts.models import *
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import json
|
import json
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
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.shortcuts import render, get_object_or_404
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from computes.models import Compute
|
from computes.models import Compute
|
||||||
|
|
|
@ -25,8 +25,8 @@ import socket
|
||||||
from webvirtcloud.settings import WS_PORT, WS_HOST, WS_CERT
|
from webvirtcloud.settings import WS_PORT, WS_HOST, WS_CERT
|
||||||
from vrtManager.connection import CONN_SSH, CONN_SOCKET
|
from vrtManager.connection import CONN_SSH, CONN_SOCKET
|
||||||
from tunnel import Tunnel
|
from tunnel import Tunnel
|
||||||
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
|
|
||||||
parser.add_option("-v",
|
parser.add_option("-v",
|
||||||
|
@ -66,7 +66,6 @@ parser.add_option("-c",
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
FORMAT = "%(asctime)s - %(name)s - %(levelname)s : %(message)s"
|
FORMAT = "%(asctime)s - %(name)s - %(levelname)s : %(message)s"
|
||||||
if options.debug:
|
if options.debug:
|
||||||
logging.basicConfig(level=logging.DEBUG, format=FORMAT)
|
logging.basicConfig(level=logging.DEBUG, format=FORMAT)
|
||||||
|
@ -88,8 +87,7 @@ except ImportError:
|
||||||
try:
|
try:
|
||||||
from novnc.wsproxy import WebSocketProxy
|
from novnc.wsproxy import WebSocketProxy
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print('Unable to import a websockify implementation, ' +
|
print('Unable to import a websockify implementation,\n please install one')
|
||||||
'please install one')
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
USE_HANDLER = False
|
USE_HANDLER = False
|
||||||
|
@ -220,7 +218,6 @@ if USE_HANDLER:
|
||||||
socket_factory = self.server.socket
|
socket_factory = self.server.socket
|
||||||
|
|
||||||
self._new_client(daemon, socket_factory)
|
self._new_client(daemon, socket_factory)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
class NovaWebSocketProxy(WebSocketProxy, CompatibilityMixIn):
|
class NovaWebSocketProxy(WebSocketProxy, CompatibilityMixIn):
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.utils.translation import ugettext_lazy as _
|
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 django.contrib.auth.decorators import login_required
|
||||||
from computes.models import Compute
|
from computes.models import Compute
|
||||||
from create.models import Flavor
|
from create.models import Flavor
|
||||||
|
|
|
@ -8,7 +8,7 @@ import string
|
||||||
import random
|
import random
|
||||||
from bisect import insort
|
from bisect import insort
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
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.shortcuts import render, get_object_or_404
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.http import HttpResponseRedirect
|
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 django.contrib.auth.decorators import login_required
|
||||||
from computes.models import Compute
|
from computes.models import Compute
|
||||||
from interfaces.forms import AddInterface
|
from interfaces.forms import AddInterface
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
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 django.contrib.auth.decorators import login_required
|
||||||
from instances.models import Instance
|
from instances.models import Instance
|
||||||
from logs.models import Logs
|
from logs.models import Logs
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.utils.translation import ugettext_lazy as _
|
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 django.contrib.auth.decorators import login_required
|
||||||
from computes.models import Compute
|
from computes.models import Compute
|
||||||
from networks.forms import AddNetPool
|
from networks.forms import AddNetPool
|
||||||
|
@ -44,7 +44,7 @@ def networks(request, compute_id):
|
||||||
msg = _("Network pool name already in use")
|
msg = _("Network pool name already in use")
|
||||||
error_messages.append(msg)
|
error_messages.append(msg)
|
||||||
if data['forward'] == 'bridge' and data['bridge_name'] == '':
|
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']:
|
if data['subnet']:
|
||||||
ipv4 = True
|
ipv4 = True
|
||||||
gateway4, netmask4, dhcp4 = network_size(data['subnet'], data['dhcp4'])
|
gateway4, netmask4, dhcp4 = network_size(data['subnet'], data['dhcp4'])
|
||||||
|
@ -52,7 +52,7 @@ def networks(request, compute_id):
|
||||||
ipv6 = True
|
ipv6 = True
|
||||||
gateway6, prefix6, dhcp6 = network_size(data['subnet6'], data['dhcp6'])
|
gateway6, prefix6, dhcp6 = network_size(data['subnet6'], data['dhcp6'])
|
||||||
if prefix6 != '64':
|
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:
|
if not error_messages:
|
||||||
conn.create_network(data['name'],
|
conn.create_network(data['name'],
|
||||||
data['forward'],
|
data['forward'],
|
||||||
|
@ -113,7 +113,7 @@ def network(request, compute_id, pool):
|
||||||
ipv6_network = ip_network
|
ipv6_network = ip_network
|
||||||
ipv6_fixed_address = conn.get_dhcp_host_addr(family)
|
ipv6_fixed_address = conn.get_dhcp_host_addr(family)
|
||||||
else:
|
else:
|
||||||
raise Exception("Unknown Network Family")
|
raise Exception(_("Unknown Network Family"))
|
||||||
|
|
||||||
xml = conn._XMLDesc(0)
|
xml = conn._XMLDesc(0)
|
||||||
except libvirtError as lib_err:
|
except libvirtError as lib_err:
|
||||||
|
@ -163,7 +163,7 @@ def network(request, compute_id, pool):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ret_val = conn.modify_fixed_address(name, address, mac_duid, family)
|
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())
|
return HttpResponseRedirect(request.get_full_path())
|
||||||
except libvirtError as lib_err:
|
except libvirtError as lib_err:
|
||||||
error_messages.append(lib_err.message)
|
error_messages.append(lib_err.message)
|
||||||
|
@ -173,7 +173,7 @@ def network(request, compute_id, pool):
|
||||||
ip = request.POST.get('address', '')
|
ip = request.POST.get('address', '')
|
||||||
family = request.POST.get('family', 'ipv4')
|
family = request.POST.get('family', 'ipv4')
|
||||||
conn.delete_fixed_address(ip, family)
|
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())
|
return HttpResponseRedirect(request.get_full_path())
|
||||||
if 'modify_dhcp_range' in request.POST:
|
if 'modify_dhcp_range' in request.POST:
|
||||||
range_start = request.POST.get('range_start', '')
|
range_start = request.POST.get('range_start', '')
|
||||||
|
@ -181,7 +181,7 @@ def network(request, compute_id, pool):
|
||||||
family = request.POST.get('family', 'ipv4')
|
family = request.POST.get('family', 'ipv4')
|
||||||
try:
|
try:
|
||||||
conn.modify_dhcp_range(range_start, range_end, family)
|
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())
|
return HttpResponseRedirect(request.get_full_path())
|
||||||
except libvirtError as lib_err:
|
except libvirtError as lib_err:
|
||||||
error_messages.append(lib_err.message)
|
error_messages.append(lib_err.message)
|
||||||
|
@ -204,10 +204,10 @@ def network(request, compute_id, pool):
|
||||||
try:
|
try:
|
||||||
conn.set_qos(qos_dir, average, peak, burst)
|
conn.set_qos(qos_dir, average, peak, burst)
|
||||||
if conn.is_active():
|
if conn.is_active():
|
||||||
messages.success(request, "{} Qos is set. Network XML is changed.".format(qos_dir.capitalize()) +
|
messages.success(request, _("{} Qos is set. Network XML is changed.").format(qos_dir.capitalize()) +
|
||||||
"Stop and start network to activate new config")
|
_("Stop and start network to activate new config"))
|
||||||
else:
|
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:
|
except libvirtError as le:
|
||||||
messages.error(request, le.message)
|
messages.error(request, le.message)
|
||||||
return HttpResponseRedirect(request.get_full_path())
|
return HttpResponseRedirect(request.get_full_path())
|
||||||
|
@ -216,10 +216,10 @@ def network(request, compute_id, pool):
|
||||||
conn.unset_qos(qos_dir)
|
conn.unset_qos(qos_dir)
|
||||||
|
|
||||||
if conn.is_active():
|
if conn.is_active():
|
||||||
messages.success(request, "{} Qos is deleted. Network XML is changed. ".format(qos_dir.capitalize()) +
|
messages.success(request, _("{} Qos is deleted. Network XML is changed. ").format(qos_dir.capitalize()) +
|
||||||
"Stop and start network to activate new config.")
|
_("Stop and start network to activate new config."))
|
||||||
else:
|
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())
|
return HttpResponseRedirect(request.get_full_path())
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import unicode_literals
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.utils.translation import ugettext_lazy as _
|
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 django.contrib.auth.decorators import login_required
|
||||||
from computes.models import Compute
|
from computes.models import Compute
|
||||||
from vrtManager import util
|
from vrtManager import util
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.http import HttpResponseRedirect
|
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 django.contrib.auth.decorators import login_required
|
||||||
from computes.models import Compute
|
from computes.models import Compute
|
||||||
from secrets.forms import AddSecret
|
from secrets.forms import AddSecret
|
||||||
|
|
Loading…
Reference in a new issue