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=========================================================
21 package org.onap.so.bpmn.infrastructure.scripts;
23 import org.apache.commons.lang3.*
24 import org.camunda.bpm.engine.delegate.BpmnError
25 import org.camunda.bpm.engine.delegate.DelegateExecution
26 import org.onap.so.bpmn.common.scripts.AaiUtil
27 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
28 import org.onap.so.bpmn.common.scripts.ExceptionUtil
29 import org.onap.so.bpmn.common.scripts.MsoUtils
30 import org.onap.so.bpmn.common.scripts.NetworkUtils
31 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
32 import org.onap.so.bpmn.common.scripts.VidUtils
33 import org.onap.so.bpmn.core.UrnPropertiesReader
34 import org.onap.so.bpmn.core.WorkflowException
35 import org.onap.so.bpmn.core.json.JsonUtils
36 import org.onap.so.logger.MsoLogger
37 import org.onap.so.rest.APIResponse;
38 import org.springframework.web.util.UriUtils
39 import org.onap.so.client.aai.AAIResourcesClient
40 import org.onap.so.client.aai.AAIObjectType
41 import org.onap.so.client.aai.entities.AAIResultWrapper
42 import org.onap.so.client.aai.entities.Relationships
43 import org.onap.so.client.aai.entities.uri.AAIResourceUri
44 import org.onap.so.client.aai.entities.uri.AAIUriFactory
45 import org.json.JSONObject
46 import javax.ws.rs.NotFoundException
49 import groovy.xml.XmlUtil
53 * This groovy class supports the <class>DoCreateNetworkInstance.bpmn</class> process.
56 public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor {
57 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateNetworkInstance.class);
59 String Prefix="CRENWKI_"
60 ExceptionUtil exceptionUtil = new ExceptionUtil()
61 JsonUtils jsonUtil = new JsonUtils()
62 VidUtils vidUtils = new VidUtils(this)
63 NetworkUtils networkUtils = new NetworkUtils()
64 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
66 def className = getClass().getSimpleName()
69 * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstance.bpmn</class> process.
72 public InitializeProcessVariables(DelegateExecution execution){
73 /* Initialize all the process variables in this block */
75 execution.setVariable(Prefix + "networkRequest", "")
76 execution.setVariable(Prefix + "rollbackEnabled", null)
77 execution.setVariable(Prefix + "networkInputs", "")
78 //execution.setVariable(Prefix + "requestId", "")
79 execution.setVariable(Prefix + "messageId", "")
80 execution.setVariable(Prefix + "source", "")
81 execution.setVariable("BasicAuthHeaderValuePO", "")
82 execution.setVariable("BasicAuthHeaderValueSDNC", "")
83 execution.setVariable(Prefix + "serviceInstanceId","")
84 execution.setVariable("GENGS_type", "")
85 execution.setVariable(Prefix + "rsrc_endpoint", null)
86 execution.setVariable(Prefix + "networkOutputs", "")
87 execution.setVariable(Prefix + "networkId","")
88 execution.setVariable(Prefix + "networkName","")
91 execution.setVariable(Prefix + "queryNameAAIRequest","")
92 execution.setVariable(Prefix + "queryNameAAIResponse", "")
93 execution.setVariable(Prefix + "aaiNameReturnCode", "")
94 execution.setVariable(Prefix + "isAAIqueryNameGood", false)
96 // AAI query Cloud Region
97 execution.setVariable(Prefix + "queryCloudRegionRequest","")
98 execution.setVariable(Prefix + "queryCloudRegionReturnCode","")
99 execution.setVariable(Prefix + "queryCloudRegionResponse","")
100 execution.setVariable(Prefix + "cloudRegionPo","")
101 execution.setVariable(Prefix + "cloudRegionSdnc","")
102 execution.setVariable(Prefix + "isCloudRegionGood", false)
105 execution.setVariable(Prefix + "queryIdAAIRequest","")
106 execution.setVariable(Prefix + "queryIdAAIResponse", "")
107 execution.setVariable(Prefix + "aaiIdReturnCode", "")
109 // AAI query vpn binding
110 execution.setVariable(Prefix + "queryVpnBindingAAIRequest","")
111 execution.setVariable(Prefix + "queryVpnBindingAAIResponse", "")
112 execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "")
113 execution.setVariable(Prefix + "vpnBindings", null)
114 execution.setVariable(Prefix + "vpnCount", 0)
115 execution.setVariable(Prefix + "routeCollection", "")
117 // AAI query network policy
118 execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest","")
119 execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", "")
120 execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "")
121 execution.setVariable(Prefix + "networkPolicyUriList", null)
122 execution.setVariable(Prefix + "networkPolicyCount", 0)
123 execution.setVariable(Prefix + "networkCollection", "")
125 // AAI query route table reference
126 execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest","")
127 execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", "")
128 execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "")
129 execution.setVariable(Prefix + "networkTableRefUriList", null)
130 execution.setVariable(Prefix + "networkTableRefCount", 0)
131 execution.setVariable(Prefix + "tableRefCollection", "")
134 execution.setVariable(Prefix + "requeryIdAAIRequest","")
135 execution.setVariable(Prefix + "requeryIdAAIResponse", "")
136 execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "")
138 // AAI update contrail
139 execution.setVariable(Prefix + "updateContrailAAIUrlRequest","")
140 execution.setVariable(Prefix + "updateContrailAAIPayloadRequest","")
141 execution.setVariable(Prefix + "updateContrailAAIResponse", "")
142 execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", "")
144 execution.setVariable(Prefix + "createNetworkRequest", "")
145 execution.setVariable(Prefix + "createNetworkResponse", "")
146 execution.setVariable(Prefix + "rollbackNetworkRequest", "")
147 //execution.setVariable(Prefix + "rollbackNetworkResponse", "")
148 execution.setVariable(Prefix + "networkReturnCode", "")
149 //execution.setVariable(Prefix + "rollbackNetworkReturnCode", "")
150 execution.setVariable(Prefix + "isNetworkRollbackNeeded", false)
152 execution.setVariable(Prefix + "assignSDNCRequest", "")
153 execution.setVariable(Prefix + "assignSDNCResponse", "")
154 execution.setVariable(Prefix + "rollbackSDNCRequest", "")
155 //execution.setVariable(Prefix + "rollbackSDNCResponse", "")
156 execution.setVariable(Prefix + "sdncReturnCode", "")
157 //execution.setVariable(Prefix + "rollbackSDNCReturnCode", "")
158 execution.setVariable(Prefix + "isSdncRollbackNeeded", false)
159 execution.setVariable(Prefix + "sdncResponseSuccess", false)
161 execution.setVariable(Prefix + "activateSDNCRequest", "")
162 execution.setVariable(Prefix + "activateSDNCResponse", "")
163 execution.setVariable(Prefix + "rollbackActivateSDNCRequest", "")
164 //execution.setVariable(Prefix + "rollbackActivateSDNCResponse", "")
165 execution.setVariable(Prefix + "sdncActivateReturnCode", "")
166 //execution.setVariable(Prefix + "rollbackActivateSDNCReturnCode", "")
167 execution.setVariable(Prefix + "isSdncActivateRollbackNeeded", false)
168 execution.setVariable(Prefix + "sdncActivateResponseSuccess", false)
170 execution.setVariable(Prefix + "orchestrationStatus", "")
171 execution.setVariable(Prefix + "isVnfBindingPresent", false)
172 execution.setVariable(Prefix + "Success", false)
174 execution.setVariable(Prefix + "isException", false)
178 // **************************************************
179 // Pre or Prepare Request Section
180 // **************************************************
182 * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstance.bpmn</class> process.
185 public void preProcessRequest (DelegateExecution execution) {
187 execution.setVariable("prefix",Prefix)
188 msoLogger.trace("Inside preProcessRequest() of " + className + ".groovy")
191 // initialize flow variables
192 InitializeProcessVariables(execution)
194 // GET Incoming request & validate 3 kinds of format.
195 execution.setVariable("action", "CREATE")
196 String networkRequest = execution.getVariable("bpmnRequest")
197 if (networkRequest != null) {
198 if (networkRequest.contains("requestDetails")) {
199 // JSON format request is sent, create xml
201 def prettyJson = JsonOutput.prettyPrint(networkRequest.toString())
202 msoLogger.debug(" Incoming message formatted . . . : " + '\n' + prettyJson)
203 networkRequest = vidUtils.createXmlNetworkRequestInfra(execution, networkRequest)
205 } catch (Exception ex) {
206 String dataErrorMessage = " Invalid json format Request - " + ex.getMessage()
207 msoLogger.debug(dataErrorMessage)
208 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
211 // XML format request is sent
215 // vIPR format request is sent, create xml from individual variables
216 networkRequest = vidUtils.createXmlNetworkRequestInstance(execution)
219 networkRequest = utils.formatXml(networkRequest)
220 execution.setVariable(Prefix + "networkRequest", networkRequest)
221 msoLogger.debug(Prefix + "networkRequest - " + '\n' + networkRequest)
223 // validate 'backout-on-failure' to override 'mso.rollback'
224 boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, networkRequest)
225 execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled)
226 msoLogger.debug(Prefix + "rollbackEnabled - " + rollbackEnabled)
228 String networkInputs = utils.getNodeXml(networkRequest, "network-inputs", false).replace("tag0:","").replace(":tag0","")
229 execution.setVariable(Prefix + "networkInputs", networkInputs)
230 msoLogger.debug(Prefix + "networkInputs - " + '\n' + networkInputs)
233 String messageId = execution.getVariable("testMessageId") // for testing
234 if (messageId == null || messageId == "") {
235 messageId = UUID.randomUUID()
236 msoLogger.debug(Prefix + "messageId, random generated: " + messageId)
238 msoLogger.debug(Prefix + "messageId, pre-assigned: " + messageId)
240 execution.setVariable(Prefix + "messageId", messageId)
242 String source = utils.getNodeText(networkRequest, "source")
243 execution.setVariable(Prefix + "source", source)
244 msoLogger.debug(Prefix + "source - " + source)
246 // validate cloud region
247 String lcpCloudRegionId = utils.getNodeText(networkRequest, "aic-cloud-region")
248 if ((lcpCloudRegionId == null) || (lcpCloudRegionId == "") || (lcpCloudRegionId == "null")) {
249 String dataErrorMessage = "Missing value/element: 'lcpCloudRegionId' or 'cloudConfiguration' or 'aic-cloud-region'."
250 msoLogger.debug(" Invalid Request - " + dataErrorMessage)
251 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
254 // validate service instance id
255 String serviceInstanceId = utils.getNodeText(networkRequest, "service-instance-id")
256 if ((serviceInstanceId == null) || (serviceInstanceId == "") || (serviceInstanceId == "null")) {
257 String dataErrorMessage = "Missing value/element: 'serviceInstanceId'."
258 msoLogger.debug(" Invalid Request - " + dataErrorMessage)
259 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
262 // PO Authorization Info / headers Authorization=
263 String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution)
266 def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey",execution))
267 execution.setVariable("BasicAuthHeaderValuePO",encodedString)
268 execution.setVariable("BasicAuthHeaderValueSDNC", encodedString)
270 } catch (IOException ex) {
271 String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - "
272 String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage()
273 msoLogger.debug(dataErrorMessage)
274 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
277 // Set variables for Generic Get Sub Flow use
278 execution.setVariable(Prefix + "serviceInstanceId", serviceInstanceId)
279 msoLogger.debug(Prefix + "serviceInstanceId - " + serviceInstanceId)
281 execution.setVariable("GENGS_type", "service-instance")
282 msoLogger.debug("GENGS_type - " + "service-instance")
283 msoLogger.debug(" Url for SDNC adapter: " + UrnPropertiesReader.getVariable("mso.adapters.sdnc.endpoint",execution))
285 String sdncVersion = execution.getVariable("sdncVersion")
286 msoLogger.debug("sdncVersion? : " + sdncVersion)
288 // build 'networkOutputs'
289 String networkId = utils.getNodeText(networkRequest, "network-id")
290 if ((networkId == null) || (networkId == "null")) {
293 String networkName = utils.getNodeText(networkRequest, "network-name")
294 if ((networkName == null) || (networkName == "null")) {
297 String networkOutputs =
299 <network-id>${MsoUtils.xmlEscape(networkId)}</network-id>
300 <network-name>${MsoUtils.xmlEscape(networkName)}</network-name>
301 </network-outputs>"""
302 execution.setVariable(Prefix + "networkOutputs", networkOutputs)
303 msoLogger.debug(Prefix + "networkOutputs - " + '\n' + networkOutputs)
304 execution.setVariable(Prefix + "networkId", networkId)
305 execution.setVariable(Prefix + "networkName", networkName)
307 } catch (BpmnError e) {
310 } catch (Exception ex) {
311 sendSyncError(execution)
313 String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage()
314 msoLogger.debug(exceptionMessage)
315 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
322 * Gets the service instance uri from aai
324 public void getServiceInstance(DelegateExecution execution) {
326 String serviceInstanceId = execution.getVariable('CRENWKI_serviceInstanceId')
328 AAIResourcesClient resourceClient = new AAIResourcesClient()
329 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
331 if(!resourceClient.exists(uri)){
332 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
335 }catch(BpmnError e) {
337 }catch (Exception ex){
338 String msg = "Exception in getServiceInstance. " + ex.getMessage()
340 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
345 public void callRESTQueryAAINetworkName (DelegateExecution execution) {
347 execution.setVariable("prefix",Prefix)
349 msoLogger.debug(" ***** Inside callRESTQueryAAINetworkName() of DoCreateNetworkInstance ***** " )
352 String networkInputs = execution.getVariable(Prefix + "networkInputs")
353 String networkName = utils.getNodeText(networkInputs, "network-name")
354 networkName = UriUtils.encode(networkName,"UTF-8")
356 // Prepare AA&I url with network-name
357 String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
358 AaiUtil aaiUriUtil = new AaiUtil(this)
359 String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution)
360 String queryAAINameRequest = "${aai_endpoint}${aai_uri}" + "?network-name=" + networkName
361 execution.setVariable(Prefix + "queryNameAAIRequest", queryAAINameRequest)
362 msoLogger.debug(Prefix + "queryNameAAIRequest - " + "\n" + queryAAINameRequest)
365 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryAAINameRequest)
366 String returnCode = response.getStatusCode()
367 execution.setVariable(Prefix + "aaiNameReturnCode", returnCode)
368 msoLogger.debug(" ***** AAI Query Name Response Code : " + returnCode)
370 String aaiResponseAsString = response.getResponseBodyAsString()
371 msoLogger.debug(" ***** AAI Query Name Response : " +'\n'+ aaiResponseAsString)
373 if (returnCode=='200') {
374 execution.setVariable(Prefix + "queryNameAAIResponse", aaiResponseAsString)
375 execution.setVariable(Prefix + "isAAIqueryNameGood", true)
376 String orchestrationStatus = ""
378 // response is NOT empty
379 orchestrationStatus = utils.getNodeText(aaiResponseAsString, "orchestration-status")
380 execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus.toUpperCase())
381 msoLogger.debug(Prefix + "orchestrationStatus - " + orchestrationStatus.toUpperCase())
382 execution.setVariable("orchestrationStatus", orchestrationStatus)
384 } catch (Exception ex) {
386 execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus)
387 msoLogger.debug(Prefix + "orchestrationStatus - " + orchestrationStatus)
391 if (returnCode=='404') {
392 msoLogger.debug(" QueryAAINetworkName return code = '404' (Not Found). Proceed with the Create !!! ")
396 String dataErrorMessage = "Unexpected Error Response from QueryAAINetworkName - " + returnCode
397 msoLogger.debug(dataErrorMessage)
398 exceptionUtil.buildWorkflowException(execution, 2500, dataErrorMessage)
404 msoLogger.debug(Prefix + "isAAIqueryNameGood? : " + execution.getVariable(Prefix + "isAAIqueryNameGood"))
406 } catch (BpmnError e) {
409 } catch (Exception ex) {
411 String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow - callRESTQueryAAINetworkName() - " + ex.getMessage()
412 msoLogger.debug(exceptionMessage)
413 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
419 public void callRESTQueryAAICloudRegion (DelegateExecution execution) {
421 execution.setVariable("prefix",Prefix)
423 msoLogger.debug(" ***** Inside callRESTQueryAAICloudRegion() of DoCreateNetworkInstance ***** " )
426 String networkInputs = execution.getVariable(Prefix + "networkInputs")
427 String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region")
428 cloudRegion = UriUtils.encode(cloudRegion,"UTF-8")
431 String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
432 AaiUtil aaiUtil = new AaiUtil(this)
433 String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution)
434 String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion
435 execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
436 msoLogger.debug(Prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest)
438 String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
439 String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion)
441 if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) {
442 execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo)
443 execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc)
444 execution.setVariable(Prefix + "isCloudRegionGood", true)
447 String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode")
448 msoLogger.debug(dataErrorMessage)
449 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
453 msoLogger.debug(" is Cloud Region Good: " + execution.getVariable(Prefix + "isCloudRegionGood"))
455 } catch (BpmnError e) {
458 } catch (Exception ex) {
460 String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow - callRESTQueryAAICloudRegion() - " + ex.getMessage()
461 msoLogger.debug(exceptionMessage)
462 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
468 public void callRESTQueryAAINetworkId(DelegateExecution execution) {
470 execution.setVariable("prefix",Prefix)
472 msoLogger.debug(" ***** Inside callRESTQueryAAINetworkId() of DoCreateNetworkInstance ***** " )
476 String networkId = ""
477 String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse")
478 if (execution.getVariable("sdncVersion") != "1610") {
479 String networkResponseInformation = ""
481 networkResponseInformation = utils.getNodeXml(assignSDNCResponse, "network-response-information", false).replace("tag0:","").replace(":tag0","")
482 networkId = utils.getNodeText(networkResponseInformation, "instance-id")
483 } catch (Exception ex) {
484 String dataErrorMessage = " SNDC Response network validation for 'instance-id' (network-id) failed: Empty <network-response-information>"
485 msoLogger.debug(dataErrorMessage)
486 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
490 networkId = utils.getNodeText(assignSDNCResponse, "network-id")
492 if (networkId == null || networkId == "null") {
493 String dataErrorMessage = "SNDC Response did not contains 'instance-id' or 'network-id' element, or the value is null."
494 msoLogger.debug(dataErrorMessage)
495 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
497 msoLogger.debug(" SNDC Response network validation for 'instance-id' (network-id)' is good: " + networkId)
501 execution.setVariable(Prefix + "networkId", networkId)
502 String networkName = utils.getNodeText(assignSDNCResponse, "network-name")
503 execution.setVariable(Prefix + "networkName", networkName)
505 networkId = UriUtils.encode(networkId,"UTF-8")
508 String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
509 AaiUtil aaiUriUtil = new AaiUtil(this)
510 String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution)
511 String queryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all"
512 execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest)
513 msoLogger.debug(Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest)
515 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryIdAAIRequest)
516 String returnCode = response.getStatusCode()
517 execution.setVariable(Prefix + "aaiIdReturnCode", returnCode)
519 msoLogger.debug(" ***** AAI Response Code : " + returnCode)
521 String aaiResponseAsString = response.getResponseBodyAsString()
523 if (returnCode=='200') {
524 execution.setVariable(Prefix + "queryIdAAIResponse", aaiResponseAsString)
525 msoLogger.debug(" QueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString)
527 String netId = utils.getNodeText(aaiResponseAsString, "network-id")
528 execution.setVariable(Prefix + "networkId", netId)
529 String netName = utils.getNodeText(aaiResponseAsString, "network-name")
530 execution.setVariable(Prefix + "networkName", netName)
533 if (returnCode=='404') {
534 String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)."
535 msoLogger.debug(" AAI Query Failed. " + dataErrorMessage)
536 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
539 if (aaiResponseAsString.contains("RESTFault")) {
540 WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
541 execution.setVariable("WorkflowException", exceptionObject)
542 throw new BpmnError("MSOWorkflowException")
546 String dataErrorMessage = "Unexpected Response from QueryAAINetworkId - " + returnCode
547 msoLogger.debug("Unexpected Response from QueryAAINetworkId - " + dataErrorMessage)
548 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
554 } catch (BpmnError e) {
557 } catch (Exception ex) {
558 String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkId() - " + ex.getMessage()
559 msoLogger.debug(exceptionMessage)
560 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
566 public void callRESTReQueryAAINetworkId(DelegateExecution execution) {
568 execution.setVariable("prefix",Prefix)
570 msoLogger.debug(" ***** Inside callRESTReQueryAAINetworkId() of DoCreateNetworkInstance ***** " )
574 String networkId = execution.getVariable(Prefix + "networkId")
575 String netId = networkId
576 networkId = UriUtils.encode(networkId,"UTF-8")
579 String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
580 AaiUtil aaiUriUtil = new AaiUtil(this)
581 String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution)
582 String requeryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all"
583 execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest)
584 msoLogger.debug(Prefix + "requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest)
586 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, requeryIdAAIRequest)
587 String returnCode = response.getStatusCode()
588 execution.setVariable(Prefix + "aaiRequeryIdReturnCode", returnCode)
589 msoLogger.debug(" ***** AAI ReQuery Response Code : " + returnCode)
591 String aaiResponseAsString = response.getResponseBodyAsString()
593 if (returnCode=='200') {
594 execution.setVariable(Prefix + "requeryIdAAIResponse", aaiResponseAsString)
595 msoLogger.debug(" ReQueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString)
597 String netName = utils.getNodeText(aaiResponseAsString, "network-name")
598 String networkOutputs =
600 <network-id>${MsoUtils.xmlEscape(netId)}</network-id>
601 <network-name>${MsoUtils.xmlEscape(netName)}</network-name>
602 </network-outputs>"""
603 execution.setVariable(Prefix + "networkOutputs", networkOutputs)
604 msoLogger.debug(" networkOutputs - " + '\n' + networkOutputs)
607 if (returnCode=='404') {
608 String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)."
609 msoLogger.debug(" AAI ReQuery Failed. - " + dataErrorMessage)
610 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
613 if (aaiResponseAsString.contains("RESTFault")) {
614 WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
615 execution.setVariable("WorkflowException", exceptionObject)
616 throw new BpmnError("MSOWorkflowException")
620 String dataErrorMessage = "Unexpected Response from ReQueryAAINetworkId - " + returnCode
621 msoLogger.debug(dataErrorMessage)
622 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
628 } catch (BpmnError e) {
631 } catch (Exception ex) {
632 String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTReQueryAAINetworkId() - " + ex.getMessage()
633 msoLogger.debug(exceptionMessage)
634 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
640 public void callRESTQueryAAINetworkVpnBinding(DelegateExecution execution) {
642 execution.setVariable("prefix",Prefix)
644 msoLogger.debug(" ***** Inside callRESTQueryAAINetworkVpnBinding() of DoCreateNetworkInstance ***** " )
649 String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
650 String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
651 msoLogger.debug(" relationship - " + relationship)
653 // Check if Vnf Binding is present, then build a List of vnfBinding
654 List vpnBindingUri = networkUtils.getVnfBindingObject(relationship)
655 int vpnCount = vpnBindingUri.size()
656 execution.setVariable(Prefix + "vpnCount", vpnCount)
657 msoLogger.debug(Prefix + "vpnCount - " + vpnCount)
659 String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
660 AaiUtil aaiUriUtil = new AaiUtil(this)
663 execution.setVariable(Prefix + "vpnBindings", vpnBindingUri)
664 msoLogger.debug(" vpnBindingUri List - " + vpnBindingUri)
666 String routeTargets = ""
667 // AII loop call using list vpnBindings
668 for (i in 0..vpnBindingUri.size()-1) {
672 // prepare url using vpnBinding
673 String queryVpnBindingAAIRequest = ""
674 String aai_uri = aaiUriUtil.getNetworkVpnBindingUri(execution)
676 // Note: By default, the vpnBinding url is found in 'related-link' of the response,
677 // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping.
678 if (aai_uri == null || aai_uri == "") {
679 // using value of 'related-link' from response
680 if (vpnBindingUri[i].charAt(vpnBindingUri[i].length()-1) == '/') {
681 queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i].substring(0, vpnBindingUri[i].length()-1) + "?depth=all"
683 queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + "?depth=all"
687 // using uri value in URN mapping
688 String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length())
689 if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') {
690 vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1)
692 queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + "?depth=all"
695 execution.setVariable(Prefix + "queryVpnBindingAAIRequest", queryVpnBindingAAIRequest)
696 msoLogger.debug(Prefix + "queryVpnBindingAAIRequest, , vpnBinding #" + counting + " : " + "\n" + queryVpnBindingAAIRequest)
698 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryVpnBindingAAIRequest)
699 String returnCode = response.getStatusCode()
700 execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", returnCode)
701 msoLogger.debug(" ***** AAI query vpn binding Response Code, vpnBinding #" + counting + " : " + returnCode)
703 String aaiResponseAsString = response.getResponseBodyAsString()
705 if (returnCode=='200') {
706 execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiResponseAsString)
707 msoLogger.debug(" AAI Query Vpn Binding Success REST Response, , vpnBinding #" + counting + " : " + "\n" + aaiResponseAsString)
709 String routeTarget = ""
710 String routeRole = ""
711 if (utils.nodeExists(aaiResponseAsString, "route-targets")) {
712 String aaiRouteTargets = utils.getNodeXml(aaiResponseAsString, "route-targets", false)
713 def aaiRouteTargetsXml = new XmlSlurper().parseText(aaiRouteTargets)
714 def aaiRouteTarget = aaiRouteTargetsXml.'**'.findAll {it.name() == "route-target"}
715 for (j in 0..aaiRouteTarget.size()-1) {
716 routeTarget = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "global-route-target")
717 routeRole = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "route-target-role")
718 routeTargets += "<routeTargets>" + '\n' +
719 " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' +
720 " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' +
721 "</routeTargets>" + '\n'
726 if (returnCode=='404') {
727 String dataErrorMessage = "Response Error from AAINetworkVpnBinding is 404 (Not Found)."
728 msoLogger.debug(dataErrorMessage)
729 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
732 if (aaiResponseAsString.contains("RESTFault")) {
733 WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
734 execution.setVariable("WorkflowException", exceptionObject)
735 throw new BpmnError("MSOWorkflowException")
739 String dataErrorMessage = " Unexpected Response from AAINetworkVpnBinding - " + returnCode
740 msoLogger.debug(dataErrorMessage)
741 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
749 execution.setVariable(Prefix + "routeCollection", routeTargets)
750 msoLogger.debug(Prefix + "routeCollection - " + '\n' + routeTargets)
753 // reset return code to success
754 execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200")
755 String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution)
756 String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri)
757 String aaiStubResponse =
758 """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
759 <vpn-binding xmlns="${schemaVersion}">
760 <global-route-target/>
763 String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
764 execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml)
765 execution.setVariable(Prefix + "routeCollection", "<routeTargets/>")
766 msoLogger.debug(" No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml)
770 } catch (BpmnError e) {
773 } catch (Exception ex) {
774 String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage()
775 msoLogger.debug(exceptionMessage)
776 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
782 public void callRESTQueryAAINetworkPolicy(DelegateExecution execution) {
784 execution.setVariable("prefix",Prefix)
786 msoLogger.debug(" ***** Inside callRESTQueryAAINetworkPolicy() of DoCreateNetworkInstance ***** " )
790 String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
791 String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
792 msoLogger.debug(" relationship - " + relationship)
794 // Check if Network Policy is present, then build a List of network policy
795 List networkPolicyUriList = networkUtils.getNetworkPolicyObject(relationship)
796 int networkPolicyCount = networkPolicyUriList.size()
797 execution.setVariable(Prefix + "networkPolicyCount", networkPolicyCount)
798 msoLogger.debug(Prefix + "networkPolicyCount - " + networkPolicyCount)
800 String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
801 AaiUtil aaiUriUtil = new AaiUtil(this)
803 if (networkPolicyCount > 0) {
804 execution.setVariable(Prefix + "networkPolicyUriList", networkPolicyUriList)
805 msoLogger.debug(" networkPolicyUri List - " + networkPolicyUriList)
807 String networkPolicies = ""
808 // AII loop call using list vpnBindings
809 for (i in 0..networkPolicyUriList.size()-1) {
813 // prepare url using vpnBinding
814 String queryNetworkPolicyAAIRequest = ""
816 String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution)
818 // Note: By default, the network policy url is found in 'related-link' of the response,
819 // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping.
820 if (aai_uri == null || aai_uri == "") {
821 // using value of 'related-link' from response
822 if (networkPolicyUriList[i].charAt(networkPolicyUriList[i].length()-1) == '/') {
823 queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i].substring(0, networkPolicyUriList[i].length()-1) + "?depth=all"
825 queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + "?depth=all"
828 // using uri value in URN mapping
829 String networkPolicyId = networkPolicyUriList[i].substring(networkPolicyUriList[i].indexOf("/network-policy/")+16, networkPolicyUriList[i].length())
830 println " networkPolicyId - " + networkPolicyId
831 if (networkPolicyId.charAt(networkPolicyId.length()-1) == '/') {
832 networkPolicyId = networkPolicyId.substring(0, networkPolicyId.length()-1)
834 queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + "?depth=all"
839 execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest)
840 msoLogger.debug(Prefix + "queryNetworkPolicyAAIRequest, , NetworkPolicy #" + counting + " : " + "\n" + queryNetworkPolicyAAIRequest)
842 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyAAIRequest)
843 String returnCode = response.getStatusCode()
844 execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", returnCode)
845 msoLogger.debug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode)
847 String aaiResponseAsString = response.getResponseBodyAsString()
849 if (returnCode=='200') {
850 execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiResponseAsString)
851 msoLogger.debug(" QueryAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString)
853 String networkPolicy = ""
854 if (utils.nodeExists(aaiResponseAsString, "network-policy-fqdn")) {
855 networkPolicy = utils.getNodeText(aaiResponseAsString, "network-policy-fqdn")
856 networkPolicies += "<policyFqdns>" + networkPolicy + "</policyFqdns>" + '\n'
860 if (returnCode=='404') {
861 String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)."
862 msoLogger.debug(dataErrorMessage)
863 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
866 if (aaiResponseAsString.contains("RESTFault")) {
867 WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
868 execution.setVariable("WorkflowException", exceptionObject)
869 throw new BpmnError("MSOWorkflowException")
873 String dataErrorMessage = "Unexpected Response from QueryAAINetworkPolicy - " + returnCode
874 msoLogger.debug(dataErrorMessage)
875 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
883 execution.setVariable(Prefix + "networkCollection", networkPolicies)
884 msoLogger.debug(Prefix + "networkCollection - " + '\n' + networkPolicies)
887 // reset return code to success
888 execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200")
889 String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution)
890 String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri)
891 String aaiStubResponse =
892 """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
893 <network-policy xmlns="${schemaVersion}">
894 <network-policy-fqdn/>
897 String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
898 execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml)
899 execution.setVariable(Prefix + "networkCollection", "<policyFqdns/>")
900 msoLogger.debug(" No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml)
904 } catch (BpmnError e) {
907 } catch (Exception ex) {
908 String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage()
909 msoLogger.debug(exceptionMessage)
910 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
916 public void callRESTQueryAAINetworkTableRef(DelegateExecution execution) {
918 execution.setVariable("prefix",Prefix)
920 msoLogger.debug(" ***** Inside callRESTQueryAAINetworkTableRef() of DoCreateNetworkInstance ***** " )
924 String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
925 String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
926 msoLogger.debug(" relationship - " + relationship)
928 // Check if Network TableREf is present, then build a List of network policy
929 List networkTableRefUriList = networkUtils.getNetworkTableRefObject(relationship)
930 int networkTableRefCount = networkTableRefUriList.size()
931 execution.setVariable(Prefix + "networkTableRefCount", networkTableRefCount)
932 msoLogger.debug(Prefix + "networkTableRefCount - " + networkTableRefCount)
934 String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
935 AaiUtil aaiUriUtil = new AaiUtil(this)
937 if (networkTableRefCount > 0) {
938 execution.setVariable(Prefix + "networkTableRefUriList", networkTableRefUriList)
939 msoLogger.debug(" networkTableRefUri List - " + networkTableRefUriList)
941 // AII loop call using list vpnBindings
942 String networkTableRefs = ""
943 for (i in 0..networkTableRefUriList.size()-1) {
947 // prepare url using tableRef
948 String queryNetworkTableRefAAIRequest = ""
950 String aai_uri = aaiUriUtil.getNetworkTableReferencesUri(execution)
952 // Note: By default, the network policy url is found in 'related-link' of the response,
953 // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping.
954 if (aai_uri == null || aai_uri == "") {
955 // using value of 'related-link' from response
956 if (networkTableRefUriList[i].charAt(networkTableRefUriList[i].length()-1) == '/') {
957 queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i].substring(0, networkTableRefUriList[i].length()-1) + "?depth=all"
959 queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + "?depth=all"
962 // using uri value in URN mapping
963 String networkTableRefId = networkTableRefUriList[i].substring(networkTableRefUriList[i].indexOf("/route-table-reference/")+23, networkTableRefUriList[i].length())
965 if (networkTableRefId.charAt(networkTableRefId.length()-1) == '/') {
966 networkTableRefId = networkTableRefId.substring(0, networkTableRefId.length()-1)
968 queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + "?depth=all"
973 execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest)
974 msoLogger.debug(Prefix + "queryNetworkTableRefAAIRequest, , NetworkTableRef #" + counting + " : " + "\n" + queryNetworkTableRefAAIRequest)
976 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkTableRefAAIRequest)
977 String returnCode = response.getStatusCode()
978 execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", returnCode)
979 msoLogger.debug(" ***** AAI query network Table Reference Response Code, NetworkTableRef #" + counting + " : " + returnCode)
981 String aaiResponseAsString = response.getResponseBodyAsString()
983 if (returnCode=='200') {
984 execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiResponseAsString)
985 msoLogger.debug(" QueryAAINetworkTableRef Success REST Response, , NetworkTableRef #" + counting + " : " + "\n" + aaiResponseAsString)
987 String networkTableRef = ""
988 if (utils.nodeExists(aaiResponseAsString, "route-table-reference-fqdn")) {
989 networkTableRef = utils.getNodeText(aaiResponseAsString, "route-table-reference-fqdn")
990 networkTableRefs += "<routeTableFqdns>" + networkTableRef + "</routeTableFqdns>" + '\n'
994 if (returnCode=='404') {
995 String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)."
996 msoLogger.debug(dataErrorMessage)
997 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
1000 if (aaiResponseAsString.contains("RESTFault")) {
1001 WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
1002 execution.setVariable("WorkflowException", exceptionObject)
1003 throw new BpmnError("MSOWorkflowException")
1007 String dataErrorMessage = "Unexpected Response from QueryAAINetworkTableRef - " + returnCode
1008 msoLogger.debug(dataErrorMessage)
1009 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
1017 execution.setVariable(Prefix + "tableRefCollection", networkTableRefs)
1018 msoLogger.debug(Prefix + "tableRefCollection - " + '\n' + networkTableRefs)
1021 // reset return code to success
1022 execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200")
1023 String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution)
1024 String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri)
1025 String aaiStubResponse =
1026 """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
1027 <route-table-references xmlns="${schemaVersion}">
1028 <route-table-reference-fqdn/>
1029 </route-table-references>
1031 String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
1032 execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml)
1033 execution.setVariable(Prefix + "tableRefCollection", "<routeTableFqdns/>")
1034 msoLogger.debug(" No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml)
1038 } catch (BpmnError e) {
1041 } catch (Exception ex) {
1042 String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkTableRef() - " + ex.getMessage()
1043 msoLogger.debug(exceptionMessage)
1044 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
1051 public void callRESTUpdateContrailAAINetwork(DelegateExecution execution) {
1053 execution.setVariable("prefix",Prefix)
1055 msoLogger.debug(" ***** Inside callRESTUpdateContrailAAINetwork() of DoCreateNetworkInstance ***** " )
1059 String networkId = execution.getVariable(Prefix + "networkId")
1060 networkId = UriUtils.encode(networkId,"UTF-8")
1061 String requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse")
1062 String createNetworkResponse = execution.getVariable(Prefix + "createNetworkResponse")
1065 String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
1066 AaiUtil aaiUriUtil = new AaiUtil(this)
1067 String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution)
1068 String updateContrailAAIUrlRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all"
1070 execution.setVariable(Prefix + "updateContrailAAIUrlRequest", updateContrailAAIUrlRequest)
1071 msoLogger.debug(Prefix + "updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest)
1073 //Prepare payload (PUT)
1074 String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri)
1075 String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, createNetworkResponse, schemaVersion)
1076 String payloadXml = utils.formatXml(payload)
1077 execution.setVariable(Prefix + "updateContrailAAIPayloadRequest", payloadXml)
1078 msoLogger.debug(" 'payload' to Update Contrail - " + "\n" + payloadXml)
1080 APIResponse response = aaiUriUtil.executeAAIPutCall(execution, updateContrailAAIUrlRequest, payloadXml)
1082 String returnCode = response.getStatusCode()
1083 execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", returnCode)
1084 msoLogger.debug(" ***** AAI Update Contrail Response Code : " + returnCode)
1085 String aaiUpdateContrailResponseAsString = response.getResponseBodyAsString()
1086 if (returnCode=='200') {
1087 execution.setVariable(Prefix + "updateContrailAAIResponse", aaiUpdateContrailResponseAsString)
1088 msoLogger.debug(" AAI Update Contrail Success REST Response - " + "\n" + aaiUpdateContrailResponseAsString)
1089 // Point-of-no-return is set to false, rollback not needed.
1090 String rollbackEnabled = execution.getVariable(Prefix + "rollbackEnabled")
1091 if (rollbackEnabled == "true") {
1092 execution.setVariable(Prefix + "isPONR", false)
1094 execution.setVariable(Prefix + "isPONR", true)
1096 msoLogger.debug(Prefix + "isPONR" + ": " + execution.getVariable(Prefix + "isPONR"))
1098 if (returnCode=='404') {
1099 String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)."
1100 msoLogger.debug(dataErrorMessage)
1101 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
1104 if (aaiUpdateContrailResponseAsString.contains("RESTFault")) {
1105 WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiUpdateContrailResponseAsString, execution)
1106 execution.setVariable("WorkflowException", exceptionObject)
1107 throw new BpmnError("MSOWorkflowException")
1111 String errorMessage = "Unexpected Response from UpdateContrailAAINetwork - " + returnCode
1112 msoLogger.debug(errorMessage)
1113 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
1118 } catch (BpmnError e) {
1121 } catch (Exception ex) {
1122 String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTUpdateContrailAAINetwork() - " + ex.getMessage()
1123 msoLogger.debug(exceptionMessage)
1124 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
1130 public void prepareCreateNetworkRequest (DelegateExecution execution) {
1132 execution.setVariable("prefix",Prefix)
1134 msoLogger.trace("Inside prepareCreateNetworkRequest() of DoCreateNetworkInstance")
1139 String requestId = execution.getVariable("msoRequestId")
1140 if (requestId == null) {
1141 requestId = execution.getVariable("mso-request-id")
1143 String messageId = execution.getVariable(Prefix + "messageId")
1144 String source = execution.getVariable(Prefix + "source")
1146 String requestInput = execution.getVariable(Prefix + "networkRequest")
1147 String queryIdResponse = execution.getVariable(Prefix + "queryIdAAIResponse")
1148 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionPo")
1149 String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled")
1151 // Prepare Network request
1152 String routeCollection = execution.getVariable(Prefix + "routeCollection")
1153 String policyCollection = execution.getVariable(Prefix + "networkCollection")
1154 String tableCollection = execution.getVariable(Prefix + "tableRefCollection")
1155 String createNetworkRequest = networkUtils.CreateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyCollection, tableCollection, cloudRegionId, backoutOnFailure, source )
1157 String buildDeleteNetworkRequestAsString = utils.formatXml(createNetworkRequest)
1158 buildDeleteNetworkRequestAsString = buildDeleteNetworkRequestAsString.replace(":w1aac13n0", "").replace("w1aac13n0:", "")
1160 execution.setVariable(Prefix + "createNetworkRequest", buildDeleteNetworkRequestAsString)
1161 msoLogger.debug(Prefix + "createNetworkRequest - " + "\n" + buildDeleteNetworkRequestAsString)
1163 } catch (Exception ex) {
1164 String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareCreateNetworkRequest() - " + ex.getMessage()
1165 msoLogger.debug(exceptionMessage)
1166 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
1172 public void prepareSDNCRequest (DelegateExecution execution) {
1174 execution.setVariable("prefix",Prefix)
1176 msoLogger.trace("Inside prepareSDNCRequest() of DoCreateNetworkInstance")
1180 String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
1181 String createNetworkInput = execution.getVariable(Prefix + "networkRequest")
1182 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
1184 String networkId = execution.getVariable(Prefix + "networkId")
1185 String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId")
1187 // get/set 'msoRequestId' and 'mso-request-id'
1188 String requestId = execution.getVariable("msoRequestId")
1189 if (requestId != null) {
1190 execution.setVariable("mso-request-id", requestId)
1192 requestId = execution.getVariable("mso-request-id")
1194 execution.setVariable(Prefix + "requestId", requestId)
1196 // 1. prepare assign topology via SDNC Adapter SUBFLOW call
1197 String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, createNetworkInput, serviceInstanceId, sdncCallback, "assign", "NetworkActivateRequest", cloudRegionId, networkId, null, null)
1199 String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest)
1200 execution.setVariable(Prefix + "assignSDNCRequest", sndcTopologyCreateRequesAsString)
1201 msoLogger.debug(Prefix + "assignSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString)
1204 } catch (Exception ex) {
1205 String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSDNCRequest() - " + ex.getMessage()
1206 msoLogger.debug(exceptionMessage)
1207 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
1213 public void prepareRpcSDNCRequest (DelegateExecution execution) {
1215 execution.setVariable("prefix",Prefix)
1217 msoLogger.trace("Inside prepareRpcSDNCRequest() of DoCreateNetworkInstance")
1222 String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
1223 String createNetworkInput = execution.getVariable(Prefix + "networkRequest")
1224 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
1226 String networkId = execution.getVariable(Prefix + "networkId")
1227 String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId")
1229 // 1. prepare assign topology via SDNC Adapter SUBFLOW call
1230 String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null)
1232 String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest)
1233 execution.setVariable(Prefix + "assignSDNCRequest", sndcTopologyCreateRequesAsString)
1234 msoLogger.debug(Prefix + "assignSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString)
1236 } catch (Exception ex) {
1237 String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCRequest() - " + ex.getMessage()
1238 msoLogger.debug(exceptionMessage)
1239 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
1245 public void prepareRpcSDNCActivateRequest (DelegateExecution execution) {
1247 execution.setVariable("prefix",Prefix)
1249 msoLogger.trace("Inside prepareRpcSDNCActivateRequest() of DoCreateNetworkInstance")
1253 String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
1254 String createNetworkInput = execution.getVariable(Prefix + "networkRequest")
1255 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
1256 String networkId = execution.getVariable(Prefix + "networkId")
1257 String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId")
1259 // 1. prepare assign topology via SDNC Adapter SUBFLOW call
1260 String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "activate", "CreateNetworkInstance", cloudRegionId, networkId, null)
1262 String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest)
1263 execution.setVariable(Prefix + "activateSDNCRequest", sndcTopologyCreateRequesAsString)
1264 msoLogger.debug(Prefix + "activateSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString)
1267 } catch (Exception ex) {
1268 String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCActivateRequest() - " + ex.getMessage()
1269 msoLogger.debug(exceptionMessage)
1270 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
1279 // **************************************************
1280 // Post or Validate Response Section
1281 // **************************************************
1283 public void validateCreateNetworkResponse (DelegateExecution execution) {
1285 execution.setVariable("prefix",Prefix)
1287 msoLogger.trace("Inside validateNetworkResponse() of DoCreateNetworkInstance")
1290 String returnCode = execution.getVariable(Prefix + "networkReturnCode")
1291 String networkResponse = execution.getVariable(Prefix + "createNetworkResponse")
1292 if (networkResponse==null) {
1293 networkResponse="" // reset
1296 msoLogger.debug(" Network Adapter create responseCode: " + returnCode)
1298 String errorMessage = ""
1299 if (returnCode == "200") {
1300 execution.setVariable(Prefix + "isNetworkRollbackNeeded", true)
1301 execution.setVariable(Prefix + "createNetworkResponse", networkResponse)
1302 msoLogger.debug(" Network Adapter create Success Response - " + "\n" + networkResponse)
1304 // prepare rollback data
1305 String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","")
1306 rollbackData = rollbackData.replace("rollback>", "networkRollback>")
1307 String rollbackNetwork =
1308 """<rollbackNetworkRequest>
1310 </rollbackNetworkRequest>"""
1311 String rollbackNetworkXml = utils.formatXml(rollbackNetwork)
1312 execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml)
1313 msoLogger.debug(" Network Adapter rollback data - " + "\n" + rollbackNetworkXml)
1315 } else { // network error
1316 if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx
1317 if (networkResponse.contains("createNetworkError")) {
1318 networkResponse = networkResponse.replace('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', '')
1319 errorMessage = utils.getNodeText(networkResponse, "message")
1320 errorMessage = "Received error from Network Adapter: " + errorMessage
1321 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
1323 } else { // CatchAll exception
1324 if (returnCode == "500") {
1325 errorMessage = "JBWEB000065: HTTP Status 500."
1327 errorMessage = "Return code is " + returnCode
1329 errorMessage = "Received error from Network Adapter: " + errorMessage
1330 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
1334 } else { // CatchAll exception
1335 String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode
1336 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
1342 } catch (BpmnError e) {
1345 } catch (Exception ex) {
1346 String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. validateCreateNetworkResponse() - " + ex.getMessage()
1347 msoLogger.debug(exceptionMessage)
1348 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
1355 public void validateSDNCResponse (DelegateExecution execution) {
1357 execution.setVariable("prefix",Prefix)
1359 msoLogger.trace("Inside validateSDNCResponse() of DoCreateNetworkInstance")
1361 String response = execution.getVariable(Prefix + "assignSDNCResponse")
1362 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
1363 WorkflowException workflowException = execution.getVariable("WorkflowException")
1365 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
1366 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
1368 String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "assignSDNCResponse")
1369 assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace('<?xml version="1.0" encoding="UTF-8"?>', "")
1370 execution.setVariable(Prefix + "assignSDNCResponse", assignSDNCResponseDecodeXml)
1372 if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess'
1373 execution.setVariable(Prefix + "isSdncRollbackNeeded", true)
1374 msoLogger.debug("Successfully Validated SDNC Response")
1377 msoLogger.debug("Did NOT Successfully Validated SDNC Response")
1378 throw new BpmnError("MSOWorkflowException")
1383 public void validateRpcSDNCActivateResponse (DelegateExecution execution) {
1385 execution.setVariable("prefix",Prefix)
1387 msoLogger.trace("Inside validateRpcSDNCActivateResponse() of DoCreateNetworkInstance")
1389 String response = execution.getVariable(Prefix + "activateSDNCResponse")
1390 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
1391 WorkflowException workflowException = execution.getVariable("WorkflowException")
1393 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
1394 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
1396 String assignSDNCResponseDecodeXml = execution.getVariable(Prefix + "activateSDNCResponse")
1397 assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace('<?xml version="1.0" encoding="UTF-8"?>', "")
1398 execution.setVariable(Prefix + "activateSDNCResponse", assignSDNCResponseDecodeXml)
1400 if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess'
1401 execution.setVariable(Prefix + "isSdncActivateRollbackNeeded", true)
1402 msoLogger.debug("Successfully Validated Rpc SDNC Activate Response")
1405 msoLogger.debug("Did NOT Successfully Validated Rpc SDNC Activate Response")
1406 throw new BpmnError("MSOWorkflowException")
1412 public void prepareSDNCRollbackRequest (DelegateExecution execution) {
1414 execution.setVariable("prefix",Prefix)
1416 msoLogger.trace("Inside prepareSDNCRollbackRequest() of DoCreateNetworkInstance")
1420 String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
1421 String createNetworkInput = execution.getVariable(Prefix + "networkRequest")
1422 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
1423 String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse")
1424 String networkId = execution.getVariable(Prefix + "networkId")
1425 if (networkId == 'null') {networkId = ""}
1426 String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId")
1428 // 2. prepare rollback topology via SDNC Adapter SUBFLOW call
1429 String sndcTopologyRollbackRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, createNetworkInput, serviceInstanceId, sdncCallback, "rollback", "NetworkActivateRequest", cloudRegionId, networkId, null, null)
1430 String sndcTopologyRollbackRequestAsString = utils.formatXml(sndcTopologyRollbackRequest)
1431 execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRequestAsString)
1432 msoLogger.debug(" Preparing request for SDNC Topology 'rollback-NetworkActivateRequest' rollback . . . - " + "\n" + sndcTopologyRollbackRequestAsString)
1435 } catch (Exception ex) {
1436 String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSDNCRollbackRequest() - " + ex.getMessage()
1437 msoLogger.debug(exceptionMessage)
1438 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
1444 public void prepareRpcSDNCRollbackRequest (DelegateExecution execution) {
1446 execution.setVariable("prefix",Prefix)
1448 msoLogger.trace("Inside prepareRpcSDNCRollbackRequest() of DoCreateNetworkInstance")
1452 String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
1453 String createNetworkInput = execution.getVariable(Prefix + "networkRequest")
1454 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
1455 String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse")
1456 String networkId = execution.getVariable(Prefix + "networkId")
1457 if (networkId == 'null') {networkId = ""}
1458 String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId")
1460 // 2. prepare rollback topology via SDNC Adapter SUBFLOW call
1461 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "unassign", "DeleteNetworkInstance", cloudRegionId, networkId, null)
1462 String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
1463 execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRpcRequestAsString)
1464 msoLogger.debug(" Preparing request for SDNC Topology 'unassign-DeleteNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString)
1467 } catch (Exception ex) {
1468 String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCRollbackRequest() - " + ex.getMessage()
1469 msoLogger.debug(exceptionMessage)
1470 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
1476 public void prepareRpcSDNCActivateRollback(DelegateExecution execution) {
1478 execution.setVariable("prefix",Prefix)
1480 msoLogger.trace("Inside prepareRpcSDNCActivateRollback() of DoCreateNetworkInstance")
1485 String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
1486 String createNetworkInput = execution.getVariable(Prefix + "networkRequest")
1487 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
1488 String activateSDNCResponse = execution.getVariable(Prefix + "activateSDNCResponse")
1489 String networkId = execution.getVariable(Prefix + "networkId")
1490 if (networkId == 'null') {networkId = ""}
1491 String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId")
1493 // 2. prepare rollback topology via SDNC Adapter SUBFLOW call
1494 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null)
1495 String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
1496 execution.setVariable(Prefix + "rollbackActivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString)
1497 msoLogger.debug(" Preparing request for RPC SDNC Topology 'deactivate-DeleteNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString)
1500 } catch (Exception ex) {
1501 String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCActivateRollback() - " + ex.getMessage()
1502 msoLogger.debug(exceptionMessage)
1503 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
1509 public void prepareRollbackData(DelegateExecution execution) {
1511 execution.setVariable("prefix",Prefix)
1513 msoLogger.trace("Inside prepareRollbackData() of DoCreateNetworkInstance")
1517 Map<String, String> rollbackData = new HashMap<String, String>();
1518 String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest")
1519 if (rollbackSDNCRequest != null) {
1520 if (rollbackSDNCRequest != "") {
1521 rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest"))
1524 String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest")
1525 if (rollbackNetworkRequest != null) {
1526 if (rollbackNetworkRequest != "") {
1527 rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest"))
1530 String rollbackActivateSDNCRequest = execution.getVariable(Prefix + "rollbackActivateSDNCRequest")
1531 if (rollbackActivateSDNCRequest != null) {
1532 if (rollbackActivateSDNCRequest != "") {
1533 rollbackData.put("rollbackActivateSDNCRequest", execution.getVariable(Prefix + "rollbackActivateSDNCRequest"))
1536 execution.setVariable("rollbackData", rollbackData)
1537 msoLogger.debug("** rollbackData : " + rollbackData)
1539 execution.setVariable("WorkflowException", execution.getVariable(Prefix + "WorkflowException"))
1540 msoLogger.debug("** WorkflowException : " + execution.getVariable("WorkflowException"))
1542 } catch (Exception ex) {
1543 String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRollbackData() - " + ex.getMessage()
1544 msoLogger.debug(exceptionMessage)
1545 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
1551 public void postProcessResponse(DelegateExecution execution) {
1553 execution.setVariable("prefix",Prefix)
1555 msoLogger.trace("Inside postProcessResponse() of DoCreateNetworkInstance")
1560 // 1. Silent Success: execution.getVariable("CRENWKI_orchestrationStatus") == "ACTIVE"
1561 // 2. Success: execution.getVariable("WorkflowException") == null (NULL)
1562 // 3. WorkflowException: execution.getVariable("WorkflowException") != null (NOT NULL)
1564 msoLogger.debug(" ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException"))
1566 if (execution.getVariable(Prefix + "isException") == false) {
1567 // set rollback data
1568 execution.setVariable("orchestrationStatus", "")
1569 execution.setVariable("networkId", execution.getVariable(Prefix + "networkId"))
1570 execution.setVariable("networkName", execution.getVariable(Prefix + "networkName"))
1571 prepareSuccessRollbackData(execution) // populate rollbackData
1572 execution.setVariable("WorkflowException", null)
1573 execution.setVariable(Prefix + "Success", true)
1574 msoLogger.debug(" ***** postProcessResponse(), GOOD !!!")
1576 // inside sub-flow logic
1577 execution.setVariable(Prefix + "Success", false)
1578 execution.setVariable("rollbackData", null)
1579 String exceptionMessage = " Exception encountered in MSO Bpmn. "
1580 if (execution.getVariable("workflowException") != null) { // Output of Rollback flow.
1581 msoLogger.debug(" ***** workflowException: " + execution.getVariable("workflowException"))
1582 WorkflowException wfex = execution.getVariable("workflowException")
1583 exceptionMessage = wfex.getErrorMessage()
1585 if (execution.getVariable(Prefix + "WorkflowException") != null) {
1586 WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException")
1587 exceptionMessage = pwfex.getErrorMessage()
1590 // going to the Main flow: a-la-carte or macro
1591 msoLogger.debug(" ***** postProcessResponse(), BAD !!!")
1592 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
1593 throw new BpmnError("MSOWorkflowException")
1596 } catch(BpmnError b){
1597 msoLogger.debug("Rethrowing MSOWorkflowException")
1600 } catch (Exception ex) {
1601 String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. postProcessResponse() - " + ex.getMessage()
1602 msoLogger.debug(exceptionMessage)
1603 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
1604 throw new BpmnError("MSOWorkflowException")
1612 public void prepareSuccessRollbackData(DelegateExecution execution) {
1614 execution.setVariable("prefix",Prefix)
1616 msoLogger.trace("Inside prepareSuccessRollbackData() of DoCreateNetworkInstance")
1620 if (execution.getVariable("sdncVersion") != '1610') {
1621 prepareRpcSDNCRollbackRequest(execution)
1622 prepareRpcSDNCActivateRollback(execution)
1624 prepareSDNCRollbackRequest(execution)
1627 Map<String, String> rollbackData = new HashMap<String, String>();
1628 String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest")
1629 if (rollbackSDNCRequest != null) {
1630 if (rollbackSDNCRequest != "") {
1631 rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest)
1634 String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest")
1635 if (rollbackNetworkRequest != null) {
1636 if (rollbackNetworkRequest != "") {
1637 rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest)
1640 String rollbackActivateSDNCRequest = execution.getVariable(Prefix + "rollbackActivateSDNCRequest")
1641 if (rollbackActivateSDNCRequest != null) {
1642 if (rollbackActivateSDNCRequest != "") {
1643 rollbackData.put("rollbackActivateSDNCRequest", rollbackActivateSDNCRequest)
1646 execution.setVariable("rollbackData", rollbackData)
1648 msoLogger.debug("** 'rollbackData' for Full Rollback : " + rollbackData)
1649 execution.setVariable("WorkflowException", null)
1652 } catch (Exception ex) {
1653 String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage()
1654 msoLogger.debug(exceptionMessage)
1655 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
1661 public void setExceptionFlag(DelegateExecution execution){
1663 execution.setVariable("prefix",Prefix)
1665 msoLogger.trace("Inside setExceptionFlag() of DoCreateNetworkInstance")
1669 execution.setVariable(Prefix + "isException", true)
1671 if (execution.getVariable("SavedWorkflowException1") != null) {
1672 execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1"))
1674 execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException"))
1676 msoLogger.debug(Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException"))
1678 } catch(Exception ex){
1679 String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. setExceptionFlag(): " + ex.getMessage()
1680 msoLogger.debug(exceptionMessage)
1681 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
1687 // *******************************
1688 // Build Error Section
1689 // *******************************
1693 public void processJavaException(DelegateExecution execution){
1695 execution.setVariable("prefix",Prefix)
1698 msoLogger.debug( "Caught a Java Exception in " + Prefix)
1699 msoLogger.debug("Started processJavaException Method")
1700 msoLogger.debug("Variables List: " + execution.getVariables())
1701 execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated
1702 exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception")
1704 }catch(Exception e){
1705 msoLogger.debug("Caught Exception during processJavaException Method: " + e)
1706 execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated
1707 exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix)
1709 msoLogger.debug( "Completed processJavaException Method in " + Prefix)