mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 23:25:24 +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")},
|
||||
)
|
||||
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)
|
||||
template = models.CharField(max_length=256, blank=True)
|
||||
images = models.CharField(max_length=256, blank=True)
|
||||
|
|
|
@ -45,6 +45,16 @@
|
|||
</select>
|
||||
</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 class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Close" %}</button>
|
||||
|
|
|
@ -168,6 +168,16 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</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 class="row">
|
||||
<label class="col-sm-4 col-form-label">{% trans "Advanced" %}</label>
|
||||
|
@ -422,7 +432,16 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</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 class="row">
|
||||
<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:]+">
|
||||
</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">
|
||||
<label class="col-sm-3 col-form-label">{% trans "Advanced" %}</label>
|
||||
<div class="d-grid col-sm-7">
|
||||
|
@ -865,7 +894,7 @@
|
|||
'{% endfor %}' +
|
||||
'</select>' +
|
||||
' -> ' + 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;
|
||||
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 +')">' +
|
||||
' eth' + net_counter +
|
||||
' -> ' + 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);
|
||||
selected_list_html += li;
|
||||
net_counter++;
|
||||
|
|
|
@ -1253,6 +1253,7 @@ def add_network(request, pk):
|
|||
mac = request.POST.get("add-net-mac")
|
||||
nwfilter = request.POST.get("add-net-nwfilter")
|
||||
(source, source_type) = utils.get_network_tuple(request.POST.get("add-net-network"))
|
||||
model = request.POST.get("add-net-model")
|
||||
|
||||
if source_type == "iface":
|
||||
iface = wvmInterface(
|
||||
|
@ -1264,7 +1265,7 @@ def add_network(request, pk):
|
|||
)
|
||||
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}
|
||||
addlogmsg(request.user.username, instance.compute.name, instance.name, msg)
|
||||
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
|
||||
networks = sorted(conn.get_networks())
|
||||
nwfilters = conn.get_nwfilters()
|
||||
net_models_host = conn.get_network_models()
|
||||
storages = sorted(conn.get_storages(only_actives=True))
|
||||
default_graphics = app_settings.QEMU_CONSOLE_DEFAULT_TYPE
|
||||
default_cdrom = app_settings.INSTANCE_CDROM_ADD
|
||||
|
@ -1866,6 +1868,7 @@ def create_instance(request, compute_id, arch, machine):
|
|||
virtio=data["virtio"],
|
||||
listener_addr=data["listener_addr"],
|
||||
nwfilter=data["nwfilter"],
|
||||
net_model=data["net_model"],
|
||||
graphics=data["graphics"],
|
||||
video=data["video"],
|
||||
console_pass=data["console_pass"],
|
||||
|
|
|
@ -757,7 +757,7 @@ class wvmConnect(object):
|
|||
"""
|
||||
:return: network card models
|
||||
"""
|
||||
return ["default", "e1000", "virtio"]
|
||||
return ["default", "e1000", "e1000e","rt18139", "virtio"]
|
||||
|
||||
def get_image_formats(self):
|
||||
"""
|
||||
|
|
|
@ -161,6 +161,7 @@ class wvmCreate(wvmConnect):
|
|||
graphics,
|
||||
virtio,
|
||||
listener_addr,
|
||||
net_model="virtio",
|
||||
video="vga",
|
||||
console_pass="random",
|
||||
mac=None,
|
||||
|
@ -316,7 +317,7 @@ class wvmCreate(wvmConnect):
|
|||
if nwfilter:
|
||||
xml += f"""<filterref filter='{nwfilter}'/>"""
|
||||
if virtio:
|
||||
xml += """<model type='virtio'/>"""
|
||||
xml += f"""<model type='{net_model}'/>"""
|
||||
xml += """</interface>"""
|
||||
|
||||
if console_pass == "random":
|
||||
|
|
Loading…
Reference in a new issue