2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
10 * http://www.apache.org/licenses/LICENSE-2.0
\r
12 * Unless required by applicable law or agreed to in writing, software
\r
13 * distributed under the License is distributed on an "AS IS" BASIS,
\r
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
15 * See the License for the specific language governing permissions and
\r
16 * limitations under the License.
\r
17 * ============LICENSE_END=========================================================
\r
20 package org.openecomp.mso.bpmn.infrastructure.scripts
\r
22 import groovy.json.JsonOutput
\r
23 import groovy.json.JsonSlurper
\r
24 import groovy.util.Node
\r
25 import groovy.util.XmlParser;
\r
26 import groovy.xml.QName
\r
28 import java.beans.MetaData.java_lang_Class_PersistenceDelegate
\r
29 import java.io.Serializable;
\r
30 import java.util.UUID;
\r
31 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
\r
32 import org.camunda.bpm.engine.delegate.BpmnError
\r
33 import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd
\r
34 import org.camunda.bpm.engine.runtime.Execution
\r
35 import org.openecomp.mso.rest.APIResponse
\r
36 import org.openecomp.mso.rest.RESTClient
\r
37 import org.openecomp.mso.rest.RESTConfig
\r
38 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;
\r
39 import org.openecomp.mso.bpmn.common.scripts.VidUtils;
\r
40 import org.openecomp.mso.bpmn.core.RollbackData
\r
41 import org.openecomp.mso.bpmn.core.WorkflowException
\r
42 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
\r
43 import org.openecomp.mso.bpmn.core.json.JsonUtils
\r
44 import org.openecomp.mso.bpmn.core.domain.ModelInfo
\r
45 import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
\r
46 import org.openecomp.mso.bpmn.core.domain.VnfResource
\r
47 import org.openecomp.mso.client.aai.*
\r
49 import org.openecomp.mso.client.appc.ApplicationControllerClient;
\r
50 import org.openecomp.mso.client.appc.ApplicationControllerSupport;
\r
51 import org.openecomp.appc.client.lcm.model.Action;
\r
52 import org.openecomp.appc.client.lcm.model.ActionIdentifiers;
\r
53 import org.openecomp.appc.client.lcm.model.LockInput
\r
54 import org.openecomp.appc.client.lcm.model.UnlockInput
\r
55 import org.openecomp.appc.client.lcm.model.HealthCheckInput
\r
56 import org.openecomp.appc.client.lcm.model.StartInput
\r
57 import org.openecomp.appc.client.lcm.model.StopInput
\r
58 import org.openecomp.appc.client.lcm.model.Flags
\r
59 import org.openecomp.appc.client.lcm.model.Status
\r
63 public class UpdateVnfInfra extends AbstractServiceTaskProcessor {
\r
65 ExceptionUtil exceptionUtil = new ExceptionUtil()
\r
66 JsonUtils jsonUtils = new JsonUtils()
\r
67 ApplicationControllerClient appcClient = new ApplicationControllerClient()
\r
68 def prefix = "UPDVnfI_"
\r
71 * Initialize the flow's variables.
\r
73 * @param execution The flow's execution instance.
\r
75 public void initProcessVariables(Execution execution) {
\r
76 execution.setVariable('prefix', 'UPDVnfI_')
\r
77 execution.setVariable('UPDVnfI_Request', null)
\r
78 execution.setVariable('UPDVnfI_requestInfo', null)
\r
79 execution.setVariable('UPDVnfI_requestId', null)
\r
80 execution.setVariable('UPDVnfI_source', null)
\r
81 execution.setVariable('UPDVnfI_vnfInputs', null)
\r
82 execution.setVariable('UPDVnfI_vnfId', null)
\r
83 execution.setVariable('UPDVnfI_tenantId', null)
\r
84 execution.setVariable('UPDVnfI_vnfParams', null)
\r
85 execution.setVariable('UpdateVnfSuccessIndicator', false)
\r
86 execution.setVariable('UPDVnfI_serviceType', null)
\r
87 execution.setVariable('UPDVnfI_nfRole', null)
\r
88 execution.setVariable('UPDVnfI_currentActivity', 'UPDVnfI')
\r
89 execution.setVariable('UPDVnfI_workStep', null)
\r
90 execution.setVariable('UPDVnfI_failedActivity', null)
\r
91 execution.setVariable('UPDVnfI_errorCode', "0")
\r
92 execution.setVariable('UPDVnfI_errorText', null)
\r
93 execution.setVariable('UPDVnfI_healthCheckIndex', 1)
\r
97 * Check for missing elements in the received request.
\r
99 * @param execution The flow's execution instance.
\r
101 public void preProcessRequest(Execution execution) {
\r
102 def method = getClass().getSimpleName() + '.preProcessRequest(' +
\r
103 'execution=' + execution.getId() +
\r
105 initProcessVariables(execution)
\r
106 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
107 logDebug('Entered ' + method, isDebugLogEnabled)
\r
109 initProcessVariables(execution)
\r
111 def incomingRequest = execution.getVariable('bpmnRequest')
\r
113 utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled)
\r
115 def jsonSlurper = new JsonSlurper()
\r
116 def jsonOutput = new JsonOutput()
\r
117 Map reqMap = jsonSlurper.parseText(incomingRequest)
\r
118 utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled)
\r
120 def serviceInstanceId = execution.getVariable('serviceInstanceId')
\r
121 def vnfId = execution.getVariable('vnfId')
\r
123 execution.setVariable(prefix + 'serviceInstanceId', serviceInstanceId)
\r
124 execution.setVariable(prefix + 'vnfId', vnfId)
\r
125 execution.setVariable("isVidRequest", "true")
\r
127 def asdcServiceModelVersion = ''
\r
128 def serviceModelInfo = null
\r
130 def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList
\r
132 if (relatedInstanceList != null) {
\r
133 relatedInstanceList.each {
\r
134 if (it.relatedInstance.modelInfo?.modelType == 'service') {
\r
135 utils.log("DEBUG", "PROCESSING SERVICE INFO", isDebugLogEnabled)
\r
136 asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion
\r
137 serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
\r
138 utils.log("DEBUG", "ServiceModelInfo: " + serviceModelInfo, isDebugLogEnabled)
\r
139 def modelInvariant = jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid")
\r
140 utils.log("DEBUG", "modelInvariant: " + modelInvariant, isDebugLogEnabled)
\r
146 execution.setVariable(prefix + 'asdcServiceModelVersion', asdcServiceModelVersion)
\r
147 execution.setVariable(prefix + 'serviceModelInfo', serviceModelInfo)
\r
148 def vnfModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo)
\r
149 execution.setVariable(prefix + 'vnfModelInfo', vnfModelInfo)
\r
150 def vnfModelInvariantUuid = jsonUtils.getJsonValue(vnfModelInfo, "modelInvariantUuid")
\r
151 execution.setVariable(prefix + 'vnfModelInvariantUuid', vnfModelInvariantUuid)
\r
152 logDebug("vnfModelInvariantUuid: " + vnfModelInvariantUuid, isDebugLogEnabled)
\r
154 def vnfType = execution.getVariable('vnfType')
\r
155 execution.setVariable(prefix + 'vnfType', vnfType)
\r
157 def userParams = reqMap.requestDetails?.requestParameters?.userParams
\r
159 Map<String, String> userParamsMap = [:]
\r
160 if (userParams != null) {
\r
161 userParams.each { userParam ->
\r
162 userParamsMap.put(userParam.name, userParam.value)
\r
166 utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled)
\r
168 execution.setVariable(prefix + 'vfModuleInputParams', userParamsMap)
\r
170 def requestId = execution.getVariable("mso-request-id")
\r
171 execution.setVariable(prefix + 'requestId', requestId)
\r
172 execution.setVariable('msoRequestId', requestId)
\r
175 def vnfName = reqMap.requestDetails?.requestInfo?.instanceName ?: null
\r
176 execution.setVariable(prefix + 'vnfName', vnfName)
\r
178 def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null
\r
179 execution.setVariable(prefix + 'requestorId', requestorId)
\r
181 def usePreload = reqMap.requestDetails?.requestParameters?.usePreload
\r
182 execution.setVariable(prefix + 'usePreload', usePreload)
\r
184 def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration
\r
185 def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId
\r
186 execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId)
\r
187 def tenantId = cloudConfiguration.tenantId
\r
188 execution.setVariable(prefix + 'tenantId', tenantId)
\r
190 def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: ''
\r
191 execution.setVariable(prefix + 'globalSubscriberId', globalSubscriberId)
\r
193 execution.setVariable(prefix + 'sdncVersion', '1702')
\r
195 execution.setVariable("UpdateVnfInfraSuccessIndicator", false)
\r
197 execution.setVariable("isDebugLogEnabled", isDebugLogEnabled)
\r
199 def source = reqMap.requestDetails?.requestInfo?.source
\r
200 execution.setVariable(prefix + "source", source)
\r
202 //For Completion Handler & Fallout Handler
\r
203 String requestInfo =
\r
204 """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
\r
205 <request-id>${requestId}</request-id>
\r
206 <action>UPDATE</action>
\r
207 <source>${source}</source>
\r
210 execution.setVariable(prefix + "requestInfo", requestInfo)
\r
212 logDebug('RequestInfo: ' + execution.getVariable(prefix + "requestInfo"), isDebugLogEnabled)
\r
214 logDebug('Exited ' + method, isDebugLogEnabled)
\r
217 catch(groovy.json.JsonException je) {
\r
218 utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled)
\r
219 exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format")
\r
222 catch(Exception e) {
\r
223 String restFaultMessage = e.getMessage()
\r
224 utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled)
\r
225 exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage)
\r
230 * Prepare and send the sychronous response for this flow.
\r
232 * @param execution The flow's execution instance.
\r
234 public void sendSynchResponse(Execution execution) {
\r
235 def method = getClass().getSimpleName() + '.sendSynchResponse(' +
\r
236 'execution=' + execution.getId() +
\r
238 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
239 logDebug('Entered ' + method, isDebugLogEnabled)
\r
243 def requestInfo = execution.getVariable('UPDVnfI_requestInfo')
\r
244 def requestId = execution.getVariable('UPDVnfI_requestId')
\r
245 def source = execution.getVariable('UPDVnfI_source')
\r
246 def progress = getNodeTextForce(requestInfo, 'progress')
\r
247 if (progress.isEmpty()) {
\r
250 def startTime = getNodeTextForce(requestInfo, 'start-time')
\r
251 if (startTime.isEmpty()) {
\r
252 startTime = System.currentTimeMillis()
\r
255 // RESTResponse (for API Handler (APIH) Reply Task)
\r
256 def vnfId = execution.getVariable("vnfId")
\r
257 String synchResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim()
\r
259 sendWorkflowResponse(execution, 200, synchResponse)
\r
261 logDebug('Exited ' + method, isDebugLogEnabled)
\r
262 } catch (BpmnError e) {
\r
264 } catch (Exception e) {
\r
265 logError('Caught exception in ' + method, e)
\r
266 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage())
\r
273 * Get VnfResource decomposition object for this VNF.
\r
276 * @param execution The flow's execution instance.
\r
278 public void getVnfResourceDecomposition(Execution execution) {
\r
279 def method = getClass().getSimpleName() + '.getVnfResourceDecomposition(' +
\r
280 'execution=' + execution.getId() +
\r
282 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
283 logDebug('Entered ' + method, isDebugLogEnabled)
\r
286 ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
\r
287 String vnfModelInvariantUuid = execution.getVariable(prefix + 'vnfModelInvariantUuid')
\r
288 logDebug("vnfModelInvariantUuid: " + vnfModelInvariantUuid, isDebugLogEnabled)
\r
289 List<VnfResource> vnfResources = serviceDecomposition.getServiceVnfs()
\r
291 for (i in 0..vnfResources.size()-1) {
\r
292 ModelInfo modelInfo = vnfResources[i].getModelInfo()
\r
293 String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid()
\r
294 logDebug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition, isDebugLogEnabled)
\r
296 if (vnfModelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) {
\r
297 VnfResource vnfResourceDecomposition = vnfResources[i]
\r
298 execution.setVariable(prefix + 'vnfResourceDecomposition', vnfResourceDecomposition)
\r
299 def nfRole = vnfResourceDecomposition.getNfRole()
\r
300 execution.setVariable(prefix + 'nfRole', nfRole)
\r
301 logDebug("vnfResourceDecomposition: " + vnfResourceDecomposition.toJsonString(), isDebugLogEnabled)
\r
310 logDebug('Exited ' + method, isDebugLogEnabled)
\r
311 } catch (BpmnError e) {
\r
313 } catch (Exception e) {
\r
314 logError('Caught exception in ' + method, e)
\r
315 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getVnfResourceDecomposition(): ' + e.getMessage())
\r
320 * Check if this VNF is already in maintenance in A&AI.
\r
323 * @param execution The flow's execution instance.
\r
325 public void checkIfVnfInMaintInAAI(Execution execution) {
\r
326 def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' +
\r
327 'execution=' + execution.getId() +
\r
329 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
330 execution.setVariable(prefix + 'errorCode', "0")
\r
331 execution.setVariable(prefix + "workStep", "checkIfVnfInMaintInAAI")
\r
332 execution.setVariable(prefix + "failedActivity", "AAI")
\r
333 logDebug('Entered ' + method, isDebugLogEnabled)
\r
336 def transactionLoggingUuid = UUID.randomUUID().toString()
\r
337 AAIRestClientImpl client = new AAIRestClientImpl()
\r
338 AAIValidatorImpl aaiValidator = new AAIValidatorImpl()
\r
339 aaiValidator.setClient(client)
\r
340 def vnfId = execution.getVariable("vnfId")
\r
341 boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid)
\r
342 logDebug("isInMaint result: " + isInMaint, isDebugLogEnabled)
\r
343 execution.setVariable(prefix + 'isVnfInMaintenance', isInMaint)
\r
345 logDebug('Exited ' + method, isDebugLogEnabled)
\r
346 } catch (BpmnError e) {
\r
348 } catch (Exception e) {
\r
349 logError('Caught exception in ' + method, e)
\r
350 execution.setVariable(prefix + "errorCode", "1002")
\r
351 execution.setVariable(prefix + "errorText", e.getMessage())
\r
352 //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage())
\r
358 * Check if this VNF's pservers are locked in A&AI.
\r
361 * @param execution The flow's execution instance.
\r
363 public void checkIfPserversInMaintInAAI(Execution execution) {
\r
364 def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' +
\r
365 'execution=' + execution.getId() +
\r
367 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
368 execution.setVariable(prefix + 'errorCode', "0")
\r
369 logDebug('Entered ' + method, isDebugLogEnabled)
\r
370 execution.setVariable(prefix + "workStep", "checkIfPserversInMaintInAAI")
\r
371 execution.setVariable(prefix + "failedActivity", "AAI")
\r
374 def transactionLoggingUuid = UUID.randomUUID().toString()
\r
375 AAIRestClientImpl client = new AAIRestClientImpl()
\r
376 AAIValidatorImpl aaiValidator = new AAIValidatorImpl()
\r
377 aaiValidator.setClient(client)
\r
378 def vnfId = execution.getVariable("vnfId")
\r
379 boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid)
\r
380 logDebug("areLocked result: " + areLocked, isDebugLogEnabled)
\r
381 execution.setVariable(prefix + 'arePserversLocked', areLocked)
\r
383 logDebug('Exited ' + method, isDebugLogEnabled)
\r
384 } catch (BpmnError e) {
\r
386 } catch (Exception e) {
\r
387 logError('Caught exception in ' + method, e)
\r
388 execution.setVariable(prefix + "errorCode", "1002")
\r
389 execution.setVariable(prefix + "errorText", e.getMessage())
\r
390 //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfPserversInMaintInAAI(): ' + e.getMessage())
\r
395 * Set inMaint flag for this VNF to the specified value in A&AI.
\r
398 * @param execution The flow's execution instance.
\r
399 * @param inMaint The boolean value of the flag to set
\r
401 public void setVnfInMaintFlagInAAI(Execution execution, boolean inMaint) {
\r
402 def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' +
\r
403 'execution=' + execution.getId() +
\r
405 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
406 execution.setVariable(prefix + 'errorCode', "0")
\r
407 logDebug('Entered ' + method, isDebugLogEnabled)
\r
409 execution.setVariable(prefix + "workStep", "setVnfInMaintFlagInAAI")
\r
412 execution.setVariable(prefix + "workStep", "unsetVnfInMaintFlagInAAI")
\r
414 execution.setVariable(prefix + "failedActivity", "AAI")
\r
417 def transactionLoggingUuid = UUID.randomUUID().toString()
\r
418 AAIRestClientImpl client = new AAIRestClientImpl()
\r
419 AAIUpdatorImpl aaiUpdator = new AAIUpdatorImpl()
\r
420 aaiUpdator.setClient(client)
\r
421 def vnfId = execution.getVariable("vnfId")
\r
423 aaiUpdator.updateVnfToLocked(vnfId, transactionLoggingUuid)
\r
426 aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid)
\r
429 logDebug('Exited ' + method, isDebugLogEnabled)
\r
430 } catch (BpmnError e) {
\r
432 } catch (Exception e) {
\r
433 logError('Caught exception in ' + method, e)
\r
434 execution.setVariable(prefix + "errorCode", "1002")
\r
435 execution.setVariable(prefix + "errorText", e.getMessage())
\r
436 //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage())
\r
441 * Call APP-C client to execute specified APP-C command for this VNF.
\r
444 * @param execution The flow's execution instance.
\r
445 * @param action The action to take in APP-C.
\r
447 public void runAppcCommand(Execution execution, Action action) {
\r
448 def method = getClass().getSimpleName() + '.runAppcCommand(' +
\r
449 'execution=' + execution.getId() +
\r
451 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
452 execution.setVariable(prefix + 'errorCode', "0")
\r
453 logDebug('Entered ' + method, isDebugLogEnabled)
\r
456 logDebug("Running APP-C action: " + action.toString(), isDebugLogEnabled)
\r
457 String vnfId = execution.getVariable('vnfId')
\r
458 String msoRequestId = execution.getVariable(prefix + 'requestId')
\r
459 execution.setVariable('msoRequestId', msoRequestId)
\r
460 execution.setVariable(prefix + "failedActivity", "APP-C")
\r
462 ApplicationControllerSupport support = new ApplicationControllerSupport()
\r
463 appcClient.appCSupport=support
\r
464 org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage", "org.openecomp.appc.client.lcm.model");
\r
465 Flags flags = new Flags();
\r
466 ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
\r
467 actionIdentifiers.setVnfId(vnfId);
\r
471 execution.setVariable(prefix + 'workStep', "LockVNF")
\r
472 appcStatus = appcClient.runCommand(Action.Lock,actionIdentifiers,flags,null,msoRequestId)
\r
474 case Action.Unlock:
\r
475 execution.setVariable(prefix + 'workStep', "UnlockVNF")
\r
476 appcStatus = appcClient.runCommand(Action.Unlock,actionIdentifiers,flags,null,msoRequestId)
\r
478 case Action.HealthCheck:
\r
479 def healthCheckIndex = execution.getVariable(prefix + 'healthCheckIndex')
\r
480 execution.setVariable(prefix + 'workStep', "HealthCheckVNF" + healthCheckIndex)
\r
481 execution.setVariable(prefix + 'healthCheckIndex', healthCheckIndex + 1)
\r
482 appcStatus = appcClient.runCommand(Action.HealthCheck,actionIdentifiers,flags,null,msoRequestId)
\r
485 execution.setVariable(prefix + 'workStep', "StartVNF")
\r
486 appcStatus = appcClient.runCommand(Action.Start,actionIdentifiers,flags,null,msoRequestId)
\r
489 execution.setVariable(prefix + 'workStep', "StopVNF")
\r
490 appcStatus = appcClient.runCommand(Action.Stop,actionIdentifiers,flags,null,msoRequestId)
\r
495 logDebug("Completed AppC request", isDebugLogEnabled)
\r
496 int appcCode = appcStatus.getCode()
\r
497 logDebug("AppC status code is: " + appcCode, isDebugLogEnabled)
\r
498 logDebug("AppC status message is: " + appcStatus.getMessage(), isDebugLogEnabled)
\r
499 if (support.getCategoryOf(appcStatus) == ApplicationControllerSupport.StatusCategory.ERROR) {
\r
500 execution.setVariable(prefix + "errorCode", Integer.toString(appcCode))
\r
501 execution.setVariable(prefix + "errorText", appcStatus.getMessage())
\r
503 logDebug('Exited ' + method, isDebugLogEnabled)
\r
504 } catch (BpmnError e) {
\r
505 logError('Caught exception in ' + method, e)
\r
506 execution.setVariable(prefix + "errorCode", "1002")
\r
507 execution.setVariable(prefix + "errorText", e.getMessage())
\r
509 } catch (java.lang.NoSuchMethodError e) {
\r
510 logError('Caught exception in ' + method, e)
\r
511 execution.setVariable(prefix + "errorCode", "1002")
\r
512 execution.setVariable(prefix + "errorText", e.getMessage())
\r
514 } catch (Exception e) {
\r
515 logError('Caught exception in ' + method, e)
\r
516 execution.setVariable(prefix + "errorCode", "1002")
\r
517 execution.setVariable(prefix + "errorText", e.getMessage())
\r
519 //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in ' + method + ': ' + e.getMessage())
\r
528 * Builds a "CompletionHandler" request and stores it in the specified execution variable.
\r
530 * @param execution the execution
\r
531 * @param resultVar the execution variable in which the result will be stored
\r
533 public void completionHandlerPrep(Execution execution, String resultVar) {
\r
534 def method = getClass().getSimpleName() + '.completionHandlerPrep(' +
\r
535 'execution=' + execution.getId() +
\r
536 ', resultVar=' + resultVar +
\r
538 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
539 logDebug('Entered ' + method, isDebugLogEnabled)
\r
543 appcClient.shutdownclient()
\r
544 def requestInfo = getVariable(execution, 'UPDVnfI_requestInfo')
\r
546 String content = """
\r
547 <sdncadapterworkflow:MsoCompletionRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
\r
548 xmlns:reqtype="http://org.openecomp/mso/request/types/v1">
\r
550 <sdncadapterworkflow:mso-bpel-name>MSO_ACTIVATE_BPEL</sdncadapterworkflow:mso-bpel-name>
\r
551 </sdncadapterworkflow:MsoCompletionRequest>
\r
554 content = utils.formatXml(content)
\r
555 logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled)
\r
556 execution.setVariable(resultVar, content)
\r
558 logDebug('Exited ' + method, isDebugLogEnabled)
\r
559 } catch (BpmnError e) {
\r
561 } catch (Exception e) {
\r
562 logError('Caught exception in ' + method, e)
\r
563 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error')
\r
568 * Prepare DoUpdateVnfAndModules call.
\r
571 * @param execution The flow's execution instance.
\r
573 public void prepDoUpdateVnfAndModules(Execution execution) {
\r
574 def method = getClass().getSimpleName() + '.prepDoUpdateVnfAndModules(' +
\r
575 'execution=' + execution.getId() +
\r
577 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
578 execution.setVariable(prefix + 'errorCode', "0")
\r
579 logDebug('Entered ' + method, isDebugLogEnabled)
\r
580 execution.setVariable(prefix + "workStep", "doUpdateVnfAndModules")
\r
581 execution.setVariable(prefix + "failedActivity", "MSO Update VNF")
\r
582 logDebug('Exited ' + method, isDebugLogEnabled)
\r
587 * Builds a "FalloutHandler" request and stores it in the specified execution variable.
\r
589 * @param execution the execution
\r
590 * @param resultVar the execution variable in which the result will be stored
\r
592 public void falloutHandlerPrep(Execution execution, String resultVar) {
\r
593 def method = getClass().getSimpleName() + '.falloutHandlerPrep(' +
\r
594 'execution=' + execution.getId() +
\r
595 ', resultVar=' + resultVar +
\r
597 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
598 logDebug('Entered ' + method, isDebugLogEnabled)
\r
601 def prefix = execution.getVariable('prefix')
\r
602 def request = getVariable(execution, prefix+'Request')
\r
603 def requestInformation = execution.getVariable(prefix + "requestInfo")
\r
605 appcClient.shutdownclient()
\r
607 def WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
608 def errorResponseCode = workflowException.getErrorCode()
\r
609 def errorResponseMsg = workflowException.getErrorMessage()
\r
610 def encErrorResponseMsg = ""
\r
611 if (errorResponseMsg != null) {
\r
612 encErrorResponseMsg = errorResponseMsg.replace("&", "&").replace("<", "<").replace(">", ">")
\r
615 String content = """
\r
616 <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
\r
617 xmlns:reqtype="http://org.openecomp/mso/request/types/v1"
\r
618 xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1"
\r
619 xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1">
\r
620 ${requestInformation}
\r
621 <sdncadapterworkflow:WorkflowException>
\r
622 <sdncadapterworkflow:ErrorMessage>${encErrorResponseMsg}</sdncadapterworkflow:ErrorMessage>
\r
623 <sdncadapterworkflow:ErrorCode>${errorResponseCode}</sdncadapterworkflow:ErrorCode>
\r
624 </sdncadapterworkflow:WorkflowException>
\r
625 </sdncadapterworkflow:FalloutHandlerRequest>
\r
627 content = utils.formatXml(content)
\r
628 logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled)
\r
629 execution.setVariable(resultVar, content)
\r
631 logDebug('Exited ' + method, isDebugLogEnabled)
\r
632 } catch (BpmnError e) {
\r
634 } catch (Exception e) {
\r
635 logError('Caught exception in ' + method, e)
\r
636 exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error')
\r
641 * Handle Abort disposition from RainyDayHandler
\r
643 * @param execution The flow's execution instance.
\r
645 public void abortProcessing(Execution execution) {
\r
646 def method = getClass().getSimpleName() + '.abortProcessing(' +
\r
647 'execution=' + execution.getId() +
\r
649 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
650 logDebug('Entered ' + method, isDebugLogEnabled)
\r
652 def errorText = execution.getVariable(prefix + "errorText")
\r
653 def errorCode = execution.getVariable(prefix + "errorCode")
\r
655 exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText)
\r
659 * Handle Manual disposition from RainyDayHandler
\r
661 * @param execution The flow's execution instance.
\r
663 public void manualProcessing(Execution execution) {
\r
664 def method = getClass().getSimpleName() + '.manualProcessing(' +
\r
665 'execution=' + execution.getId() +
\r
667 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
668 logDebug('Entered ' + method, isDebugLogEnabled)
\r
670 def taskId = execution.getVariable("UPDVnfI_taskId")
\r
672 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Processing halted - manual task created: " + taskId)
\r