use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.
the class ElanServiceProvider method getEgressMatchesForElanInstance.
@Override
public List<MatchInfoBase> getEgressMatchesForElanInstance(String elanInstanceName) {
ElanInstance elanInstance = getElanInstance(elanInstanceName);
if (elanInstance == null) {
LOG.debug("No ELAN instance found for {}", elanInstanceName);
return Collections.emptyList();
}
Long elanTag = elanInstance.getElanTag();
if (elanTag == null) {
LOG.debug("No ELAN tag found for {}", elanInstanceName);
return Collections.emptyList();
}
return Collections.singletonList(new NxMatchRegister(ElanConstants.ELAN_REG_ID, elanTag, MetaDataUtil.getElanMaskForReg()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.
the class ElanServiceProvider method getElanMacTable.
@Override
public Collection<MacEntry> getElanMacTable(String elanInstanceName) {
Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
List<MacEntry> macAddress = new ArrayList<>();
if (elanInfo == null) {
return macAddress;
}
List<String> elanInterfaces = elanInfo.getElanInterfaces();
if (elanInterfaces != null && elanInterfaces.size() > 0) {
for (String elanInterface : elanInterfaces) {
ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(elanInterface);
if (elanInterfaceMac != null && elanInterfaceMac.getMacEntry() != null && elanInterfaceMac.getMacEntry().size() > 0) {
macAddress.addAll(elanInterfaceMac.getMacEntry());
}
}
}
return macAddress;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.
the class DeleteL2GwDeviceMacsFromElanJob method call.
/*
* (non-Javadoc)
*
* @see java.util.concurrent.Callable#call()
*/
@Override
public List<ListenableFuture<Void>> call() {
LOG.debug("Deleting l2gw device [{}] macs from other l2gw devices for elan [{}]", this.l2GwDevice.getHwvtepNodeId(), this.elanName);
final String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(this.elanName);
List<MacAddress> macs = new ArrayList<>();
macAddresses.forEach((mac) -> macs.add(new MacAddress(mac.getValue().toLowerCase())));
List<ListenableFuture<Void>> futures = new ArrayList<>();
ConcurrentMap<String, L2GatewayDevice> elanL2GwDevices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(this.elanName);
for (L2GatewayDevice otherDevice : elanL2GwDevices.values()) {
if (!otherDevice.getHwvtepNodeId().equals(this.l2GwDevice.getHwvtepNodeId()) && !ElanL2GatewayUtils.areMLAGDevices(this.l2GwDevice, otherDevice)) {
final String hwvtepId = otherDevice.getHwvtepNodeId();
// This delete is batched using resourcebatchingmnagaer
futures.addAll(deleteRemoteUcastMacs(new NodeId(hwvtepId), logicalSwitchName, macs));
}
}
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.
the class VpnManagerImpl method addArpResponderFlowsToExternalNetworkIps.
@Override
public void addArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress, BigInteger dpnId, Uuid extNetworkId, WriteTransaction writeTx) {
if (dpnId == null || BigInteger.ZERO.equals(dpnId)) {
LOG.warn("Failed to install arp responder flows for router {}. DPN id is missing.", id);
return;
}
String extInterfaceName = elanService.getExternalElanInterface(extNetworkId.getValue(), dpnId);
if (extInterfaceName != null) {
doAddArpResponderFlowsToExternalNetworkIps(id, fixedIps, macAddress, dpnId, extNetworkId, writeTx, extInterfaceName);
return;
}
LOG.warn("Failed to install responder flows for {}. No external interface found for DPN id {}", id, dpnId);
if (!upgradeState.isUpgradeInProgress()) {
return;
}
// The following through the end of the function deals with an upgrade scenario where the neutron configuration
// is restored before the OVS switches reconnect. In such a case, the elan-dpn-interfaces entries will be
// missing from the operational data store. In order to mitigate this we use DataTreeEventCallbackRegistrar
// to wait for the exact operational md-sal object we need to contain the external interface we need.
LOG.info("Upgrade in process, waiting for an external interface to appear on dpn {} for elan {}", dpnId, extNetworkId.getValue());
InstanceIdentifier<DpnInterfaces> dpnInterfacesIid = elanService.getElanDpnInterfaceOperationalDataPath(extNetworkId.getValue(), dpnId);
eventCallbacks.onAddOrUpdate(LogicalDatastoreType.OPERATIONAL, dpnInterfacesIid, (unused, alsoUnused) -> {
LOG.info("Reattempting write of arp responder for external interfaces for external network {}", extNetworkId);
DpnInterfaces dpnInterfaces = elanService.getElanInterfaceInfoByElanDpn(extNetworkId.getValue(), dpnId);
if (dpnInterfaces == null) {
LOG.error("Could not retrieve DpnInterfaces for {}, {}", extNetworkId.getValue(), dpnId);
return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
}
String extIfc = null;
for (String dpnInterface : dpnInterfaces.getInterfaces()) {
if (interfaceManager.isExternalInterface(dpnInterface)) {
extIfc = dpnInterface;
break;
}
}
if (extIfc == null) {
if (upgradeState.isUpgradeInProgress()) {
LOG.info("External interface not found yet in elan {} on dpn {}, keep waiting", extNetworkId.getValue(), dpnInterfaces);
return DataTreeEventCallbackRegistrar.NextAction.CALL_AGAIN;
} else {
return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
}
}
final String extIfcFinal = extIfc;
ListenableFuture<Void> listenableFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
doAddArpResponderFlowsToExternalNetworkIps(id, fixedIps, macAddress, dpnId, extNetworkId, tx, extIfcFinal);
});
ListenableFutures.addErrorLogging(listenableFuture, LOG, "Error while configuring arp responder for ext. interface");
return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.
the class ElanDpnInterfacesListener method add.
@Override
protected void add(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces dpnInterfaces) {
LOG.debug("received Dpninterfaces add event for dpn {}", dpnInterfaces.getDpId());
BigInteger dpnId = dpnInterfaces.getDpId();
String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
// on br-int patch port for this DPN
if (elanInstance != null && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
jobCoordinator.enqueueJob(dpnId.toString(), () -> {
LOG.debug("creating vlan member intf for elan {}, dpn {}", elanInstance.getPhysicalNetworkName(), dpnId);
elanService.createExternalElanNetwork(elanInstance, dpnId);
return Collections.emptyList();
});
}
}
Aggregations