Search in sources :

Example 1 with VfModuleRollback

use of org.onap.so.adapters.vnfrest.VfModuleRollback 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());
    }
}
Also used : HashMap(java.util.HashMap) VfModuleRollback(org.onap.so.adapters.vnfrest.VfModuleRollback) CreateVfModuleResponse(org.onap.so.adapters.vnfrest.CreateVfModuleResponse) StackInfo(org.onap.so.openstack.beans.StackInfo)

Example 2 with VfModuleRollback

use of org.onap.so.adapters.vnfrest.VfModuleRollback in project so by onap.

the class VnfAdapterClientIT method rollbackVfModuleTestThrowException.

@Test(expected = VnfAdapterClientException.class)
public void rollbackVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
    RollbackVfModuleRequest request = new RollbackVfModuleRequest();
    VfModuleRollback rollback = new VfModuleRollback();
    rollback.setCloudSiteId(TESTING_ID);
    request.setVfModuleRollback(rollback);
    VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
    mockResponse.setMessage("Error in rollback Vf module");
    wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
    client.rollbackVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
}
Also used : RollbackVfModuleRequest(org.onap.so.adapters.vnfrest.RollbackVfModuleRequest) VfModuleRollback(org.onap.so.adapters.vnfrest.VfModuleRollback) VfModuleExceptionResponse(org.onap.so.adapters.vnfrest.VfModuleExceptionResponse) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Example 3 with VfModuleRollback

use of org.onap.so.adapters.vnfrest.VfModuleRollback in project so by onap.

the class VnfAdapterClientIT method rollbackVfModuleTest.

@Test
public void rollbackVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
    RollbackVfModuleRequest request = new RollbackVfModuleRequest();
    VfModuleRollback rollback = new VfModuleRollback();
    rollback.setCloudSiteId(TESTING_ID);
    request.setVfModuleRollback(rollback);
    RollbackVfModuleResponse mockResponse = new RollbackVfModuleResponse();
    mockResponse.setVfModuleRolledback(true);
    wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
    RollbackVfModuleResponse response = client.rollbackVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
    assertEquals("Testing RollbackVfModule response", true, response.getVfModuleRolledback());
}
Also used : RollbackVfModuleRequest(org.onap.so.adapters.vnfrest.RollbackVfModuleRequest) VfModuleRollback(org.onap.so.adapters.vnfrest.VfModuleRollback) RollbackVfModuleResponse(org.onap.so.adapters.vnfrest.RollbackVfModuleResponse) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Aggregations

VfModuleRollback (org.onap.so.adapters.vnfrest.VfModuleRollback)3 Test (org.junit.Test)2 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)2 RollbackVfModuleRequest (org.onap.so.adapters.vnfrest.RollbackVfModuleRequest)2 HashMap (java.util.HashMap)1 CreateVfModuleResponse (org.onap.so.adapters.vnfrest.CreateVfModuleResponse)1 RollbackVfModuleResponse (org.onap.so.adapters.vnfrest.RollbackVfModuleResponse)1 VfModuleExceptionResponse (org.onap.so.adapters.vnfrest.VfModuleExceptionResponse)1 StackInfo (org.onap.so.openstack.beans.StackInfo)1