4a64ab058bb1873ebba78f266e3ca0728418fa17
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  * 
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  * ============LICENSE_END=========================================================
18  */
19
20 package org.openecomp.mso.bpmn.infrastructure.scripts
21
22 import groovy.json.JsonOutput
23 import groovy.json.JsonSlurper
24 import groovy.util.Node
25 import groovy.util.XmlParser;
26 import groovy.xml.QName
27
28 import java.io.Serializable;
29 import java.util.UUID;
30 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
31 import org.camunda.bpm.engine.delegate.BpmnError
32 import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd
33 import org.camunda.bpm.engine.delegate.DelegateExecution
34 import org.openecomp.mso.rest.APIResponse
35 import org.openecomp.mso.rest.RESTClient
36 import org.openecomp.mso.rest.RESTConfig
37 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;
38 import org.openecomp.mso.bpmn.common.scripts.VidUtils;
39 import org.openecomp.mso.bpmn.core.RollbackData
40 import org.openecomp.mso.bpmn.core.WorkflowException
41 import org.openecomp.mso.bpmn.core.json.JsonUtils
42 import org.openecomp.mso.bpmn.core.domain.ModelInfo
43 import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
44 import org.openecomp.mso.bpmn.core.domain.VnfResource
45 import org.openecomp.mso.client.aai.*
46
47 import org.openecomp.mso.client.appc.ApplicationControllerClient;
48 import org.openecomp.mso.client.appc.ApplicationControllerSupport;
49 import org.openecomp.mso.client.aai.AAIResourcesClient
50 import org.openecomp.mso.client.aai.entities.AAIResultWrapper
51 import org.openecomp.mso.client.aai.entities.uri.AAIUri
52 import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory
53 import org.onap.appc.client.lcm.model.Action;
54 import org.onap.appc.client.lcm.model.ActionIdentifiers;
55 import org.onap.appc.client.lcm.model.LockInput
56 import org.onap.appc.client.lcm.model.UnlockInput
57 import org.onap.appc.client.lcm.model.HealthCheckInput
58 import org.onap.appc.client.lcm.model.StartInput
59 import org.onap.appc.client.lcm.model.StopInput
60 import org.onap.appc.client.lcm.model.Flags
61 import org.onap.appc.client.lcm.model.Status
62
63
64
65 public class VnfInPlaceUpdate extends VnfCmBase {
66
67         ExceptionUtil exceptionUtil = new ExceptionUtil()
68         JsonUtils jsonUtils = new JsonUtils()   
69         def prefix = "VnfIPU_"
70
71         /**
72          * Initialize the flow's variables.
73          *
74          * @param execution The flow's execution instance.
75          */
76         public void initProcessVariables(DelegateExecution execution) {
77                 execution.setVariable('prefix', 'VnfIPU_')
78                 execution.setVariable('Request', null)
79                 execution.setVariable('requestInfo', null)              
80                 execution.setVariable('source', null)
81                 execution.setVariable('vnfInputs', null)        
82                 execution.setVariable('tenantId', null)         
83                 execution.setVariable('vnfParams', null)                
84                 execution.setVariable('UpdateVnfSuccessIndicator', false)
85                 execution.setVariable('serviceType', null)
86                 execution.setVariable('nfRole', null)
87                 execution.setVariable('currentActivity', 'VnfIPU')
88                 execution.setVariable('workStep', null)
89                 execution.setVariable('failedActivity', null)
90                 execution.setVariable('errorCode', "0")
91                 execution.setVariable('errorText', null)
92                 execution.setVariable('healthCheckIndex0', 0)
93                 execution.setVariable('healthCheckIndex1', 1)
94                 execution.setVariable('maxRetryCount', 3)
95                 execution.setVariable("rollbackSetClosedLoopDisabledFlag", false)
96                 execution.setVariable("rollbackVnfStop", false)
97                 execution.setVariable("rollbackVnfLock", false)
98                 execution.setVariable("rollbackQuiesceTraffic", false)
99                 execution.setVariable("rollbackSetVnfInMaintenanceFlag", false)         
100         }
101
102         /**
103          * Check for missing elements in the received request.
104          *
105          * @param execution The flow's execution instance.
106          */
107         public void preProcessRequest(DelegateExecution execution) {
108                 def method = getClass().getSimpleName() + '.preProcessRequest(' +
109                 'execution=' + execution.getId() +
110                 ')'
111                 initProcessVariables(execution)
112                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
113                 logDebug('Entered ' + method, isDebugLogEnabled)
114
115                 initProcessVariables(execution)         
116
117                 def incomingRequest = execution.getVariable('bpmnRequest')
118
119                 utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled)
120                 try {
121                         def jsonSlurper = new JsonSlurper()
122                         def jsonOutput = new JsonOutput()
123                         Map reqMap = jsonSlurper.parseText(incomingRequest)
124                         utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled)
125
126                         def serviceInstanceId = execution.getVariable('serviceInstanceId')
127                         def vnfId = execution.getVariable('vnfId')
128                         
129                         execution.setVariable('serviceInstanceId', serviceInstanceId)
130                         execution.setVariable('vnfId', vnfId)
131                         execution.setVariable("isVidRequest", "true")
132                         execution.setVariable('serviceType', 'Mobility')
133                         execution.setVariable('payload', "")
134                         execution.setVariable('actionSnapshot', Action.Snapshot)
135                         execution.setVariable('actionLock', Action.Lock)
136                         execution.setVariable('actionUnlock', Action.Unlock)                    
137                         execution.setVariable('actionUpgradePreCheck', Action.UpgradePreCheck)
138                         execution.setVariable('actionUpgradePostCheck', Action.UpgradePostCheck)
139                         execution.setVariable('actionQuiesceTraffic', Action.QuiesceTraffic)
140                         execution.setVariable('actionUpgradeBackup', Action.UpgradeBackup)
141                         execution.setVariable('actionUpgradeSoftware', Action.UpgradeSoftware)
142                         execution.setVariable('actionResumeTraffic', Action.ResumeTraffic)
143                 
144                         def payload = reqMap.requestDetails?.requestParameters?.payload
145                         execution.setVariable('payload', payload)
146                         
147                         utils.log("DEBUG", 'Processed payload: ' + payload, isDebugLogEnabled)                  
148                                         
149                                                 
150                         def requestId = execution.getVariable("mso-request-id")
151                         execution.setVariable('requestId', requestId)
152                         execution.setVariable('msoRequestId', requestId)
153                         
154                         def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null
155                         execution.setVariable('requestorId', requestorId)
156                                                                 
157                         def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration
158                         def lcpCloudRegionId    = cloudConfiguration.lcpCloudRegionId
159                         execution.setVariable('lcpCloudRegionId', lcpCloudRegionId)
160                         def tenantId = cloudConfiguration.tenantId
161                         execution.setVariable('tenantId', tenantId)                     
162
163                         execution.setVariable("UpdateVnfInfraSuccessIndicator", false)
164                                                 
165                         execution.setVariable("isDebugLogEnabled", isDebugLogEnabled)                   
166                         
167                         def source = reqMap.requestDetails?.requestInfo?.source
168                         execution.setVariable("source", source)
169                         
170                         //For Completion Handler & Fallout Handler
171                         String requestInfo =
172                         """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
173                                         <request-id>${requestId}</request-id>
174                                         <action>UPDATE</action>
175                                         <source>${source}</source>
176                                    </request-info>"""
177                         
178                         execution.setVariable("requestInfo", requestInfo)                       
179                         
180                         logDebug('RequestInfo: ' + execution.getVariable("requestInfo"), isDebugLogEnabled)             
181                         
182                         logDebug('Exited ' + method, isDebugLogEnabled)
183
184                 }
185                 catch(groovy.json.JsonException je) {
186                         utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled)
187                         exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format")
188
189                 }
190                 catch(Exception e) {
191                         String restFaultMessage = e.getMessage()
192                         utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled)
193                         exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage)
194                 }       
195         }
196
197         /**
198          * Prepare and send the sychronous response for this flow.
199          *
200          * @param execution The flow's execution instance.
201          */
202         public void sendSynchResponse(DelegateExecution execution) {
203                 def method = getClass().getSimpleName() + '.sendSynchResponse(' +
204                         'execution=' + execution.getId() +
205                         ')'
206                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
207                 logDebug('Entered ' + method, isDebugLogEnabled)
208
209
210                 try {
211                         def requestInfo = execution.getVariable('requestInfo')
212                         def requestId = execution.getVariable('requestId')
213                         def source = execution.getVariable('source')
214                         def progress = getNodeTextForce(requestInfo, 'progress')
215                         if (progress.isEmpty()) {
216                                 progress = '0'
217                         }
218                         def startTime = getNodeTextForce(requestInfo, 'start-time')
219                         if (startTime.isEmpty()) {
220                                 startTime = System.currentTimeMillis()
221                         }
222
223                         // RESTResponse (for API Handler (APIH) Reply Task)
224                         def vnfId = execution.getVariable("vnfId")
225                         String synchResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim()
226
227                         sendWorkflowResponse(execution, 200, synchResponse)
228
229                         logDebug('Exited ' + method, isDebugLogEnabled)
230                 } catch (BpmnError e) {
231                         throw e;
232                 } catch (Exception e) {
233                         logError('Caught exception in ' + method, e)
234                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage())
235                 }
236         }
237
238         
239         /**
240          * Check if this VNF is already in maintenance in A&AI.
241          *
242          *
243          * @param execution The flow's execution instance.
244          */
245         public void checkIfVnfInMaintInAAI(DelegateExecution execution) {
246                 def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' +
247                         'execution=' + execution.getId() +
248                         ')'
249                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
250                 execution.setVariable('errorCode', "0")
251                 execution.setVariable("workStep", "checkIfVnfInMaintInAAI")
252                 execution.setVariable("failedActivity", "AAI")
253                 logDebug('Entered ' + method, isDebugLogEnabled)
254
255                 try {
256                         def transactionLoggingUuid = UUID.randomUUID().toString()
257                         AAIRestClientImpl client = new AAIRestClientImpl()
258                         AAIValidatorImpl aaiValidator = new AAIValidatorImpl()
259                         aaiValidator.setClient(client)
260                         def vnfId = execution.getVariable("vnfId")
261                         boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid)
262                         logDebug("isInMaint result: " + isInMaint, isDebugLogEnabled)
263                         execution.setVariable('isVnfInMaintenance', isInMaint)
264                         
265                         if (isInMaint) {
266                                 execution.setVariable("errorCode", "1003")
267                                 execution.setVariable("errorText", "VNF is in maintenance in A&AI")
268                         }
269
270
271                         logDebug('Exited ' + method, isDebugLogEnabled)
272                 } catch (BpmnError e) {
273                         throw e;
274                 } catch (Exception e) {
275                         logError('Caught exception in ' + method, e)                    
276                         execution.setVariable("errorCode", "1002")
277                         execution.setVariable("errorText", e.getMessage())
278                         //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage())
279                 }
280         }
281         
282         
283         /**
284          * Check if this VNF's pservers are locked in A&AI.
285          *
286          *
287          * @param execution The flow's execution instance.
288          */
289         public void checkIfPserversInMaintInAAI(DelegateExecution execution) {
290                 def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' +
291                         'execution=' + execution.getId() +
292                         ')'
293                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
294                 execution.setVariable('errorCode', "0")
295                 logDebug('Entered ' + method, isDebugLogEnabled)
296                 execution.setVariable("workStep", "checkIfPserversInMaintInAAI")
297                 execution.setVariable("failedActivity", "AAI")
298
299                 try {
300                         def transactionLoggingUuid = UUID.randomUUID().toString()
301                         AAIRestClientImpl client = new AAIRestClientImpl()
302                         AAIValidatorImpl aaiValidator = new AAIValidatorImpl()
303                         aaiValidator.setClient(client)
304                         def vnfId = execution.getVariable("vnfId")                      
305                         boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid)
306                         logDebug("areLocked result: " + areLocked, isDebugLogEnabled)
307                         execution.setVariable('arePserversLocked', areLocked)
308                         
309                         if (areLocked) {
310                                 execution.setVariable("errorCode", "1003")
311                                 execution.setVariable("errorText", "pServers are locked in A&AI")
312                         }                       
313
314                         logDebug('Exited ' + method, isDebugLogEnabled)
315                 } catch (BpmnError e) {
316                         throw e;
317                 } catch (Exception e) {
318                         logError('Caught exception in ' + method, e)
319                         execution.setVariable("errorCode", "1002")
320                         execution.setVariable("errorText", e.getMessage())
321                         //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfPserversInMaintInAAI(): ' + e.getMessage())
322                 }
323         }
324         
325         /**
326          * Set inMaint flag for this VNF to the specified value in A&AI.
327          *
328          *
329          * @param execution The flow's execution instance.
330          * @param inMaint The boolean value of the flag to set
331          */
332         public void setVnfInMaintFlagInAAI(DelegateExecution execution, boolean inMaint) {
333                 def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' +
334                         'execution=' + execution.getId() +
335                         ')'
336                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
337                 execution.setVariable('errorCode', "0")
338                 logDebug('Entered ' + method, isDebugLogEnabled)
339                 if (inMaint) {
340                         execution.setVariable("workStep", "setVnfInMaintFlagInAAI")
341                 }
342                 else {
343                         execution.setVariable("workStep", "unsetVnfInMaintFlagInAAI")
344                 }
345                 execution.setVariable("failedActivity", "AAI")
346
347                 try {
348                         def transactionLoggingUuid = UUID.randomUUID().toString()
349                         AAIRestClientImpl client = new AAIRestClientImpl()
350                         AAIUpdatorImpl aaiUpdator = new AAIUpdatorImpl()
351                         aaiUpdator.setClient(client)
352                         def vnfId = execution.getVariable("vnfId")
353                         if (inMaint) {
354                                 aaiUpdator.updateVnfToLocked(vnfId, transactionLoggingUuid)
355                                 execution.setVariable("rollbackSetVnfInMaintenanceFlag", true)
356                         }
357                         else {
358                                 aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid)                           
359                         }
360                                                         
361                         logDebug('Exited ' + method, isDebugLogEnabled)
362                 } catch (BpmnError e) {
363                         throw e;
364                 } catch (Exception e) {
365                         logError('Caught exception in ' + method, e)
366                         execution.setVariable("errorCode", "1002")
367                         execution.setVariable("errorText", e.getMessage())
368                         //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage())
369                 }
370         }
371         
372         /**
373          * Check if VF Closed Loop Disabled in A&AI.
374          *
375          *
376          * @param execution The flow's execution instance.
377          */
378         public void checkIfClosedLoopDisabledInAAI(DelegateExecution execution) {
379                 def method = getClass().getSimpleName() + '.checkIfClosedLoopDisabledInAAI(' +
380                         'execution=' + execution.getId() +
381                         ')'
382                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
383                 execution.setVariable('errorCode', "0")
384                 execution.setVariable("workStep", "checkClosedLoopDisabledFlagInAAI")
385                 execution.setVariable("failedActivity", "AAI")
386                 logDebug('Entered ' + method, isDebugLogEnabled)
387
388                 try {
389                         def transactionLoggingUuid = UUID.randomUUID().toString()                       
390                         def vnfId = execution.getVariable("vnfId")
391                         logDebug("vnfId is: " + vnfId, isDebugLogEnabled)
392                         AAIResourcesClient client = new AAIResourcesClient()                    
393                         AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
394                         AAIResultWrapper aaiRW = client.get(genericVnfUri)
395                         Map<String, Object> result = aaiRW.asMap()
396                         boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false)
397                 
398                         logDebug("isClosedLoopDisabled result: " + isClosedLoopDisabled, isDebugLogEnabled)
399                         execution.setVariable('isClosedLoopDisabled', isClosedLoopDisabled)
400                         
401                         if (isClosedLoopDisabled) {
402                                 execution.setVariable("errorCode", "1004")
403                                 execution.setVariable("errorText", "closedLoop is disabled in A&AI")
404                         }
405
406                         logDebug('Exited ' + method, isDebugLogEnabled)
407                 } catch (BpmnError e) {
408                         throw e;
409                 } catch (Exception e) {
410                         logError('Caught exception in ' + method, e)
411                         execution.setVariable("errorCode", "1002")
412                         execution.setVariable("errorText", e.getMessage())              
413                 }
414         }
415         
416         /**
417          * Set VF Closed Loop Disabled Flag in A&AI.
418          *
419          *
420          * @param execution The flow's execution instance.
421          */
422         public void setClosedLoopDisabledInAAI(DelegateExecution execution, boolean setDisabled) {
423                 def method = getClass().getSimpleName() + '.setClosedLoopDisabledInAAI(' +
424                         'execution=' + execution.getId() +
425                         ')'
426                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
427                 execution.setVariable('errorCode', "0")
428                 if (setDisabled) {
429                         execution.setVariable("workStep", "setClosedLoopDisabledFlagInAAI")
430                         execution.setVariable("rollbackSetClosedLoopDisabledFlag", true)
431                 }
432                 else {
433                         execution.setVariable("workStep", "unsetClosedLoopDisabledFlagInAAI")
434                 }
435                 
436                 execution.setVariable("failedActivity", "AAI")
437                 logDebug('Entered ' + method, isDebugLogEnabled)
438
439                 try {
440                         def transactionLoggingUuid = UUID.randomUUID().toString()
441                         def vnfId = execution.getVariable("vnfId")
442                         AAIResourcesClient client = new AAIResourcesClient()                    
443                         AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
444                         
445                         Map<String, Boolean> request = new HashMap<>()
446                         request.put("is-closed-loop-disabled", setDisabled)
447                         client.update(genericVnfUri, request)
448                         logDebug("set isClosedLoop to: " + setDisabled, isDebugLogEnabled)              
449
450                         logDebug('Exited ' + method, isDebugLogEnabled)
451                 } catch (BpmnError e) {
452                         throw e;
453                 } catch (Exception e) {
454                         logError('Caught exception in ' + method, e)
455                         execution.setVariable("errorCode", "1002")
456                         execution.setVariable("errorText", e.getMessage())                      
457                 }
458         }
459         
460         
461         
462         
463         /**
464          * Call APP-C client to execute specified APP-C command for this VNF.
465          *
466          *
467          * @param execution The flow's execution instance.
468          * @param action The action to take in APP-C.
469          */
470         public void runAppcCommand(DelegateExecution execution, Action action) {
471                 def method = getClass().getSimpleName() + '.runAppcCommand(' +
472                         'execution=' + execution.getId() +
473                         ')'
474                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
475                 execution.setVariable('errorCode', "0")
476                 logDebug('Entered ' + method, isDebugLogEnabled)
477                 
478                 ApplicationControllerClient appcClient = null
479                 
480                 try {
481                         logDebug("Running APP-C action: " + action.toString(), isDebugLogEnabled)
482                         String vnfId = execution.getVariable('vnfId')
483                         String msoRequestId = execution.getVariable('requestId')
484                         execution.setVariable('msoRequestId', msoRequestId)                     
485                         execution.setVariable("failedActivity", "APP-C")
486                         
487                         appcClient = new ApplicationControllerClient()                          
488                         ApplicationControllerSupport support = new ApplicationControllerSupport()                       
489                         appcClient.appCSupport=support                  
490                         org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage", "org.onap.appc.client.lcm.model");                       
491                         Flags flags = new Flags();                      
492                         ActionIdentifiers actionIdentifiers = new ActionIdentifiers();                  
493                         actionIdentifiers.setVnfId(vnfId);
494                         Status appcStatus
495                         switch(action) {
496                                 case Action.Lock:
497                                         execution.setVariable('workStep', "LockVNF")
498                                         appcStatus = appcClient.runCommand(Action.Lock,actionIdentifiers,null,msoRequestId)                                     
499                                         break
500                                 case Action.Unlock:
501                                         execution.setVariable('workStep', "UnlockVNF")
502                                         appcStatus = appcClient.runCommand(Action.Unlock,actionIdentifiers,null,msoRequestId)                                   
503                                         break
504                                 case Action.HealthCheck:
505                                         def healthCheckIndex = execution.getVariable('healthCheckIndex')
506                                         execution.setVariable('workStep', "HealthCheckVNF" + healthCheckIndex)
507                                         execution.setVariable('healthCheckIndex', healthCheckIndex + 1)
508                                         appcStatus = appcClient.runCommand(Action.HealthCheck,actionIdentifiers,null,msoRequestId)                                      
509                                         break
510                                 case Action.Start:
511                                         execution.setVariable('workStep', "StartVNF")
512                                         appcStatus = appcClient.runCommand(Action.Start,actionIdentifiers,null,msoRequestId)                                    
513                                         break
514                                 case Action.Stop:
515                                         execution.setVariable('workStep', "StopVNF")
516                                         appcStatus = appcClient.runCommand(Action.Stop,actionIdentifiers,null,msoRequestId)                                     
517                                         break
518                                 default:
519                                         break
520                         }
521                         logDebug("Completed AppC request", isDebugLogEnabled)                   
522                         int appcCode = appcStatus.getCode()
523                         logDebug("AppC status code is: " + appcCode, isDebugLogEnabled)
524                         logDebug("AppC status message is: " + appcStatus.getMessage(), isDebugLogEnabled)
525                         if (support.getCategoryOf(appcStatus) == ApplicationControllerSupport.StatusCategory.ERROR) {
526                                 execution.setVariable("errorCode", Integer.toString(appcCode))
527                                 execution.setVariable("errorText", appcStatus.getMessage())                             
528                         }
529                                 
530                         logDebug('Exited ' + method, isDebugLogEnabled)
531                 } catch (BpmnError e) {
532                         logError('Caught exception in ' + method, e)
533                         execution.setVariable("errorCode", "1002")
534                         execution.setVariable("errorText", e.getMessage())
535                         
536                 } catch (java.lang.NoSuchMethodError e) {
537                         logError('Caught exception in ' + method, e)
538                         execution.setVariable("errorCode", "1002")
539                         execution.setVariable("errorText", e.getMessage())              
540                         
541                 } catch (Exception e) {
542                         logError('Caught exception in ' + method, e)
543                         execution.setVariable("errorCode", "1002")
544                         execution.setVariable("errorText", e.getMessage())      
545                         
546                 }
547         }
548         
549         /**
550          * Placeholder for a call to APP-C client to execute specified APP-C command for this VNF.
551          *
552          *
553          * @param execution The flow's execution instance.
554          * @param action The action to take in APP-C.
555          */
556         public void runAppcCommandPlaceholder(DelegateExecution execution, String action) {
557                 def method = getClass().getSimpleName() + '.runAppcCommandPlaceholder(' +
558                         'execution=' + execution.getId() +
559                         ')'
560                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')              
561                 execution.setVariable('errorCode', "0")
562                 logDebug('Entered ' + method, isDebugLogEnabled)                
563                 execution.setVariable("failedActivity", "APP-C")
564                 execution.setVariable("workStep", action)               
565         }
566
567
568
569         /**
570          * Handle Abort disposition from RainyDayHandler
571          *
572          * @param execution The flow's execution instance.       
573          */
574         public void abortProcessing(DelegateExecution execution) {
575                 def method = getClass().getSimpleName() + '.abortProcessing(' +
576                         'execution=' + execution.getId() +
577                         ')'
578                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
579                 logDebug('Entered ' + method, isDebugLogEnabled)
580                 
581                 def errorText = execution.getVariable("errorText")
582                 def errorCode = execution.getVariable("errorCode")
583                 
584                 exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText)
585         }       
586         
587         /**
588          * Increment Retry Count for Current Work Step
589          *
590          * @param execution The flow's execution instance.
591          */
592         public void incrementRetryCount(DelegateExecution execution) {
593                 def method = getClass().getSimpleName() + '.incrementRetryCount(' +
594                         'execution=' + execution.getId() +
595                         ')'
596                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
597                 logDebug('Entered ' + method, isDebugLogEnabled)
598                 
599                 String retryCountVariableName = execution.getVariable("workStep") + "RetryCount"
600                 execution.setVariable("retryCountVariableName", retryCountVariableName)
601                 
602                 def retryCountVariable = execution.getVariable(retryCountVariableName)
603                 int retryCount = 0
604                 
605                 if (retryCountVariable != null) {
606                         retryCount = (int) retryCountVariable
607                 }
608                 
609                 retryCount += 1
610                 
611                 execution.setVariable(retryCountVariableName, retryCount)
612                 
613                 logDebug("value of " + retryCountVariableName + " is " + retryCount, isDebugLogEnabled)
614                 logDebug('Exited ' + method, isDebugLogEnabled)
615                         
616                 
617         }
618
619         
620 }