aboutsummaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java3
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java12
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java17
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java11
-rw-r--r--adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java4
-rw-r--r--adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java5
6 files changed, 42 insertions, 10 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..fb880a91e3 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,18 @@ public abstract class BaseNssmfManager implements NssmfManager {
private ResourceOperationStatus getOperationStatus(String nsiId, String jobId, String serviceUuid) {
+ logger.info("Query operations: nsiId = [{}], jobId = [{}], serviceUuid = [{}]", nsiId, jobId, serviceUuid);
+
ResourceOperationStatus status = new ResourceOperationStatus(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..4b0e98e8ec 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,6 +232,8 @@ 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");
updateDbStatus(status, restResponse.getStatus(), STARTED, NssmfAdapterUtil.getStatusDesc(actionType));
}
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..f150f47f4f 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,9 @@ 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"
+ " \"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"
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..68adf8073b 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
@@ -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);