aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEnbo Wang <wangenbo@huawei.com>2020-10-31 23:51:18 +0800
committerEnbo Wang <wangenbo@huawei.com>2020-10-31 23:51:18 +0800
commit864fdb52e8aef5f4ccd77220c86dd44bc07d80e2 (patch)
tree327ae6748e901f7987868b4957cff26834632cc7
parent1757b2f9727591fd5907f43834dbe9f0b8261740 (diff)
Fix issue of missing deleting NSSI from AAI for ExternalNssmfManager
Issue-ID: SO-3341 Signed-off-by: Enbo Wang <wangenbo@huawei.com> Change-Id: I5aa407e56a8a2588006e89d1db5a9f2b8fcad642
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java2
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java8
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java37
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java1
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java5
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) {