2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.openecomp.mso.bpmn.infrastructure.scripts
22 import static org.apache.commons.lang3.StringUtils.*
24 import org.openecomp.mso.bpmn.core.RollbackData
25 import org.camunda.bpm.engine.delegate.BpmnError
26 import org.camunda.bpm.engine.delegate.DelegateExecution
27 import org.springframework.web.util.UriUtils
28 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
29 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
30 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
31 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
32 import org.openecomp.mso.bpmn.common.scripts.VidUtils
33 import org.openecomp.mso.bpmn.core.WorkflowException
34 import org.openecomp.mso.bpmn.core.domain.VnfResource
35 import org.openecomp.mso.bpmn.core.json.JsonUtils
39 * This class supports the DoCreateVnf building block subflow
40 * with the creation of a generic vnf for
44 class DoCreateVnf extends AbstractServiceTaskProcessor {
46 String Prefix="DoCVNF_"
47 ExceptionUtil exceptionUtil = new ExceptionUtil()
48 JsonUtils jsonUtil = new JsonUtils()
49 VidUtils vidUtils = new VidUtils(this)
50 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
53 * This method gets and validates the incoming
59 public void preProcessRequest(DelegateExecution execution) {
60 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
61 execution.setVariable("prefix",Prefix)
62 utils.log("DEBUG", " *** STARTED DoCreateVnf PreProcessRequest Process*** ", isDebugEnabled)
64 // DISABLE SDNC INTERACTION FOR NOW
65 execution.setVariable("SDNCInteractionEnabled", false)
72 def rollbackData = execution.getVariable("rollbackData")
73 if (rollbackData == null) {
74 rollbackData = new RollbackData()
77 String vnfModelInfo = execution.getVariable("vnfModelInfo")
78 String serviceModelInfo = execution.getVariable("serviceModelInfo")
80 String requestId = execution.getVariable("msoRequestId")
81 execution.setVariable("DoCVNF_requestId", requestId)
82 execution.setVariable("mso-request-id", requestId)
83 utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled)
85 String serviceInstanceId = execution.getVariable("serviceInstanceId")
86 execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId)
87 rollbackData.put("VNF", "serviceInstanceId", serviceInstanceId)
88 utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled)
90 String vnfType = execution.getVariable("vnfType")
91 execution.setVariable("DoCVNF_vnfType", vnfType)
92 utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled)
94 String vnfName = execution.getVariable("vnfName")
95 if (vnfName.equals("") || vnfName.equals("null")) {
98 execution.setVariable("DoCVNF_vnfName", vnfName)
99 utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled)
101 String serviceId = execution.getVariable("productFamilyId")
102 execution.setVariable("DoCVNF_serviceId", serviceId)
103 utils.log("DEBUG", "Incoming Service Id is: " + serviceId, isDebugEnabled)
105 String source = "VID"
106 execution.setVariable("DoCVNF_source", source)
107 rollbackData.put("VNF", "source", source)
108 utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled)
110 String suppressRollback = execution.getVariable("disableRollback")
111 execution.setVariable("DoCVNF_suppressRollback", suppressRollback)
112 utils.log("DEBUG", "Incoming Suppress Rollback is: " + suppressRollback, isDebugEnabled)
114 String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantUuid")
115 execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId)
116 utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled)
118 String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid")
119 if (modelVersionId == null) {
122 execution.setVariable("DoCVNF_modelVersionId", modelVersionId)
123 utils.log("DEBUG", "Incoming Version Id is: " + modelVersionId, isDebugEnabled)
125 String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion")
126 execution.setVariable("DoCVNF_modelVersion", modelVersion)
127 utils.log("DEBUG", "Incoming Model Version is: " + modelVersion, isDebugEnabled)
129 String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName")
130 execution.setVariable("DoCVNF_modelName", modelName)
131 utils.log("DEBUG", "Incoming Model Name is: " + modelName, isDebugEnabled)
133 String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid")
134 if (modelCustomizationId == null) {
135 modelCustomizationId = ""
137 execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId)
138 utils.log("DEBUG", "Incoming Model Customization Id is: " + modelCustomizationId, isDebugEnabled)
140 String cloudSiteId = execution.getVariable("lcpCloudRegionId")
141 execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId)
142 rollbackData.put("VNF", "cloudSiteId", cloudSiteId)
143 utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled)
145 String tenantId = execution.getVariable("tenantId")
146 execution.setVariable("DoCVNF_tenantId", tenantId)
147 rollbackData.put("VNF", "tenantId", tenantId)
148 utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId, isDebugEnabled)
150 String globalSubscriberId = execution.getVariable("globalSubscriberId")
151 if (globalSubscriberId == null) {
152 globalSubscriberId = ""
154 execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId)
155 utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled)
157 String sdncVersion = execution.getVariable("sdncVersion")
158 if (sdncVersion == null) {
161 execution.setVariable("DoCVNF_sdncVersion", sdncVersion)
162 utils.log("DEBUG", "Incoming Sdnc Version is: " + sdncVersion, isDebugEnabled)
164 //For Completion Handler & Fallout Handler
166 """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
167 <request-id>${requestId}</request-id>
168 <action>CREATE</action>
169 <source>${source}</source>
172 execution.setVariable("DoCVNF_requestInfo", requestInfo)
173 //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
174 String orchStatus = "Created"
175 execution.setVariable("DoCVNF_orchStatus", orchStatus)
177 //TODO: Equipment Role - Should come from SDN-C Response in 1702
178 String equipmentRole = " "
179 execution.setVariable("DoCVNF_equipmentRole", equipmentRole)
180 String vnfId = execution.getVariable("testVnfId") // for junits
182 vnfId = execution.getVariable("vnfId")
183 if (isBlank(vnfId)) {
184 vnfId = UUID.randomUUID().toString()
185 utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugEnabled)
188 execution.setVariable("DoCVNF_vnfId", vnfId)
190 // Setting for Sub Flow Calls
191 execution.setVariable("DoCVNF_type", "generic-vnf")
192 execution.setVariable("GENGS_type", "service-instance")
194 String sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
195 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
196 def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing'
198 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
200 execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl)
201 rollbackData.put("VNF", "sdncCallbackUrl", sdncCallbackUrl)
202 utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl)
203 logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled)
205 VnfResource vnfResource = (VnfResource) execution.getVariable((String)"vnfResourceDecomposition")
206 String nfRole = vnfResource.getNfRole()
208 execution.setVariable("DoCVNF_nfRole", nfRole)
209 logDebug("NF Role is: " + nfRole, isDebugEnabled)
211 String nfNamingCode = vnfResource.getNfNamingCode()
212 execution.setVariable("DoCVNF_nfNamingCode", nfNamingCode)
213 logDebug("NF Naming Code is: " + nfNamingCode, isDebugEnabled)
215 String nfType = vnfResource.getNfType()
216 execution.setVariable("DoCVNF_nfType", nfType)
217 logDebug("NF Type is: " + nfType, isDebugEnabled)
219 String nfFunction = vnfResource.getNfFunction()
220 execution.setVariable("DoCVNF_nfFunction", nfFunction)
221 logDebug("NF Function is: " + nfFunction, isDebugEnabled)
223 rollbackData.put("VNF", "rollbackSDNCAssign", "false")
224 rollbackData.put("VNF", "rollbackSDNCActivate", "false")
225 rollbackData.put("VNF", "rollbackVnfCreate", "false")
227 execution.setVariable("rollbackData", rollbackData)
230 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
233 utils.log("DEBUG", " Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage(), isDebugEnabled)
234 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest")
237 utils.log("DEBUG", "*** COMPLETED DoCreateVnf PreProcessRequest Process ***", isDebugEnabled)
240 private Object getVariableEnforced(DelegateExecution execution, String name){
241 Object enforced = execution.getVariable(name)
248 public void prepareCreateGenericVnf (DelegateExecution execution) {
249 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
250 execution.setVariable("prefix",Prefix)
252 utils.log("DEBUG", " *** STARTED DoCreateVnf PrepareCreateGenericVnf Process *** ", isDebugEnabled)
255 String vnfId = getVariableEnforced(execution, "DoCVNF_vnfId")
256 String vnfName = getVariableEnforced(execution, "DoCVNF_vnfName")
257 if (vnfName == null) {
258 vnfName = "sdncGenerated"
259 utils.log("DEBUG", "Sending a dummy VNF name to AAI - the name will be generated by SDNC: " + vnfName, isDebugEnabled)
261 String vnfType = getVariableEnforced(execution, "DoCVNF_vnfType")
262 utils.log("DEBUG", "WE ARE HERE:" + vnfType, isDebugEnabled)
263 String serviceId = getVariableEnforced(execution, "DoCVNF_serviceId")
264 String orchStatus = getVariableEnforced(execution, "DoCVNF_orchStatus")
265 String modelInvariantId = getVariableEnforced(execution, "DoCVNF_modelInvariantId")
266 String modelVersionId = getVariableEnforced(execution, "DoCVNF_modelVersionId")
267 String modelCustomizationId = getVariableEnforced(execution, "DoCVNF_modelCustomizationId")
268 // TODO: 1702 Variable
269 String equipmentRole = getVariableEnforced(execution, "DoCVNF_equipmentRole")
270 String nfType = getVariableEnforced(execution, "DoCVNF_nfType")
271 String nfRole = getVariableEnforced(execution, "DoCVNF_nfRole")
272 String nfFunction = getVariableEnforced(execution, "DoCVNF_nfFunction")
273 String nfNamingCode = getVariableEnforced(execution, "DoCVNF_nfNamingCode")
275 //Get Service Instance Info
276 String serviceInstanceId = getVariableEnforced(execution, "DoCVNF_serviceInstanceId")
277 String siRelatedLink = getVariableEnforced(execution, "GENGS_siResourceLink")
279 int custStart = siRelatedLink.indexOf("customer/")
280 int custEnd = siRelatedLink.indexOf("/service-subscriptions")
281 String globalCustId = siRelatedLink.substring(custStart + 9, custEnd)
282 int serviceStart = siRelatedLink.indexOf("service-subscription/")
283 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
284 String serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
285 serviceType = UriUtils.decode(serviceType,"UTF-8")
288 AaiUtil aaiUtil = new AaiUtil(this)
289 def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution)
290 String namespace = aaiUtil.getNamespaceFromUri(execution, aai_uri)
293 """<generic-vnf xmlns="${namespace}">
294 <vnf-id>${vnfId}</vnf-id>
295 <vnf-name>${vnfName}</vnf-name>
296 <service-id>${serviceId}</service-id>
297 <vnf-type>${vnfType}</vnf-type>
298 <prov-status>PREPROV</prov-status>
299 <orchestration-status>${orchStatus}</orchestration-status>
300 <model-invariant-id>${modelInvariantId}</model-invariant-id>
301 <model-version-id>${modelVersionId}</model-version-id>
302 <model-customization-id>${modelCustomizationId}</model-customization-id>
303 <nf-type>${nfType}</nf-type>
304 <nf-role>${nfRole}</nf-role>
305 <nf-function>${nfFunction}</nf-function>
306 <nf-naming-code>${nfNamingCode}</nf-naming-code>
309 <related-to>service-instance</related-to>
310 <related-link>${siRelatedLink}</related-link>
312 <relationship-key>customer.global-customer-id</relationship-key>
313 <relationship-value>${globalCustId}</relationship-value>
316 <relationship-key>service-subscription.service-type</relationship-key>
317 <relationship-value>${serviceType}</relationship-value>
320 <relationship-key>service-instance.service-instance-id</relationship-key>
321 <relationship-value>${serviceInstanceId}</relationship-value>
327 execution.setVariable("DoCVNF_genericVnfPayload", payload)
329 }catch(Exception ex) {
330 utils.log("DEBUG", "Error Occured in DoCreateVnf PrepareCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled)
331 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PrepareCreateGenericVnf Process")
333 utils.log("DEBUG", "*** COMPLETED DoCreateVnf PrepareCreateGenericVnf Process ***", isDebugEnabled)
336 public void postProcessCreateGenericVnf (DelegateExecution execution) {
337 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
338 execution.setVariable("prefix",Prefix)
340 utils.log("DEBUG", " *** STARTED DoCreateVnf PostProcessCreateGenericVnf Process *** ", isDebugEnabled)
343 String vnfId = execution.getVariable("DoCVNF_vnfId")
344 def rollbackData = execution.getVariable("rollbackData")
345 rollbackData.put("VNF", "vnfId", vnfId)
346 rollbackData.put("VNF", "rollbackVnfCreate", "true")
347 execution.setVariable("rollbackData", rollbackData)
348 }catch(Exception ex) {
349 utils.log("DEBUG", "Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled)
350 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process")
352 utils.log("DEBUG", "*** COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process ***", isDebugEnabled)
356 public void preProcessSDNCAssignRequest(DelegateExecution execution){
357 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
358 execution.setVariable("prefix", Prefix)
359 logDebug(" ======== STARTED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled)
360 def vnfId = execution.getVariable("DoCVNF_vnfId")
361 def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
362 logDebug("NEW VNF ID: " + vnfId, isDebugLogEnabled)
363 utils.logAudit("NEW VNF ID: " + vnfId)
368 String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign")
370 assignSDNCRequest = utils.formatXml(assignSDNCRequest)
371 execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest)
372 logDebug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest, isDebugLogEnabled)
373 utils.logAudit("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest)
376 utils.log("ERROR", "Exception Occured Processing preProcessSDNCAssignRequest. Exception is:\n" + e, isDebugLogEnabled)
377 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage())
379 logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled)
382 public void preProcessSDNCActivateRequest(DelegateExecution execution) {
383 def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' +
384 'execution=' + execution.getId() +
386 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
387 logDebug('Entered ' + method, isDebugLogEnabled)
388 execution.setVariable("prefix", Prefix)
389 logDebug(" ======== STARTED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled)
391 String vnfId = execution.getVariable("DoCVNF_vnfId")
392 String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
394 String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate")
396 execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest)
397 logDebug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest, isDebugLogEnabled)
398 utils.logAudit("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest)
401 log.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e, isDebugLogEnabled)
402 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage())
404 logDebug("======== COMPLETED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled)
407 public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
409 String uuid = execution.getVariable('testReqId') // for junits
411 uuid = execution.getVariable("DoCVNF_requestId") + "-" + System.currentTimeMillis()
413 def callbackURL = execution.getVariable("DoCVNF_sdncCallbackUrl")
414 def requestId = execution.getVariable("DoCVNF_requestId")
415 def serviceId = execution.getVariable("DoCVNF_serviceId")
416 def vnfType = execution.getVariable("DoCVNF_vnfType")
417 def vnfName = execution.getVariable("DoCVNF_vnfName")
418 // Only send vnfName to SDNC if it is not null, otherwise it will get generated by SDNC on Assign
419 String vnfNameString = ""
420 if (vnfName != null) {
421 vnfNameString = """<vnf-name>${vnfName}</vnf-name>"""
423 def tenantId = execution.getVariable("DoCVNF_tenantId")
424 def source = execution.getVariable("DoCVNF_source")
425 def vnfId = execution.getVariable("DoCVNF_vnfId")
426 def cloudSiteId = execution.getVariable("DoCVNF_cloudSiteId")
427 def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId")
428 def serviceModelInfo = execution.getVariable("serviceModelInfo")
429 def vnfModelInfo = execution.getVariable("vnfModelInfo")
430 String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
431 String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)
432 def globalSubscriberId = execution.getVariable("DoCVNF_globalSubscriberId")
433 def sdncVersion = execution.getVariable("DoCVNF_sdncVersion")
435 String sdncVNFParamsXml = ""
437 if(execution.getVariable("DoCVNF_vnfParamsExistFlag") == true){
438 sdncVNFParamsXml = buildSDNCParamsXml(execution)
440 sdncVNFParamsXml = ""
444 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
445 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
446 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
447 <sdncadapter:RequestHeader>
448 <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
449 <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
450 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
451 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
452 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
453 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
454 </sdncadapter:RequestHeader>
455 <sdncadapterworkflow:SDNCRequestData>
456 <request-information>
457 <request-id>${requestId}</request-id>
458 <request-action>CreateVnfInstance</request-action>
459 <source>${source}</source>
463 </request-information>
464 <service-information>
465 <service-id>${serviceId}</service-id>
466 <subscription-service-type>${serviceId}</subscription-service-type>
467 ${serviceEcompModelInformation}
468 <service-instance-id>${svcInstId}</service-instance-id>
469 <global-customer-id>${globalSubscriberId}</global-customer-id>
470 </service-information>
472 <vnf-id>${vnfId}</vnf-id>
473 <vnf-type>${vnfType}</vnf-type>
474 ${vnfEcompModelInformation}
478 <tenant>${tenantId}</tenant>
479 <aic-cloud-region>${cloudSiteId}</aic-cloud-region>
482 </sdncadapterworkflow:SDNCRequestData>
483 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
485 utils.logAudit("sdncRequest: " + sdncRequest)
489 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
490 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
491 execution.setVariable("prefix",Prefix)
492 logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
494 WorkflowException workflowException = execution.getVariable("WorkflowException")
495 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
497 utils.logAudit("workflowException: " + workflowException)
499 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
500 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
502 utils.logAudit("SDNCResponse: " + response)
504 String sdncResponse = response
505 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
506 logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled)
507 if(method.equals("get")){
508 String topologyGetResponse = execution.getVariable("DoCVNF_getSDNCAdapterResponse")
509 String data = utils.getNodeXml(topologyGetResponse, "response-data")
510 data = data.replaceAll("<", "<")
511 data = data.replaceAll(">", ">")
512 utils.log("DEBUG", "topologyGetResponseData: " + data, isDebugLogEnabled)
513 String vnfName = utils.getNodeText1(data, "vnf-name")
514 utils.log("DEBUG", "vnfName received from SDNC: " + vnfName, isDebugLogEnabled)
515 execution.setVariable("vnfName", vnfName)
516 execution.setVariable("DoCVNF_vnfName", vnfName)
518 def rollbackData = execution.getVariable("rollbackData")
519 if (method.equals("assign")) {
520 rollbackData.put("VNF", "rollbackSDNCAssign", "true")
522 else if (method.equals("activate")) {
523 rollbackData.put("VNF", "rollbackSDNCActivate", "true")
525 execution.setVariable("rollbackData", rollbackData)
529 logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
530 throw new BpmnError("MSOWorkflowException")
532 logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
535 public void preProcessSDNCGetRequest(DelegateExecution execution){
536 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
537 execution.setVariable("prefix", Prefix)
538 utils.log("DEBUG", " ======== STARTED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled)
540 def serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
542 String uuid = execution.getVariable('testReqId') // for junits
544 uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
547 def callbackUrl = execution.getVariable("DoCVFM_sdncCallbackUrl")
548 utils.logAudit("callbackUrl:" + callbackUrl)
550 def vnfId = execution.getVariable('DCVFM_vnfId')
553 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
557 svcInstId = serviceInstanceId
559 // serviceOperation will be retrieved from "object-path" element
560 // in SDNC Assign Response for VNF
561 String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse")
562 utils.logAudit("DoCVNF_assignSDNCAdapterResponse is: \n" + response)
564 String serviceOperation = ""
566 String data = utils.getNodeXml(response, "response-data")
567 data = data.replaceAll("<", "<")
568 data = data.replaceAll(">", ">")
569 utils.log("DEBUG", "responseData: " + data, isDebugLogEnabled)
570 serviceOperation = utils.getNodeText1(data, "object-path")
571 utils.log("DEBUG", "VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation, isDebugLogEnabled)
574 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
577 String SDNCGetRequest =
578 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
579 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
580 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
581 <sdncadapter:RequestHeader>
582 <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
583 <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
584 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
585 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
586 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
587 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
588 </sdncadapter:RequestHeader>
589 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
590 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
592 utils.logAudit("SDNCGetRequest: \n" + SDNCGetRequest)
593 execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest)
594 utils.log("DEBUG", "Outgoing GetSDNCRequest is: \n" + SDNCGetRequest, isDebugLogEnabled)
597 utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
598 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage())
600 utils.log("DEBUG", "======== COMPLETED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled)
604 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
606 * @param execution The flow's execution instance.
608 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
609 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
610 'execution=' + execution.getId() +
612 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
613 logDebug('Entered ' + method, isDebugLogEnabled)
616 def vnfId = execution.getVariable('DoCVNF_vnfId')
617 logDebug("VNF ID: " + vnfId, isDebugLogEnabled)
619 String updateAAIGenericVnfRequest = """
620 <UpdateAAIGenericVnfRequest>
621 <vnf-id>${vnfId}</vnf-id>
622 <orchestration-status>Active</orchestration-status>
623 </UpdateAAIGenericVnfRequest>
625 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
626 execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
627 utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
628 logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled)
631 logDebug('Exited ' + method, isDebugLogEnabled)
632 } catch (BpmnError e) {
634 } catch (Exception e) {
635 logError('Caught exception in ' + method, e)
636 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())