use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class ElanL2GatewayUtils method installL2gwDeviceMacsInDpn.
/**
* Install external device local macs in dpn.
*
* @param dpnId
* the dpn id
* @param l2gwDeviceNodeId
* the l2gw device node id
* @param elan
* the elan
* @param interfaceName
* the interface name
* @throws ElanException in case of issues creating the flow objects
*/
public void installL2gwDeviceMacsInDpn(BigInteger dpnId, NodeId l2gwDeviceNodeId, ElanInstance elan, String interfaceName) throws ElanException {
L2GatewayDevice l2gwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elan.getElanInstanceName(), l2gwDeviceNodeId.getValue());
if (l2gwDevice == null) {
LOG.debug("L2 gw device not found in elan cache for device name {}", l2gwDeviceNodeId.getValue());
return;
}
installDmacFlowsOnDpn(dpnId, l2gwDevice, elan, interfaceName);
}
use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class L2GatewayConnectionUtils method readAndCopyLocalUcastMacsToCache.
private void readAndCopyLocalUcastMacsToCache(final String elanName, final L2GatewayDevice l2GatewayDevice) {
final InstanceIdentifier<Node> nodeIid = HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(l2GatewayDevice.getHwvtepNodeId()));
jobCoordinator.enqueueJob(elanName + ":" + l2GatewayDevice.getDeviceName(), () -> {
final SettableFuture settableFuture = SettableFuture.create();
Futures.addCallback(broker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, nodeIid), new SettableFutureCallback<Optional<Node>>(settableFuture) {
@Override
public void onSuccess(@Nonnull Optional<Node> resultNode) {
LocalUcastMacListener localUcastMacListener = new LocalUcastMacListener(broker, haOpClusteredListener, elanL2GatewayUtils, jobCoordinator, elanInstanceCache);
settableFuture.set(resultNode);
Optional<Node> nodeOptional = resultNode;
if (nodeOptional.isPresent()) {
Node node = nodeOptional.get();
if (node.getAugmentation(HwvtepGlobalAugmentation.class) != null) {
List<LocalUcastMacs> localUcastMacs = node.getAugmentation(HwvtepGlobalAugmentation.class).getLocalUcastMacs();
if (localUcastMacs == null) {
return;
}
localUcastMacs.stream().filter((mac) -> {
return macBelongsToLogicalSwitch(mac, elanName);
}).forEach((mac) -> {
InstanceIdentifier<LocalUcastMacs> macIid = getMacIid(nodeIid, mac);
localUcastMacListener.added(macIid, mac);
});
}
}
}
}, MoreExecutors.directExecutor());
return Lists.newArrayList(settableFuture);
}, 5);
}
use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class L2GatewayConnectionUtils method disAssociateHwvtepsFromElan.
private void disAssociateHwvtepsFromElan(String elanName, L2gatewayConnection input) {
Integer defaultVlan = input.getSegmentId();
List<L2GatewayDevice> l2Devices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
List<Devices> l2gwDevicesToBeDeleted = new ArrayList<>();
for (L2GatewayDevice elanL2gwDevice : l2Devices) {
if (elanL2gwDevice.getL2GatewayIds().contains(input.getKey().getUuid())) {
l2gwDevicesToBeDeleted.addAll(elanL2gwDevice.getDevicesForL2gwConnectionId(input.getKey().getUuid()));
}
}
if (l2gwDevicesToBeDeleted.isEmpty()) {
// delete logical switch
Uuid l2GatewayId = input.getL2gatewayId();
L2gateway l2Gateway = L2GatewayConnectionUtils.getNeutronL2gateway(broker, l2GatewayId);
if (l2Gateway == null) {
LOG.error("Failed to find the l2gateway for the connection {}", input.getUuid());
return;
} else {
l2gwDevicesToBeDeleted.addAll(l2Gateway.getDevices());
}
}
for (Devices l2Device : l2gwDevicesToBeDeleted) {
String l2DeviceName = l2Device.getDeviceName();
L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(l2DeviceName);
String hwvtepNodeId = l2GatewayDevice.getHwvtepNodeId();
boolean isLastL2GwConnDeleted = false;
L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
if (elanL2GwDevice != null && isLastL2GwConnBeingDeleted(elanL2GwDevice)) {
// Delete L2 Gateway device from 'ElanL2GwDevice' cache
LOG.debug("Elan L2Gw Conn cache removed for id {}", hwvtepNodeId);
ElanL2GwCacheUtils.removeL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
isLastL2GwConnDeleted = true;
} else {
Uuid l2GwConnId = input.getKey().getUuid();
LOG.debug("Elan L2Gw Conn cache with id {} is being referred by other L2Gw Conns; so only " + "L2 Gw Conn {} reference is removed", hwvtepNodeId, l2GwConnId);
if (elanL2GwDevice != null) {
elanL2GwDevice.removeL2GatewayId(l2GwConnId);
} else {
isLastL2GwConnDeleted = true;
}
}
DisAssociateHwvtepFromElanJob disAssociateHwvtepToElanJob = new DisAssociateHwvtepFromElanJob(elanL2GatewayUtils, elanL2GatewayMulticastUtils, elanL2GwDevice, elanName, () -> elanInstanceCache.get(elanName).orNull(), l2Device, defaultVlan, hwvtepNodeId, isLastL2GwConnDeleted);
elanClusterUtils.runOnlyInOwnerNode(disAssociateHwvtepToElanJob.getJobKey(), "remove l2gw connection job", disAssociateHwvtepToElanJob);
}
}
use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class HwvtepLocalUcastMacListener method removed.
@Override
protected void removed(InstanceIdentifier<LocalUcastMacs> identifier, LocalUcastMacs macRemoved) {
String hwvtepNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
String macAddress = macRemoved.getMacEntryKey().getValue().toLowerCase(Locale.getDefault());
LOG.trace("LocalUcastMacs {} removed from {}", macAddress, hwvtepNodeId);
String elanName = getElanName(macRemoved);
L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
if (elanL2GwDevice == null) {
LOG.warn("Could not find L2GatewayDevice for ELAN: {}, nodeID:{} from cache", elanName, hwvtepNodeId);
return;
}
// Remove MAC from cache
elanL2GwDevice.removeUcastLocalMac(macRemoved);
elanL2GatewayUtils.unInstallL2GwUcastMacFromL2gwDevices(elanName, elanL2GwDevice, Collections.singletonList(new MacAddress(macAddress.toLowerCase(Locale.getDefault()))));
elanL2GatewayUtils.unInstallL2GwUcastMacFromElanDpns(elanInstanceCache.get(elanName).orNull(), elanL2GwDevice, Collections.singletonList(new MacAddress(macAddress.toLowerCase(Locale.getDefault()))));
}
use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class HwvtepLocalUcastMacListener method added.
@Override
public void added(InstanceIdentifier<LocalUcastMacs> identifier, LocalUcastMacs macAdded) {
String hwvtepNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
String macAddress = macAdded.getMacEntryKey().getValue().toLowerCase(Locale.getDefault());
LOG.trace("LocalUcastMacs {} added to {}", macAddress, hwvtepNodeId);
String elanName = getElanName(macAdded);
ElanInstance elan = elanInstanceCache.get(elanName).orNull();
if (elan == null) {
LOG.warn("Could not find ELAN for mac {} being added", macAddress);
return;
}
L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
if (elanL2GwDevice == null) {
LOG.warn("Could not find L2GatewayDevice for ELAN: {}, nodeID:{} from cache", elanName, hwvtepNodeId);
return;
}
// Cache MAC for furthur processing later
elanL2GwDevice.addUcastLocalMac(macAdded);
elanL2GatewayUtils.installL2GwUcastMacInElan(elan, elanL2GwDevice, macAddress.toLowerCase(Locale.getDefault()), macAdded, null);
}
Aggregations