networks: During activation raise device not found

When an interface assigned to a connection is not available in list of
devices, raise a proper error that device is not found.
This commit is contained in:
Sunil Mohan Adapa 2015-08-22 20:51:14 +05:30
parent e7214b7586
commit 2c23b0ecb4

View File

@ -327,16 +327,17 @@ def edit_wifi_connection(connection, name, interface, zone, ssid, mode,
def activate_connection(connection_uuid): def activate_connection(connection_uuid):
"""Find and activate a network connection.""" """Find and activate a network connection."""
# Find the connection
connection = get_connection(connection_uuid) connection = get_connection(connection_uuid)
interface = connection.get_interface_name() interface = connection.get_interface_name()
client = nm.Client.new(None) client = nm.Client.new(None)
for device in client.get_devices(): for device in client.get_devices():
if device.get_iface() == interface: if device.get_iface() == interface:
client.activate_connection_async(connection, client.activate_connection_async(
device, connection, device, '/', None, _callback, None)
'/', None, _callback, break
None) else:
raise DeviceNotFound(connection)
return connection return connection