2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.openecomp.mso.bpmn.vcpe.scripts;
22 import org.openecomp.mso.bpmn.common.scripts.*;
23 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
24 import org.openecomp.mso.bpmn.core.RollbackData
25 import org.openecomp.mso.bpmn.core.WorkflowException
26 import org.openecomp.mso.bpmn.core.json.JsonUtils
27 import org.openecomp.mso.rest.APIResponse
29 import java.util.UUID;
30 import org.camunda.bpm.engine.delegate.BpmnError
31 import org.camunda.bpm.engine.runtime.Execution
32 import org.apache.commons.lang3.*
33 import org.springframework.web.util.UriUtils;
34 import static org.apache.commons.lang3.StringUtils.*
38 * This groovy class supports the <class>DoCreateAllottedResourceTXC.bpmn</class> process.
43 * @param - msoRequestId
44 * @param - isDEbugLogEnabled
45 * @param - disableRollback
46 * @param - failExists - O
47 * @param - serviceInstanceId
48 * @param - parentServiceInstanceId
49 * @param - allottedReourceId - O
50 * @param - allottedResourceModelInfo
51 * @param - allottedResourceRole
52 * @param - allottedResourceType
53 * @param - brgWanMacAddress
56 * @param - rollbackData (localRB->null)
57 * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
58 * @param - WorkflowException - O
59 * @param - allottedResourceId
60 * @param - allottedResourceName
62 * @param - vgmuxBearerIP
66 public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{
68 private static final String DebugFlag = "isDebugLogEnabled"
70 String Prefix="DCARTXC_"
71 ExceptionUtil exceptionUtil = new ExceptionUtil()
72 JsonUtils jsonUtil = new JsonUtils()
74 public void preProcessRequest (Execution execution) {
76 def isDebugEnabled = execution.getVariable(DebugFlag)
78 utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled)
81 execution.setVariable("prefix", Prefix)
84 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
85 if (isBlank(sdncCallbackUrl)) {
86 msg = "URN_mso_workflow_sdncadapter_callback is null"
87 utils.log("DEBUG", msg, isDebugEnabled)
88 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
90 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
91 utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
94 if (isBlank(execution.getVariable("serviceInstanceId"))){
95 msg = "Input serviceInstanceId is null"
96 utils.log("DEBUG", msg, isDebugEnabled)
97 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
99 if (isBlank(execution.getVariable("parentServiceInstanceId"))) {
100 msg = "Input parentServiceInstanceId is null"
101 utils.log("DEBUG", msg, isDebugEnabled)
102 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
104 if (isBlank(execution.getVariable("allottedResourceModelInfo"))) {
105 msg = "Input allottedResourceModelInfo is null"
106 utils.log("DEBUG", msg, isDebugEnabled)
107 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
109 if (isBlank(execution.getVariable("brgWanMacAddress"))) {
110 msg = "Input brgWanMacAddress is null"
111 utils.log("DEBUG", msg, isDebugEnabled)
112 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
114 if (isBlank(execution.getVariable("allottedResourceRole"))) {
115 msg = "Input allottedResourceRole is null"
116 utils.log("DEBUG", msg, isDebugEnabled)
117 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
119 if (isBlank(execution.getVariable("allottedResourceType"))) {
120 msg = "Input allottedResourceType is null"
121 utils.log("DEBUG", msg, isDebugEnabled)
122 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
125 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
127 } catch (Exception ex){
128 msg = "Exception in preProcessRequest " + ex.getMessage()
129 utils.log("DEBUG", msg, isDebugEnabled)
130 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
132 utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
135 public void getAaiAR (Execution execution) {
137 def isDebugEnabled = execution.getVariable(DebugFlag)
138 utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled)
140 String arType = execution.getVariable("allottedResourceType")
141 String arRole = execution.getVariable("allottedResourceRole")
143 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
144 String orchStatus = arUtils.getAROrchStatus(execution)
148 if (orchStatus != null) // AR was found
150 if ("true".equals(execution.getVariable("failExists")))
152 errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists"
156 if ("Active".equals(orchStatus))
158 execution.setVariable("foundActiveAR", true)
160 else // blanks included
162 errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus
166 if (!isBlank(errorMsg)) {
167 utils.log("DEBUG", errorMsg, isDebugEnabled)
168 exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg)
170 utils.log("DEBUG"," *****Exit getAaiAR *****", isDebugEnabled)
173 public void createAaiAR(Execution execution) {
175 def isDebugEnabled=execution.getVariable(DebugFlag)
176 utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled)
179 String allottedResourceId = execution.getVariable("allottedResourceId")
180 if (isBlank(allottedResourceId))
182 allottedResourceId = UUID.randomUUID().toString()
183 execution.setVariable("allottedResourceId", allottedResourceId)
189 AaiUtil aaiUriUtil = new AaiUtil(this)
190 String aaiEndpoint = execution.getVariable("URN_aai_endpoint")
191 String siResourceLink= execution.getVariable("PSI_resourceLink")
194 utils.log("DEBUG", "PSI_resourceLink:" + siResourceLink, isDebugEnabled)
196 if(!isBlank(siResourceLink)) {
197 utils.log("DEBUG", "Incoming PSI Resource Link is: " + siResourceLink, isDebugEnabled)
198 String[] split = siResourceLink.split("/aai/")
199 siUri = "/aai/" + split[1]
203 msg = "Parent Service Link in AAI is null"
204 utils.log("DEBUG", msg, isDebugEnabled)
205 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
208 arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8")
209 execution.setVariable("aaiARPath", arUrl)
210 utils.log("DEBUG", "GET AllottedResource AAI URL is:\n" + arUrl, isDebugEnabled)
212 String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl)
214 String arType = execution.getVariable("allottedResourceType")
215 String arRole = execution.getVariable("allottedResourceRole")
216 String CSI_resourceLink = execution.getVariable("CSI_resourceLink")
217 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
218 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
219 String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
220 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
222 if (modelInvariantId == null) {
223 modelInvariantId = ""
225 if (modelVersionId == null) {
228 if (modelCustomizationId == null) {
229 modelCustomizationId = ""
233 """<allotted-resource xmlns="${namespace}">
234 <id>${allottedResourceId}</id>
235 <description></description>
236 <type>${arType}</type>
237 <role>${arRole}</role>
238 <selflink></selflink>
239 <model-invariant-id>${modelInvariantId}</model-invariant-id>
240 <model-version-id>${modelVersionId}</model-version-id>
241 <model-customization-id>${modelCustomizationId}</model-customization-id>
242 <orchestration-status>PendingCreate</orchestration-status>
243 <operation-status></operation-status>
246 <related-to>service-instance</related-to>
247 <related-link>${CSI_resourceLink}</related-link>
250 </allotted-resource>""".trim()
252 execution.setVariable("AaiARPayload", payload)
253 utils.log("DEBUG", " payload to create AllottedResource in AAI:" + "\n" + payload, isDebugEnabled)
255 APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload)
256 int responseCode = response.getStatusCode()
257 utils.log("DEBUG", "AllottedResource AAI PUT responseCode:" + responseCode, isDebugEnabled)
259 String aaiResponse = response.getResponseBodyAsString()
260 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
261 utils.log("DEBUG", "AllottedResource AAI PUT responseStr:" + aaiResponse, isDebugEnabled)
263 //200 OK 201 CREATED 202 ACCEPTED
264 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
266 utils.log("DEBUG", "AAI PUT AllottedResource received a Good Response", isDebugEnabled)
269 utils.log("DEBUG", "AAI Put AllottedResouce received a Bad Response Code: " + responseCode, isDebugEnabled)
270 exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
271 throw new BpmnError("MSOWorkflowException")
274 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
276 } catch (Exception ex) {
277 msg = "Exception in createAaiAR " + ex.getMessage()
278 utils.log("DEBUG", msg, isDebugEnabled)
279 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
282 //start rollback set up
283 RollbackData rollbackData = new RollbackData()
284 def disableRollback = execution.getVariable("disableRollback")
285 rollbackData.put(Prefix, "disableRollback", disableRollback.toString())
286 rollbackData.put(Prefix, "rollbackAAI", "true")
287 rollbackData.put(Prefix, "allottedResourceId", allottedResourceId)
288 rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId"))
289 rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId"))
290 rollbackData.put(Prefix, "aaiARPath", arUrl)
291 execution.setVariable("rollbackData", rollbackData)
292 utils.log("DEBUG"," *** Exit createAaiAR*** ", isDebugEnabled)
295 public String buildSDNCRequest(Execution execution, String action, String sdncRequestId) {
297 def isDebugEnabled = execution.getVariable(DebugFlag)
299 utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled)
300 String sdncReq = null
304 String allottedResourceId = execution.getVariable("allottedResourceId")
305 String serviceInstanceId = execution.getVariable("serviceInstanceId")
306 String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
307 String serviceChainServiceInstanceId = execution.getVariable("serviceChainServiceInstanceId")
308 String callbackUrl = execution.getVariable("sdncCallbackUrl")
309 String requestId = execution.getVariable("msoRequestId")
311 String brgWanMacAddress = execution.getVariable("brgWanMacAddress")
313 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
314 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
315 String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion")
316 String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
317 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
318 String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName")
320 if (modelInvariantId == null) {
321 modelInvariantId = ""
323 if (modelVersion == null) {
326 if (modelUUId == null) {
329 if (modelName == null) {
332 if (modelCustomizationId == null) {
333 modelCustomizationId = ""
337 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
338 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
339 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
340 <sdncadapter:RequestHeader>
341 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
342 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
343 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
344 <sdncadapter:SvcOperation>tunnelxconn-topology-operation</sdncadapter:SvcOperation>
345 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
346 </sdncadapter:RequestHeader>
347 <sdncadapterworkflow:SDNCRequestData>
348 <request-information>
349 <request-id>${requestId}</request-id>
350 <request-action>CreateTunnelXConnInstance</request-action>
355 </request-information>
356 <service-information>
357 <service-id></service-id>
358 <subscription-service-type></subscription-service-type>
359 <ecomp-model-information></ecomp-model-information>
360 <service-instance-id>${parentServiceInstanceId}</service-instance-id>
362 <global-customer-id></global-customer-id>
363 </service-information>
364 <allotted-resource-information>
365 <allotted-resource-id>${allottedResourceId}</allotted-resource-id>
366 <allotted-resource-type>tunnelxconn</allotted-resource-type>
367 <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id>
368 <ecomp-model-information>
369 <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
370 <model-uuid>${modelUUId}</model-uuid>
371 <model-customization-uuid>${modelCustomizationId}</model-customization-uuid>
372 <model-version>${modelVersion}</model-version>
373 <model-name>${modelName}</model-name>
374 </ecomp-model-information>
375 </allotted-resource-information>
376 <tunnelxconn-request-input>
377 <brg-wan-mac-address>${brgWanMacAddress}</brg-wan-mac-address>
378 </tunnelxconn-request-input>
379 </sdncadapterworkflow:SDNCRequestData>
380 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
382 utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled)
383 sdncReq = utils.formatXml(sdncReq)
385 } catch(Exception ex) {
386 msg = "Exception in buildSDNCRequest. " + ex.getMessage()
387 utils.log("DEBUG", msg, isDebugEnabled)
388 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
390 utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled)
394 public void preProcessSDNCAssign(Execution execution) {
396 def isDebugEnabled = execution.getVariable(DebugFlag)
398 utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled)
401 String sdncRequestId = UUID.randomUUID().toString()
402 String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId)
403 execution.setVariable("sdncAssignRequest", sdncAssignReq)
404 utils.logAudit("sdncAssignRequest: " + sdncAssignReq)
405 def sdncRequestId2 = UUID.randomUUID().toString()
406 String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
407 def rollbackData = execution.getVariable("rollbackData")
408 rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq)
409 execution.setVariable("rollbackData", rollbackData)
411 utils.log("DEBUG","sdncAssignRollbackReq:\n" + sdncAssignRollbackReq, isDebugEnabled)
412 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
414 } catch (BpmnError e) {
416 } catch(Exception ex) {
417 msg = "Exception in preProcessSDNCAssign. " + ex.getMessage()
418 utils.log("DEBUG", msg, isDebugEnabled)
419 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
421 utils.log("DEBUG"," *****Exit preProcessSDNCAssign *****", isDebugEnabled)
424 public void preProcessSDNCCreate(Execution execution) {
426 def isDebugEnabled = execution.getVariable(DebugFlag)
428 utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled)
431 String sdncRequestId = UUID.randomUUID().toString()
432 String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId)
433 execution.setVariable("sdncCreateRequest", sdncCreateReq)
434 utils.logAudit("sdncCreateReq: " + sdncCreateReq)
435 def sdncRequestId2 = UUID.randomUUID().toString()
436 String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
437 def rollbackData = execution.getVariable("rollbackData")
438 rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq)
439 execution.setVariable("rollbackData", rollbackData)
441 utils.log("DEBUG","sdncCreateRollbackReq:\n" + sdncCreateRollbackReq, isDebugEnabled)
442 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
444 } catch (BpmnError e) {
446 } catch(Exception ex) {
447 msg = "Exception in preProcessSDNCCreate. " + ex.getMessage()
448 utils.log("DEBUG", msg, isDebugEnabled)
449 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
451 utils.log("DEBUG"," *****Exit preProcessSDNCCreate *****", isDebugEnabled)
454 public void preProcessSDNCActivate(Execution execution) {
456 def isDebugEnabled = execution.getVariable(DebugFlag)
458 utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled)
461 String sdncRequestId = UUID.randomUUID().toString()
462 String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId)
463 execution.setVariable("sdncActivateRequest", sdncActivateReq)
464 utils.logAudit("sdncActivateReq: " + sdncActivateReq)
465 def sdncRequestId2 = UUID.randomUUID().toString()
466 String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
467 def rollbackData = execution.getVariable("rollbackData")
468 rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq)
469 execution.setVariable("rollbackData", rollbackData)
471 utils.log("DEBUG","sdncActivateRollbackReq:\n" + sdncActivateRollbackReq, isDebugEnabled)
472 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
474 } catch (BpmnError e) {
476 } catch(Exception ex) {
477 msg = "Exception in preProcessSDNCActivate. " + ex.getMessage()
478 utils.log("DEBUG", msg, isDebugEnabled)
479 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
481 utils.log("DEBUG"," *****Exit preProcessSDNCActivate *****", isDebugEnabled)
484 public void validateSDNCResp(Execution execution, String response, String method){
486 def isDebugLogEnabled=execution.getVariable(DebugFlag)
487 utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled)
491 WorkflowException workflowException = execution.getVariable("WorkflowException")
492 utils.logAudit("workflowException: " + workflowException)
494 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
495 utils.logAudit("SDNCResponse: " + response)
497 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
498 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
500 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
501 utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled)
503 if (!"get".equals(method))
505 def rollbackData = execution.getVariable("rollbackData")
506 rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true")
507 execution.setVariable("rollbackData", rollbackData)
511 utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
512 throw new BpmnError("MSOWorkflowException")
514 } catch (BpmnError e) {
516 } catch(Exception ex) {
517 msg = "Exception in validateSDNCResp. " + ex.getMessage()
518 utils.log("DEBUG", msg, isDebugLogEnabled)
519 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
521 logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled)
524 public void preProcessSDNCGet(Execution execution){
525 def isDebugLogEnabled = execution.getVariable(DebugFlag)
526 utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled)
529 def callbackUrl = execution.getVariable("sdncCallbackUrl")
530 // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI
531 // or from "object-path" in SDNC response for assign when AR does not exist in AA
533 String serviceOperation = ""
535 if (execution.getVariable("foundActiveAR")) {
536 def aaiQueryResponse = execution.getVariable("aaiARGetResponse")
537 serviceOperation = utils.getNodeText1(aaiQueryResponse, "selflink")
538 utils.log("DEBUG", "AR service operation/aaiARSelfLink: " + serviceOperation, isDebugLogEnabled)
542 String response = execution.getVariable("sdncAssignResponse")
543 String data = utils.getNodeXml(response, "response-data")
544 data = data.replaceAll("<", "<")
545 data = data.replaceAll(">", ">")
546 utils.log("DEBUG", "Assign responseData: " + data, isDebugLogEnabled)
547 serviceOperation = utils.getNodeText1(data, "object-path")
548 utils.log("DEBUG", "AR service operation:" + serviceOperation, isDebugLogEnabled)
551 String serviceInstanceId = execution.getVariable("serviceInstanceId")
552 String sdncRequestId = UUID.randomUUID().toString()
554 String tsleep = execution.getVariable("junitSleepMs")
556 //workaround for sdnc replication issue
557 sleep(tsleep == null ? 5000 : tsleep as Long)
559 //neeed the same url as used by vfmodules
560 String SDNCGetRequest =
561 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
562 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
563 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
564 <sdncadapter:RequestHeader>
565 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
566 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
567 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
568 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
569 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
570 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
571 </sdncadapter:RequestHeader>
572 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
573 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
575 execution.setVariable("sdncGetRequest", SDNCGetRequest)
578 utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
579 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage())
581 utils.log("DEBUG", "*** Exit preProcessSDNCGet *** ", isDebugLogEnabled)
584 public void updateAaiAROrchStatus(Execution execution, String status){
585 def isDebugEnabled = execution.getVariable(DebugFlag)
586 utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled)
587 String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create
588 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
589 String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath)
590 utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled)
593 public void generateOutputs(Execution execution)
595 def isDebugEnabled=execution.getVariable(DebugFlag)
596 utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled)
598 String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped
599 utils.log("DEBUG", "resp:" + sdncGetResponse, isDebugEnabled)
600 String arData = utils.getNodeXml(sdncGetResponse, "tunnelxconn-topology")
601 arData = utils.removeXmlNamespaces(arData)
603 String txca = utils.getNodeXml(arData, "tunnelxconn-assignments")
604 execution.setVariable("vni", utils.getNodeText1(txca, "vni"))
605 execution.setVariable("vgmuxBearerIP", utils.getNodeText1(txca, "vgmux_bearer_ip"))
606 execution.setVariable("vgmuxLanIP", utils.getNodeText1(txca, "vgmux_lan_ip"))
608 String ari = utils.getNodeXml(arData, "allotted-resource-identifiers")
609 execution.setVariable("allotedResourceName", utils.getNodeText1(ari, "allotted-resource-name"))
610 } catch (BpmnError e) {
611 utils.log("DEBUG", "BPMN Error in generateOutputs ", isDebugEnabled)
612 } catch(Exception ex) {
613 String msg = "Exception in generateOutputs " + ex.getMessage()
614 utils.log("DEBUG", msg, isDebugEnabled)
616 utils.log("DEBUG"," *** Exit generateOutputs *** ", isDebugEnabled)
620 public void preProcessRollback (Execution execution) {
621 def isDebugEnabled=execution.getVariable(DebugFlag)
622 utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled)
625 Object workflowException = execution.getVariable("WorkflowException");
627 if (workflowException instanceof WorkflowException) {
628 utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
629 execution.setVariable("prevWorkflowException", workflowException);
630 //execution.setVariable("WorkflowException", null);
632 } catch (BpmnError e) {
633 utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)
634 } catch(Exception ex) {
635 String msg = "Exception in preProcessRollback. " + ex.getMessage()
636 utils.log("DEBUG", msg, isDebugEnabled)
638 utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled)
641 public void postProcessRollback (Execution execution) {
642 def isDebugEnabled=execution.getVariable(DebugFlag)
643 utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled)
646 Object workflowException = execution.getVariable("prevWorkflowException");
647 if (workflowException instanceof WorkflowException) {
648 utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)
649 execution.setVariable("WorkflowException", workflowException);
651 execution.setVariable("rollbackData", null)
652 } catch (BpmnError b) {
653 utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)
655 } catch(Exception ex) {
656 msg = "Exception in postProcessRollback. " + ex.getMessage()
657 utils.log("DEBUG", msg, isDebugEnabled)
659 utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled)