aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2018-04-11 05:58:45 +0000
committerSeshu Kumar M <seshu.kumar.m@huawei.com>2018-04-11 09:36:42 +0000
commite88ee9a2c2970735222eeeb155eaf4fdfb63698d (patch)
tree4e0695d2a1915a9ae347b6df789ea20999d106c0
parent660c01edc4a6b897582bcc0d959edede7fecde25 (diff)
Implementation for SDNC resource delete
Implementation for SDNC resource delete Change-Id: I7e7366cadb29ad9c4d4a3ca4f25512e6cbf2fcdb Issue-ID: SO-422 Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy222
1 files changed, 222 insertions, 0 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy
new file mode 100644
index 0000000000..479e091345
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy
@@ -0,0 +1,222 @@
+
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 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.openecomp.mso.bpmn.infrastructure.scripts
+
+import org.json.JSONArray
+import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder
+import org.openecomp.mso.bpmn.core.domain.Resource
+import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
+import org.openecomp.mso.bpmn.infrastructure.properties.BPMNProperties;
+import org.apache.http.HttpResponse
+import org.json.JSONArray
+import org.openecomp.mso.bpmn.common.recipe.BpmnRestClient
+import org.openecomp.mso.bpmn.common.recipe.ResourceInput;
+
+import static org.apache.commons.lang3.StringUtils.*;
+import groovy.xml.XmlUtil
+import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils;
+import groovy.json.*
+
+import org.openecomp.mso.bpmn.core.json.JsonUtils
+import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
+import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
+import org.openecomp.mso.bpmn.core.WorkflowException
+import org.openecomp.mso.rest.APIResponse;
+import org.openecomp.mso.rest.RESTClient
+import org.openecomp.mso.rest.RESTConfig
+
+import java.util.List;
+import java.util.UUID;
+import javax.xml.parsers.DocumentBuilder
+import javax.xml.parsers.DocumentBuilderFactory
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.json.JSONObject;
+import org.apache.commons.lang3.*
+import org.apache.commons.codec.binary.Base64;
+import org.springframework.web.util.UriUtils;
+import org.w3c.dom.Document
+import org.w3c.dom.Element
+import org.w3c.dom.Node
+import org.w3c.dom.NodeList
+import org.xml.sax.InputSource
+
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP.Def;
+
+public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
+ String Prefix="DDELSDNNS_"
+
+
+ public void preProcessRequest (DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** preProcessSDNCDelete *****", isDebugEnabled)
+ String msg = ""
+
+ try {
+ serviceInstanceId = execution.getVariable("serviceInstanceId")
+ serviceInstanceName = execution.getVariable("serviceInstanceName")
+ callbackURL = execution.getVariable("sdncCallbackUrl")
+ requestId = execution.getVariable("msoRequestId")
+ serviceId = execution.getVariable("productFamilyId")
+ subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
+ String recipeParamsFromRequest = execution.getVariable("recipeParams")
+ String serviceModelInfo = execution.getVariable("serviceModelInfo")
+ modelInvariantUuid = ""
+ modelVersion = ""
+ modelUuid = ""
+ modelName = ""
+
+ if (!isBlank(serviceModelInfo))
+ {
+ modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
+ modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion")
+ modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid")
+ modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName")
+
+ if (modelInvariantUuid == null) {
+ modelInvariantUuid = ""
+ }
+ if (modelVersion == null) {
+ modelVersion = ""
+ }
+ if (modelUuid == null) {
+ modelUuid = ""
+ }
+ if (modelName == null) {
+ modelName = ""
+ }
+ }
+ if (serviceInstanceName == null) {
+ serviceInstanceName = ""
+ }
+ if (serviceId == null) {
+ serviceId = ""
+ }
+
+ def siParamsXml = execution.getVariable("siParamsXml")
+ def serviceType = execution.getVariable("serviceType")
+ if (serviceType == null)
+ {
+ serviceType = ""
+ }
+
+ sdncRequestId = UUID.randomUUID().toString()
+
+ String recipeParamsFromWf = execution.getVariable("recipeParamXsd")
+
+ String operationType = "Network"
+ String sdnc_svcAction = "delete"
+
+ if(!StringUtils.isBlank(recipeParamsFromRequest)){
+ //the operationType from worflow(first node) is second priority.
+ operationType = jsonUtil.getJsonValue(recipeParamsFromRequest, "operationType")
+ }
+ if(!StringUtils.isBlank(recipeParamsFromWf)){
+ //the operationType from worflow(first node) is highest priority.
+ operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType")
+ }
+
+ operationType = "delete" + operationType + "Instance"
+
+ if(StringUtils.containsIgnoreCase(resourceInputObj.getResourceInstanceName(), "overlay")){
+ //This will be resolved in R3.
+ sdnc_svcAction ="deactivate"
+ operationType = "DeActivateDCINetworkInstance"
+ }
+ if(StringUtils.containsIgnoreCase(resourceInputObj.getResourceInstanceName(), "underlay")){
+ //This will be resolved in R3.
+ operationType ="DeleteNetworkInstance"
+ }
+
+ String sdncDelete =
+ """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>${sdnc_svcAction}</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>${serviceType}</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${requestId}</request-id>
+ <source>MSO</source>
+ <notification-url/>
+ <order-number/>
+ <order-version/>
+ <request-action>${operationType}</request-action>
+ </request-information>
+ <service-information>
+ <service-id>${serviceId}</service-id>
+ <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
+ <onap-model-information>
+ <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
+ <model-uuid>${modelUuid}</model-uuid>
+ <model-version>${modelVersion}</model-version>
+ <model-name>${modelName}</model-name>
+ </onap-model-information>
+ <service-instance-id>${serviceInstanceId}</service-instance-id>
+ <subscriber-name/>
+ <global-customer-id>${globalSubscriberId}</global-customer-id>
+ </service-information>
+ <service-request-input>
+ <service-instance-name>${serviceInstanceName}</service-instance-name>
+ ${siParamsXml}
+ </service-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
+
+ sdncDelete = utils.formatXml(sdncDelete)
+ //def sdncRequestId2 = UUID.randomUUID().toString()
+ //String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
+ execution.setVariable("sdncDelete", sdncDelete)
+ execution.setVariable("sdncDeactivate", sdncDeactivate)
+ utils.log("INFO","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled)
+ utils.log("INFO","sdncDelete:\n" + sdncDelete, isDebugEnabled)
+
+ } catch (BpmnError e) {
+ throw e;
+ } catch(Exception ex) {
+ msg = "Exception in preProcessSDNCDelete. " + ex.getMessage()
+ utils.log("INFO", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage())
+ }
+ utils.log("INFO"," *****Exit preProcessSDNCDelete *****", isDebugEnabled)
+ }
+
+
+ public void postProcessSDNCDelete(DelegateExecution execution, String response) {
+
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** postProcessSDNC " + " *****", isDebugEnabled)
+ String msg = ""
+ utils.log("INFO"," response " + response, isDebugEnabled)
+ utils.log("INFO"," *** Exit postProcessSDNC " + " ***", isDebugEnabled)
+ }
+
+}