2 * © 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
\r
4 package org.openecomp.mso.bpmn.vcpe.scripts;
\r
6 import groovy.xml.XmlUtil
\r
9 import org.openecomp.mso.bpmn.core.json.JsonUtils
\r
10 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
\r
11 import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils
\r
12 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
\r
13 import org.openecomp.mso.bpmn.common.scripts.VidUtils
\r
14 import org.openecomp.mso.bpmn.core.RollbackData
\r
15 import org.openecomp.mso.bpmn.core.WorkflowException
\r
16 import org.openecomp.mso.bpmn.core.domain.*
\r
18 import java.util.UUID;
\r
20 import org.camunda.bpm.engine.delegate.BpmnError
\r
21 import org.camunda.bpm.engine.runtime.Execution
\r
22 import org.json.JSONObject;
\r
23 import org.json.JSONArray;
\r
24 import org.apache.commons.lang3.*
\r
25 import org.apache.commons.codec.binary.Base64;
\r
26 import org.springframework.web.util.UriUtils;
\r
29 * This groovy class supports the <class>CreateVcpeResCustService.bpmn</class> process.
\r
34 public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {
\r
36 String Prefix="CVRCS_"
\r
37 ExceptionUtil exceptionUtil = new ExceptionUtil()
\r
38 JsonUtils jsonUtil = new JsonUtils()
\r
39 VidUtils vidUtils = new VidUtils()
\r
40 CatalogDbUtils catalogDbUtils = new CatalogDbUtils()
\r
43 * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process.
\r
46 public InitializeProcessVariables(Execution execution){
\r
47 /* Initialize all the process variables in this block */
\r
49 execution.setVariable("createVcpeServiceRequest", "")
\r
50 execution.setVariable("globalSubscriberId", "")
\r
51 execution.setVariable("serviceInstanceName", "")
\r
52 execution.setVariable("msoRequestId", "")
\r
53 execution.setVariable("CVRCS_NetworksCreatedCount", 0)
\r
54 execution.setVariable("CVRCS_VnfsCreatedCount", 0)
\r
55 execution.setVariable("productFamilyId", "")
\r
56 execution.setVariable("brgWanMacAddress", "")
\r
59 execution.setVariable("sdncVersion", "1707")
\r
62 // **************************************************
\r
63 // Pre or Prepare Request Section
\r
64 // **************************************************
\r
66 * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process.
\r
69 public void preProcessRequest (Execution execution) {
\r
70 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
71 execution.setVariable("prefix",Prefix)
\r
73 utils.log("DEBUG", " ***** Inside preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled)
\r
76 // initialize flow variables
\r
77 InitializeProcessVariables(execution)
\r
79 // check for incoming json message/input
\r
80 String createVcpeServiceRequest = execution.getVariable("bpmnRequest")
\r
81 utils.logAudit(createVcpeServiceRequest)
\r
82 execution.setVariable("createVcpeServiceRequest", createVcpeServiceRequest);
\r
83 println 'createVcpeServiceRequest - ' + createVcpeServiceRequest
\r
85 // extract requestId
\r
86 String requestId = execution.getVariable("mso-request-id")
\r
87 execution.setVariable("msoRequestId", requestId)
\r
89 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
91 if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) {
\r
92 serviceInstanceId = UUID.randomUUID().toString()
\r
93 utils.log("DEBUG", " Generated new Service Instance: " + serviceInstanceId , isDebugEnabled)
\r
95 utils.log("DEBUG", "Using provided Service Instance ID: " + serviceInstanceId , isDebugEnabled)
\r
98 serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8")
\r
99 execution.setVariable("serviceInstanceId", serviceInstanceId)
\r
101 String requestAction = execution.getVariable("requestAction")
\r
102 execution.setVariable("requestAction", requestAction)
\r
104 setBasicDBAuthHeader(execution, isDebugEnabled)
\r
106 String source = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.source")
\r
107 if ((source == null) || (source.isEmpty())) {
\r
108 execution.setVariable("source", "VID")
\r
110 execution.setVariable("source", source)
\r
113 // extract globalSubscriberId
\r
114 String globalSubscriberId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId")
\r
116 // verify element global-customer-id is sent from JSON input, throw exception if missing
\r
117 if ((globalSubscriberId == null) || (globalSubscriberId.isEmpty())) {
\r
118 String dataErrorMessage = " Element 'globalSubscriberId' is missing. "
\r
119 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
\r
122 execution.setVariable("globalSubscriberId", globalSubscriberId)
\r
123 execution.setVariable("globalCustomerId", globalSubscriberId)
\r
126 // extract subscriptionServiceType
\r
127 String subscriptionServiceType = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestParameters.subscriptionServiceType")
\r
128 execution.setVariable("subscriptionServiceType", subscriptionServiceType)
\r
129 utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled)
\r
131 String suppressRollback = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.suppressRollback")
\r
132 execution.setVariable("disableRollback", suppressRollback)
\r
133 utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled)
\r
135 String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.productFamilyId")
\r
136 execution.setVariable("productFamilyId", productFamilyId)
\r
137 utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled)
\r
139 String subscriberInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.subscriberInfo")
\r
140 execution.setVariable("subscriberInfo", subscriberInfo)
\r
141 utils.log("DEBUG", "Incoming subscriberInfo is: " + subscriberInfo, isDebugEnabled)
\r
144 * Extracting User Parameters from incoming Request and converting into a Map
146 def jsonSlurper = new JsonSlurper()
147 def jsonOutput = new JsonOutput()
149 Map reqMap = jsonSlurper.parseText(createVcpeServiceRequest)
152 def userParams = reqMap.requestDetails?.requestParameters?.userParams
154 Map<String, String> inputMap = [:]
157 name, value -> inputMap.put(name, value)
158 if (name.equals("BRG_WAN_MAC_Address"))
159 execution.setVariable("brgWanMacAddress", value)
\r
163 utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled)
164 execution.setVariable("serviceInputParams", inputMap)
166 utils.log("DEBUG", "Incoming brgWanMacAddress is: " + execution.getVariable('brgWanMacAddress'), isDebugEnabled)
\r
168 //For Completion Handler & Fallout Handler
\r
169 String requestInfo =
\r
170 """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
\r
171 <request-id>${requestId}</request-id>
\r
172 <action>CREATE</action>
\r
173 <source>${source}</source>
\r
176 execution.setVariable("CVRCS_requestInfo", requestInfo)
\r
178 utils.log("DEBUG", " ***** Completed preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled)
\r
180 } catch (BpmnError e) {
\r
183 } catch (Exception ex){
\r
184 String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage()
\r
185 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
189 public void sendSyncResponse (Execution execution) {
\r
190 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
192 utils.log("DEBUG", " ***** Inside sendSyncResponse of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
195 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
196 String requestId = execution.getVariable("mso-request-id")
\r
198 // RESTResponse (for API Handler (APIH) Reply Task)
\r
199 String syncResponse ="""{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim()
\r
201 utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)
\r
202 sendWorkflowResponse(execution, 202, syncResponse)
\r
204 } catch (Exception ex) {
\r
205 String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected from method sendSyncResponse() - " + ex.getMessage()
\r
206 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
210 // *******************************
\r
212 // *******************************
\r
213 public void prepareDecomposeService(Execution execution) {
\r
214 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
217 utils.log("DEBUG", " ***** Inside prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
219 String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
\r
221 //serviceModelInfo JSON string will be used as-is for DoCreateServiceInstance BB
\r
222 String serviceModelInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.modelInfo")
\r
223 execution.setVariable("serviceModelInfo", serviceModelInfo)
\r
225 utils.log("DEBUG", " ***** Completed prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
226 } catch (Exception ex) {
\r
227 // try error in method block
\r
228 String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage()
\r
229 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
233 // *******************************
\r
235 // *******************************
\r
236 public void prepareCreateServiceInstance(Execution execution) {
\r
237 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
240 utils.log("DEBUG", " ***** Inside prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
243 * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject
\r
244 * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
\r
245 * ModelInfo modelInfo = serviceDecomposition.getModelInfo()
\r
248 String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
\r
249 // String serviceInputParams = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestParameters")
\r
250 // execution.setVariable("serviceInputParams", serviceInputParams)
\r
253 String serviceInstanceName = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.instanceName")
\r
254 execution.setVariable("serviceInstanceName", serviceInstanceName)
\r
256 ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
\r
257 execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonString())
\r
259 utils.log("DEBUG", " ***** Completed prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
260 } catch (Exception ex) {
\r
261 // try error in method block
\r
262 String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()
\r
263 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
267 public void postProcessServiceInstanceCreate (Execution execution){
\r
268 def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' +'execution=' + execution.getId() +')'
\r
269 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
270 logDebug('Entered ' + method, isDebugLogEnabled)
\r
272 String source = execution.getVariable("source")
\r
273 String requestId = execution.getVariable("mso-request-id")
\r
274 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
275 String serviceInstanceName = execution.getVariable("serviceInstanceName")
\r
279 String payload = """
\r
280 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb">
\r
283 <req:updateInfraRequest>
\r
284 <requestId>${requestId}</requestId>
\r
285 <lastModifiedBy>BPEL</lastModifiedBy>
\r
286 <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
\r
287 <serviceInstanceName>${serviceInstanceName}</serviceInstanceName>
\r
288 </req:updateInfraRequest>
\r
290 </soapenv:Envelope>
\r
292 execution.setVariable("CVRCS_setUpdateDbInstancePayload", payload)
\r
293 utils.logAudit("CVRCS_setUpdateDbInstancePayload: " + payload)
\r
294 logDebug('Exited ' + method, isDebugLogEnabled)
\r
296 } catch (BpmnError e) {
\r
298 } catch (Exception e) {
\r
299 logError('Caught exception in ' + method, e)
\r
300 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
\r
305 public void processDecomposition (Execution execution) {
\r
306 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
308 utils.log("DEBUG", " ***** Inside getDataFromDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
312 ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
\r
313 List<NetworkResource> networkList = serviceDecomposition.getServiceNetworks()
\r
316 execution.setVariable("networkList", networkList)
\r
317 execution.setVariable("networkListString", networkList.toString())
\r
319 utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled)
\r
321 if (networkList != null && networkList.size() > 0) {
\r
322 execution.setVariable("CVRCS_NetworksCount", networkList.size())
\r
323 utils.log("DEBUG", "networks to create: "+ networkList.size(), isDebugEnabled)
\r
325 execution.setVariable("CVRCS_NetworksCount", 0)
\r
326 utils.log("DEBUG", "no networks to create based upon serviceDecomposition content", isDebugEnabled)
\r
330 List<VnfResource> vnfList = serviceDecomposition.getServiceVnfs()
\r
331 execution.setVariable("vnfList", vnfList)
\r
332 execution.setVariable("vnfListString", vnfList.toString())
\r
334 String vnfModelInfoString = ""
\r
335 if (vnfList != null && vnfList.size() > 0) {
\r
336 execution.setVariable("CVRCS_VNFsCount", vnfList.size())
\r
337 utils.log("DEBUG", "vnfs to create: "+ vnfList.size(), isDebugEnabled)
\r
338 ModelInfo vnfModelInfo = vnfList[0].getModelInfo()
\r
340 vnfModelInfoString = vnfModelInfo.toString()
\r
341 String vnfModelInfoWithRoot = vnfModelInfo.toString()
\r
342 vnfModelInfoString = jsonUtil.getJsonValue(vnfModelInfoWithRoot, "modelInfo")
\r
344 execution.setVariable("CVRCS_VNFsCount", 0)
\r
345 utils.log("DEBUG", "no vnfs to create based upon serviceDecomposition content", isDebugEnabled)
\r
348 execution.setVariable("vnfModelInfo", vnfModelInfoString)
\r
349 execution.setVariable("vnfModelInfoString", vnfModelInfoString)
\r
350 utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled)
\r
352 utils.log("DEBUG", " ***** Completed getDataFromDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
353 } catch (Exception ex) {
\r
354 sendSyncError(execution)
\r
355 String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. getDataFromDecomposition() - " + ex.getMessage()
\r
356 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
357 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
361 // *******************************
\r
362 // Generate Network request Section
\r
363 // *******************************
\r
364 public void prepareNetworkCreate (Execution execution) {
\r
365 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
368 utils.log("DEBUG", " ***** Inside preparenNetworkCreate of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
371 String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
\r
373 List<NetworkResource> networkList = execution.getVariable("networkList")
\r
374 utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled)
\r
376 Integer networksCreatedCount = execution.getVariable("CVRCS_NetworksCreatedCount")
\r
377 String networkModelInfoString = ""
\r
379 if (networkList != null) {
\r
380 utils.log("DEBUG", " getting model info for network # :" + networksCreatedCount, isDebugEnabled)
\r
381 ModelInfo networkModelInfo = networkList[networksCreatedCount.intValue()].getModelInfo()
\r
382 //Currently use String representation in JSON format as an input
\r
383 //execution.setVariable("networkModelInfo", networkModelInfo)
\r
384 networkModelInfoString = networkModelInfo.toJsonStringNoRootName()
\r
386 String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected number of networks to create - " + ex.getMessage()
\r
387 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
390 //Currently use String representation in JSON format as an input
\r
391 execution.setVariable("networkModelInfo", networkModelInfoString)
\r
392 utils.log("DEBUG", " networkModelInfoString :" + networkModelInfoString, isDebugEnabled)
\r
394 // extract cloud configuration
\r
395 String lcpCloudRegionId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId")
\r
396 execution.setVariable("lcpCloudRegionId", lcpCloudRegionId)
\r
397 utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled)
\r
398 String tenantId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.tenantId")
\r
399 execution.setVariable("tenantId", tenantId)
\r
400 utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled)
\r
402 String sdncVersion = execution.getVariable("sdncVersion")
\r
403 utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled)
\r
405 // List<VnfResource> vnfList = execution.getVariable("vnfList")
\r
406 // utils.log("DEBUG", "vnfList: "+ vnfList.toString(), isDebugEnabled)
\r
408 // String vnfModelInfo = execution.getVariable("vnfModelInfo")
\r
409 // utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled)
\r
411 utils.log("DEBUG", " ***** Completed preparenNetworkCreate of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
412 } catch (Exception ex) {
\r
413 // try error in method block
\r
414 String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareNetworkCreate() - " + ex.getMessage()
\r
415 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
419 // *******************************
\r
420 // Validate Network request Section -> increment count
\r
421 // *******************************
\r
422 public void validateNetworkCreate (Execution execution) {
\r
423 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
426 utils.log("DEBUG", " ***** Inside validateNetworkCreate of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
428 Integer networksCreatedCount = execution.getVariable("CVRCS_NetworksCreatedCount")
\r
429 networksCreatedCount++
\r
430 execution.setVariable("CVRCS_NetworksCreatedCount", networksCreatedCount)
\r
432 execution.setVariable("DCRENI_rollbackData"+networksCreatedCount, execution.getVariable("DCRENI_rollbackData"))
\r
434 utils.log("DEBUG", "networksCreatedCount: "+ networksCreatedCount, isDebugEnabled)
\r
435 utils.log("DEBUG", "DCRENI_rollbackData N : "+ execution.getVariable("DCRENI_rollbackData"+networksCreatedCount), isDebugEnabled)
\r
437 // JSONArray vnfList = execution.getVariable("vnfList")
\r
438 // utils.log("DEBUG", "vnfList: "+ vnfList, isDebugEnabled)
\r
440 String vnfModelInfo = execution.getVariable("vnfModelInfo")
\r
441 utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled)
\r
443 List<NetworkResource> networkList = execution.getVariable("networkList")
\r
444 utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled)
\r
446 utils.log("DEBUG", " ***** Completed validateNetworkCreate of CreateVcpeResCustService ***** "+" network # "+networksCreatedCount, isDebugEnabled)
\r
447 } catch (Exception ex) {
\r
448 // try error in method block
\r
449 String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method validateNetworkCreate() - " + ex.getMessage()
\r
450 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
455 public void prepareCreateAllottedResourceTXC(Execution execution) {
\r
456 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
459 utils.log("DEBUG", " ***** Inside prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
462 * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject
\r
463 * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
\r
464 * ModelInfo modelInfo = serviceDecomposition.getModelInfo()
\r
467 String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
\r
468 ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
\r
470 //parentServiceInstanceId
\r
471 //The parentServiceInstanceId will be a Landing Network service. This value will have been provided to the calling flow by SNIRO query (homing solution).
\r
472 //serviceDecomposition.getServiceNetworks()
\r
474 //For 1707, the vIPR Tenant OAM flow will use the BRG allotted resource parent service ID (since it is known that the security zone also comes from the vIPR FW).
\r
475 //Beyond 1707, this would need to be captured somehow in TOSCA model and also provided by SNIRO.
\r
477 //allottedResourceModelInfo
\r
478 //allottedResourceRole
\r
479 //The model Info parameters are a JSON structure as defined in the Service Instantiation API.
\r
480 //It would be sufficient to only include the service model UUID (i.e. the modelVersionId), since this BB will query the full model from the Catalog DB.
\r
481 List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources()
\r
482 if (allottedResources != null) {
\r
483 Iterator iter = allottedResources.iterator();
\r
484 while (iter.hasNext()){
\r
485 AllottedResource allottedResource = (AllottedResource)iter.next();
\r
487 utils.log("DEBUG", " getting model info for AllottedResource # :" + allottedResource.toJsonString(), isDebugEnabled)
\r
488 utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType(), isDebugEnabled)
\r
489 if(allottedResource.getAllottedResourceType() != null && allottedResource.getAllottedResourceType().equalsIgnoreCase("TunnelXConn")){
\r
490 //set create flag to true
\r
491 execution.setVariable("createTXCAR", true)
\r
492 ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo()
\r
493 execution.setVariable("allottedResourceModelInfoTXC", allottedResourceModelInfo.toJsonString())
\r
494 execution.setVariable("allottedResourceRoleTXC", allottedResource.getAllottedResourceRole())
\r
495 execution.setVariable("allottedResourceTypeTXC", allottedResource.getAllottedResourceType())
\r
497 //from Homing Solution. This is the infraServiceInstanceId in the BRG Allotted Resource decomposition structure.
\r
498 execution.setVariable("parentServiceInstanceIdTXC", allottedResource.getHomingSolution().getServiceInstanceId())
\r
503 //Populate with the A&AI network ID (l3-network object) for the Tenant OAM network that was created in prior step
\r
504 //String sourceNetworkId = execution.getVariable("networkId")
\r
505 //execution.setVariable("sourceNetworkId", sourceNetworkId)
\r
506 //Populate with the network-role (from A&AI l3-network object) for the Tenant OAM network from prior step
\r
508 //List<NetworkResource> networkResources = serviceDecomposition.getServiceNetworks()
\r
509 //if (networkResources != null) {
\r
510 //Iterator iter = networkResources.iterator();
\r
511 //while (iter.hasNext()){
\r
512 //NetworkResource networkResource = (NetworkResource)iter.next();
\r
513 //execution.setVariable("sourceNetworkRole", networkResource.getNetworkRole())
\r
518 String allottedResourceId = execution.getVariable("allottedResourceId")
\r
519 execution.setVariable("allottedResourceIdTXC", allottedResourceId)
\r
520 utils.log("DEBUG", "setting allottedResourceId CreateVcpeResCustService "+allottedResourceId, isDebugEnabled)
\r
522 utils.log("DEBUG", " ***** Completed prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
523 } catch (Exception ex) {
\r
524 // try error in method block
\r
525 String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceTXC flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()
\r
526 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
529 public void prepareCreateAllottedResourceBRG(Execution execution) {
\r
530 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
533 utils.log("DEBUG", " ***** Inside prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
536 * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject
\r
537 * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
\r
538 * ModelInfo modelInfo = serviceDecomposition.getModelInfo()
\r
541 String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
\r
542 ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
\r
544 //parentServiceInstanceId
\r
545 //The parentServiceInstanceId will be a Landing Network service. This value will have been provided to the calling flow by SNIRO query (homing solution).
\r
546 //serviceDecomposition.getServiceNetworks()
\r
548 //For 1707, the vIPR Tenant OAM flow will use the BRG allotted resource parent service ID (since it is known that the security zone also comes from the vIPR FW).
\r
549 //Beyond 1707, this would need to be captured somehow in TOSCA model and also provided by SNIRO.
\r
551 //allottedResourceModelInfo
\r
552 //allottedResourceRole
\r
553 //The model Info parameters are a JSON structure as defined in the Service Instantiation API.
\r
554 //It would be sufficient to only include the service model UUID (i.e. the modelVersionId), since this BB will query the full model from the Catalog DB.
\r
555 List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources()
\r
556 if (allottedResources != null) {
\r
557 Iterator iter = allottedResources.iterator();
\r
558 while (iter.hasNext()){
\r
559 AllottedResource allottedResource = (AllottedResource)iter.next();
\r
561 utils.log("DEBUG", " getting model info for AllottedResource # :" + allottedResource.toJsonString(), isDebugEnabled)
\r
562 utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType(), isDebugEnabled)
\r
563 if (allottedResource.getAllottedResourceType() != null && allottedResource.getAllottedResourceType().equalsIgnoreCase("BRG")) {
\r
564 //set create flag to true
\r
565 execution.setVariable("createBRGAR", true)
\r
566 ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo()
\r
567 execution.setVariable("allottedResourceModelInfoBRG", allottedResourceModelInfo.toJsonString())
\r
568 execution.setVariable("allottedResourceRoleBRG", allottedResource.getAllottedResourceRole())
\r
569 execution.setVariable("allottedResourceTypeBRG", allottedResource.getAllottedResourceType())
\r
570 //For 1707, the vIPR Tenant OAM flow will use the BRG allotted resource parent service ID (since it is known that the security zone also comes from the vIPR FW).
\r
571 //This Id should be taken from the homing solution for the BRG resource.
\r
572 //After decomposition and homing BBs, there should be an allotted resource object in the decomposition that represents the BRG,
\r
573 //and in its homingSolution section should be found the infraServiceInstanceId (i.e. infraServiceInstanceId in BRG Allotted Resource structure) (which the Homing BB would have populated).
\r
575 //from Homing Solution. This is the infraServiceInstanceId in the BRG Allotted Resource decomposition structure.
\r
576 execution.setVariable("parentServiceInstanceIdBRG", allottedResource.getHomingSolution().getServiceInstanceId())
\r
581 //Populate with the A&AI network ID (l3-network object) for the Tenant OAM network that was created in prior step
\r
582 //String sourceNetworkId = execution.getVariable("networkId")
\r
583 //execution.setVariable("sourceNetworkId", sourceNetworkId)
\r
584 //Populate with the network-role (from A&AI l3-network object) for the Tenant OAM network from prior step
\r
586 //List<NetworkResource> networkResources = serviceDecomposition.getServiceNetworks()
\r
587 //if (networkResources != null) {
\r
588 //Iterator iter = networkResources.iterator();
\r
589 //while (iter.hasNext()){
\r
590 //NetworkResource networkResource = (NetworkResource)iter.next();
\r
591 //execution.setVariable("sourceNetworkRole", networkResource.getNetworkRole())
\r
596 String allottedResourceId = execution.getVariable("allottedResourceId")
\r
597 execution.setVariable("allottedResourceIdBRG", allottedResourceId)
\r
598 utils.log("DEBUG", "setting allottedResourceId CreateVcpeResCustService "+allottedResourceId, isDebugEnabled)
\r
600 utils.log("DEBUG", " ***** Completed prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
601 } catch (Exception ex) {
\r
602 // try error in method block
\r
603 String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceBRG flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage()
\r
604 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
610 // *******************************
\r
611 // Generate Network request Section
\r
612 // *******************************
\r
613 public void prepareVnfAndModulesCreate (Execution execution) {
\r
614 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
617 utils.log("DEBUG", " ***** Inside prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
619 // String disableRollback = execution.getVariable("disableRollback")
\r
620 // def backoutOnFailure = ""
\r
621 // if(disableRollback != null){
\r
622 // if ( disableRollback == true) {
\r
623 // backoutOnFailure = "false"
\r
624 // } else if ( disableRollback == false) {
\r
625 // backoutOnFailure = "true"
\r
628 //failIfExists - optional
\r
630 String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest")
\r
631 String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.productFamilyId")
\r
632 execution.setVariable("productFamilyId", productFamilyId)
\r
633 utils.log("DEBUG","productFamilyId: "+ productFamilyId, isDebugEnabled)
\r
635 List<VnfResource> vnfList = execution.getVariable("vnfList")
\r
637 Integer vnfsCreatedCount = execution.getVariable("CVRCS_VnfsCreatedCount")
\r
638 String vnfModelInfoString = null;
\r
640 if (vnfList != null && vnfList.size() > 0 ) {
\r
641 utils.log("DEBUG", "getting model info for vnf # " + vnfsCreatedCount, isDebugEnabled)
\r
642 ModelInfo vnfModelInfo1 = vnfList[0].getModelInfo()
\r
643 utils.log("DEBUG", "got 0 ", isDebugEnabled)
\r
644 ModelInfo vnfModelInfo = vnfList[vnfsCreatedCount.intValue()].getModelInfo()
\r
645 vnfModelInfoString = vnfModelInfo.toString()
\r
647 //TODO: vnfList does not contain data. Need to investigate why ... . Fro VCPE use model stored
\r
648 vnfModelInfoString = execution.getVariable("vnfModelInfo")
\r
651 utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled)
\r
653 // extract cloud configuration
\r
654 String lcpCloudRegionId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId")
\r
655 execution.setVariable("lcpCloudRegionId", lcpCloudRegionId)
\r
656 utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled)
\r
657 String tenantId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.tenantId")
\r
658 execution.setVariable("tenantId", tenantId)
\r
659 utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled)
\r
661 String sdncVersion = execution.getVariable("sdncVersion")
\r
662 utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled)
\r
664 utils.log("DEBUG", " ***** Completed prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
665 } catch (Exception ex) {
\r
666 // try error in method block
\r
667 String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareVnfAndModulesCreate() - " + ex.getMessage()
\r
668 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
672 // *******************************
\r
673 // Validate Vnf request Section -> increment count
\r
674 // *******************************
\r
675 public void validateVnfCreate (Execution execution) {
\r
676 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
679 utils.log("DEBUG", " ***** Inside validateVnfCreate of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
681 Integer vnfsCreatedCount = execution.getVariable("CVRCS_VnfsCreatedCount")
\r
684 execution.setVariable("CVRCS_VnfsCreatedCount", vnfsCreatedCount)
\r
686 utils.log("DEBUG", " ***** Completed validateVnfCreate of CreateVcpeResCustService ***** "+" vnf # "+vnfsCreatedCount, isDebugEnabled)
\r
687 } catch (Exception ex) {
\r
688 // try error in method block
\r
689 String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method validateVnfCreate() - " + ex.getMessage()
\r
690 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
694 // *******************************
\r
695 // Validate Network request Section -> decrement count
\r
696 // *******************************
\r
697 public void validateNetworkRollback (Execution execution) {
\r
698 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
701 utils.log("DEBUG", " ***** Inside validateNetworkRollback of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
703 Integer networksCreatedCount = execution.getVariable("CVRCS_NetworksCreatedCount")
\r
704 networksCreatedCount--
\r
706 execution.setVariable("CVRCS_NetworksCreatedCount", networksCreatedCount)
\r
708 execution.setVariable("DCRENI_rollbackData", execution.getVariable("DCRENI_rollbackData"+networksCreatedCount))
\r
710 utils.log("DEBUG", " ***** Completed validateNetworkRollback of CreateVcpeResCustService ***** "+" network # "+networksCreatedCount, isDebugEnabled)
\r
711 } catch (Exception ex) {
\r
712 // try error in method block
\r
713 String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method validateNetworkRollback() - " + ex.getMessage()
\r
714 //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
715 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
716 execution.setVariable("CVRCS_NetworksCreatedCount", 0)
\r
717 utils.log("ERROR", exceptionMessage, true)
\r
721 // *****************************************
\r
722 // Prepare Completion request Section
\r
723 // *****************************************
\r
724 public void postProcessResponse (Execution execution) {
\r
725 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
727 utils.log("DEBUG", " ***** Inside postProcessResponse of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
730 String source = execution.getVariable("source")
\r
731 String requestId = execution.getVariable("mso-request-id")
\r
732 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
734 String msoCompletionRequest =
\r
735 """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
\r
736 xmlns:ns="http://org.openecomp/mso/request/types/v1">
\r
737 <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
\r
738 <request-id>${requestId}</request-id>
\r
739 <action>CREATE</action>
\r
740 <source>${source}</source>
\r
742 <status-message>Service Instance has been created successfully via macro orchestration</status-message>
\r
743 <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
\r
744 <mso-bpel-name>BPMN macro create</mso-bpel-name>
\r
745 </aetgt:MsoCompletionRequest>"""
\r
748 String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
\r
750 utils.logAudit(xmlMsoCompletionRequest)
\r
751 execution.setVariable("CVRCS_Success", true)
\r
752 execution.setVariable("CVRCS_CompleteMsoProcessRequest", xmlMsoCompletionRequest)
\r
753 utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
\r
754 } catch (BpmnError e) {
\r
756 } catch (Exception ex) {
\r
757 // try error in method block
\r
758 String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage()
\r
759 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
763 public void preProcessRollback (Execution execution) {
\r
764 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
765 utils.log("DEBUG"," ***** preProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
768 Object workflowException = execution.getVariable("WorkflowException");
\r
770 if (workflowException instanceof WorkflowException) {
\r
771 utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
\r
772 execution.setVariable("prevWorkflowException", workflowException);
\r
773 //execution.setVariable("WorkflowException", null);
\r
775 } catch (BpmnError e) {
\r
776 utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)
\r
777 } catch(Exception ex) {
\r
778 String msg = "Exception in preProcessRollback. " + ex.getMessage()
\r
779 utils.log("DEBUG", msg, isDebugEnabled)
\r
781 utils.log("DEBUG"," *** Exit preProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled)
\r
784 public void postProcessRollback (Execution execution) {
\r
785 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
786 utils.log("DEBUG"," ***** postProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
789 Object workflowException = execution.getVariable("prevWorkflowException");
\r
790 if (workflowException instanceof WorkflowException) {
\r
791 utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)
\r
792 execution.setVariable("WorkflowException", workflowException);
\r
794 } catch (BpmnError b) {
\r
795 utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)
\r
797 } catch(Exception ex) {
\r
798 msg = "Exception in postProcessRollback. " + ex.getMessage()
\r
799 utils.log("DEBUG", msg, isDebugEnabled)
\r
801 utils.log("DEBUG"," *** Exit postProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled)
\r
804 public void prepareFalloutRequest(Execution execution){
\r
805 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
807 utils.log("DEBUG", " *** STARTED CreateVcpeResCustService prepareFalloutRequest Process *** ", isDebugEnabled)
\r
810 WorkflowException wfex = execution.getVariable("WorkflowException")
\r
811 utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled)
\r
812 String requestInfo = execution.getVariable("CVRCS_requestInfo")
\r
813 utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled)
\r
815 //TODO. hmmm. there is no way to UPDATE error message.
\r
816 // String errorMessage = wfex.getErrorMessage()
\r
817 // boolean successIndicator = execution.getVariable("DCRESI_rollbackSuccessful")
\r
818 // if (successIndicator){
\r
819 // errorMessage = errorMessage + ". Rollback successful."
\r
821 // errorMessage = errorMessage + ". Rollback not completed."
\r
824 String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)
\r
826 execution.setVariable("CVRCS_falloutRequest", falloutRequest)
\r
828 } catch (Exception ex) {
\r
829 utils.log("DEBUG", "Error Occured in CreateVcpeResCustService prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled)
\r
830 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVcpeResCustService prepareFalloutRequest Process")
\r
832 utils.log("DEBUG", "*** COMPLETED CreateVcpeResCustService prepareFalloutRequest Process ***", isDebugEnabled)
\r
836 public void sendSyncError (Execution execution) {
\r
837 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
838 execution.setVariable("prefix", Prefix)
\r
840 utils.log("DEBUG", " ***** Inside sendSyncError() of CreateVcpeResCustService ***** ", isDebugEnabled)
\r
843 String errorMessage = ""
\r
844 if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
\r
845 WorkflowException wfe = execution.getVariable("WorkflowException")
\r
846 errorMessage = wfe.getErrorMessage()
\r
848 errorMessage = "Sending Sync Error."
\r
851 String buildworkflowException =
\r
852 """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
\r
853 <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
\r
854 <aetgt:ErrorCode>7000</aetgt:ErrorCode>
\r
855 </aetgt:WorkflowException>"""
\r
857 utils.logAudit(buildworkflowException)
\r
858 sendWorkflowResponse(execution, 500, buildworkflowException)
\r
859 } catch (Exception ex) {
\r
860 utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
\r
864 public void processJavaException(Execution execution){
\r
865 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
866 execution.setVariable("prefix",Prefix)
\r
868 utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled)
\r
869 utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
\r
870 utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)
\r
871 execution.setVariable("CRESI_unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated
\r
872 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception")
\r
873 }catch(BpmnError b){
\r
874 utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled)
\r
876 }catch(Exception e){
\r
877 utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
\r
878 execution.setVariable("CRESI_unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated
\r
879 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method")
\r
881 utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled)
\r