# generic software for Amarisoft 4G/5G stack.
#
# Its intended usage is small-to-medium networks.

[buildout]
extends =
  buildout.hash.cfg
  ../../stack/slapos.cfg
  ../../stack/monitor/buildout.cfg
  ../../component/logrotate/buildout.cfg
  ../../component/nghttp2/buildout.cfg
  ../../component/iperf3/buildout.cfg
  ../../component/python3/buildout.cfg
  ../../component/python-pynacl/buildout.cfg
  ../../component/bcrypt/buildout.cfg
  ../../component/nginx/buildout.cfg
  ../../component/numpy/buildout.cfg
  ../../component/openssl/buildout.cfg
  ../../component/pygolang/buildout.cfg
  ../../component/git/buildout.cfg
  ../../component/dnsmasq/buildout.cfg
  ../../component/fluent-bit/buildout.cfg
  ../../component/openssh/buildout.cfg
  ../../component/libcap/buildout.cfg
  ru/buildout.cfg

parts +=
  template
  slapos-cookbook
# copy all configs by default
  mme.jinja2.cfg
  dnsmasq-core-network.jinja2.cfg
  ims.jinja2.cfg
  enb.jinja2.cfg
  ue_db.jinja2.cfg
  ue.jinja2.cfg
  drb_lte.jinja2.cfg
  drb_nr.jinja2.cfg
  sib23.jinja2.asn
  mt_call_qos.jinja2.sdp
  monitor-httpd-extra-conf
# copy all gadget file
  gadget
  g-chart.line.js
  promise.gadget.js
  software.cfg.html
  rsvp.js
  iperf3
  dnsmasq
  eggs
  xamari
  amarisoft-lte-mock-scripts
  setcap-dnsmasq
# unimplemented parts - the http monitor and better log handling using logrotate
#  apache-php
#  logrotate

[template]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/template.cfg

[download-base]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_update_hash_filename_}

[template-enb]
<= download-base

[template-core-network]
<= download-base

[template-ue]
<= download-base

[template-obsolete]
<= download-base

[copy-to-instance]
recipe  = slapos.recipe.build:download
url     = ${:_profile_base_location_}/${:_buildout_section_name_}

[copy-config-to-instance]
recipe  = slapos.recipe.build:download
url     = ${:_profile_base_location_}/config/${:_buildout_section_name_}

[gadget]
recipe = slapos.recipe.template
output = ${buildout:directory}/${:_buildout_section_name_}/renderjs.js
url = https://lab.nexedi.com/nexedi/renderjs/raw/b715d066bfddc30bedfc8356fb720dcbb391378e/dist/renderjs-0.28.0.js
md5sum = 7e074a29b07e0045d2ba8a8e63bd499e

[monitor-httpd-extra-conf]
recipe = slapos.recipe.template
output = ${buildout:directory}/etc/httpd-include-file.conf
inline =
  Alias /gadget  ${buildout:directory}/gadget
  <Directory  ${buildout:directory}/gadget>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    Satisfy Any
    Allow from all
  </Directory>

[copy-gadget-to-software]
recipe      = slapos.recipe.build:download
url         = ${:_profile_base_location_}/gadget/${:_buildout_section_name_}
destination =  ${buildout:directory}/gadget/${:_buildout_section_name_}

[enb.jinja2.cfg]
<= copy-config-to-instance
filename = enb.jinja2.cfg
[drb_lte.jinja2.cfg]
<= copy-config-to-instance
[drb_nr.jinja2.cfg]
<= copy-config-to-instance
[sib23.jinja2.asn]
<= copy-config-to-instance
filename = sib23.jinja2.asn
[mt_call_qos.jinja2.sdp]
<= copy-config-to-instance
[ue_db.jinja2.cfg]
<= copy-config-to-instance
filename = ue_db.jinja2.cfg
[mme.jinja2.cfg]
<= copy-config-to-instance
filename = mme.jinja2.cfg
[dnsmasq-core-network.jinja2.cfg]
<= copy-config-to-instance
[ims.jinja2.cfg]
<= copy-config-to-instance
filename = ims.jinja2.cfg
[ue.jinja2.cfg]
<= copy-config-to-instance
filename = ue.jinja2.cfg
[slaplte.jinja2]
<= download-base
[nginx_conf.in]
<= download-base

# Download gadget files
[software.cfg.html]
<= copy-gadget-to-software
[promise.gadget.js]
<= copy-gadget-to-software

[rsvp.js]
<= copy-gadget-to-software
url = https://lab.nexedi.com/nexedi/rsvp.js/raw/b0c4596df6a52d75705a59262bc992a166ff11a1/dist/rsvp-2.0.4.js
md5sum = 2b0f2d52857b17fdfb8a5c2ea451a5ad

[g-chart.line.js]
<= copy-gadget-to-software
url = https://raw.githubusercontent.com/guschnwg/g-chart/cbcc7bc40f88fcce4854b55d0902b6273004ba3e/g-chart.line.js
md5sum = 57c50b46c9492c6ab78dc44deac3c0ce

[eggs]
recipe = zc.recipe.egg
eggs =
  websocket-client
  ${python-pynacl:egg}
  ${bcrypt:egg}
  xmltodict
  ncclient
  ${lxml-python:egg}
  nrarfcn
  netifaces
  netaddr
interpreter = pythonwitheggs

[amarisoft-lte-mock-repository]
recipe = slapos.recipe.build:gitclone
repository = https://lab.nexedi.com/nexedi/amarisoft-lte-mock.git
revision = 1.1
git-executable = ${git:location}/bin/git

[amarisoft-lte-mock]
recipe = zc.recipe.egg:develop
setup = ${amarisoft-lte-mock-repository:location}
egg = amarisoft-lte-mock
depends =

[amarisoft-lte-mock-scripts]
recipe = zc.recipe.egg
eggs = 
  ${amarisoft-lte-mock:egg}
  pcpp
  PyYAML
  websockets
scripts =
  lteenb
  ltemme
  lteims
  lteue

[xlte-repository]
recipe = slapos.recipe.build:gitclone
repository = https://lab.nexedi.com/kirr/xlte.git
revision = c5e92b6a
git-executable = ${git:location}/bin/git

[xlte]
recipe = zc.recipe.egg:develop
setup = ${xlte-repository:location}
egg = xlte
depends =
  ${numpy:egg}
  ${pygolang:egg}

[xamari]
recipe = zc.recipe.egg
eggs = ${xlte:egg}
scripts = xamari

[setcap]
recipe = plone.recipe.command
command = sudo -n /opt/amarisoft/setcap ${:exe} || true
update-command = ${:command}

[setcap-dnsmasq]
<= setcap
exe = ${dnsmasq:location}/sbin/dnsmasq

[versions]
websocket-client = 1.4.2
ncclient = 0.6.13
xmltodict = 0.13.0
nrarfcn = 2.4.0:whl
pcpp = 1.30