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
import
json
,
copy
,
sys
,
pprint
# XXX test both enb.cfg + ue.cfg simultaneously
config
=
"enb"
# j2render renders config/<config>.jinja2.cfg into config/<config>.cfg with provided json parameters.
json_params_empty
=
"""{
def
j2render
(
config
,
jcfg
):
"rf_mode": 'fdd',
ctx
=
json
.
loads
(
jcfg
)
"slap_configuration": {
textctx
=
''
},
for
k
,
v
in
ctx
.
items
():
"directory": {
textctx
+=
'json %s %s
\
n
'
%
(
k
,
json
.
dumps
(
v
))
},
textctx
+=
'import json_module json
\
n
'
"slapparameter_dict": {
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.
with
open
(
'config/{}.cfg'
.
format
(
config
),
'w+'
)
as
f
:
shared_instance_list
=
[]
f
.
write
(
r
.
_render
().
decode
())
def
iSHARED
(
title
,
slave_reference
,
cfg
):
# 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
=
{
ishared
=
{
'slave_title'
:
title
,
'slave_title'
:
title
,
'slave_reference'
:
slave_reference
,
'slave_reference'
:
slave_reference
,
'slap_software_type'
:
"enb"
,
'slap_software_type'
:
"enb"
,
'_'
:
json
.
dumps
(
cfg
)
'_'
:
json
.
dumps
(
cfg
)
}
}
shared_instance_list
.
append
(
ishared
)
self
.
shared_instance_list
.
append
(
ishared
)
return
ishared
return
ishared
# ---- eNB ----
# 3 cells sharing SDR-based RU consisting of 2 SDR boards (4tx + 4rx ports max)
# 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
# RU definition is embedded into cell for simplicity of management
def
iRU1_SDR_tLTE2_tNR
():
def
iRU1_SDR_tLTE2_tNR
(
ienb
):
RU1
=
{
RU1
=
{
'ru_type'
:
'sdr'
,
'ru_type'
:
'sdr'
,
'ru_link_type'
:
'sdr'
,
'ru_link_type'
:
'sdr'
,
...
@@ -40,7 +74,7 @@ def iRU1_SDR_tLTE2_tNR():
...
@@ -40,7 +74,7 @@ def iRU1_SDR_tLTE2_tNR():
'rx_gain'
:
52
,
'rx_gain'
:
52
,
}
}
i
SHARED
(
'Cell 1a'
,
'_CELL1_a'
,
{
i
enb
.
ishared
(
'Cell 1a'
,
'_CELL1_a'
,
{
'cell_type'
:
'lte'
,
'cell_type'
:
'lte'
,
'rf_mode'
:
'tdd'
,
'rf_mode'
:
'tdd'
,
'bandwidth'
:
'5 MHz'
,
'bandwidth'
:
'5 MHz'
,
...
@@ -50,7 +84,7 @@ def iRU1_SDR_tLTE2_tNR():
...
@@ -50,7 +84,7 @@ def iRU1_SDR_tLTE2_tNR():
'ru'
:
RU1
,
# RU definition embedded into CELL
'ru'
:
RU1
,
# RU definition embedded into CELL
})
})
i
SHARED
(
'Cell 1b'
,
'_CELL1_b'
,
{
i
enb
.
ishared
(
'Cell 1b'
,
'_CELL1_b'
,
{
'cell_type'
:
'lte'
,
'cell_type'
:
'lte'
,
'rf_mode'
:
'tdd'
,
'rf_mode'
:
'tdd'
,
'bandwidth'
:
'5 MHz'
,
'bandwidth'
:
'5 MHz'
,
...
@@ -63,7 +97,7 @@ def iRU1_SDR_tLTE2_tNR():
...
@@ -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'
,
'cell_type'
:
'nr'
,
'rf_mode'
:
'tdd'
,
'rf_mode'
:
'tdd'
,
'bandwidth'
:
5
,
'bandwidth'
:
5
,
...
@@ -80,7 +114,7 @@ def iRU1_SDR_tLTE2_tNR():
...
@@ -80,7 +114,7 @@ def iRU1_SDR_tLTE2_tNR():
# LTE + NR cells that use CPRI-based Lopcomm radio units
# 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
# 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
=
{
RU2_a
=
{
'ru_type'
:
'lopcomm'
,
'ru_type'
:
'lopcomm'
,
'ru_link_type'
:
'cpri'
,
'ru_link_type'
:
'cpri'
,
...
@@ -106,10 +140,10 @@ def iRU2_LOPCOMM_fLTE_fNR():
...
@@ -106,10 +140,10 @@ def iRU2_LOPCOMM_fLTE_fNR():
RU2_b
[
'tx_gain'
]
+=
10
RU2_b
[
'tx_gain'
]
+=
10
RU2_b
[
'rx_gain'
]
+=
10
RU2_b
[
'rx_gain'
]
+=
10
i
SHARED
(
'Radio Unit 2a'
,
'_RU2_a'
,
RU2_a
)
i
enb
.
ishared
(
'Radio Unit 2a'
,
'_RU2_a'
,
RU2_a
)
i
SHARED
(
'Radio Unit 2b'
,
'_RU2_b'
,
RU2_b
)
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'
,
'cell_type'
:
'lte'
,
'rf_mode'
:
'fdd'
,
'rf_mode'
:
'fdd'
,
'bandwidth'
:
'5 MHz'
,
'bandwidth'
:
'5 MHz'
,
...
@@ -122,7 +156,7 @@ def iRU2_LOPCOMM_fLTE_fNR():
...
@@ -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'
,
'cell_type'
:
'nr'
,
'rf_mode'
:
'fdd'
,
'rf_mode'
:
'fdd'
,
'bandwidth'
:
5
,
'bandwidth'
:
5
,
...
@@ -137,11 +171,10 @@ def iRU2_LOPCOMM_fLTE_fNR():
...
@@ -137,11 +171,10 @@ def iRU2_LOPCOMM_fLTE_fNR():
})
})
# ---- for tests ----
# ---- for tests ----
# 2 FDD cells working via shared SDR board
# 2 FDD cells working via shared SDR board
def
iRU3_SDR1_fLTE2
():
def
iRU3_SDR1_fLTE2
(
ienb
):
RU
=
{
RU
=
{
'ru_type'
:
'sdr'
,
'ru_type'
:
'sdr'
,
'ru_link_type'
:
'sdr'
,
'ru_link_type'
:
'sdr'
,
...
@@ -152,7 +185,7 @@ def iRU3_SDR1_fLTE2():
...
@@ -152,7 +185,7 @@ def iRU3_SDR1_fLTE2():
'rx_gain'
:
61
,
'rx_gain'
:
61
,
}
}
i
SHARED
(
'Cell 3a'
,
'_CELL3_a'
,
{
i
enb
.
ishared
(
'Cell 3a'
,
'_CELL3_a'
,
{
'cell_type'
:
'lte'
,
'cell_type'
:
'lte'
,
'rf_mode'
:
'fdd'
,
'rf_mode'
:
'fdd'
,
'bandwidth'
:
'5 MHz'
,
'bandwidth'
:
'5 MHz'
,
...
@@ -162,7 +195,7 @@ def iRU3_SDR1_fLTE2():
...
@@ -162,7 +195,7 @@ def iRU3_SDR1_fLTE2():
'ru'
:
RU
,
'ru'
:
RU
,
})
})
i
SHARED
(
'Cell 3b'
,
'_CELL3_b'
,
{
i
enb
.
ishared
(
'Cell 3b'
,
'_CELL3_b'
,
{
'cell_type'
:
'lte'
,
'cell_type'
:
'lte'
,
'rf_mode'
:
'fdd'
,
'rf_mode'
:
'fdd'
,
'bandwidth'
:
'5 MHz'
,
'bandwidth'
:
'5 MHz'
,
...
@@ -176,14 +209,14 @@ def iRU3_SDR1_fLTE2():
...
@@ -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
()
jshared_instance_list
=
json
.
dumps
(
ienb
.
shared_instance_list
)
#iRU2_LOPCOMM_fLTE_fNR()
json_params
=
"""{
#iRU3_SDR1_fLTE2()
jshared_instance_list
=
json
.
dumps
(
shared_instance_list
)
json_params
=
"""{
"sib23_file": "sib2_3.asn",
"sib23_file": "sib2_3.asn",
"slap_configuration": {
"slap_configuration": {
"tap-name": "slaptap9",
"tap-name": "slaptap9",
...
@@ -203,43 +236,22 @@ json_params = """{
...
@@ -203,43 +236,22 @@ json_params = """{
},
},
"slapparameter_dict": {
"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
# ---- UE ----
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'
,
})
# avoid dependency on zc.buildout.download and the need to use non-stub buildout section
def
do_ue
():
def
_read
(
url
,
*
args
):
pass
# XXX temp
with
open
(
url
,
*
args
)
as
f
:
return
f
.
read
()
r
.
_read
=
_read
# 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
:
def
main
():
f
.
write
(
r
.
_render
().
decode
())
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