aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzm330 <zhangminyj@chinamobile.com>2021-01-07 20:14:45 +0800
committerzm330 <zhangminyj@chinamobile.com>2021-01-07 20:14:58 +0800
commit01d865e89f94af25b477659608b7311b3ddadc1e (patch)
tree7f508a97cb3976155325fd792c3e135dbf2e48e6
parent67160220ddd1463696f3d56fde035dc4f3949f73 (diff)
Fix some deallocate issues
Issue-ID: SO-3411 Signed-off-by: zm330 <zhangminyj@chinamobile.com> Change-Id: Ie61983b9e9567bd21e5cd12cda4d76ec422c5dee
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy7
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy66
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn27
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java4
5 files changed, 77 insertions, 29 deletions
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 96f2956b93..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
@@ -100,7 +100,7 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager {
restUtil.createServiceInstance(nssiInstance, serviceInfo);
} else if (ActionType.DEALLOCATE.equals(jobOperType)) {
// TODO
- // restUtil.deleteServiceInstance(serviceInfo);
+ restUtil.deleteServiceInstance(serviceInfo);
}
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy
index b94c81b41f..d00f349690 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy
@@ -19,6 +19,7 @@
*/
package org.onap.so.bpmn.infrastructure.scripts
+import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri
import static org.apache.commons.lang3.StringUtils.isBlank
import javax.ws.rs.NotFoundException
@@ -319,12 +320,12 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor {
CommunicationServiceProfile csProfile = csProfiles.getCommunicationServiceProfile().get(0)
profileId = csProfile ? csProfile.getProfileId() : ""
}
- resourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).communicationServiceProfile(profileId))
- if (!getAAIClient().exists(resourceUri)) {
+ AAISimpleUri profileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId).communicationServiceProfile(profileId))
+ if (!getAAIClient().exists(profileUri)) {
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "communication service profile was not found in aai")
}
- getAAIClient().delete(resourceUri)
+ getAAIClient().delete(profileUri)
LOGGER.debug("end delete communication service profile from AAI")
}
catch (any)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy
index 2889f79c30..5fd06fd8d4 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy
@@ -19,22 +19,15 @@
*/
package org.onap.so.bpmn.infrastructure.scripts
-import org.onap.aai.domain.yang.SliceProfiles
-import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri
-
-import static org.apache.commons.lang3.StringUtils.isBlank
-import javax.ws.rs.NotFoundException
-import javax.ws.rs.core.Response
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.AllottedResource
import org.onap.aai.domain.yang.AllottedResources
import org.onap.aai.domain.yang.Relationship
import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.aai.domain.yang.ServiceProfile
-import org.onap.aai.domain.yang.ServiceProfiles
import org.onap.aaiclient.client.aai.AAIObjectName
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
@@ -48,6 +41,11 @@ import org.onap.so.client.HttpClientFactory
import org.slf4j.Logger
import org.slf4j.LoggerFactory
+import javax.ws.rs.NotFoundException
+import javax.ws.rs.core.Response
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
/**
* This groovy class supports the <class>DoDeleteSliceService.bpmn</class> process.
*
@@ -193,13 +191,27 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
{
LOGGER.trace(" *****${PREFIX} Start getNSIFromAAI *****")
String nsiId = execution.getVariable("nsiId")
+ List<String> nssiIdList = getNSSIIdList(execution, nsiId)
+ String msg = "nsiId: ${nsiId}, nssiIdList:"
+ msg+= nssiIdList.join(",")
+ LOGGER.info(msg)
+ execution.setVariable("nssiIdList", nssiIdList)
+ LOGGER.trace(" *****${PREFIX} Exit getNSIFromAAI *****")
+ }
+ /**
+ * Get NSSI Id from AAI
+ * @param execution
+ * @param nsiId
+ * @return
+ */
+ private List<String> getNSSIIdList(DelegateExecution execution, String nsiId){
+ List<String> nssiIdList = []
+
try
{
- String errorMsg = "query nsi from aai failed."
+ String errorMsg = "query nssi from aai failed."
AAIResultWrapper wrapper = queryAAI(execution, Types.SERVICE_INSTANCE, nsiId, errorMsg)
- Optional<ServiceInstance> si =wrapper.asBean(ServiceInstance.class)
- List<String> nssiIdList = []
- String msg = "nsiId:${nsiId},nssiIdList:"
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
if(si.isPresent())
{
List<Relationship> relationshipList = si.get().getRelationshipList()?.getRelationship()
@@ -217,15 +229,12 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
ServiceInstance instance = serviceInstance.get()
if ("nssi".equalsIgnoreCase(instance.getServiceRole())) {
nssiId = instance.getServiceInstanceId()
+ nssiIdList.add(nssiId)
}
}
- nssiIdList.add(nssiId)
- msg+="${nssiId}, "
}
}
}
- LOGGER.info(msg)
- execution.setVariable("nssiIdList", nssiIdList)
}
catch(BpmnError e){
throw e
@@ -235,7 +244,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
LOGGER.error(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- LOGGER.trace(" *****${PREFIX} Exit getNSIFromAAI *****")
+ return nssiIdList
}
/**
@@ -396,6 +405,7 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
LOGGER.debug("Start terminateNSIQuery")
return
+
//To test
String requestId = execution.getVariable("msoRequestId")
String nxlId = currentNSSI['nsiServiceInstanceId']
@@ -446,4 +456,26 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor {
}
LOGGER.debug("Finish terminateNSIQuery")
}
+
+
+ /**
+ * If no nssi,delete NSI from AAI
+ * @param execution
+ */
+ void deleteNSIInstance(DelegateExecution execution){
+ def currentNSSI = execution.getVariable("currentNSSI")
+ def nsiId = currentNSSI['nsiServiceInstanceId']
+ List<String> nssiIdList = getNSSIIdList(execution, nsiId)
+ try
+ {
+ if(0 == nssiIdList.size()){
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("serviceType")).serviceInstance(nsiId))
+ getAAIClient().delete(serviceInstanceUri)
+ }
+ } catch (Exception ex) {
+ LOGGER.debug( "Failed to delete NSI instance.")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to delete NSI instance.")
+ }
+
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn
index 9edb6127f0..f1534a0360 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteSliceService.bpmn
@@ -34,9 +34,9 @@ ddss.getNSSIListFromAAI(execution)</bpmn:script>
<bpmn:outgoing>SequenceFlow_0926ghe</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:endEvent id="EndEvent_0jaitqv" name="End">
- <bpmn:incoming>SequenceFlow_1c4fjbv</bpmn:incoming>
+ <bpmn:incoming>SequenceFlow_1odnvjl</bpmn:incoming>
</bpmn:endEvent>
- <bpmn:sequenceFlow id="SequenceFlow_1c4fjbv" name="yes" sourceRef="ExclusiveGateway_1ogbunu" targetRef="EndEvent_0jaitqv">
+ <bpmn:sequenceFlow id="SequenceFlow_1c4fjbv" name="yes" sourceRef="ExclusiveGateway_1ogbunu" targetRef="Task_10yni6k">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isAllNSSIFinished" ) == true)}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="SequenceFlow_0c58sw3" sourceRef="Task_1rc7mcw" targetRef="ScriptTask_159855t" />
@@ -96,6 +96,14 @@ dss.terminateNSIQuery(execution)</bpmn:script>
<bpmn:sequenceFlow id="SequenceFlow_17tvomo" sourceRef="Task_1iomfas" targetRef="Task_1rc7mcw" />
<bpmn:sequenceFlow id="SequenceFlow_1aa2ek0" sourceRef="Task_1u755sr" targetRef="Task_1iuls9p" />
<bpmn:sequenceFlow id="SequenceFlow_1252rbf" sourceRef="Task_1iuls9p" targetRef="Task_1iomfas" />
+ <bpmn:sequenceFlow id="SequenceFlow_1odnvjl" sourceRef="Task_10yni6k" targetRef="EndEvent_0jaitqv" />
+ <bpmn:scriptTask id="Task_10yni6k" name="DeleteNSIFromAAI" scriptFormat="groovy">
+ <bpmn:incoming>SequenceFlow_1c4fjbv</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1odnvjl</bpmn:outgoing>
+ <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def ddss= new DoDeleteSliceService()
+ddss.deleteNSIInstance(execution)</bpmn:script>
+ </bpmn:scriptTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoDeleteSliceServiceV1">
@@ -138,9 +146,9 @@ dss.terminateNSIQuery(execution)</bpmn:script>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1c4fjbv_di" bpmnElement="SequenceFlow_1c4fjbv">
<di:waypoint x="1765" y="140" />
- <di:waypoint x="1802" y="140" />
+ <di:waypoint x="1830" y="140" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1771" y="118" width="17" height="14" />
+ <dc:Bounds x="1793" y="118" width="17" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1rgfzzy_di" bpmnElement="SequenceFlow_1rgfzzy">
@@ -177,9 +185,9 @@ dss.terminateNSIQuery(execution)</bpmn:script>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0jaitqv_di" bpmnElement="EndEvent_0jaitqv">
- <dc:Bounds x="1802" y="122" width="36" height="36" />
+ <dc:Bounds x="2002" y="122" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1810" y="168" width="20" height="14" />
+ <dc:Bounds x="2010" y="168" width="20" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ScriptTask_0icszw6_di" bpmnElement="Task_0etki1p">
@@ -200,6 +208,13 @@ dss.terminateNSIQuery(execution)</bpmn:script>
<bpmndi:BPMNShape id="Activity_1iuls9p_di" bpmnElement="Task_1iuls9p">
<dc:Bounds x="1050" y="100" width="100" height="80" />
</bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1odnvjl_di" bpmnElement="SequenceFlow_1odnvjl">
+ <di:waypoint x="1930" y="140" />
+ <di:waypoint x="2002" y="140" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ScriptTask_1qk9lnm_di" bpmnElement="Task_10yni6k">
+ <dc:Bounds x="1830" y="100" width="100" height="80" />
+ </bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java b/common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java
index 3292730f29..356c1cb4de 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/NssmfRequest.java
@@ -37,7 +37,7 @@ public class NssmfRequest implements Serializable {
private String globalSubscriberId;
- private String serviceInstanceId;
+ private String serviceInstanceID;
private String subscriptionServiceType;
@@ -54,7 +54,7 @@ public class NssmfRequest implements Serializable {
this.subscriptionServiceType = serviceInfo.getSubscriptionServiceType();
this.networkType = networkType;
this.additionalProperties = additionalProperties;
- this.serviceInstanceId = serviceInfo.getNssiId();
+ this.serviceInstanceID = serviceInfo.getNssiId();
this.name = serviceInfo.getNssiName();
}