diff options
author | Chuanyu Chen <chenchuanyu@huawei.com> | 2020-11-02 06:18:18 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-11-02 06:18:18 +0000 |
commit | 255147b2161873c6893b5a1b31e6657d10d67ad5 (patch) | |
tree | a14b6a973413c9740482eb47aebbde7c17af08be | |
parent | d6d16964cb8e19029e36ce16ca5385d4a903252b (diff) | |
parent | 864fdb52e8aef5f4ccd77220c86dd44bc07d80e2 (diff) |
Merge "Fix issue of missing deleting NSSI from AAI for ExternalNssmfManager"
5 files changed, 37 insertions, 16 deletions
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 dacab3b168..77662bf272 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 @@ -34,4 +34,6 @@ public interface AaiServiceProvider { 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 7cdeac4507..1d7c42aafe 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 @@ -87,4 +87,12 @@ public class AaiServiceProviderImpl implements AaiServiceProvider { return null; }); } + + @Override + public void invokeDeleteServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); + + aaiClientProvider.getAaiClient().delete(uri); + } } 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 7a5b6a4926..bb2b83fd59 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 @@ -25,6 +25,7 @@ import org.apache.http.message.BasicHeader; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.so.adapters.nssmf.entity.NssmfInfo; import org.onap.so.adapters.nssmf.entity.RestResponse; +import org.onap.so.adapters.nssmf.enums.ActionType; import org.onap.so.adapters.nssmf.enums.JobStatus; import org.onap.so.adapters.nssmf.exceptions.ApplicationException; import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; @@ -63,28 +64,32 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { protected void afterQueryJobStatus(ResourceOperationStatus status) { if (Integer.parseInt(status.getProgress()) == 100) { - ServiceInstance nssiInstance = restUtil.getServiceInstance(serviceInfo); - if (nssiInstance == null) { - nssiInstance = new ServiceInstance(); - } + ActionType jobOperType = ActionType.valueOf(status.getOperType()); + + if (ActionType.ALLOCATE.equals(jobOperType)) { + ServiceInstance nssiInstance = restUtil.getServiceInstance(serviceInfo); + if (nssiInstance == null) { + nssiInstance = new ServiceInstance(); + } - nssiInstance.setServiceInstanceId(serviceInfo.getNssiId()); - nssiInstance.setServiceInstanceName(serviceInfo.getNssiName()); - nssiInstance.setServiceType(serviceInfo.getSST()); + nssiInstance.setServiceInstanceId(serviceInfo.getNssiId()); + nssiInstance.setServiceInstanceName(serviceInfo.getNssiName()); + nssiInstance.setServiceType(serviceInfo.getSST()); - nssiInstance.setOrchestrationStatus(initStatus); - nssiInstance.setModelInvariantId(serviceInfo.getServiceInvariantUuid()); - nssiInstance.setModelVersionId(serviceInfo.getServiceUuid()); - nssiInstance.setServiceInstanceLocationId(serviceInfo.getPLMNIdList()); - nssiInstance.setEnvironmentContext(esrInfo.getNetworkType().getNetworkType()); - nssiInstance.setServiceRole("nssi"); + nssiInstance.setOrchestrationStatus(initStatus); + nssiInstance.setModelInvariantId(serviceInfo.getServiceInvariantUuid()); + nssiInstance.setModelVersionId(serviceInfo.getServiceUuid()); + nssiInstance.setServiceInstanceLocationId(serviceInfo.getPLMNIdList()); + nssiInstance.setEnvironmentContext(esrInfo.getNetworkType().getNetworkType()); + nssiInstance.setServiceRole("nssi"); - restUtil.createServiceInstance(nssiInstance, serviceInfo); + restUtil.createServiceInstance(nssiInstance, serviceInfo); + } else if (ActionType.DEALLOCATE.equals(jobOperType)) { + restUtil.deleteServiceInstance(serviceInfo); + } } } - - @Override protected String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException { return marshal(actDeActNssi); 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 eb2dba0f44..c51b72d61e 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 @@ -76,6 +76,7 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager { ResourceOperationStatus status = new ResourceOperationStatus(serviceInfo.getNsiId(), resp.getJobId(), serviceInfo.getServiceUuid()); status.setResourceInstanceID(nssiId); + status.setOperType(actionType.toString()); updateDbStatus(status, restResponse.getStatus(), JobStatus.FINISHED, NssmfAdapterUtil.getStatusDesc(actionType)); 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 432cfacb0b..a7adbe116a 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 @@ -82,6 +82,11 @@ public class RestUtil { serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); } + public void deleteServiceInstance(ServiceInfo serviceInfo) { + aaiSvcProv.invokeDeleteServiceInstance(serviceInfo.getGlobalSubscriberId(), + serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); + } + public NssmfInfo getNssmfHost(EsrInfo esrInfo) throws ApplicationException { EsrThirdpartySdncList sdncList = aaiSvcProv.invokeGetThirdPartySdncList(); if (sdncList != null && sdncList.getEsrThirdpartySdnc() != null) { |