use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class DeleteLogicalSwitchJob method call.
@Override
public List<ListenableFuture<Void>> call() {
if (cancelled) {
LOG.info("Delete logical switch job cancelled ");
return Collections.emptyList();
}
LOG.debug("running logical switch deleted job for {} in {}", logicalSwitchName, hwvtepNodeId);
elanL2GatewayUtils.deleteElanMacsFromL2GatewayDevice(hwvtepNodeId.getValue(), logicalSwitchName);
InstanceIdentifier<LogicalSwitches> logicalSwitch = HwvtepSouthboundUtils.createLogicalSwitchesInstanceIdentifier(hwvtepNodeId, new HwvtepNodeName(logicalSwitchName));
RemoteMcastMacsKey remoteMcastMacsKey = new RemoteMcastMacsKey(new HwvtepLogicalSwitchRef(logicalSwitch), new MacAddress(ElanConstants.UNKNOWN_DMAC));
HwvtepUtils.deleteRemoteMcastMac(broker, hwvtepNodeId, remoteMcastMacsKey);
L2GatewayDevice l2GatewayDevice = new L2GatewayDevice("");
l2GatewayDevice.setHwvtepNodeId(hwvtepNodeId.getValue());
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(HwvtepUtils.deleteLogicalSwitch(broker, hwvtepNodeId, logicalSwitchName));
if (clearUcast) {
LOG.trace("Clearing the local ucast macs of device {} macs ", hwvtepNodeId.getValue());
elanL2GatewayUtils.deleteL2GwDeviceUcastLocalMacsFromElan(l2GatewayDevice, logicalSwitchName);
}
return futures;
}
use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class DhcpExternalTunnelManager method configureDhcpArpRequestResponseFlow.
public void configureDhcpArpRequestResponseFlow(BigInteger dpnId, String elanInstanceName, boolean addFlow, IpAddress tunnelIp, String dhcpIpAddress, String dhcpMacAddress) {
L2GatewayDevice device = getDeviceFromTunnelIp(tunnelIp);
if (device == null) {
LOG.error("Unable to get L2Device for tunnelIp {} and elanInstanceName {}", tunnelIp, elanInstanceName);
}
jobCoordinator.enqueueJob(getJobKey(elanInstanceName), () -> {
if (entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE, HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
String tunnelInterfaceName = getExternalTunnelInterfaceName(String.valueOf(dpnId), device.getHwvtepNodeId());
int lportTag = interfaceManager.getInterfaceInfo(tunnelInterfaceName).getInterfaceTag();
InstanceIdentifier<ElanInstance> elanIdentifier = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).build();
Optional<ElanInstance> optElan = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, elanIdentifier);
if (optElan.isPresent()) {
LOG.trace("Configuring the SR-IOV Arp request/response flows for LPort {} ElanTag {}.", lportTag, optElan.get().getElanTag());
Uuid nwUuid = new Uuid(elanInstanceName);
String strVni = DhcpServiceUtils.getSegmentationId(nwUuid, broker);
BigInteger vni = strVni != null ? new BigInteger(strVni) : BigInteger.ZERO;
if (!vni.equals(BigInteger.ZERO)) {
if (addFlow) {
LOG.trace("Installing the SR-IOV DHCP Arp flow for DPN {} Port Ip {}, Lport {}.", dpnId, dhcpIpAddress, lportTag);
installDhcpArpRequestFlows(dpnId, vni, dhcpIpAddress, lportTag, optElan.get().getElanTag());
installDhcpArpResponderFlows(dpnId, tunnelInterfaceName, lportTag, elanInstanceName, dhcpIpAddress, dhcpMacAddress);
} else {
LOG.trace("Uninstalling the SR-IOV DHCP Arp flows for DPN {} Port Ip {}, Lport {}.", dpnId, dhcpIpAddress, lportTag);
uninstallDhcpArpRequestFlows(dpnId, vni, dhcpIpAddress, lportTag);
uninstallDhcpArpResponderFlows(dpnId, tunnelInterfaceName, lportTag, dhcpIpAddress);
}
}
}
}
return null;
});
}
use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class L2GwUtilsCacheCli method print.
private void print(String elan, ConcurrentMap<String, L2GatewayDevice> devices) {
session.getConsole().println("Elan name : " + elan);
session.getConsole().println("No of devices in elan " + devices.keySet().size());
for (L2GatewayDevice device : devices.values()) {
session.getConsole().println("device " + device);
}
}
use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class ElanL2GwCacheUtils method getAllElanDevicesFromCache.
public static List<L2GatewayDevice> getAllElanDevicesFromCache() {
ConcurrentMap<String, ConcurrentMap<String, L2GatewayDevice>> cachedMap = (ConcurrentMap<String, ConcurrentMap<String, L2GatewayDevice>>) CacheUtil.getCache(ElanL2GwCacheUtils.L2GATEWAY_CONN_CACHE_NAME);
if (cachedMap == null || cachedMap.isEmpty()) {
return null;
}
List<L2GatewayDevice> l2GwDevices = new ArrayList<>();
for (ConcurrentMap<String, L2GatewayDevice> l2gwDevices : cachedMap.values()) {
for (L2GatewayDevice l2gwDevice : l2gwDevices.values()) {
l2GwDevices.add(l2gwDevice);
}
}
return l2GwDevices;
}
use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.
the class L2GatewayListener method removeL2Device.
private void removeL2Device(Devices l2Device, L2gateway input) {
final String l2DeviceName = l2Device.getDeviceName();
L2GatewayDevice l2GwDevice = l2GatewayCache.get(l2DeviceName);
if (l2GwDevice != null) {
// Also, do not delete device from cache if it's connected
if (L2GatewayUtils.isLastL2GatewayBeingDeleted(l2GwDevice)) {
if (l2GwDevice.isConnected()) {
l2GwDevice.removeL2GatewayId(input.getUuid());
// Delete ITM tunnels
final String hwvtepId = l2GwDevice.getHwvtepNodeId();
final Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
jobCoordinator.enqueueJob(hwvtepId, () -> {
if (entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE, HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
LOG.info("Deleting ITM Tunnels for {} connected to cluster node owner", l2DeviceName);
for (IpAddress tunnelIp : tunnelIps) {
L2GatewayUtils.deleteItmTunnels(itmRpcService, hwvtepId, l2DeviceName, tunnelIp);
}
} else {
LOG.info("ITM Tunnels are not deleted on the cluster node as this is not owner for {}", l2DeviceName);
}
return null;
});
} else {
l2GatewayCache.remove(l2DeviceName);
// Cleaning up the config DS
NodeId nodeId = new NodeId(l2GwDevice.getHwvtepNodeId());
NodeId psNodeId = HwvtepSouthboundUtils.createManagedNodeId(nodeId, l2DeviceName);
// FIXME: These should be removed
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(nodeId));
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(psNodeId));
}
} else {
l2GwDevice.removeL2GatewayId(input.getUuid());
LOG.trace("ITM tunnels are not deleted for {} as this device has other L2gateway associations", l2DeviceName);
}
} else {
LOG.error("Unable to find L2 Gateway details for {}", l2DeviceName);
}
}
Aggregations