mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
network: Minor refactoring, new is_primary() function
Signed-off-by: Fioddor Superconcentrado <fioddor@gmail.com> [sunil: Made the method private to reduce the exposed API of the module] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
7ee2b385c9
commit
6cc13bea65
@ -89,6 +89,12 @@ def get_interface_list(device_type):
|
||||
return interfaces
|
||||
|
||||
|
||||
def _is_primary(connection):
|
||||
"""Return whether a connection is primary connection."""
|
||||
primary = get_nm_client().get_primary_connection()
|
||||
return (primary and primary.get_uuid() == connection.get_uuid())
|
||||
|
||||
|
||||
def get_status_from_connection(connection):
|
||||
"""Return the current status of a connection."""
|
||||
status = collections.defaultdict(dict)
|
||||
@ -98,6 +104,7 @@ def get_status_from_connection(connection):
|
||||
status['type'] = connection.get_connection_type()
|
||||
status['zone'] = connection.get_setting_connection().get_zone()
|
||||
status['interface_name'] = connection.get_interface_name()
|
||||
status['primary'] = _is_primary(connection)
|
||||
|
||||
status['ipv4']['method'] = connection.get_setting_ip4_config().get_method()
|
||||
status['ipv6']['method'] = connection.get_setting_ip6_config().get_method()
|
||||
@ -106,11 +113,6 @@ def get_status_from_connection(connection):
|
||||
setting_wireless = connection.get_setting_wireless()
|
||||
status['wireless']['ssid'] = setting_wireless.get_ssid().get_data()
|
||||
|
||||
primary_connection = get_nm_client().get_primary_connection()
|
||||
status['primary'] = (
|
||||
primary_connection
|
||||
and primary_connection.get_uuid() == connection.get_uuid())
|
||||
|
||||
return status
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user