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