1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-10-31 19:44:16 +00:00

Global setting for NIC type

This commit is contained in:
MisterBlueBear 2023-11-01 18:08:38 -04:00
parent 2ff0abf8c5
commit 7e8c05fff9
4 changed files with 50 additions and 3 deletions

View file

@ -0,0 +1,18 @@
# Generated by Django 4.2.5 on 2023-10-30 17:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('appsettings', '0008_auto_20220905_1459'),
]
operations = [
migrations.AlterField(
model_name='appsettings',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
]

View file

@ -0,0 +1,28 @@
# Generated by Django 4.2.5 on 2023-10-30 17:05
from django.db import migrations
from django.utils.translation import gettext_lazy as _
def add_default_settings(apps, schema_editor):
setting = apps.get_model("appsettings", "AppSettings")
db_alias = schema_editor.connection.alias
setting.objects.using(db_alias).bulk_create([
setting(35, _("VM NIC Type"), "INSTANCE_NIC_DEFAULT_TYPE", "default", "default,e1000,e1000e,rt18139,virtio", _("Change instance default NIC type"))
])
def del_default_settings(apps, schema_editor):
setting = apps.get_model("appsettings", "AppSettings")
db_alias = schema_editor.connection.alias
setting.objects.using(db_alias).filter(key="INSTANCE_NIC_DEFAULT_TYPE").delete()
class Migration(migrations.Migration):
dependencies = [
('appsettings', '0009_alter_appsettings_id')
]
operations = [
migrations.RunPython(add_default_settings,del_default_settings)
]

View file

@ -200,7 +200,7 @@
<div class="col-sm-7"> <div class="col-sm-7">
<select class="form-select" name="net_model"> <select class="form-select" name="net_model">
{% for model in net_models_host %} {% for model in net_models_host %}
<option value="{{ model }}" {% if model == 'default' %} selected {% endif %}>{{ model }}</option> <option value="{{ model }}" {% if model == default_nic_type %} selected {% endif %}>{{ model }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@ -476,7 +476,7 @@
<div class="col-sm-7"> <div class="col-sm-7">
<select class="form-select" name="net_model"> <select class="form-select" name="net_model">
{% for model in net_models_host %} {% for model in net_models_host %}
<option value="{{ model }}" {% if model == 'default' %} selected {% endif %}>{{ model }}</option> <option value="{{ model }}" {% if model == default_nic_type %} selected {% endif %}>{{ model }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@ -728,7 +728,7 @@
<div class="col-sm-7"> <div class="col-sm-7">
<select class="form-select" name="net_model"> <select class="form-select" name="net_model">
{% for model in net_models_host %} {% for model in net_models_host %}
<option value="{{ model }}" {% if model == 'default' %} selected {% endif %}>{{ model }}</option> <option value="{{ model }}" {% if model == default_nic_type %} selected {% endif %}>{{ model }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>

View file

@ -1692,6 +1692,7 @@ def create_instance(request, compute_id, arch, machine):
networks = sorted(conn.get_networks()) networks = sorted(conn.get_networks())
nwfilters = conn.get_nwfilters() nwfilters = conn.get_nwfilters()
net_models_host = conn.get_network_models() net_models_host = conn.get_network_models()
default_nic_type = app_settings.INSTANCE_NIC_DEFAULT_TYPE
storages = sorted(conn.get_storages(only_actives=True)) storages = sorted(conn.get_storages(only_actives=True))
default_graphics = app_settings.QEMU_CONSOLE_DEFAULT_TYPE default_graphics = app_settings.QEMU_CONSOLE_DEFAULT_TYPE
default_cdrom = app_settings.INSTANCE_CDROM_ADD default_cdrom = app_settings.INSTANCE_CDROM_ADD