use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.
the class AclLiveStatisticsRpcServiceTest method newElan.
// FIXME copied from AclServiceTestBase
protected void newElan(String elanName, long elanId) throws TransactionCommitFailedException {
ElanInstance elan = new ElanInstanceBuilder().setElanInstanceName(elanName).setElanTag(5000L).build();
singleTransactionDataBroker.syncWrite(CONFIGURATION, AclServiceUtils.getElanInstanceConfigurationDataPath(elanName), elan);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.
the class ElanL2GatewayMulticastUtils method getTepIpOfDesignatedSwitchForExternalTunnel.
/**
* Gets the tep ip of designated switch for external tunnel.
*
* @param l2GwDevice
* the l2 gw device
* @param elanInstanceName
* the elan instance name
* @return the tep ip of designated switch for external tunnel
*/
public IpAddress getTepIpOfDesignatedSwitchForExternalTunnel(L2GatewayDevice l2GwDevice, String elanInstanceName) {
IpAddress tepIp = null;
if (l2GwDevice.getTunnelIp() == null) {
LOG.warn("Tunnel IP not found for {}", l2GwDevice.getDeviceName());
return tepIp;
}
DesignatedSwitchForTunnel desgSwitch = getDesignatedSwitchForExternalTunnel(l2GwDevice.getTunnelIp(), elanInstanceName);
if (desgSwitch != null) {
tepIp = elanItmUtils.getSourceDpnTepIp(BigInteger.valueOf(desgSwitch.getDpId()), new NodeId(l2GwDevice.getHwvtepNodeId()));
}
return tepIp;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.
the class ElanL2GatewayMulticastUtils method updateMcastMacsForAllElanDevices.
/**
* Update mcast macs for this elan.
* for all dpns in this elan recompute and update broadcast group
* for all l2gw devices in this elan recompute and update remote mcast mac entry
*
* @param elanName
* the elan name
* @param device
* the device
* @param updateThisDevice
* the update this device
* @return the listenable future
*/
private ListenableFuture<Void> updateMcastMacsForAllElanDevices(String elanName, L2GatewayDevice device, boolean updateThisDevice) {
SettableFuture<Void> ft = SettableFuture.create();
ft.set(null);
List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanName);
ConcurrentMap<String, L2GatewayDevice> devices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanName);
List<IpAddress> dpnsTepIps = getAllTepIpsOfDpns(device, dpns);
List<IpAddress> l2GwDevicesTepIps = getAllTepIpsOfL2GwDevices(devices);
return txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
if (updateThisDevice) {
preapareRemoteMcastMacEntry(elanName, device, dpnsTepIps, l2GwDevicesTepIps);
}
// present to configure RemoteMcastMac entry
for (L2GatewayDevice otherDevice : devices.values()) {
if (!otherDevice.getDeviceName().equals(device.getDeviceName())) {
preapareRemoteMcastMacEntry(elanName, otherDevice, dpnsTepIps, l2GwDevicesTepIps);
}
}
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.
the class ElanL2GatewayMulticastUtils method preapareRemoteMcastMacEntry.
/**
* Update remote mcast mac.
*
* @param elanName
* the elan name
* @param device
* the device
* @param dpnsTepIps
* the dpns tep ips
* @param l2GwDevicesTepIps
* the l2 gw devices tep ips
* @return the write transaction
*/
private void preapareRemoteMcastMacEntry(String elanName, L2GatewayDevice device, List<IpAddress> dpnsTepIps, List<IpAddress> l2GwDevicesTepIps) {
NodeId nodeId = new NodeId(device.getHwvtepNodeId());
ArrayList<IpAddress> remoteTepIps = new ArrayList<>(l2GwDevicesTepIps);
remoteTepIps.remove(device.getTunnelIp());
remoteTepIps.addAll(dpnsTepIps);
IpAddress dhcpDesignatedSwitchTepIp = getTepIpOfDesignatedSwitchForExternalTunnel(device, elanName);
if (dpnsTepIps.isEmpty()) {
// physical locator in l2 gw device
if (dhcpDesignatedSwitchTepIp != null) {
remoteTepIps.add(dhcpDesignatedSwitchTepIp);
HwvtepPhysicalLocatorAugmentation phyLocatorAug = HwvtepSouthboundUtils.createHwvtepPhysicalLocatorAugmentation(String.valueOf(dhcpDesignatedSwitchTepIp.getValue()));
InstanceIdentifier<TerminationPoint> iid = HwvtepSouthboundUtils.createPhysicalLocatorInstanceIdentifier(nodeId, phyLocatorAug);
TerminationPoint terminationPoint = new TerminationPointBuilder().setKey(HwvtepSouthboundUtils.getTerminationPointKey(phyLocatorAug)).addAugmentation(HwvtepPhysicalLocatorAugmentation.class, phyLocatorAug).build();
ResourceBatchingManager.getInstance().put(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, iid, terminationPoint);
LOG.info("Adding PhysicalLocator for node: {} with Dhcp designated switch Tep Ip {} " + "as physical locator, elan {}", device.getHwvtepNodeId(), String.valueOf(dhcpDesignatedSwitchTepIp.getValue()), elanName);
} else {
LOG.warn("Dhcp designated switch Tep Ip not found for l2 gw node {} and elan {}", device.getHwvtepNodeId(), elanName);
}
}
if (dhcpDesignatedSwitchTepIp != null && !remoteTepIps.contains(dhcpDesignatedSwitchTepIp)) {
remoteTepIps.add(dhcpDesignatedSwitchTepIp);
}
String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(elanName);
putRemoteMcastMac(nodeId, logicalSwitchName, remoteTepIps);
LOG.info("Adding RemoteMcastMac for node: {} with physical locators: {}", device.getHwvtepNodeId(), remoteTepIps);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.
the class ElanL2GatewayUtils method getElanMacTableEntriesMacs.
/**
* Gets the elan mac table entries as remote ucast macs. <br>
* Note: ELAN MAC table only contains internal switches MAC's. It doesn't
* contain external device MAC's.
*
* @param elanName
* the elan name
* @param hwVtepNodeId
* the hw vtep node id
* @param logicalSwitchName
* the logical switch name
* @return the elan mac table entries as remote ucast macs
*/
public List<RemoteUcastMacs> getElanMacTableEntriesMacs(String elanName, NodeId hwVtepNodeId, String logicalSwitchName) {
List<RemoteUcastMacs> lstRemoteUcastMacs = new ArrayList<>();
MacTable macTable = ElanUtils.getElanMacTable(broker, elanName);
if (macTable == null || macTable.getMacEntry() == null || macTable.getMacEntry().isEmpty()) {
LOG.trace("MacTable is empty for elan: {}", elanName);
return lstRemoteUcastMacs;
}
for (MacEntry macEntry : macTable.getMacEntry()) {
BigInteger dpnId = getDpidFromInterface(macEntry.getInterface());
if (dpnId == null) {
LOG.error("DPN ID not found for interface {}", macEntry.getInterface());
continue;
}
IpAddress dpnTepIp = elanItmUtils.getSourceDpnTepIp(dpnId, hwVtepNodeId);
LOG.trace("Dpn Tep IP: {} for dpnId: {} and nodeId: {}", dpnTepIp, dpnId, hwVtepNodeId.getValue());
if (dpnTepIp == null) {
LOG.error("TEP IP not found for dpnId {} and nodeId {}", dpnId, hwVtepNodeId.getValue());
continue;
}
HwvtepPhysicalLocatorAugmentation physLocatorAug = HwvtepSouthboundUtils.createHwvtepPhysicalLocatorAugmentation(String.valueOf(dpnTepIp.getValue()));
// TODO: Query ARP cache to get IP address corresponding to the
// MAC
RemoteUcastMacs remoteUcastMac = HwvtepSouthboundUtils.createRemoteUcastMac(hwVtepNodeId, macEntry.getMacAddress().getValue().toLowerCase(Locale.getDefault()), null, /*IpAddress*/
logicalSwitchName, physLocatorAug);
lstRemoteUcastMacs.add(remoteUcastMac);
}
return lstRemoteUcastMacs;
}
Aggregations