X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2dms%2Fapi%2Fdms_lcm_nfdeploymentdesc.py;h=80245740ed371df0b23761c7b290ff67dc524d94;hb=98c86a07982d8405aabc7f0e64782d1b91ac4cf4;hp=5ed98b76c212ac69c6761c3e2d69b79f5c446740;hpb=5ad82f634e2f10aaeccf1d2420fafc63e2d0056e;p=pti%2Fo2.git diff --git a/o2dms/api/dms_lcm_nfdeploymentdesc.py b/o2dms/api/dms_lcm_nfdeploymentdesc.py index 5ed98b7..8024574 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 @@ -56,12 +57,35 @@ def lcm_nfdeploymentdesc_create( id = str(uuid.uuid4()) entity = NfDeploymentDesc( id, input['name'], deploymentManagerId, input['description'], - input['inputParams'], input['outputParams'], input['artifactUrl']) + 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: + if desc.inputParams: + json.loads(desc.inputParams) + if desc.outputParams: + json.loads(desc.outputParams) + if not desc.deploymentManagerId: + raise Exception("Invalid deploymentManager Id") + if not desc.artifactRepoUrl: + raise Exception("Invalid artifactRepoUrl") + if not desc.artifactName: + raise Exception("Invalid artifactName") + return + except json.decoder.JSONDecodeError as e: + logger.debug("NfDeploymentDesc json 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, @@ -73,7 +97,8 @@ def lcm_nfdeploymentdesc_update( entity.description = input['description'] entity.inputParams = input['inputParams'] entity.outputParams = input['outputParams'] - entity.artifactUrl = input['artifactUrl'] + entity.artifactRepoUrl = input['artifactRepoUrl'] + entity.artifactName = input['artifactName'] uow.commit() return True