use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.
the class ElanL2GatewayUtils method getOtherDevicesMacs.
/**
* Gets the l2 gateway devices ucast local macs as remote ucast macs.
*
* @param elanName
* the elan name
* @param l2GatewayDeviceToBeConfigured
* the l2 gateway device to be configured
* @param hwVtepNodeId
* the hw vtep node Id to be configured
* @param logicalSwitchName
* the logical switch name
* @return the l2 gateway devices macs as remote ucast macs
*/
public static List<RemoteUcastMacs> getOtherDevicesMacs(String elanName, L2GatewayDevice l2GatewayDeviceToBeConfigured, NodeId hwVtepNodeId, String logicalSwitchName) {
List<RemoteUcastMacs> lstRemoteUcastMacs = new ArrayList<>();
ConcurrentMap<String, L2GatewayDevice> elanL2GwDevicesFromCache = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanName);
if (elanL2GwDevicesFromCache != null) {
for (L2GatewayDevice otherDevice : elanL2GwDevicesFromCache.values()) {
if (l2GatewayDeviceToBeConfigured.getHwvtepNodeId().equals(otherDevice.getHwvtepNodeId())) {
continue;
}
if (!areMLAGDevices(l2GatewayDeviceToBeConfigured, otherDevice)) {
for (LocalUcastMacs localUcastMac : otherDevice.getUcastLocalMacs()) {
HwvtepPhysicalLocatorAugmentation physLocatorAug = HwvtepSouthboundUtils.createHwvtepPhysicalLocatorAugmentation(String.valueOf(otherDevice.getTunnelIp().getValue()));
RemoteUcastMacs remoteUcastMac = HwvtepSouthboundUtils.createRemoteUcastMac(hwVtepNodeId, localUcastMac.getMacEntryKey().getValue().toLowerCase(Locale.getDefault()), localUcastMac.getIpaddr(), logicalSwitchName, physLocatorAug);
lstRemoteUcastMacs.add(remoteUcastMac);
}
}
}
}
return lstRemoteUcastMacs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.
the class ElanL2GatewayUtils method deleteElanL2GwDevicesUcastLocalMacsFromDpn.
/**
* Delete elan l2 gateway devices ucast local macs from dpn.
*
* @param elanName
* the elan name
* @param dpnId
* the dpn id
*/
public void deleteElanL2GwDevicesUcastLocalMacsFromDpn(final String elanName, final BigInteger dpnId) {
ConcurrentMap<String, L2GatewayDevice> elanL2GwDevices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanName);
if (elanL2GwDevices == null || elanL2GwDevices.isEmpty()) {
LOG.trace("No L2 gateway devices in Elan [{}] cache.", elanName);
return;
}
final ElanInstance elan = elanInstanceCache.get(elanName).orNull();
if (elan == null) {
LOG.error("Could not find Elan by name: {}", elanName);
return;
}
LOG.info("Deleting Elan [{}] L2GatewayDevices UcastLocalMacs from Dpn [{}]", elanName, dpnId);
final Long elanTag = elan.getElanTag();
for (final L2GatewayDevice l2GwDevice : elanL2GwDevices.values()) {
getL2GwDeviceLocalMacsAndRunCallback(elan.getElanInstanceName(), l2GwDevice, (localMacs) -> {
for (MacAddress mac : localMacs) {
String jobKey = elanName + ":" + mac.getValue();
elanClusterUtils.runOnlyInOwnerNode(jobKey, () -> elanDmacUtils.deleteDmacFlowsToExternalMac(elanTag, dpnId, l2GwDevice.getHwvtepNodeId(), mac.getValue()));
}
return null;
});
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.
the class ElanL2GatewayUtils method deleteL2GwDeviceUcastLocalMacsFromElan.
/**
* Delete l2 gateway device ucast local macs from elan.<br>
* Deletes macs from internal ELAN nodes and also on rest of external l2
* gateway devices which are part of the ELAN.
*
* @param l2GatewayDevice
* the l2 gateway device whose ucast local macs to be deleted
* from elan
* @param elanName
* the elan name
*/
public void deleteL2GwDeviceUcastLocalMacsFromElan(L2GatewayDevice l2GatewayDevice, String elanName) {
LOG.info("Deleting L2GatewayDevice [{}] UcastLocalMacs from elan [{}]", l2GatewayDevice.getHwvtepNodeId(), elanName);
ElanInstance elan = elanInstanceCache.get(elanName).orNull();
if (elan == null) {
LOG.error("Could not find Elan by name: {}", elanName);
return;
}
Collection<MacAddress> localMacs = getL2GwDeviceLocalMacs(elanName, l2GatewayDevice);
unInstallL2GwUcastMacFromL2gwDevices(elanName, l2GatewayDevice, localMacs);
unInstallL2GwUcastMacFromElanDpns(elan, l2GatewayDevice, localMacs);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.
the class ElanL2GatewayUtils method unInstallL2GwUcastMacFromElanDpns.
/**
* Uninstall l2gw macs from other DPNs in the elan instance provided.
* @param elan - Elan Instance for which other DPNs will be scanned.
* @param l2GwDevice - l2gwDevice whose macs are required to be cleared from other devices.
* @param macAddresses - Mac address to be cleared.
*/
public void unInstallL2GwUcastMacFromElanDpns(final ElanInstance elan, final L2GatewayDevice l2GwDevice, final Collection<MacAddress> macAddresses) {
if (macAddresses == null || macAddresses.isEmpty()) {
return;
}
if (elan == null || elan.getElanInstanceName() == null) {
LOG.error("Could not delete l2gw ucast macs, Failed to find the elan for device {}", l2GwDevice.getHwvtepNodeId());
return;
}
final Collection<DpnInterfaces> elanDpns = getElanDpns(elan.getElanInstanceName());
// Retrieve all participating DPNs in this Elan. Populate this MAC in
// DMAC table. Looping through all DPNs in order to add/remove mac flows
// in their DMAC table
List<ListenableFuture<Void>> result = new ArrayList<>();
for (final MacAddress mac : macAddresses) {
elanClusterUtils.runOnlyInOwnerNode(elan.getElanInstanceName() + ":" + mac.getValue(), "delete remote ucast macs in elan DPNs", () -> {
for (DpnInterfaces elanDpn : elanDpns) {
BigInteger dpnId = elanDpn.getDpId();
result.addAll(elanDmacUtils.deleteDmacFlowsToExternalMac(elan.getElanTag(), dpnId, l2GwDevice.getHwvtepNodeId(), mac.getValue().toLowerCase(Locale.getDefault())));
}
return result;
});
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.
the class ElanL2GatewayUtils method updateVlanBindingsInL2GatewayDevice.
/**
* Update vlan bindings in l2 gateway device.
*
* @param nodeId
* the node id
* @param logicalSwitchName
* the logical switch name
* @param hwVtepDevice
* the hardware device
* @param defaultVlanId
* the default vlan id
* @return the listenable future
*/
public ListenableFuture<Void> updateVlanBindingsInL2GatewayDevice(NodeId nodeId, String logicalSwitchName, Devices hwVtepDevice, Integer defaultVlanId) {
if (hwVtepDevice == null || hwVtepDevice.getInterfaces() == null || hwVtepDevice.getInterfaces().isEmpty()) {
String errMsg = "HwVtepDevice is null or interfaces are empty.";
LOG.error(errMsg);
return Futures.immediateFailedFuture(new RuntimeException(errMsg));
}
return txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
for (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces deviceInterface : hwVtepDevice.getInterfaces()) {
// Removed the check for checking terminationPoint present in OP or not
// for coniguring vlan bindings
// As we are not any more dependent on it , plugin takes care of this
// with port reconcilation.
List<VlanBindings> vlanBindings = new ArrayList<>();
if (deviceInterface.getSegmentationIds() != null && !deviceInterface.getSegmentationIds().isEmpty()) {
for (Integer vlanId : deviceInterface.getSegmentationIds()) {
vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, vlanId, logicalSwitchName));
}
} else {
// Use defaultVlanId (specified in L2GatewayConnection) if Vlan
// ID not specified at interface level.
vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, defaultVlanId, logicalSwitchName));
}
HwvtepUtils.mergeVlanBindings(tx, nodeId, hwVtepDevice.getDeviceName(), deviceInterface.getInterfaceName(), vlanBindings);
}
LOG.info("Updated Hwvtep VlanBindings in config DS. NodeID: {}, LogicalSwitch: {}", nodeId.getValue(), logicalSwitchName);
});
}
Aggregations