Search in sources :

Example 1 with CreateNetworkResponse

use of org.onap.so.adapters.nwrest.CreateNetworkResponse in project so by onap.

the class NetworkAdapterCreateTasks method processResponseFromOpenstack.

public void processResponseFromOpenstack(BuildingBlockExecution execution) {
    try {
        L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        CreateNetworkResponse createNetworkResponse = execution.getVariable("createNetworkResponse");
        if (createNetworkResponse != null) {
            l3Network.setHeatStackId(createNetworkResponse.getNetworkStackId());
            if (createNetworkResponse.getNetworkCreated()) {
                // setting rollback TRUE only if network was actually created (not a silent success OP)
                execution.setVariable("networkAdapterCreateRollback", true);
            }
        } else {
            throw new Exception("No response was sent back from NetworkAdapter subflow.");
        }
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) CreateNetworkResponse(org.onap.so.adapters.nwrest.CreateNetworkResponse)

Example 2 with CreateNetworkResponse

use of org.onap.so.adapters.nwrest.CreateNetworkResponse in project so by onap.

the class NetworkAdapterCreateTasks method rollbackCreateNetwork.

// TODO is this even used anywhere?
public void rollbackCreateNetwork(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        CreateNetworkResponse createNetworkResponse = execution.getVariable("createNetworkResponse");
        Map<String, String> userInput = gBBInput.getUserInput();
        String cloudRegionPo = execution.getVariable("cloudRegionPo");
        networkAdapterResources.rollbackCreateNetwork(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) CreateNetworkResponse(org.onap.so.adapters.nwrest.CreateNetworkResponse) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)

Example 3 with CreateNetworkResponse

use of org.onap.so.adapters.nwrest.CreateNetworkResponse in project so by onap.

the class NetworkAdapterImpl method postProcessNetworkAdapter.

public void postProcessNetworkAdapter(BuildingBlockExecution execution) {
    try {
        String workflowResponse = (String) execution.getVariable("WorkflowResponse");
        if (workflowResponse != null) {
            Optional<String> responseType = findResponseType(workflowResponse);
            if ("createNetworkResponse".equals(responseType.get())) {
                CreateNetworkResponse createNetworkResponse = (CreateNetworkResponse) unmarshalXml(workflowResponse, CreateNetworkResponse.class);
                execution.setVariable("createNetworkResponse", createNetworkResponse);
            } else if ("deleteNetworkResponse".equals(responseType.get())) {
                DeleteNetworkResponse deleteNetworkResponse = (DeleteNetworkResponse) unmarshalXml(workflowResponse, DeleteNetworkResponse.class);
                execution.setVariable("deleteNetworkResponse", deleteNetworkResponse);
            } else if ("updateNetworkResponse".equals(responseType.get())) {
                UpdateNetworkResponse updateNetworkResponse = (UpdateNetworkResponse) unmarshalXml(workflowResponse, UpdateNetworkResponse.class);
                execution.setVariable("updateNetworkResponse", updateNetworkResponse);
            } else {
                logger.warn("Unable to determine network response type");
            }
        }
    } catch (Exception e) {
        logger.error("Error Network Adapter post process", e);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e.getMessage(), Components.OPENSTACK);
    }
}
Also used : DeleteNetworkResponse(org.onap.so.adapters.nwrest.DeleteNetworkResponse) CreateNetworkResponse(org.onap.so.adapters.nwrest.CreateNetworkResponse) UpdateNetworkResponse(org.onap.so.adapters.nwrest.UpdateNetworkResponse) JAXBException(javax.xml.bind.JAXBException)

Example 4 with CreateNetworkResponse

use of org.onap.so.adapters.nwrest.CreateNetworkResponse in project so by onap.

the class AAIUpdateTasksTest method updateNetworkCreatedTest.

@Test
public void updateNetworkCreatedTest() throws Exception {
    CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
    createNetworkResponse.setNetworkFqdn("testNetworkFqdn");
    createNetworkResponse.setNetworkStackId("testNetworkStackId");
    HashMap<String, String> subnetMap = new HashMap<>();
    subnetMap.put("testSubnetId", "testNeutronSubnetId");
    createNetworkResponse.setSubnetMap(subnetMap);
    network.getSubnets().add(subnet);
    execution.setVariable("createNetworkResponse", createNetworkResponse);
    doNothing().when(aaiNetworkResources).updateNetwork(network);
    doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
    aaiUpdateTasks.updateNetworkCreated(execution);
    verify(aaiNetworkResources, times(1)).updateNetwork(network);
    verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet);
    assertEquals(createNetworkResponse.getNetworkFqdn(), network.getContrailNetworkFqdn());
    assertEquals(OrchestrationStatus.CREATED, network.getOrchestrationStatus());
    assertEquals(createNetworkResponse.getNetworkStackId(), network.getHeatStackId());
    assertEquals(createNetworkResponse.getNeutronNetworkId(), network.getNeutronNetworkId());
    String neutronSubnetId = createNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue();
    assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId());
}
Also used : HashMap(java.util.HashMap) CreateNetworkResponse(org.onap.so.adapters.nwrest.CreateNetworkResponse) Test(org.junit.Test)

Example 5 with CreateNetworkResponse

use of org.onap.so.adapters.nwrest.CreateNetworkResponse 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)

Aggregations

CreateNetworkResponse (org.onap.so.adapters.nwrest.CreateNetworkResponse)11 Test (org.junit.Test)6 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)4 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CreateNetworkRequest (org.onap.so.adapters.nwrest.CreateNetworkRequest)2 RollbackNetworkRequest (org.onap.so.adapters.nwrest.RollbackNetworkRequest)2 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)2 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)2 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)2 ArrayList (java.util.ArrayList)1 JAXBException (javax.xml.bind.JAXBException)1 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)1 DeleteNetworkResponse (org.onap.so.adapters.nwrest.DeleteNetworkResponse)1 RollbackNetworkResponse (org.onap.so.adapters.nwrest.RollbackNetworkResponse)1 UpdateNetworkResponse (org.onap.so.adapters.nwrest.UpdateNetworkResponse)1 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)1 HostRoute (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute)1 Subnet (org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet)1