wi-fi network connection: Fixed error message when entering the form

- When selecting an existing WiFi on the "scan" page, the user will be redirected to the "WiFi add" form.
  This form did not contain a WiFi capable Interface as default selection, for this reason the user get a
  invalid form message when entering the form.
This commit is contained in:
Daniel Steglich 2015-09-21 21:47:25 +02:00 committed by Sunil Mohan Adapa
parent 3c47dfb6ef
commit 408aa8910a
2 changed files with 13 additions and 0 deletions

View File

@ -360,7 +360,9 @@ def add_wifi(request, ssid=None):
form_data = None
if ssid:
device = network.get_first_wifi_device()
form_data = {'name': ssid,
'interface': device,
'zone': 'external',
'ssid': ssid,
'mode': 'infrastructure',

View File

@ -76,6 +76,17 @@ def get_interface_list(device_type):
return interfaces
def get_first_wifi_device():
"""Get a list of network interface available on the system."""
interface = "empty"
for device in nm.Client.new(None).get_devices():
if device.get_device_type() == nm.DeviceType.WIFI:
interface = device.get_iface()
return interface
return interface
def get_ip_from_device(devicename):
"""
Get the first ip address from the network interface.