Commit ac3786d9 authored by Joanne Hugé's avatar Joanne Hugé

add lopcomm stats service

parent 3aefe472
...@@ -16,19 +16,23 @@ ...@@ -16,19 +16,23 @@
[template] [template]
filename = instance.cfg filename = instance.cfg
md5sum = 61e9685d6aa973ae0c45c45ca357458a md5sum = e4d4b5c9d4f00b36478dc9f2b13c1e3c
[amarisoft-stats.jinja2.py] [amarisoft-stats.jinja2.py]
_update_hash_filename_ = amarisoft-stats.jinja2.py _update_hash_filename_ = amarisoft-stats.jinja2.py
md5sum = 6e0a052bd0ca08cc0c7b4880d3deffcc md5sum = 6e0a052bd0ca08cc0c7b4880d3deffcc
[lopcomm-rrh-stats.jinja2.py]
_update_hash_filename_ = lopcomm-rrh-stats.jinja2.py
md5sum = 37a5d971626f44d8dfd734ebce8c8473
[template-lte-enb-epc] [template-lte-enb-epc]
_update_hash_filename_ = instance-enb-epc.jinja2.cfg _update_hash_filename_ = instance-enb-epc.jinja2.cfg
md5sum = 833667743c693b8d5f78a2527b275a9e md5sum = 833667743c693b8d5f78a2527b275a9e
[template-lte-enb] [template-lte-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg _update_hash_filename_ = instance-enb.jinja2.cfg
md5sum = afd8867c4dec5c5c68a4005dec502ebb md5sum = fb2e5265bdb844c5c936d1f3837f9892
[template-lte-gnb-epc] [template-lte-gnb-epc]
_update_hash_filename_ = instance-gnb-epc.jinja2.cfg _update_hash_filename_ = instance-gnb-epc.jinja2.cfg
......
...@@ -5,6 +5,7 @@ parts = ...@@ -5,6 +5,7 @@ parts =
lte-enb-config lte-enb-config
lte-enb-service lte-enb-service
amarisoft-stats-service amarisoft-stats-service
lopcomm-rrh-stats-service
sdr-busy-promise sdr-busy-promise
cell-gain-saturated-promise cell-gain-saturated-promise
rx-saturated-promise rx-saturated-promise
...@@ -120,7 +121,20 @@ mode = 0775 ...@@ -120,7 +121,20 @@ mode = 0775
url = {{ amarisoft_stats_template }} url = {{ amarisoft_stats_template }}
output = ${directory:bin}/amarisoft-stats.py output = ${directory:bin}/amarisoft-stats.py
### eNodeB (enb) [lopcomm-rrh-stats-template]
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
log-output = ${directory:var}/log/lopcomm-rrh-stats.json.log
context =
section directory directory
key slapparameter_dict slap-configuration:configuration
key log_file :log-output
raw testing {{ slapparameter_dict.get("testing", False) }}
raw python_path {{ buildout_directory}}/bin/pythonwitheggs
mode = 0775
url = {{ lopcomm_rrh_stats_template }}
output = ${directory:bin}/lopcomm-rrh-stats.py
[amarisoft-stats-service] [amarisoft-stats-service]
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
command-line = ${amarisoft-stats-template:output} command-line = ${amarisoft-stats-template:output}
...@@ -129,6 +143,14 @@ mode = 0775 ...@@ -129,6 +143,14 @@ mode = 0775
hash-files = hash-files =
${amarisoft-stats-template:output} ${amarisoft-stats-template:output}
[lopcomm-rrh-stats-service]
recipe = slapos.cookbook:wrapper
command-line = ${lopcomm-rrh-stats-template:output}
wrapper-path = ${directory:service}/lopcomm-rrh-stats
mode = 0775
hash-files =
${lopcomm-rrh-stats-template:output}
[config-base] [config-base]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do extensions = jinja2.ext.do
......
...@@ -110,6 +110,7 @@ extra-context = ...@@ -110,6 +110,7 @@ extra-context =
raw sib23 ${sib23.asn:target} raw sib23 ${sib23.asn:target}
raw ltelogs_template ${ltelogs.jinja2.sh:target} raw ltelogs_template ${ltelogs.jinja2.sh:target}
raw amarisoft_stats_template ${amarisoft-stats.jinja2.py:target} raw amarisoft_stats_template ${amarisoft-stats.jinja2.py:target}
raw lopcomm_rrh_stats_template ${lopcomm-rrh-stats.jinja2.py:target}
raw sdr_busy_promise ${sdr-busy-promise:target} raw sdr_busy_promise ${sdr-busy-promise:target}
raw cell_gain_saturated_promise ${cell-gain-saturated-promise:target} raw cell_gain_saturated_promise ${cell-gain-saturated-promise:target}
raw rx_saturated_promise ${rx-saturated-promise:target} raw rx_saturated_promise ${rx-saturated-promise:target}
......
#!{{ python_path }}
import json
import logging
import time
from logging.handlers import RotatingFileHandler
from ncclient import manager
from ncclient.xml_ import *
from ncclient.devices.default import DefaultDeviceHandler
class LopcommNetconfClient:
def __init__(self):
log_file = "{{ log_file }}"
self.logger = logging.getLogger('logger')
self.logger.setLevel(logging.INFO)
handler = RotatingFileHandler(log_file, maxBytes=30000, backupCount=2)
formatter = logging.Formatter('{"time": "%(asctime)s", "log_level": "%(levelname)s", "message": "%(message)s", "data": %(data)s}')
handler.setFormatter(formatter)
self.logger.addHandler(handler)
if {{ testing }}:
return
def connect(host, port, user, password):
if {{ testing }}:
return
conn = manager.connect(host=host,
port=port,
username=user,
password=password,
timeout=1800,
device_params={
'name': 'huawei'
},
hostkey_verify=False)
#result = conn.create_subscription(filter=('xpath', '/o-ran-fm:*'))
sub = conn.create_subscription()
result = None
while result == None:
result = conn.take_notification(block=True, timeout=60)
print(result)
import pdb; pdb.set_trace()
#self.logger.info('', extra={'data': r})
if __name__ == '__main__':
#LOG_FORMAT = '%(asctime)s %(levelname)s %(filename)s:%(lineno)d %(message)s'
#logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=LOG_FORMAT)
#logging.getLogger().setLevel(logging.DEBUG)
connect("192.168.0.210", 830, "oranuser", "oranpassword")
nc = LopcommNetconfClient()
while True:
try:
nc.connect()
time.sleep(10)
except Exception as e:
nc.logger.debug(e)
finally:
nc.close()
...@@ -40,6 +40,9 @@ url = ${:_profile_base_location_}/${:_update_hash_filename_} ...@@ -40,6 +40,9 @@ url = ${:_profile_base_location_}/${:_update_hash_filename_}
[amarisoft-stats.jinja2.py] [amarisoft-stats.jinja2.py]
<= download-base <= download-base
[lopcomm-rrh-stats.jinja2.py]
<= download-base
[template-lte-enb-epc] [template-lte-enb-epc]
<= download-base <= download-base
...@@ -115,11 +118,27 @@ filename = ue-lte.jinja2.cfg ...@@ -115,11 +118,27 @@ filename = ue-lte.jinja2.cfg
<= copy-config-to-instance <= copy-config-to-instance
filename = ue-nr.jinja2.cfg filename = ue-nr.jinja2.cfg
[pynacl]
recipe = zc.recipe.egg:custom
egg = pynacl
setup-eggs =
cffi
[bcrypt]
recipe = zc.recipe.egg:custom
egg = bcrypt
setup-eggs =
cffi
[eggs] [eggs]
recipe = zc.recipe.egg recipe = zc.recipe.egg
eggs = eggs =
websocket-client websocket-client
${pynacl:egg}
${bcrypt:egg}
ncclient
interpreter = pythonwitheggs interpreter = pythonwitheggs
[versions] [versions]
websocket-client = 1.4.2 websocket-client = 1.4.2
ncclient = 0.6.13
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