Search in sources :

Example 1 with NetworkRollback

use of org.onap.so.openstack.beans.NetworkRollback in project so by onap.

the class NetworkAdapterObjectMapper method createNetworkRollbackRequestMapper.

/**
 * Access method to build Rollback Network Request
 *
 * @return
 * @throws UnsupportedEncodingException
 */
public RollbackNetworkRequest createNetworkRollbackRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, Map<String, String> userInput, String cloudRegionPo, CreateNetworkResponse createNetworkResponse) {
    RollbackNetworkRequest rollbackNetworkRequest = new RollbackNetworkRequest();
    rollbackNetworkRequest = setCommonRollbackRequestFields(rollbackNetworkRequest, requestContext);
    NetworkRollback networkRollback = buildNetworkRollback(l3Network, cloudRegion, cloudRegionPo, createNetworkResponse);
    rollbackNetworkRequest.setNetworkRollback(networkRollback);
    return rollbackNetworkRequest;
}
Also used : NetworkRollback(org.onap.so.openstack.beans.NetworkRollback) RollbackNetworkRequest(org.onap.so.adapters.nwrest.RollbackNetworkRequest)

Example 2 with NetworkRollback

use of org.onap.so.openstack.beans.NetworkRollback in project so by onap.

the class NetworkAdapterObjectMapperTest method createNetworkRollbackRequestMapperTest.

@Test
public void createNetworkRollbackRequestMapperTest() throws Exception {
    String cloudRegionPo = "cloudRegionPo";
    RollbackNetworkRequest expectedRollbackNetworkRequest = new RollbackNetworkRequest();
    expectedRollbackNetworkRequest.setMessageId(requestContext.getMsoRequestId());
    NetworkRollback networkRollback = new NetworkRollback();
    networkRollback.setCloudId(cloudRegionPo);
    networkRollback.setNetworkCreated(true);
    networkRollback.setNetworkId(l3Network.getNetworkId());
    networkRollback.setNetworkType(l3Network.getNetworkType());
    networkRollback.setTenantId(cloudRegion.getTenantId());
    expectedRollbackNetworkRequest.setNetworkRollback(networkRollback);
    expectedRollbackNetworkRequest.setSkipAAI(true);
    CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
    createNetworkResponse.setNetworkCreated(true);
    RollbackNetworkRequest rollbackNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRollbackRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
    assertThat(rollbackNetworkRequest, sameBeanAs(expectedRollbackNetworkRequest).ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("networkParams").ignoring("messageId"));
}
Also used : CreateNetworkResponse(org.onap.so.adapters.nwrest.CreateNetworkResponse) NetworkRollback(org.onap.so.openstack.beans.NetworkRollback) RollbackNetworkRequest(org.onap.so.adapters.nwrest.RollbackNetworkRequest) Test(org.junit.Test)

Example 3 with NetworkRollback

use of org.onap.so.openstack.beans.NetworkRollback in project so by onap.

the class NetworkAdapterClientIT method rollbackNetworkTestThrowException.

@Test(expected = NetworkAdapterClientException.class)
public void rollbackNetworkTestThrowException() throws NetworkAdapterClientException, JsonProcessingException {
    RollbackNetworkRequest request = new RollbackNetworkRequest();
    NetworkRollback rollback = new NetworkRollback();
    rollback.setCloudId(TESTING_ID);
    request.setNetworkRollback(rollback);
    RollbackNetworkError mockResponse = new RollbackNetworkError();
    mockResponse.setMessage("Error in rollback network");
    wireMockServer.stubFor(delete(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID)).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
    client.rollbackNetwork(AAI_NETWORK_ID, request);
}
Also used : NetworkRollback(org.onap.so.openstack.beans.NetworkRollback) RollbackNetworkRequest(org.onap.so.adapters.nwrest.RollbackNetworkRequest) RollbackNetworkError(org.onap.so.adapters.nwrest.RollbackNetworkError) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Example 4 with NetworkRollback

use of org.onap.so.openstack.beans.NetworkRollback in project so by onap.

the class PollService method buildNetworkRollback.

private NetworkRollback buildNetworkRollback(CreateNetworkRequest req, String stackId) {
    NetworkRollback networkRollback = new NetworkRollback();
    networkRollback.setCloudId(req.getCloudSiteId());
    networkRollback.setTenantId(req.getTenantId());
    networkRollback.setMsoRequest(req.getMsoRequest());
    networkRollback.setModelCustomizationUuid(req.getModelCustomizationUuid());
    networkRollback.setNetworkStackId(stackId);
    networkRollback.setNetworkCreated(true);
    networkRollback.setNetworkType(req.getNetworkType());
    return networkRollback;
}
Also used : NetworkRollback(org.onap.so.openstack.beans.NetworkRollback)

Example 5 with NetworkRollback

use of org.onap.so.openstack.beans.NetworkRollback in project so by onap.

the class StackService method rollbackNetwork.

private void rollbackNetwork(String xmlRequest, Holder<String> canonicalStackId, MutableBoolean backout, MutableBoolean success) throws NetworkException {
    backout.setFalse();
    RollbackNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), RollbackNetworkRequest.class);
    NetworkRollback rollback = req.getNetworkRollback();
    networkAdapterImpl.rollbackNetwork(rollback);
    canonicalStackId.value = rollback.getNetworkStackId();
    success.setTrue();
}
Also used : NetworkRollback(org.onap.so.openstack.beans.NetworkRollback) RollbackNetworkRequest(org.onap.so.adapters.nwrest.RollbackNetworkRequest) StringReader(java.io.StringReader)

Aggregations

NetworkRollback (org.onap.so.openstack.beans.NetworkRollback)7 RollbackNetworkRequest (org.onap.so.adapters.nwrest.RollbackNetworkRequest)5 Test (org.junit.Test)3 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)2 StringReader (java.io.StringReader)1 CreateNetworkResponse (org.onap.so.adapters.nwrest.CreateNetworkResponse)1 RollbackNetworkError (org.onap.so.adapters.nwrest.RollbackNetworkError)1 RollbackNetworkResponse (org.onap.so.adapters.nwrest.RollbackNetworkResponse)1 ModelInfoNetwork (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)1