Commit 37cf9b3f authored by Thomas Gambier's avatar Thomas Gambier Committed by Thomas Gambier

format: remove option use_unique_local_address

The option use_unique_local_address was added in
de11308a but was already broken because
2 different names were used for the option:
 * use_unique_local_address_block
 * use_unique_local_address

There was a tentative fix in c09214cb
but the option name in slapos.cfg.example was never fixed.
parent acfb7b53
Changes
=======
1.7.4 (unreleased)
------------------
* format: remove use_unique_local_address_block option as it was never really used. User can add a local IPv6 range on the interface before running "slapos node format".
1.7.3 (2022-02-17)
------------------
* runpromises: support software releases older than slapos 1.0.118
......
......@@ -32,8 +32,6 @@ tap_ipv6 = true
# You can choose any other local network which does not conflict with your
# current machine configuration
ipv4_local_network = 10.0.0.0/16
# Change to true if you want slapos to use local-only IPv6
use_unique_local_address = False
# to enable, change to [firewall]
[disabled-firewall]
......
......@@ -140,8 +140,7 @@ def _generateSlaposNodeConfigurationFile(slapos_node_config_path, args):
('instance_root', args.slapos_instance_root),
('software_root', args.slapos_software_root),
('computer_xml', '%s/slapos.xml' % slapos_home),
('log_file', '%s/log/slapos-node-format.log' % slapos_home),
('use_unique_local_address_block', 'false')
('log_file', '%s/log/slapos-node-format.log' % slapos_home)
]
slapos_node_configuration_content = _replaceParameterValue(
......
......@@ -506,15 +506,6 @@ class Computer(object):
except ValueError:
pass
def _addUniqueLocalAddressIpv6(self, interface_name):
"""
Create a unique local address in the interface interface_name, so that
slapformat can build upon this.
See https://en.wikipedia.org/wiki/Unique_local_address.
"""
command = 'ip address add dev %s fd00::1/64' % interface_name
callAndRead(command.split())
@property
def software_gid(self):
"""Return GID for self.software_user.
......@@ -523,7 +514,7 @@ class Computer(object):
effectively create the user and group."""
return pwd.getpwnam(self.software_user)[3]
def format(self, alter_user=True, alter_network=True, create_tap=True, use_unique_local_address_block=False):
def format(self, alter_user=True, alter_network=True, create_tap=True):
"""
Setup underlaying OS so it reflects this instance (``self``).
......@@ -569,9 +560,6 @@ class Computer(object):
if self.address is not None:
self.interface.addIPv6Address(self.address, self.netmask)
if use_unique_local_address_block:
self._addUniqueLocalAddressIpv6(self.ipv6_interface or self.interface.name)
if create_tap:
if self.tap_gateway_interface:
gateway_addr_dict = getIfaceAddressIPv4(self.tap_gateway_interface)
......@@ -1409,8 +1397,7 @@ def do_format(conf):
computer.format(alter_user=conf.alter_user,
alter_network=conf.alter_network,
create_tap=conf.create_tap,
use_unique_local_address_block=conf.use_unique_local_address_block)
create_tap=conf.create_tap)
if getattr(conf, 'certificate_repository_path', None):
mkdir_p(conf.certificate_repository_path, mode=0o700)
......@@ -1442,7 +1429,6 @@ class FormatConfig(object):
tap_ipv6 = True
tap_gateway_interface = ''
ipv4_local_network = None
use_unique_local_address_block = False
# User options
alter_user = 'True' # modifiable by cmdline
......@@ -1501,7 +1487,7 @@ class FormatConfig(object):
raise UsageError(message)
# Convert strings to booleans
for option in ['alter_network', 'alter_user', 'create_tap', 'create_tun', 'use_unique_local_address_block', 'tap_ipv6']:
for option in ['alter_network', 'alter_user', 'create_tap', 'create_tun', 'tap_ipv6']:
attr = getattr(self, option)
if isinstance(attr, str):
if attr.lower() == 'true':
......
......@@ -646,46 +646,6 @@ class TestComputer(SlapformatMixin):
],
self.fakeCallAndRead.external_command_list)
def test_construct_use_unique_local_address_block(self):
"""
Test that slapformat creates a unique local address in the interface.
"""
global USER_LIST
USER_LIST = ['root']
computer = slapos.format.Computer('computer',
instance_root='/instance_root',
software_root='/software_root',
interface=slapos.format.Interface(
logger=self.logger, name='myinterface', ipv4_local_network='127.0.0.1/16'),
partition_list=[
slapos.format.Partition(
'partition', '/part_path', slapos.format.User('testuser'), [],
tap=slapos.format.Tap('tap')),
])
global INTERFACE_DICT
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::'}]
}
computer.format(use_unique_local_address_block=True, alter_user=False, create_tap=False)
self.assertEqual([
"makedirs('/instance_root', 493)",
"makedirs('/software_root', 493)",
"chmod('/software_root', 493)",
"mkdir('/instance_root/partition', 488)",
"chmod('/instance_root/partition', 488)"
],
self.test_result.bucket)
self.assertEqual([
'ip address add dev myinterface fd00::1/64',
'ip addr add ip/255.255.255.255 dev myinterface',
'ip addr add ip/ffff:ffff:ffff:ffff:: dev myinterface',
'ip -6 addr list myinterface'
],
self.fakeCallAndRead.external_command_list)
class TestFormatDump(SlapformatMixin):
def setUp(self):
......
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