Commit 8a62834e authored by Lu Xu's avatar Lu Xu 👀

software/ors-amarisoft: add carrier configuration for lopcomm RRH

parent fcb7b7ee
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
[template] [template]
filename = instance.cfg filename = instance.cfg
md5sum = 4af831f81760b37250fa50ad3812142a md5sum = 3f982f31a642ba9d6a1613f49e1c0d10
[amarisoft-stats.jinja2.py] [amarisoft-stats.jinja2.py]
_update_hash_filename_ = amarisoft-stats.jinja2.py _update_hash_filename_ = amarisoft-stats.jinja2.py
...@@ -28,7 +28,11 @@ md5sum = c930c28365c685a6066f382c9b5d8893 ...@@ -28,7 +28,11 @@ md5sum = c930c28365c685a6066f382c9b5d8893
[lopcomm-rrh-stats.jinja2.py] [lopcomm-rrh-stats.jinja2.py]
_update_hash_filename_ = lopcomm-rrh-stats.jinja2.py _update_hash_filename_ = lopcomm-rrh-stats.jinja2.py
md5sum = 39e191080722ac13ebc56b1e6350eb8f md5sum = 6339dd6c5dcbef95b58ed52a9fadc9a4
[lopcomm-rrh-config.jinja2.py]
_update_hash_filename_ = lopcomm-rrh-config.jinja2.py
md5sum = e0b68a87238282568e0e04c792ec7288
[template-lte-enb-epc] [template-lte-enb-epc]
_update_hash_filename_ = instance-enb-epc.jinja2.cfg _update_hash_filename_ = instance-enb-epc.jinja2.cfg
...@@ -36,7 +40,7 @@ md5sum = bb4435f433e100fede09ff921d42c927 ...@@ -36,7 +40,7 @@ md5sum = bb4435f433e100fede09ff921d42c927
[template-lte-enb] [template-lte-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg _update_hash_filename_ = instance-enb.jinja2.cfg
md5sum = 31707b64ab531c60fc99287238130c5b md5sum = 49f8628e616c1fa09608b58a7f9ac34e
[template-lte-gnb-epc] [template-lte-gnb-epc]
_update_hash_filename_ = instance-gnb-epc.jinja2.cfg _update_hash_filename_ = instance-gnb-epc.jinja2.cfg
...@@ -97,3 +101,11 @@ md5sum = 31c166f0a1b6d664f92b8f318b233d9a ...@@ -97,3 +101,11 @@ md5sum = 31c166f0a1b6d664f92b8f318b233d9a
[ue-nr.jinja2.cfg] [ue-nr.jinja2.cfg]
filename = config/ue-nr.jinja2.cfg filename = config/ue-nr.jinja2.cfg
md5sum = b3078deab008d7e81ddd88ac02b8b698 md5sum = b3078deab008d7e81ddd88ac02b8b698
[CreateProcessingEle.jinja2.xml]
filename = netconf/CreateProcessingEle.jinja2.xml
md5sum = e435990eb0a0d4be41efa9bd16dce09b
[cu_config.jinja2.xml]
filename = netconf/cu_config.jinja2.xml
md5sum = 50b8f86cf4ed87be179f6a62284c56d7
...@@ -8,6 +8,8 @@ parts = ...@@ -8,6 +8,8 @@ parts =
amarisoft-rf-info-service amarisoft-rf-info-service
{% if slapparameter_dict.get('rrh', '') == "Lopcomm ORAN" %} {% if slapparameter_dict.get('rrh', '') == "Lopcomm ORAN" %}
lopcomm-rrh-stats-service lopcomm-rrh-stats-service
lopcomm-rrh-config-template
lopcomm-cu-config
check-lopcomm-vswr.py check-lopcomm-vswr.py
check-lopcomm-lof.py check-lopcomm-lof.py
check-lopcomm-rssi.py check-lopcomm-rssi.py
...@@ -151,17 +153,40 @@ recipe = slapos.recipe.template:jinja2 ...@@ -151,17 +153,40 @@ recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do extensions = jinja2.ext.do
log-output = ${directory:var}/log/lopcomm-rrh-stats.log log-output = ${directory:var}/log/lopcomm-rrh-stats.log
json-log-output = ${directory:var}/log/lopcomm-rrh-stats.json.log json-log-output = ${directory:var}/log/lopcomm-rrh-stats.json.log
cfg-json-log-output = ${directory:var}/log/lopcomm-rrh-config.json.log
context = context =
section directory directory section directory directory
key slapparameter_dict slap-configuration:configuration key slapparameter_dict slap-configuration:configuration
key log_file :log-output key log_file :log-output
key json_log_file :json-log-output key json_log_file :json-log-output
key cfg_json_log_file :cfg-json-log-output
raw testing {{ slapparameter_dict.get("testing", False) }} raw testing {{ slapparameter_dict.get("testing", False) }}
raw python_path {{ buildout_directory}}/bin/pythonwitheggs raw python_path {{ buildout_directory}}/bin/pythonwitheggs
mode = 0775 mode = 0775
url = {{ lopcomm_rrh_stats_template }} url = {{ lopcomm_rrh_stats_template }}
output = ${directory:bin}/lopcomm-rrh-stats.py output = ${directory:bin}/lopcomm-rrh-stats.py
[lopcomm-cu-config]
<= config-base
url = {{ cu_config_template }}
output = ${directory:etc}/cu_config.xml
[lopcomm-rrh-config-template]
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
log-output = ${directory:var}/log/lopcomm-rrh-config.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
raw CreateProcessingEle_template {{ CreateProcessingEle_template }}
key cu_config_template lopcomm-cu-config:output
mode = 0775
url = {{ lopcomm_rrh_config_template }}
output = ${directory:script}/lopcomm-rrh-config.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}
......
...@@ -112,6 +112,9 @@ extra-context = ...@@ -112,6 +112,9 @@ extra-context =
raw amarisoft_stats_template ${amarisoft-stats.jinja2.py:target} raw amarisoft_stats_template ${amarisoft-stats.jinja2.py:target}
raw amarisoft_rf_info_template ${amarisoft-rf-info.jinja2.py:target} raw amarisoft_rf_info_template ${amarisoft-rf-info.jinja2.py:target}
raw lopcomm_rrh_stats_template ${lopcomm-rrh-stats.jinja2.py:target} raw lopcomm_rrh_stats_template ${lopcomm-rrh-stats.jinja2.py:target}
raw lopcomm_rrh_config_template ${lopcomm-rrh-config.jinja2.py:target}
raw CreateProcessingEle_template ${CreateProcessingEle.jinja2.xml:target}
raw cu_config_template ${cu_config.jinja2.xml:target}
raw openssl_location ${openssl:location} raw openssl_location ${openssl:location}
raw default_dl_earfcn ${default-params:default-dl-earfcn} raw default_dl_earfcn ${default-params:default-dl-earfcn}
raw default_lte_dl_freq ${default-params:default-lte-dl-freq} raw default_lte_dl_freq ${default-params:default-lte-dl-freq}
......
#!{{ python_path }}
import logging
import time
import xmltodict
from logging.handlers import RotatingFileHandler
from ncclient import manager
from ncclient.operations import RPCError
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.DEBUG)
handler = RotatingFileHandler(log_file, maxBytes=100000, backupCount=5)
self.logger.addHandler(handler)
formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s")
handler.setFormatter(formatter)
if {{ testing }}:
return
def connect(self, host, port, user, password):
if {{ testing }}:
return
self.address = (host, port)
self.logger.info('Connecting to %s, user %s...' % (self.address, user))
self.conn = manager.connect(host=host,
port=port,
username=user,
password=password,
timeout=1800,
device_params={
'name': 'default'
},
hostkey_verify=False)
self.logger.info('Connection to %s successful' % (self.address,))
def edit_config(self, config_files):
for config_file in config_files:
with open(config_file) as f:
config_xml = f.read()
try:
self.logger.info('Sending edit-config RPC request...')
self.conn.edit_config(target='running', config=config_xml)
self.logger.info('Edit-config RPC request sent successfully')
except RPCError as e:
self.logger.error('Error sending edit-config RPC request: %s' % e)
def close(self):
# Close not compatible between ncclient and netconf server
#self.conn.close()
pass
if __name__ == '__main__':
nc = LopcommNetconfClient()
while True:
try:
nc.connect("192.168.0.210", 830, "oranuser", "oranpassword")
nc.edit_config(["{{ CreateProcessingEle_template }}", "{{ cu_config_template }}"])
break
except Exception as e:
nc.logger.debug('Got exception, waiting 10 seconds before reconnecting...')
nc.logger.debug(e)
time.sleep(10)
finally:
nc.close()
...@@ -14,17 +14,25 @@ class LopcommNetconfClient: ...@@ -14,17 +14,25 @@ class LopcommNetconfClient:
log_file = "{{ log_file }}" log_file = "{{ log_file }}"
json_log_file = "{{ json_log_file }}" json_log_file = "{{ json_log_file }}"
cfg_json_log_file = "{{ cfg_json_log_file }}"
self.logger = logging.getLogger('logger') self.logger = logging.getLogger('logger')
self.json_logger = logging.getLogger('json_logger') self.json_logger = logging.getLogger('json_logger')
self.cfg_json_logger = logging.getLogger('cfg_json_logger')
self.logger.setLevel(logging.DEBUG) self.logger.setLevel(logging.DEBUG)
self.json_logger.setLevel(logging.DEBUG) self.json_logger.setLevel(logging.DEBUG)
self.cfg_json_logger.setLevel(logging.DEBUG)
json_handler = RotatingFileHandler(json_log_file, maxBytes=100000, backupCount=5) json_handler = RotatingFileHandler(json_log_file, maxBytes=100000, backupCount=5)
json_formatter = logging.Formatter('{"time": "%(asctime)s", "log_level": "%(levelname)s", "message": "%(message)s", "data": %(data)s}') json_formatter = logging.Formatter('{"time": "%(asctime)s", "log_level": "%(levelname)s", "message": "%(message)s", "data": %(data)s}')
json_handler.setFormatter(json_formatter) json_handler.setFormatter(json_formatter)
self.json_logger.addHandler(json_handler) self.json_logger.addHandler(json_handler)
cfg_json_handler = RotatingFileHandler(cfg_json_log_file, maxBytes=100000, backupCount=5)
cfg_json_formatter = logging.Formatter('{"time": "%(asctime)s", "log_level": "%(levelname)s", "message": "%(message)s", "data": %(data)s}')
cfg_json_handler.setFormatter(cfg_json_formatter)
self.cfg_json_logger.addHandler(cfg_json_handler)
handler = RotatingFileHandler(log_file, maxBytes=100000, backupCount=5) handler = RotatingFileHandler(log_file, maxBytes=100000, backupCount=5)
self.logger.addHandler(handler) self.logger.addHandler(handler)
formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s") formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s")
...@@ -48,7 +56,7 @@ class LopcommNetconfClient: ...@@ -48,7 +56,7 @@ class LopcommNetconfClient:
password=password, password=password,
timeout=1800, timeout=1800,
device_params={ device_params={
'name': 'huawei' 'name': 'default'
}, },
hostkey_verify=False) hostkey_verify=False)
...@@ -71,7 +79,11 @@ class LopcommNetconfClient: ...@@ -71,7 +79,11 @@ class LopcommNetconfClient:
self.logger.debug('Got new notification from %s...' % (self.address,)) self.logger.debug('Got new notification from %s...' % (self.address,))
result_in_xml = result._raw result_in_xml = result._raw
data_dict = xmltodict.parse(result_in_xml) data_dict = xmltodict.parse(result_in_xml)
self.json_logger.info('', extra={'data': data_dict}) if 'alarm-notif' in data_dict['notification']:
self.json_logger.info('', extra={'data': data_dict})
else:
self.cfg_json_logger.info('', extra={'data': data_dict})
def close(self): def close(self):
# Close not compatible between ncclient and netconf server # Close not compatible between ncclient and netconf server
......
...@@ -22,6 +22,8 @@ parts += ...@@ -22,6 +22,8 @@ parts +=
ue_db.jinja2.cfg ue_db.jinja2.cfg
ue-lte.jinja2.cfg ue-lte.jinja2.cfg
ue-nr.jinja2.cfg ue-nr.jinja2.cfg
CreateProcessingEle.jinja2.xml
cu_config.jinja2.xml
sib23.asn sib23.asn
iperf3 iperf3
eggs eggs
...@@ -47,6 +49,9 @@ url = ${:_profile_base_location_}/${:_update_hash_filename_} ...@@ -47,6 +49,9 @@ url = ${:_profile_base_location_}/${:_update_hash_filename_}
[lopcomm-rrh-stats.jinja2.py] [lopcomm-rrh-stats.jinja2.py]
<= download-base <= download-base
[lopcomm-rrh-config.jinja2.py]
<= download-base
[template-lte-enb-epc] [template-lte-enb-epc]
<= download-base <= download-base
...@@ -79,6 +84,10 @@ url = ${:_profile_base_location_}/${:_buildout_section_name_} ...@@ -79,6 +84,10 @@ url = ${:_profile_base_location_}/${:_buildout_section_name_}
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/config/${:_buildout_section_name_} url = ${:_profile_base_location_}/config/${:_buildout_section_name_}
[copy-netconf-to-instance]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/netconf/${:_buildout_section_name_}
[enb.jinja2.cfg] [enb.jinja2.cfg]
<= copy-config-to-instance <= copy-config-to-instance
filename = enb.jinja2.cfg filename = enb.jinja2.cfg
...@@ -107,6 +116,13 @@ filename = ue-lte.jinja2.cfg ...@@ -107,6 +116,13 @@ filename = ue-lte.jinja2.cfg
<= copy-config-to-instance <= copy-config-to-instance
filename = ue-nr.jinja2.cfg filename = ue-nr.jinja2.cfg
[CreateProcessingEle.jinja2.xml]
<= copy-netconf-to-instance
filename = CreateProcessingEle.jinja2.xml
[cu_config.jinja2.xml]
<= copy-netconf-to-instance
filename = cu_config.jinja2.xml
[eggs] [eggs]
recipe = zc.recipe.egg recipe = zc.recipe.egg
eggs = eggs =
......
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