mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 15:15:22 +00:00
Merge pull request #620 from MisterBlueBear/global_setting_nic_type
Global setting for NIC type
This commit is contained in:
commit
6c0cc3c274
4 changed files with 50 additions and 3 deletions
18
appsettings/migrations/0009_alter_appsettings_id.py
Normal file
18
appsettings/migrations/0009_alter_appsettings_id.py
Normal 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'),
|
||||
),
|
||||
]
|
28
appsettings/migrations/0010_auto_20231030_1305.py
Normal file
28
appsettings/migrations/0010_auto_20231030_1305.py
Normal 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)
|
||||
]
|
|
@ -200,7 +200,7 @@
|
|||
<div class="col-sm-7">
|
||||
<select class="form-select" name="net_model">
|
||||
{% 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 %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -476,7 +476,7 @@
|
|||
<div class="col-sm-7">
|
||||
<select class="form-select" name="net_model">
|
||||
{% 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 %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -728,7 +728,7 @@
|
|||
<div class="col-sm-7">
|
||||
<select class="form-select" name="net_model">
|
||||
{% 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 %}
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
@ -1692,6 +1692,7 @@ def create_instance(request, compute_id, arch, machine):
|
|||
networks = sorted(conn.get_networks())
|
||||
nwfilters = conn.get_nwfilters()
|
||||
net_models_host = conn.get_network_models()
|
||||
default_nic_type = app_settings.INSTANCE_NIC_DEFAULT_TYPE
|
||||
storages = sorted(conn.get_storages(only_actives=True))
|
||||
default_graphics = app_settings.QEMU_CONSOLE_DEFAULT_TYPE
|
||||
default_cdrom = app_settings.INSTANCE_CDROM_ADD
|
||||
|
|
Loading…
Reference in a new issue