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);
}
}
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);
}
}
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);
}
}
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));
}
Aggregations