Commit 76092aa2 authored by Kirill Smelkov's avatar Kirill Smelkov Committed by Jérome Perrin

software/ors-amarisoft: Fix enb.cfg build in standalone mode (cell_list)

In b0c37a4a (software/ors-amarisoft: Start to generalize existing
lopcomm/multicell into multiRU slowly) I deduplicated cell_list initialization
and moved it into single place, but overlooked that enb.cfg build became broken
in standalone mode:

    .../software/ors-amarisoft$ ./pythonwitheggs slapos-render-config.py
    Traceback (most recent call last):
      File "/srv/slapgrid/slappart35/srv/project/slapos/software/ors-amarisoft/./pythonwitheggs", line 47, in <module>
        exec(compile(__file__f.read(), __file__, "exec"))
      File "slapos-render-config.py", line 88, in <module>
        do('enb', {"tdd_ul_dl_config": "[Configuration 6] 5ms 5UL 3DL (maximum uplink)"})
      File "slapos-render-config.py", line 86, in do
        j2render(cfg, json_params % locals())
      File "slapos-render-config.py", line 34, in j2render
        f.write(r._render().decode())
      File ".../eggs/slapos.recipe.template-5.1-py3.9.egg/slapos/recipe/template/jinja2_template.py", line 215, in _render
        return template_object.render(**self.context).encode(self.encoding)
      File ".../eggs/Jinja2-2.11.3-py3.9.egg/jinja2/environment.py", line 1090, in render
        self.environment.handle_exception()
      File ".../eggs/Jinja2-2.11.3-py3.9.egg/jinja2/environment.py", line 832, in handle_exception
        reraise(*rewrite_traceback_stack(source=source))
      File ".../eggs/Jinja2-2.11.3-py3.9.egg/jinja2/_compat.py", line 28, in reraise
        raise value.with_traceback(tb)
      File "config/enb.jinja2.cfg", line 1, in top-level template code
        {%- set cell_count = cell_list|length %}
    jinja2.exceptions.UndefinedError: 'cell_list' is undefined

-> Fix it by teaching enb.jinja2.cfg to also load cell list in standalone by itself.

Not touching gnb.jinja2.cfg as currently gnb does not support multicell at all,
and in the future it will be sole enb.cfg to handle both LTE and NR
simultaneously.

/cc @jhuge, @lu.xu, @xavier_thompson, @Daetalus
parent 29d34086
......@@ -16,7 +16,7 @@
[template]
filename = instance.cfg
md5sum = 827d549fae50b81c753a22c94a366095
md5sum = b4f7cf9de06af21a0c4c00d8be5edce7
[slaplte.jinja2]
_update_hash_filename_ = slaplte.jinja2
......@@ -84,7 +84,7 @@ md5sum = 52da9fe3a569199e35ad89ae1a44c30e
[template-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg
md5sum = fe49c51b683e1934c1b542591c97550b
md5sum = b52a8584712f9cee338c71a6dedc7dad
[template-gnb]
_update_hash_filename_ = instance-gnb.jinja2.cfg
......@@ -112,7 +112,7 @@ md5sum = dcaac06553a3222b14c0013a13f4a149
[enb.jinja2.cfg]
filename = config/enb.jinja2.cfg
md5sum = 8e49dfc9318da43bd817b8891cba24b7
md5sum = a961cc1469bd2534645470f914f12905
[drb_lte.jinja2.cfg]
filename = config/drb_lte.jinja2.cfg
......
{%- import 'slaplte.jinja2' as slaplte with context %}
{#- for standalone testing via slapos-render-config.py
NOTE: keep in sync with ru/libinstance.jinja2.cfg #}
{%- if _standalone is defined %}
{%- set cell_list = {} %}
{%- do slaplte.load_cell(cell_list) %}
{%- endif %}
{%- set cell_count = cell_list|length %}
{%- if slapparameter_dict.get('tdd_ul_dl_config', '[Configuration 2] 5ms 2UL 6DL (default)') == '[Configuration 2] 5ms 2UL 6DL (default)' %}
......
......@@ -368,6 +368,9 @@ extra-context =
json cell_list {{ rulib.cell_list | tojson }}
key sib23_file sib-config:output
key drb_file drb-config:output
import-list =
rawfile slaplte.jinja2 {{ slaplte_template }}
[publish-connection-information]
<= monitor-publish
......
......@@ -276,6 +276,7 @@ extra-context =
key enb amarisoft:enb
key sdr amarisoft:sdr
raw enb_template ${enb.jinja2.cfg:target}
raw slaplte_template ${slaplte.jinja2:target}
raw drb_lte_template ${drb_lte.jinja2.cfg:target}
raw sib23_template ${sib23.jinja2.asn:target}
raw amarisoft_stats_template ${amarisoft-stats.jinja2.py:target}
......
......@@ -12,6 +12,8 @@ import json
# j2render renders config/<cfg>.jinja2.cfg into config/<cfg>.cfg with provided json parameters.
def j2render(cfg, jcfg):
ctx = json.loads(jcfg)
assert '_standalone' not in ctx
ctx['_standalone'] = True
textctx = ''
for k, v in ctx.items():
textctx += 'json %s %s\n' % (k, json.dumps(v))
......@@ -21,6 +23,8 @@ def j2render(cfg, jcfg):
'url': 'config/{}.jinja2.cfg'.format(cfg),
'output': 'config/{}.cfg'.format(cfg),
'context': textctx,
'import-list': '''
rawfile slaplte.jinja2 slaplte.jinja2''',
})
#print(r.context)
......
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