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.*
23 import org.openecomp.mso.bpmn.core.RollbackData
24 import org.camunda.bpm.engine.delegate.BpmnError
25 import org.camunda.bpm.engine.runtime.Execution
26 import org.springframework.web.util.UriUtils
27 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
28 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
29 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
30 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
31 import org.openecomp.mso.bpmn.common.scripts.VidUtils
32 import org.openecomp.mso.bpmn.core.WorkflowException
33 import org.openecomp.mso.bpmn.core.domain.VnfResource
34 import org.openecomp.mso.bpmn.core.json.JsonUtils
38 * This class supports the DoCreateVnf building block subflow
39 * with the creation of a generic vnf for
43 class DoCreateVnf extends AbstractServiceTaskProcessor {
45 String Prefix="DoCVNF_"
46 ExceptionUtil exceptionUtil = new ExceptionUtil()
47 JsonUtils jsonUtil = new JsonUtils()
48 VidUtils vidUtils = new VidUtils(this)
49 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
52 * This method gets and validates the incoming
58 public void preProcessRequest(Execution execution) {
59 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
60 execution.setVariable("prefix",Prefix)
61 utils.log("DEBUG", " *** STARTED DoCreateVnf PreProcessRequest Process*** ", isDebugEnabled)
63 // DISABLE SDNC INTERACTION FOR NOW
64 execution.setVariable("SDNCInteractionEnabled", false)
71 def rollbackData = execution.getVariable("rollbackData")
72 if (rollbackData == null) {
73 rollbackData = new RollbackData()
76 String vnfModelInfo = execution.getVariable("vnfModelInfo")
77 String serviceModelInfo = execution.getVariable("serviceModelInfo")
79 String requestId = execution.getVariable("msoRequestId")
80 execution.setVariable("DoCVNF_requestId", requestId)
81 execution.setVariable("mso-request-id", requestId)
82 utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled)
84 String serviceInstanceId = execution.getVariable("serviceInstanceId")
85 execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId)
86 rollbackData.put("VNF", "serviceInstanceId", serviceInstanceId)
87 utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled)
89 String vnfType = execution.getVariable("vnfType")
90 execution.setVariable("DoCVNF_vnfType", vnfType)
91 utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled)
93 String vnfName = execution.getVariable("vnfName")
94 if (vnfName.equals("") || vnfName.equals("null")) {
97 execution.setVariable("DoCVNF_vnfName", vnfName)
98 utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled)
100 String serviceId = execution.getVariable("productFamilyId")
101 execution.setVariable("DoCVNF_serviceId", serviceId)
102 utils.log("DEBUG", "Incoming Service Id is: " + serviceId, isDebugEnabled)
104 String source = "VID"
105 execution.setVariable("DoCVNF_source", source)
106 rollbackData.put("VNF", "source", source)
107 utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled)
109 String suppressRollback = execution.getVariable("disableRollback")
110 execution.setVariable("DoCVNF_suppressRollback", suppressRollback)
111 utils.log("DEBUG", "Incoming Suppress Rollback is: " + suppressRollback, isDebugEnabled)
113 String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantUuid")
114 execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId)
115 utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled)
117 String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid")
118 if (modelVersionId == null) {
121 execution.setVariable("DoCVNF_modelVersionId", modelVersionId)
122 utils.log("DEBUG", "Incoming Version Id is: " + modelVersionId, isDebugEnabled)
124 String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion")
125 execution.setVariable("DoCVNF_modelVersion", modelVersion)
126 utils.log("DEBUG", "Incoming Model Version is: " + modelVersion, isDebugEnabled)
128 String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName")
129 execution.setVariable("DoCVNF_modelName", modelName)
130 utils.log("DEBUG", "Incoming Model Name is: " + modelName, isDebugEnabled)
132 String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid")
133 if (modelCustomizationId == null) {
134 modelCustomizationId = ""
136 execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId)
137 utils.log("DEBUG", "Incoming Model Customization Id is: " + modelCustomizationId, isDebugEnabled)
139 String cloudSiteId = execution.getVariable("lcpCloudRegionId")
140 execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId)
141 rollbackData.put("VNF", "cloudSiteId", cloudSiteId)
142 utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled)
144 String tenantId = execution.getVariable("tenantId")
145 execution.setVariable("DoCVNF_tenantId", tenantId)
146 rollbackData.put("VNF", "tenantId", tenantId)
147 utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId, isDebugEnabled)
149 String globalSubscriberId = execution.getVariable("globalSubscriberId")
150 if (globalSubscriberId == null) {
151 globalSubscriberId = ""
153 execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId)
154 utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled)
156 String sdncVersion = execution.getVariable("sdncVersion")
157 if (sdncVersion == null) {
160 execution.setVariable("DoCVNF_sdncVersion", sdncVersion)
161 utils.log("DEBUG", "Incoming Sdnc Version is: " + sdncVersion, isDebugEnabled)
163 //For Completion Handler & Fallout Handler
165 """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
166 <request-id>${requestId}</request-id>
167 <action>CREATE</action>
168 <source>${source}</source>
171 execution.setVariable("DoCVNF_requestInfo", requestInfo)
172 //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
173 String orchStatus = "Created"
174 execution.setVariable("DoCVNF_orchStatus", orchStatus)
176 //TODO: Equipment Role - Should come from SDN-C Response in 1702
177 String equipmentRole = " "
178 execution.setVariable("DoCVNF_equipmentRole", equipmentRole)
179 String vnfId = execution.getVariable("testVnfId") // for junits
181 vnfId = execution.getVariable("vnfId")
182 if (isBlank(vnfId)) {
183 vnfId = UUID.randomUUID().toString()
184 utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugEnabled)
187 execution.setVariable("DoCVNF_vnfId", vnfId)
189 // Setting for Sub Flow Calls
190 execution.setVariable("DoCVNF_type", "generic-vnf")
191 execution.setVariable("GENGS_type", "service-instance")
193 String sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
194 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
195 def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing'
197 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
199 execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl)
200 rollbackData.put("VNF", "sdncCallbackUrl", sdncCallbackUrl)
201 utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl)
202 logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled)
204 VnfResource vnfResource = (VnfResource) execution.getVariable("vnfResourceDecomposition")
206 String nfRole = vnfResource.getNfRole()
207 execution.setVariable("DoCVNF_nfRole", nfRole)
208 logDebug("NF Role is: " + nfRole, isDebugEnabled)
210 String nfNamingCode = vnfResource.getNfNamingCode()
211 execution.setVariable("DoCVNF_nfNamingCode", nfNamingCode)
212 logDebug("NF Naming Code is: " + nfNamingCode, isDebugEnabled)
214 String nfType = vnfResource.getNfType()
215 execution.setVariable("DoCVNF_nfType", nfType)
216 logDebug("NF Type is: " + nfType, isDebugEnabled)
218 String nfFunction = vnfResource.getNfFunction()
219 execution.setVariable("DoCVNF_nfFunction", nfFunction)
220 logDebug("NF Function is: " + nfFunction, isDebugEnabled)
222 rollbackData.put("VNF", "rollbackSDNCAssign", "false")
223 rollbackData.put("VNF", "rollbackSDNCActivate", "false")
224 rollbackData.put("VNF", "rollbackVnfCreate", "false")
226 execution.setVariable("rollbackData", rollbackData)
229 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
232 utils.log("DEBUG", " Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage(), isDebugEnabled)
233 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest")
236 utils.log("DEBUG", "*** COMPLETED DoCreateVnf PreProcessRequest Process ***", isDebugEnabled)
240 public void prepareCreateGenericVnf (Execution execution) {
241 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
242 execution.setVariable("prefix",Prefix)
244 utils.log("DEBUG", " *** STARTED DoCreateVnf PrepareCreateGenericVnf Process *** ", isDebugEnabled)
247 String vnfId = execution.getVariable("DoCVNF_vnfId")
248 def vnfName = execution.getVariable("DoCVNF_vnfName")
249 if (vnfName == null) {
250 vnfName = "sdncGenerated"
251 utils.log("DEBUG", "Sending a dummy VNF name to AAI - the name will be generated by SDNC: " + vnfName, isDebugEnabled)
253 def vnfType = execution.getVariable("DoCVNF_vnfType")
254 def serviceId = execution.getVariable("DoCVNF_serviceId")
255 def orchStatus = execution.getVariable("DoCVNF_orchStatus")
256 def modelInvariantId = execution.getVariable("DoCVNF_modelInvariantId")
257 def modelVersionId = execution.getVariable("DoCVNF_modelVersionId")
258 def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId")
259 // TODO: 1702 Variable
260 def equipmentRole = execution.getVariable("DoCVNF_equipmentRole")
261 def nfType = execution.getVariable("DoCVNF_nfType")
262 def nfRole = execution.getVariable("DoCVNF_nfRole")
263 def nfFunction = execution.getVariable("DoCVNF_nfFunction")
264 def nfNamingCode = execution.getVariable("DoCVNF_nfNamingCode")
266 //Get Service Instance Info
267 def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
268 String siRelatedLink = execution.getVariable("GENGS_siResourceLink")
270 int custStart = siRelatedLink.indexOf("customer/")
271 int custEnd = siRelatedLink.indexOf("/service-subscriptions")
272 String globalCustId = siRelatedLink.substring(custStart + 9, custEnd)
273 int serviceStart = siRelatedLink.indexOf("service-subscription/")
274 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
275 String serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
276 serviceType = UriUtils.decode(serviceType,"UTF-8")
279 AaiUtil aaiUtil = new AaiUtil(this)
280 def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution)
281 String namespace = aaiUtil.getNamespaceFromUri(execution, aai_uri)
284 """<generic-vnf xmlns="${namespace}">
285 <vnf-id>${vnfId}</vnf-id>
286 <vnf-name>${vnfName}</vnf-name>
287 <service-id>${serviceId}</service-id>
288 <vnf-type>${vnfType}</vnf-type>
289 <prov-status>PREPROV</prov-status>
290 <orchestration-status>${orchStatus}</orchestration-status>
291 <model-invariant-id>${modelInvariantId}</model-invariant-id>
292 <model-version-id>${modelVersionId}</model-version-id>
293 <model-customization-id>${modelCustomizationId}</model-customization-id>
294 <nf-type>${nfType}</nf-type>
295 <nf-role>${nfRole}</nf-role>
296 <nf-function>${nfFunction}</nf-function>
297 <nf-naming-code>${nfNamingCode}</nf-naming-code>
300 <related-to>service-instance</related-to>
301 <related-link>${siRelatedLink}</related-link>
303 <relationship-key>customer.global-customer-id</relationship-key>
304 <relationship-value>${globalCustId}</relationship-value>
307 <relationship-key>service-subscription.service-type</relationship-key>
308 <relationship-value>${serviceType}</relationship-value>
311 <relationship-key>service-instance.service-instance-id</relationship-key>
312 <relationship-value>${serviceInstanceId}</relationship-value>
318 execution.setVariable("DoCVNF_genericVnfPayload", payload)
320 }catch(Exception ex) {
321 utils.log("DEBUG", "Error Occured in DoCreateVnf PrepareCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled)
322 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PrepareCreateGenericVnf Process")
324 utils.log("DEBUG", "*** COMPLETED DoCreateVnf PrepareCreateGenericVnf Process ***", isDebugEnabled)
327 public void postProcessCreateGenericVnf (Execution execution) {
328 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
329 execution.setVariable("prefix",Prefix)
331 utils.log("DEBUG", " *** STARTED DoCreateVnf PostProcessCreateGenericVnf Process *** ", isDebugEnabled)
334 String vnfId = execution.getVariable("DoCVNF_vnfId")
335 def rollbackData = execution.getVariable("rollbackData")
336 rollbackData.put("VNF", "vnfId", vnfId)
337 rollbackData.put("VNF", "rollbackVnfCreate", "true")
338 execution.setVariable("rollbackData", rollbackData)
339 }catch(Exception ex) {
340 utils.log("DEBUG", "Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled)
341 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process")
343 utils.log("DEBUG", "*** COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process ***", isDebugEnabled)
347 public void preProcessSDNCAssignRequest(Execution execution){
348 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
349 execution.setVariable("prefix", Prefix)
350 logDebug(" ======== STARTED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled)
351 def vnfId = execution.getVariable("DoCVNF_vnfId")
352 def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
353 logDebug("NEW VNF ID: " + vnfId, isDebugLogEnabled)
354 utils.logAudit("NEW VNF ID: " + vnfId)
359 String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign")
361 assignSDNCRequest = utils.formatXml(assignSDNCRequest)
362 execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest)
363 logDebug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest, isDebugLogEnabled)
364 utils.logAudit("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest)
367 utils.log("ERROR", "Exception Occured Processing preProcessSDNCAssignRequest. Exception is:\n" + e, isDebugLogEnabled)
368 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage())
370 logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled)
373 public void preProcessSDNCActivateRequest(Execution execution) {
374 def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' +
375 'execution=' + execution.getId() +
377 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
378 logDebug('Entered ' + method, isDebugLogEnabled)
379 execution.setVariable("prefix", Prefix)
380 logDebug(" ======== STARTED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled)
382 String vnfId = execution.getVariable("DoCVNF_vnfId")
383 String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
385 String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate")
387 execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest)
388 logDebug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest, isDebugLogEnabled)
389 utils.logAudit("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest)
392 log.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e, isDebugLogEnabled)
393 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage())
395 logDebug("======== COMPLETED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled)
398 public String buildSDNCRequest(Execution execution, String svcInstId, String action){
400 String uuid = execution.getVariable('testReqId') // for junits
402 uuid = execution.getVariable("DoCVNF_requestId") + "-" + System.currentTimeMillis()
404 def callbackURL = execution.getVariable("DoCVNF_sdncCallbackUrl")
405 def requestId = execution.getVariable("DoCVNF_requestId")
406 def serviceId = execution.getVariable("DoCVNF_serviceId")
407 def vnfType = execution.getVariable("DoCVNF_vnfType")
408 def vnfName = execution.getVariable("DoCVNF_vnfName")
409 // Only send vnfName to SDNC if it is not null, otherwise it will get generated by SDNC on Assign
410 String vnfNameString = ""
411 if (vnfName != null) {
412 vnfNameString = """<vnf-name>${vnfName}</vnf-name>"""
414 def tenantId = execution.getVariable("DoCVNF_tenantId")
415 def source = execution.getVariable("DoCVNF_source")
416 def vnfId = execution.getVariable("DoCVNF_vnfId")
417 def cloudSiteId = execution.getVariable("DoCVNF_cloudSiteId")
418 def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId")
419 def serviceModelInfo = execution.getVariable("serviceModelInfo")
420 def vnfModelInfo = execution.getVariable("vnfModelInfo")
421 String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
422 String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)
423 def globalSubscriberId = execution.getVariable("DoCVNF_globalSubscriberId")
424 def sdncVersion = execution.getVariable("DoCVNF_sdncVersion")
426 String sdncVNFParamsXml = ""
428 if(execution.getVariable("DoCVNF_vnfParamsExistFlag") == true){
429 sdncVNFParamsXml = buildSDNCParamsXml(execution)
431 sdncVNFParamsXml = ""
435 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
436 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
437 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
438 <sdncadapter:RequestHeader>
439 <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
440 <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
441 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
442 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
443 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
444 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
445 </sdncadapter:RequestHeader>
446 <sdncadapterworkflow:SDNCRequestData>
447 <request-information>
448 <request-id>${requestId}</request-id>
449 <request-action>CreateVnfInstance</request-action>
450 <source>${source}</source>
454 </request-information>
455 <service-information>
456 <service-id>${serviceId}</service-id>
457 <subscription-service-type>${serviceId}</subscription-service-type>
458 ${serviceEcompModelInformation}
459 <service-instance-id>${svcInstId}</service-instance-id>
460 <global-customer-id>${globalSubscriberId}</global-customer-id>
461 </service-information>
463 <vnf-id>${vnfId}</vnf-id>
464 <vnf-type>${vnfType}</vnf-type>
465 ${vnfEcompModelInformation}
469 <tenant>${tenantId}</tenant>
470 <aic-cloud-region>${cloudSiteId}</aic-cloud-region>
473 </sdncadapterworkflow:SDNCRequestData>
474 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
476 utils.logAudit("sdncRequest: " + sdncRequest)
480 public void validateSDNCResponse(Execution execution, String response, String method){
481 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
482 execution.setVariable("prefix",Prefix)
483 logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
485 WorkflowException workflowException = execution.getVariable("WorkflowException")
486 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
488 utils.logAudit("workflowException: " + workflowException)
490 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
491 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
493 utils.logAudit("SDNCResponse: " + response)
495 String sdncResponse = response
496 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
497 logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled)
498 if(method.equals("get")){
499 String topologyGetResponse = execution.getVariable("DoCVNF_getSDNCAdapterResponse")
500 String data = utils.getNodeXml(topologyGetResponse, "response-data")
501 data = data.replaceAll("<", "<")
502 data = data.replaceAll(">", ">")
503 utils.log("DEBUG", "topologyGetResponseData: " + data, isDebugLogEnabled)
504 String vnfName = utils.getNodeText1(data, "vnf-name")
505 utils.log("DEBUG", "vnfName received from SDNC: " + vnfName, isDebugLogEnabled)
506 execution.setVariable("vnfName", vnfName)
507 execution.setVariable("DoCVNF_vnfName", vnfName)
509 def rollbackData = execution.getVariable("rollbackData")
510 if (method.equals("assign")) {
511 rollbackData.put("VNF", "rollbackSDNCAssign", "true")
513 else if (method.equals("activate")) {
514 rollbackData.put("VNF", "rollbackSDNCActivate", "true")
516 execution.setVariable("rollbackData", rollbackData)
520 logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
521 throw new BpmnError("MSOWorkflowException")
523 logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
526 public void preProcessSDNCGetRequest(Execution execution){
527 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
528 execution.setVariable("prefix", Prefix)
529 utils.log("DEBUG", " ======== STARTED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled)
531 def serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
533 String uuid = execution.getVariable('testReqId') // for junits
535 uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
538 def callbackUrl = execution.getVariable("DoCVFM_sdncCallbackUrl")
539 utils.logAudit("callbackUrl:" + callbackUrl)
541 def vnfId = execution.getVariable('DCVFM_vnfId')
544 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
548 svcInstId = serviceInstanceId
550 // serviceOperation will be retrieved from "object-path" element
551 // in SDNC Assign Response for VNF
552 String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse")
553 utils.logAudit("DoCVNF_assignSDNCAdapterResponse is: \n" + response)
555 String serviceOperation = ""
557 String data = utils.getNodeXml(response, "response-data")
558 data = data.replaceAll("<", "<")
559 data = data.replaceAll(">", ">")
560 utils.log("DEBUG", "responseData: " + data, isDebugLogEnabled)
561 serviceOperation = utils.getNodeText1(data, "object-path")
562 utils.log("DEBUG", "VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation, isDebugLogEnabled)
565 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
568 String SDNCGetRequest =
569 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
570 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
571 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
572 <sdncadapter:RequestHeader>
573 <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
574 <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
575 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
576 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
577 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
578 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
579 </sdncadapter:RequestHeader>
580 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
581 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
583 utils.logAudit("SDNCGetRequest: \n" + SDNCGetRequest)
584 execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest)
585 utils.log("DEBUG", "Outgoing GetSDNCRequest is: \n" + SDNCGetRequest, isDebugLogEnabled)
588 utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
589 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage())
591 utils.log("DEBUG", "======== COMPLETED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled)
595 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
597 * @param execution The flow's execution instance.
599 public void prepUpdateAAIGenericVnf(Execution execution) {
600 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
601 'execution=' + execution.getId() +
603 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
604 logDebug('Entered ' + method, isDebugLogEnabled)
607 def vnfId = execution.getVariable('DoCVNF_vnfId')
608 logDebug("VNF ID: " + vnfId, isDebugLogEnabled)
610 String updateAAIGenericVnfRequest = """
611 <UpdateAAIGenericVnfRequest>
612 <vnf-id>${vnfId}</vnf-id>
613 <orchestration-status>Active</orchestration-status>
614 </UpdateAAIGenericVnfRequest>
616 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
617 execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
618 utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
619 logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled)
622 logDebug('Exited ' + method, isDebugLogEnabled)
623 } catch (BpmnError e) {
625 } catch (Exception e) {
626 logError('Caught exception in ' + method, e)
627 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())