use of org.onap.so.cloud.resource.beans.CloudInformation in project so by onap.
the class DeleteVfModuleTest method verifyExecution.
private void verifyExecution(BuildingBlockExecution buildingBlockExecution) {
CloudInformation cloudInformation = buildingBlockExecution.getVariable("cloudInformation");
assertThat(cloudInformation.getOwner()).isEqualTo(CLOUD_OWNER);
assertThat(cloudInformation.getRegionId()).isEqualTo(LCP_CLOUD_REGION_ID);
assertThat(cloudInformation.getTenantId()).isEqualTo(TENANT_ID);
assertThat(cloudInformation.getTenantName()).isEqualTo(TENANT_NAME);
assertThat(cloudInformation.getTenantContext()).isEqualTo(TENANT_CONTEXT);
assertThat(cloudInformation.getTemplateInstanceId()).isEqualTo(HEAT_STACK_ID);
assertThat(cloudInformation.getVnfId()).isEqualTo(VNF_ID);
assertThat(cloudInformation.getVnfName()).isEqualTo(VNF_NAME);
assertThat(cloudInformation.getVfModuleId()).isEqualTo(VF_MODULE_ID);
}
use of org.onap.so.cloud.resource.beans.CloudInformation in project so by onap.
the class CreateInventoryTask method executeExternalTask.
public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
mdcSetup.setupMDC(externalTask);
Map<String, Object> variables = new HashMap<>();
String externalTaskId = externalTask.getId();
CloudInformation cloudInformation = externalTask.getVariable("cloudInformation");
boolean success = true;
if (cloudInformation != null) {
Integer retryCount = externalTask.getRetries();
try {
logger.info("Executing External Task Create Inventory, Retry Number: {} \n {}", retryCount, cloudInformation.toString());
createInventory.heatbridge(cloudInformation);
} catch (Exception e) {
logger.error("Error during inventory of stack", e);
success = false;
variables.put("inventoryErrorMessage", e.getMessage());
}
mdcSetup.setElapsedTime();
if (success) {
externalTaskService.complete(externalTask);
mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString());
logger.debug("The External Task {} was successful", externalTaskId);
logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
mdcSetup.clearClientMDCs();
} else {
if (retryCount == null) {
logger.error("The External Task {} Failed, Setting Retries to Default Start Value: {}", externalTaskId, getRetrySequence().length);
externalTaskService.handleFailure(externalTask, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, getRetrySequence().length, 10000);
} else if (retryCount != null && retryCount - 1 == 0) {
externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE, AAI_INVENTORY_FAILURE, variables);
mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString());
logger.error("The External Task {} Failed, All Retries Exhausted", externalTaskId);
logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
} else {
logger.error("The External Task {} Failed, Decrementing Retries: {} , Retry Delay: ", externalTaskId, retryCount - 1, calculateRetryDelay(retryCount));
externalTaskService.handleFailure(externalTask, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, retryCount - 1, calculateRetryDelay(retryCount));
}
}
} else {
logger.error("The External Task {} Failed, No Cloud Information Provided", externalTaskId);
externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE);
}
}
use of org.onap.so.cloud.resource.beans.CloudInformation in project so by onap.
the class DeleteInventoryTask method executeExternalTask.
public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
mdcSetup.setupMDC(externalTask);
Map<String, Object> variables = new HashMap<>();
String externalTaskId = externalTask.getId();
CloudInformation cloudInformation = externalTask.getVariable("cloudInformation");
boolean success = true;
if (cloudInformation != null) {
Integer retryCount = externalTask.getRetries();
try {
deleteInventory.heatbridge(cloudInformation);
} catch (Exception e) {
logger.error("Error during inventory of stack", e);
success = false;
variables.put("inventoryErrorMessage", e.getMessage());
}
mdcSetup.setElapsedTime();
if (success) {
externalTaskService.complete(externalTask);
mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString());
logger.debug("The External Task Id: {} Successful", externalTaskId);
logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
mdcSetup.clearClientMDCs();
} else {
if (retryCount == null) {
logger.error("The External Task Id: {} Failed, Setting Retries to Default Start Value: {}", externalTaskId, getRetrySequence().length);
externalTaskService.handleFailure(externalTask, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, getRetrySequence().length, 10000);
} else if (retryCount != null && retryCount - 1 == 0) {
externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE, AAI_INVENTORY_FAILURE, variables);
mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString());
logger.error("The External Task Id: {} Failed, All Retries Exhausted", externalTaskId);
logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
} else {
logger.error("The External Task Id: {} Failed, Decrementing Retries: {} , Retry Delay: ", externalTaskId, retryCount - 1, calculateRetryDelay(retryCount));
externalTaskService.handleFailure(externalTask, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, retryCount - 1, calculateRetryDelay(retryCount));
}
logger.error("The External Task Id: {} Failed", externalTaskId);
}
} else {
logger.error("The External Task Id: {} Failed, No Cloud Information Provided", externalTaskId);
externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE);
}
}
use of org.onap.so.cloud.resource.beans.CloudInformation in project so by onap.
the class CreateVFModule method createInventoryVariable.
public void createInventoryVariable(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
CloudInformation cloudInformation = new CloudInformation();
cloudInformation.setOwner(gBBInput.getCloudRegion().getCloudOwner());
cloudInformation.setRegionId(gBBInput.getCloudRegion().getLcpCloudRegionId());
String tenantId = gBBInput.getTenant().getTenantId();
if (tenantId == null) {
tenantId = gBBInput.getCloudRegion().getTenantId();
}
cloudInformation.setTenantId(tenantId);
cloudInformation.setTenantName(gBBInput.getTenant().getTenantName());
cloudInformation.setTenantContext(gBBInput.getTenant().getTenantContext());
cloudInformation.setTemplateInstanceId(execution.getVariable("heatStackId"));
cloudInformation.setNodeType(getNodeType(gBBInput.getCloudRegion()));
cloudInformation.setVnfName(vnf.getVnfName());
cloudInformation.setVnfId(vnf.getVnfId());
cloudInformation.setVfModuleId(vfModule.getVfModuleId());
execution.setVariable("cloudInformation", cloudInformation);
} catch (Exception e) {
logger.error("Error building CloudInformation Object for NC Inventory", e);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
}
}
use of org.onap.so.cloud.resource.beans.CloudInformation in project so by onap.
the class DeleteVFModule method createInventoryVariable.
public void createInventoryVariable(BuildingBlockExecution execution) {
try {
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
CloudInformation cloudInformation = new CloudInformation();
cloudInformation.setOwner(gBBInput.getCloudRegion().getCloudOwner());
cloudInformation.setRegionId(gBBInput.getCloudRegion().getLcpCloudRegionId());
cloudInformation.setTenantId(gBBInput.getTenant().getTenantId());
cloudInformation.setTenantName(gBBInput.getTenant().getTenantName());
cloudInformation.setTenantContext(gBBInput.getTenant().getTenantContext());
cloudInformation.setTemplateInstanceId(vfModule.getHeatStackId());
cloudInformation.setVnfName(vnf.getVnfName());
cloudInformation.setVnfId(vnf.getVnfId());
cloudInformation.setVfModuleId(vfModule.getVfModuleId());
execution.setVariable("cloudInformation", cloudInformation);
} catch (Exception e) {
logger.error("Error building CloudInformation Object for NC Inventory", e);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
}
}
Aggregations