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.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
34 import org.onap.logging.filter.base.ErrorCode
35 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
36 import org.onap.so.bpmn.common.scripts.ExceptionUtil
37 import org.onap.so.bpmn.common.scripts.MsoUtils
38 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
39 import org.onap.so.bpmn.common.scripts.VidUtils
40 import org.onap.so.bpmn.common.util.OofInfraUtils
41 import org.onap.so.bpmn.core.RollbackData
42 import org.onap.so.bpmn.core.UrnPropertiesReader
43 import org.onap.so.bpmn.core.WorkflowException
44 import org.onap.so.bpmn.core.domain.VnfResource
45 import org.onap.so.bpmn.core.json.JsonUtils
46 import org.onap.so.db.catalog.beans.HomingInstance
47 import org.onap.so.logger.LoggingAnchor
48 import org.onap.so.logger.MessageEnum
49 import org.slf4j.Logger
50 import org.slf4j.LoggerFactory
53 * This class supports the DoCreateVnf building block subflow
54 * with the creation of a generic vnf for
58 class DoCreateVnf extends AbstractServiceTaskProcessor {
60 private static final Logger logger = LoggerFactory.getLogger( DoCreateVnf.class);
61 String Prefix="DoCVNF_"
62 ExceptionUtil exceptionUtil = new ExceptionUtil()
63 JsonUtils jsonUtil = new JsonUtils()
64 VidUtils vidUtils = new VidUtils(this)
65 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
66 OofInfraUtils oofInfraUtils = new OofInfraUtils()
69 * This method gets and validates the incoming
75 public void preProcessRequest(DelegateExecution execution) {
76 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
77 execution.setVariable("prefix",Prefix)
78 logger.debug("STARTED DoCreateVnf PreProcessRequest Process")
80 // DISABLE SDNC INTERACTION FOR NOW
81 execution.setVariable("SDNCInteractionEnabled", false)
88 def rollbackData = execution.getVariable("rollbackData")
89 if (rollbackData == null) {
90 rollbackData = new RollbackData()
93 String vnfModelInfo = execution.getVariable("vnfModelInfo")
94 String serviceModelInfo = execution.getVariable("serviceModelInfo")
96 String requestId = execution.getVariable("msoRequestId")
97 execution.setVariable("DoCVNF_requestId", requestId)
98 execution.setVariable("mso-request-id", requestId)
99 logger.debug("Incoming Request Id is: " + requestId)
101 String serviceInstanceId = execution.getVariable("serviceInstanceId")
102 execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId)
103 rollbackData.put("VNF", "serviceInstanceId", serviceInstanceId)
104 logger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
106 String vnfType = execution.getVariable("vnfType")
107 execution.setVariable("DoCVNF_vnfType", vnfType)
108 logger.debug("Incoming Vnf Type is: " + vnfType)
110 String vnfName = execution.getVariable("vnfName")
111 if (vnfName.equals("") || vnfName.equals("null")) {
112 AAIResourcesClient resourceClient = new AAIResourcesClient()
113 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(execution.getVariable("vnfId")))
114 if(resourceClient.exists(uri)){
115 exceptionUtil.buildWorkflowException(execution, 5000, "Generic Vnf Already Exist.")
120 execution.setVariable("DoCVNF_vnfName", vnfName)
121 logger.debug("Incoming Vnf Name is: " + vnfName)
123 String serviceId = execution.getVariable("productFamilyId")
124 execution.setVariable("DoCVNF_serviceId", serviceId)
125 logger.debug("Incoming Service Id is: " + serviceId)
127 String source = "VID"
128 execution.setVariable("DoCVNF_source", source)
129 rollbackData.put("VNF", "source", source)
130 logger.debug("Incoming Source is: " + source)
132 String suppressRollback = execution.getVariable("disableRollback")
133 execution.setVariable("DoCVNF_suppressRollback", suppressRollback)
134 logger.debug("Incoming Suppress Rollback is: " + suppressRollback)
136 String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantUuid")
137 execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId)
138 logger.debug("Incoming Invariant Id is: " + modelInvariantId)
140 String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid")
141 if (modelVersionId == null) {
144 execution.setVariable("DoCVNF_modelVersionId", modelVersionId)
145 logger.debug("Incoming Version Id is: " + modelVersionId)
147 String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion")
148 execution.setVariable("DoCVNF_modelVersion", modelVersion)
149 logger.debug("Incoming Model Version is: " + modelVersion)
151 String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName")
152 execution.setVariable("DoCVNF_modelName", modelName)
153 logger.debug("Incoming Model Name is: " + modelName)
155 String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid")
156 if (modelCustomizationId == null) {
157 modelCustomizationId = ""
159 execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId)
160 logger.debug("Incoming Model Customization Id is: " + modelCustomizationId)
162 String cloudSiteId = execution.getVariable("lcpCloudRegionId")
163 execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId)
164 rollbackData.put("VNF", "cloudSiteId", cloudSiteId)
165 logger.debug("Incoming Cloud Site Id is: " + cloudSiteId)
167 String tenantId = execution.getVariable("tenantId")
168 execution.setVariable("DoCVNF_tenantId", tenantId)
169 rollbackData.put("VNF", "tenantId", tenantId)
170 logger.debug("Incoming Tenant Id is: " + tenantId)
172 String globalSubscriberId = execution.getVariable("globalSubscriberId")
173 if (globalSubscriberId == null) {
174 globalSubscriberId = ""
176 execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId)
177 logger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId)
179 String sdncVersion = execution.getVariable("sdncVersion")
180 if (sdncVersion == null) {
183 execution.setVariable("DoCVNF_sdncVersion", sdncVersion)
184 logger.debug("Incoming Sdnc Version is: " + sdncVersion)
186 //For Completion Handler & Fallout Handler
188 """<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
189 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
190 <action>CREATE</action>
191 <source>${MsoUtils.xmlEscape(source)}</source>
194 execution.setVariable("DoCVNF_requestInfo", requestInfo)
195 //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
196 String orchStatus = "Created"
197 execution.setVariable("DoCVNF_orchStatus", orchStatus)
199 //TODO: Equipment Role - Should come from SDN-C Response in 1702
200 String equipmentRole = " "
201 execution.setVariable("DoCVNF_equipmentRole", equipmentRole)
202 String vnfId = execution.getVariable("testVnfId") // for junits
204 vnfId = execution.getVariable("vnfId")
205 if (isBlank(vnfId)) {
206 vnfId = UUID.randomUUID().toString()
207 logger.debug("Generated Vnf Id is: " + vnfId)
210 execution.setVariable("DoCVNF_vnfId", vnfId)
212 // Setting for Sub Flow Calls
213 execution.setVariable("DoCVNF_type", "generic-vnf")
214 execution.setVariable("GENGS_type", "service-instance")
216 String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
217 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
218 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
219 logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
220 ErrorCode.UnknownError.getValue());
221 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
223 execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl)
224 rollbackData.put("VNF", "sdncCallbackUrl", sdncCallbackUrl)
225 logger.debug("SDNC Callback URL is: " + sdncCallbackUrl)
227 VnfResource vnfResource = (VnfResource) execution.getVariable((String)"vnfResourceDecomposition")
228 String nfRole = vnfResource.getNfRole()
230 execution.setVariable("DoCVNF_nfRole", nfRole)
231 logger.debug("NF Role is: " + nfRole)
233 String nfNamingCode = vnfResource.getNfNamingCode()
234 execution.setVariable("DoCVNF_nfNamingCode", nfNamingCode)
235 logger.debug("NF Naming Code is: " + nfNamingCode)
237 String nfType = vnfResource.getNfType()
238 execution.setVariable("DoCVNF_nfType", nfType)
239 logger.debug("NF Type is: " + nfType)
241 String nfFunction = vnfResource.getNfFunction()
242 execution.setVariable("DoCVNF_nfFunction", nfFunction)
243 logger.debug("NF Function is: " + nfFunction)
247 HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution)
248 if (homingInstance != null) {
249 execution.setVariable("DoCVNF_cloudSiteId", homingInstance.getCloudRegionId())
250 rollbackData.put("VNF", "cloudSiteId", homingInstance.getCloudRegionId())
251 logger.debug("Overwriting cloudSiteId with homing cloudSiteId: " +
252 homingInstance.getCloudRegionId())
254 } catch (Exception exception) {
255 logger.debug("Could not find homing information for service instance: " + serviceInstanceId +
257 logger.debug("Could not find homing information for service instance error: " + exception)
260 rollbackData.put("VNF", "rollbackSDNCAssign", "false")
261 rollbackData.put("VNF", "rollbackSDNCActivate", "false")
262 rollbackData.put("VNF", "rollbackVnfCreate", "false")
264 execution.setVariable("rollbackData", rollbackData)
267 logger.debug("Rethrowing MSOWorkflowException")
270 logger.debug(" Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage())
271 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest")
274 logger.trace("COMPLETED DoCreateVnf PreProcessRequest Process")
278 * Gets the service instance from aai
280 public void getServiceInstance(DelegateExecution execution) {
282 String serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
284 AAIResourcesClient resourceClient = new AAIResourcesClient()
285 AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId))
287 if(resourceClient.exists(uri)){
288 Map<String, String> keys = uri.getURIKeys()
289 execution.setVariable("globalCustomerId", keys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId))
290 execution.setVariable("serviceType", keys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType))
291 execution.setVariable("GENGS_siResourceLink", uri.build().toString())
294 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
297 }catch(BpmnError e) {
299 }catch(Exception ex) {
300 String msg = "Exception in getServiceInstance. " + ex.getMessage()
302 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
306 private Object getVariableEnforced(DelegateExecution execution, String name){
307 Object enforced = execution.getVariable(name)
314 public void createGenericVnf (DelegateExecution execution) {
315 execution.setVariable("prefix",Prefix)
316 logger.trace("STARTED DoCreateVnf CreateGenericVnf Process")
319 String vnfId = getVariableEnforced(execution, "DoCVNF_vnfId")
320 String vnfName = getVariableEnforced(execution, "DoCVNF_vnfName")
321 if (vnfName == null) {
322 vnfName = "sdncGenerated"
323 logger.debug("Sending a dummy VNF name to AAI - the name will be generated by SDNC: " + vnfName)
325 String vnfType = getVariableEnforced(execution, "DoCVNF_vnfType")
326 String serviceId = getVariableEnforced(execution, "DoCVNF_serviceId")
327 String orchStatus = getVariableEnforced(execution, "DoCVNF_orchStatus")
328 String modelInvariantId = getVariableEnforced(execution, "DoCVNF_modelInvariantId")
329 String modelVersionId = getVariableEnforced(execution, "DoCVNF_modelVersionId")
330 String modelCustomizationId = getVariableEnforced(execution, "DoCVNF_modelCustomizationId")
331 String equipmentRole = getVariableEnforced(execution, "DoCVNF_equipmentRole")
332 String nfType = getVariableEnforced(execution, "DoCVNF_nfType")
333 String nfRole = getVariableEnforced(execution, "DoCVNF_nfRole")
334 String nfFunction = getVariableEnforced(execution, "DoCVNF_nfFunction")
335 String nfNamingCode = getVariableEnforced(execution, "DoCVNF_nfNamingCode")
337 //Get Service Instance Info
338 String serviceInstanceId = getVariableEnforced(execution, "DoCVNF_serviceInstanceId")
340 String globalCustId = execution.getVariable("globalCustomerId")
341 String serviceType = execution.getVariable("serviceType")
343 Map<String, String> payload = new LinkedHashMap<>();
344 payload.put("vnf-id", vnfId);
345 payload.put("vnf-name", vnfName);
346 payload.put("service-id", serviceId);
347 payload.put("vnf-type", vnfType);
348 payload.put("prov-status", "PREPROV");
349 payload.put("orchestration-status", orchStatus);
350 payload.put("model-invariant-id", modelInvariantId);
351 payload.put("model-version-id", modelVersionId);
352 payload.put("model-customization-id", modelCustomizationId);
353 payload.put("nf-type", nfType);
354 payload.put("nf-role", nfRole);
355 payload.put("nf-function", nfFunction);
356 payload.put("nf-naming-code", nfNamingCode);
358 AAIResourcesClient resourceClient = new AAIResourcesClient();
359 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))
360 resourceClient.create(uri, payload)
362 AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalCustId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId))
363 resourceClient.connect(uri, siUri)
365 }catch(Exception ex) {
366 logger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process: {}", ex.getMessage(), ex)
367 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf CreateGenericVnf Process")
369 logger.trace("COMPLETED DoCreateVnf CreateGenericVnf Process")
372 public void postProcessCreateGenericVnf (DelegateExecution execution) {
373 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
374 execution.setVariable("prefix",Prefix)
376 logger.trace("STARTED DoCreateVnf PostProcessCreateGenericVnf Process")
379 String vnfId = execution.getVariable("DoCVNF_vnfId")
380 def rollbackData = execution.getVariable("rollbackData")
381 rollbackData.put("VNF", "vnfId", vnfId)
382 rollbackData.put("VNF", "rollbackVnfCreate", "true")
383 execution.setVariable("rollbackData", rollbackData)
384 }catch(Exception ex) {
385 logger.debug("Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage())
386 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process")
388 logger.trace("COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process")
392 public void preProcessSDNCAssignRequest(DelegateExecution execution){
393 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
394 execution.setVariable("prefix", Prefix)
395 logger.trace("STARTED preProcessSDNCAssignRequest")
396 def vnfId = execution.getVariable("DoCVNF_vnfId")
397 def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
398 logger.debug("NEW VNF ID: " + vnfId)
403 String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign")
405 assignSDNCRequest = utils.formatXml(assignSDNCRequest)
406 execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest)
407 logger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest)
410 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
411 "Exception Occured Processing preProcessSDNCAssignRequest", "BPMN",
412 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e)
413 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage())
415 logger.trace("COMPLETED preProcessSDNCAssignRequest")
418 public void preProcessSDNCActivateRequest(DelegateExecution execution) {
419 def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' +
420 'execution=' + execution.getId() +
422 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
423 logger.trace('Entered ' + method)
424 execution.setVariable("prefix", Prefix)
425 logger.trace("STARTED preProcessSDNCActivateRequest Process")
427 String vnfId = execution.getVariable("DoCVNF_vnfId")
428 String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
430 String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate")
432 execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest)
433 logger.debug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest)
436 logger.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e)
437 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage())
439 logger.trace("COMPLETED preProcessSDNCActivateRequest Process")
442 public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
444 String uuid = execution.getVariable('testReqId') // for junits
446 uuid = execution.getVariable("DoCVNF_requestId") + "-" + System.currentTimeMillis()
448 def callbackURL = execution.getVariable("DoCVNF_sdncCallbackUrl")
449 def requestId = execution.getVariable("DoCVNF_requestId")
450 def serviceId = execution.getVariable("DoCVNF_serviceId")
451 def vnfType = execution.getVariable("DoCVNF_vnfType")
452 def vnfName = execution.getVariable("DoCVNF_vnfName")
453 // Only send vnfName to SDNC if it is not null, otherwise it will get generated by SDNC on Assign
454 String vnfNameString = ""
455 if (vnfName != null) {
456 vnfNameString = """<vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name>"""
458 def tenantId = execution.getVariable("DoCVNF_tenantId")
459 def source = execution.getVariable("DoCVNF_source")
460 def vnfId = execution.getVariable("DoCVNF_vnfId")
461 def cloudSiteId = execution.getVariable("DoCVNF_cloudSiteId")
462 def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId")
463 def serviceModelInfo = execution.getVariable("serviceModelInfo")
464 def vnfModelInfo = execution.getVariable("vnfModelInfo")
465 String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
466 String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)
467 def globalSubscriberId = execution.getVariable("DoCVNF_globalSubscriberId")
468 def sdncVersion = execution.getVariable("DoCVNF_sdncVersion")
470 String sdncVNFParamsXml = ""
472 if(execution.getVariable("DoCVNF_vnfParamsExistFlag") == true){
473 sdncVNFParamsXml = buildSDNCParamsXml(execution)
475 sdncVNFParamsXml = ""
479 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
480 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
481 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
482 <sdncadapter:RequestHeader>
483 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
484 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
485 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
486 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
487 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
488 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
489 </sdncadapter:RequestHeader>
490 <sdncadapterworkflow:SDNCRequestData>
491 <request-information>
492 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
493 <request-action>CreateVnfInstance</request-action>
494 <source>${MsoUtils.xmlEscape(source)}</source>
498 </request-information>
499 <service-information>
500 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
501 <subscription-service-type>${MsoUtils.xmlEscape(serviceId)}</subscription-service-type>
502 ${serviceEcompModelInformation}
503 <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id>
504 <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
505 </service-information>
507 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
508 <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
509 ${vnfEcompModelInformation}
513 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
514 <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>
517 </sdncadapterworkflow:SDNCRequestData>
518 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
520 logger.debug("sdncRequest: " + sdncRequest)
524 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
525 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
526 execution.setVariable("prefix",Prefix)
527 logger.debug("STARTED ValidateSDNCResponse Process")
529 WorkflowException workflowException = execution.getVariable("WorkflowException")
530 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
532 logger.debug("workflowException: " + workflowException)
534 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
535 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
537 logger.debug("SDNCResponse: " + response)
539 String sdncResponse = response
540 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
541 logger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
542 if(method.equals("get")){
543 String topologyGetResponse = execution.getVariable("DoCVNF_getSDNCAdapterResponse")
544 String data = utils.getNodeXml(topologyGetResponse, "response-data")
545 logger.debug("topologyGetResponseData: " + data)
546 String vnfName = utils.getNodeText(data, "vnf-name")
547 logger.debug("vnfName received from SDNC: " + vnfName)
548 execution.setVariable("vnfName", vnfName)
549 execution.setVariable("DoCVNF_vnfName", vnfName)
551 def rollbackData = execution.getVariable("rollbackData")
552 if (method.equals("assign")) {
553 rollbackData.put("VNF", "rollbackSDNCAssign", "true")
555 else if (method.equals("activate")) {
556 rollbackData.put("VNF", "rollbackSDNCActivate", "true")
558 execution.setVariable("rollbackData", rollbackData)
562 logger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
563 throw new BpmnError("MSOWorkflowException")
565 logger.debug("COMPLETED ValidateSDNCResponse Process")
568 public void preProcessSDNCGetRequest(DelegateExecution execution){
569 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
570 execution.setVariable("prefix", Prefix)
571 logger.trace("STARTED preProcessSDNCGetRequest Process")
573 def serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
575 String uuid = execution.getVariable('testReqId') // for junits
577 uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
580 def callbackUrl = execution.getVariable("DoCVFM_sdncCallbackUrl")
581 logger.debug("callbackUrl:" + callbackUrl)
583 def vnfId = execution.getVariable('DCVFM_vnfId')
586 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
590 svcInstId = serviceInstanceId
592 // serviceOperation will be retrieved from "object-path" element
593 // in SDNC Assign Response for VNF
594 String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse")
595 logger.debug("DoCVNF_assignSDNCAdapterResponse is: \n" + response)
597 String serviceOperation = ""
599 String data = utils.getNodeXml(response, "response-data")
600 logger.debug("responseData: " + data)
601 serviceOperation = utils.getNodeText(data, "object-path")
602 logger.debug("VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation)
605 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
608 String SDNCGetRequest =
609 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
610 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
611 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
612 <sdncadapter:RequestHeader>
613 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
614 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
615 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
616 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
617 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
618 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
619 </sdncadapter:RequestHeader>
620 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
621 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
624 execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest)
625 logger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest)
628 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
629 "Exception Occurred Processing preProcessSDNCGetRequest. ", "BPMN",
630 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
631 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage())
633 logger.trace("COMPLETED preProcessSDNCGetRequest Process")
637 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
639 * @param execution The flow's execution instance.
641 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
642 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
643 'execution=' + execution.getId() +
645 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
646 logger.trace('Entered ' + method)
649 def vnfId = execution.getVariable('DoCVNF_vnfId')
650 logger.debug("VNF ID: " + vnfId)
652 String updateAAIGenericVnfRequest = """
653 <UpdateAAIGenericVnfRequest>
654 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
655 <orchestration-status>Active</orchestration-status>
656 </UpdateAAIGenericVnfRequest>
658 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
659 execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
660 logger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
663 logger.trace('Exited ' + method)
664 } catch (BpmnError e) {
666 } catch (Exception e) {
667 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
668 "Caught exception in " + method, "BPMN",
669 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
670 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())