use of org.onap.so.adapters.vnfrest.CreateVfModuleResponse in project so by onap.
the class VnfAdapterImpl method postProcessVnfAdapter.
public void postProcessVnfAdapter(BuildingBlockExecution execution) {
try {
String vnfAdapterResponse = execution.getVariable("WorkflowResponse");
if (!StringUtils.isEmpty(vnfAdapterResponse)) {
Object vnfRestResponse = unMarshal(vnfAdapterResponse);
if (vnfRestResponse instanceof CreateVfModuleResponse) {
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
String heatStackId = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleStackId();
if (!StringUtils.isEmpty(heatStackId)) {
vfModule.setHeatStackId(heatStackId);
execution.setVariable(HEAT_STACK_ID, heatStackId);
}
Map<String, String> vfModuleOutputs = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleOutputs();
if (vfModuleOutputs != null) {
processVfModuleOutputs(execution, vfModuleOutputs);
}
} else if (vnfRestResponse instanceof DeleteVfModuleResponse) {
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
Boolean vfModuleDelete = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleDeleted();
if (null != vfModuleDelete && vfModuleDelete) {
vfModule.setHeatStackId(null);
execution.setVariable(HEAT_STACK_ID, null);
Map<String, String> vfModuleOutputs = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleOutputs();
if (vfModuleOutputs != null) {
processVfModuleOutputs(execution, vfModuleOutputs);
if (execution.getVariable(OAM_MANAGEMENT_V4_ADDRESS) != null) {
genericVnf.setIpv4OamAddress("");
execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, "");
}
if (execution.getVariable(OAM_MANAGEMENT_V6_ADDRESS) != null) {
genericVnf.setManagementV6Address("");
execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, "");
}
if (execution.getVariable(CONTRAIL_SERVICE_INSTANCE_FQDN) != null) {
vfModule.setContrailServiceInstanceFqdn("");
execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, "");
}
}
}
} else if (vnfRestResponse instanceof CreateVolumeGroupResponse) {
VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
String heatStackId = ((CreateVolumeGroupResponse) vnfRestResponse).getVolumeGroupStackId();
if (!StringUtils.isEmpty(heatStackId)) {
volumeGroup.setHeatStackId(heatStackId);
execution.setVariable(HEAT_STACK_ID, heatStackId);
} else {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "HeatStackId is missing from create VolumeGroup Vnf Adapter response.");
}
} else if (vnfRestResponse instanceof DeleteVolumeGroupResponse) {
VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
Boolean volumeGroupDelete = ((DeleteVolumeGroupResponse) vnfRestResponse).getVolumeGroupDeleted();
if (null != volumeGroupDelete && volumeGroupDelete) {
volumeGroup.setHeatStackId(null);
execution.setVariable(HEAT_STACK_ID, null);
}
}
}
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.adapters.vnfrest.CreateVfModuleResponse in project so by onap.
the class VnfAdapterClientIT method createVfModuleTest.
@Test
public void createVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
CreateVfModuleRequest request = new CreateVfModuleRequest();
request.setCloudSiteId(TESTING_ID);
CreateVfModuleResponse mockResponse = new CreateVfModuleResponse();
mockResponse.setVfModuleCreated(true);
wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
CreateVfModuleResponse response = client.createVfModule(AAI_VNF_ID, request);
assertEquals("Testing CreateVfModule response", true, response.getVfModuleCreated());
}
use of org.onap.so.adapters.vnfrest.CreateVfModuleResponse in project so by onap.
the class PollService method determineCreateVfModuleStatus.
private Optional<String> determineCreateVfModuleStatus(CreateVfModuleRequest req, ExternalTask externalTask, MutableBoolean success, boolean isMulticloud) throws MsoException {
String stackId = externalTask.getVariable("stackId");
boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(req.getModelCustomizationUuid(), false);
if (pollRollbackStatus) {
logger.debug("Executing External Task Poll Service for Rollback Vf Module");
if (!isMulticloud) {
pollDeleteResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), stackId, success);
}
return Optional.empty();
} else {
logger.debug("Executing External Task Poll Service for Create Vf Module");
Map<String, String> outputs = new HashMap<String, String>();
if (!isMulticloud) {
StackInfo stack = pollCreateResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), stackId, success);
outputs = vnfAdapterImpl.copyStringOutputs(stack.getOutputs());
}
VfModuleRollback modRollback = new VfModuleRollback(buildVnfRollback(req, stackId, isMulticloud), req.getVfModuleId(), stackId, req.getMessageId());
CreateVfModuleResponse createResponse = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), stackId, Boolean.TRUE, outputs, modRollback, req.getMessageId());
return Optional.of(createResponse.toXmlString());
}
}
Aggregations