Search in sources :

Example 1 with HostRoute

use of org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute in project so by onap.

the class NetworkAdapterObjectMapperTest method buildCreateNetworkRequestFromBbobjectTest.

@Test
public void buildCreateNetworkRequestFromBbobjectTest() 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.setNetworkType(l3Network.getNetworkType());
    expectedCreateNetworkRequest.setBackout(false);
    expectedCreateNetworkRequest.setFailIfExists(false);
    expectedCreateNetworkRequest.setNetworkTechnology("CONTRAIL");
    MsoRequest msoRequest = new MsoRequest();
    msoRequest.setRequestId(requestContext.getMsoRequestId());
    msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
    expectedCreateNetworkRequest.setMsoRequest(msoRequest);
    expectedCreateNetworkRequest.setSkipAAI(true);
    HashMap<String, String> networkParams = new HashMap<String, String>();
    networkParams.put("shared", "true");
    networkParams.put("external", "false");
    networkParams.put("testUserInputKey", "testUserInputValue");
    expectedCreateNetworkRequest.setNetworkParams(networkParams);
    expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
    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.setNetworkTechnology("Contrail");
    l3Network.setIsSharedNetwork(true);
    l3Network.setIsExternalNetwork(false);
    doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
    doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
    CreateNetworkRequest createNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
    assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailRequest").ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("messageId"));
}
Also used : CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) HashMap(java.util.HashMap) MsoRequest(org.onap.so.entity.MsoRequest) ArrayList(java.util.ArrayList) HostRoute(org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) Test(org.junit.Test)

Example 2 with HostRoute

use of org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute 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 3 with HostRoute

use of org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute in project so by onap.

the class AAIObjectMapper method mapToAAISubNets.

public org.onap.aai.domain.yang.Subnets mapToAAISubNets(List<Subnet> subnetList) {
    org.onap.aai.domain.yang.Subnets subnets = null;
    if (!subnetList.isEmpty()) {
        subnets = new org.onap.aai.domain.yang.Subnets();
        org.onap.aai.domain.yang.Subnet subnet = null;
        for (Subnet subnetSource : subnetList) {
            subnet = new org.onap.aai.domain.yang.Subnet();
            subnet.setSubnetId(subnetSource.getSubnetId());
            subnet.setSubnetName(subnetSource.getSubnetName());
            subnet.setNeutronSubnetId(subnetSource.getNeutronSubnetId());
            subnet.setGatewayAddress(subnetSource.getGatewayAddress());
            subnet.setCidrMask(subnetSource.getCidrMask());
            subnet.setIpVersion(subnetSource.getIpVersion());
            subnet.setOrchestrationStatus(subnetSource.getOrchestrationStatus().toString());
            subnet.setCidrMask(subnetSource.getCidrMask());
            subnet.setDhcpEnabled(subnetSource.isDhcpEnabled());
            subnet.setDhcpStart(subnetSource.getDhcpStart());
            subnet.setDhcpEnd(subnetSource.getDhcpEnd());
            subnet.setSubnetRole(subnetSource.getSubnetRole());
            subnet.setIpAssignmentDirection(subnetSource.getIpAssignmentDirection());
            subnet.setSubnetSequence(subnetSource.getSubnetSequence());
            org.onap.aai.domain.yang.HostRoutes hostRoutes = new org.onap.aai.domain.yang.HostRoutes();
            org.onap.aai.domain.yang.HostRoute hostRoute = null;
            for (HostRoute hostRouteSource : subnetSource.getHostRoutes()) {
                hostRoute = new org.onap.aai.domain.yang.HostRoute();
                hostRoute.setHostRouteId(hostRouteSource.getHostRouteId());
                hostRoute.setRoutePrefix(hostRouteSource.getRoutePrefix());
                hostRoute.setNextHop(hostRouteSource.getNextHop());
                hostRoute.setNextHopType(hostRouteSource.getNextHopType());
                hostRoutes.getHostRoute().add(hostRoute);
            }
            subnet.setHostRoutes(hostRoutes);
            subnets.getSubnet().add(subnet);
        }
    }
    return subnets;
}
Also used : HostRoute(org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet)

Example 4 with HostRoute

use of org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute in project so by onap.

the class AAIObjectMapperTest method mapToAAISubNetsTest.

@Test
public void mapToAAISubNetsTest() throws Exception {
    List<Subnet> subnets = new ArrayList<Subnet>();
    Subnet subnet1 = new Subnet();
    subnet1.setSubnetId("57e9a1ff-d14f-4071-a828-b19ae98eb2fc");
    subnet1.setSubnetName("subnetName");
    subnet1.setGatewayAddress("192.168.52.1");
    subnet1.setNetworkStartAddress("192.168.52.0");
    subnet1.setCidrMask("24");
    subnet1.setIpVersion("4");
    subnet1.setOrchestrationStatus(OrchestrationStatus.CREATED);
    subnet1.setIpAssignmentDirection("true");
    subnet1.setDhcpEnabled(true);
    subnet1.setDhcpStart("dhcpStart");
    subnet1.setDhcpEnd("dhcpEnd");
    subnet1.setSubnetRole("subnetRole");
    subnet1.setIpAssignmentDirection("true");
    subnet1.setSubnetSequence(new Integer(3));
    List<HostRoute> hostRoutes = new ArrayList<HostRoute>();
    HostRoute hostRoute1 = new HostRoute();
    hostRoute1.setHostRouteId("string");
    hostRoute1.setRoutePrefix("192.10.16.0/24");
    hostRoute1.setNextHop("192.10.16.100/24");
    hostRoute1.setNextHopType("ip-address");
    HostRoute hostRoute2 = new HostRoute();
    hostRoute2.setHostRouteId("string");
    hostRoute2.setRoutePrefix("192.110.17.0/24");
    hostRoute2.setNextHop("192.110.17.110/24");
    hostRoute2.setNextHopType("ip-address");
    hostRoutes.add(hostRoute1);
    hostRoutes.add(hostRoute2);
    subnet1.getHostRoutes().addAll(hostRoutes);
    subnets.add(subnet1);
    subnets.add(subnet1);
    AAIObjectMapper aaiObjectMapper = new AAIObjectMapper();
    org.onap.aai.domain.yang.Subnets v12Subnets = aaiObjectMapper.mapToAAISubNets(subnets);
    assertEquals(subnets.get(0).getDhcpEnd(), v12Subnets.getSubnet().get(0).getDhcpEnd());
    assertEquals(subnets.get(0).getCidrMask(), v12Subnets.getSubnet().get(0).getCidrMask());
    String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSubnetsMapped_to_aai.json")));
    ObjectMapper omapper = new ObjectMapper();
    org.onap.aai.domain.yang.Subnets subnet = omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.Subnets.class);
    ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
    String jsonGenerated = ow.writeValueAsString(v12Subnets);
    String jsonExpected = ow.writeValueAsString(subnet);
    assertEquals(jsonExpected, jsonGenerated);
}
Also used : ArrayList(java.util.ArrayList) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) HostRoute(org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 5 with HostRoute

use of org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute in project so by onap.

the class AAIObjectMapperTest method mapNetworkTest.

@Test
public void mapNetworkTest() throws Exception {
    L3Network l3Network = new L3Network();
    ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
    modelInfoNetwork.setModelCustomizationUUID("modelCustomization_id");
    modelInfoNetwork.setModelInvariantUUID("modelInvariant_id");
    modelInfoNetwork.setModelUUID("modelCustomization_id");
    modelInfoNetwork.setNetworkType("CONTRAIL_EXTERNAL");
    modelInfoNetwork.setNetworkRole("dmz_direct");
    modelInfoNetwork.setNetworkTechnology("contrail");
    l3Network.setModelInfoNetwork(modelInfoNetwork);
    l3Network.setNetworkId("TESTING_ID");
    l3Network.setNetworkName("TESTING_NAME");
    l3Network.setIsBoundToVpn(true);
    l3Network.setServiceId("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
    l3Network.setNetworkRoleInstance(1L);
    l3Network.setOrchestrationStatus(OrchestrationStatus.CREATED);
    l3Network.setHeatStackId("heatStack_id");
    l3Network.setContrailNetworkFqdn("contrailNetwork_fqdn");
    l3Network.setWidgetModelId("widgetModel_id");
    l3Network.setWidgetModelVersion("widgetModel_version");
    l3Network.setPhysicalNetworkName("physicalNetwork_name");
    l3Network.setIsProviderNetwork(true);
    l3Network.setIsSharedNetwork(false);
    l3Network.setIsExternalNetwork(true);
    l3Network.setSelflink("self_link");
    l3Network.setOperationalStatus("operationalStatus");
    List<Subnet> subnets = new ArrayList<Subnet>();
    Subnet subnet1 = new Subnet();
    subnet1.setSubnetId("57e9a1ff-d14f-4071-a828-b19ae98eb2fc");
    subnet1.setSubnetName("subnetName");
    subnet1.setGatewayAddress("192.168.52.1");
    subnet1.setNetworkStartAddress("192.168.52.0");
    subnet1.setCidrMask("24");
    subnet1.setIpVersion("4");
    subnet1.setOrchestrationStatus(OrchestrationStatus.CREATED);
    subnet1.setIpAssignmentDirection("true");
    subnet1.setDhcpEnabled(true);
    subnet1.setDhcpStart("dhcpStart");
    subnet1.setDhcpEnd("dhcpEnd");
    subnet1.setSubnetRole("subnetRole");
    subnet1.setIpAssignmentDirection("true");
    subnet1.setSubnetSequence(new Integer(3));
    List<HostRoute> hostRoutes = new ArrayList<HostRoute>();
    HostRoute hostRoute1 = new HostRoute();
    hostRoute1.setHostRouteId("string");
    hostRoute1.setRoutePrefix("192.10.16.0/24");
    hostRoute1.setNextHop("192.10.16.100/24");
    hostRoute1.setNextHopType("ip-address");
    HostRoute hostRoute2 = new HostRoute();
    hostRoute2.setHostRouteId("string");
    hostRoute2.setRoutePrefix("192.110.17.0/24");
    hostRoute2.setNextHop("192.110.17.110/24");
    hostRoute2.setNextHopType("ip-address");
    hostRoutes.add(hostRoute1);
    hostRoutes.add(hostRoute2);
    subnet1.getHostRoutes().addAll(hostRoutes);
    subnets.add(subnet1);
    subnets.add(subnet1);
    l3Network.getSubnets().addAll(subnets);
    List<CtagAssignment> ctagAssignments = new ArrayList<CtagAssignment>();
    CtagAssignment ctagAssignment1 = new CtagAssignment();
    ctagAssignment1.setVlanIdInner(1L);
    ctagAssignments.add(ctagAssignment1);
    l3Network.getCtagAssignments().addAll(ctagAssignments);
    List<SegmentationAssignment> segmentationAssignments = new ArrayList<SegmentationAssignment>();
    SegmentationAssignment segmentationAssignment1 = new SegmentationAssignment();
    segmentationAssignment1.setSegmentationId("segmentationId1");
    SegmentationAssignment segmentationAssignment2 = new SegmentationAssignment();
    segmentationAssignment2.setSegmentationId("segmentationId2");
    segmentationAssignments.add(segmentationAssignment1);
    segmentationAssignments.add(segmentationAssignment2);
    l3Network.getSegmentationAssignments().addAll(segmentationAssignments);
    AAIObjectMapper l3NetworkMapper = new AAIObjectMapper();
    org.onap.aai.domain.yang.L3Network v12L3Network = l3NetworkMapper.mapNetwork(l3Network);
    String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiL3NetworkMapped_to_aai.json")));
    ObjectMapper omapper = new ObjectMapper();
    org.onap.aai.domain.yang.L3Network network = omapper.readValue(jsonToCompare, org.onap.aai.domain.yang.L3Network.class);
    ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
    String jsonGenerated = ow.writeValueAsString(v12L3Network);
    String jsonExpected = ow.writeValueAsString(network);
    assertEquals(jsonExpected, jsonGenerated);
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) SegmentationAssignment(org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment) ArrayList(java.util.ArrayList) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork) HostRoute(org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CtagAssignment(org.onap.so.bpmn.servicedecomposition.bbobjects.CtagAssignment) Test(org.junit.Test)

Aggregations

HostRoute (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute)5 Subnet (org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)2 CreateNetworkRequest (org.onap.so.adapters.nwrest.CreateNetworkRequest)2 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)2 MsoRequest (org.onap.so.entity.MsoRequest)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CreateNetworkResponse (org.onap.so.adapters.nwrest.CreateNetworkResponse)1 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)1 CtagAssignment (org.onap.so.bpmn.servicedecomposition.bbobjects.CtagAssignment)1 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)1 SegmentationAssignment (org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment)1 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)1 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)1 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)1 ModelInfoNetwork (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)1