diff options
Diffstat (limited to 'adapters/mso-nssmf-adapter/src')
10 files changed, 145 insertions, 34 deletions
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java index 84e1eb2acc..1e3c76cdde 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java @@ -91,8 +91,7 @@ public class NssmfAdapterConsts { private final static String INTERNAL_MODIFY_URL = "/onap/so/infra/3gppservices/{apiVersion}/modify"; // - private final static String EXTERNAL_QUERY_JOB_STATUS = - "/api/rest/provMns/{apiVersion}/NSS/jobs/{jobId}?responseId={responseId}"; + private final static String EXTERNAL_QUERY_JOB_STATUS = "/api/rest/provMns/{apiVersion}/NSS/jobs/{jobId}"; private final static String INTERNAL_QUERY_SUB_NET_CAPABILITY = "/onap/so/infra/3gppservices/{apiVersion}/subnetCapabilityQuery"; diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java index 9df20bac1c..530cc1be0d 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java @@ -24,6 +24,9 @@ import lombok.Getter; @Getter public enum ActionType { + /** + * allocate + */ ALLOCATE("allocate"), DEALLOCATE("deallocate"), @@ -52,4 +55,13 @@ public enum ActionType { ActionType(String type) { this.type = type; } + + public static ActionType getActionType(String value) { + for (ActionType actionType : ActionType.values()) { + if (actionType.type.equalsIgnoreCase(value)) { + return actionType; + } + } + return null; + } } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java index 2de6e01693..0456c90fae 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java @@ -31,14 +31,19 @@ import org.onap.so.adapters.nssmf.util.RestUtil; import org.onap.so.beans.nsmf.*; import org.onap.so.db.request.beans.ResourceOperationStatus; import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.data.domain.Example; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; public abstract class BaseNssmfManager implements NssmfManager { + private static final Logger logger = LoggerFactory.getLogger(BaseNssmfManager.class); + protected RestUtil restUtil; protected ResourceOperationStatusRepository repository; @@ -152,6 +157,7 @@ public abstract class BaseNssmfManager implements NssmfManager { ResourceOperationStatus status = getOperationStatus(serviceInfo.getNsiId(), jobId, serviceInfo.getServiceUuid()); + logger.info("ResourceOperationStatus = {}", status); this.restResponse = doQueryJobStatus(status); afterQueryJobStatus(status); @@ -165,11 +171,16 @@ public abstract class BaseNssmfManager implements NssmfManager { private ResourceOperationStatus getOperationStatus(String nsiId, String jobId, String serviceUuid) { - ResourceOperationStatus status = new ResourceOperationStatus(nsiId, jobId, serviceUuid); + logger.info("Query operations: nsiId = [{}], jobId = [{}], serviceUuid = [{}]", nsiId, jobId, serviceUuid); - Optional<ResourceOperationStatus> optional = repository.findOne(Example.of(status)); + List<ResourceOperationStatus> resourceOperationStatuses = + repository.findByServiceIdAndOperationId(nsiId, jobId); - return optional.orElse(null); + logger.info("resourceOperationStatuses = {}", resourceOperationStatuses); + if (resourceOperationStatuses.size() == 0) { + return null; + } + return resourceOperationStatuses.get(0); } @Override diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java index 3c5be7eb39..7ec6c0f9e1 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java @@ -75,8 +75,9 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { @Override protected void afterQueryJobStatus(ResourceOperationStatus status) { + logger.info("afterQueryJobStatus = " + status); if (Integer.parseInt(status.getProgress()) == 100) { - + logger.info("after query finished = " + status); ActionType jobOperType = ActionType.valueOf(status.getOperType()); if (ActionType.ALLOCATE.equals(jobOperType)) { @@ -118,6 +119,8 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { JobStatusResponse jobStatusResponse = unMarshal(restResponse.getResponseContent(), JobStatusResponse.class); ResponseDescriptor rspDesc = jobStatusResponse.getResponseDescriptor(); + + logger.info("status = {}", status); rspDesc.setNssiId(status.getResourceInstanceID()); jobStatusResponse.setResponseDescriptor(rspDesc); @@ -152,7 +155,7 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { protected void updateRequestDbJobStatus(ResponseDescriptor rspDesc, ResourceOperationStatus status, RestResponse rsp) throws ApplicationException { - + status.setProgress(Integer.toString(rspDesc.getProgress())); switch (fromString(rspDesc.getStatus())) { case STARTED: updateDbStatus(status, rsp.getStatus(), STARTED, QUERY_JOB_STATUS_SUCCESS); @@ -168,6 +171,8 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { case ERROR: updateDbStatus(status, rsp.getStatus(), ERROR, QUERY_JOB_STATUS_FAILED); throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED); + default: + throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED); } } @@ -227,7 +232,11 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { ResourceOperationStatus status = new ResourceOperationStatus(serviceInfo.getNsiId(), response.getJobId(), serviceInfo.getServiceUuid()); status.setResourceInstanceID(response.getNssiId()); + status.setOperType(actionType.toString()); + status.setProgress("0"); + response.setStatus(STARTED.toString()); + restResponse.setResponseContent(marshal(response)); updateDbStatus(status, restResponse.getStatus(), STARTED, NssmfAdapterUtil.getStatusDesc(actionType)); } } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java index e89160c4ae..64ab199bc1 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java @@ -66,19 +66,20 @@ public abstract class InternalNssmfManager extends BaseNssmfManager { } private RestResponse responseDBStatus(ResourceOperationStatus status) throws ApplicationException { + JobStatusResponse statusResponse = new JobStatusResponse(); ResponseDescriptor descriptor = new ResponseDescriptor(); if (status == null) { descriptor.setProgress(0); descriptor.setStatus(PROCESSING.name()); descriptor.setStatusDescription("Initiating Nssi Instance"); - return restUtil.createResponse(200, marshal(descriptor)); + } else { + descriptor.setStatus(status.getStatus()); + descriptor.setStatusDescription(status.getStatusDescription()); + descriptor.setProgress(Integer.parseInt(status.getProgress())); + descriptor.setNssiId(status.getResourceInstanceID()); } - descriptor.setStatus(status.getStatus()); - descriptor.setStatusDescription(status.getStatusDescription()); - descriptor.setProgress(Integer.parseInt(status.getProgress())); - descriptor.setNssiId(status.getResourceInstanceID()); - // descriptor.setResponseId(status.getOperationId()); - return restUtil.createResponse(200, marshal(descriptor)); + statusResponse.setResponseDescriptor(descriptor); + return restUtil.createResponse(200, marshal(statusResponse)); } @Override diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java index c51b72d61e..3d0d0926fd 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java @@ -27,6 +27,7 @@ import org.onap.so.adapters.nssmf.enums.SelectionType; import org.onap.so.adapters.nssmf.exceptions.ApplicationException; import org.onap.so.adapters.nssmf.manager.impl.ExternalNssmfManager; import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; +import org.onap.so.beans.nsmf.AnSliceProfile; import org.onap.so.beans.nsmf.DeAllocateNssi; import org.onap.so.beans.nsmf.NssiResponse; import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest; @@ -47,7 +48,21 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager { @Override protected String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { Map<String, Object> request = new HashMap<>(); - request.put("attributeListIn", nbiRequest.getAllocateAnNssi().getSliceProfile()); + + AnSliceProfile anSliceProfile = nbiRequest.getAllocateAnNssi().getSliceProfile(); + + RanSliceProfile ranSliceProfile = new RanSliceProfile(); + ranSliceProfile.setSliceProfileId(anSliceProfile.getSliceProfileId()); + ranSliceProfile.setSNSSAIList(anSliceProfile.getSNSSAIList()); + ranSliceProfile.setPLMNIdList(anSliceProfile.getPLMNIdList()); + ranSliceProfile.setPerfReq(anSliceProfile.getPerfReq()); + ranSliceProfile.setMaxNumberofUEs(anSliceProfile.getMaxNumberOfUEs()); + ranSliceProfile.setCoverageAreaTAList(anSliceProfile.getCoverageAreaTAList()); + ranSliceProfile.setLatency(anSliceProfile.getLatency()); + ranSliceProfile.setUEMobilityLevel(anSliceProfile.getUeMobilityLevel()); + ranSliceProfile.setResourceSharingLevel(anSliceProfile.getResourceSharingLevel()); + + request.put("attributeListIn", ranSliceProfile); return marshal(request); } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/RanSliceProfile.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/RanSliceProfile.java new file mode 100644 index 0000000000..7035456d75 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/RanSliceProfile.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.nssmf.manager.impl.external; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import java.io.Serializable; +import java.util.List; +import org.onap.so.beans.nsmf.PerfReq; +import org.onap.so.beans.nsmf.UeMobilityLevel; +import org.onap.so.beans.nsmf.ResourceSharingLevel; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Data +public class RanSliceProfile implements Serializable { + /* + * Reference 3GPP TS 28.541 V16.5.0, Section 6.3.4. + */ + + private static final long serialVersionUID = 172447042469370448L; + + @JsonProperty(value = "sliceProfileId", required = true) + private String sliceProfileId; + + @JsonProperty(value = "sNSSAIList", required = true) + private List<String> sNSSAIList; + + @JsonProperty(value = "pLMNIdList", required = true) + private List<String> pLMNIdList; + + @JsonProperty(value = "perfReq", required = true) + private PerfReq perfReq; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + @JsonProperty(value = "maxNumberofUEs") + private long maxNumberofUEs; + + @JsonProperty(value = "coverageAreaTAList") + private List<Integer> coverageAreaTAList; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + @JsonProperty(value = "latency") + private int latency; + + @JsonProperty(value = "uEMobilityLevel") + private UeMobilityLevel uEMobilityLevel; + + @JsonProperty(value = "resourceSharingLevel") + private ResourceSharingLevel resourceSharingLevel; + +} diff --git a/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json b/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json index 8db52168ae..8753e85ea2 100644 --- a/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json +++ b/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json @@ -1,19 +1,10 @@ { "AN": { - "latency": "5", + "latency": 5, "maxNumberofUEs": "100" }, "CN": { - "latency": "10", + "latency": 5, "maxNumberofConns": "100" - }, - "TN_FH": { - "latency": "10" - }, - "TN_MH": { - "latency": "5" - }, - "TN_BH": { - "latency": "10" } } diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java index 2d79544383..f78bfd297a 100644 --- a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java +++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java @@ -77,9 +77,10 @@ public class NssmfAdapterRestTest { private final static String ALLOCATE = "{\n" + " \"esrInfo\" : {\n" + " \"vendor\" : \"huawei\",\n" + " \"networkType\" : \"cn\"\n" + " },\n" + " \"allocateCnNssi\" : {\n" + " \"nssiId\" : \"NSST-C-001-HDBNJ-NSSMF-01-A-ZX\",\n" + " \"nssiName\" : \"eMBB-001\",\n" - + " \"sliceProfile\" : {\n" + " \"sNSSAIList\" : [ \"001-100001\" ],\n" + + " \"sliceProfile\" : {\n" + " \"snssaiList\" : [ \"001-100001\" ],\n" + + " \"maxNumberofPDUSession\" : 10,\n" + " \"sliceProfileId\" : \"ab9af40f13f721b5f13539d87484098\",\n" - + " \"pLMNIdList\" : [ \"460-00\", \"460-01\" ],\n" + " \"perfReq\" : {\n" + + " \"plmnIdList\" : [ \"460-00\", \"460-01\" ],\n" + " \"perfReq\" : {\n" + " \"perfReqEmbbList\" : [ {\n" + " \"activityFactor\" : 50\n" + " } ]\n" + " },\n" + " \"maxNumberofUEs\" : 200,\n" + " \"coverageAreaTAList\" : [ \"1\", \"2\", \"3\" ],\n" + " \"latency\" : 6,\n" @@ -315,12 +316,13 @@ public class NssmfAdapterRestTest { taList.add("3"); sP.setSnssaiList(sns); sP.setSliceProfileId("ab9af40f13f721b5f13539d87484098"); - sP.setPlmnIdList(plmn); + sP.setPLMNIdList(plmn); sP.setPerfReq(perfReq); - sP.setMaxNumberofUEs(200); + sP.setMaxNumberOfUEs(200); sP.setCoverageAreaTAList(taList); sP.setLatency(6); sP.setResourceSharingLevel(NON_SHARED); + sP.setMaxNumberOfPDUSession(10); NsiInfo nsiInfo = new NsiInfo(); nsiInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); nsiInfo.setNsiName("eMBB-001"); diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java index 0d86056821..d7b3b03333 100644 --- a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java +++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java @@ -204,9 +204,9 @@ public class NssmfManagerServiceImplTest { taList.add("3"); sP.setSnssaiList(sns); sP.setSliceProfileId("ab9af40f13f721b5f13539d87484098"); - sP.setPlmnIdList(plmn); + sP.setPLMNIdList(plmn); sP.setPerfReq(perfReq); - sP.setMaxNumberofUEs(200); + sP.setMaxNumberOfUEs(200); sP.setCoverageAreaTAList(taList); sP.setLatency(6); sP.setResourceSharingLevel(NON_SHARED); @@ -361,9 +361,10 @@ public class NssmfManagerServiceImplTest { NssmfAdapterNBIRequest nbiRequest = createNbiRequest(); nbiRequest.setResponseId("7512eb3feb5249eca5ddd742fedddd39"); - Optional<ResourceOperationStatus> optional = Optional.of(operationStatus); + List<ResourceOperationStatus> optional = new ArrayList<>(); + optional.add(operationStatus); - doAnswer(invocation -> optional).when(repository).findOne(any()); + doAnswer(invocation -> optional).when(repository).findByServiceIdAndOperationId(any(), any()); createCommonMock(200, nssmf); |