diff options
Diffstat (limited to 'adapters/mso-nssmf-adapter/src')
16 files changed, 269 insertions, 38 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..a24f8ef0c7 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"; @@ -123,7 +122,7 @@ public class NssmfAdapterConsts { urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.ACTIVATE), new NssmfUrlInfo(EXTERNAL_CN_ACTIVATE_URL, HttpMethod.PUT)); urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.ACTIVATE), - new NssmfUrlInfo(INTERNAL_ACTIVATE_URL, HttpMethod.PUT)); + new NssmfUrlInfo(INTERNAL_ACTIVATE_URL, HttpMethod.POST)); urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.DEACTIVATE), new NssmfUrlInfo(EXTERNAL_AN_DEACTIVATE_URL, HttpMethod.PUT)); @@ -132,7 +131,7 @@ public class NssmfAdapterConsts { urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.DEACTIVATE), new NssmfUrlInfo(EXTERNAL_CN_DEACTIVATE_URL, HttpMethod.PUT)); urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.DEACTIVATE), - new NssmfUrlInfo(INTERNAL_DEACTIVATE_URL, HttpMethod.PUT)); + new NssmfUrlInfo(INTERNAL_DEACTIVATE_URL, HttpMethod.POST)); urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.TERMINATE), new NssmfUrlInfo(EXTERNAL_AN_TERMINATE_URL, HttpMethod.DELETE)); 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/extclients/aai/AaiServiceProvider.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java index 77662bf272..4df2fa16e1 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java @@ -33,6 +33,9 @@ public interface AaiServiceProvider { void invokeCreateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType, String serviceInstanceId); + void invokeUpdateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType, + String serviceInstanceId); + ServiceInstance invokeGetServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId); void invokeDeleteServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId); diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java index 1d7c42aafe..688012efe7 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java @@ -77,6 +77,14 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { } @Override + public void invokeUpdateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType, + String serviceInstanceId) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); + aaiClientProvider.getAaiClient().update(uri, nssiInstance); + } + + @Override public ServiceInstance invokeGetServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId) { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java index 0b332af607..e397201e4b 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java @@ -77,6 +77,12 @@ public class NssmfManagerBuilder { return; } + if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.TRANSPORT.equals(networkType)) { + this.nssmfManger = new ExternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType) + .setInitStatus("activated"); + return; + } + if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.ACCESS.equals(networkType)) { this.nssmfManger = new ExternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType) .setInitStatus("activated"); 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 789f4f239d..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 @@ -193,7 +204,7 @@ public abstract class BaseNssmfManager implements NssmfManager { return doQuerySubnetCapability(nbiRequest.getSubnetCapabilityQuery()); } - protected abstract <T> RestResponse doQuerySubnetCapability(T req) throws ApplicationException; + protected abstract RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException; /** * send request to nssmf 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 72d1b53781..7c4bd50852 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 @@ -20,7 +20,11 @@ package org.onap.so.adapters.nssmf.manager.impl; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.http.Header; +import org.apache.http.HttpStatus; import org.apache.http.message.BasicHeader; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.so.adapters.nssmf.entity.NssmfInfo; @@ -31,14 +35,23 @@ import org.onap.so.adapters.nssmf.exceptions.ApplicationException; import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; import org.onap.so.beans.nsmf.*; import org.onap.so.db.request.beans.ResourceOperationStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import static java.lang.String.valueOf; import static org.onap.so.adapters.nssmf.enums.JobStatus.*; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.*; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.QUERY_JOB_STATUS_FAILED; +import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.QUERY_JOB_STATUS_SUCCESS; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; public abstract class ExternalNssmfManager extends BaseNssmfManager { + private static final Logger logger = LoggerFactory.getLogger(ExternalNssmfManager.class); + @Override protected String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { return doWrapExtAllocateReqBody(nbiRequest); @@ -62,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)) { @@ -85,6 +99,7 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { restUtil.createServiceInstance(nssiInstance, serviceInfo); } else if (ActionType.DEALLOCATE.equals(jobOperType)) { + // TODO restUtil.deleteServiceInstance(serviceInfo); } } @@ -105,6 +120,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); @@ -139,7 +156,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); @@ -155,6 +172,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); } } @@ -167,11 +186,34 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { } @Override - protected <T> RestResponse doQuerySubnetCapability(T req) throws ApplicationException { - RestResponse response = new RestResponse(); - response.setStatus(200); - response.setResponseContent(null); - return response; + protected RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException { + + ObjectMapper oMapper = new ObjectMapper(); + InputStream inputStream = TypeReference.class.getResourceAsStream("/subnetCapability.json"); + Map subnetCapability = new HashMap<>(); + try { + subnetCapability = oMapper.readValue(inputStream, Map.class); + } catch (Exception e) { + logger.debug("Exception while reading subnet capability value from json", e); + } + Map<String, Object> responseMap = new HashMap<>(); + List<String> subnetTypes = req.getSubnetTypes(); + for (String value : subnetTypes) { + if (subnetCapability.containsKey(value)) { + responseMap.put(value, subnetCapability.get(value)); + } + } + String response = null; + try { + response = oMapper.writeValueAsString(responseMap); + } catch (JsonProcessingException e) { + logger.debug("Exception while converting subnet capability object to String {}", e.getMessage()); + } + + RestResponse rsp = new RestResponse(); + rsp.setStatus(HttpStatus.SC_OK); + rsp.setResponseContent(response); + return rsp; } /** @@ -191,7 +233,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 88b5071371..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 @@ -122,7 +123,7 @@ public abstract class InternalNssmfManager extends BaseNssmfManager { protected abstract String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; @Override - protected <T> RestResponse doQuerySubnetCapability(T req) throws ApplicationException { + protected RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException { // handler return sendRequest(marshal(req)); } 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..1af6d15c06 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; @@ -42,12 +43,29 @@ import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; public class ExternalAnNssmfManager extends ExternalNssmfManager { - private Map<String, String> bodyParams = new HashMap<>(); // request body params + /** + * request body params + */ + private Map<String, String> bodyParams = new HashMap<>(); @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); } @@ -78,7 +96,7 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager { status.setResourceInstanceID(nssiId); status.setOperType(actionType.toString()); - updateDbStatus(status, restResponse.getStatus(), JobStatus.FINISHED, + updateDbStatus(status, restResponse.getStatus(), JobStatus.STARTED, NssmfAdapterUtil.getStatusDesc(actionType)); } // todo @@ -110,7 +128,23 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager { @Override public RestResponse activateNssi(NssmfAdapterNBIRequest nbiRequest, String snssai) throws ApplicationException { // TODO - return null; + NssiResponse resp = new NssiResponse(); + String nssiId = nbiRequest.getActDeActNssi().getNssiId(); + resp.setJobId(UUID.randomUUID().toString()); + resp.setNssiId(nssiId); + + RestResponse returnRsp = new RestResponse(); + + returnRsp.setStatus(202); + returnRsp.setResponseContent(marshal(resp)); + + ResourceOperationStatus status = + new ResourceOperationStatus(serviceInfo.getNsiId(), resp.getJobId(), serviceInfo.getServiceUuid()); + status.setResourceInstanceID(nssiId); + status.setOperType(actionType.toString()); + + updateDbStatus(status, returnRsp.getStatus(), JobStatus.FINISHED, NssmfAdapterUtil.getStatusDesc(actionType)); + return returnRsp; } @Override diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java index fb76adcce6..08c464e46b 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java @@ -20,11 +20,14 @@ package org.onap.so.adapters.nssmf.manager.impl.external; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.so.adapters.nssmf.enums.ActionType; 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.beans.nsmf.DeAllocateNssi; import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest; +import org.onap.so.db.request.beans.ResourceOperationStatus; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; public class ExternalCnNssmfManager extends ExternalNssmfManager { @@ -45,6 +48,23 @@ public class ExternalCnNssmfManager extends ExternalNssmfManager { } @Override + protected void afterQueryJobStatus(ResourceOperationStatus status) { + super.afterQueryJobStatus(status); + ActionType jobOperType = ActionType.valueOf(status.getOperType()); + if (Integer.parseInt(status.getProgress()) == 100) { + if (ActionType.ACTIVATE.equals(jobOperType)) { + ServiceInstance nssiInstance = restUtil.getServiceInstance(serviceInfo); + nssiInstance.setOrchestrationStatus("activated"); + restUtil.updateServiceInstance(nssiInstance, serviceInfo); + } else if (ActionType.DEACTIVATE.equals(jobOperType)) { + ServiceInstance nssiInstance = restUtil.getServiceInstance(serviceInfo); + nssiInstance.setOrchestrationStatus("deactivated"); + restUtil.updateServiceInstance(nssiInstance, serviceInfo); + } + } + } + + @Override protected SelectionType doQueryNSSISelectionCapability() { return SelectionType.NSMF; 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/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java index 8bfbd55387..1b4a9e9fca 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java @@ -37,6 +37,6 @@ public class InternalTnNssmfManager extends InternalNssmfManager { @Override protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { // TODO - return null; + return doWrapAllocateReqBody(nbiRequest); } } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java index 7a86c5ba2b..60bf423ed8 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java @@ -77,6 +77,11 @@ public class RestUtil { serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); } + public void updateServiceInstance(ServiceInstance serviceInstance, ServiceInfo serviceInfo) { + aaiSvcProv.invokeUpdateServiceInstance(serviceInstance, serviceInfo.getGlobalSubscriberId(), + serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); + } + public ServiceInstance getServiceInstance(ServiceInfo serviceInfo) { return aaiSvcProv.invokeGetServiceInstance(serviceInfo.getGlobalSubscriberId(), serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); diff --git a/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json b/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json new file mode 100644 index 0000000000..8753e85ea2 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json @@ -0,0 +1,10 @@ +{ + "AN": { + "latency": 5, + "maxNumberofUEs": "100" + }, + "CN": { + "latency": 5, + "maxNumberofConns": "100" + } +} 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 f150f47f4f..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 @@ -78,6 +78,7 @@ public class NssmfAdapterRestTest { + " \"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" + + " \"maxNumberofPDUSession\" : 10,\n" + " \"sliceProfileId\" : \"ab9af40f13f721b5f13539d87484098\",\n" + " \"plmnIdList\" : [ \"460-00\", \"460-01\" ],\n" + " \"perfReq\" : {\n" + " \"perfReqEmbbList\" : [ {\n" + " \"activityFactor\" : 50\n" + " } ]\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 4a659e1ca3..26904fa8a4 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 @@ -35,9 +35,11 @@ import org.mockito.stubbing.Answer; import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts; import org.onap.so.adapters.nssmf.entity.NssmfInfo; import org.onap.so.adapters.nssmf.entity.TokenResponse; +import org.onap.so.adapters.nssmf.enums.ActionType; import org.onap.so.adapters.nssmf.enums.HttpMethod; import org.onap.so.adapters.nssmf.util.RestUtil; import org.onap.so.beans.nsmf.*; +import org.onap.so.beans.nsmf.oof.SubnetCapability; import org.onap.so.db.request.beans.ResourceOperationStatus; import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; import org.springframework.http.ResponseEntity; @@ -203,9 +205,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); @@ -357,12 +359,14 @@ public class NssmfManagerServiceImplTest { operationStatus.setOperationId("4b45d919816ccaa2b762df5120f72067"); operationStatus.setResourceTemplateUUID("8ee5926d-720b-4bb2-86f9-d20e921c143b"); operationStatus.setServiceId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); + operationStatus.setOperType(ActionType.ALLOCATE.toString()); 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); @@ -374,8 +378,6 @@ public class NssmfManagerServiceImplTest { assertEquals(allRes.getResponseDescriptor().getStatus(), "processing"); assertEquals(allRes.getResponseDescriptor().getResponseId(), "7512eb3feb5249eca5ddd742fedddd39"); - System.out.println(res); - } @Test @@ -429,7 +431,9 @@ public class NssmfManagerServiceImplTest { public void querySubnetCapability() { NssmfAdapterNBIRequest nbiRequest = createNbiRequest(); - String subnetCapabilityQuery = "\"subnetTypes\": [\"TN-FH\",\"TN-MH\",\"TN-BH\"]"; + QuerySubnetCapability subnetCapabilityQuery = new QuerySubnetCapability(); + List<String> subnetTypes = Arrays.asList("TN-FH", "TN-MH", "TN-BH"); + subnetCapabilityQuery.setSubnetTypes(subnetTypes); nbiRequest.setSubnetCapabilityQuery(subnetCapabilityQuery); ResponseEntity res = nssiManagerService.queryNSSISelectionCapability(nbiRequest); assertNotNull(res); |