Commit 1aa17677 authored by Xavier Thompson's avatar Xavier Thompson

software/theia: Use IPv6 range when available

See merge request !1403
parents 63078069 1cbfa70e
Pipeline #28986 failed with stage
in 0 seconds
......@@ -15,4 +15,4 @@
[template]
filename = instance.cfg
md5sum = 06379c0ed1fe0df409c7b8f61fc218eb
md5sum = ed0f91f39d5eda903938aa527625f40d
......@@ -28,13 +28,20 @@ test-working-dir = ${buildout:directory}/tmp
nxdtest-working-dir = ${:var}/nxdtest
[slapos-test-runner-nxdtest-environment.sh]
recipe = slapos.recipe.template
recipe = slapos.recipe.template:jinja2
output = ${directory:etc}/${:_buildout_section_name_}
PATH={{ buildout['bin-directory'] }}:{{ curl_location }}/bin:{{ faketime_location }}/bin:{{ openssl_location }}/bin:/usr/bin:/bin
context =
section slap slap-configuration
key ipv6_random slap-configuration:ipv6-random
{%- raw %}
inline =
export PATH={{ buildout['bin-directory'] }}:{{ curl_location }}/bin:{{ faketime_location }}/bin:{{ openssl_location }}/bin:/usr/bin:/bin
export PATH=${:PATH}
export SLAPOS_TEST_IPV4=${slap-configuration:ipv4-random}
export SLAPOS_TEST_IPV6=${slap-configuration:ipv6-random}
export SLAPOS_TEST_IPV6={{ slap.get('ipv6-range-network') or ipv6_random }}
export SLAPOS_TEST_WORKING_DIR=${directory:test-working-dir}
{%- endraw %}
[slapos-test-runner-dot-nxdtest]
recipe = slapos.recipe.template:jinja2
......
......@@ -15,11 +15,11 @@
[instance-theia]
_update_hash_filename_ = instance-theia.cfg.jinja.in
md5sum = a9d4ace568acdd5002d587816ab91737
md5sum = d8fa4bed6b7d7c77b0aec53abae32426
[instance]
_update_hash_filename_ = instance.cfg.in
md5sum = 08b8aa2b7f59ac0e4e5d4ca180054937
md5sum = f322033a7670b9be29b1bf1bf9024b87
[instance-import]
_update_hash_filename_ = instance-import.cfg.jinja.in
......@@ -35,7 +35,7 @@ md5sum = ad9499e7355ded4975ad313442cecb7a
[slapos-standalone-script]
_update_hash_filename_ = slapos_standalone_script.py.jinja
md5sum = 6792d29057db35ea69b01e72a5c913e3
md5sum = 93c492cc5c186989f104f37de43f25c5
[theia-common]
_update_hash_filename_ = theia_common.py
......
......@@ -38,7 +38,7 @@ additional-url = $${remote-additional-frontend:connection-secure_access}
username = $${frontend-instance-password:username}
password = $${frontend-instance-password:passwd}
backend-url = $${frontend-instance:url}
ipv6 = {{ ipv6_random }}
ipv6 = {{ ipv6_theia }}
[directory]
recipe = slapos.cookbook:mkdirectory
......@@ -227,7 +227,7 @@ storage-path = $${buildout:parts-directory}/.$${:_buildout_section_name_}
recipe = slapos.cookbook:free_port
minimum = 3000
maximum = 3100
ip = {{ ipv6_random }}
ip = {{ ipv6_theia }}
[frontend-instance-certificate]
recipe = plone.recipe.command
......@@ -421,7 +421,7 @@ inline =
#!/bin/sh
export HOME=$${directory:home}
export PATH=${cli-utilities:PATH}:$HOME/.cargo/bin:$HOME/.local/bin:$PATH
export IPV6_SLAPRUNNER={{ ipv6_random }}
export IPV6_SLAPRUNNER={{ ipv6_theia }}
# Theia Backend
# -------------
......@@ -566,7 +566,7 @@ ip = {{ ipv4_random }}
[slapos-standalone-config]
ipv4 = {{ ipv4_random }}
ipv6 = {{ ipv6_random }}
ipv6 = {{ slap_resource.get('ipv6-range-network') or ipv6_theia }}
port = $${slapos-standalone-port:port}
base-directory = $${directory:runner}
software-root = $${directory:runner}/software
......@@ -603,7 +603,7 @@ context =
key home_path directory:home
key forward_frontend_requests :forward-frontend-requests
section slap_connection slap-connection
section slapos_standalone_config slapos-standalone-config
section config slapos-standalone-config
forward-frontend-requests = {{ parameter_dict['forward-slapos-frontend-requests'] }}
url = ${slapos-standalone-script:output}
......
......@@ -37,8 +37,9 @@ context =
key parameter_dict slap-configuration:configuration
key root_title slap-configuration:root-instance-title
key partition_root_path buildout:directory
key ipv6_random slap-configuration:ipv6-random
key ipv6_theia slap-configuration:ipv6-random
key ipv4_random slap-configuration:ipv4-random
section slap_resource slap-configuration
import os os
import json json
default-parameters =
......
......@@ -70,23 +70,23 @@ def setupStandalone():
shared_parts = {{ repr(shared_part_list) }}
shared_part_list = [x.strip() for x in shared_parts.splitlines() if x.strip()]
standalone = slapos.slap.standalone.StandaloneSlapOS(
{{ repr(slapos_standalone_config['base-directory']) }},
{{ repr(slapos_standalone_config['ipv4']) }},
{{ slapos_standalone_config['port'] }},
computer_id={{ repr(slapos_standalone_config['computer-id']) }},
{{ repr(config['base-directory']) }},
{{ repr(config['ipv4']) }},
{{ config['port'] }},
computer_id={{ repr(config['computer-id']) }},
shared_part_list=shared_part_list,
software_root={{ repr(slapos_standalone_config['software-root']) }},
instance_root={{ repr(slapos_standalone_config['instance-root']) }},
software_root={{ repr(config['software-root']) }},
instance_root={{ repr(config['instance-root']) }},
partition_forward_configuration=partition_forward_configuration,
slapos_bin={{ repr(slapos_standalone_config['slapos-bin']) }},
local_software_release_root={{ repr(slapos_standalone_config['local-software-release-root']) }},
slapos_bin={{ repr(config['slapos-bin']) }},
local_software_release_root={{ repr(config['local-software-release-root']) }},
)
standalone.start()
try:
partition_count = 20
logging.info("Standalone SlapOS: Formatting %d partitions", partition_count)
standalone.format(partition_count, {{ repr(slapos_standalone_config['ipv4']) }}, {{ repr(slapos_standalone_config['ipv6']) }})
logging.info("Standalone SlapOS for computer `%s` started", {{ repr(slapos_standalone_config['computer-id']) }})
standalone.format(partition_count, {{ repr(config['ipv4']) }}, {{ repr(config['ipv6']) }})
logging.info("Standalone SlapOS for computer `%s` started", {{ repr(config['computer-id']) }})
# Run instance at least once, to start the supervisor managing instances.
try:
standalone.waitForInstance(max_retry=0)
......@@ -179,7 +179,7 @@ def main():
s = socket.socket(socket.AF_UNIX)
s.bind({{ repr('\0' + slapos_standalone_config['abstract-socket-path']) }})
s.bind({{ repr('\0' + config['abstract-socket-path']) }})
s.listen(5)
logging.info("Standalone SlapOS ready")
......
......@@ -34,6 +34,7 @@ import subprocess
import sqlite3
import time
import netaddr
import pexpect
import psutil
import requests
......@@ -241,6 +242,19 @@ class TestTheia(TheiaTestCase):
self.assertIn(b'slaprunner', self.captureSlapos('proxy', 'show'))
self.assertIn(b'slaprunner', self.captureSlapos('computer', 'list'))
def test_ipv6_range(self):
proxy_path = self.getPath('srv', 'runner', 'var', 'proxy.db')
query = "SELECT partition_reference, address FROM partition_network%s" % DB_VERSION
with sqlite3.connect(proxy_path) as db:
rows = db.execute(query).fetchall()
partitions = set(p for p, _ in rows)
ipv6 = set(addr for _, addr in rows if netaddr.valid_ipv6(addr))
# Check that each partition has a different IPv6
self.assertEqual(len(partitions), len(ipv6))
# Check that no partition has the same IPv6 as theia
self.assertNotIn(self.connection_parameters['ipv6'], ipv6)
class TestTheiaWithNonAsciiInstanceName(TestTheia):
default_partition_reference = '💥'
......
......@@ -435,7 +435,8 @@ class TestTheiaExportAndImport(ResilienceMixin, ExportAndImportMixin, ResilientT
class TakeoverMixin(ExportAndImportMixin):
def _getTakeoverUrlAndPassword(self, scope="theia-1"):
parameter_dict = self.computer_partition.getConnectionParameterDict()
partition = self.requestDefaultInstance() # re-request for up-to-date info
parameter_dict = partition.getConnectionParameterDict()
takeover_url = parameter_dict["takeover-%s-url" % scope]
takeover_password = parameter_dict["takeover-%s-password" % scope]
return takeover_url, takeover_password
......
......@@ -297,7 +297,7 @@ simplegeneric = 0.8.1
singledispatch = 3.4.0.3
six = 1.16.0
slapos.cookbook = 1.0.326
slapos.core = 1.10.0
slapos.core = 1.10.1
slapos.extension.shared = 1.0
slapos.libnetworkcache = 0.25
slapos.rebootstrap = 4.5
......
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