Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos
Commits
cc1a4d62
Commit
cc1a4d62
authored
Sep 28, 2023
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f92ceda0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
93 deletions
+105
-93
software/ors-amarisoft/slapos-render-config.py
software/ors-amarisoft/slapos-render-config.py
+105
-93
No files found.
software/ors-amarisoft/slapos-render-config.py
View file @
cc1a4d62
# Program slapos-render-config is handy during config/ templates development.
#
# It mimics the way config files are generated during the build but runs much
# faster compared to full `slapos node software` + `slapos node instance` runs.
import
zc.buildout.buildout
# XXX workaround for bug in vvv
from
slapos.recipe.template
import
jinja2_template
import
json
,
copy
,
sys
,
pprint
# XXX test both enb.cfg + ue.cfg simultaneously
config
=
"enb"
json_params_empty
=
"""{
"rf_mode": 'fdd',
"slap_configuration": {
},
"directory": {
},
"slapparameter_dict": {
}
}"""
# j2render renders config/<config>.jinja2.cfg into config/<config>.cfg with provided json parameters.
def
j2render
(
config
,
jcfg
):
ctx
=
json
.
loads
(
jcfg
)
textctx
=
''
for
k
,
v
in
ctx
.
items
():
textctx
+=
'json %s %s
\
n
'
%
(
k
,
json
.
dumps
(
v
))
textctx
+=
'import json_module json
\
n
'
buildout
=
None
# stub
r
=
jinja2_template
.
Recipe
(
buildout
,
"recipe"
,
{
'extensions'
:
'jinja2.ext.do'
,
'url'
:
'config/{}.jinja2.cfg'
.
format
(
config
),
'output'
:
'config/{}.cfg'
.
format
(
config
),
'context'
:
textctx
,
'import-list'
:
'rawfile lte.jinja2 config/lte.jinja2'
,
})
# avoid dependency on zc.buildout.download and the need to use non-stub buildout section
def
_read
(
url
,
*
args
):
with
open
(
url
,
*
args
)
as
f
:
return
f
.
read
()
r
.
_read
=
_read
# for template debugging
r
.
context
.
update
({
'print'
:
lambda
*
argv
:
print
(
*
argv
,
file
=
sys
.
stderr
),
'pprint'
:
lambda
obj
:
pprint
.
pprint
(
obj
,
sys
.
stderr
),
})
# iSHARED appends new shared instance with specified configuration to shared_instance_list.
shared_instance_list
=
[]
def
iSHARED
(
title
,
slave_reference
,
cfg
):
with
open
(
'config/{}.cfg'
.
format
(
config
),
'w+'
)
as
f
:
f
.
write
(
r
.
_render
().
decode
())
# Instance ...
class
Instance
:
def
__init__
(
self
):
self
.
shared_instance_list
=
[]
# ishared appends new shared instance with specified configuration to .shared_instance_list .
def
ishared
(
self
,
title
,
slave_reference
,
cfg
):
ishared
=
{
'slave_title'
:
title
,
'slave_reference'
:
slave_reference
,
'slap_software_type'
:
"enb"
,
'_'
:
json
.
dumps
(
cfg
)
}
shared_instance_list
.
append
(
ishared
)
self
.
shared_instance_list
.
append
(
ishared
)
return
ishared
# ---- eNB ----
# 3 cells sharing SDR-based RU consisting of 2 SDR boards (4tx + 4rx ports max)
# RU definition is embedded into cell for simplicity of management
def
iRU1_SDR_tLTE2_tNR
():
def
iRU1_SDR_tLTE2_tNR
(
ienb
):
RU1
=
{
'ru_type'
:
'sdr'
,
'ru_link_type'
:
'sdr'
,
...
...
@@ -40,7 +74,7 @@ def iRU1_SDR_tLTE2_tNR():
'rx_gain'
:
52
,
}
i
SHARED
(
'Cell 1a'
,
'_CELL1_a'
,
{
i
enb
.
ishared
(
'Cell 1a'
,
'_CELL1_a'
,
{
'cell_type'
:
'lte'
,
'rf_mode'
:
'tdd'
,
'bandwidth'
:
'5 MHz'
,
...
...
@@ -50,7 +84,7 @@ def iRU1_SDR_tLTE2_tNR():
'ru'
:
RU1
,
# RU definition embedded into CELL
})
i
SHARED
(
'Cell 1b'
,
'_CELL1_b'
,
{
i
enb
.
ishared
(
'Cell 1b'
,
'_CELL1_b'
,
{
'cell_type'
:
'lte'
,
'rf_mode'
:
'tdd'
,
'bandwidth'
:
'5 MHz'
,
...
...
@@ -63,7 +97,7 @@ def iRU1_SDR_tLTE2_tNR():
}
})
i
SHARED
(
'Cell 1c'
,
'_CELL1_c'
,
{
i
enb
.
ishared
(
'Cell 1c'
,
'_CELL1_c'
,
{
'cell_type'
:
'nr'
,
'rf_mode'
:
'tdd'
,
'bandwidth'
:
5
,
...
...
@@ -80,7 +114,7 @@ def iRU1_SDR_tLTE2_tNR():
# LTE + NR cells that use CPRI-based Lopcomm radio units
# here we instantiate RUs separately since embedding RU into a cell is demonstrated by CELL1_a above
def
iRU2_LOPCOMM_fLTE_fNR
():
def
iRU2_LOPCOMM_fLTE_fNR
(
ienb
):
RU2_a
=
{
'ru_type'
:
'lopcomm'
,
'ru_link_type'
:
'cpri'
,
...
...
@@ -106,10 +140,10 @@ def iRU2_LOPCOMM_fLTE_fNR():
RU2_b
[
'tx_gain'
]
+=
10
RU2_b
[
'rx_gain'
]
+=
10
i
SHARED
(
'Radio Unit 2a'
,
'_RU2_a'
,
RU2_a
)
i
SHARED
(
'Radio Unit 2b'
,
'_RU2_b'
,
RU2_b
)
i
enb
.
ishared
(
'Radio Unit 2a'
,
'_RU2_a'
,
RU2_a
)
i
enb
.
ishared
(
'Radio Unit 2b'
,
'_RU2_b'
,
RU2_b
)
i
SHARED
(
'Cell 2a'
,
'_CELL2_a'
,
{
i
enb
.
ishared
(
'Cell 2a'
,
'_CELL2_a'
,
{
'cell_type'
:
'lte'
,
'rf_mode'
:
'fdd'
,
'bandwidth'
:
'5 MHz'
,
...
...
@@ -122,7 +156,7 @@ def iRU2_LOPCOMM_fLTE_fNR():
}
})
i
SHARED
(
'Cell 2b'
,
'_CELL2_b'
,
{
i
enb
.
ishared
(
'Cell 2b'
,
'_CELL2_b'
,
{
'cell_type'
:
'nr'
,
'rf_mode'
:
'fdd'
,
'bandwidth'
:
5
,
...
...
@@ -137,11 +171,10 @@ def iRU2_LOPCOMM_fLTE_fNR():
})
# ---- for tests ----
# 2 FDD cells working via shared SDR board
def
iRU3_SDR1_fLTE2
():
def
iRU3_SDR1_fLTE2
(
ienb
):
RU
=
{
'ru_type'
:
'sdr'
,
'ru_link_type'
:
'sdr'
,
...
...
@@ -152,7 +185,7 @@ def iRU3_SDR1_fLTE2():
'rx_gain'
:
61
,
}
i
SHARED
(
'Cell 3a'
,
'_CELL3_a'
,
{
i
enb
.
ishared
(
'Cell 3a'
,
'_CELL3_a'
,
{
'cell_type'
:
'lte'
,
'rf_mode'
:
'fdd'
,
'bandwidth'
:
'5 MHz'
,
...
...
@@ -162,7 +195,7 @@ def iRU3_SDR1_fLTE2():
'ru'
:
RU
,
})
i
SHARED
(
'Cell 3b'
,
'_CELL3_b'
,
{
i
enb
.
ishared
(
'Cell 3b'
,
'_CELL3_b'
,
{
'cell_type'
:
'lte'
,
'rf_mode'
:
'fdd'
,
'bandwidth'
:
'5 MHz'
,
...
...
@@ -176,14 +209,14 @@ def iRU3_SDR1_fLTE2():
})
def
do_enb
():
ienb
=
Instance
()
iRU1_SDR_tLTE2_tNR
(
ienb
)
#iRU2_LOPCOMM_fLTE_fNR(ienb)
#iRU3_SDR1_fLTE2(ienb)
iRU1_SDR_tLTE2_tNR
()
#iRU2_LOPCOMM_fLTE_fNR()
#iRU3_SDR1_fLTE2()
jshared_instance_list
=
json
.
dumps
(
shared_instance_list
)
json_params
=
"""{
jshared_instance_list
=
json
.
dumps
(
ienb
.
shared_instance_list
)
json_params
=
"""{
"sib23_file": "sib2_3.asn",
"slap_configuration": {
"tap-name": "slaptap9",
...
...
@@ -203,43 +236,22 @@ json_params = """{
},
"slapparameter_dict": {
}
}"""
%
glob
als
()
}"""
%
loc
als
()
j2render
(
'enb'
,
json_params
)
import
zc.buildout.buildout
# XXX workaround for bug in vvv
from
slapos.recipe.template
import
jinja2_template
# j2render renders config/<config>.jinja2.cfg into config/<config>.cfg
def
j2render
(
config
):
ctx
=
json
.
loads
(
json_params
)
textctx
=
''
for
k
,
v
in
ctx
.
items
():
textctx
+=
'json %s %s
\
n
'
%
(
k
,
json
.
dumps
(
v
))
textctx
+=
'import json_module json
\
n
'
buildout
=
None
# stub
r
=
jinja2_template
.
Recipe
(
buildout
,
"recipe"
,
{
'extensions'
:
'jinja2.ext.do'
,
'url'
:
'config/{}.jinja2.cfg'
.
format
(
config
),
'output'
:
'config/{}.cfg'
.
format
(
config
),
'context'
:
textctx
,
'import-list'
:
'rawfile lte.jinja2 config/lte.jinja2'
,
})
# ---- UE ----
# avoid dependency on zc.buildout.download and the need to use non-stub buildout section
def
_read
(
url
,
*
args
):
with
open
(
url
,
*
args
)
as
f
:
return
f
.
read
()
r
.
_read
=
_read
def
do_ue
():
pass
# XXX temp
# debugging
r
.
context
.
update
({
'print'
:
lambda
*
argv
:
print
(
*
argv
,
file
=
sys
.
stderr
),
'pprint'
:
lambda
obj
:
pprint
.
pprint
(
obj
,
sys
.
stderr
),
})
with
open
(
'config/{}.cfg'
.
format
(
config
),
'w+'
)
as
f
:
f
.
write
(
r
.
_render
().
decode
())
def
main
():
do_enb
()
do_ue
()
j2render
(
config
)
# XXX temp
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment