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