Commit e155a995 authored by Kirill Smelkov's avatar Kirill Smelkov

software/ors-amarisoft: ru/*: Wrap with `if not testing` things that require real environment

For example there is no slaptap under StandaloneSlapOS and <RU>-netconf-socket
promise needs real RU hardware to be around and accepting incoming connections.

If we don't wrap such things with `if not testing` running test on testnodes will fail.

/cc @lu.xu, @tomo, @xavier_thompson, @Daetalus
/reviewed-by @jhuge
/reviewed-on nexedi/slapos!1514
parent db05a810
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
[template] [template]
filename = instance.cfg filename = instance.cfg
md5sum = 32cb60d3cc7718e21ad8887d16cb7e10 md5sum = a6c6075e138c2fa4400077acab7c015c
[slaplte.jinja2] [slaplte.jinja2]
_update_hash_filename_ = slaplte.jinja2 _update_hash_filename_ = slaplte.jinja2
...@@ -32,7 +32,7 @@ md5sum = ab666fdfadbfc7d8a16ace38d295c883 ...@@ -32,7 +32,7 @@ md5sum = ab666fdfadbfc7d8a16ace38d295c883
[ru_libinstance.jinja2.cfg] [ru_libinstance.jinja2.cfg]
_update_hash_filename_ = ru/libinstance.jinja2.cfg _update_hash_filename_ = ru/libinstance.jinja2.cfg
md5sum = 17f90d61a4994c58ceb816d2d8b06422 md5sum = 30c262a427de2132d6d66d9fb3597426
[ru_sdr_libinstance.jinja2.cfg] [ru_sdr_libinstance.jinja2.cfg]
_update_hash_filename_ = ru/sdr/libinstance.jinja2.cfg _update_hash_filename_ = ru/sdr/libinstance.jinja2.cfg
...@@ -40,7 +40,7 @@ md5sum = de71c63b8df940207409de7e948f7c8c ...@@ -40,7 +40,7 @@ md5sum = de71c63b8df940207409de7e948f7c8c
[ru_lopcomm_libinstance.jinja2.cfg] [ru_lopcomm_libinstance.jinja2.cfg]
_update_hash_filename_ = ru/lopcomm/libinstance.jinja2.cfg _update_hash_filename_ = ru/lopcomm/libinstance.jinja2.cfg
md5sum = 497c7831d9bcf47e1d1c87284b08a5dc md5sum = 71508d94a47db493f30af30188c48d64
[ru_sunwave_libinstance.jinja2.cfg] [ru_sunwave_libinstance.jinja2.cfg]
_update_hash_filename_ = ru/sunwave/libinstance.jinja2.cfg _update_hash_filename_ = ru/sunwave/libinstance.jinja2.cfg
......
...@@ -26,6 +26,7 @@ output = $${buildout:directory}/$${:filename} ...@@ -26,6 +26,7 @@ output = $${buildout:directory}/$${:filename}
extra-context = extra-context =
context = context =
import json_module json import json_module json
import netaddr netaddr
key eggs_directory buildout:eggs-directory key eggs_directory buildout:eggs-directory
key develop_eggs_directory buildout:develop-eggs-directory key develop_eggs_directory buildout:develop-eggs-directory
raw buildout_directory ${buildout:directory} raw buildout_directory ${buildout:directory}
......
...@@ -58,6 +58,11 @@ ntap = {{ ntap }} ...@@ -58,6 +58,11 @@ ntap = {{ ntap }}
command = {{ netcapdo }} {{ pythonwitheggs }} {{ ru_tapsplit }} {{ slaplte.tap }} ${:ntap} command = {{ netcapdo }} {{ pythonwitheggs }} {{ ru_tapsplit }} {{ slaplte.tap }} ${:ntap}
update-command = ${:command} update-command = ${:command}
stop-on-error = true stop-on-error = true
{%- if testing %}
# StandaloneSlapOS does not provide slaptap
command = :
{%- endif %}
{%- set test_slapnet = netaddr.IPNetwork('1234::/71') %}
{%- if ntap <= 1 %} {%- if ntap <= 1 %}
[vtap] [vtap]
...@@ -67,10 +72,16 @@ stop-on-error = false ...@@ -67,10 +72,16 @@ stop-on-error = false
{%- if ntap == 1 %} {%- if ntap == 1 %}
{%- do vtap_list.append(slaplte.tap) %} {%- do vtap_list.append(slaplte.tap) %}
[vtap.{{ slaplte.tap }}] [vtap.{{ slaplte.tap }}]
{%- if testing %}
network = {{ str(test_slapnet) }}
gateway = {{ str(test_slapnet[1]) }}
addr = {{ str(test_slapnet[-1]) }}
{%- else %}
network = {{ slap_configuration['tap-ipv6-network'] }} network = {{ slap_configuration['tap-ipv6-network'] }}
gateway = {{ slap_configuration['tap-ipv6-gateway'] }} gateway = {{ slap_configuration['tap-ipv6-gateway'] }}
addr = {{ slap_configuration['tap-ipv6-addr'] }} addr = {{ slap_configuration['tap-ipv6-addr'] }}
{%- endif %} {%- endif %}
{%- endif %}
{%- else %} {%- else %}
...@@ -86,6 +97,7 @@ init = ...@@ -86,6 +97,7 @@ init =
with open(path) as f: with open(path) as f:
return f.read() return f.read()
import netaddr
# ~ import tapsplit # ~ import tapsplit
tapsplit = types.ModuleType('tapsplit') tapsplit = types.ModuleType('tapsplit')
exec(readfile('{{ ru_tapsplit }}'), tapsplit.__dict__) exec(readfile('{{ ru_tapsplit }}'), tapsplit.__dict__)
...@@ -93,6 +105,9 @@ init = ...@@ -93,6 +105,9 @@ init =
# simulate what tapsplit would assign to the tap # simulate what tapsplit would assign to the tap
# ( tap subinterface will be created for real later at install time - when it # ( tap subinterface will be created for real later at install time - when it
# is too late to update section options ) # is too late to update section options )
if {{ testing }}:
slapnet = netaddr.IPNetwork('{{ str(test_slapnet) }}')
else:
slapnet = tapsplit.ifnet6('{{ slaplte.tap }}') slapnet = tapsplit.ifnet6('{{ slaplte.tap }}')
tapnet = tapsplit.netsplit(slapnet, {{ 1+ntap }}) [{{ i }}] tapnet = tapsplit.netsplit(slapnet, {{ 1+ntap }}) [{{ i }}]
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
{#- indicate whether RU is listening for netconf #} {#- indicate whether RU is listening for netconf #}
{%- if not testing %}
{{ promise('%s-netconf-socket' % ru_ref) }} {{ promise('%s-netconf-socket' % ru_ref) }}
promise = check_socket_listening promise = check_socket_listening
config-host = ${vtap.{{cell._tap}}:gateway} config-host = ${vtap.{{cell._tap}}:gateway}
config-port = 830 config-port = 830
{%- endif %}
{#- push firmware to RU #} {#- push firmware to RU #}
...@@ -37,9 +39,11 @@ mode = 0775 ...@@ -37,9 +39,11 @@ mode = 0775
url = {{ ru_lopcomm_software_template }} url = {{ ru_lopcomm_software_template }}
output = ${directory:script}/{{ru_ref}}-software.py output = ${directory:script}/{{ru_ref}}-software.py
{%- if not testing %}
{{ promise('%s-firmware' % ru_ref) }} {{ promise('%s-firmware' % ru_ref) }}
promise = check_command_execute promise = check_command_execute
config-command = [ -f ${ {{-ru_ref}}-software-template:is_firmware_updated} ] config-command = [ -f ${ {{-ru_ref}}-software-template:is_firmware_updated} ]
{%- endif %}
{#- push config to RU #} {#- push config to RU #}
...@@ -126,9 +130,11 @@ mode = 0775 ...@@ -126,9 +130,11 @@ mode = 0775
hash-files = hash-files =
${:command-line} ${:command-line}
{%- if not testing %}
{{ promise('%s-netconf-connection' % ru_ref) }} {{ promise('%s-netconf-connection' % ru_ref) }}
promise = check_command_execute promise = check_command_execute
config-command = [ -f ${ {{-ru_ref}}-stats-template:is_netconf_connected} ] config-command = [ -f ${ {{-ru_ref}}-stats-template:is_netconf_connected} ]
{%- endif %}
{{ promise('%s-vswr' % ru_ref) }} {{ promise('%s-vswr' % ru_ref) }}
promise = check_lopcomm_vswr promise = check_lopcomm_vswr
......
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