use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanServiceProvider method getElanInterfaces.
@Override
@Nonnull
public List<String> getElanInterfaces(String elanInstanceName) {
List<String> elanInterfaces = new ArrayList<>();
InstanceIdentifier<ElanInterfaces> elanInterfacesIdentifier = InstanceIdentifier.builder(ElanInterfaces.class).build();
Optional<ElanInterfaces> elanInterfacesOptional = ElanUtils.read(broker, LogicalDatastoreType.CONFIGURATION, elanInterfacesIdentifier);
if (!elanInterfacesOptional.isPresent()) {
return elanInterfaces;
}
List<ElanInterface> elanInterfaceList = elanInterfacesOptional.get().getElanInterface();
for (ElanInterface elanInterface : elanInterfaceList) {
if (elanInterface.getElanInstanceName().equals(elanInstanceName)) {
elanInterfaces.add(elanInterface.getName());
}
}
return elanInterfaces;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanInterfaceManager method removeEntriesForElanInterface.
List<ListenableFuture<Void>> removeEntriesForElanInterface(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String interfaceName, boolean isLastElanInterface) {
String elanName = elanInfo.getElanInstanceName();
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(flowTx -> {
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(interfaceTx -> {
InstanceIdentifier<ElanInterfaceMac> elanInterfaceId = ElanUtils.getElanInterfaceMacEntriesOperationalDataPath(interfaceName);
Optional<ElanInterfaceMac> existingElanInterfaceMac = interfaceTx.read(LogicalDatastoreType.OPERATIONAL, elanInterfaceId).checkedGet();
LOG.debug("Removing the Interface:{} from elan:{}", interfaceName, elanName);
if (interfaceInfo != null) {
if (existingElanInterfaceMac.isPresent()) {
List<MacEntry> existingMacEntries = existingElanInterfaceMac.get().getMacEntry();
if (existingMacEntries != null) {
List<PhysAddress> macAddresses = new ArrayList<>();
for (MacEntry macEntry : existingMacEntries) {
PhysAddress macAddress = macEntry.getMacAddress();
LOG.debug("removing the mac-entry:{} present on elanInterface:{}", macAddress.getValue(), interfaceName);
Optional<MacEntry> macEntryOptional = elanUtils.getMacEntryForElanInstance(interfaceTx, elanName, macAddress);
if (!isLastElanInterface && macEntryOptional.isPresent()) {
interfaceTx.delete(LogicalDatastoreType.OPERATIONAL, ElanUtils.getMacEntryOperationalDataPath(elanName, macAddress));
}
elanUtils.deleteMacFlows(elanInfo, interfaceInfo, macEntry, flowTx);
macAddresses.add(macAddress);
}
// to this ELAN
if (isVxlanNetworkOrVxlanSegment(elanInfo) && !macAddresses.isEmpty()) {
elanL2GatewayUtils.removeMacsFromElanExternalDevices(elanInfo, macAddresses);
}
}
}
removeDefaultTermFlow(interfaceInfo.getDpId(), interfaceInfo.getInterfaceTag());
removeFilterEqualsTable(elanInfo, interfaceInfo, flowTx);
} else if (existingElanInterfaceMac.isPresent()) {
// Interface does not exist in ConfigDS, so lets remove everything
// about that interface related to Elan
List<MacEntry> macEntries = existingElanInterfaceMac.get().getMacEntry();
if (macEntries != null) {
for (MacEntry macEntry : macEntries) {
PhysAddress macAddress = macEntry.getMacAddress();
if (elanUtils.getMacEntryForElanInstance(elanName, macAddress).isPresent()) {
interfaceTx.delete(LogicalDatastoreType.OPERATIONAL, ElanUtils.getMacEntryOperationalDataPath(elanName, macAddress));
}
}
}
}
if (existingElanInterfaceMac.isPresent()) {
interfaceTx.delete(LogicalDatastoreType.OPERATIONAL, elanInterfaceId);
}
unbindService(interfaceName, interfaceTx);
deleteElanInterfaceFromConfigDS(interfaceName, interfaceTx);
}));
}));
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanInterfaceManager method deleteAllRemoteMacsInADpn.
private void deleteAllRemoteMacsInADpn(String elanName, BigInteger dpId, long elanTag) {
List<DpnInterfaces> dpnInterfaces = elanUtils.getInvolvedDpnsInElan(elanName);
for (DpnInterfaces dpnInterface : dpnInterfaces) {
BigInteger currentDpId = dpnInterface.getDpId();
if (!currentDpId.equals(dpId)) {
for (String elanInterface : dpnInterface.getInterfaces()) {
ElanInterfaceMac macs = elanUtils.getElanInterfaceMacByInterfaceName(elanInterface);
if (macs == null || macs.getMacEntry() == null) {
continue;
}
for (MacEntry mac : macs.getMacEntry()) {
removeTheMacFlowInTheDPN(dpId, elanTag, currentDpId, mac);
removeEtreeMacFlowInTheDPN(dpId, elanTag, currentDpId, mac);
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanInterfaceManager method remove.
@Override
protected void remove(InstanceIdentifier<ElanInterface> identifier, ElanInterface del) {
String interfaceName = del.getName();
ElanInstance elanInfo = elanInstanceCache.get(del.getElanInstanceName()).orNull();
/*
* Handling in case the elan instance is deleted.If the Elan instance is
* deleted, there is no need to explicitly delete the elan interfaces
*/
if (elanInfo == null) {
return;
}
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
if (interfaceInfo == null && elanInfo.isExternal()) {
// In deleting external network, the underlying ietf Inteface might have been removed
// from the config DS prior to deleting the ELAN interface. We try to get the InterfaceInfo
// from Operational DS instead
interfaceInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(interfaceName);
}
String elanInstanceName = elanInfo.getElanInstanceName();
InterfaceRemoveWorkerOnElan configWorker = new InterfaceRemoveWorkerOnElan(elanInstanceName, elanInfo, interfaceName, interfaceInfo, this);
jobCoordinator.enqueueJob(elanInstanceName, configWorker, ElanConstants.JOB_MAX_RETRIES);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface in project netvirt by opendaylight.
the class ElanInterfaceStateChangeListener method remove.
@Override
protected void remove(InstanceIdentifier<Interface> identifier, Interface delIf) {
if (!L2vlan.class.equals(delIf.getType())) {
return;
}
LOG.trace("Received interface {} Down event", delIf);
String interfaceName = delIf.getName();
Optional<ElanInterface> elanInterface = elanInterfaceCache.get(interfaceName);
if (!elanInterface.isPresent()) {
LOG.debug("No Elan Interface is created for the interface:{} ", interfaceName);
return;
}
NodeConnectorId nodeConnectorId = new NodeConnectorId(delIf.getLowerLayerIf().get(0));
BigInteger dpId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
InterfaceInfo interfaceInfo = new InterfaceInfo(dpId, nodeConnectorId.getValue());
interfaceInfo.setInterfaceName(interfaceName);
interfaceInfo.setInterfaceType(InterfaceInfo.InterfaceType.VLAN_INTERFACE);
interfaceInfo.setInterfaceTag(delIf.getIfIndex());
String elanInstanceName = elanInterface.get().getElanInstanceName();
ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
if (elanInstance == null) {
LOG.debug("No Elan instance is available for the interface:{} ", interfaceName);
return;
}
InterfaceRemoveWorkerOnElan removeWorker = new InterfaceRemoveWorkerOnElan(elanInstanceName, elanInstance, interfaceName, interfaceInfo, elanInterfaceManager);
jobCoordinator.enqueueJob(elanInstanceName, removeWorker, ElanConstants.JOB_MAX_RETRIES);
}
Aggregations