use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class HwvtepPhysicalSwitchListener method added.
@Override
protected void added(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, final PhysicalSwitchAugmentation phySwitchAdded) {
String globalNodeId = getManagedByNodeId(identifier);
final InstanceIdentifier<Node> globalNodeIid = getManagedByNodeIid(identifier);
NodeId nodeId = getNodeId(identifier);
if (TUNNEL_IP_NOT_AVAILABLE.test(phySwitchAdded)) {
LOG.error("Could not find the /tunnel ips for node {}", nodeId.getValue());
return;
}
final String psName = getPsName(identifier);
LOG.trace("Received physical switch {} added event received for node {}", psName, nodeId.getValue());
haOpClusteredListener.runAfterNodeIsConnected(globalNodeIid, (node) -> {
LOG.trace("Running job for node {} ", globalNodeIid);
if (!node.isPresent()) {
LOG.error("Global node is absent {}", globalNodeId);
return;
}
HAOpClusteredListener.addToCacheIfHAChildNode(globalNodeIid, node.get());
if (hwvtepHACache.isHAEnabledDevice(globalNodeIid)) {
LOG.trace("Ha enabled device {}", globalNodeIid);
return;
}
LOG.trace("Updating cache for node {}", globalNodeIid);
L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
if (childConnectedAfterParent.test(l2GwDevice, globalNodeIid)) {
LOG.trace("Device {} {} is already Connected by {}", psName, globalNodeId, l2GwDevice.getHwvtepNodeId());
return;
}
InstanceIdentifier<Node> existingIid = globalNodeIid;
if (l2GwDevice != null && l2GwDevice.getHwvtepNodeId() != null) {
existingIid = HwvtepHAUtil.convertToInstanceIdentifier(l2GwDevice.getHwvtepNodeId());
}
if (parentConnectedAfterChild.test(l2GwDevice, globalNodeIid) && alreadyHasL2Gwids.test(l2GwDevice)) {
LOG.error("Child node {} having l2gw configured became ha node " + " removing the l2device {} from all elan cache and provision parent node {}", existingIid, psName, globalNodeIid);
ElanL2GwCacheUtils.removeL2GatewayDeviceFromAllElanCache(l2GwDevice.getHwvtepNodeId());
}
l2GwDevice = l2GatewayCache.addOrGet(psName);
l2GwDevice.setConnected(true);
l2GwDevice.setHwvtepNodeId(globalNodeId);
List<TunnelIps> tunnelIps = phySwitchAdded.getTunnelIps();
if (tunnelIps != null) {
for (TunnelIps tunnelIp : tunnelIps) {
IpAddress tunnelIpAddr = tunnelIp.getTunnelIpsKey();
l2GwDevice.addTunnelIp(tunnelIpAddr);
}
}
handleAdd(l2GwDevice);
elanClusterUtils.runOnlyInOwnerNode("Update config tunnels IP ", () -> {
try {
updateConfigTunnelIp(identifier, phySwitchAdded);
} catch (ReadFailedException e) {
LOG.error("Failed to update tunnel ips {}", identifier);
}
});
return;
});
}
use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class HwvtepPhysicalSwitchListener method removed.
@Override
protected void removed(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchDeleted) {
NodeId nodeId = getNodeId(identifier);
String psName = phySwitchDeleted.getHwvtepNodeName().getValue();
LOG.info("Received physical switch {} removed event for node {}", psName, nodeId.getValue());
L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
if (l2GwDevice != null) {
if (!L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
l2GatewayCache.remove(psName);
LOG.debug("{} details removed from L2Gateway Cache", psName);
MDSALUtil.syncDelete(this.dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(nodeId));
} else {
LOG.debug("{} details are not removed from L2Gateway Cache as it has L2Gateway reference", psName);
}
l2GwDevice.setConnected(false);
// ElanL2GwCacheUtils.removeL2GatewayDeviceFromAllElanCache(psName);
} else {
LOG.error("Unable to find L2 Gateway details for {}", psName);
}
}
use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class L2GatewayConnectionListener method addL2DeviceToCache.
void addL2DeviceToCache(InstanceIdentifier<Node> psIid, Node globalNode, Node psNode) {
LOG.trace("Adding device to cache {}", psNode.getNodeId().getValue());
String deviceName = HwvtepHAUtil.getPsName(psIid);
L2GatewayDevice l2GwDevice = l2GatewayCache.addOrGet(deviceName);
l2GwDevice.setConnected(true);
l2GwDevice.setHwvtepNodeId(globalNode.getNodeId().getValue());
List<TunnelIps> tunnelIps = psNode.getAugmentation(PhysicalSwitchAugmentation.class) != null ? psNode.getAugmentation(PhysicalSwitchAugmentation.class).getTunnelIps() : null;
if (tunnelIps != null) {
for (TunnelIps tunnelIp : tunnelIps) {
IpAddress tunnelIpAddr = tunnelIp.getTunnelIpsKey();
l2GwDevice.addTunnelIp(tunnelIpAddr);
}
}
}
use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class LocalUcastMacListener method removed.
public void removed(final InstanceIdentifier<LocalUcastMacs> identifier, final 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);
ResourceBatchingManager.getInstance().delete(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, identifier);
String elanName = getElanName(macRemoved);
jobCoordinator.enqueueJob(elanName + HwvtepHAUtil.L2GW_JOB_KEY, () -> {
L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
if (elanL2GwDevice == null) {
LOG.warn("Could not find L2GatewayDevice for ELAN: {}, nodeID:{} from cache", elanName, hwvtepNodeId);
return null;
}
elanL2GwDevice.removeUcastLocalMac(macRemoved);
ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
elanL2GatewayUtils.unInstallL2GwUcastMacFromL2gwDevices(elanName, elanL2GwDevice, Collections.singletonList(new MacAddress(macAddress.toLowerCase(Locale.getDefault()))));
elanL2GatewayUtils.unInstallL2GwUcastMacFromElanDpns(elanInstance, elanL2GwDevice, Collections.singletonList(new MacAddress(macAddress.toLowerCase(Locale.getDefault()))));
return null;
});
}
use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class DeleteL2GwDeviceMacsFromElanJob method call.
/*
* (non-Javadoc)
*
* @see java.util.concurrent.Callable#call()
*/
@Override
public List<ListenableFuture<Void>> call() {
LOG.debug("Deleting l2gw device [{}] macs from other l2gw devices for elan [{}]", this.l2GwDevice.getHwvtepNodeId(), this.elanName);
final String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(this.elanName);
List<MacAddress> macs = new ArrayList<>();
macAddresses.forEach((mac) -> macs.add(new MacAddress(mac.getValue().toLowerCase())));
List<ListenableFuture<Void>> futures = new ArrayList<>();
ConcurrentMap<String, L2GatewayDevice> elanL2GwDevices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(this.elanName);
for (L2GatewayDevice otherDevice : elanL2GwDevices.values()) {
if (!otherDevice.getHwvtepNodeId().equals(this.l2GwDevice.getHwvtepNodeId()) && !ElanL2GatewayUtils.areMLAGDevices(this.l2GwDevice, otherDevice)) {
final String hwvtepId = otherDevice.getHwvtepNodeId();
// This delete is batched using resourcebatchingmnagaer
futures.addAll(deleteRemoteUcastMacs(new NodeId(hwvtepId), logicalSwitchName, macs));
}
}
return futures;
}
Aggregations