use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class ElanL2GatewayUtils method deleteElanMacsFromL2GatewayDevice.
/**
* Delete elan macs from L2 gateway device.<br>
* This includes deleting ELAN mac table entries plus external device
* UcastLocalMacs which are part of the same ELAN.
*
* @param hwvtepNodeId
* the hwvtepNodeId
* @param elanName
* the elan name
* @return the listenable future
*/
public ListenableFuture<Void> deleteElanMacsFromL2GatewayDevice(String hwvtepNodeId, String elanName) {
String logicalSwitch = getLogicalSwitchFromElan(elanName);
List<MacAddress> lstElanMacs = getRemoteUcastMacs(new NodeId(hwvtepNodeId), logicalSwitch, LogicalDatastoreType.CONFIGURATION);
ListenableFuture<Void> future = HwvtepUtils.deleteRemoteUcastMacs(broker, new NodeId(hwvtepNodeId), logicalSwitch, lstElanMacs);
Futures.addCallback(future, new FutureCallback<Void>() {
@Override
public void onSuccess(Void noarg) {
LOG.trace("Successful in batch deletion of elan [{}] macs from l2gw device [{}]", elanName, hwvtepNodeId);
}
@Override
public void onFailure(Throwable error) {
LOG.warn("Failed during batch delete of elan {} macs from l2gw device {}. " + "Retrying with sequential deletes.", elanName, hwvtepNodeId, error);
if (lstElanMacs != null && !lstElanMacs.isEmpty()) {
for (MacAddress mac : lstElanMacs) {
HwvtepUtils.deleteRemoteUcastMac(broker, new NodeId(hwvtepNodeId), logicalSwitch, mac);
}
}
}
}, MoreExecutors.directExecutor());
if (LOG.isDebugEnabled()) {
List<String> elanMacs = lstElanMacs.stream().map(MacAddress::getValue).collect(Collectors.toList());
LOG.debug("Deleting elan [{}] macs from node [{}]. Deleted macs = {}", elanName, hwvtepNodeId, elanMacs);
}
return future;
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class ElanL2GatewayUtils method getRemoteUcastMacs.
/**
* Gets the remote ucast macs from hwvtep node filtering based on logical
* switch.
*
* @param hwvtepNodeId
* the hwvtep node id
* @param logicalSwitch
* the logical switch
* @param datastoreType
* the datastore type
* @return the remote ucast macs
*/
public List<MacAddress> getRemoteUcastMacs(NodeId hwvtepNodeId, String logicalSwitch, LogicalDatastoreType datastoreType) {
List<MacAddress> lstMacs = Collections.emptyList();
Node hwvtepNode = HwvtepUtils.getHwVtepNode(broker, datastoreType, hwvtepNodeId);
if (hwvtepNode != null) {
List<RemoteUcastMacs> remoteUcastMacs = hwvtepNode.getAugmentation(HwvtepGlobalAugmentation.class).getRemoteUcastMacs();
if (remoteUcastMacs != null && !remoteUcastMacs.isEmpty()) {
// Filtering remoteUcastMacs based on the logical switch and
// forming a list of MacAddress
lstMacs = remoteUcastMacs.stream().filter(mac -> logicalSwitch.equals(mac.getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue())).map(HwvtepMacTableGenericAttributes::getMacEntryKey).collect(Collectors.toList());
}
}
return lstMacs;
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class ElanL2GatewayUtils method installElanMacsInL2GatewayDevice.
/**
* Install ELAN macs in L2 Gateway device.<br>
* This includes installing ELAN mac table entries plus external device
* UcastLocalMacs which are part of the same ELAN.
*
* @param elanName
* the elan name
* @param l2GatewayDevice
* the l2 gateway device which has to be configured
* @return the listenable future
*/
public ListenableFuture<Void> installElanMacsInL2GatewayDevice(String elanName, L2GatewayDevice l2GatewayDevice) {
String logicalSwitchName = getLogicalSwitchFromElan(elanName);
NodeId hwVtepNodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
List<RemoteUcastMacs> lstL2GatewayDevicesMacs = getOtherDevicesMacs(elanName, l2GatewayDevice, hwVtepNodeId, logicalSwitchName);
List<RemoteUcastMacs> lstElanMacTableEntries = getElanMacTableEntriesMacs(elanName, hwVtepNodeId, logicalSwitchName);
List<RemoteUcastMacs> lstRemoteUcastMacs = new ArrayList<>(lstL2GatewayDevicesMacs);
lstRemoteUcastMacs.addAll(lstElanMacTableEntries);
ListenableFuture<Void> future = HwvtepUtils.addRemoteUcastMacs(broker, hwVtepNodeId, lstRemoteUcastMacs);
LOG.info("Added RemoteUcastMacs entries [{}] in config DS. NodeID: {}, LogicalSwitch: {}", lstRemoteUcastMacs.size(), hwVtepNodeId.getValue(), logicalSwitchName);
return future;
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac 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.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class TestBuilders method buildRemoteMcastMacs.
public static RemoteMcastMacs buildRemoteMcastMacs(InstanceIdentifier<Node> iid, String mac, String logicalSwitchName, String[] tepIps) {
RemoteMcastMacsBuilder remoteMcastMacsBuilder = new RemoteMcastMacsBuilder();
if (mac.equals("unknown-dst")) {
remoteMcastMacsBuilder.setMacEntryKey(new MacAddress("00:00:00:00:00:00"));
} else {
remoteMcastMacsBuilder.setMacEntryKey(new MacAddress(mac));
}
remoteMcastMacsBuilder.setMacEntryUuid(getUUid(mac));
// mMacLocalBuilder.setIpaddr(new IpAddress(ip.toCharArray()));
remoteMcastMacsBuilder.setLogicalSwitchRef(buildLogicalSwitchesRef(iid, logicalSwitchName));
List<LocatorSet> locatorSets = new ArrayList<>();
for (String tepIp : tepIps) {
locatorSets.add(new LocatorSetBuilder().setLocatorRef(buildLocatorRef(iid, tepIp)).build());
}
remoteMcastMacsBuilder.setLocatorSet(locatorSets);
return remoteMcastMacsBuilder.build();
}
Aggregations