* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.appc.client.lcm.model.Action;
+import org.onap.appc.client.lcm.model.Action
+import org.onap.logging.filter.base.ErrorCode
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.aai.*
-import org.onap.so.client.aai.entities.AAIResultWrapper
-import org.onap.so.client.aai.entities.uri.AAIUri
-import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.aaiclient.client.aai.*
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.so.logger.MessageEnum
-import org.onap.so.logger.MsoLogger
-
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
public class VnfConfigUpdate extends VnfCmBase {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfConfigUpdate.class);
+ private static final Logger logger = LoggerFactory.getLogger( VnfConfigUpdate.class)
ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtils = new JsonUtils()
+ JsonUtils jsonUtils = new JsonUtils()
def prefix = "VnfIPU_"
/**
*/
public void initProcessVariables(DelegateExecution execution) {
execution.setVariable('prefix', 'VnfCU_')
- execution.setVariable('Request', null)
- execution.setVariable('source', null)
- execution.setVariable('controllerType', null)
+ execution.setVariable('Request', null)
+ execution.setVariable('source', null)
+ execution.setVariable('controllerType', null)
execution.setVariable('UpdateVnfSuccessIndicator', false)
execution.setVariable('serviceType', null)
execution.setVariable('nfRole', null)
')'
initProcessVariables(execution)
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered {}', method)
- initProcessVariables(execution)
+ initProcessVariables(execution)
def incomingRequest = execution.getVariable('bpmnRequest')
- msoLogger.debug("Incoming Infra Request: " + incomingRequest)
+ logger.debug("Incoming Infra Request: {}", incomingRequest)
try {
def jsonSlurper = new JsonSlurper()
def jsonOutput = new JsonOutput()
Map reqMap = jsonSlurper.parseText(incomingRequest)
- msoLogger.debug(" Request is in JSON format.")
+ logger.debug(" Request is in JSON format.")
def serviceInstanceId = execution.getVariable('serviceInstanceId')
def vnfId = execution.getVariable('vnfId')
-
+
execution.setVariable('serviceInstanceId', serviceInstanceId)
- execution.setVariable('vnfId', vnfId)
+ execution.setVariable('vnfId', vnfId)
execution.setVariable('serviceType', 'Mobility')
execution.setVariable('payload', "")
execution.setVariable('actionHealthCheck', Action.HealthCheck)
- execution.setVariable('actionConfigModify', Action.ConfigModify)
-
+ execution.setVariable('actionConfigModify', Action.ConfigModify)
+
def controllerType = reqMap.requestDetails?.requestParameters?.controllerType
execution.setVariable('controllerType', controllerType)
-
- msoLogger.debug('Controller Type: ' + controllerType)
-
+
+ logger.debug('Controller Type: {}', controllerType)
+
def payload = reqMap.requestDetails?.requestParameters?.payload
execution.setVariable('payload', payload)
-
- msoLogger.debug('Processed payload: ' + payload)
-
+
+ logger.debug('Processed payload: {}', payload)
+
def requestId = execution.getVariable("mso-request-id")
execution.setVariable('requestId', requestId)
- execution.setVariable('msoRequestId', requestId)
-
+ execution.setVariable('msoRequestId', requestId)
+
def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null
execution.setVariable('requestorId', requestorId)
-
+
execution.setVariable('sdncVersion', '1702')
execution.setVariable("UpdateVnfInfraSuccessIndicator", false)
-
-
+
+
def source = reqMap.requestDetails?.requestInfo?.source
execution.setVariable("source", source)
-
+
//For Completion Handler & Fallout Handler
String requestInfo =
"""<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
<action>UPDATE</action>
<source>${MsoUtils.xmlEscape(source)}</source>
</request-info>"""
-
- execution.setVariable("requestInfo", requestInfo)
-
- msoLogger.debug('RequestInfo: ' + execution.getVariable("requestInfo"))
-
- msoLogger.trace('Exited ' + method)
+
+ execution.setVariable("requestInfo", requestInfo)
+
+ logger.debug('RequestInfo: {}', execution.getVariable("requestInfo"))
+
+ logger.trace('Exited {}', method)
}
catch(groovy.json.JsonException je) {
- msoLogger.debug(" Request is not in JSON format.")
+ logger.debug(" Request is not in JSON format.")
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format")
}
catch(Exception e) {
String restFaultMessage = e.getMessage()
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered - " + "\n" + restFaultMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} Exception Encountered - \n {} \n ", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ ErrorCode.UnknownError.getValue(), restFaultMessage, e)
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage)
- }
+ }
}
/**
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered {}', method)
try {
sendWorkflowResponse(execution, 200, synchResponse)
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited {}', method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} Caught exception in {}\n ", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ ErrorCode.UnknownError.getValue(), method, e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage())
}
- }
-
-
+ }
+
+
/**
* Check if this VNF is already in maintenance in A&AI.
*
execution.setVariable('errorCode', "0")
execution.setVariable("workStep", "checkIfVnfInMaintInAAI")
execution.setVariable("failedActivity", "AAI")
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered {}', method)
try {
AAIRestClientImpl client = new AAIRestClientImpl()
aaiValidator.setClient(client)
def vnfId = execution.getVariable("vnfId")
boolean isInMaint = aaiValidator.isVNFLocked(vnfId)
- msoLogger.debug("isInMaint result: " + isInMaint)
+ logger.debug("isInMaint result: {}", isInMaint)
execution.setVariable('isVnfInMaintenance', isInMaint)
-
+
if (isInMaint) {
execution.setVariable("errorCode", "1003")
execution.setVariable("errorText", "VNF is in maintenance in A&AI")
}
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited {}', method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} Caught exception in {}\n ", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ ErrorCode.UnknownError.getValue(), method, e)
execution.setVariable("errorCode", "1002")
execution.setVariable("errorText", e.getMessage())
//exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage())
}
}
-
-
+
+
/**
* Check if this VNF's pservers are locked in A&AI.
*
')'
execution.setVariable('errorCode', "0")
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered {}', method)
execution.setVariable("workStep", "checkIfPserversInMaintInAAI")
execution.setVariable("failedActivity", "AAI")
AAIRestClientImpl client = new AAIRestClientImpl()
AAIValidatorImpl aaiValidator = new AAIValidatorImpl()
aaiValidator.setClient(client)
- def vnfId = execution.getVariable("vnfId")
+ def vnfId = execution.getVariable("vnfId")
boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId)
- msoLogger.debug("areLocked result: " + areLocked)
+ logger.debug("areLocked result: {}", areLocked)
execution.setVariable('arePserversLocked', areLocked)
-
+
if (areLocked) {
execution.setVariable("errorCode", "1003")
execution.setVariable("errorText", "pServers are locked in A&AI")
}
-
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited {}', method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} Caught exception in {}\n ", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ ErrorCode.UnknownError.getValue(), method, e)
execution.setVariable("errorCode", "1002")
execution.setVariable("errorText", e.getMessage())
//exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfPserversInMaintInAAI(): ' + e.getMessage())
}
}
-
+
/**
* Set inMaint flag for this VNF to the specified value in A&AI.
*
')'
execution.setVariable('errorCode', "0")
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered {}', method)
if (inMaint) {
execution.setVariable("workStep", "setVnfInMaintFlagInAAI")
execution.setVariable("rollbackSetVnfInMaintenanceFlag", true)
execution.setVariable("failedActivity", "AAI")
try {
- def transactionLoggingUuid = UUID.randomUUID().toString()
AAIRestClientImpl client = new AAIRestClientImpl()
AAIUpdatorImpl aaiUpdator = new AAIUpdatorImpl()
aaiUpdator.setClient(client)
def vnfId = execution.getVariable("vnfId")
if (inMaint) {
- aaiUpdator.updateVnfToLocked(vnfId, transactionLoggingUuid)
+ aaiUpdator.updateVnfToLocked(vnfId)
execution.setVariable("rollbackSetVnfInMaintenanceFlag", true)
}
else {
- aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid)
+ aaiUpdator.updateVnfToUnLocked(vnfId)
}
-
- msoLogger.trace('Exited ' + method)
+
+ logger.trace('Exited {}', method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} Caught exception in {}\n ", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ ErrorCode.UnknownError.getValue(), method, e)
execution.setVariable("errorCode", "1002")
execution.setVariable("errorText", e.getMessage())
- //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage())
}
}
-
+
/**
* Check if VF Closed Loop Disabled in A&AI.
*
execution.setVariable('errorCode', "0")
execution.setVariable("workStep", "checkClosedLoopDisabledFlagInAAI")
execution.setVariable("failedActivity", "AAI")
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered {}', method)
try {
def transactionLoggingUuid = UUID.randomUUID().toString()
def vnfId = execution.getVariable("vnfId")
- msoLogger.debug("vnfId is: " + vnfId)
- AAIResourcesClient client = new AAIResourcesClient()
- AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ logger.debug("vnfId is: {}", vnfId)
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))
AAIResultWrapper aaiRW = client.get(genericVnfUri)
Map<String, Object> result = aaiRW.asMap()
boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false)
-
- msoLogger.debug("isClosedLoopDisabled result: " + isClosedLoopDisabled)
+
+ logger.debug("isClosedLoopDisabled result: {}", isClosedLoopDisabled)
execution.setVariable('isClosedLoopDisabled', isClosedLoopDisabled)
-
+
if (isClosedLoopDisabled) {
execution.setVariable("errorCode", "1004")
execution.setVariable("errorText", "closedLoop is disabled in A&AI")
}
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited {}', method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} Caught exception in {}\n ", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ ErrorCode.UnknownError.getValue(), method, e)
execution.setVariable("errorCode", "1002")
execution.setVariable("errorText", e.getMessage())
//exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage())
}
}
-
+
/**
* Set VF Closed Loop Disabled Flag in A&AI.
*
else {
execution.setVariable("workStep", "unsetClosedLoopDisabledFlagInAAI")
}
-
+
execution.setVariable("failedActivity", "AAI")
- msoLogger.trace('Entered ' + method)
+ logger.trace('Entered {}', method)
try {
def transactionLoggingUuid = UUID.randomUUID().toString()
def vnfId = execution.getVariable("vnfId")
- AAIResourcesClient client = new AAIResourcesClient()
- AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
-
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri genericVnfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId))
+
Map<String, Boolean> request = new HashMap<>()
request.put("is-closed-loop-disabled", setDisabled)
client.update(genericVnfUri, request)
- msoLogger.debug("set isClosedLoop to: " + setDisabled)
+ logger.debug("set isClosedLoop to: {}", setDisabled)
-
- msoLogger.trace('Exited ' + method)
+ logger.trace('Exited {}', method)
} catch (BpmnError e) {
throw e;
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ logger.error("{} {} Caught exception in {}\n ", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ ErrorCode.UnknownError.getValue(), method, e)
execution.setVariable("errorCode", "1002")
execution.setVariable("errorText", e.getMessage())
//exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage())
}
- }
+ }
+
-
/**
* Handle Abort disposition from RainyDayHandler
*
- * @param execution The flow's execution instance.
+ * @param execution The flow's execution instance.
*/
public void abortProcessing(DelegateExecution execution) {
def method = getClass().getSimpleName() + '.abortProcessing(' +
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
-
+ logger.trace('Entered {}', method)
+
def errorText = execution.getVariable("errorText")
def errorCode = execution.getVariable("errorCode")
-
+
exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText)
}
-
+
/**
* Increment Retry Count for Current Work Step
*
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
-
+ logger.trace('Entered {}', method)
+
String retryCountVariableName = execution.getVariable("workStep") + "RetryCount"
execution.setVariable("retryCountVariableName", retryCountVariableName)
-
+
def retryCountVariable = execution.getVariable(retryCountVariableName)
int retryCount = 0
-
+
if (retryCountVariable != null) {
retryCount = (int) retryCountVariable
- }
-
+ }
+
retryCount += 1
-
+
execution.setVariable(retryCountVariableName, retryCount)
-
- msoLogger.debug("value of " + retryCountVariableName + " is " + retryCount)
- msoLogger.trace('Exited ' + method)
-
-
- }
-
-
-
+
+ logger.debug("value of {} is {}", retryCountVariableName, retryCount)
+ logger.trace('Exited {}', method)
+ }
+
}