Commit 1a532ff5 authored by Kirill Smelkov's avatar Kirill Smelkov

Merge branch 'x/lte-multiru+quote' into x/lte-multiru

Quote/dumps all strings where ru_ref or call_ref take place to properly handle
arbitrary references with e.g. '$' '\n' and other tricky symbols via which it
was possible to break instantiation and to inject buildout code.
parents 0a7493df 2a564c6b
......@@ -24,11 +24,11 @@ md5sum = f5c76c3443b75569eb18503dce38e783
[slaplte.jinja2]
_update_hash_filename_ = slaplte.jinja2
md5sum = 8c044b28682940fbca62657c16613157
md5sum = fa841e105d78aab36b9ea205a69608fb
[ru_libinstance.jinja2.cfg]
_update_hash_filename_ = ru/libinstance.jinja2.cfg
md5sum = 031805301916a7d17a6a8fb31914cbea
md5sum = 4c1e6fbd774042cdd12687fd30635c6b
[ru_sdr_libinstance.jinja2.cfg]
_update_hash_filename_ = ru/sdr/libinstance.jinja2.cfg
......@@ -36,7 +36,7 @@ md5sum = b7906ca3a6b17963f78f680fc0842b74
[ru_lopcomm_libinstance.jinja2.cfg]
_update_hash_filename_ = ru/lopcomm/libinstance.jinja2.cfg
md5sum = 409ab889d75ec260aa0e52548463a38f
md5sum = 667bf3d0af1ae3e6d740c667957449dc
[ru_sunwave_libinstance.jinja2.cfg]
_update_hash_filename_ = ru/sunwave/libinstance.jinja2.cfg
......@@ -76,19 +76,19 @@ md5sum = 2b08bb666c5f3ab287cdddbfdb4c9249
[ru_tapsplit]
_update_hash_filename_ = ru/tapsplit
md5sum = 2b8b57c5771b2a2203c0e7767e629e55
md5sum = da551861a6612333e8560622b9db8000
[ru_xbuildout.py]
_update_hash_filename_ = ru/xbuildout.py
md5sum = b9aa7356ebccfb1e9d2324106ad88485
md5sum = 2856e18a18eb8f0af090cfd714e1973a
[ru_capdo.c]
_update_hash_filename_ = ru/capdo.c
md5sum = 52da9fe3a569199e35ad89ae1a44c30e
md5sum = 628f732bcaa86f0b3a6ecb64ca5de071
[template-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg
md5sum = 143f9b0e9866d37e6527e89f74b4ef1c
md5sum = 29b5a5a61b0498681d480726be9e56bf
[template-ors-enb]
_update_hash_filename_ = instance-ors-enb.jinja2.cfg
......@@ -100,7 +100,7 @@ md5sum = c807be73b9304f5a4c7483a3776bbc17
[template-ue]
_update_hash_filename_ = instance-ue.jinja2.cfg
md5sum = aa6b8e50bd8d9c4cc6e23b01a2be5644
md5sum = 0b4621200b254427beea3c2565afcb08
[template-obsolete]
_update_hash_filename_ = instance-obsolete.jinja2.cfg
......@@ -112,7 +112,7 @@ md5sum = dcaac06553a3222b14c0013a13f4a149
[enb.jinja2.cfg]
filename = config/enb.jinja2.cfg
md5sum = a8e67b3c9373fe4d97066a64d1ff8a98
md5sum = 7edbafa743dc17749ff910aca775abbf
[drb_lte.jinja2.cfg]
filename = config/drb_lte.jinja2.cfg
......
{%- import 'slaplte.jinja2' as slaplte with context %}
{%- set B = slaplte.B %}
{%- set J = slaplte.J %}
{%- set jcell_ru_ref = slaplte.jcell_ru_ref %}
{%- set cfg = slaplte.cfg %}
{#- for standalone testing via slapos-render-config.py
NOTE: keep in sync with instance-enb.jinja2.cfg and ru/libinstance.jinja2.cfg #}
......@@ -35,13 +35,13 @@
{
{%- if cell2.cell_type == 'lte' %}
rat: "eutra",
cell_id: {{ slapparameter_dict.enb_id }}{{ cell2.cell_id.removeprefix('0x') }}, // -> {{ cell2_ref }}
cell_id: {{ slapparameter_dict.enb_id }}{{ cell2.cell_id.removeprefix('0x') }}, // -> {{ B(cell2_ref) }}
n_id_cell: {{ cell2.pci }},
dl_earfcn: {{ cell2.dl_earfcn }},
tac: {{ cell2.tac }},
{%- elif cell2.cell_type == 'nr' %}
rat: "nr",
cell_id: {{ cell2.cell_id }}, // -> {{ cell2_ref }}
cell_id: {{ cell2.cell_id }}, // -> {{ B(cell2_ref) }}
{%- else %}
{%- do bug('unreachable') %}
{%- endif %}
......@@ -58,13 +58,13 @@
{
{%- if ncell.cell_type == 'lte' %}
rat: "eutra",
cell_id: {{ ncell.e_cell_id }}, // -> {{ peercell_ref }}
cell_id: {{ ncell.e_cell_id }}, // -> {{ B(peercell_ref) }}
n_id_cell: {{ ncell.pci }},
dl_earfcn: {{ ncell.dl_earfcn }},
tac: {{ ncell.tac }},
{%- elif ncell.cell_type == 'nr' %}
rat: "nr",
nr_cell_id: {{ ncell.nr_cell_id }}, // -> {{ peercell_ref }}
nr_cell_id: {{ ncell.nr_cell_id }}, // -> {{ B(peercell_ref) }}
gnb_id_bits: {{ ncell.gnb_id_bits }},
n_id_cell: {{ ncell.pci }},
dl_nr_arfcn: {{ ncell.dl_nr_arfcn }},
......@@ -184,7 +184,7 @@
{%- set iru = iru_dict[ru_ref] %}
{%- set ru = iru['_'] %}
// {{ cell_ref }} ({{ ru_ref }})
// {{ B(cell_ref) }} ({{ B(ru_ref) }})
{
rf_port: {{ ru._rf_port }},
n_antenna_dl: {{ ru.n_antenna_dl }},
......@@ -208,7 +208,7 @@
{%- set cell2 = icell2['_'] %}
{%- if cell2_ref != cell_ref and cell2.cell_type == 'lte' %}
{
cell_id: {{ cell2.cell_id }}, // + {{ cell2_ref }}
cell_id: {{ cell2.cell_id }}, // + {{ B(cell2_ref) }}
cross_carrier_scheduling: false,
},
{%- endif %}
......@@ -222,7 +222,7 @@
{%- set cell2 = icell2['_'] %}
{%- if cell2_ref != cell_ref and cell2.cell_type == 'nr' %}
{
cell_id: {{ cell2.cell_id }}, // + {{ cell2_ref }}
cell_id: {{ cell2.cell_id }}, // + {{ B(cell2_ref) }}
},
{%- endif %}
{%- endfor %}
......@@ -298,11 +298,11 @@
manual_ref_signal_power: true,
{%- endif %}
drb_config: "{{ cell_ref }}-drb.cfg",
drb_config: "{{ B('%s-drb.cfg' % cell_ref) }}",
sib_sched_list: [
{
filename: "{{ cell_ref }}-sib23.asn",
filename: "{{ B('%s-sib23.asn' % cell_ref) }}",
si_periodicity: 16,
},
],
......@@ -421,7 +421,7 @@
{%- set iru = iru_dict[ru_ref] %}
{%- set ru = iru['_'] %}
// {{ cell_ref }} ({{ ru_ref }})
// {{ B(cell_ref) }} ({{ B(ru_ref) }})
{
rf_port: {{ ru._rf_port }},
n_antenna_dl: {{ ru.n_antenna_dl }},
......@@ -450,7 +450,7 @@
{%- set cell2 = icell2['_'] %}
{%- if cell2_ref != cell_ref and cell2.cell_type == 'nr' %}
{
cell_id: {{ cell2.cell_id }}, // + {{ cell2_ref }}
cell_id: {{ cell2.cell_id }}, // + {{ B(cell2_ref) }}
},
{%- endif %}
{%- endfor %}
......@@ -698,7 +698,7 @@
},
drb_config: "{{ cell_ref }}-drb.cfg",
drb_config: "{{ B('%s-drb.cfg' % cell_ref) }}",
},
{%- endif %}
......
......@@ -48,7 +48,7 @@
// LTE cells
cell_list: [
// CELL_a (RU1)
// CELL__a (RU1)
{
rf_port: 0,
n_antenna_dl: 2,
......@@ -68,7 +68,7 @@
// Intra-ENB HO
{
rat: "nr",
cell_id: 0x02, // -> CELL_b
cell_id: 0x02, // -> CELL__b
},
// Inter-ENB HO
......@@ -102,7 +102,7 @@
// Dual Connectivity: LTE + NR
en_dc_scg_cell_list: [
{
cell_id: 0x02, // + CELL_b
cell_id: 0x02, // + CELL__b
},
],
......@@ -140,11 +140,11 @@
srs_hopping_bandwidth: 0,
},
drb_config: "CELL_a-drb.cfg",
drb_config: "CELL__a-drb.cfg",
sib_sched_list: [
{
filename: "CELL_a-sib23.asn",
filename: "CELL__a-sib23.asn",
si_periodicity: 16,
},
],
......@@ -242,7 +242,7 @@
// NR cells
nr_cell_list: [
// CELL_b (RU2)
// CELL__b (RU2)
{
rf_port: 1,
n_antenna_dl: 2,
......@@ -267,7 +267,7 @@
// Intra-ENB HO
{
rat: "eutra",
cell_id: 0x1001201, // -> CELL_a
cell_id: 0x1001201, // -> CELL__a
n_id_cell: 1,
dl_earfcn: 38050,
tac: 0x1234,
......@@ -438,7 +438,7 @@
},
drb_config: "CELL_b-drb.cfg",
drb_config: "CELL__b-drb.cfg",
},
],
......
......@@ -12,8 +12,8 @@
// XXX vvv <- ru.txrx_active ? XXX how to handle txrx_active for SDR ?
// (tx_gain=-1000 does not work - it still sets tx_gain to min.possible value 14)
name: "sdr",
// _UCELL1_ru 2T1R (sdr)
// _UCELL2_ru 2T2R (sdr)
// __UCELL1__ru 2T1R (sdr)
// __UCELL2__ru 2T2R (sdr)
args: "dev0=/dev/sdr0,dev1=/dev/sdr2",
rx_antenna:"tx_rx",
tdd_tx_mod: 1,
......
......@@ -189,7 +189,8 @@ context =
key slapparameter_dict slap-configuration:configuration
key gtp_addr_v6 slap-configuration:ipv6-random
raw gtp_addr_v4 {{ lan_ipv4 }}
import netaddr netaddr
import xbuildout xbuildout
import netaddr netaddr
${:extra-context}
[enb-config]
......@@ -200,14 +201,18 @@ url = ${enb-config-dl:target}
url = {{ enb_template }}
{% endif %}
output = ${directory:etc}/enb.cfg
extra-context =
json iru_dict {{ rulib.iru_dict | tojson }}
json icell_dict {{ rulib.icell_dict | tojson }}
json ipeer_dict {{ ipeer_dict | tojson }}
json ipeercell_dict {{ ipeercell_dict | tojson }}
import json_module json
import-list =
rawfile slaplte.jinja2 {{ slaplte_template }}
extra-context =
import json_module json
key iru_dict :iru_dict
key icell_dict :icell_dict
key ipeer_dict :ipeer_dict
key ipeercell_dict :ipeercell_dict
iru_dict = {{ dumps(rulib.iru_dict) }}
icell_dict = {{ dumps(rulib.icell_dict) }}
ipeer_dict = {{ dumps(ipeer_dict) }}
ipeercell_dict = {{ dumps(ipeercell_dict) }}
[publish-connection-information]
......@@ -221,8 +226,8 @@ enb-ipv4 = {{ lan_ipv4 }}
amarisoft-version = {{ lte_version }}
license-expiration = {{ lte_expiration }}
monitor-gadget-url = ${:monitor-base-url}/gadget/software.cfg.html
ru-list = {{ rulib.iru_dict.keys() | sort | join(', ') }}
cell-list = {{ rulib.icell_dict.keys() | sort | join(', ') }}
ru-list = {{ dumps(rulib.iru_dict.keys() | sort) }}
cell-list = {{ dumps(rulib.icell_dict.keys() | sort) }}
# TODO peer-list peer-cell-list
peer-list = XXX
peer-cell-list = XXX
......
......@@ -117,13 +117,16 @@ url = ${ue-config-dl:target}
url = {{ ue_template }}
{% endif %}
output = ${directory:etc}/ue.cfg
extra-context =
json iru_dict {{ rulib.iru_dict | tojson }}
json icell_dict {{ rulib.icell_dict | tojson }}
json iue_dict {{ iue_dict | tojson }}
import json_module json
import-list =
rawfile slaplte.jinja2 {{ slaplte_template }}
extra-context =
import json_module json
key iru_dict :iru_dict
key icell_dict :icell_dict
key iue_dict :iue_dict
iru_dict = {{ rulib.iru_dict }}
icell_dict = {{ rulib.icell_dict }}
iue_dict = {{ iue_dict }}
[publish-connection-information]
......
// Copyright (C) 2023 Nexedi SA and Contributors.
// Copyright (C) 2023-2024 Nexedi SA and Contributors.
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
......
......@@ -41,7 +41,7 @@
{%- set pretty_name = name.removeprefix('%s.' % root) %}
{{ part('promise-'+name) }}
<= monitor-promise-base
name = {{ pretty_name }}.py
name = {{ dumps('%s.py' % pretty_name) }}
config-testing = {{ testing }}
config-stats-period = {{ slapparameter_dict.get("enb_stats_fetch_period", 60) }}
{%- endmacro %}
......@@ -153,7 +153,8 @@ context =
import netaddr netaddr
section directory directory
section vtap_jdict vtap_jdict
json iru_dict {{ iru_dict | tojson }}
key iru_dict :iru_dict
iru_dict = {{ dumps(iru_dict) }}
{{ part('dnsmasq-service') }}
recipe = slapos.cookbook:wrapper
......@@ -185,7 +186,7 @@ hash-files =
{%- endif %}
{%- endfor %}
# {{ ru_ref }} {{ ru.n_antenna_dl }}T{{ ru.n_antenna_ul }}R ({{ ru.ru_type }})
# {{ dumps(ru_ref) }} {{ ru.n_antenna_dl }}T{{ ru.n_antenna_ul }}R ({{ ru.ru_type }})
{%- if ru.ru_link_type == 'sdr' %}
{%- for (i, n) in enumerate(ru.sdr_dev_list) %}
{{ promise('%s-sdr-busy%s' % (ru_ref, '-%d' % (i+1) if i > 0 else '')) }}
......@@ -229,13 +230,13 @@ config-max-rx-sample-db = {{ slapparameter_dict.get("max_rx_sample_db", 0) }}
{#- publish information about RU #}
{{ part('publish-%s' % ru_ref) }}
recipe = slapos.cookbook:publish.serialised
-slave-reference = {{ iru.slave_reference }}
enb = {{ root }}
-slave-reference = {{ dumps(iru.slave_reference) }}
{{ slap_configuration['slap-software-type'] }} = {{ dumps(root) }}
{%- set iru_icell_ref_list = [] %}
{%- for icell in iru_icell_list %}
{%- do iru_icell_ref_list.append(J(jref_of_shared(icell))) %}
{%- endfor %}
cell-list = {{ iru_icell_ref_list | join(', ') }}
cell-list = {{ dumps(iru_icell_ref_list) }}
{%- if ru.ru_link_type == 'cpri' %}
ipv6 = ${vtap.{{ ru.cpri_link._tap }}:gateway}
{%- endif %}
......@@ -255,31 +256,38 @@ ipv6 = ${vtap.{{ ru.cpri_link._tap }}:gateway}
{{ part('drb-config-%s' % cell_ref) }}
<= config-base
url = {{ {'lte': drb_lte_template, 'nr': drb_nr_template} [cell.cell_type] }}
output = ${directory:etc}/{{cell_ref}}-drb.cfg
output = ${directory:etc}/{{B('%s-drb.cfg' % cell_ref)}}
extra-context =
json cell_ref {{ cell_ref | tojson }}
json cell {{ cell | tojson }}
json ru_ref {{ ru_ref | tojson }}
json ru {{ ru | tojson }}
key cell_ref :cell_ref
key cell :cell
key ru_ref :ru_ref
key ru :ru
cell_ref = {{ dumps(cell_ref) }}
cell = {{ dumps(cell ) }}
ru_ref = {{ dumps(ru_ref ) }}
ru = {{ dumps(ru ) }}
{{ part('sib23-config-%s' % cell_ref) }}
<= config-base
url = {{ sib23_template }}
output = ${directory:etc}/{{cell_ref}}-sib23.asn
output = ${directory:etc}/{{B('%s-sib23.asn' % cell_ref)}}
extra-context =
json cell_ref {{ cell_ref | tojson }}
json cell {{ cell | tojson }}
json ru_ref {{ ru_ref | tojson }}
json ru {{ ru | tojson }}
key cell_ref :cell_ref
key cell :cell
key ru_ref :ru_ref
key ru :ru
cell_ref = {{ dumps(cell_ref) }}
cell = {{ dumps(cell ) }}
ru_ref = {{ dumps(ru_ref ) }}
ru = {{ dumps(ru ) }}
{%- endif %}
{#- publish information about the cell #}
{{ part('publish-%s' % cell_ref) }}
recipe = slapos.cookbook:publish.serialised
-slave-reference = {{ icell.slave_reference }}
enb = {{ root }}
ru = {{ ru_ref }}
# XXX enb -> ue in case of uesim
-slave-reference = {{ dumps(icell.slave_reference) }}
{{ slap_configuration['slap-software-type'] }} = {{ dumps(root) }}
ru = {{ dumps(ru_ref) }}
# XXX +error
{%- endfor %}
......@@ -321,7 +329,8 @@ context =
raw stats_period {{ slapparameter_dict.get("enb_stats_fetch_period", 60) }}
raw testing {{ testing }}
raw python_path {{ buildout_directory}}/bin/pythonwitheggs
json iru_dict {{ iru_dict | tojson }}
key iru_dict :iru_dict
iru_dict = {{ dumps(iru_dict) }}
mode = 0775
url = {{ ru_amarisoft_stats_template }}
output = ${directory:bin}/amarisoft-stats.py
......
......@@ -23,11 +23,11 @@ config-port = 830
[{{ B('%s-software-template' % ru_ref) }}]
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
_logbase = ${directory:var}/log/{{ru_ref}}-software
_logbase = ${directory:var}/log/{{B('%s-software' % ru_ref)}}
log-output = ${:_logbase}.log
software-reply-json-log-output = ${:_logbase}-reply.json.log
remote-file-path = sftp://${user-info:pw-name}@[${sshd-service:ipv6}]:${sshd-service:port}{{ru_lopcomm_firmware_path}}
is_firmware_updated = ${directory:etc}/{{ru_ref}}.is_firmware_updated
is_firmware_updated = ${directory:etc}/{{B('%s.is_firmware_updated' % ru_ref)}}
context =
section directory directory
section vtap vtap.{{ ru.cpri_link._tap }}
......@@ -43,7 +43,7 @@ context =
import netaddr netaddr
mode = 0775
url = {{ ru_lopcomm_software_template }}
output = ${directory:script}/{{ru_ref}}-software.py
output = ${directory:script}/{{B('%s-software.py' % ru_ref)}}
{{ promise('%s-firmware' % ru_ref) }}
promise = check_command_execute
......@@ -67,17 +67,19 @@ url = ${ {{-B('%s-cu-config-dl' % ru_ref)}}:target}
{% else %}
url = {{ ru_lopcomm_cu_config_template }}
{% endif %}
output = ${directory:etc}/{{ru_ref}}-cu_config.xml
output = ${directory:etc}/{{B('%s-cu_config.xml' % ru_ref)}}
extra-context =
import xearfcn_module xlte.earfcn
import xnrarfcn_module xlte.nrarfcn
json ru {{ ru | tojson }}
json cell {{ cell | tojson }}
key ru :ru
key cell :cell
ru = {{ dumps(ru) }}
cell = {{ dumps(cell) }}
[{{ B('%s-config-template' % ru_ref) }}]
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
log-output = ${directory:var}/log/{{ru_ref}}-config.log
log-output = ${directory:var}/log/{{B('%s-config.log' % ru_ref)}}
context =
section directory directory
section vtap vtap.{{ ru.cpri_link._tap }}
......@@ -90,7 +92,7 @@ context =
import netaddr netaddr
mode = 0775
url = {{ ru_lopcomm_config_template }}
output = ${directory:script}/{{ru_ref}}-config.py
output = ${directory:script}/{{B('%s-config.py' % ru_ref)}}
{{ promise('%s-config-log' % ru_ref) }}
promise = check_lopcomm_config_log
......@@ -102,7 +104,7 @@ config-config-log = ${ {{-B('%s-config-template' % ru_ref)}}:log-output}
[{{ B('%s-stats-template' % ru_ref) }}]
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
_logbase = ${directory:var}/log/{{ru_ref}}
_logbase = ${directory:var}/log/{{B('%s' % ru_ref)}}
log-output = ${:_logbase}-stats.log
json-log-output = ${:_logbase}-stats.json.log
cfg-json-log-output = ${:_logbase}-config.json.log
......@@ -110,7 +112,7 @@ supervision-json-log-output = ${:_logbase}-supervision.json.log
ncsession-json-log-output = ${:_logbase}-ncsession.json.log
software-json-log-output = ${:_logbase}-software.json.log
supervision-reply-json-log-output = ${:_logbase}-supervision-reply.json.log
is_netconf_connected = ${directory:etc}/{{ru_ref}}.is_netconf_connected
is_netconf_connected = ${directory:etc}/{{B('%s.is_netconf_connected' % ru_ref)}}
context =
section directory directory
section vtap vtap.{{ ru.cpri_link._tap }}
......@@ -129,12 +131,12 @@ context =
import netaddr netaddr
mode = 0775
url = {{ ru_lopcomm_stats_template }}
output = ${directory:bin}/{{ru_ref}}-stats.py
output = ${directory:bin}/{{B('%s-stats.py' % ru_ref)}}
{{ part('%s-stats-service' % ru_ref) }}
recipe = slapos.cookbook:wrapper
command-line = ${ {{-B('%s-stats-template' % ru_ref)}}:output}
wrapper-path = ${directory:service}/{{ru_ref}}-stats
wrapper-path = ${directory:service}/{{B('%s-stats' % ru_ref)}}
mode = 0775
hash-files =
${:command-line}
......@@ -179,7 +181,7 @@ config-stats-log = ${ {{-B('%s-stats-template' % ru_ref)}}:log-output}
[{{ B('%s-reset-info-template' % ru_ref) }}]
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
_logbase = ${directory:var}/log/{{ru_ref}}-reset-info
_logbase = ${directory:var}/log/{{B('%s-reset-info' % ru_ref)}}
log-output = ${:_logbase}.log
json-log-output = ${:_logbase}.json.log
context =
......@@ -191,12 +193,12 @@ context =
import netaddr netaddr
mode = 0775
url = {{ ru_lopcomm_reset_info_template }}
output = ${directory:bin}/{{ru_ref}}-reset-info.py
output = ${directory:bin}/{{B('%s-reset-info.py' % ru_ref)}}
[{{ B('%s-reset-template' % ru_ref) }}]
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
_logbase = ${directory:var}/log/{{ru_ref}}-reset
_logbase = ${directory:var}/log/{{B('%s-reset' % ru_ref)}}
log-output = ${:_logbase}.log
json-log-output = ${:_logbase}.json.log
context =
......@@ -207,19 +209,19 @@ context =
import netaddr netaddr
mode = 0775
url = {{ ru_lopcomm_reset_template }}
output = ${directory:etc}/{{ru_ref}}-reset.py
output = ${directory:etc}/{{B('%s-reset.py' % ru_ref)}}
{{ part('%s-reset-cron' % ru_ref) }}
recipe = slapos.cookbook:cron.d
cron-entries = ${cron:cron-entries}
name = {{ru_ref}}-reset
name = {{B('%s-reset' % ru_ref)}}
frequency = {{ ru.reset_schedule }}
command = {{ buildout_directory}}/bin/pythonwitheggs ${ {{-B('%s-reset-template' % ru_ref)}}:output}
{{ part('%s-reset-info-service' % ru_ref) }}
recipe = slapos.cookbook:wrapper
command-line = ${ {{- ru_ref}}-reset-info-template:output}
wrapper-path = ${directory:service}/{{ru_ref}}-reset-info
command-line = ${ {{-B('%s-reset-info-template' % ru_ref)}}:output}
wrapper-path = ${directory:service}/{{B('%s-reset-info' % ru_ref)}}
mode = 0775
hash-files =
${:command-line}
......
#!/usr/bin/env python
# Copyright (C) 2023 Nexedi SA and Contributors.
# Copyright (C) 2023-2024 Nexedi SA and Contributors.
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
......
# Copyright (C) 2023 Nexedi SA and Contributors.
# Copyright (C) 2023-2024 Nexedi SA and Contributors.
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
......@@ -19,7 +19,6 @@
- encode/decode convert string to/from form, that is suitable to be used in
names of buildout sections.
- XXX quote
"""
......@@ -60,6 +59,13 @@
#
# # referring to <ru_ref>-stats
# ${ {{-B('%s-stats' % ru_ref)}}:output}
#
#
# See also `dumps` in buildout for a way to serialize option values with
# protection against code injection:
#
# https://lab.nexedi.com/nexedi/slapos.buildout/commit/4e13dcb9
# https://lab.nexedi.com/nexedi/slapos.recipe.template/commit/84dc7957
def encode(s: str) -> str:
s = s.encode('utf-8')
outv = []
......@@ -128,18 +134,6 @@ def _decode(s):
return out
# quote converts string s into quoted form with all buildout control characters escaped... XXX
# XXX -> pyquote?
def quote(s: str) -> str:
assert isinstance(s, str), type(s)
r = str.__repr__(s) # both str and markupsafe.Markup go as regular str
for c in '$[]\n':
r = r.replace(c, r'\x%02x' % ord(c))
if r[1:-1] == s:
return s # original string
return '!py!' + r
# ----------------------------------------
import re
......@@ -198,8 +192,3 @@ def test_encode():
def _(cause):
assert isinstance(cause, UnicodeDecodeError)
checkbad(x, _)
def test_quote():
# XXX
pass
......@@ -79,6 +79,10 @@
}
%}
{#- XXX explain #}
{%- set B = xbuildout.encode %}
{#- J is used around macro calls to retrieve returned objects.
It is needed to workaround jinja2 limitation that macro can return only
......@@ -419,7 +423,7 @@
{%- set rx_gainv = [] %} {#- rx_gain by rx channel #}
{%- for (ru_ref, iru) in iru_dict.items() | sort(attribute="1._._rf_port") %}
{%- set ru = iru['_'] %}
// {{ ru_ref }} {{ ru.n_antenna_dl }}T{{ ru.n_antenna_ul }}R ({{ ru.ru_type }})
// {{ B(ru_ref) }} {{ ru.n_antenna_dl }}T{{ ru.n_antenna_ul }}R ({{ ru.ru_type }})
{%- if ru.ru_type == 'sdr' %}
{%- do ru_sdr_dict.update({len(dev_argv): ru}) %}
{%- for n in ru.sdr_dev_list %}
......
......@@ -6,7 +6,19 @@
import zc.buildout.buildout # XXX workaround for https://lab.nexedi.com/nexedi/slapos.recipe.template/merge_requests/9
from slapos.recipe.template import jinja2_template
import json, copy, sys, os, pprint, glob
import json, copy, sys, os, pprint, glob, types
# ~ import xbuildout (see instance.cfg:activate-eggs)
def readfile(path):
with open(path) as f:
return f.read()
xbuildout = types.ModuleType('xbuildout')
exec(readfile('ru/xbuildout.py'), xbuildout.__dict__)
assert 'xbuildout' not in sys.modules
sys.modules['xbuildout'] = xbuildout
B = xbuildout.encode
# j2render renders config/<src> into config/out/<out> with provided json parameters.
......@@ -19,6 +31,7 @@ def j2render(src, out, jcfg):
textctx = ''
for k, v in ctx.items():
textctx += 'json %s %s\n' % (k, json.dumps(v))
textctx += 'import xbuildout xbuildout\n'
textctx += 'import json_module json\n'
textctx += 'import nrarfcn_module nrarfcn\n'
textctx += 'import xearfcn_module xlte.earfcn\n'
......@@ -466,11 +479,11 @@ def do_enb():
'ru': ru,
})
j2render('drb_%s.jinja2.cfg' % cell['cell_type'],
'%s-drb.cfg' % cell_ref,
B('%s-drb.cfg' % cell_ref),
jctx)
j2render('sib23.jinja2.asn',
'%s-sib23.asn' % cell_ref,
B('%s-sib23.asn' % cell_ref),
jctx)
......
# Copyright (C) 2023 Nexedi SA and Contributors.
# Copyright (C) 2023-2024 Nexedi SA and Contributors.
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
......
......@@ -18,5 +18,5 @@ export SLAPOS_TEST_LOG_DIRECTORY=`pwd`/snapshot
#time ../k/kpython_for_test -m unittest discover -vf -k SimCard
#time ../k/kpython_for_test -m unittest discover -vf
#time ../k/kpython_for_test -m unittest discover -vf -k TestENB_CPRI
time ../k/kpython_for_test -m unittest discover -vf -k TestENB_SDR
#time ../k/kpython_for_test -m unittest discover -vf -k TestENB_Lopcomm
#time ../k/kpython_for_test -m unittest discover -vf -k TestENB_SDR
time ../k/kpython_for_test -m unittest discover -vf -k TestENB_Lopcomm
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