aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy177
1 files changed, 91 insertions, 86 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy
index 7b2d1b78e4..ce93db522e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy
@@ -7,9 +7,9 @@
* 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
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,6 +30,10 @@ import org.onap.so.bpmn.common.scripts.VfModuleBase;
import org.onap.so.bpmn.common.scripts.VidUtils;
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
import org.onap.so.rest.APIResponse
@@ -39,10 +43,10 @@ import groovy.json.JsonSlurper
class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVfModuleVolumeInfraV1.class);
-
+
/**
* Initialize the flow's variables.
- *
+ *
* @param execution The flow's execution instance.
*/
private void initProcessVariables(DelegateExecution execution) {
@@ -62,7 +66,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
execution.setVariable('UPDVfModVol_volumeGroupTenantId', null)
execution.setVariable('UpdateVfModuleVolumeSuccessIndicator', false)
}
-
+
/**
* Perform initial processing, such as request validation, initialization of variables, etc.
@@ -72,33 +76,33 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
preProcessRequest(execution, isDebugEnabled)
}
-
+
public void preProcessRequest(DelegateExecution execution, isDebugLogEnabled) {
initProcessVariables(execution)
String jsonRequest = validateRequest(execution)
-
+
def request = ""
-
+
try {
def jsonSlurper = new JsonSlurper()
Map reqMap = jsonSlurper.parseText(jsonRequest)
-
+
def serviceInstanceId = execution.getVariable('serviceInstanceId')
def volumeGroupId = execution.getVariable('volumeGroupId')
//def vnfId = execution.getVariable('vnfId')
-
+
def vidUtils = new VidUtils(this)
request = vidUtils.createXmlVolumeRequest(reqMap, 'UPDATE_VF_MODULE_VOL', serviceInstanceId, volumeGroupId)
-
+
execution.setVariable('UPDVfModVol_Request', request)
execution.setVariable("UPDVfModVol_isVidRequest", true)
-
+
//need to get persona-model-id aka model-invariantId to use later to validate vf-module relation in AAI
-
+
def modelInvariantId = reqMap.requestDetails.modelInfo.modelInvariantUuid ?: ''
execution.setVariable('UPDVfModVol_modelInvariantId', modelInvariantId)
-
+
msoLogger.debug("modelInvariantId from request: " + modelInvariantId)
msoLogger.debug("XML request:\n" + request)
}
@@ -106,15 +110,15 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
msoLogger.debug(" Request is in XML format.")
// assume request is in XML format - proceed as usual to process XML request
}
-
+
def requestId = execution.getVariable('mso-request-id')
-
+
def requestInfo = getRequiredNodeXml(execution, request, 'request-info')
execution.setVariable('UPDVfModVol_requestInfo', requestInfo)
execution.setVariable('UPDVfModVol_requestId', requestId)
//execution.setVariable('UPDVfModVol_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
execution.setVariable('UPDVfModVol_source', getNodeTextForce(requestInfo, 'source'))
-
+
def volumeInputs = getRequiredNodeXml(execution, request, 'volume-inputs')
execution.setVariable('UPDVfModVol_volumeInputs', volumeInputs)
execution.setVariable('UPDVfModVol_volumeGroupId', getRequiredNodeText(execution, volumeInputs, 'volume-group-id'))
@@ -126,14 +130,14 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
//execution.setVariable('UPDVfModVol_modelCustomizationId', getRequiredNodeText(execution, volumeInputs, 'model-customization-id'))
setBasicDBAuthHeader(execution, isDebugLogEnabled)
-
+
def volumeParams = utils.getNodeXml(request, 'volume-params')
execution.setVariable('UPDVfModVol_volumeParams', volumeParams)
}
/**
* Prepare and send the synchronous response.
- *
+ *
* @param execution The flow's execution instance.
*/
public void sendSynchResponse(DelegateExecution execution, isDebugLogEnabled) {
@@ -150,7 +154,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
startTime = System.currentTimeMillis()
}
def volumeInputs = execution.getVariable('UPDVfModVol_volumeInputs')
-
+
String xmlSyncResponse = """
<volume-request xmlns="http://org.onap/so/infra/vnf-request/v1">
<request-info>
@@ -167,20 +171,20 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
def syncResponse = ''
def isVidRequest = execution.getVariable('UPDVfModVol_isVidRequest')
-
+
if(isVidRequest) {
def volumeGroupId = execution.getVariable('volumeGroupId')
syncResponse = """{"requestReferences":{"instanceId":"${volumeGroupId}","requestId":"${requestId}"}}""".trim()
- }
+ }
else {
syncResponse = utils.formatXml(xmlSyncResponse)
}
-
+
msoLogger.debug('Sync response: ' + syncResponse)
execution.setVariable('UPDVfModVol_syncResponseSent', true)
sendWorkflowResponse(execution, 200, syncResponse)
}
-
+
/**
* Prepare a Request for querying AAI for Volume Group information using the
* Volume Group Id and Aic Cloud Region.
@@ -192,31 +196,32 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
- String queryAAIVolumeGroupRequest = aaiEndpoint + '/' + URLEncoder.encode(aicCloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8")
-
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId)
+ def queryAAIVolumeGroupRequest = aaiUtil.createAaiUri(uri)
+
msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest)
msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest)
-
+
APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeGroupRequest)
-
+
String returnCode = response.getStatusCode()
String aaiResponseAsString = response.getResponseBodyAsString()
-
+
msoLogger.debug("AAI query volume group by id return code: " + returnCode)
msoLogger.debug("AAI query volume group by id response: " + aaiResponseAsString)
-
+
msoLogger.debug("AAI Volume Group return code: " + returnCode)
msoLogger.debug("AAI Volume Group response: " + aaiResponseAsString)
-
+
ExceptionUtil exceptionUtil = new ExceptionUtil()
-
+
if ((returnCode == '200') || (returnCode == '204')) {
-
+
execution.setVariable('UPDVfModVol_aaiVolumeGroupResponse', aaiResponseAsString)
//def heatStackId = getNodeTextForce(aaiResponseAsString, 'heat-stack-id')
//execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', heatStackId)
-
+
def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString)
if (volumeGroupTenantId == null) {
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id " + volumeGroupId
@@ -228,42 +233,42 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
def relatedVfModuleLink = getRelatedVfModuleRelatedLink(aaiResponseAsString)
msoLogger.debug("Related VF Module link: " + relatedVfModuleLink)
execution.setVariable('UPDVfModVol_relatedVfModuleLink', relatedVfModuleLink)
-
- }
+
+ }
else if (returnCode == '404') {
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group " + volumeGroupId + " not found at AAI")
- }
+ }
else {
WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
throw new BpmnError("MSOWorkflowException")
}
}
-
+
/**
* Query AAI service instance
* @param execution
* @param isDebugEnabled
*/
public void queryAAIForGenericVnf(DelegateExecution execution, isDebugEnabled) {
-
+
def vnfId = execution.getVariable('vnfId')
-
+
AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getNetworkGenericVnfEndpoint(execution)
- def String queryAAIRequest = aaiEndpoint + "/" + UriUtils.encode(vnfId, "UTF-8")
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ String queryAAIRequest = aaiUtil.createAaiUri(uri)
msoLogger.debug("AAI query generic vnf request: " + queryAAIRequest)
-
+
APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest)
-
+
String returnCode = response.getStatusCode()
String aaiResponseAsString = response.getResponseBodyAsString()
-
+
msoLogger.debug("AAI query generic vnf return code: " + returnCode)
msoLogger.debug("AAI query generic vnf response: " + aaiResponseAsString)
ExceptionUtil exceptionUtil = new ExceptionUtil()
-
+
if (returnCode=='200') {
msoLogger.debug('Generic vnf ' + vnfId + ' found in AAI.')
execution.setVariable('UPDVfModVol_AAIQueryGenericVfnResponse', aaiResponseAsString)
@@ -278,40 +283,40 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
}
}
}
-
+
/**
* Query AAI for VF Module using vf-module-id
* @param execution
* @param isDebugLogEnabled
*/
public void queryAAIForVfModule(DelegateExecution execution, isDebugLogEnabled) {
-
+
AaiUtil aaiUtil = new AaiUtil(this)
String queryAAIVfModuleRequest = execution.getVariable('UPDVfModVol_relatedVfModuleLink')
execution.setVariable('UPDVfModVol_personaModelId', '')
-
+
msoLogger.debug('Query AAI VF Module: ' + queryAAIVfModuleRequest)
msoLogger.debug('Query AAI VF Module: ' + queryAAIVfModuleRequest)
-
+
def aaiUrl = UrnPropertiesReader.getVariable("aai.endpoint", execution)
msoLogger.debug('A&AI URL: ' + aaiUrl)
-
+
def requestEndpoint = aaiUrl + queryAAIVfModuleRequest
msoLogger.debug('A&AI request endpoint: ' + requestEndpoint)
-
+
APIResponse response = aaiUtil.executeAAIGetCall(execution, requestEndpoint)
-
+
String returnCode = response.getStatusCode()
String aaiResponseAsString = response.getResponseBodyAsString()
-
+
msoLogger.debug("AAI query vf-module: " + returnCode)
msoLogger.debug("AAI query vf-module response: " + aaiResponseAsString)
-
+
msoLogger.debug("AAI query vf-module:: " + returnCode)
msoLogger.debug("AAI query vf-module response: " + aaiResponseAsString)
-
+
ExceptionUtil exceptionUtil = new ExceptionUtil()
-
+
if ((returnCode == '200') || (returnCode == '204')) {
def personaModelId = utils.getNodeText(aaiResponseAsString, 'model-invariant-id')
if(personaModelId == null) {
@@ -330,14 +335,14 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
}
}
/**
- *
+ *
*/
public String getRelatedVfModuleRelatedLink(xml) {
def list = new XmlSlurper().parseText(xml)
def vfModuleRelationship = list.'**'.find { node -> node.'related-to'.text() == 'vf-module' }
return vfModuleRelationship?.'related-link'?.text() ?: ''
}
-
+
/**
* Prepare a Request for invoking the VnfAdapterRest subflow to do
* a Volume Group update.
@@ -345,11 +350,11 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
* @param execution The flow's execution instance.
*/
public void prepVnfAdapterRest(DelegateExecution execution, isDebugLogEnabled) {
-
+
def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
def tenantId = execution.getVariable('UPDVfModVol_tenantId')
def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId')
-
+
def aaiVolumeGroupResponse = execution.getVariable('UPDVfModVol_aaiVolumeGroupResponse')
def volumeGroupHeatStackId = getNodeTextForce(aaiVolumeGroupResponse, 'heat-stack-id')
def volumeGroupName = getNodeTextForce(aaiVolumeGroupResponse, 'volume-group-name')
@@ -358,21 +363,21 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
// Check old attribute name
modelCustomizationId = getNodeTextForce(aaiVolumeGroupResponse, 'vf-module-persona-model-customization-id')
}
-
+
def vnfType = execution.getVariable('UPDVfModVol_vnfType')
def vnfVersion = execution.getVariable('UPDVfModVol_vnfVersion')
-
+
def aaiGenericVnfResponse = execution.getVariable('UPDVfModVol_AAIQueryGenericVfnResponse')
def vnfId = utils.getNodeText(aaiGenericVnfResponse, 'vnf-id')
def vnfName = utils.getNodeText(aaiGenericVnfResponse, 'vnf-name')
-
+
def volumeParamsXml = execution.getVariable('UPDVfModVol_volumeParams')
def volumeGroupParams = transformVolumeParamsToEntries(volumeParamsXml)
-
+
def requestId = execution.getVariable('UPDVfModVol_requestId')
def serviceId = execution.getVariable('UPDVfModVol_serviceId')
-
+
def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
@@ -425,7 +430,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
execution.setVariable('UPDVfModVol_vnfAdapterRestRequest', vnfAdapterRestRequest)
msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest)
}
-
+
/**
* Prepare a Request for updating the DB for this Infra request.
*
@@ -435,7 +440,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
def requestId = execution.getVariable('UPDVfModVol_requestId')
ExceptionUtil exceptionUtil = new ExceptionUtil();
-
+
String updateInfraRequest = """
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:req="http://org.onap.so/requestsdb">
@@ -455,7 +460,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
execution.setVariable('UPDVfModVol_updateInfraRequest', updateInfraRequest)
msoLogger.debug('Request for Update Infra Request:\n' + updateInfraRequest)
}
-
+
/**
* Build a "CompletionHandler" request.
* @param execution The flow's execution instance.
@@ -471,14 +476,14 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
<source>${MsoUtils.xmlEscape(source)}</source>
</request-info>
<aetgt:mso-bpel-name>BPMN VF Module Volume action: UPDATE</aetgt:mso-bpel-name>
- </aetgt:MsoCompletionRequest>
+ </aetgt:MsoCompletionRequest>
"""
content = utils.formatXml(content)
msoLogger.debug('Request for Completion Handler:\n' + content)
execution.setVariable('UPDVfModVol_CompletionHandlerRequest', content)
}
-
+
/**
* Build a "FalloutHandler" request.
@@ -487,14 +492,14 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
public void prepFalloutHandler(DelegateExecution execution, isDebugLogEnabled) {
def requestId = execution.getVariable('UPDVfModVol_requestId')
def source = execution.getVariable('UPDVfModVol_source')
-
+
String requestInfo = """
<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
<request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
<action>UPDATE</action>
<source>${MsoUtils.xmlEscape(source)}</source>
</request-info>"""
-
+
def WorkflowException workflowException = execution.getVariable("WorkflowException")
def errorResponseCode = workflowException.getErrorCode()
def errorResponseMsg = workflowException.getErrorMessage()
@@ -507,55 +512,55 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
xmlns:reqtype="http://org.onap/so/request/types/v1"
xmlns:msoservtypes="http://org.onap/so/request/types/v1"
- xmlns:structuredtypes="http://org.onap/so/structured/types/v1">
+ xmlns:structuredtypes="http://org.onap/so/structured/types/v1">
${requestInfo}
<sdncadapterworkflow:WorkflowException>
<sdncadapterworkflow:ErrorMessage>${MsoUtils.xmlEscape(encErrorResponseMsg)}</sdncadapterworkflow:ErrorMessage>
<sdncadapterworkflow:ErrorCode>${MsoUtils.xmlEscape(errorResponseCode)}</sdncadapterworkflow:ErrorCode>
- </sdncadapterworkflow:WorkflowException>
+ </sdncadapterworkflow:WorkflowException>
</sdncadapterworkflow:FalloutHandlerRequest>
"""
content = utils.formatXml(content)
msoLogger.debug('Request for Fallout Handler:\n' + content)
execution.setVariable('UPDVfModVol_FalloutHandlerRequest', content)
}
-
+
/**
* Create a WorkflowException for the error case where the Tenant Id from
* AAI did not match the Tenant Id in the incoming request.
* @param execution The flow's execution instance.
*/
public void handleTenantIdMismatch(DelegateExecution execution, isDebugLogEnabled) {
-
+
def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId')
def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
def tenantId = execution.getVariable('UPDVfModVol_tenantId')
def volumeGroupTenantId = execution.getVariable('UPDVfModVol_volumeGroupTenantId')
-
+
def String errorMessage = "TenantId " + tenantId + " in incoming request does not match Tenant Id " + volumeGroupTenantId +
- " retrieved from AAI for Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion
-
+ " retrieved from AAI for Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion
+
ExceptionUtil exceptionUtil = new ExceptionUtil()
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception");
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
}
-
+
/**
* Create a WorkflowException for the error case where the Personal Model Id from
* AAI did not match the model invariant ID in the incoming request.
* @param execution The flow's execution instance.
*/
public void handlePersonaModelIdMismatch(DelegateExecution execution, isDebugLogEnabled) {
-
+
def modelInvariantId = execution.getVariable('UPDVfModVol_modelInvariantId')
def personaModelId = execution.getVariable('UPDVfModVol_personaModelId')
-
+
def String errorMessage = "Model Invariant ID " + modelInvariantId + " in incoming request does not match persona model ID " + personaModelId +
" retrieved from AAI for Volume Group Id "
-
+
ExceptionUtil exceptionUtil = new ExceptionUtil()
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception");
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
}
-
+
}