From: Bin Yang Date: Mon, 24 Jan 2022 06:15:55 +0000 (+0800) Subject: Validate nfdeployment descriptor params X-Git-Tag: 2.0.0-rc1~57 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=e0e98d8c53a14158105375aa84f489602caa93a8;p=pti%2Fo2.git Validate nfdeployment descriptor params Issue-ID: INF-258 Signed-off-by: Bin Yang Change-Id: I8c8891c4236272f273fc66446770e02857728853 --- diff --git a/o2dms/api/dms_lcm_nfdeploymentdesc.py b/o2dms/api/dms_lcm_nfdeploymentdesc.py index 02621d6..e5b66ca 100644 --- a/o2dms/api/dms_lcm_nfdeploymentdesc.py +++ b/o2dms/api/dms_lcm_nfdeploymentdesc.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json from sqlalchemy import select import uuid from o2common.service import unit_of_work @@ -58,11 +59,27 @@ def lcm_nfdeploymentdesc_create( id, input['name'], deploymentManagerId, input['description'], input['inputParams'], input['outputParams'], input['artifactRepoUrl'], input['artifactName']) + _nfdeploymentdesc_validate(entity) uow.nfdeployment_descs.add(entity) uow.commit() return id +def _nfdeploymentdesc_validate(desc: NfDeploymentDesc): + try: + json.loads( + desc['inputParams']) if desc['inputParams'] else None + json.loads( + desc['outputParams']) if desc['outputParams'] else None + return + except json.decoder.JSONDecodeError as e: + logger.debug("NfDeploymentDesc validate error with: %s" % (str(e))) + raise e + except Exception as e: + logger.debug("NfDeploymentDesc validate error with: %s" % (str(e))) + raise e + + def lcm_nfdeploymentdesc_update( nfdeploymentdescriptorid: str, input: DmsLcmNfDeploymentDescriptorDTO.NfDeploymentDescriptor_update,