Commit affe90a0 authored by Łukasz Nowak's avatar Łukasz Nowak

format: Stabilise partition addresses

Depending on the netifaces version the netmask can come with or without
lenght prefix, so support both cases and consider netmask with prefix
as equal to without prefix.

The only result will be update of the netmask in the computer XML file.
parent d3c516ed
...@@ -1178,11 +1178,20 @@ class Interface(object): ...@@ -1178,11 +1178,20 @@ class Interface(object):
address_dict = interface_addr_list[0] address_dict = interface_addr_list[0]
if addr is not None: if addr is not None:
dict_addr_netmask = dict(addr=addr, netmask=netmask) # support netifaces which returns netmask and netmask/len
if dict_addr_netmask in interface_addr_list or \ # will result with updating the computer XML netmask only
(tap and dict_addr_netmask in self.getGlobalScopeAddressList(tap=tap)): # to follow the change of netmask representation in netifaces
# confirmed to be configured if '/' in netmask:
return dict_addr_netmask dict_addr_netmask_with_len = dict(addr=addr, netmask=netmask)
dict_addr_netmask_without_len = dict(addr=addr, netmask=netmask.split('/')[0])
else:
dict_addr_netmask_without_len = dict(addr=addr, netmask=netmask)
dict_addr_netmask_with_len = dict(addr=addr, netmask='%s/%s' % (netmask, lenNetmaskIpv6(netmask)))
for dict_addr_netmask in [dict_addr_netmask_with_len, dict_addr_netmask_without_len]:
if dict_addr_netmask in interface_addr_list or \
(tap and dict_addr_netmask in self.getGlobalScopeAddressList(tap=tap)):
# confirmed to be configured
return dict_addr_netmask
if netmask == address_dict['netmask'] or \ if netmask == address_dict['netmask'] or \
(tap and lenNetmaskIpv6(netmask) == 128): (tap and lenNetmaskIpv6(netmask) == 128):
# same netmask, so there is a chance to add good one # same netmask, so there is a chance to add good one
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment