use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class EvpnMacVrfUtils method addEvpnDmacFlow.
public void addEvpnDmacFlow(InstanceIdentifier<MacVrfEntry> instanceIdentifier, MacVrfEntry macVrfEntry) {
String elanName = getElanNameByMacvrfiid(instanceIdentifier);
if (elanName == null) {
LOG.error("Error : elanName is null for iid {}", instanceIdentifier);
return;
}
List<DpnInterfaces> dpnInterfaceLists = elanUtils.getElanDPNByName(elanName);
if (checkEvpnAttachedToNet(elanName)) {
// TODO(Riyaz) : Check if accessing first nexthop address is right solution
String nexthopIP = new ArrayList<RoutePaths>(macVrfEntry.nonnullRoutePaths().values()).get(0).getNexthopAddress();
IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
Uint32 elanTag = getElanTagByMacvrfiid(instanceIdentifier);
if (elanTag == null) {
return;
}
String dstMacAddress = macVrfEntry.getMac();
long vni = macVrfEntry.getL2vni().toJava();
jobCoordinator.enqueueJob(dstMacAddress, () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> dpnInterfaceLists.forEach(dpnInterfaces -> {
Uint64 dpId = dpnInterfaces.getDpId();
LOG.info("ADD: Build DMAC flow with dpId {}, nexthopIP {}, elanTag {}," + "vni {}, dstMacAddress {}, elanName {} ", dpId, nexthopIP, elanTag, vni, dstMacAddress, elanName);
ElanEvpnFlowUtils.EvpnDmacFlowBuilder dmacFlowBuilder = new ElanEvpnFlowUtils.EvpnDmacFlowBuilder();
dmacFlowBuilder.setDpId(dpId).setNexthopIP(ipAddress.toString()).setElanTag(elanTag.longValue()).setVni(vni).setDstMacAddress(dstMacAddress).setElanName(elanName);
Flow flow = elanEvpnFlowUtils.evpnBuildDmacFlowForExternalRemoteMac(dmacFlowBuilder.build());
mdsalManager.addFlow(tx, dpId, flow);
}))), ElanConstants.JOB_MAX_RETRIES);
}
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class DhcpInterfaceConfigListener method remove.
@Override
public void remove(InstanceIdentifier<Interface> identifier, Interface del) {
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(del.getName()), () -> {
IfTunnel tunnelInterface = del.augmentation(IfTunnel.class);
IfL2vlan vlanInterface = del.augmentation(IfL2vlan.class);
String interfaceName = del.getName();
if (tunnelInterface != null && !tunnelInterface.isInternal()) {
IpAddress tunnelIp = tunnelInterface.getTunnelDestination();
ParentRefs interfce = del.augmentation(ParentRefs.class);
if (interfce != null) {
if (LOG.isTraceEnabled()) {
LOG.trace("Calling handleTunnelStateDown for tunnelIp {} and interface {}", tunnelIp, interfaceName);
}
return dhcpExternalTunnelManager.handleTunnelStateDown(tunnelIp, interfce.getDatapathNodeIdentifier());
}
}
if (vlanInterface != null) {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> DhcpServiceUtils.unbindDhcpService(interfaceName, tx)));
}
return Collections.emptyList();
}, DhcpMConstants.RETRY_COUNT);
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class DhcpInterfaceConfigListener method add.
@Override
public void add(InstanceIdentifier<Interface> identifier, Interface add) {
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(add.getName()), () -> {
String interfaceName = add.getName();
IfL2vlan vlanInterface = add.augmentation(IfL2vlan.class);
if (vlanInterface == null) {
return Collections.emptyList();
}
Port port = dhcpManager.getNeutronPort(interfaceName);
Subnet subnet = dhcpManager.getNeutronSubnet(port);
if (null != subnet && subnet.isEnableDhcp()) {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
LOG.debug("Binding DHCP service for interface {}", interfaceName);
DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx);
}));
}
return Collections.emptyList();
}, DhcpMConstants.RETRY_COUNT);
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class DhcpSubnetListener method installNeutronPortEntries.
private void installNeutronPortEntries(List<Uuid> portList) {
LOG.trace("DhcpSubnetListener installNeutronPortEntries : portList: {}", portList);
for (Uuid portIntf : portList) {
NodeConnectorId nodeConnectorId = getNodeConnectorIdForPortIntf(portIntf);
Uint64 dpId = DhcpServiceUtils.getDpnIdFromNodeConnectorId(nodeConnectorId);
String interfaceName = portIntf.getValue();
Port port = dhcpManager.getNeutronPort(interfaceName);
String vmMacAddress = port.getMacAddress().getValue();
// check whether any changes have happened
LOG.trace("DhcpSubnetListener installNeutronPortEntries dpId: {} vmMacAddress : {}", dpId, vmMacAddress);
// Bind the dhcp service when enabled
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx)), LOG, "Error writing to the datastore");
// install the entries
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> dhcpManager.installDhcpEntries(dpId, vmMacAddress, tx)), LOG, "Error writing to the datastore");
}
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class DhcpInterfaceRemoveJob method call.
@Override
public List<ListenableFuture<?>> call() throws ExecutionException, InterruptedException {
String interfaceName = interfaceDel.getName();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManager.getInterfaceInfoFromConfigDataStore(interfaceName);
if (iface != null) {
IfTunnel tunnelInterface = iface.augmentation(IfTunnel.class);
if (tunnelInterface != null && !tunnelInterface.isInternal()) {
IpAddress tunnelIp = tunnelInterface.getTunnelDestination();
List<Uint64> dpns = DhcpServiceUtils.getListOfDpns(dataBroker);
if (dpns.contains(dpnId)) {
return dhcpExternalTunnelManager.handleTunnelStateDown(tunnelIp, dpnId);
}
return Collections.emptyList();
}
}
List<ListenableFuture<?>> futures = new ArrayList<>();
// Support for VM migration use cases.
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> DhcpServiceUtils.unbindDhcpService(interfaceName, tx)));
java.util.Optional<String> subnetId = DhcpServiceUtils.getNeutronSubnetId(port);
if (subnetId.isPresent()) {
java.util.Optional<SubnetToDhcpPort> subnetToDhcp = DhcpServiceUtils.getSubnetDhcpPortData(dataBroker, subnetId.get());
if (subnetToDhcp.isPresent()) {
LOG.trace("Removing ArpResponder flow for last interface {} on DPN {}", interfaceName, dpnId);
ArpResponderInput arpInput = new ArpResponderInput.ArpReponderInputBuilder().setDpId(dpnId.toJava()).setInterfaceName(interfaceName).setSpa(subnetToDhcp.get().getPortFixedip()).setLportTag(interfaceDel.getIfIndex()).buildForRemoveFlow();
elanService.removeArpResponderFlow(arpInput);
}
}
futures.addAll(unInstallDhcpEntries(interfaceDel.getName(), dpnId));
return futures;
}
Aggregations