diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03f7a98f..6559dda1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,9 @@
# Changelog
+## v2.2.3
+***Summary:***
+> - *Minor fixes on service initialisation*
+
+
## v2.2.2
***Summary:***
> - *Split jwt token authorisation for NEF and CAPIF. If NEF is deployed as a standalone component then only nef token authorisation is required. If capif is integrated with nef, jwt token acquired from CAPIF is required [commit](https://github.com/medianetlab/NEF_emulator/commit/16483f55d2d14b61d804c00eb8774119e6acffdc)*
diff --git a/backend/app/app/backend_pre_start.py b/backend/app/app/backend_pre_start.py
index 325a9151..94974480 100644
--- a/backend/app/app/backend_pre_start.py
+++ b/backend/app/app/backend_pre_start.py
@@ -1,8 +1,7 @@
-import logging, requests
-from evolved5g.sdk import CAPIFProviderConnector
+import logging
from tenacity import after_log, before_log, retry, stop_after_attempt, wait_fixed
from app.db.session import SessionLocal
-from app.core.config import settings
+
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
@@ -26,57 +25,13 @@ def init() -> None:
logger.error(e)
raise e
-def capif_nef_connector():
- """
-
- """
- try:
- capif_connector = CAPIFProviderConnector(certificates_folder="app/core/certificates",
- capif_host=settings.CAPIF_HOST,
- capif_http_port=settings.CAPIF_HTTP_PORT,
- capif_https_port=settings.CAPIF_HTTPS_PORT,
- capif_netapp_username="test_nef01",
- capif_netapp_password="test_netapp_password",
- description= "test_app_description",
- csr_common_name="apfExpapfoser1502", #TODO: ASK STAVROS. THIS SHOULD NOT BE HARDCODED, RIGHT?
- csr_organizational_unit="test_app_ou",
- csr_organization="test_app_o",
- crs_locality="Madrid",
- csr_state_or_province_name="Madrid",
- csr_country_name="ES",
- csr_email_address="test@example.com"
- )
-
-
- capif_connector.register_and_onboard_provider()
- capif_connector.publish_services(service_api_description_json_full_path="app/core/capif_files/service_monitoring_event.json")
- capif_connector.publish_services(service_api_description_json_full_path="app/core/capif_files/service_as_session_with_qos.json")
- return True
- except requests.exceptions.HTTPError as err:
- if err.response.status_code == 409:
- logger.error(f'"Http Error:", {err.response.json()}')
- return False
- except requests.exceptions.ConnectionError as err:
- logger.error(f'"Error Connecting:", {err}')
- return False
- except requests.exceptions.Timeout as err:
- logger.error(f'"Timeout Error:", {err}')
- return False
- except requests.exceptions.RequestException as err:
- logger.error(f'"Error:", {err}')
- return False
def main() -> None:
logger.info("Initializing service")
init()
logger.info("Service finished initializing")
- logger.info("Trying to connect with CAPIF Core Function")
- if capif_nef_connector():
- logger.info("Successfully onboard NEF in the CAPIF Core Function")
- else:
- logger.info("Failed to onboard NEF in the CAPIF Core Function")
if __name__ == "__main__":
diff --git a/backend/app/app/initial_data.py b/backend/app/app/initial_data.py
index 9dc3d9c3..40ac067b 100644
--- a/backend/app/app/initial_data.py
+++ b/backend/app/app/initial_data.py
@@ -1,7 +1,8 @@
-import logging, json, os
-
+import logging, json, os, requests
+from evolved5g.sdk import CAPIFProviderConnector
from app.db.init_db import init_db
from app.db.session import SessionLocal
+from app.core.config import settings
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
@@ -11,6 +12,48 @@ def init() -> None:
db = SessionLocal()
init_db(db)
+
+def capif_nef_connector():
+ """
+
+ """
+ try:
+ capif_connector = CAPIFProviderConnector(certificates_folder="app/core/certificates",
+ capif_host=settings.CAPIF_HOST,
+ capif_http_port=settings.CAPIF_HTTP_PORT,
+ capif_https_port=settings.CAPIF_HTTPS_PORT,
+ capif_netapp_username="test_nef01",
+ capif_netapp_password="test_netapp_password",
+ description= "test_app_description",
+ csr_common_name="apfExpapfoser1502", #TODO: ASK STAVROS. THIS SHOULD NOT BE HARDCODED, RIGHT?
+ csr_organizational_unit="test_app_ou",
+ csr_organization="test_app_o",
+ crs_locality="Madrid",
+ csr_state_or_province_name="Madrid",
+ csr_country_name="ES",
+ csr_email_address="test@example.com"
+ )
+
+
+ capif_connector.register_and_onboard_provider()
+
+ capif_connector.publish_services(service_api_description_json_full_path="app/core/capif_files/service_monitoring_event.json")
+ capif_connector.publish_services(service_api_description_json_full_path="app/core/capif_files/service_as_session_with_qos.json")
+ return True
+ except requests.exceptions.HTTPError as err:
+ if err.response.status_code == 409:
+ logger.error(f'"Http Error:", {err.response.json()}')
+ return False
+ except requests.exceptions.ConnectionError as err:
+ logger.error(f'"Error Connecting:", {err}')
+ return False
+ except requests.exceptions.Timeout as err:
+ logger.error(f'"Timeout Error:", {err}')
+ return False
+ except requests.exceptions.RequestException as err:
+ logger.error(f'"Error:", {err}')
+ return False
+
def capif_service_description() -> None:
try:
@@ -74,6 +117,11 @@ def main() -> None:
init()
capif_service_description()
logger.info("Initial data created")
+ logger.info("Trying to connect with CAPIF Core Function")
+ if capif_nef_connector():
+ logger.info("Successfully onboard NEF in the CAPIF Core Function")
+ else:
+ logger.info("Failed to onboard NEF in the CAPIF Core Function")
if __name__ == "__main__":
diff --git a/backend/app/prestart.sh b/backend/app/prestart.sh
index 7d0a2464..393f332e 100755
--- a/backend/app/prestart.sh
+++ b/backend/app/prestart.sh
@@ -1,10 +1,10 @@
#! /usr/bin/env bash
-# Create initial data in DB
-python /app/app/initial_data.py
-
# Let the DB start
python /app/app/backend_pre_start.py
+# Create initial data in DB
+python /app/app/initial_data.py
+
# Run migrations
#alembic upgrade head
diff --git a/docker-compose.yml b/docker-compose.yml
index e7db6aff..f33551ec 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -83,6 +83,7 @@ services:
INSTALL_JUPYTER: ${INSTALL_JUPYTER-true}
extra_hosts:
- "host.docker.internal:host-gateway"
+ restart: always
networks:
- services_default