Search in sources :

Example 6 with Subnet

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

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

the class TestDataSetup method buildSubnet.

public Subnet buildSubnet() {
    Subnet subnet = new Subnet();
    subnet.setSubnetId("testSubnetId");
    subnet.setOrchestrationStatus(OrchestrationStatus.PENDING);
    subnet.setNeutronSubnetId("testNeutronSubnetId");
    return subnet;
}
Also used : Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet)

Example 8 with Subnet

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

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

the class AAIObjectMapperTest method mapSubnetTest.

@Test
public void mapSubnetTest() {
    Subnet subnet = new Subnet();
    subnet.setSubnetId("testSubnetId");
    subnet.setOrchestrationStatus(OrchestrationStatus.PENDING);
    subnet.setNeutronSubnetId("testNeutronSubnetId");
    org.onap.aai.domain.yang.Subnet expectedSubnet = new org.onap.aai.domain.yang.Subnet();
    expectedSubnet.setSubnetId("testSubnetId");
    expectedSubnet.setOrchestrationStatus("Pending");
    expectedSubnet.setNeutronSubnetId("testNeutronSubnetId");
    org.onap.aai.domain.yang.Subnet actualSubnet = aaiObjectMapper.mapSubnet(subnet);
    assertThat(actualSubnet, sameBeanAs(expectedSubnet));
}
Also used : Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) Test(org.junit.Test)

Example 10 with Subnet

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet 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)

Aggregations

Subnet (org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet)11 Test (org.junit.Test)8 HostRoute (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute)6 ArrayList (java.util.ArrayList)5 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)3 MsoRequest (org.onap.so.entity.MsoRequest)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)2 HashMap (java.util.HashMap)2 CreateNetworkRequest (org.onap.so.adapters.nwrest.CreateNetworkRequest)2 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)2 ModelInfoNetwork (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)2 Map (java.util.Map)1 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)1 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)1 ContrailNetwork (org.onap.so.adapters.nwrest.ContrailNetwork)1 CreateNetworkResponse (org.onap.so.adapters.nwrest.CreateNetworkResponse)1 ProviderVlanNetwork (org.onap.so.adapters.nwrest.ProviderVlanNetwork)1 UpdateNetworkRequest (org.onap.so.adapters.nwrest.UpdateNetworkRequest)1 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)1