1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-25 15:45:23 +00:00

Merge pull request #327 from Real-Gecko/master

Fixed #326
This commit is contained in:
Anatoliy Guskov 2020-06-22 10:16:12 +03:00 committed by GitHub
commit 5a73f14889
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 18 deletions

View file

@ -15,6 +15,7 @@ from vrtManager import util
from logs.views import addlogmsg from logs.views import addlogmsg
from webvirtcloud.settings import QEMU_CONSOLE_LISTEN_ADDRESSES from webvirtcloud.settings import QEMU_CONSOLE_LISTEN_ADDRESSES
@superuser_only @superuser_only
def create_instance_select_type(request, compute_id): def create_instance_select_type(request, compute_id):
""" """
@ -54,7 +55,7 @@ def create_instance_select_type(request, compute_id):
else: else:
try: try:
conn._defineXML(xml) 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: except libvirtError as lib_err:
error_messages.append(lib_err) error_messages.append(lib_err)
@ -179,7 +180,8 @@ def create_instance(request, compute_id, arch, machine):
default_disk_format, default_disk_format,
meta_prealloc, meta_prealloc,
default_disk_owner_uid, default_disk_owner_uid,
default_disk_owner_gid) default_disk_owner_gid,
)
volume = dict() volume = dict()
volume['device'] = 'disk' volume['device'] = 'disk'
volume['path'] = path volume['path'] = path
@ -210,7 +212,8 @@ def create_instance(request, compute_id, arch, machine):
data['storage'], data['storage'],
meta_prealloc, meta_prealloc,
default_disk_owner_uid, default_disk_owner_uid,
default_disk_owner_gid) default_disk_owner_gid,
)
volume = dict() volume = dict()
volume['path'] = clone_path volume['path'] = clone_path
volume['type'] = conn.get_volume_type(clone_path) volume['type'] = conn.get_volume_type(clone_path)
@ -290,7 +293,7 @@ def create_instance(request, compute_id, arch, machine):
msg = _("Instance is created") msg = _("Instance is created")
messages.success(request, msg) messages.success(request, msg)
addlogmsg(request.user.username, create_instance.name, 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: except libvirtError as lib_err:
if data['hdd_size'] or len(volume_list) > 0: if data['hdd_size'] or len(volume_list) > 0:
if is_disk_created: if is_disk_created:

View file

@ -34,7 +34,7 @@ def index(request):
:param request: :param request:
:return: :return:
""" """
return HttpResponseRedirect(reverse('allinstances')) return HttpResponseRedirect(reverse('instances:index'))
def allinstances(request): def allinstances(request):
@ -421,7 +421,7 @@ def instance(request, compute_id, vname):
msg = _("Destroy") msg = _("Destroy")
addlogmsg(request.user.username, instance_name, msg) addlogmsg(request.user.username, instance_name, msg)
return HttpResponseRedirect(reverse('allinstances')) return HttpResponseRedirect(reverse('instances:index'))
if 'rootpasswd' in request.POST: if 'rootpasswd' in request.POST:
passwd = request.POST.get('passwd', '') passwd = request.POST.get('passwd', '')
@ -862,7 +862,7 @@ def instance(request, compute_id, vname):
new_compute = Compute.objects.get(id=compute_id) new_compute = Compute.objects.get(id=compute_id)
try: try:
migrate_instance(new_compute, instance, live, unsafe, xml_del, offline) 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: except libvirtError as err:
messages.error(request, err) messages.error(request, err)
addlogmsg(request.user.username, instance.name, 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() new_compute = Compute.objects.order_by('?').first()
migrate_instance(new_compute, new_instance, xml_del=True, offline=True) migrate_instance(new_compute, new_instance, xml_del=True, offline=True)
return HttpResponseRedirect( 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): 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) instance.is_template = request.POST.get('is_template', False)