networks: Remove the IP address hack fully

This commit is contained in:
Sunil Mohan Adapa 2016-08-06 16:58:49 +05:30 committed by James Valleroy
parent 43e070972a
commit fee14b1764
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 9 additions and 24 deletions

View File

@ -142,19 +142,22 @@ def edit(request, uuid):
if settings_connection.get_connection_type() != 'pppoe':
settings_ipv4 = connection.get_setting_ip4_config()
form_data['ipv4_method'] = settings_ipv4.get_method()
address, netmask = network.get_first_ip_address_from_connection(
connection)
if settings_ipv4.get_num_addresses():
address = settings_ipv4.get_address(0)
form_data['ipv4_address'] = address.get_address()
prefix = address.get_prefix()
netmask = network.nm.utils_ip4_prefix_to_netmask(prefix)
form_data['ipv4_netmask'] = network.ipv4_int_to_string(netmask)
gateway = settings_ipv4.get_gateway()
dns = settings_ipv4.get_dns(0)
second_dns = settings_ipv4.get_dns(1)
if address:
form_data['ipv4_address'] = address
if netmask:
form_data['ipv4_netmask'] = netmask
if gateway:
form_data['ipv4_gateway'] = gateway
if dns:
form_data['ipv4_dns'] = dns
if second_dns:
form_data['ipv4_second_dns'] = second_dns

View File

@ -197,24 +197,6 @@ def _get_wifi_channel_from_frequency(frequency):
return str(frequency / 1000) + 'GHz'
def get_first_ip_address_from_connection(connection):
"""Return the first IP address of a connection setting.
XXX: Work around a bug in NetworkManager/Python GI. Remove after
the bug if fixed.
https://bugzilla.gnome.org/show_bug.cgi?id=756380.
"""
devicename=connection.get_interface_name()
ip="0.0.0.0"
device=nm.Client.new(None).get_device_by_iface(devicename)
ip4_config=device.get_ip4_config()
if ip4_config:
addresses=ip4_config.get_addresses()
if addresses:
ip_address=addresses.__getitem__(0).get_address()
netmask=addresses.__getitem__(0).get_prefix()
return ip_address,ipv4_int_to_string(netmask)
def get_connection_list():
"""Get a list of active and available connections."""
active_uuids = []