mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
Python3 & Django 2.2 Migration - Fix & Updates
This commit is contained in:
parent
fc8612c604
commit
4d40de1b55
98 changed files with 1525 additions and 6658 deletions
|
|
@ -62,4 +62,3 @@ class NewVMForm(forms.Form):
|
|||
elif len(name) > 64:
|
||||
raise forms.ValidationError(_('The name of the virtual machine must not exceed 20 characters'))
|
||||
return name
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
# Generated by Django 2.2.10 on 2020-01-28 07:01
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
|
|
@ -13,14 +14,11 @@ class Migration(migrations.Migration):
|
|||
migrations.CreateModel(
|
||||
name='Flavor',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('label', models.CharField(max_length=12)),
|
||||
('memory', models.IntegerField()),
|
||||
('vcpu', models.IntegerField()),
|
||||
('disk', models.IntegerField()),
|
||||
],
|
||||
options={
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
# Generated by Django 2.2.10 on 2020-01-28 07:01
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
|
@ -28,4 +27,4 @@ class Migration(migrations.Migration):
|
|||
|
||||
operations = [
|
||||
migrations.RunPython(add_favors),
|
||||
]
|
||||
]
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
from django.db import models
|
||||
from django.db.models import Model, CharField, IntegerField
|
||||
|
||||
|
||||
class Flavor(models.Model):
|
||||
label = models.CharField(max_length=12)
|
||||
memory = models.IntegerField()
|
||||
vcpu = models.IntegerField()
|
||||
disk = models.IntegerField()
|
||||
class Flavor(Model):
|
||||
label = CharField(max_length=12)
|
||||
memory = IntegerField()
|
||||
vcpu = IntegerField()
|
||||
disk = IntegerField()
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@
|
|||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="clearfix"/>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@
|
|||
<div class="col-sm-6">
|
||||
<select class="form-control" id="select_firmware" name="firmware">
|
||||
{% for frm in firmwares %}
|
||||
<option value="{{ frm }}" {% if frm == default_firmware %}selected{% endif %}>{{ frm }}</option>
|
||||
<option value="{{ frm }}" {% if frm in default_firmware %}selected{% endif %}>{{ frm }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
|
@ -792,7 +792,7 @@
|
|||
$.each(input_value.split(','), function (index, value) {
|
||||
let li = '<li>eth' + counter +
|
||||
' -> ' + value + ' ' +
|
||||
'<a class="btn-link pull-right" onclick="javascript:$(\'#network-control\').multiselect(\'deselect\', \'' + value + '\', true)"><i class="fa fa-remove"></i></a></a></li>';
|
||||
'<a class="btn-link pull-right" onclick="$(\'#network-control\').multiselect(\'deselect\', \'' + value + '\', true)"><i class="fa fa-remove"></i></a></a></li>';
|
||||
selected_list_html += li;
|
||||
counter++;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,9 +19,13 @@ from webvirtcloud.settings import QEMU_CONSOLE_DEFAULT_TYPE
|
|||
from webvirtcloud.settings import INSTANCE_VOLUME_DEFAULT_IO
|
||||
from webvirtcloud.settings import INSTANCE_VOLUME_DEFAULT_DETECT_ZEROES
|
||||
from webvirtcloud.settings import INSTANCE_VOLUME_DEFAULT_DISCARD
|
||||
from webvirtcloud.settings import INSTANCE_ARCH_DEFAULT_TYPE
|
||||
from webvirtcloud.settings import INSTANCE_FIRMWARE_DEFAULT_TYPE
|
||||
|
||||
from django.contrib import messages
|
||||
from logs.views import addlogmsg
|
||||
|
||||
|
||||
@login_required
|
||||
def create_instance_select_type(request, compute_id):
|
||||
|
||||
|
|
@ -45,8 +49,9 @@ def create_instance_select_type(request, compute_id):
|
|||
all_hypervisors = conn.get_hypervisors_machines()
|
||||
# Supported hypervisors by webvirtcloud: i686, x86_64(for now)
|
||||
supported_arch = ["x86_64", "i686", "aarch64", "armv7l", "ppc64", "ppc64le", "s390x"]
|
||||
hypervisors = [hpv for hpv in all_hypervisors.keys() if hpv in supported_arch ]
|
||||
hypervisors = [hpv for hpv in all_hypervisors.keys() if hpv in supported_arch]
|
||||
default_machine = INSTANCE_MACHINE_DEFAULT_TYPE
|
||||
default_arch = INSTANCE_ARCH_DEFAULT_TYPE
|
||||
|
||||
if request.method == 'POST':
|
||||
if 'create_xml' in request.POST:
|
||||
|
|
@ -63,18 +68,21 @@ def create_instance_select_type(request, compute_id):
|
|||
conn._defineXML(xml)
|
||||
return HttpResponseRedirect(reverse('instance', args=[compute_id, name]))
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err.message)
|
||||
error_messages.append(lib_err)
|
||||
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err)
|
||||
|
||||
return render(request, 'create_instance_w1.html', locals())
|
||||
|
||||
|
||||
@login_required
|
||||
def create_instance(request, compute_id, arch, machine):
|
||||
"""
|
||||
:param request:
|
||||
:param compute_id:
|
||||
:param arch:
|
||||
:param machine:
|
||||
:return:
|
||||
"""
|
||||
if not request.user.is_superuser:
|
||||
|
|
@ -96,6 +104,7 @@ def create_instance(request, compute_id, arch, machine):
|
|||
compute.password,
|
||||
compute.type)
|
||||
|
||||
default_firmware = INSTANCE_FIRMWARE_DEFAULT_TYPE
|
||||
default_cpu_mode = INSTANCE_CPU_DEFAULT_MODE
|
||||
instances = conn.get_instances()
|
||||
videos = conn.get_video_models(arch, machine)
|
||||
|
|
@ -189,7 +198,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.message)
|
||||
error_messages.append(lib_err)
|
||||
elif data['template']:
|
||||
templ_path = conn.get_volume_path(data['template'])
|
||||
dest_vol = conn.get_volume_path(data["name"] + ".img", data['storage'])
|
||||
|
|
@ -221,7 +230,7 @@ def create_instance(request, compute_id, arch, machine):
|
|||
volume['bus'] = request.POST.get('bus' + str(idx), '')
|
||||
volume_list.append(volume)
|
||||
except libvirtError as lib_err:
|
||||
error_messages.append(lib_err.message)
|
||||
error_messages.append(lib_err)
|
||||
if data['cache_mode'] not in conn.get_cache_modes():
|
||||
error_msg = _("Invalid cache mode")
|
||||
error_messages.append(error_msg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue