2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.infrastructure.scripts
23 import static org.apache.commons.lang3.StringUtils.*
25 import org.camunda.bpm.engine.delegate.BpmnError
26 import org.camunda.bpm.engine.delegate.DelegateExecution
27 import org.onap.so.bpmn.common.scripts.AaiUtil
28 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
29 import org.onap.so.bpmn.common.scripts.ExceptionUtil
30 import org.onap.so.bpmn.common.scripts.MsoUtils
31 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
32 import org.onap.so.bpmn.common.scripts.VidUtils
33 import org.onap.so.bpmn.core.RollbackData
34 import org.onap.so.bpmn.core.UrnPropertiesReader
35 import org.onap.so.bpmn.core.WorkflowException
36 import org.onap.so.bpmn.core.domain.VnfResource
37 import org.onap.so.bpmn.core.json.JsonUtils
38 import org.onap.so.logger.MessageEnum
39 import org.onap.so.logger.MsoLogger
40 import org.onap.so.client.aai.AAIObjectType;
41 import org.onap.so.client.aai.AAIResourcesClient
42 import org.onap.so.client.aai.entities.AAIResultWrapper
43 import org.onap.so.client.aai.entities.uri.AAIResourceUri
44 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
45 import org.springframework.web.util.UriUtils
49 * This class supports the DoCreateVnf building block subflow
50 * with the creation of a generic vnf for
54 class DoCreateVnf extends AbstractServiceTaskProcessor {
56 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVnf.class);
57 String Prefix="DoCVNF_"
58 ExceptionUtil exceptionUtil = new ExceptionUtil()
59 JsonUtils jsonUtil = new JsonUtils()
60 VidUtils vidUtils = new VidUtils(this)
61 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
64 * This method gets and validates the incoming
70 public void preProcessRequest(DelegateExecution execution) {
71 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
72 execution.setVariable("prefix",Prefix)
73 msoLogger.debug("STARTED DoCreateVnf PreProcessRequest Process")
75 // DISABLE SDNC INTERACTION FOR NOW
76 execution.setVariable("SDNCInteractionEnabled", false)
83 def rollbackData = execution.getVariable("rollbackData")
84 if (rollbackData == null) {
85 rollbackData = new RollbackData()
88 String vnfModelInfo = execution.getVariable("vnfModelInfo")
89 String serviceModelInfo = execution.getVariable("serviceModelInfo")
91 String requestId = execution.getVariable("msoRequestId")
92 execution.setVariable("DoCVNF_requestId", requestId)
93 execution.setVariable("mso-request-id", requestId)
94 msoLogger.debug("Incoming Request Id is: " + requestId)
96 String serviceInstanceId = execution.getVariable("serviceInstanceId")
97 execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId)
98 rollbackData.put("VNF", "serviceInstanceId", serviceInstanceId)
99 msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
101 String vnfType = execution.getVariable("vnfType")
102 execution.setVariable("DoCVNF_vnfType", vnfType)
103 msoLogger.debug("Incoming Vnf Type is: " + vnfType)
105 String vnfName = execution.getVariable("vnfName")
106 if (vnfName.equals("") || vnfName.equals("null")) {
109 execution.setVariable("DoCVNF_vnfName", vnfName)
110 msoLogger.debug("Incoming Vnf Name is: " + vnfName)
112 String serviceId = execution.getVariable("productFamilyId")
113 execution.setVariable("DoCVNF_serviceId", serviceId)
114 msoLogger.debug("Incoming Service Id is: " + serviceId)
116 String source = "VID"
117 execution.setVariable("DoCVNF_source", source)
118 rollbackData.put("VNF", "source", source)
119 msoLogger.debug("Incoming Source is: " + source)
121 String suppressRollback = execution.getVariable("disableRollback")
122 execution.setVariable("DoCVNF_suppressRollback", suppressRollback)
123 msoLogger.debug("Incoming Suppress Rollback is: " + suppressRollback)
125 String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantUuid")
126 execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId)
127 msoLogger.debug("Incoming Invariant Id is: " + modelInvariantId)
129 String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid")
130 if (modelVersionId == null) {
133 execution.setVariable("DoCVNF_modelVersionId", modelVersionId)
134 msoLogger.debug("Incoming Version Id is: " + modelVersionId)
136 String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion")
137 execution.setVariable("DoCVNF_modelVersion", modelVersion)
138 msoLogger.debug("Incoming Model Version is: " + modelVersion)
140 String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName")
141 execution.setVariable("DoCVNF_modelName", modelName)
142 msoLogger.debug("Incoming Model Name is: " + modelName)
144 String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid")
145 if (modelCustomizationId == null) {
146 modelCustomizationId = ""
148 execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId)
149 msoLogger.debug("Incoming Model Customization Id is: " + modelCustomizationId)
151 String cloudSiteId = execution.getVariable("lcpCloudRegionId")
152 execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId)
153 rollbackData.put("VNF", "cloudSiteId", cloudSiteId)
154 msoLogger.debug("Incoming Cloud Site Id is: " + cloudSiteId)
156 String tenantId = execution.getVariable("tenantId")
157 execution.setVariable("DoCVNF_tenantId", tenantId)
158 rollbackData.put("VNF", "tenantId", tenantId)
159 msoLogger.debug("Incoming Tenant Id is: " + tenantId)
161 String globalSubscriberId = execution.getVariable("globalSubscriberId")
162 if (globalSubscriberId == null) {
163 globalSubscriberId = ""
165 execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId)
166 msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId)
168 String sdncVersion = execution.getVariable("sdncVersion")
169 if (sdncVersion == null) {
172 execution.setVariable("DoCVNF_sdncVersion", sdncVersion)
173 msoLogger.debug("Incoming Sdnc Version is: " + sdncVersion)
175 //For Completion Handler & Fallout Handler
177 """<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
178 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
179 <action>CREATE</action>
180 <source>${MsoUtils.xmlEscape(source)}</source>
183 execution.setVariable("DoCVNF_requestInfo", requestInfo)
184 //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
185 String orchStatus = "Created"
186 execution.setVariable("DoCVNF_orchStatus", orchStatus)
188 //TODO: Equipment Role - Should come from SDN-C Response in 1702
189 String equipmentRole = " "
190 execution.setVariable("DoCVNF_equipmentRole", equipmentRole)
191 String vnfId = execution.getVariable("testVnfId") // for junits
193 vnfId = execution.getVariable("vnfId")
194 if (isBlank(vnfId)) {
195 vnfId = UUID.randomUUID().toString()
196 msoLogger.debug("Generated Vnf Id is: " + vnfId)
199 execution.setVariable("DoCVNF_vnfId", vnfId)
201 // Setting for Sub Flow Calls
202 execution.setVariable("DoCVNF_type", "generic-vnf")
203 execution.setVariable("GENGS_type", "service-instance")
205 String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
206 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
207 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
208 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError);
209 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
211 execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl)
212 rollbackData.put("VNF", "sdncCallbackUrl", sdncCallbackUrl)
213 msoLogger.debug("SDNC Callback URL is: " + sdncCallbackUrl)
215 VnfResource vnfResource = (VnfResource) execution.getVariable((String)"vnfResourceDecomposition")
216 String nfRole = vnfResource.getNfRole()
218 execution.setVariable("DoCVNF_nfRole", nfRole)
219 msoLogger.debug("NF Role is: " + nfRole)
221 String nfNamingCode = vnfResource.getNfNamingCode()
222 execution.setVariable("DoCVNF_nfNamingCode", nfNamingCode)
223 msoLogger.debug("NF Naming Code is: " + nfNamingCode)
225 String nfType = vnfResource.getNfType()
226 execution.setVariable("DoCVNF_nfType", nfType)
227 msoLogger.debug("NF Type is: " + nfType)
229 String nfFunction = vnfResource.getNfFunction()
230 execution.setVariable("DoCVNF_nfFunction", nfFunction)
231 msoLogger.debug("NF Function is: " + nfFunction)
233 rollbackData.put("VNF", "rollbackSDNCAssign", "false")
234 rollbackData.put("VNF", "rollbackSDNCActivate", "false")
235 rollbackData.put("VNF", "rollbackVnfCreate", "false")
237 execution.setVariable("rollbackData", rollbackData)
240 msoLogger.debug("Rethrowing MSOWorkflowException")
243 msoLogger.debug(" Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage())
244 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest")
247 msoLogger.trace("COMPLETED DoCreateVnf PreProcessRequest Process")
250 private Object getVariableEnforced(DelegateExecution execution, String name){
251 Object enforced = execution.getVariable(name)
258 public void createGenericVnf (DelegateExecution execution) {
259 execution.setVariable("prefix",Prefix)
260 msoLogger.trace("STARTED DoCreateVnf CreateGenericVnf Process")
263 String vnfId = getVariableEnforced(execution, "DoCVNF_vnfId")
264 String vnfName = getVariableEnforced(execution, "DoCVNF_vnfName")
265 if (vnfName == null) {
266 vnfName = "sdncGenerated"
267 msoLogger.debug("Sending a dummy VNF name to AAI - the name will be generated by SDNC: " + vnfName)
269 String vnfType = getVariableEnforced(execution, "DoCVNF_vnfType")
270 String serviceId = getVariableEnforced(execution, "DoCVNF_serviceId")
271 String orchStatus = getVariableEnforced(execution, "DoCVNF_orchStatus")
272 String modelInvariantId = getVariableEnforced(execution, "DoCVNF_modelInvariantId")
273 String modelVersionId = getVariableEnforced(execution, "DoCVNF_modelVersionId")
274 String modelCustomizationId = getVariableEnforced(execution, "DoCVNF_modelCustomizationId")
275 String equipmentRole = getVariableEnforced(execution, "DoCVNF_equipmentRole")
276 String nfType = getVariableEnforced(execution, "DoCVNF_nfType")
277 String nfRole = getVariableEnforced(execution, "DoCVNF_nfRole")
278 String nfFunction = getVariableEnforced(execution, "DoCVNF_nfFunction")
279 String nfNamingCode = getVariableEnforced(execution, "DoCVNF_nfNamingCode")
281 //Get Service Instance Info
282 String serviceInstanceId = getVariableEnforced(execution, "DoCVNF_serviceInstanceId")
283 String siRelatedLink = getVariableEnforced(execution, "GENGS_siResourceLink")
285 int custStart = siRelatedLink.indexOf("customer/")
286 int custEnd = siRelatedLink.indexOf("/service-subscriptions")
287 String globalCustId = siRelatedLink.substring(custStart + 9, custEnd)
288 int serviceStart = siRelatedLink.indexOf("service-subscription/")
289 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
290 String serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
292 Map<String, String> payload = new LinkedHashMap<>();
293 payload.put("vnf-id", vnfId);
294 payload.put("vnf-name", vnfName);
295 payload.put("service-id", serviceId);
296 payload.put("vnf-type", vnfType);
297 payload.put("prov-status", "PREPROV");
298 payload.put("orchestration-status", orchStatus);
299 payload.put("model-invariant-id", modelInvariantId);
300 payload.put("model-version-id", modelVersionId);
301 payload.put("model-customization-id", modelCustomizationId);
302 payload.put("nf-type", nfType);
303 payload.put("nf-role", nfRole);
304 payload.put("nf-function", nfFunction);
305 payload.put("nf-naming-code", nfNamingCode);
307 AAIResourcesClient resourceClient = new AAIResourcesClient();
308 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
309 resourceClient.create(uri, payload)
311 AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId)
312 resourceClient.connect(uri, siUri)
314 }catch(Exception ex) {
315 msoLogger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process " + ex.getMessage())
316 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf CreateGenericVnf Process")
318 msoLogger.trace("COMPLETED DoCreateVnf CreateGenericVnf Process")
321 public void postProcessCreateGenericVnf (DelegateExecution execution) {
322 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
323 execution.setVariable("prefix",Prefix)
325 msoLogger.trace("STARTED DoCreateVnf PostProcessCreateGenericVnf Process")
328 String vnfId = execution.getVariable("DoCVNF_vnfId")
329 def rollbackData = execution.getVariable("rollbackData")
330 rollbackData.put("VNF", "vnfId", vnfId)
331 rollbackData.put("VNF", "rollbackVnfCreate", "true")
332 execution.setVariable("rollbackData", rollbackData)
333 }catch(Exception ex) {
334 msoLogger.debug("Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage())
335 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process")
337 msoLogger.trace("COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process")
341 public void preProcessSDNCAssignRequest(DelegateExecution execution){
342 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
343 execution.setVariable("prefix", Prefix)
344 msoLogger.trace("STARTED preProcessSDNCAssignRequest")
345 def vnfId = execution.getVariable("DoCVNF_vnfId")
346 def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
347 msoLogger.debug("NEW VNF ID: " + vnfId)
352 String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign")
354 assignSDNCRequest = utils.formatXml(assignSDNCRequest)
355 execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest)
356 msoLogger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest)
359 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCAssignRequest" , "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
360 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage())
362 msoLogger.trace("COMPLETED preProcessSDNCAssignRequest")
365 public void preProcessSDNCActivateRequest(DelegateExecution execution) {
366 def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' +
367 'execution=' + execution.getId() +
369 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
370 msoLogger.trace('Entered ' + method)
371 execution.setVariable("prefix", Prefix)
372 msoLogger.trace("STARTED preProcessSDNCActivateRequest Process")
374 String vnfId = execution.getVariable("DoCVNF_vnfId")
375 String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
377 String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate")
379 execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest)
380 msoLogger.debug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest)
383 msoLogger.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e)
384 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage())
386 msoLogger.trace("COMPLETED preProcessSDNCActivateRequest Process")
389 public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
391 String uuid = execution.getVariable('testReqId') // for junits
393 uuid = execution.getVariable("DoCVNF_requestId") + "-" + System.currentTimeMillis()
395 def callbackURL = execution.getVariable("DoCVNF_sdncCallbackUrl")
396 def requestId = execution.getVariable("DoCVNF_requestId")
397 def serviceId = execution.getVariable("DoCVNF_serviceId")
398 def vnfType = execution.getVariable("DoCVNF_vnfType")
399 def vnfName = execution.getVariable("DoCVNF_vnfName")
400 // Only send vnfName to SDNC if it is not null, otherwise it will get generated by SDNC on Assign
401 String vnfNameString = ""
402 if (vnfName != null) {
403 vnfNameString = """<vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name>"""
405 def tenantId = execution.getVariable("DoCVNF_tenantId")
406 def source = execution.getVariable("DoCVNF_source")
407 def vnfId = execution.getVariable("DoCVNF_vnfId")
408 def cloudSiteId = execution.getVariable("DoCVNF_cloudSiteId")
409 def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId")
410 def serviceModelInfo = execution.getVariable("serviceModelInfo")
411 def vnfModelInfo = execution.getVariable("vnfModelInfo")
412 String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
413 String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)
414 def globalSubscriberId = execution.getVariable("DoCVNF_globalSubscriberId")
415 def sdncVersion = execution.getVariable("DoCVNF_sdncVersion")
417 String sdncVNFParamsXml = ""
419 if(execution.getVariable("DoCVNF_vnfParamsExistFlag") == true){
420 sdncVNFParamsXml = buildSDNCParamsXml(execution)
422 sdncVNFParamsXml = ""
426 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
427 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
428 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
429 <sdncadapter:RequestHeader>
430 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
431 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
432 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
433 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
434 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
435 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
436 </sdncadapter:RequestHeader>
437 <sdncadapterworkflow:SDNCRequestData>
438 <request-information>
439 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
440 <request-action>CreateVnfInstance</request-action>
441 <source>${MsoUtils.xmlEscape(source)}</source>
445 </request-information>
446 <service-information>
447 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
448 <subscription-service-type>${MsoUtils.xmlEscape(serviceId)}</subscription-service-type>
449 ${serviceEcompModelInformation}
450 <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id>
451 <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
452 </service-information>
454 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
455 <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
456 ${vnfEcompModelInformation}
460 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
461 <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>
464 </sdncadapterworkflow:SDNCRequestData>
465 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
467 msoLogger.debug("sdncRequest: " + sdncRequest)
471 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
472 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
473 execution.setVariable("prefix",Prefix)
474 msoLogger.debug("STARTED ValidateSDNCResponse Process")
476 WorkflowException workflowException = execution.getVariable("WorkflowException")
477 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
479 msoLogger.debug("workflowException: " + workflowException)
481 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
482 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
484 msoLogger.debug("SDNCResponse: " + response)
486 String sdncResponse = response
487 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
488 msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
489 if(method.equals("get")){
490 String topologyGetResponse = execution.getVariable("DoCVNF_getSDNCAdapterResponse")
491 String data = utils.getNodeXml(topologyGetResponse, "response-data")
492 msoLogger.debug("topologyGetResponseData: " + data)
493 String vnfName = utils.getNodeText(data, "vnf-name")
494 msoLogger.debug("vnfName received from SDNC: " + vnfName)
495 execution.setVariable("vnfName", vnfName)
496 execution.setVariable("DoCVNF_vnfName", vnfName)
498 def rollbackData = execution.getVariable("rollbackData")
499 if (method.equals("assign")) {
500 rollbackData.put("VNF", "rollbackSDNCAssign", "true")
502 else if (method.equals("activate")) {
503 rollbackData.put("VNF", "rollbackSDNCActivate", "true")
505 execution.setVariable("rollbackData", rollbackData)
509 msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
510 throw new BpmnError("MSOWorkflowException")
512 msoLogger.debug("COMPLETED ValidateSDNCResponse Process")
515 public void preProcessSDNCGetRequest(DelegateExecution execution){
516 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
517 execution.setVariable("prefix", Prefix)
518 msoLogger.trace("STARTED preProcessSDNCGetRequest Process")
520 def serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
522 String uuid = execution.getVariable('testReqId') // for junits
524 uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
527 def callbackUrl = execution.getVariable("DoCVFM_sdncCallbackUrl")
528 msoLogger.debug("callbackUrl:" + callbackUrl)
530 def vnfId = execution.getVariable('DCVFM_vnfId')
533 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
537 svcInstId = serviceInstanceId
539 // serviceOperation will be retrieved from "object-path" element
540 // in SDNC Assign Response for VNF
541 String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse")
542 msoLogger.debug("DoCVNF_assignSDNCAdapterResponse is: \n" + response)
544 String serviceOperation = ""
546 String data = utils.getNodeXml(response, "response-data")
547 msoLogger.debug("responseData: " + data)
548 serviceOperation = utils.getNodeText(data, "object-path")
549 msoLogger.debug("VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation)
552 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
555 String SDNCGetRequest =
556 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
557 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
558 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
559 <sdncadapter:RequestHeader>
560 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
561 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
562 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
563 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
564 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
565 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
566 </sdncadapter:RequestHeader>
567 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
568 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
571 execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest)
572 msoLogger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest)
575 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest. ", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
576 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage())
578 msoLogger.trace("COMPLETED preProcessSDNCGetRequest Process")
582 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
584 * @param execution The flow's execution instance.
586 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
587 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
588 'execution=' + execution.getId() +
590 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
591 msoLogger.trace('Entered ' + method)
594 def vnfId = execution.getVariable('DoCVNF_vnfId')
595 msoLogger.debug("VNF ID: " + vnfId)
597 String updateAAIGenericVnfRequest = """
598 <UpdateAAIGenericVnfRequest>
599 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
600 <orchestration-status>Active</orchestration-status>
601 </UpdateAAIGenericVnfRequest>
603 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
604 execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
605 msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
608 msoLogger.trace('Exited ' + method)
609 } catch (BpmnError e) {
611 } catch (Exception e) {
612 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Caught exception in " + method , "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
613 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())