2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.infrastructure.scripts
25 import static org.apache.commons.lang3.StringUtils.*
26 import org.camunda.bpm.engine.delegate.BpmnError
27 import org.camunda.bpm.engine.delegate.DelegateExecution
28 import org.onap.aaiclient.client.aai.AAIObjectType;
29 import org.onap.aaiclient.client.aai.AAIResourcesClient
30 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
31 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
32 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
33 import org.onap.logging.filter.base.ErrorCode
34 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
35 import org.onap.so.bpmn.common.scripts.ExceptionUtil
36 import org.onap.so.bpmn.common.scripts.MsoUtils
37 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
38 import org.onap.so.bpmn.common.scripts.VidUtils
39 import org.onap.so.bpmn.common.util.OofInfraUtils
40 import org.onap.so.bpmn.core.RollbackData
41 import org.onap.so.bpmn.core.UrnPropertiesReader
42 import org.onap.so.bpmn.core.WorkflowException
43 import org.onap.so.bpmn.core.domain.VnfResource
44 import org.onap.so.bpmn.core.json.JsonUtils
45 import org.onap.so.db.catalog.beans.HomingInstance
46 import org.onap.so.logger.LoggingAnchor
47 import org.onap.so.logger.MessageEnum
48 import org.slf4j.Logger
49 import org.slf4j.LoggerFactory
52 * This class supports the DoCreateVnf building block subflow
53 * with the creation of a generic vnf for
57 class DoCreateVnf extends AbstractServiceTaskProcessor {
59 private static final Logger logger = LoggerFactory.getLogger( DoCreateVnf.class);
60 String Prefix="DoCVNF_"
61 ExceptionUtil exceptionUtil = new ExceptionUtil()
62 JsonUtils jsonUtil = new JsonUtils()
63 VidUtils vidUtils = new VidUtils(this)
64 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
65 OofInfraUtils oofInfraUtils = new OofInfraUtils()
68 * This method gets and validates the incoming
74 public void preProcessRequest(DelegateExecution execution) {
75 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
76 execution.setVariable("prefix",Prefix)
77 logger.debug("STARTED DoCreateVnf PreProcessRequest Process")
79 // DISABLE SDNC INTERACTION FOR NOW
80 execution.setVariable("SDNCInteractionEnabled", false)
87 def rollbackData = execution.getVariable("rollbackData")
88 if (rollbackData == null) {
89 rollbackData = new RollbackData()
92 String vnfModelInfo = execution.getVariable("vnfModelInfo")
93 String serviceModelInfo = execution.getVariable("serviceModelInfo")
95 String requestId = execution.getVariable("msoRequestId")
96 execution.setVariable("DoCVNF_requestId", requestId)
97 execution.setVariable("mso-request-id", requestId)
98 logger.debug("Incoming Request Id is: " + requestId)
100 String serviceInstanceId = execution.getVariable("serviceInstanceId")
101 execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId)
102 rollbackData.put("VNF", "serviceInstanceId", serviceInstanceId)
103 logger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
105 String vnfType = execution.getVariable("vnfType")
106 execution.setVariable("DoCVNF_vnfType", vnfType)
107 logger.debug("Incoming Vnf Type is: " + vnfType)
109 String vnfName = execution.getVariable("vnfName")
110 if (vnfName.equals("") || vnfName.equals("null")) {
111 AAIResourcesClient resourceClient = new AAIResourcesClient()
112 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable("vnfId"))
113 if(resourceClient.exists(uri)){
114 exceptionUtil.buildWorkflowException(execution, 5000, "Generic Vnf Already Exist.")
119 execution.setVariable("DoCVNF_vnfName", vnfName)
120 logger.debug("Incoming Vnf Name is: " + vnfName)
122 String serviceId = execution.getVariable("productFamilyId")
123 execution.setVariable("DoCVNF_serviceId", serviceId)
124 logger.debug("Incoming Service Id is: " + serviceId)
126 String source = "VID"
127 execution.setVariable("DoCVNF_source", source)
128 rollbackData.put("VNF", "source", source)
129 logger.debug("Incoming Source is: " + source)
131 String suppressRollback = execution.getVariable("disableRollback")
132 execution.setVariable("DoCVNF_suppressRollback", suppressRollback)
133 logger.debug("Incoming Suppress Rollback is: " + suppressRollback)
135 String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantUuid")
136 execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId)
137 logger.debug("Incoming Invariant Id is: " + modelInvariantId)
139 String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid")
140 if (modelVersionId == null) {
143 execution.setVariable("DoCVNF_modelVersionId", modelVersionId)
144 logger.debug("Incoming Version Id is: " + modelVersionId)
146 String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion")
147 execution.setVariable("DoCVNF_modelVersion", modelVersion)
148 logger.debug("Incoming Model Version is: " + modelVersion)
150 String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName")
151 execution.setVariable("DoCVNF_modelName", modelName)
152 logger.debug("Incoming Model Name is: " + modelName)
154 String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid")
155 if (modelCustomizationId == null) {
156 modelCustomizationId = ""
158 execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId)
159 logger.debug("Incoming Model Customization Id is: " + modelCustomizationId)
161 String cloudSiteId = execution.getVariable("lcpCloudRegionId")
162 execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId)
163 rollbackData.put("VNF", "cloudSiteId", cloudSiteId)
164 logger.debug("Incoming Cloud Site Id is: " + cloudSiteId)
166 String tenantId = execution.getVariable("tenantId")
167 execution.setVariable("DoCVNF_tenantId", tenantId)
168 rollbackData.put("VNF", "tenantId", tenantId)
169 logger.debug("Incoming Tenant Id is: " + tenantId)
171 String globalSubscriberId = execution.getVariable("globalSubscriberId")
172 if (globalSubscriberId == null) {
173 globalSubscriberId = ""
175 execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId)
176 logger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId)
178 String sdncVersion = execution.getVariable("sdncVersion")
179 if (sdncVersion == null) {
182 execution.setVariable("DoCVNF_sdncVersion", sdncVersion)
183 logger.debug("Incoming Sdnc Version is: " + sdncVersion)
185 //For Completion Handler & Fallout Handler
187 """<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
188 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
189 <action>CREATE</action>
190 <source>${MsoUtils.xmlEscape(source)}</source>
193 execution.setVariable("DoCVNF_requestInfo", requestInfo)
194 //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
195 String orchStatus = "Created"
196 execution.setVariable("DoCVNF_orchStatus", orchStatus)
198 //TODO: Equipment Role - Should come from SDN-C Response in 1702
199 String equipmentRole = " "
200 execution.setVariable("DoCVNF_equipmentRole", equipmentRole)
201 String vnfId = execution.getVariable("testVnfId") // for junits
203 vnfId = execution.getVariable("vnfId")
204 if (isBlank(vnfId)) {
205 vnfId = UUID.randomUUID().toString()
206 logger.debug("Generated Vnf Id is: " + vnfId)
209 execution.setVariable("DoCVNF_vnfId", vnfId)
211 // Setting for Sub Flow Calls
212 execution.setVariable("DoCVNF_type", "generic-vnf")
213 execution.setVariable("GENGS_type", "service-instance")
215 String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
216 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
217 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
218 logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
219 ErrorCode.UnknownError.getValue());
220 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
222 execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl)
223 rollbackData.put("VNF", "sdncCallbackUrl", sdncCallbackUrl)
224 logger.debug("SDNC Callback URL is: " + sdncCallbackUrl)
226 VnfResource vnfResource = (VnfResource) execution.getVariable((String)"vnfResourceDecomposition")
227 String nfRole = vnfResource.getNfRole()
229 execution.setVariable("DoCVNF_nfRole", nfRole)
230 logger.debug("NF Role is: " + nfRole)
232 String nfNamingCode = vnfResource.getNfNamingCode()
233 execution.setVariable("DoCVNF_nfNamingCode", nfNamingCode)
234 logger.debug("NF Naming Code is: " + nfNamingCode)
236 String nfType = vnfResource.getNfType()
237 execution.setVariable("DoCVNF_nfType", nfType)
238 logger.debug("NF Type is: " + nfType)
240 String nfFunction = vnfResource.getNfFunction()
241 execution.setVariable("DoCVNF_nfFunction", nfFunction)
242 logger.debug("NF Function is: " + nfFunction)
246 HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution)
247 if (homingInstance != null) {
248 execution.setVariable("DoCVNF_cloudSiteId", homingInstance.getCloudRegionId())
249 rollbackData.put("VNF", "cloudSiteId", homingInstance.getCloudRegionId())
250 logger.debug("Overwriting cloudSiteId with homing cloudSiteId: " +
251 homingInstance.getCloudRegionId())
253 } catch (Exception exception) {
254 logger.debug("Could not find homing information for service instance: " + serviceInstanceId +
256 logger.debug("Could not find homing information for service instance error: " + exception)
259 rollbackData.put("VNF", "rollbackSDNCAssign", "false")
260 rollbackData.put("VNF", "rollbackSDNCActivate", "false")
261 rollbackData.put("VNF", "rollbackVnfCreate", "false")
263 execution.setVariable("rollbackData", rollbackData)
266 logger.debug("Rethrowing MSOWorkflowException")
269 logger.debug(" Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage())
270 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest")
273 logger.trace("COMPLETED DoCreateVnf PreProcessRequest Process")
277 * Gets the service instance from aai
279 public void getServiceInstance(DelegateExecution execution) {
281 String serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
283 AAIResourcesClient resourceClient = new AAIResourcesClient()
284 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
286 if(resourceClient.exists(uri)){
287 Map<String, String> keys = uri.getURIKeys()
288 execution.setVariable("globalCustomerId", keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId))
289 execution.setVariable("serviceType", keys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType))
290 execution.setVariable("GENGS_siResourceLink", uri.build().toString())
293 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
296 }catch(BpmnError e) {
298 }catch(Exception ex) {
299 String msg = "Exception in getServiceInstance. " + ex.getMessage()
301 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
305 private Object getVariableEnforced(DelegateExecution execution, String name){
306 Object enforced = execution.getVariable(name)
313 public void createGenericVnf (DelegateExecution execution) {
314 execution.setVariable("prefix",Prefix)
315 logger.trace("STARTED DoCreateVnf CreateGenericVnf Process")
318 String vnfId = getVariableEnforced(execution, "DoCVNF_vnfId")
319 String vnfName = getVariableEnforced(execution, "DoCVNF_vnfName")
320 if (vnfName == null) {
321 vnfName = "sdncGenerated"
322 logger.debug("Sending a dummy VNF name to AAI - the name will be generated by SDNC: " + vnfName)
324 String vnfType = getVariableEnforced(execution, "DoCVNF_vnfType")
325 String serviceId = getVariableEnforced(execution, "DoCVNF_serviceId")
326 String orchStatus = getVariableEnforced(execution, "DoCVNF_orchStatus")
327 String modelInvariantId = getVariableEnforced(execution, "DoCVNF_modelInvariantId")
328 String modelVersionId = getVariableEnforced(execution, "DoCVNF_modelVersionId")
329 String modelCustomizationId = getVariableEnforced(execution, "DoCVNF_modelCustomizationId")
330 String equipmentRole = getVariableEnforced(execution, "DoCVNF_equipmentRole")
331 String nfType = getVariableEnforced(execution, "DoCVNF_nfType")
332 String nfRole = getVariableEnforced(execution, "DoCVNF_nfRole")
333 String nfFunction = getVariableEnforced(execution, "DoCVNF_nfFunction")
334 String nfNamingCode = getVariableEnforced(execution, "DoCVNF_nfNamingCode")
336 //Get Service Instance Info
337 String serviceInstanceId = getVariableEnforced(execution, "DoCVNF_serviceInstanceId")
339 String globalCustId = execution.getVariable("globalCustomerId")
340 String serviceType = execution.getVariable("serviceType")
342 Map<String, String> payload = new LinkedHashMap<>();
343 payload.put("vnf-id", vnfId);
344 payload.put("vnf-name", vnfName);
345 payload.put("service-id", serviceId);
346 payload.put("vnf-type", vnfType);
347 payload.put("prov-status", "PREPROV");
348 payload.put("orchestration-status", orchStatus);
349 payload.put("model-invariant-id", modelInvariantId);
350 payload.put("model-version-id", modelVersionId);
351 payload.put("model-customization-id", modelCustomizationId);
352 payload.put("nf-type", nfType);
353 payload.put("nf-role", nfRole);
354 payload.put("nf-function", nfFunction);
355 payload.put("nf-naming-code", nfNamingCode);
357 AAIResourcesClient resourceClient = new AAIResourcesClient();
358 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
359 resourceClient.create(uri, payload)
361 AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId)
362 resourceClient.connect(uri, siUri)
364 }catch(Exception ex) {
365 logger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process: {}", ex.getMessage(), ex)
366 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf CreateGenericVnf Process")
368 logger.trace("COMPLETED DoCreateVnf CreateGenericVnf Process")
371 public void postProcessCreateGenericVnf (DelegateExecution execution) {
372 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
373 execution.setVariable("prefix",Prefix)
375 logger.trace("STARTED DoCreateVnf PostProcessCreateGenericVnf Process")
378 String vnfId = execution.getVariable("DoCVNF_vnfId")
379 def rollbackData = execution.getVariable("rollbackData")
380 rollbackData.put("VNF", "vnfId", vnfId)
381 rollbackData.put("VNF", "rollbackVnfCreate", "true")
382 execution.setVariable("rollbackData", rollbackData)
383 }catch(Exception ex) {
384 logger.debug("Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage())
385 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process")
387 logger.trace("COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process")
391 public void preProcessSDNCAssignRequest(DelegateExecution execution){
392 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
393 execution.setVariable("prefix", Prefix)
394 logger.trace("STARTED preProcessSDNCAssignRequest")
395 def vnfId = execution.getVariable("DoCVNF_vnfId")
396 def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
397 logger.debug("NEW VNF ID: " + vnfId)
402 String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign")
404 assignSDNCRequest = utils.formatXml(assignSDNCRequest)
405 execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest)
406 logger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest)
409 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
410 "Exception Occured Processing preProcessSDNCAssignRequest", "BPMN",
411 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e)
412 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage())
414 logger.trace("COMPLETED preProcessSDNCAssignRequest")
417 public void preProcessSDNCActivateRequest(DelegateExecution execution) {
418 def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' +
419 'execution=' + execution.getId() +
421 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
422 logger.trace('Entered ' + method)
423 execution.setVariable("prefix", Prefix)
424 logger.trace("STARTED preProcessSDNCActivateRequest Process")
426 String vnfId = execution.getVariable("DoCVNF_vnfId")
427 String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
429 String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate")
431 execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest)
432 logger.debug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest)
435 logger.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e)
436 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage())
438 logger.trace("COMPLETED preProcessSDNCActivateRequest Process")
441 public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
443 String uuid = execution.getVariable('testReqId') // for junits
445 uuid = execution.getVariable("DoCVNF_requestId") + "-" + System.currentTimeMillis()
447 def callbackURL = execution.getVariable("DoCVNF_sdncCallbackUrl")
448 def requestId = execution.getVariable("DoCVNF_requestId")
449 def serviceId = execution.getVariable("DoCVNF_serviceId")
450 def vnfType = execution.getVariable("DoCVNF_vnfType")
451 def vnfName = execution.getVariable("DoCVNF_vnfName")
452 // Only send vnfName to SDNC if it is not null, otherwise it will get generated by SDNC on Assign
453 String vnfNameString = ""
454 if (vnfName != null) {
455 vnfNameString = """<vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name>"""
457 def tenantId = execution.getVariable("DoCVNF_tenantId")
458 def source = execution.getVariable("DoCVNF_source")
459 def vnfId = execution.getVariable("DoCVNF_vnfId")
460 def cloudSiteId = execution.getVariable("DoCVNF_cloudSiteId")
461 def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId")
462 def serviceModelInfo = execution.getVariable("serviceModelInfo")
463 def vnfModelInfo = execution.getVariable("vnfModelInfo")
464 String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
465 String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)
466 def globalSubscriberId = execution.getVariable("DoCVNF_globalSubscriberId")
467 def sdncVersion = execution.getVariable("DoCVNF_sdncVersion")
469 String sdncVNFParamsXml = ""
471 if(execution.getVariable("DoCVNF_vnfParamsExistFlag") == true){
472 sdncVNFParamsXml = buildSDNCParamsXml(execution)
474 sdncVNFParamsXml = ""
478 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
479 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
480 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
481 <sdncadapter:RequestHeader>
482 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
483 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
484 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
485 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
486 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
487 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
488 </sdncadapter:RequestHeader>
489 <sdncadapterworkflow:SDNCRequestData>
490 <request-information>
491 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
492 <request-action>CreateVnfInstance</request-action>
493 <source>${MsoUtils.xmlEscape(source)}</source>
497 </request-information>
498 <service-information>
499 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
500 <subscription-service-type>${MsoUtils.xmlEscape(serviceId)}</subscription-service-type>
501 ${serviceEcompModelInformation}
502 <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id>
503 <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
504 </service-information>
506 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
507 <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
508 ${vnfEcompModelInformation}
512 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
513 <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>
516 </sdncadapterworkflow:SDNCRequestData>
517 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
519 logger.debug("sdncRequest: " + sdncRequest)
523 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
524 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
525 execution.setVariable("prefix",Prefix)
526 logger.debug("STARTED ValidateSDNCResponse Process")
528 WorkflowException workflowException = execution.getVariable("WorkflowException")
529 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
531 logger.debug("workflowException: " + workflowException)
533 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
534 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
536 logger.debug("SDNCResponse: " + response)
538 String sdncResponse = response
539 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
540 logger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
541 if(method.equals("get")){
542 String topologyGetResponse = execution.getVariable("DoCVNF_getSDNCAdapterResponse")
543 String data = utils.getNodeXml(topologyGetResponse, "response-data")
544 logger.debug("topologyGetResponseData: " + data)
545 String vnfName = utils.getNodeText(data, "vnf-name")
546 logger.debug("vnfName received from SDNC: " + vnfName)
547 execution.setVariable("vnfName", vnfName)
548 execution.setVariable("DoCVNF_vnfName", vnfName)
550 def rollbackData = execution.getVariable("rollbackData")
551 if (method.equals("assign")) {
552 rollbackData.put("VNF", "rollbackSDNCAssign", "true")
554 else if (method.equals("activate")) {
555 rollbackData.put("VNF", "rollbackSDNCActivate", "true")
557 execution.setVariable("rollbackData", rollbackData)
561 logger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
562 throw new BpmnError("MSOWorkflowException")
564 logger.debug("COMPLETED ValidateSDNCResponse Process")
567 public void preProcessSDNCGetRequest(DelegateExecution execution){
568 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
569 execution.setVariable("prefix", Prefix)
570 logger.trace("STARTED preProcessSDNCGetRequest Process")
572 def serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
574 String uuid = execution.getVariable('testReqId') // for junits
576 uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
579 def callbackUrl = execution.getVariable("DoCVFM_sdncCallbackUrl")
580 logger.debug("callbackUrl:" + callbackUrl)
582 def vnfId = execution.getVariable('DCVFM_vnfId')
585 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
589 svcInstId = serviceInstanceId
591 // serviceOperation will be retrieved from "object-path" element
592 // in SDNC Assign Response for VNF
593 String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse")
594 logger.debug("DoCVNF_assignSDNCAdapterResponse is: \n" + response)
596 String serviceOperation = ""
598 String data = utils.getNodeXml(response, "response-data")
599 logger.debug("responseData: " + data)
600 serviceOperation = utils.getNodeText(data, "object-path")
601 logger.debug("VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation)
604 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
607 String SDNCGetRequest =
608 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
609 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
610 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
611 <sdncadapter:RequestHeader>
612 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
613 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
614 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
615 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
616 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
617 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
618 </sdncadapter:RequestHeader>
619 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
620 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
623 execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest)
624 logger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest)
627 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
628 "Exception Occurred Processing preProcessSDNCGetRequest. ", "BPMN",
629 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
630 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage())
632 logger.trace("COMPLETED preProcessSDNCGetRequest Process")
636 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
638 * @param execution The flow's execution instance.
640 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
641 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
642 'execution=' + execution.getId() +
644 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
645 logger.trace('Entered ' + method)
648 def vnfId = execution.getVariable('DoCVNF_vnfId')
649 logger.debug("VNF ID: " + vnfId)
651 String updateAAIGenericVnfRequest = """
652 <UpdateAAIGenericVnfRequest>
653 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
654 <orchestration-status>Active</orchestration-status>
655 </UpdateAAIGenericVnfRequest>
657 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
658 execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
659 logger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
662 logger.trace('Exited ' + method)
663 } catch (BpmnError e) {
665 } catch (Exception e) {
666 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
667 "Caught exception in " + method, "BPMN",
668 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
669 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())