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

software/ors: add frequency out of bounds promise

parent d84ca6c6
...@@ -20,7 +20,7 @@ md5sum = f1b9ae02222c020c89d1a3fa75475826 ...@@ -20,7 +20,7 @@ md5sum = f1b9ae02222c020c89d1a3fa75475826
[template-ors] [template-ors]
filename = instance-ors.cfg filename = instance-ors.cfg
md5sum = 71255edd8b9bfc7460b32b723da01cf8 md5sum = 8c2abee8eb0a538ad8ae1a84e140af69
[slaplte.jinja2] [slaplte.jinja2]
_update_hash_filename_ = slaplte.jinja2 _update_hash_filename_ = slaplte.jinja2
...@@ -60,11 +60,11 @@ md5sum = 52da9fe3a569199e35ad89ae1a44c30e ...@@ -60,11 +60,11 @@ md5sum = 52da9fe3a569199e35ad89ae1a44c30e
[template-enb] [template-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg _update_hash_filename_ = instance-enb.jinja2.cfg
md5sum = be054d3312acd4ff5bea116e9af895b0 md5sum = bda6ff7bc76cf73e3bd55aca21134a3a
[template-ors-enb] [template-ors-enb]
_update_hash_filename_ = instance-ors-enb.jinja2.cfg _update_hash_filename_ = instance-ors-enb.jinja2.cfg
md5sum = 37295d2dfb453bdb860420c3a49ab916 md5sum = 585457493ce5302ba1f1073b8a3b877c
[template-ors-ue] [template-ors-ue]
_update_hash_filename_ = instance-ors-ue.jinja2.cfg _update_hash_filename_ = instance-ors-ue.jinja2.cfg
...@@ -137,3 +137,7 @@ md5sum = 330f5f07806f1da11cd05bb8e4b52e55 ...@@ -137,3 +137,7 @@ md5sum = 330f5f07806f1da11cd05bb8e4b52e55
[ue-ifup] [ue-ifup]
_update_hash_filename_ = config/ue-ifup _update_hash_filename_ = config/ue-ifup
md5sum = f02fbfd31ba89cf243e2752adcae28d9 md5sum = f02fbfd31ba89cf243e2752adcae28d9
[frequency_outofbounds_promise]
_update_hash_filename_ = promise/check_frequency_outofbounds.py
md5sum = 7c83eab2df4f5a5d519e3eb16e4077a3
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
[buildout] [buildout]
extra-parts =
parts = parts =
directory directory
enb-config enb-config
...@@ -30,6 +31,7 @@ parts = ...@@ -30,6 +31,7 @@ parts =
check-baseband-latency.py check-baseband-latency.py
monitor-base monitor-base
publish-connection-information publish-connection-information
${:extra-parts}
extends = {{ monitor_template }} extends = {{ monitor_template }}
......
...@@ -251,3 +251,20 @@ init = ...@@ -251,3 +251,20 @@ init =
del publish['cell-list'] del publish['cell-list']
del publish['peer-list'] del publish['peer-list']
del publish['peer-cell-list'] del publish['peer-cell-list']
# Add custom promise to check if /dev/sdr0 is busy
[frequency-outofbounds-promise]
recipe = slapos.cookbook:promise.plugin
eggs = slapos.core
file = {{ frequency_outofbounds_promise }}
output = ${directory:plugins}/check-frequency-outofbounds.py
{%- if enb_mode == 'enb' %}
config-frequency = {{ xearfcn_module.frequency(ors_version['current-earfcn']) }}
{%- elif enb_mode == 'gnb' %}
config-frequency = {{ xnrarfcn_module.frequency(ors_version['current-nr-arfcn']) }}
{%- endif %}
config-range-rating = {{ ors_version['range'] }}
[buildout]
extra-parts +=
frequency-outofbounds-promise
...@@ -30,6 +30,7 @@ filename = instance-enb.cfg ...@@ -30,6 +30,7 @@ filename = instance-enb.cfg
extra-context += extra-context +=
section ors ors-version section ors ors-version
section ors_version ors-version section ors_version ors-version
raw frequency_outofbounds_promise ${frequency_outofbounds_promise:target}
import-list += import-list +=
rawfile instance-enb-base.jinja2.cfg ${template-enb:target} rawfile instance-enb-base.jinja2.cfg ${template-enb:target}
......
import os
import errno
from zope.interface import implementer
from slapos.grid.promise import interface
from slapos.grid.promise.generic import GenericPromise
@implementer(interface.IPromise)
class RunPromise(GenericPromise):
def __init__(self, config):
"""
Called when initialising the promise before testing.
Sets the configuration and the periodicity.
"""
super(RunPromise, self).__init__(config)
self.setPeriodicity(minute=1)
def sense(self):
"""
Called every time the promise is tested.
Signals a positive or negative result.
In this case, check whether the file exists.
"""
frequency = self.getConfig('frequency')
range_rating = self.getConfig('range-rating')
try:
min_frequency = int(range_rating.split('MHz')[0].strip())
max_frequency = int(range_rating.split('-')[1].split('MHz')[0].strip())
except (IndexError, ValueError) as e:
self.logger.info("Range rating not available, skipping the promise")
return
try:
frequency = int(float(frequency))
except ValueError as e:
self.logger.info("Invalid frequency, skipping the promise")
return
if min_frequency <= frequency <= max_frequency:
self.logger.info("Frequency is in bounds ({} MHz <= {} MHz <= {} MHz)".format(
min_frequency,
frequency,
max_frequency))
elif frequency < min_frequency:
self.logger.error("Frequency is lower than the lowest possible frequency on this hardware, please increase it ({} MHz < {} MHz)".format(
frequency,
min_frequency))
else:
self.logger.error("Frequency is higher than the highest possible frequency on this hardware, please increase it ({} MHz > {} MHz)".format(
frequency,
max_frequency))
def test(self):
"""
Called after sense() if the instance is still converging.
Returns success or failure based on sense results.
In this case, fail if the previous sensor result is negative.
"""
return self._test(result_count=1, failure_amount=1)
def anomaly(self):
"""
Called after sense() if the instance has finished converging.
Returns success or failure based on sense results.
Failure signals the instance has diverged.
In this case, fail if two out of the last three results are negative.
"""
return self._anomaly(result_count=1, failure_amount=1)
...@@ -34,3 +34,6 @@ output= ${buildout:bin-directory}/${:_buildout_section_name_} ...@@ -34,3 +34,6 @@ output= ${buildout:bin-directory}/${:_buildout_section_name_}
mode = 0755 mode = 0755
context = context =
section bash bash section bash bash
[frequency_outofbounds_promise]
<= download-base
...@@ -77,7 +77,8 @@ param_dict = { ...@@ -77,7 +77,8 @@ param_dict = {
}, },
} }
enb_param_dict = { enb_param_dict = {
'dl_earfcn': 36100, # ors_version for tests is B39, so earfcn needs to be within B39
'dl_earfcn': 38450,
'enb_id': '0x17', 'enb_id': '0x17',
'bandwidth': "10 MHz", 'bandwidth': "10 MHz",
'plmn_list': { 'plmn_list': {
...@@ -105,10 +106,11 @@ enb_param_dict = { ...@@ -105,10 +106,11 @@ enb_param_dict = {
}, },
} }
gnb_param_dict = { gnb_param_dict = {
'dl_nr_arfcn': 403500, # ors_version for tests is B39, so dl_nr_arfcn needs to be within N39
'nr_band': 34, 'dl_nr_arfcn': 380000,
'nr_bandwidth': 50, 'nr_band': 39,
'ssb_nr_arfcn': 403520, 'nr_bandwidth': 40,
'ssb_nr_arfcn': 380020,
'gnb_id': '0x17', 'gnb_id': '0x17',
'gnb_id_bits': 30, 'gnb_id_bits': 30,
'ssb_pos_bitmap': '10', 'ssb_pos_bitmap': '10',
......
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