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

software/ors-amarisoft: Add promises for eNB and EPC

parent 28d8594b
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
[template] [template]
filename = instance.cfg filename = instance.cfg
md5sum = 96a76300b2f714b6c47157920fe79a53 md5sum = b65347ea7c1936c2926ef11258cea602
[template-lte-enb-epc] [template-lte-enb-epc]
_update_hash_filename_ = instance-enb-epc.jinja2.cfg _update_hash_filename_ = instance-enb-epc.jinja2.cfg
...@@ -24,7 +24,7 @@ md5sum = 762d55291e75e8b61e35f9f28d29915a ...@@ -24,7 +24,7 @@ md5sum = 762d55291e75e8b61e35f9f28d29915a
[template-lte-enb] [template-lte-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg _update_hash_filename_ = instance-enb.jinja2.cfg
md5sum = 83c37b43d7b70584bf71aed9289ea13c md5sum = ad6520b01eefdd4fa76c10f7ffa01d48
[template-lte-gnb-epc] [template-lte-gnb-epc]
_update_hash_filename_ = instance-gnb-epc.jinja2.cfg _update_hash_filename_ = instance-gnb-epc.jinja2.cfg
...@@ -32,11 +32,11 @@ md5sum = e43a726dd3023a4bbaa474bb2d7a6ebe ...@@ -32,11 +32,11 @@ md5sum = e43a726dd3023a4bbaa474bb2d7a6ebe
[template-lte-gnb] [template-lte-gnb]
_update_hash_filename_ = instance-gnb.jinja2.cfg _update_hash_filename_ = instance-gnb.jinja2.cfg
md5sum = fc59d15a7f7f942951f9e38d7a1cca2c md5sum = 02af36a5c2f4123a73c8ce4ba6cbf5c2
[template-lte-epc] [template-lte-epc]
_update_hash_filename_ = instance-epc.jinja2.cfg _update_hash_filename_ = instance-epc.jinja2.cfg
md5sum = 27d423b3a065fa00a3cf65228f4b798a md5sum = ead0846454d61121c0635c5a657c194c
[ue_db.jinja2.cfg] [ue_db.jinja2.cfg]
filename = config/ue_db.jinja2.cfg filename = config/ue_db.jinja2.cfg
...@@ -61,3 +61,11 @@ md5sum = 518c71ce57204304b703b977c665a164 ...@@ -61,3 +61,11 @@ md5sum = 518c71ce57204304b703b977c665a164
[ims.jinja2.cfg] [ims.jinja2.cfg]
filename = config/ims.jinja2.cfg filename = config/ims.jinja2.cfg
md5sum = e561ec26a70943c61557def1781cf65f md5sum = e561ec26a70943c61557def1781cf65f
[sdr-busy-promise]
_update_hash_filename_ = promise/check_sdr_busy.py
md5sum = 9e867282d7dd80c4255e87a82a47a19d
[interface-up-promise]
_update_hash_filename_ = promise/check_interface_up.py
md5sum = 505efcbe04e717088924f2267b10c2b9
...@@ -4,7 +4,7 @@ parts = ...@@ -4,7 +4,7 @@ parts =
ltelogs ltelogs
lte-enb-config lte-enb-config
lte-enb-service lte-enb-service
# Temporarily extend monitor-base until promises are added sdr-busy-promise
monitor-base monitor-base
publish-connection-information publish-connection-information
...@@ -97,3 +97,10 @@ monitor-base-url = ${monitor-instance-parameter:monitor-base-url} ...@@ -97,3 +97,10 @@ monitor-base-url = ${monitor-instance-parameter:monitor-base-url}
[monitor-instance-parameter] [monitor-instance-parameter]
monitor-title = {{ slapparameter_dict['name'] | string }} monitor-title = {{ slapparameter_dict['name'] | string }}
password = {{ slapparameter_dict['monitor-password'] | string }} password = {{ slapparameter_dict['monitor-password'] | string }}
# Add custom promise to check if /dev/sdr0 is busy
[sdr-busy-promise]
recipe = slapos.cookbook:promise.plugin
eggs = slapos.core
file = {{ sdr_busy_promise }}
output = ${directory:plugins}/check-sdr-busy.py
...@@ -4,7 +4,7 @@ parts = ...@@ -4,7 +4,7 @@ parts =
ltelogs ltelogs
lte-mme-config lte-mme-config
lte-mme-service lte-mme-service
# Temporarily extend monitor-base until promises are added tun-up-promise
monitor-base monitor-base
publish-connection-information publish-connection-information
...@@ -135,3 +135,11 @@ monitor-setup-url = https://monitor.app.officejs.com/#page=settings_configurator ...@@ -135,3 +135,11 @@ monitor-setup-url = https://monitor.app.officejs.com/#page=settings_configurator
monitor-title = {{ slapparameter_dict['name'] }} monitor-title = {{ slapparameter_dict['name'] }}
password = {{ slapparameter_dict['monitor-password'] }} password = {{ slapparameter_dict['monitor-password'] }}
{% endif %} {% endif %}
# Add custom promise to check if /dev/sdr0 is busy
[tun-up-promise]
recipe = slapos.cookbook:promise.plugin
eggs = slapos.core
file = {{ interface_up_promise }}
output = ${directory:plugins}/check-tun-up.py
config-ifname = ${slap-configuration:tun-name}
...@@ -4,7 +4,7 @@ parts = ...@@ -4,7 +4,7 @@ parts =
ltelogs ltelogs
lte-gnb-config lte-gnb-config
lte-enb-service lte-enb-service
# Temporarily extend monitor-base until promises are added sdr-busy-promise
monitor-base monitor-base
publish-connection-information publish-connection-information
...@@ -97,3 +97,10 @@ monitor-base-url = ${monitor-instance-parameter:monitor-base-url} ...@@ -97,3 +97,10 @@ monitor-base-url = ${monitor-instance-parameter:monitor-base-url}
[monitor-instance-parameter] [monitor-instance-parameter]
monitor-title = {{ slapparameter_dict['name'] | string }} monitor-title = {{ slapparameter_dict['name'] | string }}
password = {{ slapparameter_dict['monitor-password'] | string }} password = {{ slapparameter_dict['monitor-password'] | string }}
# Add custom promise to check if /dev/sdr0 is busy
[sdr-busy-promise]
recipe = slapos.cookbook:promise.plugin
eggs = slapos.core
file = {{ sdr_busy_promise }}
output = ${directory:plugins}/check-sdr-busy.py
...@@ -62,6 +62,7 @@ extra-context = ...@@ -62,6 +62,7 @@ extra-context =
raw enb ${enb:destination} raw enb ${enb:destination}
raw enb_template ${enb.jinja2.cfg:target} raw enb_template ${enb.jinja2.cfg:target}
raw ltelogs_template ${ltelogs.jinja2.sh:target} raw ltelogs_template ${ltelogs.jinja2.sh:target}
raw sdr_busy_promise ${sdr-busy-promise:target}
raw openssl_location ${openssl:location} raw openssl_location ${openssl:location}
raw default_dl_earfcn ${enb:default-dl-earfcn} raw default_dl_earfcn ${enb:default-dl-earfcn}
raw default_lte_dl_freq ${enb:default-lte-dl-freq} raw default_lte_dl_freq ${enb:default-lte-dl-freq}
...@@ -82,6 +83,7 @@ extra-context = ...@@ -82,6 +83,7 @@ extra-context =
raw enb ${enb:destination} raw enb ${enb:destination}
raw gnb_template ${gnb.jinja2.cfg:target} raw gnb_template ${gnb.jinja2.cfg:target}
raw ltelogs_template ${ltelogs.jinja2.sh:target} raw ltelogs_template ${ltelogs.jinja2.sh:target}
raw sdr_busy_promise ${sdr-busy-promise:target}
raw openssl_location ${openssl:location} raw openssl_location ${openssl:location}
raw default_dl_nr_arfcn ${enb:default-dl-nr-arfcn} raw default_dl_nr_arfcn ${enb:default-dl-nr-arfcn}
raw default_nr_band ${enb:default-nr-band} raw default_nr_band ${enb:default-nr-band}
...@@ -99,6 +101,7 @@ filename = instance-lte-epc.cfg ...@@ -99,6 +101,7 @@ filename = instance-lte-epc.cfg
extensions = jinja2.ext.do extensions = jinja2.ext.do
extra-context = extra-context =
raw monitor_template ${monitor2-template:rendered} raw monitor_template ${monitor2-template:rendered}
raw interface_up_promise ${interface-up-promise:target}
raw mme ${mme:destination} raw mme ${mme:destination}
raw mme_template ${mme.jinja2.cfg:target} raw mme_template ${mme.jinja2.cfg:target}
raw ims_template ${ims.jinja2.cfg:target} raw ims_template ${ims.jinja2.cfg:target}
......
import socket
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=2)
def sense(self):
"""
Called every time the promise is tested.
Signals a positive or negative result.
In this case, check whether the file exists.
"""
ifname = self.getConfig('ifname')
f = open('/sys/class/net/%s/operstate' % ifname, 'r')
if f.read() == 'up\n':
self.logger.info("%s is up", ifname)
else:
self.logger.error("%s is down", ifname)
f.close()
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=3, failure_amount=2)
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=2)
def sense(self):
"""
Called every time the promise is tested.
Signals a positive or negative result.
In this case, check whether the file exists.
"""
sdr_dev = '/dev/sdr0'
try:
open(sdr_dev, 'w').close()
self.logger.error("eNB is not using %s", sdr_dev)
except IOError as e:
if e.errno == errno.EBUSY:
self.logger.info("eNB is using %s", sdr_dev)
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=3, failure_amount=2)
...@@ -49,6 +49,12 @@ url = ${:_profile_base_location_}/${:_update_hash_filename_} ...@@ -49,6 +49,12 @@ url = ${:_profile_base_location_}/${:_update_hash_filename_}
[template-lte-epc] [template-lte-epc]
<= download-base <= download-base
[sdr-busy-promise]
<= download-base
[interface-up-promise]
<= download-base
[amarisoft] [amarisoft]
recipe = slapos.recipe.build recipe = slapos.recipe.build
path = /opt/amarisoft/lte path = /opt/amarisoft/lte
......
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