instance.cfg 12.1 KB
Newer Older
1 2 3 4 5 6 7 8
[buildout]
parts =
  switch-softwaretype

eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true

9 10 11 12 13 14
[directory]
recipe = slapos.cookbook:mkdirectory
software = ${buildout:directory}
home = $${buildout:directory}
etc = $${:home}/etc

15
[slap-configuration]
16
recipe = slapos.cookbook:slapconfiguration.serialised
17 18 19 20 21 22 23 24
computer = $${slap-connection:computer-id}
partition = $${slap-connection:partition-id}
url = $${slap-connection:server-url}
key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}

[jinja2-template-base]
recipe = slapos.recipe.template:jinja2
25
output = $${buildout:directory}/$${:filename}
26 27 28 29 30 31 32 33
extra-context =
context =
    import json_module json
    key eggs_directory buildout:eggs-directory
    key develop_eggs_directory buildout:develop-eggs-directory
    raw buildout_directory ${buildout:directory}
    section slap_connection slap-connection
    key slapparameter_dict slap-configuration:configuration
34
    key lan_ipv4 lan-ip:ipv4
35
    $${:extra-context}
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
36
import-list =
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
37
    rawfile amari_slap.jinja2 ${amari_slap.jinja2:target}
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
38
    rawfile ru_libinstance.jinja2.cfg ${ru_libinstance.jinja2.cfg:target}
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
39 40 41
    rawfile ru_sdr_libinstance.jinja2.cfg ${ru_sdr_libinstance.jinja2.cfg:target}
    rawfile ru_lopcomm_libinstance.jinja2.cfg ${ru_lopcomm_libinstance.jinja2.cfg:target}
    rawfile ru_sunwave_libinstance.jinja2.cfg ${ru_sunwave_libinstance.jinja2.cfg:target}
42

43 44 45
[amarisoft]
recipe = slapos.recipe.build
init =
46
  import os, re
47 48 49 50
  try:
    lte_version = sorted(filter(lambda x: re.match(r"v[0-9]{4}-[0-9]{2}-[0-9]{2}", x), os.listdir('/opt/amarisoft')))[-1][1:]
  except FileNotFoundError:
    lte_version = 'LTEVERSION'
51 52 53
  path = "/opt/amarisoft/v" + lte_version
  options['lte-version'] = lte_version
  options['path'] = path
54
  options['sdr'] = path + "/trx_sdr"
55 56 57
  options['enb'] = path + "/enb"
  options['mme'] = path + "/mme"
  options['ims'] = path + "/ims"
58
  options['ue'] = path + "/ue"
59

Kirill Smelkov's avatar
.  
Kirill Smelkov committed
60
# XXX -> ru/ors ?
61 62
[ors-version]
recipe = slapos.recipe.build
63
configuration = $${slap-configuration:configuration}
64 65
init =
  import subprocess
66 67 68 69 70
  range_map = {
    "B38": "2570MHz - 2620MHz",
    "B39": "1880MHz - 1920MHz",
    "B42": "3400MHz - 3600MHz",
    "B43": "3600MHz - 3800MHz",
71
    "B28": "758MHz - 803MHz",
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
72
    "N77": "3300MHz - 4200MHz",
73
    "N79": "4400MHz - 5000MHz",
74
    "UNKNOWN": "Information not available for this band",
75
  }
76 77 78 79 80
  default_tx_gain_map = {
    "B38": (59, 65),
    "B39": (59, 64),
    "B42": (63, 62),
    "B43": (63, 62),
81
    "B28": (60, 62),
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
82
    "N77": (60, 62),
83
    "N79": (60, 62),
84
    "UNKNOWN": (60, 62),
85 86 87 88 89 90
  }
  default_rx_gain_map = {
    "B38": (43, 43),
    "B39": (43, 43),
    "B42": (43, 43),
    "B43": (43, 43),
91
    "B28": (43, 43),
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
92
    "N77": (43, 43),
93
    "N79": (43, 43),
94
    "UNKNOWN": (43, 43),
95 96 97 98 99 100
  }
  default_earfcn_map = {
    "B38": 38050,
    "B39": 38350,
    "B42": 42590,
    "B43": 44590,
101
    "B28": 9550,
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
102
    "N77": 0,
103
    "N79": 0,
104
    "UNKNOWN": 0,
105 106 107 108 109 110
  }
  default_nr_arfcn_map = {
    "B38": 519000,
    "B39": 378000,
    "B42": 632628,
    "B43": 646666,
111
    "B28": 0,
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
112
    "N77": 660000,
113
    "N79": 720000,
114
    "UNKNOWN": 0,
115 116 117 118 119 120
  }
  default_nr_band_map = {
    "B38": 41,
    "B39": 39,
    "B42": 78,
    "B43": 78,
121
    "B28": 0,
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
122
    "N77": 77,
123
    "N79": 79,
124
    "UNKNOWN": 0,
125
  }
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
  power_map = {
    "B38": (
      lambda x: (-0.008712931375092506) * x**2 + (2.1973585140044642) * x + (-94.29420762479742),
      lambda x: (-0.004472751640641793) * x**2 + (1.6308290630103919) * x + (-81.84549245154561),
    ),
    "B39": (
      lambda x: (-0.008712931375092506) * x**2 + (2.1973585140044642) * x + (-94.29420762479742),
      lambda x: (-0.0022523817802900985) * x**2 + (1.2674016231310092) * x + (-66.57165215468584),
    ),
    "B42": (
      lambda x: (-0.014198126839751619) * x**2 + (2.980758813262773) * x + (-125.25800492285738),
      lambda x: (0.003977721774394756) * x**2 + (0.527208191717173) * x + (-42.761142655285376),
    ),
    "B43": (
      lambda x: (-0.014198126839751619) * x**2 + (2.980758813262773) * x + (-125.25800492285738),
      lambda x: (-0.0036530114002551943) * x**2 + (1.510856844601873) * x + (-74.58790185136355),
    ),
143 144 145 146
    "B28": (
      lambda x: "UNKNOWN",
      lambda x: "UNKNOWN",
    ),
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
147 148 149 150
    "N77": (
      lambda x: "UNKNOWN",
      lambda x: "UNKNOWN",
    ),
151 152 153 154
    "N79": (
      lambda x: "UNKNOWN",
      lambda x: "UNKNOWN",
    ),
155
    "UNKNOWN": (
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
      lambda x: "UNKNOWN",
      lambda x: "UNKNOWN",
    ),
  }
  def get_sdr_info(cmd):
    if options['configuration'].get('testing', False):
      return {'t': 'TDD', 'b': 'B39', 'v': '4.2', 's': 'B53'}[cmd].encode()
    return subprocess.check_output(
      ["sudo", "-n", "/opt/amarisoft/get-sdr-info", "-" + cmd]
    )
  options['version'] = float(get_sdr_info('v').decode())
  options['band'] = get_sdr_info('b').decode()
  options['tdd'] = get_sdr_info('t').decode()
  options['one-watt'] = bool(options['version'] >= 4)
  options['ors-version'] = "{} {} {}".format(
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
171
    options['tdd'],
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
    options['band'],
    "2x1W" if options['one-watt'] else "2x0.5W",
  )
  default_tx_gain  = default_tx_gain_map [options['band']][int(options['one-watt'])]
  default_rx_gain  = default_rx_gain_map [options['band']][int(options['one-watt'])]
  default_earfcn   = default_earfcn_map  [options['band']]
  default_nr_arfcn = default_nr_arfcn_map[options['band']]
  default_nr_band  = default_nr_band_map [options['band']]
  options['range']            = range_map           [options['band']]
  options['current-tx-gain']  = options['configuration'].get('tx_gain'    , default_tx_gain )
  options['current-rx-gain']  = options['configuration'].get('rx_gain'    , default_rx_gain )
  options['current-earfcn']   = options['configuration'].get('dl_earfcn'  , default_earfcn  )
  options['current-nr-arfcn'] = options['configuration'].get('dl_nr_arfcn', default_nr_arfcn)
  options['current-nr-band']  = options['configuration'].get('nr_band'    , default_nr_band )
  power_estimate_dbm = power_map[options['band']][int(options['one-watt'])](float(options['current-tx-gain']))
  if power_estimate_dbm == "UNKNOWN":
    power_estimate = "Information not available for this band"
  else:
    power_estimate_mw = 10 ** ( power_estimate_dbm / 10 )
    if power_estimate_mw < 0.01:
      power_estimate_s = "{:0.2f} µW".format(power_estimate_mw * 1000)
    else:
      power_estimate_s = "{:0.2f} mW".format(power_estimate_mw)
    power_estimate = "{:0.2f} dBm ({})".format(power_estimate_dbm, power_estimate_s)
  options['power-estimate'] = power_estimate
197

198
[lan-ip]
199 200 201 202
recipe = slapos.recipe.build
init =
  import netifaces
  for i in netifaces.interfaces():
203
      if not (i.startswith("slaptun") or i.startswith("slaptap") or i.startswith("re6stnet") or i == "lo"):
204 205 206 207 208 209 210
          a = netifaces.ifaddresses(i)
          if netifaces.AF_INET in a:
              try:
                  options['ipv4'] = a[netifaces.AF_INET][0]['addr']
              except:
                  options['ipv4'] = "0.0.0.0"

Kirill Smelkov's avatar
.  
Kirill Smelkov committed
211 212 213 214 215 216 217 218 219 220
[ors-id]
recipe = slapos.recipe.build
computer = $${slap-connection:computer-id}
title = $${slap-configuration:root-instance-title}
init =
  import socket
  options['hostname'] = socket.gethostname()
  ors_id = '__'.join(options[x] for x in ('hostname', 'computer', 'title'))
  options['ors-id'] = ors_id

221 222
[switch-softwaretype]
recipe = slapos.cookbook:switch-softwaretype
223 224 225
enb = dynamic-template-enb:output
gnb = dynamic-template-gnb:output
core-network = dynamic-template-core-network:output
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
226
ue = dynamic-template-ue:output
227
RootSoftwareInstance = $${:core-network}
228 229 230 231 232
obsolete = dynamic-template-obsolete:output
enb-epc = $${:obsolete}
gnb-epc = $${:obsolete}
epc = $${:obsolete}
mme = $${:obsolete}
233

234
[dynamic-template-obsolete]
235
< = jinja2-template-base
236 237
url = ${template-obsolete:target}
filename = instance-obsolete.cfg
238 239
extensions = jinja2.ext.do
extra-context =
240
    key slave_instance_list slap-configuration:slave-instance-list
241

242
[dynamic-template-enb]
243
< = jinja2-template-base
244 245
url = ${template-enb:target}
filename = instance-enb.cfg
246
extensions = jinja2.ext.do
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
247
# XXX move RU-specific bits from extra context to ru/...
248
extra-context =
249
    raw monitor_template ${monitor2-template:output}
250
    section ors_version ors-version
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
251
    section ors_id ors-id
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
252
    section slap_configuration slap-configuration
253
    key enb amarisoft:enb
254
    key sdr amarisoft:sdr
255
    raw enb_template   ${enb.jinja2.cfg:target}
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
256
    raw amari_lte_template   ${amari_lte.jinja2:target}
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
257
    raw amari_slap_template  ${amari_slap.jinja2:target}
258
    raw sib23_template   ${sib23.jinja2.asn:target}
259
    raw ltelogs_template   ${ltelogs.jinja2.sh:target}
260
    raw amarisoft_stats_template   ${amarisoft-stats.jinja2.py:target}
261
    raw amarisoft_rf_info_template   ${amarisoft-rf-info.jinja2.py:target}
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
262
    raw ru_lopcomm_stats_template   ${ru_lopcomm_stats.jinja2.py:target}
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
263
    raw ru_lopcomm_config_template   ${ru_lopcomm_config.jinja2.py:target}
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
264
    raw ru_lopcomm_software_template   ${ru_lopcomm_software.jinja2.py:target}
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
265
    raw lopcomm_rrh_supervision_template   ${lopcomm-rrh-supervision.jinja2.py:target}
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
266
    raw ru_lopcomm_CreateProcessingEle_template   ${ru_lopcomm_CreateProcessingEle.jinja2.xml:target}
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
267
    raw ru_lopcomm_cu_config_template   ${ru_lopcomm_cu_config.jinja2.xml:target}
268
    raw openssl_location ${openssl:location}
269
    raw default_lte_inactivity_timer ${default-params:default-lte-inactivity-timer}
270 271 272
    raw dnsmasq_template   ${dnsmasq.jinja2.cfg:target}
    raw dnsmasq_location ${dnsmasq:location}
    key dnsmasq_config_path dnsmasq-config:output
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
273 274 275
    raw fluent_bit_location ${fluent-bit:location}
    raw openssh_location ${openssh:location}
    raw openssh_output_keygen ${openssh-output:keygen}
276

277
[dynamic-template-gnb]
278
< = jinja2-template-base
279 280
url = ${template-gnb:target}
filename = instance-gnb.cfg
281 282
extensions = jinja2.ext.do
extra-context =
283
    raw monitor_template ${monitor2-template:output}
284
    section ors_version ors-version
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
285
    section ors_id ors-id
286
    key enb amarisoft:enb
287
    key sdr amarisoft:sdr
288 289
    raw gnb_template   ${gnb.jinja2.cfg:target}
    raw ltelogs_template   ${ltelogs.jinja2.sh:target}
290
    raw amarisoft_stats_template   ${amarisoft-stats.jinja2.py:target}
291
    raw amarisoft_rf_info_template   ${amarisoft-rf-info.jinja2.py:target}
292
    raw openssl_location ${openssl:location}
293
    raw default_nr_inactivity_timer ${default-params:default-nr-inactivity-timer}
294
    raw python_path ${python3:location}
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
295
    raw fluent_bit_location ${fluent-bit:location}
296

297
[dynamic-template-core-network]
298
< = jinja2-template-base
299 300
url = ${template-core-network:target}
filename = instance-core-network.cfg
301 302
extensions = jinja2.ext.do
extra-context =
303
    raw monitor_template ${monitor2-template:output}
304
    key mme amarisoft:mme
305
    raw mme_template   ${mme.jinja2.cfg:target}
306
    raw dnsmasq_template   ${dnsmasq.jinja2.cfg:target}
307 308 309 310
    raw ims_template   ${ims.jinja2.cfg:target}
    raw ltelogs_template   ${ltelogs.jinja2.sh:target}
    raw openssl_location ${openssl:location}
    raw nghttp2_location ${nghttp2:location}
311
    raw iperf3_location ${iperf3:location}
312
    raw dnsmasq_location ${dnsmasq:location}
313
    key ue_db_path ue-db-config:output
314
    key dnsmasq_config_path dnsmasq-config:output
315
    key slave_instance_list slap-configuration:slave-instance-list
316

Kirill Smelkov's avatar
.  
Kirill Smelkov committed
317
[dynamic-template-ue]
318
< = jinja2-template-base
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
319 320
url = ${template-ue:target}
filename = instance-ue.cfg
321 322 323 324
extensions = jinja2.ext.do
extra-context =
    raw monitor_template ${monitor2-template:output}
    key ue amarisoft:ue
325
    key sdr amarisoft:sdr
Kirill Smelkov's avatar
.  
Kirill Smelkov committed
326
    raw ue_template   ${ue.jinja2.cfg:target}
327 328 329
    raw ltelogs_template   ${ltelogs.jinja2.sh:target}
    raw openssl_location ${openssl:location}

330 331
[ue-db-config]
recipe = slapos.recipe.template:jinja2
332
url = ${ue_db.jinja2.cfg:target}
333 334
filename = ue_db.cfg
extensions = jinja2.ext.do
335
output = $${directory:etc}/$${:filename}
336
context =
337
    import json_module json
338
    key slave_instance_list slap-configuration:slave-instance-list
339 340 341 342 343 344 345 346 347

[dnsmasq-config]
recipe = slapos.recipe.template:jinja2
url = ${dnsmasq.jinja2.cfg:target}
filename = dnsmasq.cfg
extensions = jinja2.ext.do
output = $${directory:etc}/$${:filename}
context =
    import json_module json
348 349
    import netaddr netaddr
    section directory directory
350
    section slap_configuration slap-configuration
351
    key slapparameter_dict slap-configuration:configuration