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,7 +1178,16 @@ class Interface(object):
address_dict = interface_addr_list[0]
if addr is not None:
dict_addr_netmask = dict(addr=addr, netmask=netmask)
# support netifaces which returns netmask and netmask/len
# will result with updating the computer XML netmask only
# to follow the change of netmask representation in netifaces
if '/' in 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
......
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