mirror of
https://github.com/retspen/webvirtcloud
synced 2024-10-31 19:44:16 +00:00
network interface model selection added for new instance and new interface
This commit is contained in:
parent
b47ec2e8f9
commit
7d1cfb69b0
6 changed files with 50 additions and 6 deletions
|
@ -252,6 +252,7 @@ class CreateInstance(models.Model):
|
||||||
error_messages={"required": _("No Network pool has been choosen")},
|
error_messages={"required": _("No Network pool has been choosen")},
|
||||||
)
|
)
|
||||||
nwfilter = models.CharField(max_length=256, blank=True)
|
nwfilter = models.CharField(max_length=256, blank=True)
|
||||||
|
net_model = models.CharField(max_length=256, blank=True)
|
||||||
storage = models.CharField(max_length=256, blank=True)
|
storage = models.CharField(max_length=256, blank=True)
|
||||||
template = models.CharField(max_length=256, blank=True)
|
template = models.CharField(max_length=256, blank=True)
|
||||||
images = models.CharField(max_length=256, blank=True)
|
images = models.CharField(max_length=256, blank=True)
|
||||||
|
|
|
@ -45,6 +45,16 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-sm-4 col-form-label">{% trans "Model" %} </label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<select class="form-select" name="add-net-model">
|
||||||
|
{% for model in net_models_host %}
|
||||||
|
<option value="{{ model }}" {% if model == 'default' %} selected {% endif %}>{{ model }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Close" %}</button>
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Close" %}</button>
|
||||||
|
|
|
@ -168,6 +168,16 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-sm-4 col-form-label">{% trans "Model" %} </label>
|
||||||
|
<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>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col-sm-4 col-form-label">{% trans "Advanced" %}</label>
|
<label class="col-sm-4 col-form-label">{% trans "Advanced" %}</label>
|
||||||
|
@ -422,7 +432,16 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<input id="mac" type="hidden" name="mac" value=""/>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-sm-3 col-form-label">{% trans "Model" %} </label>
|
||||||
|
<div class="col-sm-7 my-1">
|
||||||
|
<select class="form-select" name="net_model">
|
||||||
|
{% for model in net_models_host %}
|
||||||
|
<option value="{{ model }}" {% if model == 'default' %} selected {% endif %}>{{ model }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col-sm-3 col-form-label">{% trans "Advanced" %}</label>
|
<label class="col-sm-3 col-form-label">{% trans "Advanced" %}</label>
|
||||||
|
@ -666,6 +685,16 @@
|
||||||
<input type="text" class="form-control" name="mac" maxlength="17" value="{{ mac_auto }}" required pattern="[a-zA-Z0-9:]+">
|
<input type="text" class="form-control" name="mac" maxlength="17" value="{{ mac_auto }}" required pattern="[a-zA-Z0-9:]+">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-sm-3 col-form-label">{% trans "Model" %} </label>
|
||||||
|
<div class="col-sm-7 my-1">
|
||||||
|
<select class="form-select" name="net_model">
|
||||||
|
{% for model in net_models_host %}
|
||||||
|
<option value="{{ model }}" {% if model == 'default' %} selected {% endif %}>{{ model }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col-sm-3 col-form-label">{% trans "Advanced" %}</label>
|
<label class="col-sm-3 col-form-label">{% trans "Advanced" %}</label>
|
||||||
<div class="d-grid col-sm-7">
|
<div class="d-grid col-sm-7">
|
||||||
|
@ -865,7 +894,7 @@
|
||||||
'{% endfor %}' +
|
'{% endfor %}' +
|
||||||
'</select>' +
|
'</select>' +
|
||||||
' -> ' + value + ' ' +
|
' -> ' + value + ' ' +
|
||||||
'<a class="btn-link float-end" onclick="javascript:$(\'#image-control\').multiselect(\'deselect\', \'' + value + '\', true)">{% bs_icon 'trash'%} </a></li>';
|
'<a class="btn-link float-end" onclick="javascript:$(\'#image-control\').multiselect(\'deselect\', \'' + value + '\', true)"> X </a></li>';
|
||||||
selected_list_html += li;
|
selected_list_html += li;
|
||||||
counter++;
|
counter++;
|
||||||
});
|
});
|
||||||
|
@ -899,7 +928,7 @@
|
||||||
let li = '<li><input type="text" class="input-xs" name="mac'+ net_counter +'" maxlength="17" required pattern="[a-zA-Z0-9:]+" onchange="populate_mac(' + net_counter +')">' +
|
let li = '<li><input type="text" class="input-xs" name="mac'+ net_counter +'" maxlength="17" required pattern="[a-zA-Z0-9:]+" onchange="populate_mac(' + net_counter +')">' +
|
||||||
' eth' + net_counter +
|
' eth' + net_counter +
|
||||||
' -> ' + value + ' ' +
|
' -> ' + value + ' ' +
|
||||||
'<a class="btn-link float-end" onclick="$(\'#network-control\').multiselect(\'deselect\', \'' + value + '\', true)">{% bs_icon 'trash'%} </a></li>';
|
'<a class="btn-link float-end" onclick="$(\'#network-control\').multiselect(\'deselect\', \'' + value + '\', true)"> X </a></li>';
|
||||||
random_mac(net_counter);
|
random_mac(net_counter);
|
||||||
selected_list_html += li;
|
selected_list_html += li;
|
||||||
net_counter++;
|
net_counter++;
|
||||||
|
|
|
@ -1253,6 +1253,7 @@ def add_network(request, pk):
|
||||||
mac = request.POST.get("add-net-mac")
|
mac = request.POST.get("add-net-mac")
|
||||||
nwfilter = request.POST.get("add-net-nwfilter")
|
nwfilter = request.POST.get("add-net-nwfilter")
|
||||||
(source, source_type) = utils.get_network_tuple(request.POST.get("add-net-network"))
|
(source, source_type) = utils.get_network_tuple(request.POST.get("add-net-network"))
|
||||||
|
model = request.POST.get("add-net-model")
|
||||||
|
|
||||||
if source_type == "iface":
|
if source_type == "iface":
|
||||||
iface = wvmInterface(
|
iface = wvmInterface(
|
||||||
|
@ -1264,7 +1265,7 @@ def add_network(request, pk):
|
||||||
)
|
)
|
||||||
source_type = iface.get_type()
|
source_type = iface.get_type()
|
||||||
|
|
||||||
instance.proxy.add_network(mac, source, source_type, nwfilter=nwfilter)
|
instance.proxy.add_network(mac, source, source_type, model=model, nwfilter=nwfilter)
|
||||||
msg = _("Add network: %(mac)s") % {"mac": mac}
|
msg = _("Add network: %(mac)s") % {"mac": mac}
|
||||||
addlogmsg(request.user.username, instance.compute.name, instance.name, msg)
|
addlogmsg(request.user.username, instance.compute.name, instance.name, msg)
|
||||||
return redirect(request.META.get("HTTP_REFERER") + "#network")
|
return redirect(request.META.get("HTTP_REFERER") + "#network")
|
||||||
|
@ -1690,6 +1691,7 @@ def create_instance(request, compute_id, arch, machine):
|
||||||
default_bus = app_settings.INSTANCE_VOLUME_DEFAULT_BUS
|
default_bus = app_settings.INSTANCE_VOLUME_DEFAULT_BUS
|
||||||
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()
|
||||||
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
|
||||||
|
@ -1866,6 +1868,7 @@ def create_instance(request, compute_id, arch, machine):
|
||||||
virtio=data["virtio"],
|
virtio=data["virtio"],
|
||||||
listener_addr=data["listener_addr"],
|
listener_addr=data["listener_addr"],
|
||||||
nwfilter=data["nwfilter"],
|
nwfilter=data["nwfilter"],
|
||||||
|
net_model=data["net_model"],
|
||||||
graphics=data["graphics"],
|
graphics=data["graphics"],
|
||||||
video=data["video"],
|
video=data["video"],
|
||||||
console_pass=data["console_pass"],
|
console_pass=data["console_pass"],
|
||||||
|
|
|
@ -757,7 +757,7 @@ class wvmConnect(object):
|
||||||
"""
|
"""
|
||||||
:return: network card models
|
:return: network card models
|
||||||
"""
|
"""
|
||||||
return ["default", "e1000", "virtio"]
|
return ["default", "e1000", "e1000e","rt18139", "virtio"]
|
||||||
|
|
||||||
def get_image_formats(self):
|
def get_image_formats(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -161,6 +161,7 @@ class wvmCreate(wvmConnect):
|
||||||
graphics,
|
graphics,
|
||||||
virtio,
|
virtio,
|
||||||
listener_addr,
|
listener_addr,
|
||||||
|
net_model="virtio",
|
||||||
video="vga",
|
video="vga",
|
||||||
console_pass="random",
|
console_pass="random",
|
||||||
mac=None,
|
mac=None,
|
||||||
|
@ -316,7 +317,7 @@ class wvmCreate(wvmConnect):
|
||||||
if nwfilter:
|
if nwfilter:
|
||||||
xml += f"""<filterref filter='{nwfilter}'/>"""
|
xml += f"""<filterref filter='{nwfilter}'/>"""
|
||||||
if virtio:
|
if virtio:
|
||||||
xml += """<model type='virtio'/>"""
|
xml += f"""<model type='{net_model}'/>"""
|
||||||
xml += """</interface>"""
|
xml += """</interface>"""
|
||||||
|
|
||||||
if console_pass == "random":
|
if console_pass == "random":
|
||||||
|
|
Loading…
Reference in a new issue