2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.bpmn.infrastructure.scripts
23 import org.json.JSONArray;
25 import static org.apache.commons.lang3.StringUtils.*;
26 import groovy.xml.XmlUtil
29 import org.openecomp.mso.bpmn.core.json.JsonUtils
30 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
31 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
32 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
33 import org.openecomp.mso.bpmn.core.WorkflowException
34 import org.openecomp.mso.rest.APIResponse;
35 import org.openecomp.mso.rest.RESTClient
36 import org.openecomp.mso.rest.RESTConfig
38 import java.util.List;
39 import java.util.UUID;
40 import javax.xml.parsers.DocumentBuilder
41 import javax.xml.parsers.DocumentBuilderFactory
43 import org.camunda.bpm.engine.delegate.BpmnError
44 import org.camunda.bpm.engine.delegate.DelegateExecution
45 import org.json.JSONObject;
46 import org.apache.commons.lang3.*
47 import org.apache.commons.codec.binary.Base64;
48 import org.springframework.web.util.UriUtils;
49 import org.w3c.dom.Document
50 import org.w3c.dom.Element
51 import org.w3c.dom.Node
52 import org.w3c.dom.NodeList
53 import org.xml.sax.InputSource
55 import com.fasterxml.jackson.jaxrs.json.annotation.JSONP.Def;
58 * This groovy class supports the <class>DoDeleteE2EServiceInstance.bpmn</class> process.
61 * @param - msoRequestId
62 * @param - globalSubscriberId - O
63 * @param - subscriptionServiceType - O
64 * @param - serviceInstanceId
65 * @param - serviceInstanceName - O
66 * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM)
67 * @param - sdncVersion
68 * @param - failNotFound - TODO
69 * @param - serviceInputParams - TODO
72 * @param - WorkflowException
76 public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
78 String Prefix="DDELSI_"
79 ExceptionUtil exceptionUtil = new ExceptionUtil()
80 JsonUtils jsonUtil = new JsonUtils()
82 public void preProcessRequest (DelegateExecution execution) {
83 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
84 utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled)
88 String requestId = execution.getVariable("msoRequestId")
89 execution.setVariable("prefix",Prefix)
92 //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
93 String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
94 if (globalSubscriberId == null)
96 execution.setVariable("globalSubscriberId", "")
99 //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
100 String serviceType = execution.getVariable("serviceType")
101 if (serviceType == null)
103 execution.setVariable("serviceType", "")
106 //Generated in parent for AAI PUT
107 String serviceInstanceId = execution.getVariable("serviceInstanceId")
108 if (isBlank(serviceInstanceId)){
109 msg = "Input serviceInstanceId is null"
110 utils.log("INFO", msg, isDebugEnabled)
111 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
114 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
115 if (isBlank(sdncCallbackUrl)) {
116 msg = "URN_mso_workflow_sdncadapter_callback is null"
117 utils.log("INFO", msg, isDebugEnabled)
118 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
120 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
121 utils.log("INFO","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
123 StringBuilder sbParams = new StringBuilder()
124 Map<String, String> paramsMap = execution.getVariable("serviceInputParams")
125 if (paramsMap != null)
127 sbParams.append("<service-input-parameters>")
128 for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
130 String paramName = entry.getKey()
131 String paramValue = entry.getValue()
134 <name>${paramName}</name>
135 <value>${paramValue}</value>
138 sbParams.append(paramsXml)
140 sbParams.append("</service-input-parameters>")
142 String siParamsXml = sbParams.toString()
143 if (siParamsXml == null)
145 execution.setVariable("siParamsXml", siParamsXml)
147 } catch (BpmnError e) {
149 } catch (Exception ex){
150 msg = "Exception in preProcessRequest " + ex.getMessage()
151 utils.log("INFO", msg, isDebugEnabled)
152 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
154 utils.log("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled)
158 public void preProcessVFCDelete (DelegateExecution execution) {
161 public void postProcessVFCDelete(DelegateExecution execution, String response, String method) {
164 public void preProcessSDNCDelete (DelegateExecution execution) {
165 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
166 utils.log("INFO"," ***** preProcessSDNCDelete *****", isDebugEnabled)
170 def serviceInstanceId = execution.getVariable("serviceInstanceId")
171 def serviceInstanceName = execution.getVariable("serviceInstanceName")
172 def callbackURL = execution.getVariable("sdncCallbackUrl")
173 def requestId = execution.getVariable("msoRequestId")
174 def serviceId = execution.getVariable("productFamilyId")
175 def subscriptionServiceType = execution.getVariable("subscriptionServiceType")
176 def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
178 String serviceModelInfo = execution.getVariable("serviceModelInfo")
179 def modelInvariantUuid = ""
180 def modelVersion = ""
183 if (!isBlank(serviceModelInfo))
185 modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
186 modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion")
187 modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid")
188 modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName")
190 if (modelInvariantUuid == null) {
191 modelInvariantUuid = ""
193 if (modelVersion == null) {
196 if (modelUuid == null) {
199 if (modelName == null) {
203 if (serviceInstanceName == null) {
204 serviceInstanceName = ""
206 if (serviceId == null) {
210 def siParamsXml = execution.getVariable("siParamsXml")
211 def serviceType = execution.getVariable("serviceType")
212 if (serviceType == null)
217 def sdncRequestId = UUID.randomUUID().toString()
220 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
221 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
222 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
223 <sdncadapter:RequestHeader>
224 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
225 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
226 <sdncadapter:SvcAction>delete</sdncadapter:SvcAction>
227 <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>
228 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
229 <sdncadapter:MsoAction>${serviceType}</sdncadapter:MsoAction>
230 </sdncadapter:RequestHeader>
231 <sdncadapterworkflow:SDNCRequestData>
232 <request-information>
233 <request-id>${requestId}</request-id>
238 <request-action>DeleteServiceInstance</request-action>
239 </request-information>
240 <service-information>
241 <service-id>${serviceId}</service-id>
242 <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
243 <onap-model-information>
244 <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
245 <model-uuid>${modelUuid}</model-uuid>
246 <model-version>${modelVersion}</model-version>
247 <model-name>${modelName}</model-name>
248 </onap-model-information>
249 <service-instance-id>${serviceInstanceId}</service-instance-id>
251 <global-customer-id>${globalSubscriberId}</global-customer-id>
252 </service-information>
253 <service-request-input>
254 <service-instance-name>${serviceInstanceName}</service-instance-name>
256 </service-request-input>
257 </sdncadapterworkflow:SDNCRequestData>
258 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
260 sdncDelete = utils.formatXml(sdncDelete)
261 def sdncRequestId2 = UUID.randomUUID().toString()
262 String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
263 execution.setVariable("sdncDelete", sdncDelete)
264 execution.setVariable("sdncDeactivate", sdncDeactivate)
265 utils.log("INFO","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled)
266 utils.log("INFO","sdncDelete:\n" + sdncDelete, isDebugEnabled)
268 } catch (BpmnError e) {
270 } catch(Exception ex) {
271 msg = "Exception in preProcessSDNCDelete. " + ex.getMessage()
272 utils.log("INFO", msg, isDebugEnabled)
273 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage())
275 utils.log("INFO"," *****Exit preProcessSDNCDelete *****", isDebugEnabled)
278 public void postProcessSDNCDelete(DelegateExecution execution, String response, String method) {
280 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
281 utils.log("INFO"," ***** postProcessSDNC " + method + " *****", isDebugEnabled)
285 WorkflowException workflowException = execution.getVariable("WorkflowException")
286 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
287 utils.log("INFO", "SDNCResponse: " + response, isDebugEnabled)
288 utils.log("INFO", "workflowException: " + workflowException, isDebugEnabled)
290 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
291 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
292 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == "true"){
293 utils.log("INFO","Good response from SDNC Adapter for service-instance " + method + "response:\n" + response, isDebugEnabled)
296 msg = "Bad Response from SDNC Adapter for service-instance " + method
297 utils.log("INFO", msg, isDebugEnabled)
298 exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg)
300 } catch (BpmnError e) {
302 } catch(Exception ex) {
303 msg = "Exception in postProcessSDNC " + method + " Exception:" + ex.getMessage()
304 utils.log("INFO", msg, isDebugEnabled)
305 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
307 utils.log("INFO"," *** Exit postProcessSDNC " + method + " ***", isDebugEnabled)
310 public void postProcessAAIGET(DelegateExecution execution) {
311 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
312 utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled)
316 String serviceInstanceId = execution.getVariable("serviceInstanceId")
317 boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
318 String serviceType = ""
321 utils.log("INFO","Found Service-instance in AAI", isDebugEnabled)
323 String siData = execution.getVariable("GENGS_service")
324 utils.log("INFO", "SI Data", isDebugEnabled)
327 msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId
328 utils.log("INFO", msg, isDebugEnabled)
329 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
333 utils.log("INFO", "SI Data" + siData, isDebugEnabled)
334 //Confirm there are no related service instances (vnf/network or volume)
335 if (utils.nodeExists(siData, "relationship-list")) {
336 utils.log("INFO", "SI Data relationship-list exists:", isDebugEnabled)
337 InputSource source = new InputSource(new StringReader(siData));
338 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
339 DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
340 Document serviceXml = docBuilder.parse(source)
341 serviceXml.getDocumentElement().normalize()
343 NodeList nodeList = serviceXml.getElementsByTagName("relationship")
344 JSONArray jArray = new JSONArray()
345 for (int x = 0; x < nodeList.getLength(); x++) {
346 Node node = nodeList.item(x)
347 if (node.getNodeType() == Node.ELEMENT_NODE) {
348 Element eElement = (Element) node
349 def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() //for ns
350 if(e.equals("service-instance")){
351 def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent()
352 utils.log("INFO", "ServiceInstance Related NS :" + relatedObject, isDebugEnabled)
353 NodeList dataList = node.getChildNodes()
354 if(null != dataList) {
355 JSONObject jObj = new JSONObject()
356 for (int i = 0; i < dataList.getLength(); i++) {
357 Node dNode = dataList.item(i)
358 if(dNode.getNodeName() == "relationship-data") {
359 Element rDataEle = (Element)dNode
360 def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent()
361 def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent()
362 if(eKey.equals("service-instance.service-instance-id")){
363 jObj.put("resourceInstanceId", eValue)
366 else if(dNode.getNodeName() == "related-to-property"){
367 Element rDataEle = (Element)dNode
368 def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent()
369 def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent()
370 if(eKey.equals("service-instance.service-instance-name")){
371 jObj.put("resourceType", eValue)
375 utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled)
378 //for overlay/underlay
379 }else if (e.equals("configuration")){
380 def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent()
381 utils.log("INFO", "ServiceInstance Related Configuration :" + relatedObject, isDebugEnabled)
382 NodeList dataList = node.getChildNodes()
383 if(null != dataList) {
384 JSONObject jObj = new JSONObject()
385 for (int i = 0; i < dataList.getLength(); i++) {
386 Node dNode = dataList.item(i)
387 if(dNode.getNodeName() == "relationship-data") {
388 Element rDataEle = (Element)dNode
389 def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent()
390 def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent()
391 if(eKey.equals("configuration.configuration-id")){
392 jObj.put("resourceInstanceId", eValue)
395 else if(dNode.getNodeName() == "related-to-property"){
396 Element rDataEle = (Element)dNode
397 def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent()
398 def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent()
399 if(eKey.equals("configuration.configuration-type")){
400 jObj.put("resourceType", eValue)
404 utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled)
410 execution.setVariable("serviceRelationShip", jArray.toString())
414 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
416 utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled)
417 WorkflowException workflowException = execution.getVariable("WorkflowException")
418 utils.logAudit("workflowException: " + workflowException)
419 if(workflowException != null){
420 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
424 msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
425 utils.log("INFO", msg, isDebugEnabled)
426 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
430 utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled)
432 }catch (BpmnError e) {
434 } catch (Exception ex) {
435 msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage()
436 utils.log("INFO", msg, isDebugEnabled)
437 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
439 utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled)
442 public void postProcessAAIDEL(DelegateExecution execution) {
443 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
444 utils.log("INFO"," ***** postProcessAAIDEL ***** ", isDebugEnabled)
447 String serviceInstanceId = execution.getVariable("serviceInstanceId")
448 boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator")
450 msg = "Error deleting Service-instance in AAI" + serviceInstanceId
451 utils.log("INFO", msg, isDebugEnabled)
452 WorkflowException workflowException = execution.getVariable("WorkflowException")
453 utils.logAudit("workflowException: " + workflowException)
454 if(workflowException != null){
455 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
459 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
462 } catch (BpmnError e) {
464 } catch (Exception ex) {
465 msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIDEL. " + ex.getMessage()
466 utils.log("INFO", msg, isDebugEnabled)
467 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
469 utils.log("INFO"," *** Exit postProcessAAIDEL *** ", isDebugEnabled)
472 public void preInitResourcesOperStatus(DelegateExecution execution){
473 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
475 utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
477 String serviceId = execution.getVariable("serviceInstanceId")
478 String operationId = execution.getVariable("operationId")
479 String operationType = execution.getVariable("operationType")
480 String resourceTemplateUUIDs = ""
481 String result = "processing"
482 String progress = "0"
484 String operationContent = "Prepare service creation"
485 utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled)
486 serviceId = UriUtils.encode(serviceId,"UTF-8")
487 execution.setVariable("serviceInstanceId", serviceId)
488 execution.setVariable("operationId", operationId)
489 execution.setVariable("operationType", operationType)
490 // we use resource instance ids for delete flow as resourceTemplateUUIDs
493 "resourceInstanceId":"1111",
494 "resourceType":"vIMS"
497 "resourceInstanceId":"222",
498 "resourceType":"vEPC"
501 "resourceInstanceId":"3333",
502 "resourceType":"overlay"
505 "resourceInstanceId":"4444",
506 "resourceType":"underlay"
509 String serviceRelationShip = execution.getVariable("serviceRelationShip")
511 def jsonSlurper = new JsonSlurper()
512 def jsonOutput = new JsonOutput()
513 List relationShipList = jsonSlurper.parseText(serviceRelationShip)
515 if (relationShipList != null) {
516 relationShipList.each {
517 resourceTemplateUUIDs = resourceTemplateUUIDs + it.resourceInstanceId + ":"
520 execution.setVariable("URN_mso_adapters_openecomp_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter")
523 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
524 xmlns:ns="http://org.openecomp.mso/requestsdb">
527 <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
528 <serviceId>${serviceId}</serviceId>
529 <operationId>${operationId}</operationId>
530 <operationType>${operationType}</operationType>
531 <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
532 </ns:initResourceOperationStatus>
534 </soapenv:Envelope>"""
536 payload = utils.formatXml(payload)
537 execution.setVariable("CVFMI_initResOperStatusRequest", payload)
538 utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
539 utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
542 utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled)
543 execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
545 utils.log("INFO", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
549 * prepare delete parameters
551 public void preResourceDelete(execution, resourceName){
552 // we use resource instance ids for delete flow as resourceTemplateUUIDs
555 "resourceInstanceId":"1111",
556 "resourceType":"vIMS"
559 "resourceInstanceId":"222",
560 "resourceType":"vEPC"
563 "resourceInstanceId":"3333",
564 "resourceType":"overlay"
567 "resourceInstanceId":"4444",
568 "resourceType":"underlay"
571 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
573 utils.log("INFO", " ======== STARTED preResourceDelete Process ======== ", isDebugEnabled)
574 String serviceRelationShip = execution.getVariable("serviceRelationShip")
575 def jsonSlurper = new JsonSlurper()
576 def jsonOutput = new JsonOutput()
577 List relationShipList = jsonSlurper.parseText(serviceRelationShip)
579 if (relationShipList != null) {
580 relationShipList.each {
581 if(StringUtils.containsIgnoreCase(it.resourceType, resourceName)) {
582 String resourceInstanceUUID = it.resourceInstanceId
583 String resourceTemplateUUID = it.resourceInstanceId
584 execution.setVariable("resourceTemplateId", resourceTemplateUUID)
585 execution.setVariable("resourceInstanceId", resourceInstanceUUID)
586 execution.setVariable("resourceType", resourceName)
587 utils.log("INFO", "Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + " resourceInstanceId: " + resourceInstanceUUID + " resourceType: " + resourceName, isDebugEnabled)
591 utils.log("INFO", " ======== END preResourceDelete Process ======== ", isDebugEnabled)
594 public void sequenceResource(execution){
595 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
597 utils.log("INFO", " ======== STARTED sequenceResource Process ======== ", isDebugEnabled)
598 List<String> nsResources = new ArrayList<String>()
599 List<String> wanResources = new ArrayList<String>()
600 List<String> resourceSequence = new ArrayList<String>()
602 String serviceRelationShip = execution.getVariable("serviceRelationShip")
605 def jsonSlurper = new JsonSlurper()
606 def jsonOutput = new JsonOutput()
607 List relationShipList = jsonSlurper.parseText(serviceRelationShip)
609 if (relationShipList != null) {
610 relationShipList.each {
611 if(StringUtils.containsIgnoreCase(it.resourceType, "overlay") || StringUtils.containsIgnoreCase(it.resourceType, "underlay")){
612 wanResources.add(it.resourceType)
614 nsResources.add(it.resourceType)
618 resourceSequence.addAll(wanResources)
619 resourceSequence.addAll(nsResources)
620 String isContainsWanResource = wanResources.isEmpty() ? "false" : "true"
621 execution.setVariable("isContainsWanResource", isContainsWanResource)
622 execution.setVariable("currentResourceIndex", 0)
623 execution.setVariable("resourceSequence", resourceSequence)
624 utils.log("INFO", "resourceSequence: " + resourceSequence, isDebugEnabled)
625 execution.setVariable("wanResources", wanResources)
626 utils.log("INFO", " ======== END sequenceResource Process ======== ", isDebugEnabled)
629 public void getCurrentResource(execution){
630 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
631 utils.log("INFO", "======== Start getCurrentResoure Process ======== ", isDebugEnabled)
632 def currentIndex = execution.getVariable("currentResourceIndex")
633 List<String> resourceSequence = execution.getVariable("resourceSequence")
634 List<String> wanResources = execution.getVariable("wanResources")
635 String resourceName = resourceSequence.get(currentIndex)
636 execution.setVariable("resourceType",resourceName)
637 if(wanResources.contains(resourceName)){
638 execution.setVariable("controllerInfo", "SDN-C")
640 execution.setVariable("controllerInfo", "VF-C")
642 utils.log("INFO", "======== COMPLETED getCurrentResoure Process ======== ", isDebugEnabled)
645 public void parseNextResource(execution){
646 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
647 utils.log("INFO", "======== Start parseNextResource Process ======== ", isDebugEnabled)
648 def currentIndex = execution.getVariable("currentResourceIndex")
649 def nextIndex = currentIndex + 1
650 execution.setVariable("currentResourceIndex", nextIndex)
651 List<String> resourceSequence = execution.getVariable("resourceSequence")
652 if(nextIndex >= resourceSequence.size()){
653 execution.setVariable("allResourceFinished", "true")
655 execution.setVariable("allResourceFinished", "false")
657 utils.log("INFO", "======== COMPLETED parseNextResource Process ======== ", isDebugEnabled)