From 659a526fb149407f1bc7c598e1943195915dcbd6 Mon Sep 17 00:00:00 2001 From: "Zhang Rong(Jon)" Date: Fri, 21 Jan 2022 14:12:38 +0800 Subject: [PATCH] Docs: update the dms v1 path changes; Fix INF-254 through retry 1. Update documents about the dms v1 endpoint changes 2. Add retry for the database mapper creation Issue-ID: INF-254 Signed-off-by: Zhang Rong(Jon) Change-Id: I5115cdb8333c720ed060032146135071eead7be5 --- README.md | 10 +++---- docs/api.rst | 48 ++++++++++++++++++---------------- docs/installation-guide.rst | 2 +- docs/user-guide.rst | 14 +++++----- o2app/bootstrap.py | 12 +++++++-- o2app/entrypoints/flask_application.py | 5 ++-- 6 files changed, 50 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 3f15087..01d9710 100644 --- a/README.md +++ b/README.md @@ -264,7 +264,7 @@ docker logs -f o2_redis_pubsub_1 curl --location --request GET 'http://localhost:5005/o2ims_infrastructureInventory/v1/deploymentManagers' export dmsId= -curl --location --request POST 'http://localhost:5005/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor' \ +curl --location --request POST 'http://localhost:5005/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor' \ --header 'Content-Type: application/json' \ --data-raw '{ "name": "cfwdesc1", @@ -276,9 +276,9 @@ curl --location --request POST 'http://localhost:5005/o2dms/${dmsId}/O2dms_Deplo "outputParams": "{\"output1\": 100}" }' -curl --location --request GET 'http://localhost:5005/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor' +curl --location --request GET 'http://localhost:5005/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor' -curl --location --request POST 'http://localhost:5005/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment' \ +curl --location --request POST 'http://localhost:5005/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment' \ --header 'Content-Type: application/json' \ --data-raw '{ "name": "cfw100", @@ -287,7 +287,7 @@ curl --location --request POST 'http://localhost:5005/o2dms/${dmsId}/O2dms_Deplo "parentDeploymentId": "" }' -curl --location --request GET 'http://localhost:5005/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment' +curl --location --request GET 'http://localhost:5005/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment' export NfDeploymentId= @@ -309,5 +309,5 @@ open browswer with url: http://:30667 ## bring down CFW ```sh -curl --location --request DELETE 'http://localhost:5005/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment/${NfDeploymentId}' +curl --location --request DELETE 'http://localhost:5005/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment/${NfDeploymentId}' ``` diff --git a/docs/api.rst b/docs/api.rst index e593221..4763897 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -12,7 +12,7 @@ INF O2 Services API 1.0.0 Description ~~~~~~~~~~~ -Swagger OpenAPI document for INF O2 Services +Swagger OpenAPI document for the INF O2 Services @@ -33,8 +33,8 @@ DMS LCM related operations. -POST ``/o2dms/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeployment`` ----------------------------------------------------------------------------- +POST ``/o2dms/v1/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeployment`` +------------------------------------------------------------------------------- @@ -116,8 +116,8 @@ DMS LCM not found -POST ``/o2dms/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor`` --------------------------------------------------------------------------------------- +POST ``/o2dms/v1/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor`` +----------------------------------------------------------------------------------------- @@ -203,8 +203,8 @@ DMS LCM not found -DELETE ``/o2dms/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeployment/{nfDeploymentId}`` ------------------------------------------------------------------------------------------------ +DELETE ``/o2dms/v1/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeployment/{nfDeploymentId}`` +-------------------------------------------------------------------------------------------------- @@ -244,8 +244,8 @@ DMS LCM not found -DELETE ``/o2dms/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor/{nfDeploymentDescriptorId}`` -------------------------------------------------------------------------------------------------------------------- +DELETE ``/o2dms/v1/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor/{nfDeploymentDescriptorId}`` +---------------------------------------------------------------------------------------------------------------------- @@ -285,8 +285,8 @@ DMS LCM not found -GET ``/o2dms/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeployment/{nfDeploymentId}`` --------------------------------------------------------------------------------------------- +GET ``/o2dms/v1/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeployment/{nfDeploymentId}`` +----------------------------------------------------------------------------------------------- @@ -349,8 +349,8 @@ DMS LCM not found -GET ``/o2dms/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor/{nfDeploymentDescriptorId}`` ----------------------------------------------------------------------------------------------------------------- +GET ``/o2dms/v1/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor/{nfDeploymentDescriptorId}`` +------------------------------------------------------------------------------------------------------------------- @@ -414,8 +414,8 @@ DMS LCM not found -GET ``/o2dms/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeployment`` ---------------------------------------------------------------------------- +GET ``/o2dms/v1/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeployment`` +------------------------------------------------------------------------------ @@ -488,8 +488,8 @@ DMS LCM not found -GET ``/o2dms/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor`` -------------------------------------------------------------------------------------- +GET ``/o2dms/v1/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor`` +---------------------------------------------------------------------------------------- @@ -564,8 +564,8 @@ DMS LCM not found -GET ``/o2dms/{deploymentManagerID}`` ------------------------------------- +GET ``/o2dms/v1/{deploymentManagerID}`` +--------------------------------------- @@ -627,8 +627,8 @@ Deployment manager not found -PUT ``/o2dms/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeployment/{nfDeploymentId}`` --------------------------------------------------------------------------------------------- +PUT ``/o2dms/v1/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeployment/{nfDeploymentId}`` +----------------------------------------------------------------------------------------------- @@ -685,8 +685,8 @@ DMS LCM not found -PUT ``/o2dms/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor/{nfDeploymentDescriptorId}`` ----------------------------------------------------------------------------------------------------------------- +PUT ``/o2dms/v1/{deploymentManagerID}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor/{nfDeploymentDescriptorId}`` +------------------------------------------------------------------------------------------------------------------- @@ -1529,6 +1529,8 @@ Parameters :header: "Name", "Located in", "Required", "Type", "Format", "Properties", "Description" :widths: 20, 15, 10, 10, 10, 20, 30 + parentId | query | No | string | | | filter parentId + resourceTypeName | query | No | string | | | filter resource type resourcePoolID | path | Yes | string | | | ID of the resource pool diff --git a/docs/installation-guide.rst b/docs/installation-guide.rst index 3c92bd3..68f7ed0 100644 --- a/docs/installation-guide.rst +++ b/docs/installation-guide.rst @@ -136,7 +136,7 @@ The following instruction should be done outside of INF platform controller host export OS_PASSWORD= # If the external OAM IP same as OS_AUTH_URL's IP address, you can use the below command to set the environment - # export API_HOST_EXTERNAL_FLOATING=$(echo ${OS_AUTH_URL/$(echo ${OS_AUTH_URL} | grep :// | sed -e's,^\(.*//\).*,\1,g')} | cut -d/ -f1 | sed -e 's,:.*,,g') + # export API_HOST_EXTERNAL_FLOATING=$(echo ${OS_AUTH_URL} | sed -e s,`echo ${OS_AUTH_URL} | grep :// | sed -e's,^\(.*//\).*,\1,g'`,,g | cut -d/ -f1 | sed -e 's,:.*,,g') export API_HOST_EXTERNAL_FLOATING= cat <o2service-override.yaml diff --git a/docs/user-guide.rst b/docs/user-guide.rst index d1559d8..ca4a19f 100644 --- a/docs/user-guide.rst +++ b/docs/user-guide.rst @@ -208,7 +208,7 @@ SMO. .. code:: bash - curl --location --request POST "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor" \ + curl --location --request POST "http://${OAM_IP}:30205/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor" \ --header 'Content-Type: application/json' \ --data-raw '{ "name": "cfwdesc1", @@ -220,9 +220,9 @@ SMO. "outputParams": "{\"output1\": 100}" }' - curl --location --request GET "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor" + curl --location --request GET "http://${OAM_IP}:30205/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor" - export descId=` curl -X 'GET' "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor" -H 'accept: application/json' -H 'X-Fields: id' 2>/dev/null | jq .[].id | xargs echo` + export descId=` curl -X 'GET' "http://${OAM_IP}:30205/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor" -H 'accept: application/json' -H 'X-Fields: id' 2>/dev/null | jq .[].id | xargs echo` echo ${descId} # check the exported descriptor id @@ -234,7 +234,7 @@ SMO. .. code:: bash - curl --location --request POST "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment" \ + curl --location --request POST "http://${OAM_IP}:30205/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment" \ --header 'Content-Type: application/json' \ --data-raw '{ "name": "cfw100", @@ -243,7 +243,7 @@ SMO. "parentDeploymentId": "" }' - curl --location --request GET "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment" + curl --location --request GET "http://${OAM_IP}:30205/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment" - Check pods of the firewall sample @@ -255,8 +255,8 @@ SMO. .. code:: shell - export NfDeploymentId=`curl --location --request GET "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment" 2>/dev/null | jq .[].id | xargs echo` + export NfDeploymentId=`curl --location --request GET "http://${OAM_IP}:30205/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment" 2>/dev/null | jq .[].id | xargs echo` echo ${NfDeploymentId} # Check the exported deployment id - curl --location --request DELETE "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment/${NfDeploymentId}" + curl --location --request DELETE "http://${OAM_IP}:30205/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment/${NfDeploymentId}" diff --git a/o2app/bootstrap.py b/o2app/bootstrap.py index 329d9e2..4413e80 100644 --- a/o2app/bootstrap.py +++ b/o2app/bootstrap.py @@ -40,6 +40,15 @@ def wait_for_db_ready(engine): logger.info("DB is ready") +@retry(tries=3, delay=2) +def wait_for_mappers_ready(engine): + # wait for mapper ready + logger.info("Wait for mapper ready ...") + o2ims_orm.start_o2ims_mappers(engine) + o2dms_orm.start_o2dms_mappers(engine) + logger.info("mapper is ready") + + def bootstrap( start_orm: bool = True, uow: unit_of_work.AbstractUnitOfWork = SqlAlchemyUnitOfWork(), @@ -56,8 +65,7 @@ def bootstrap( engine = uow.session.get_bind() wait_for_db_ready(engine) - o2ims_orm.start_o2ims_mappers(engine) - o2dms_orm.start_o2dms_mappers(engine) + wait_for_mappers_ready(engine) dependencies = {"uow": uow, "notifications": notifications, "publish": publish} diff --git a/o2app/entrypoints/flask_application.py b/o2app/entrypoints/flask_application.py index cb12fb4..cde0715 100644 --- a/o2app/entrypoints/flask_application.py +++ b/o2app/entrypoints/flask_application.py @@ -24,9 +24,8 @@ from o2dms.api import configure_namespace as dms_route_configure_namespace app = Flask(__name__) app.config.SWAGGER_UI_DOC_EXPANSION = 'list' api = Api(app, version='1.0.0', - title='INF O2 Services', - description='Swagger OpenAPI document for \ - the INF O2 Services', + title='INF O2 Services API', + description='Swagger OpenAPI document for the INF O2 Services', ) bus = bootstrap.bootstrap() -- 2.16.6