use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes in project netvirt by opendaylight.
the class BaseVrfEntryHandler method resolveAdjacency.
@Nonnull
protected List<AdjacencyResult> resolveAdjacency(final BigInteger remoteDpnId, final long vpnId, final VrfEntry vrfEntry, String rd) {
List<RoutePaths> routePaths = vrfEntry.getRoutePaths();
FibHelper.sortIpAddress(routePaths);
List<AdjacencyResult> adjacencyList = new ArrayList<>();
List<String> prefixIpList;
LOG.trace("resolveAdjacency called with remotedDpnId {}, vpnId{}, VrfEntry {}", remoteDpnId, vpnId, vrfEntry);
try {
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.BGP) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
List<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker, fibUtil.getVpnNameFromId(vpnId), usedRds, vrfEntry.getDestPrefix());
if (vpnExtraRoutes.isEmpty()) {
Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
// We don't want to provide an adjacencyList for an extra-route-prefix.
if (prefixInfo == null) {
LOG.debug("The extra route {} in rd {} for vpn {} has been removed from all the next hops", vrfEntry.getDestPrefix(), rd, vpnId);
return adjacencyList;
}
prefixIpList = Collections.singletonList(vrfEntry.getDestPrefix());
} else {
List<String> prefixIpListLocal = new ArrayList<>();
vpnExtraRoutes.stream().forEach(route -> {
route.getNexthopIpList().stream().forEach(extraRouteIp -> {
String ipPrefix;
if (isIpv4Address(extraRouteIp)) {
ipPrefix = extraRouteIp + NwConstants.IPV4PREFIX;
} else {
ipPrefix = extraRouteIp + NwConstants.IPV6PREFIX;
}
prefixIpListLocal.add(ipPrefix);
});
});
prefixIpList = prefixIpListLocal;
}
} else {
prefixIpList = Collections.singletonList(vrfEntry.getDestPrefix());
}
for (String prefixIp : prefixIpList) {
if (routePaths == null || routePaths.isEmpty()) {
LOG.trace("Processing Destination IP {} without NextHop IP", prefixIp);
AdjacencyResult adjacencyResult = nextHopManager.getRemoteNextHopPointer(remoteDpnId, vpnId, prefixIp, null);
addAdjacencyResultToList(adjacencyList, adjacencyResult);
continue;
}
adjacencyList.addAll(routePaths.stream().map(routePath -> {
LOG.debug("NextHop IP for destination {} is {}", prefixIp, routePath.getNexthopAddress());
return nextHopManager.getRemoteNextHopPointer(remoteDpnId, vpnId, prefixIp, routePath.getNexthopAddress());
}).filter(adjacencyResult -> adjacencyResult != null && !adjacencyList.contains(adjacencyResult)).distinct().collect(toList()));
}
} catch (NullPointerException e) {
LOG.trace("", e);
}
return adjacencyList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes in project netvirt by opendaylight.
the class BaseVrfEntryHandler method addRewriteDstMacAction.
protected void addRewriteDstMacAction(long vpnId, VrfEntry vrfEntry, Prefixes prefixInfo, List<ActionInfo> actionInfos) {
if (vrfEntry.getMac() != null) {
actionInfos.add(new ActionSetFieldEthernetDestination(actionInfos.size(), new MacAddress(vrfEntry.getMac())));
return;
}
if (prefixInfo == null) {
prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
// Checking PrefixtoInterface again as it is populated later in some cases
if (prefixInfo == null) {
LOG.debug("No prefix info found for prefix {}", vrfEntry.getDestPrefix());
return;
}
}
String ipPrefix = prefixInfo.getIpAddress();
String ifName = prefixInfo.getVpnInterfaceName();
if (ifName == null) {
LOG.debug("Failed to get VPN interface for prefix {}", ipPrefix);
return;
}
String vpnName = fibUtil.getVpnNameFromId(vpnId);
if (vpnName == null) {
LOG.debug("Failed to get VPN name for vpnId {}", vpnId);
return;
}
String macAddress = fibUtil.getMacAddressFromPrefix(ifName, vpnName, ipPrefix);
if (macAddress == null) {
LOG.warn("No MAC address found for VPN interface {} prefix {}", ifName, ipPrefix);
return;
}
actionInfos.add(new ActionSetFieldEthernetDestination(actionInfos.size(), new MacAddress(macAddress)));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes in project netvirt by opendaylight.
the class NeutronvpnUtils method populateSubnetIpPrefixes.
protected void populateSubnetIpPrefixes(Port port) {
List<IpPrefixOrAddress> subnetIpPrefixes = getSubnetIpPrefixes(port);
if (subnetIpPrefixes != null) {
String portId = port.getUuid().getValue();
InstanceIdentifier<PortSubnetIpPrefixes> portSubnetIpPrefixIdentifier = NeutronvpnUtils.buildPortSubnetIpPrefixIdentifier(portId);
PortSubnetIpPrefixesBuilder subnetIpPrefixesBuilder = new PortSubnetIpPrefixesBuilder().setKey(new PortSubnetIpPrefixesKey(portId)).setPortId(portId).setSubnetIpPrefixes(subnetIpPrefixes);
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, portSubnetIpPrefixIdentifier, subnetIpPrefixesBuilder.build());
LOG.debug("Created Subnet IP Prefixes for port {}", port.getUuid().getValue());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes in project netvirt by opendaylight.
the class NeutronvpnUtils method getPrivateSubnetsToExport.
/**
* Get a list of Private Subnetmap Ids from router to export then its prefixes in Internet VPN.
* @param extNet Provider Network, which has a port attached as external network gateway to router
* @return a list of Private Subnetmap Ids of the router with external network gateway
*/
@Nonnull
public List<Uuid> getPrivateSubnetsToExport(@Nonnull Network extNet) {
List<Uuid> subList = new ArrayList<>();
Uuid extNetVpnId = getVpnForNetwork(extNet.getUuid());
if (extNetVpnId == null) {
return subList;
}
Router router = getNeutronRouter(getRouterforVpn(extNetVpnId));
ExternalGatewayInfo info = router.getExternalGatewayInfo();
if (info == null) {
LOG.error("getPrivateSubnetsToExport: can not get info about external gateway for router {}", router.getUuid().getValue());
return subList;
}
// check that router really has given provider network as its external gateway port
if (!extNet.getUuid().equals(info.getExternalNetworkId())) {
LOG.error("getPrivateSubnetsToExport: router {} is not attached to given provider network {}", router.getUuid().getValue(), extNet.getUuid().getValue());
return subList;
}
return getSubnetsforVpn(router.getUuid());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method insertNBMappings.
private void insertNBMappings(long iid, String... prefixes) {
LOG.debug("Adding Northbound mappings in VNI {} for prefixes: {}", iid, prefixes);
final InstanceIdType iiType = new InstanceIdType(iid);
for (String prefix : prefixes) {
MappingRecord record = newMappingRecord(prefix, iiType);
mapService.addMapping(MappingOrigin.Northbound, record.getEid(), null, new MappingData(record));
}
sleepForMilliseconds(100);
MappingServiceIntegrationTestUtil.printMapCacheState(mapService);
}
Aggregations