forked from medianetlab/NEF_emulator
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request medianetlab#91 from medianetlab/develop
Develop
- Loading branch information
Showing
5 changed files
with
61 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="[email protected]" | ||
) | ||
|
||
|
||
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__": | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="[email protected]" | ||
) | ||
|
||
|
||
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__": | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters