--- /dev/null
+# https://help.github.com/articles/dealing-with-line-endings/
+
+# Set the default behavior, in case people don't have core.autocrlf set.
+* text=auto
+
+# Explicitly declare text files you want to always be normalized
+# and converted to native line endings on checkout.
+*.css text
+*.htm text diff=html
+*.html text diff=html
+*.java text diff=java
+*.js text
+*.jsp text
+*.less text
+*.properties text
+*.sql text
+*.xml text
+
+# Denote all files that are truly binary and should not be modified.
+*.png binary
+*.jpg binary
--- /dev/null
+# misc cruft
+*.log
+log.txt
+rmr/*
+docs_and_diagrams/
+
+# documentation
+.tox
+docs/_build/
+
+# standard python ignore template
+.pytest_cache/
+xunit-results.xml
+.DS_Store
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+venv-tox/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*,cover
+.hypothesis/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# IPython Notebook
+.ipynb_checkpoints
+
+# pyenv
+.python-version
+
+# celery beat schedule file
+celerybeat-schedule
+
+# dotenv
+.env
+
+# virtualenv
+venv/
+ENV/
+
+# Spyder project settings
+.spyderproject
+
+# Rope project settings
+.ropeproject
+
+# Test report
+xunit-reports
+coverage-reports
+
+# Eclipse
+.project
+.pydevproject
+.settings
--- /dev/null
+# ==================================================================================
+# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==================================================================================
+FROM python:3.8-alpine
+
+# copy rmr libraries from builder image in lieu of an Alpine package
+COPY --from=nexus3.o-ran-sc.org:10002/o-ran-sc/bldr-alpine3-rmr:4.0.5 /usr/local/lib64/librmr* /usr/local/lib64/
+# RMR setup
+RUN mkdir -p /opt/route/
+COPY resources/test_route.rt /opt/route/test_route.rt
+ENV LD_LIBRARY_PATH /usr/local/lib/:/usr/local/lib64
+ENV RMR_SEED_RT /opt/route/test_route.rt
+
+# sdl needs gcc
+RUN apk update && apk add gcc musl-dev bash
+
+# Install
+COPY setup.py /tmp
+COPY LICENSE.txt /tmp/
+COPY src/ /tmp/src
+RUN pip install /tmp
+
+# Run
+ENV PYTHONUNBUFFERED 1
+CMD run-hw-python.py
--- /dev/null
+
+ Unless otherwise specified, all software contained herein is licensed
+ under the Apache License, Version 2.0 (the "Software License");
+ you may not use this software except in compliance with the Software
+ License. You may obtain a copy of the Software License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the Software License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the Software License for the specific language governing permissions
+ and limitations under the Software License.
+
+
+
+ Unless otherwise specified, all documentation contained herein is licensed
+ under the Creative Commons License, Attribution 4.0 Intl. (the
+ "Documentation License"); you may not use this documentation except in
+ compliance with the Documentation License. You may obtain a copy of the
+ Documentation License at
+
+ https://creativecommons.org/licenses/by/4.0/
+
+ Unless required by applicable law or agreed to in writing, documentation
+ distributed under the Documentation License is distributed on an "AS IS"
+ BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the Documentation License for the specific language governing
+ permissions and limitations under the Documentation License.
--- /dev/null
+apiVersion: v1
+kind: Pod
+metadata:
+ name: hwxapp
+ labels:
+ role: xapp
+spec:
+ containers:
+ - name: hwxapp-py
+ image: hwxapp-py:1.0
+ ports:
+ - name: rmr
+ containerPort: 4560
+ protocol: TCP
--- /dev/null
+newrt|start
+rte|13111|127.0.0.1:4560
+newrt|end
--- /dev/null
+# ==================================================================================
+#
+# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==================================================================================
+
+from setuptools import setup, find_packages
+
+setup(
+ name='hw_python',
+ version='0.0.1',
+ packages=find_packages(),
+ url='https://gerrit.o-ran-sc.org/r/admin/repos/ric-app/hw-python',
+ license='Apache 2.0',
+ install_requires=["ricxappframe>=1.1.1,<2.0.0"],
+ entry_points={"console_scripts": ["run-hw-python.py=src.main:start"]}, # adds a magical entrypoint for Docker
+ data_files=[("", ["LICENSE.txt"])],
+)
+
--- /dev/null
+# ==================================================================================
+#
+# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==================================================================================
--- /dev/null
+# ==================================================================================
+#
+# Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ==================================================================================
+
+import json
+from os import getenv
+from ricxappframe.xapp_frame import RMRXapp, rmr
+from ricxappframe.alarm import alarm
+
+
+# pylint: disable=invalid-name
+rmr_xapp = None
+
+
+def post_init(self):
+ """
+ Function that runs when xapp initialization is complete
+ """
+ self.logger.info("post_init called")
+
+def handle_config_change(self, config):
+ """
+ Function that runs at start and on every configuration file change.
+ """
+ self.logger.info("handle_config_change: config: {}".format(config))
+
+
+def default_handler(self, summary, sbuf):
+ """
+ Function that processes messages for which no handler is defined
+ """
+ self.logger.info("default_handler called")
+ self.rmr_free(sbuf)
+
+
+def start(thread=False):
+ """
+ This is a convenience function that allows this xapp to run in Docker
+ for "real" (no thread, real SDL), but also easily modified for unit testing
+ (e.g., use_fake_sdl). The defaults for this function are for the Dockerized xapp.
+ """
+ global rmr_xapp
+ fake_sdl = getenv("USE_FAKE_SDL", True)
+ config_file = getenv("CONFIG_FILE", None)
+ rmr_xapp = RMRXapp(default_handler,
+ config_handler=handle_config_change,
+ rmr_port=4560,
+ post_init=post_init,
+ use_fake_sdl=bool(fake_sdl))
+ rmr_xapp.run(thread)
+
+
+def stop():
+ """
+ can only be called if thread=True when started
+ TODO: could we register a signal handler for Docker SIGTERM that calls this?
+ """
+ rmr_xapp.stop()
+
+if __name__ == "__main__":
+ start()