diff options
Diffstat (limited to 'adapters/mso-nssmf-adapter')
10 files changed, 150 insertions, 9 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 1e3c76cdde..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 @@ -122,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)); @@ -131,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/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/impl/ExternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java index 7ec6c0f9e1..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 @@ -99,6 +99,7 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { restUtil.createServiceInstance(nssiInstance, serviceInfo); } else if (ActionType.DEALLOCATE.equals(jobOperType)) { + // TODO restUtil.deleteServiceInstance(serviceInfo); } } 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/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 d7b3b03333..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,6 +35,7 @@ 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.*; @@ -358,6 +359,7 @@ 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"); @@ -376,8 +378,6 @@ public class NssmfManagerServiceImplTest { assertEquals(allRes.getResponseDescriptor().getStatus(), "processing"); assertEquals(allRes.getResponseDescriptor().getResponseId(), "7512eb3feb5249eca5ddd742fedddd39"); - System.out.println(res); - } @Test |