use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyKey in project netvirt by opendaylight.
the class ArpMonitorStopTask method removeMipAdjacency.
private void removeMipAdjacency(String fixedip, String vpnName, String interfaceName) {
synchronized (interfaceName.intern()) {
InstanceIdentifier<VpnInterface> vpnIfId = VpnUtil.getVpnInterfaceIdentifier(interfaceName);
InstanceIdentifier<Adjacencies> path = vpnIfId.augmentation(Adjacencies.class);
Optional<Adjacencies> adjacencies = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
if (adjacencies.isPresent()) {
InstanceIdentifier<Adjacency> adid = vpnIfId.augmentation(Adjacencies.class).child(Adjacency.class, new AdjacencyKey(ipToPrefix(fixedip)));
try {
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, adid);
} catch (TransactionCommitFailedException e) {
LOG.error("Failed to delete the learned-ip-adjacency for vpn {} interface {} prefix {}", vpnName, interfaceName, ipToPrefix(fixedip), e);
return;
}
LOG.info("Successfully deleted the learned-ip-adjacency prefix {} on vpn {} for interface {}", ipToPrefix(fixedip), vpnName, interfaceName);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyKey in project netvirt by opendaylight.
the class ArpNotificationHandler method addMipAdjacency.
private void addMipAdjacency(String vpnName, String vpnInterface, IpAddress srcPrefix, String mipMacAddress, IpAddress dstPrefix) {
LOG.trace("Adding {} adjacency to VPN Interface {} ", srcPrefix, vpnInterface);
InstanceIdentifier<VpnInterface> vpnIfId = VpnUtil.getVpnInterfaceIdentifier(vpnInterface);
InstanceIdentifier<Adjacencies> path = vpnIfId.augmentation(Adjacencies.class);
synchronized (vpnInterface.intern()) {
Optional<Adjacencies> adjacencies = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
String nextHopIpAddr = null;
String nextHopMacAddress = null;
String ip = srcPrefix.getIpv4Address().getValue();
if (interfaceManager.isExternalInterface(vpnInterface)) {
String subnetId = getSubnetId(vpnName, dstPrefix.getIpv4Address().getValue());
if (subnetId == null) {
LOG.trace("Can't find corresponding subnet for src IP {}, src MAC {}, dst IP {}, in VPN {}", srcPrefix, mipMacAddress, dstPrefix, vpnName);
return;
}
ip = VpnUtil.getIpPrefix(ip);
AdjacencyBuilder newAdjBuilder = new AdjacencyBuilder().setIpAddress(ip).setKey(new AdjacencyKey(ip)).setAdjacencyType(AdjacencyType.PrimaryAdjacency).setMacAddress(mipMacAddress).setSubnetId(new Uuid(subnetId)).setPhysNetworkFunc(true);
List<Adjacency> adjacencyList = adjacencies.isPresent() ? adjacencies.get().getAdjacency() : new ArrayList<>();
adjacencyList.add(newAdjBuilder.build());
Adjacencies aug = VpnUtil.getVpnInterfaceAugmentation(adjacencyList);
Optional<VpnInterface> optionalVpnInterface = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfId);
VpnInterface newVpnIntf;
if (optionalVpnInterface.isPresent()) {
newVpnIntf = new VpnInterfaceBuilder(optionalVpnInterface.get()).addAugmentation(Adjacencies.class, aug).build();
VpnUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfId, newVpnIntf);
}
LOG.debug(" Successfully stored subnetroute Adjacency into VpnInterface {}", vpnInterface);
return;
}
if (adjacencies.isPresent()) {
List<Adjacency> adjacencyList = adjacencies.get().getAdjacency();
ip = VpnUtil.getIpPrefix(ip);
for (Adjacency adjacs : adjacencyList) {
if (adjacs.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
if (adjacs.getIpAddress().equals(ip)) {
LOG.error("The MIP {} is already present as a primary adjacency for interface {} vpn {}." + "Skipping adjacency addition.", ip, vpnInterface, vpnName);
return;
}
nextHopIpAddr = adjacs.getIpAddress();
nextHopMacAddress = adjacs.getMacAddress();
break;
}
}
if (nextHopIpAddr != null) {
String rd = VpnUtil.getVpnRd(dataBroker, vpnName);
long label = VpnUtil.getUniqueId(idManager, VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(rd != null ? rd : vpnName, ip));
if (label == 0) {
LOG.error("Unable to fetch label from Id Manager. Bailing out of adding MIP adjacency {} " + "to vpn interface {} for vpn {}", ip, vpnInterface, vpnName);
return;
}
String nextHopIp = nextHopIpAddr.split("/")[0];
AdjacencyBuilder newAdjBuilder = new AdjacencyBuilder().setIpAddress(ip).setKey(new AdjacencyKey(ip)).setNextHopIpList(Collections.singletonList(nextHopIp)).setAdjacencyType(AdjacencyType.LearntIp);
if (mipMacAddress != null && !mipMacAddress.equalsIgnoreCase(nextHopMacAddress)) {
newAdjBuilder.setMacAddress(mipMacAddress);
}
adjacencyList.add(newAdjBuilder.build());
Adjacencies aug = VpnUtil.getVpnInterfaceAugmentation(adjacencyList);
Optional<VpnInterface> optionalVpnInterface = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfId);
VpnInterface newVpnIntf;
if (optionalVpnInterface.isPresent()) {
newVpnIntf = new VpnInterfaceBuilder(optionalVpnInterface.get()).addAugmentation(Adjacencies.class, aug).build();
VpnUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfId, newVpnIntf);
}
LOG.debug(" Successfully stored subnetroute Adjacency into VpnInterface {}", vpnInterface);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyKey in project netvirt by opendaylight.
the class L3vpnOverVxlanPopulator method createOperationalAdjacency.
@Override
public Adjacency createOperationalAdjacency(L3vpnInput input) {
Adjacency nextHop = input.getNextHop();
String nextHopIp = input.getNextHopIp();
String rd = input.getRd();
String prefix = VpnUtil.getIpPrefix(nextHop.getIpAddress());
List<String> adjNextHop = nextHop.getNextHopIpList();
List<String> nextHopList = adjNextHop != null && !adjNextHop.isEmpty() ? adjNextHop : nextHopIp == null ? Collections.emptyList() : Collections.singletonList(nextHopIp);
return new AdjacencyBuilder(nextHop).setNextHopIpList(nextHopList).setIpAddress(prefix).setVrfId(rd).setKey(new AdjacencyKey(prefix)).setAdjacencyType(nextHop.getAdjacencyType()).setSubnetGatewayMacAddress(nextHop.getSubnetGatewayMacAddress()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyKey in project netvirt by opendaylight.
the class CoeUtils method createPortIpAdjacencies.
static Adjacencies createPortIpAdjacencies(Pods pod, String interfaceName, String macAddress, Boolean isRouterInterface) {
List<Adjacency> adjList = new ArrayList<>();
LOG.trace("create config adjacencies for Port: {}", interfaceName);
IpAddress ip = pod.getInterface().get(0).getIpAddress();
String ipValue = ip.getIpv4Address() != null ? ip.getIpv4Address().getValue() : ip.getIpv6Address().getValue();
String ipPrefix = ip.getIpv4Address() != null ? ipValue + "/32" : ipValue + "/128";
String hostIp = new String(pod.getHostIpAddress().getValue());
UUID subnetId = UUID.nameUUIDFromBytes(hostIp.getBytes(StandardCharsets.UTF_8));
String gatewayIP = ipValue.replaceFirst("\\d+$", "1");
Adjacency vmAdj = new AdjacencyBuilder().setKey(new AdjacencyKey(ipPrefix)).setIpAddress(ipPrefix).setMacAddress(macAddress).setAdjacencyType(Adjacency.AdjacencyType.PrimaryAdjacency).setSubnetId(new Uuid(subnetId.toString())).setSubnetGatewayIp(gatewayIP).build();
if (!adjList.contains(vmAdj)) {
adjList.add(vmAdj);
}
// }
return new AdjacenciesBuilder().setAdjacency(adjList).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyKey in project netvirt by opendaylight.
the class NeutronvpnManager method createPortIpAdjacencies.
protected Adjacencies createPortIpAdjacencies(Port port, Boolean isRouterInterface, WriteTransaction wrtConfigTxn, Subnetmap sn, VpnInterface vpnIface) {
List<Adjacency> adjList = new ArrayList<>();
if (vpnIface != null) {
adjList = vpnIface.getAugmentation(Adjacencies.class).getAdjacency();
}
String infName = port.getUuid().getValue();
LOG.trace("neutronVpnManager: create config adjacencies for Port: {}", infName);
for (FixedIps ip : port.getFixedIps()) {
String ipValue = String.valueOf(ip.getIpAddress().getValue());
String ipPrefix = ip.getIpAddress().getIpv4Address() != null ? ipValue + "/32" : ipValue + "/128";
if (sn != null && !FibHelper.doesPrefixBelongToSubnet(ipPrefix, sn.getSubnetIp(), false)) {
continue;
}
Adjacency vmAdj = new AdjacencyBuilder().setKey(new AdjacencyKey(ipPrefix)).setIpAddress(ipPrefix).setMacAddress(port.getMacAddress().getValue()).setAdjacencyType(AdjacencyType.PrimaryAdjacency).setSubnetId(ip.getSubnetId()).build();
if (!adjList.contains(vmAdj)) {
adjList.add(vmAdj);
}
Subnetmap snTemp = sn != null ? sn : neutronvpnUtils.getSubnetmap(ip.getSubnetId());
Uuid routerId = snTemp != null ? snTemp.getRouterId() : null;
Uuid vpnId = snTemp != null ? snTemp.getVpnId() : null;
if (vpnId != null) {
neutronvpnUtils.createVpnPortFixedIpToPort(vpnId.getValue(), ipValue, infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
}
if (snTemp != null && snTemp.getInternetVpnId() != null) {
neutronvpnUtils.createVpnPortFixedIpToPort(sn.getInternetVpnId().getValue(), ipValue, infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
}
if (routerId != null) {
Router rtr = neutronvpnUtils.getNeutronRouter(routerId);
if (rtr != null && rtr.getRoutes() != null) {
List<Routes> routeList = rtr.getRoutes();
// create extraroute Adjacence for each ipValue,
// because router can have IPv4 and IPv6 subnet ports, or can have
// more that one IPv4 subnet port or more than one IPv6 subnet port
List<Adjacency> erAdjList = getAdjacencyforExtraRoute(routeList, ipValue);
if (!erAdjList.isEmpty()) {
adjList.addAll(erAdjList);
}
}
}
}
return new AdjacenciesBuilder().setAdjacency(adjList).build();
}
Aggregations