mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 20:26:48 +00:00
fix(interfaces): an ethernet interface needs no bridge member, and unreadable host devices are reported
The form required a bridge member for an ethernet interface, which does not use one. When the host's network devices could not be read, the error was swallowed and every creation failed with "the device is not on this host"; the page now shows the real error and does not try.
This commit is contained in:
parent
9fdb039977
commit
55eb63a09f
3 changed files with 42 additions and 6 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import contextlib
|
||||
from django.contrib import messages
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from libvirt import libvirtError
|
||||
from computes.models import Compute
|
||||
from interfaces.forms import AddInterface
|
||||
|
|
@ -30,9 +30,12 @@ def interfaces(request, compute_id):
|
|||
)
|
||||
ifaces = conn.get_ifaces()
|
||||
|
||||
netdevs = []
|
||||
with contextlib.suppress(Exception):
|
||||
netdevs, netdev_error = [], None
|
||||
try:
|
||||
netdevs = conn.get_net_devices()
|
||||
except Exception as err:
|
||||
netdev_error = err
|
||||
messages.error(request, _("The network devices of this host could not be read: %(error)s") % {"error": err})
|
||||
|
||||
for iface in ifaces:
|
||||
interf = wvmInterface(
|
||||
|
|
@ -45,7 +48,8 @@ def interfaces(request, compute_id):
|
|||
ifaces_all.append(interf.get_details())
|
||||
|
||||
if request.method == "POST":
|
||||
if "create" in request.POST:
|
||||
# without the host's devices nothing can be checked, so nothing is created
|
||||
if "create" in request.POST and netdev_error is None:
|
||||
form = AddInterface(request.POST, netdevs=netdevs)
|
||||
if form.is_valid():
|
||||
data = form.cleaned_data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue