Search in sources :

Example 1 with RouteTargets

use of org.onap.aai.domain.yang.RouteTargets in project so by onap.

the class AAIQueryTasks method getNetworkVpnBinding.

/**
 * BPMN access method to extract VPN Binding data from AAI result and populate proper fields into
 * CreateNetworkRequest
 */
public void getNetworkVpnBinding(BuildingBlockExecution execution) {
    try {
        L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
        CreateNetworkRequest createNetworkRequest = execution.getVariable("createNetworkRequest");
        Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
        if (!networkRelationships.isPresent()) {
            throw (new Exception(ERROR_MSG));
        }
        List<AAIResourceUri> netBindingsUriList = networkRelationships.get().getRelatedUris(Types.VPN_BINDING);
        List<org.onap.so.openstack.beans.RouteTarget> routeTargets = new ArrayList<>();
        for (AAIResourceUri netBindingUri : netBindingsUriList) {
            logger.info("Get Route Targests");
            Optional<VpnBinding> oVpnBinding = aaiNetworkResources.getVpnBinding(netBindingUri);
            if (oVpnBinding.isPresent()) {
                VpnBinding vpnBinding = oVpnBinding.get();
                RouteTargets rts = vpnBinding.getRouteTargets();
                if (rts != null) {
                    List<org.onap.aai.domain.yang.RouteTarget> rtList = rts.getRouteTarget();
                    if (!rtList.isEmpty()) {
                        PropertyMap<org.onap.aai.domain.yang.RouteTarget, org.onap.so.openstack.beans.RouteTarget> personMap = new PropertyMap<org.onap.aai.domain.yang.RouteTarget, org.onap.so.openstack.beans.RouteTarget>() {

                            @Override
                            protected void configure() {
                                map().setRouteTarget(source.getGlobalRouteTarget());
                                map(source.getRouteTargetRole(), destination.getRouteTargetRole());
                            }
                        };
                        modelMapper.addMappings(personMap);
                        for (org.onap.aai.domain.yang.RouteTarget rt : rtList) {
                            org.onap.so.openstack.beans.RouteTarget openstackRtBean = modelMapper.map(rt, org.onap.so.openstack.beans.RouteTarget.class);
                            routeTargets.add(openstackRtBean);
                        }
                    }
                }
            }
        }
        // store route targets data in execution - to be used as part of
        // Network adapter input
        createNetworkRequest.getContrailNetwork().setRouteTargets(routeTargets);
        execution.setVariable("createNetworkRequest", createNetworkRequest);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ArrayList(java.util.ArrayList) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) RouteTargets(org.onap.aai.domain.yang.RouteTargets) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) VpnBinding(org.onap.aai.domain.yang.VpnBinding) PropertyMap(org.modelmapper.PropertyMap)

Example 2 with RouteTargets

use of org.onap.aai.domain.yang.RouteTargets in project so by onap.

the class AAIObjectMapper method mapRouteTargetToVpnBinding.

private void mapRouteTargetToVpnBinding(org.onap.aai.domain.yang.VpnBinding aaiVpnBinding, VpnBinding vpnBinding) {
    if (vpnBinding.getRouteTargets() != null && !vpnBinding.getRouteTargets().isEmpty()) {
        RouteTargets routeTargets = new RouteTargets();
        for (RouteTarget routeTarget : vpnBinding.getRouteTargets()) {
            routeTargets.getRouteTarget().add(mapRouteTarget(routeTarget));
        }
        aaiVpnBinding.setRouteTargets(routeTargets);
    }
}
Also used : RouteTargets(org.onap.aai.domain.yang.RouteTargets) RouteTarget(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget)

Example 3 with RouteTargets

use of org.onap.aai.domain.yang.RouteTargets in project so by onap.

the class VrfValidationTest method testAaiRouteTargetValidation.

@Test
public void testAaiRouteTargetValidation() throws VrfBondingServiceException, JsonParseException, JsonMappingException, IOException {
    L3Network l3Network = mapper.readValue(new File("src/test/resources/__files/BuildingBlocks/aaiNetworkWrapper.json"), L3Network.class);
    AAIResultWrapper networkWrapper = new AAIResultWrapper(l3Network);
    if (networkWrapper.getRelationships().isPresent()) {
        List<AAIResourceUri> vpnBindingUris = networkWrapper.getRelationships().get().getRelatedUris(Types.VPN_BINDING);
        VpnBinding vpnBinding = new VpnBinding();
        vpnBinding.setRouteTargets(new RouteTargets());
        vpnBinding.getRouteTargets().getRouteTarget().add(new RouteTarget());
        AAIResultWrapper wrapper = Mockito.mock(AAIResultWrapper.class);
        doReturn(wrapper).when(bbSetupUtils).getAAIResourceDepthOne(vpnBindingUris.get(0));
        doReturn(Optional.of(vpnBinding)).when(wrapper).asBean(VpnBinding.class);
        ExpectedException.none();
        vrfValidation.aaiRouteTargetValidation(l3Network);
    }
}
Also used : L3Network(org.onap.aai.domain.yang.L3Network) VpnBinding(org.onap.aai.domain.yang.VpnBinding) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) RouteTargets(org.onap.aai.domain.yang.RouteTargets) RouteTarget(org.onap.aai.domain.yang.RouteTarget) File(java.io.File) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 4 with RouteTargets

use of org.onap.aai.domain.yang.RouteTargets in project so by onap.

the class AAIObjectMapperTest method mapVpnBindingTest.

@Test
public void mapVpnBindingTest() {
    VpnBinding vpnBinding = new VpnBinding();
    vpnBinding.setVpnId("testVpnId");
    vpnBinding.setVpnName("testVpn");
    vpnBinding.setVpnPlatform("AVPN");
    vpnBinding.setCustomerVpnId("testCustomerVpnId");
    vpnBinding.setVpnType("testVpnType");
    vpnBinding.setVpnRegion("testVpnRegion");
    vpnBinding.setRouteDistinguisher("testRD");
    RouteTarget routeTarget = new RouteTarget();
    routeTarget.setRouteTargetRole("testRtRole");
    routeTarget.setGlobalRouteTarget("testGrt");
    vpnBinding.getRouteTargets().add(routeTarget);
    org.onap.aai.domain.yang.VpnBinding expectedVpnBinding = new org.onap.aai.domain.yang.VpnBinding();
    expectedVpnBinding.setVpnId("testVpnId");
    expectedVpnBinding.setVpnName("testVpn");
    expectedVpnBinding.setVpnPlatform("AVPN");
    expectedVpnBinding.setCustomerVpnId("testCustomerVpnId");
    expectedVpnBinding.setVpnType("testVpnType");
    expectedVpnBinding.setVpnRegion("testVpnRegion");
    expectedVpnBinding.setRouteDistinguisher("testRD");
    org.onap.aai.domain.yang.RouteTarget expectedRouteTarget = new org.onap.aai.domain.yang.RouteTarget();
    expectedRouteTarget.setRouteTargetRole("testRtRole");
    expectedRouteTarget.setGlobalRouteTarget("testGrt");
    RouteTargets expectedRouteTargets = new RouteTargets();
    expectedRouteTargets.getRouteTarget().add(expectedRouteTarget);
    expectedVpnBinding.setRouteTargets(expectedRouteTargets);
    org.onap.aai.domain.yang.VpnBinding actualVpnBinding = aaiObjectMapper.mapVpnBinding(vpnBinding);
    assertThat(actualVpnBinding, sameBeanAs(expectedVpnBinding));
}
Also used : VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding) RouteTarget(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget) RouteTargets(org.onap.aai.domain.yang.RouteTargets) Test(org.junit.Test)

Aggregations

RouteTargets (org.onap.aai.domain.yang.RouteTargets)4 Test (org.junit.Test)2 VpnBinding (org.onap.aai.domain.yang.VpnBinding)2 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)2 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)2 RouteTarget (org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 PropertyMap (org.modelmapper.PropertyMap)1 L3Network (org.onap.aai.domain.yang.L3Network)1 RouteTarget (org.onap.aai.domain.yang.RouteTarget)1 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)1 CreateNetworkRequest (org.onap.so.adapters.nwrest.CreateNetworkRequest)1 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)1 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)1 VpnBinding (org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding)1