From 60cd967c2e69900bb69495ed944cc38830fc860d Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Thu, 26 Apr 2018 12:53:50 +0000 Subject: Add NS relationship delete for E2E service Add NS relationship delete for E2E service Change-Id: Ia58308dae0fef38b32098d1e92c0871617a86ed2 Issue-ID: SO-422 Signed-off-by: subhash kumar singh --- .../DoDeleteVFCNetworkServiceInstance.groovy | 71 +++++++++++++++++++++- .../DoDeleteVFCNetworkServiceInstance.bpmn | 42 +++++++++---- 2 files changed, 100 insertions(+), 13 deletions(-) diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy index c71cb0521e..f0ecbab82c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy @@ -20,7 +20,7 @@ package org.openecomp.mso.bpmn.infrastructure.scripts; -import static org.apache.commons.lang3.StringUtils.*; +import static org.apache.commons.lang3.StringUtils.* import groovy.xml.XmlUtil import groovy.json.* import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -39,6 +39,10 @@ import org.springframework.web.util.UriUtils import org.openecomp.mso.rest.RESTClient import org.openecomp.mso.rest.RESTConfig import org.openecomp.mso.rest.APIResponse; +import org.openecomp.mso.rest.RESTConfig +import org.openecomp.mso.rest.RESTClient + + /** * This groovy class supports the DoDeleteVFCNetworkServiceInstance.bpmn process. @@ -98,6 +102,71 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces utils.log("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled) } + /** + * unwind NS from AAI relationship + */ + public void deleteNSRelationship(DelegateExecution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("INFO"," ***** addNSRelationship *****", isDebugEnabled) + String nsInstanceId = execution.getVariable("resourceInstanceId") + if(nsInstanceId == null || nsInstanceId == ""){ + utils.log("INFO"," Delete NS failed", isDebugEnabled) + return + } + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("serviceType") + String serviceId = execution.getVariable("serviceId") + String deleteRelationPayload = """ + service-instance + /aai/v11/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${nsInstanceId} + + customer.global-customer-id + ${globalSubscriberId} + + + service-subscription.service-type + ${serviceType} + + + service-instance.service-instance-id + ${nsInstanceId} + + """ + String endpoint = execution.getVariable("URN_aai_endpoint") + utils.log("INFO","Add Relationship req:\n" + deleteRelationPayload, isDebugEnabled) + String url = endpoint + "/aai/v11/business/customers/customer/" + globalSubscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances/service-instance/" + serviceId + "/relationship-list/relationship" + + APIResponse aaiRsp = executeAAIDeleteCall(execution, url, deleteRelationPayload) + utils.log("INFO","aai response status code:" + aaiRsp.getStatusCode(), isDebugEnabled) + utils.log("INFO","aai response content:" + aaiRsp.getResponseBodyAsString(), isDebugEnabled) + utils.log("INFO"," *****Exit addNSRelationship *****", isDebugEnabled) + } + + public APIResponse executeAAIDeleteCall(DelegateExecution execution, String url, String payload){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("INFO", " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled) + APIResponse apiResponse = null + try{ + String uuid = utils.getRequestID() + utils.log("INFO","Generated uuid is: " + uuid, isDebugEnabled) + utils.log("INFO","URL to be used is: " + url, isDebugEnabled) + String userName = execution.getVariable("URN_aai_auth") + String password = execution.getVariable("URN_mso_msoKey") + String basicAuthCred = utils.getBasicAuth(userName,password) + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml"); + if (basicAuthCred != null && !"".equals(basicAuthCred)) { + client.addAuthorizationHeader(basicAuthCred) + } + apiResponse = client.httpDelete(payload) + utils.log("INFO","======== Completed Execute AAI Delete Process ======== ", isDebugEnabled) + }catch(Exception e){ + utils.log("ERROR","Exception occured while executing AAI Put Call. Exception is: \n" + e, isDebugEnabled) + throw new BpmnError("MSOWorkflowException") + } + return apiResponse + } + /** * delete NS task */ diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVFCNetworkServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVFCNetworkServiceInstance.bpmn index 3cef94d6ea..41b8d2e7aa 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVFCNetworkServiceInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVFCNetworkServiceInstance.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1qo2pln @@ -20,7 +20,7 @@ def dcsi = new DoDeleteVFCNetworkServiceInstance() dcsi.preProcessRequest(execution)]]> - SequenceFlow_150q0fo + SequenceFlow_1h1c24p SequenceFlow_1ywe21t - + + + + SequenceFlow_150q0fo + SequenceFlow_1h1c24p + + @@ -107,19 +115,19 @@ dcsi.timeDelay(execution)]]> - + - + - + - + @@ -141,10 +149,10 @@ dcsi.timeDelay(execution)]]> - + - + @@ -232,10 +240,10 @@ dcsi.timeDelay(execution)]]> - - + + - + @@ -252,6 +260,16 @@ dcsi.timeDelay(execution)]]> + + + + + + + + + + -- cgit 1.2.3-korg