diff --git a/create/views.py b/create/views.py index 0518ab5..b92ad35 100644 --- a/create/views.py +++ b/create/views.py @@ -15,6 +15,7 @@ from vrtManager import util from logs.views import addlogmsg from webvirtcloud.settings import QEMU_CONSOLE_LISTEN_ADDRESSES + @superuser_only def create_instance_select_type(request, compute_id): """ @@ -54,7 +55,7 @@ def create_instance_select_type(request, compute_id): else: try: conn._defineXML(xml) - return HttpResponseRedirect(reverse('instance', args=[compute_id, name])) + return HttpResponseRedirect(reverse('instances:instance', args=[compute_id, name])) except libvirtError as lib_err: error_messages.append(lib_err) @@ -173,13 +174,14 @@ def create_instance(request, compute_id, arch, machine): else: try: path = conn.create_volume( - data['storage'], - data['name'], - data['hdd_size'], + data['storage'], + data['name'], + data['hdd_size'], default_disk_format, - meta_prealloc, - default_disk_owner_uid, - default_disk_owner_gid) + meta_prealloc, + default_disk_owner_uid, + default_disk_owner_gid, + ) volume = dict() volume['device'] = 'disk' volume['path'] = path @@ -194,7 +196,7 @@ def create_instance(request, compute_id, arch, machine): volume_list.append(volume) is_disk_created = True - + except libvirtError as lib_err: error_messages.append(lib_err) elif data['template']: @@ -210,7 +212,8 @@ def create_instance(request, compute_id, arch, machine): data['storage'], meta_prealloc, default_disk_owner_uid, - default_disk_owner_gid) + default_disk_owner_gid, + ) volume = dict() volume['path'] = clone_path volume['type'] = conn.get_volume_type(clone_path) @@ -276,13 +279,13 @@ def create_instance(request, compute_id, arch, machine): machine=machine, firmware=firmware, volumes=volume_list, - networks=data['networks'], + networks=data['networks'], virtio=data['virtio'], - listen_addr=data["listener_addr"], + listen_addr=data["listener_addr"], nwfilter=data["nwfilter"], - graphics=data["graphics"], + graphics=data["graphics"], video=data["video"], - console_pass=data["console_pass"], + console_pass=data["console_pass"], mac=data['mac'], qemu_ga=data['qemu_ga']) create_instance = Instance(compute_id=compute_id, name=data['name'], uuid=uuid) @@ -290,7 +293,7 @@ def create_instance(request, compute_id, arch, machine): msg = _("Instance is created") messages.success(request, msg) addlogmsg(request.user.username, create_instance.name, msg) - return HttpResponseRedirect(reverse('instance', args=[compute_id, data['name']])) + return HttpResponseRedirect(reverse('instances:instance', args=[compute_id, data['name']])) except libvirtError as lib_err: if data['hdd_size'] or len(volume_list) > 0: if is_disk_created: diff --git a/instances/views.py b/instances/views.py index f19db27..13d2804 100644 --- a/instances/views.py +++ b/instances/views.py @@ -34,7 +34,7 @@ def index(request): :param request: :return: """ - return HttpResponseRedirect(reverse('allinstances')) + return HttpResponseRedirect(reverse('instances:index')) def allinstances(request): @@ -421,7 +421,7 @@ def instance(request, compute_id, vname): msg = _("Destroy") addlogmsg(request.user.username, instance_name, msg) - return HttpResponseRedirect(reverse('allinstances')) + return HttpResponseRedirect(reverse('instances:index')) if 'rootpasswd' in request.POST: passwd = request.POST.get('passwd', '') @@ -862,7 +862,7 @@ def instance(request, compute_id, vname): new_compute = Compute.objects.get(id=compute_id) try: migrate_instance(new_compute, instance, live, unsafe, xml_del, offline) - return HttpResponseRedirect(reverse('instance', args=[new_compute.id, vname])) + return HttpResponseRedirect(reverse('instances:instance', args=[new_compute.id, vname])) except libvirtError as err: messages.error(request, err) addlogmsg(request.user.username, instance.name, err) @@ -1031,7 +1031,7 @@ def instance(request, compute_id, vname): new_compute = Compute.objects.order_by('?').first() migrate_instance(new_compute, new_instance, xml_del=True, offline=True) return HttpResponseRedirect( - reverse('instance', args=[new_instance.compute.id, new_instance.name])) + reverse('instances:instance', args=[new_instance.compute.id, new_instance.name])) if 'change_options' in request.POST and (request.user.is_superuser or request.user.is_staff or userinstance.is_change): instance.is_template = request.POST.get('is_template', False)