use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs in project netvirt by opendaylight.
the class DhcpUCastMacListener method add.
@Override
protected void add(InstanceIdentifier<LocalUcastMacs> identifier, LocalUcastMacs add) {
NodeId torNodeId = identifier.firstKeyOf(Node.class).getNodeId();
InstanceIdentifier<LogicalSwitches> logicalSwitchRef = (InstanceIdentifier<LogicalSwitches>) add.getLogicalSwitchRef().getValue();
Optional<LogicalSwitches> logicalSwitchOptional = MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, logicalSwitchRef);
if (!logicalSwitchOptional.isPresent()) {
LOG.error("Logical Switch ref doesn't have data {}", logicalSwitchRef);
return;
}
LogicalSwitches logicalSwitch = logicalSwitchOptional.get();
String elanInstanceName = logicalSwitch.getHwvtepNodeName().getValue();
String macAddress = add.getMacEntryKey().getValue();
BigInteger vni = new BigInteger(logicalSwitch.getTunnelKey());
Port port = dhcpExternalTunnelManager.readVniMacToPortCache(vni, macAddress);
if (port == null) {
LOG.trace("No neutron port created for macAddress {}, tunnelKey {}", macAddress, vni);
return;
}
L2GatewayDevice device = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanInstanceName, torNodeId.getValue());
if (device == null) {
LOG.error("Logical Switch Device with name {} is not present in L2GWCONN cache", elanInstanceName);
return;
}
IpAddress tunnelIp = device.getTunnelIp();
Subnet subnet = dhcpManager.getNeutronSubnet(port);
if (null != subnet && !subnet.isEnableDhcp()) {
dhcpExternalTunnelManager.updateExistingVMTunnelIPCache(tunnelIp, elanInstanceName, macAddress);
LOG.warn("DhcpUCastMacListener add: flag for the subnetId {} is False so Table 18 entries are not added", subnet.getUuid());
return;
}
BigInteger designatedDpnId = dhcpExternalTunnelManager.readDesignatedSwitchesForExternalTunnel(tunnelIp, elanInstanceName);
if (designatedDpnId == null || designatedDpnId.equals(DhcpMConstants.INVALID_DPID)) {
LOG.trace("Unable to install flows for macAddress {}. TunnelIp {}, elanInstanceName {}, designatedDpn {} ", macAddress, tunnelIp, elanInstanceName, designatedDpnId);
dhcpExternalTunnelManager.updateLocalCache(tunnelIp, elanInstanceName, macAddress);
return;
}
dhcpExternalTunnelManager.installDhcpFlowsForVms(tunnelIp, elanInstanceName, DhcpServiceUtils.getListOfDpns(broker), designatedDpnId, macAddress);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs 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.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs in project netvirt by opendaylight.
the class ElanL2GatewayUtils method getElanInstanceForUcastLocalMac.
public ElanInstance getElanInstanceForUcastLocalMac(LocalUcastMacs localUcastMac) {
Optional<LogicalSwitches> lsOpc = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, (InstanceIdentifier<LogicalSwitches>) localUcastMac.getLogicalSwitchRef().getValue());
if (lsOpc.isPresent()) {
LogicalSwitches ls = lsOpc.get();
// Logical switch name is Elan name
String elanName = getElanFromLogicalSwitch(ls.getHwvtepNodeName().getValue());
return elanInstanceCache.get(elanName).orNull();
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs in project netvirt by opendaylight.
the class TestBuilders method buildLocalUcastMacs.
public static LocalUcastMacs buildLocalUcastMacs(InstanceIdentifier<Node> nodeIid, String vmMac, String vmip, String tepIp, String logicalSwitchName) {
LocalUcastMacsBuilder ucmlBuilder = new LocalUcastMacsBuilder();
ucmlBuilder.setIpaddr(new IpAddress(vmip.toCharArray()));
ucmlBuilder.setMacEntryKey(new MacAddress(vmMac));
ucmlBuilder.setMacEntryUuid(getUUid(vmMac));
ucmlBuilder.setLocatorRef(buildLocatorRef(nodeIid, tepIp));
ucmlBuilder.setLogicalSwitchRef(buildLogicalSwitchesRef(nodeIid, logicalSwitchName));
return ucmlBuilder.build();
}
Aggregations