Commit 18ee7dad authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Rafael Monnerat

format: Support environments with netmask with /

On some systems netmask can already contain /<bits>, so just use the
nu.me.ri.cal value.

/reviewed-on !106
parent 680edc78
......@@ -1212,6 +1212,11 @@ class Interface(object):
raise AddressGenerationError(addr)
netmask = ipv6FromBin('1'*128) # the netmask of the tap itself is always 128 bits
if '/' in netmask:
_addr_netmask, _ = netmask.split('/')
else:
_addr_netmask = netmask
while try_num > 0:
if tap:
addr = ipv6FromBin(prefix
......@@ -1221,11 +1226,11 @@ class Interface(object):
addr = ':'.join(address_dict['addr'].split(':')[:-1] + ['%x' % (
random.randint(1, 65000), )])
socket.inet_pton(socket.AF_INET6, addr)
if (dict(addr=addr, netmask=netmask) not in
if (dict(addr=addr, netmask=_addr_netmask) not in
self.getGlobalScopeAddressList(tap=tap)):
# Checking the validity of the IPv6 address
if self._addSystemAddress(addr, netmask, tap=tap):
return dict(addr=addr, netmask=netmask)
if self._addSystemAddress(addr, _addr_netmask, tap=tap):
return dict(addr=addr, netmask=_addr_netmask)
try_num -= 1
raise AddressGenerationError(addr)
......
......@@ -471,11 +471,11 @@ class TestComputer(SlapformatMixin):
INTERFACE_DICT['myinterface'] = {
socket.AF_INET: [{'addr': '192.168.242.77', 'broadcast': '127.0.0.1',
'netmask': '255.255.255.0'}],
socket.AF_INET6: [{'addr': '2a01:e35:2e27::e59c', 'netmask': 'ffff:ffff:ffff:ffff::'}]
socket.AF_INET6: [{'addr': '2a01:e35:2e27::e59c', 'netmask': 'ffff:ffff:ffff:ffff::/64'}]
}
INTERFACE_DICT['tap'] = {
socket.AF_INET6: [{'addr': '2a01:e35:2e27::e59c', 'netmask': 'ffff:ffff:ffff:ffff::'}]
socket.AF_INET6: [{'addr': '2a01:e35:2e27::e59c', 'netmask': 'ffff:ffff:ffff:ffff::/64'}]
}
computer.format(alter_user=False)
......@@ -524,7 +524,7 @@ class TestComputer(SlapformatMixin):
INTERFACE_DICT['iface'] = {
socket.AF_INET: [{'addr': '192.168.242.77', 'broadcast': '127.0.0.1',
'netmask': '255.255.255.0'}],
socket.AF_INET6: [{'addr': '2a01:e35:2e27:3456:1357::e59c', 'netmask': 'ffff:ffff:ffff:ffff:ffff::'}]
socket.AF_INET6: [{'addr': '2a01:e35:2e27:3456:1357::e59c', 'netmask': 'ffff:ffff:ffff:ffff:ffff::/48'}]
}
INTERFACE_DICT['eth1'] = {
socket.AF_INET: [{'addr': '10.8.0.1', 'broadcast': '10.8.0.254',
......@@ -532,7 +532,7 @@ class TestComputer(SlapformatMixin):
}
INTERFACE_DICT['tap'] = {
socket.AF_INET6: [{'addr': '2a01:e35:2e27:3456:1357:7890:ffff:ffff', 'netmask': 'ffff:ffff:ffff:ffff:ffff:ffff:ffff'}]
socket.AF_INET6: [{'addr': '2a01:e35:2e27:3456:1357:7890:ffff:ffff', 'netmask': 'ffff:ffff:ffff:ffff:ffff:ffff:ffff/16'}]
}
computer.format(alter_user=False)
......@@ -623,7 +623,7 @@ class TestComputer(SlapformatMixin):
INTERFACE_DICT['myinterface'] = {
socket.AF_INET: [{'addr': '192.168.242.77', 'broadcast': '127.0.0.1',
'netmask': '255.255.255.0'}],
socket.AF_INET6: [{'addr': '2a01:e35:2e27::e59c', 'netmask': 'ffff:ffff:ffff:ffff::'}]
socket.AF_INET6: [{'addr': '2a01:e35:2e27::e59c', 'netmask': 'ffff:ffff:ffff:ffff::/64'}]
}
computer.format(alter_network=False, alter_user=False)
......@@ -663,7 +663,7 @@ class TestComputer(SlapformatMixin):
INTERFACE_DICT['myinterface'] = {
socket.AF_INET: [{'addr': '192.168.242.77', 'broadcast': '127.0.0.1',
'netmask': '255.255.255.0'}],
socket.AF_INET6: [{'addr': '2a01:e35:2e27::e59c', 'netmask': 'ffff:ffff:ffff:ffff::'}]
socket.AF_INET6: [{'addr': '2a01:e35:2e27::e59c', 'netmask': 'ffff:ffff:ffff:ffff::/64'}]
}
computer.format(use_unique_local_address_block=True, alter_user=False, create_tap=False)
......@@ -725,7 +725,7 @@ class TestComputerWithCPUSet(SlapformatMixin):
socket.AF_INET: [
{'addr': '127.0.0.1', 'broadcast': '127.0.255.255', 'netmask': '255.255.0.0'}],
socket.AF_INET6: [
{'addr': '2a01:e35:2e27::e59c', 'netmask': 'ffff:ffff:ffff:ffff::'}]
{'addr': '2a01:e35:2e27::e59c', 'netmask': 'ffff:ffff:ffff:ffff::/64'}]
}
from slapos.manager.cpuset import Manager
......
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