networks: Support virtual Ethernet (veth) devices

Closes #1767

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
[sunil: Add comment and a cosmetic change]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Veiko Aasa 2020-01-28 17:43:43 +02:00 committed by Sunil Mohan Adapa
parent 964051a849
commit 932d2e17f9
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -43,7 +43,7 @@ class ConnectionForm(forms.Form):
"""Base form to create/edit a connection."""
name = forms.CharField(label=_('Connection Name'))
interface = forms.ChoiceField(
label=_('Physical Interface'), choices=(),
label=_('Network Interface'), choices=(),
help_text=_('The network device that this connection should be bound '
'to.'))
zone = forms.ChoiceField(
@ -120,6 +120,10 @@ class ConnectionForm(forms.Form):
def _get_interface_choices(device_type):
"""Return a list of choices for a given device type."""
interfaces = network.get_interface_list(device_type)
# Support for virtual Ethernet devices used in containers
if device_type == nm.DeviceType.ETHERNET:
interfaces.update(network.get_interface_list(nm.DeviceType.VETH))
choices = [('', _('-- select --'))]
for interface, mac in interfaces.items():
display_string = '{interface} ({mac})'.format(