Search in sources :

Example 11 with CreateNetworkRequest

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

the class NetworkAdapterClientIT method createNetworkTest.

@Test
public void createNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
    CreateNetworkRequest request = new CreateNetworkRequest();
    request.setCloudSiteId(TESTING_ID);
    CreateNetworkResponse mockResponse = new CreateNetworkResponse();
    mockResponse.setNetworkCreated(true);
    wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT)).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
    CreateNetworkResponse response = client.createNetwork(request);
    assertEquals("Testing CreateVfModule response", true, response.getNetworkCreated());
}
Also used : CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) CreateNetworkResponse(org.onap.so.adapters.nwrest.CreateNetworkResponse) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Example 12 with CreateNetworkRequest

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

the class NetworkAdapterResourcesTest method createNetworTest.

@Test
public void createNetworTest() throws Exception {
    String cloudRegionPo = "cloudRegionPo";
    CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
    expectedCreateNetworkRequest.setCloudSiteId(cloudRegionPo);
    expectedCreateNetworkRequest.setTenantId(cloudRegion.getTenantId());
    expectedCreateNetworkRequest.setNetworkId(l3Network.getNetworkId());
    expectedCreateNetworkRequest.setNetworkName(l3Network.getNetworkName());
    expectedCreateNetworkRequest.setBackout(false);
    expectedCreateNetworkRequest.setFailIfExists(true);
    MsoRequest msoRequest = new MsoRequest();
    msoRequest.setRequestId(requestContext.getMsoRequestId());
    msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
    expectedCreateNetworkRequest.setMsoRequest(msoRequest);
    expectedCreateNetworkRequest.setSkipAAI(true);
    Subnet openstackSubnet = new Subnet();
    HostRoute hostRoute = new HostRoute();
    hostRoute.setHostRouteId("hostRouteId");
    hostRoute.setNextHop("nextHop");
    hostRoute.setRoutePrefix("routePrefix");
    openstackSubnet.getHostRoutes().add(hostRoute);
    List<Subnet> subnetList = new ArrayList<Subnet>();
    subnetList.add(openstackSubnet);
    l3Network.getSubnets().add(openstackSubnet);
    l3Network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
    CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
    createNetworkRequest.setCloudSiteId("cloudSiteId");
    CreateNetworkResponse expectedCreateNetworkResponse = new CreateNetworkResponse();
    expectedCreateNetworkResponse.setNetworkStackId("networkStackId");
    expectedCreateNetworkResponse.setNetworkCreated(true);
    doReturn(expectedCreateNetworkResponse).when(MOCK_networkAdapterClient).createNetwork(isA(CreateNetworkRequest.class));
    doReturn(createNetworkRequest).when(MOCK_networkAdapterObjectMapper).createNetworkRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(Customer.class));
    CreateNetworkResponse actualCreateNetwrokResponse = (networkAdapterResources.createNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer)).get();
    verify(MOCK_networkAdapterClient, times(1)).createNetwork(createNetworkRequest);
    verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
    assertThat(expectedCreateNetworkResponse, Matchers.sameBeanAs(actualCreateNetwrokResponse));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) CreateNetworkResponse(org.onap.so.adapters.nwrest.CreateNetworkResponse) ArrayList(java.util.ArrayList) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) MsoRequest(org.onap.so.entity.MsoRequest) HostRoute(org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) Map(java.util.Map) Test(org.junit.Test)

Example 13 with CreateNetworkRequest

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

the class NetworkAdapterCreateTasksTest method createNetworkTest.

@Test
public void createNetworkTest() {
    String cloudRegionPo = "cloudRegionPo";
    CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
    execution.setVariable("cloudRegionPo", cloudRegionPo);
    doReturn(createNetworkRequest).when(networkAdapterObjectMapper).createNetworkRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(Customer.class));
    networkAdapterCreateTasks.createNetwork(execution);
    verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
    assertEquals(createNetworkRequest.toXmlString(), execution.getVariable("networkAdapterRequest"));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) Map(java.util.Map) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) Test(org.junit.Test)

Example 14 with CreateNetworkRequest

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

the class NetworkAdapterObjectMapper method createNetworkRequestMapper.

public CreateNetworkRequest createNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, Map<String, String> userInput, String cloudRegionPo, Customer customer) {
    CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
    // set cloudSiteId as determined for cloud region PO instead of cloudRegion.getLcpCloudRegionId()
    createNetworkRequest.setCloudSiteId(cloudRegionPo);
    createNetworkRequest.setTenantId(cloudRegion.getTenantId());
    createNetworkRequest.setNetworkId(l3Network.getNetworkId());
    createNetworkRequest.setNetworkName(l3Network.getNetworkName());
    // TODO fields not available
    createNetworkRequest.setNetworkType(l3Network.getNetworkType());
    // createNetworkRequest.setNetworkTypeVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
    ModelInfoNetwork modelInfoNetwork = l3Network.getModelInfoNetwork();
    if (modelInfoNetwork != null) {
        createNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
    }
    // build and set Subnet list
    createNetworkRequest.setSubnets(buildOpenstackSubnetList(l3Network));
    // build and set provider Vlan Network
    ProviderVlanNetwork providerVlanNetwork = buildProviderVlanNetwork(l3Network);
    createNetworkRequest.setProviderVlanNetwork(providerVlanNetwork);
    String networkTechnology = l3Network.getModelInfoNetwork().getNetworkTechnology();
    if (networkTechnology == null) {
        networkTechnology = l3Network.getNetworkTechnology();
        logger.warn("NetworkTechnology was null in CatalogDB. Using field from AAI: " + networkTechnology);
    }
    if (networkTechnology != null) {
        createNetworkRequest.setNetworkTechnology(networkTechnology.toUpperCase());
        if (createNetworkRequest.getNetworkTechnology().contains("CONTRAIL")) {
            createNetworkRequest.setContrailRequest(true);
        }
    }
    // build and set Contrail Network
    ContrailNetwork contrailNetwork = buildContrailNetwork(l3Network, customer);
    createNetworkRequest.setContrailNetwork(contrailNetwork);
    // set Network Parameters from VID request, add "shared" and "external" to this map
    createNetworkRequest.setNetworkParams(addSharedAndExternal(userInput, l3Network));
    createNetworkRequest = setFlowFlags(createNetworkRequest, orchestrationContext);
    createNetworkRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
    String messageId = getRandomUuid();
    createNetworkRequest.setMessageId(messageId);
    createNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId));
    return createNetworkRequest;
}
Also used : ContrailNetwork(org.onap.so.adapters.nwrest.ContrailNetwork) CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork) ProviderVlanNetwork(org.onap.so.adapters.nwrest.ProviderVlanNetwork)

Aggregations

CreateNetworkRequest (org.onap.so.adapters.nwrest.CreateNetworkRequest)14 Test (org.junit.Test)7 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)6 HashMap (java.util.HashMap)4 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)4 StringReader (java.io.StringReader)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)2 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)2 ContrailNetwork (org.onap.so.adapters.nwrest.ContrailNetwork)2 CreateNetworkResponse (org.onap.so.adapters.nwrest.CreateNetworkResponse)2 ProviderVlanNetwork (org.onap.so.adapters.nwrest.ProviderVlanNetwork)2 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)2 CreateVolumeGroupRequest (org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest)2 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)2 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)2 HostRoute (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute)2 Subnet (org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet)2 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)2 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)2