use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project netvirt by opendaylight.
the class ElanUtils method isTunnelInLogicalGroup.
public boolean isTunnelInLogicalGroup(String interfaceName) {
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface configIface = interfaceManager.getInterfaceInfoFromConfigDataStore(interfaceName);
IfTunnel ifTunnel = configIface.getAugmentation(IfTunnel.class);
if (ifTunnel != null && ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
ParentRefs refs = configIface.getAugmentation(ParentRefs.class);
if (refs != null && !Strings.isNullOrEmpty(refs.getParentInterface())) {
// multiple VxLAN tunnels enabled, i.e. only logical tunnel should be treated
return true;
}
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project netvirt by opendaylight.
the class DhcpInterfaceConfigListener method remove.
@Override
protected void remove(InstanceIdentifier<Interface> identifier, Interface del) {
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(del.getName()), () -> {
IfTunnel tunnelInterface = del.getAugmentation(IfTunnel.class);
IfL2vlan vlanInterface = del.getAugmentation(IfL2vlan.class);
String interfaceName = del.getName();
if (tunnelInterface != null && !tunnelInterface.isInternal()) {
IpAddress tunnelIp = tunnelInterface.getTunnelDestination();
ParentRefs interfce = del.getAugmentation(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(tx -> DhcpServiceUtils.unbindDhcpService(interfaceName, tx)));
}
return Collections.emptyList();
}, DhcpMConstants.RETRY_COUNT);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project netvirt by opendaylight.
the class DhcpInterfaceAddJob method call.
@Override
public List<ListenableFuture<Void>> call() {
String interfaceName = interfaceAdd.getName();
LOG.trace("Received add DCN for interface {}, dpid {}", interfaceName, dpnId);
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.getAugmentation(IfTunnel.class);
if (tunnelInterface != null && !tunnelInterface.isInternal()) {
IpAddress tunnelIp = tunnelInterface.getTunnelDestination();
List<BigInteger> dpns = DhcpServiceUtils.getListOfDpns(dataBroker);
if (dpns.contains(dpnId)) {
return dhcpExternalTunnelManager.handleTunnelStateUp(tunnelIp, dpnId);
}
return Collections.emptyList();
}
}
if (!dpnId.equals(DhcpMConstants.INVALID_DPID)) {
Port port = dhcpManager.getNeutronPort(interfaceName);
Subnet subnet = dhcpManager.getNeutronSubnet(port);
if (null == subnet || !subnet.isEnableDhcp()) {
LOG.debug("DHCP is not enabled for port {}", port.getName());
return Collections.emptyList();
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
// Support for VM migration use cases.
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx)));
LOG.info("DhcpInterfaceEventListener add isEnableDhcp:{}", subnet.isEnableDhcp());
futures.addAll(installDhcpEntries(interfaceAdd.getName(), dpnId));
LOG.trace("Checking ElanDpnInterface {} for dpn {} ", interfaceName, dpnId);
String subnetId = subnet.getUuid().getValue();
java.util.Optional<SubnetToDhcpPort> subnetToDhcp = DhcpServiceUtils.getSubnetDhcpPortData(dataBroker, subnetId);
if (!subnetToDhcp.isPresent()) {
return Collections.emptyList();
}
LOG.trace("Installing the Arp responder for interface {} with DHCP MAC {} & IP {}.", interfaceName, subnetToDhcp.get().getPortMacaddress(), subnetToDhcp.get().getPortFixedip());
ArpReponderInputBuilder builder = new ArpReponderInputBuilder();
builder.setDpId(dpnId).setInterfaceName(interfaceName).setSpa(subnetToDhcp.get().getPortFixedip()).setSha(subnetToDhcp.get().getPortMacaddress()).setLportTag(interfaceAdd.getIfIndex());
builder.setInstructions(ArpResponderUtil.getInterfaceInstructions(interfaceManager, interfaceName, subnetToDhcp.get().getPortFixedip(), subnetToDhcp.get().getPortMacaddress()));
elanService.addArpResponderFlow(builder.buildForInstallFlow());
return futures;
}
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project netvirt by opendaylight.
the class DhcpInterfaceRemoveJob method call.
@Override
public List<ListenableFuture<Void>> call() {
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.getAugmentation(IfTunnel.class);
if (tunnelInterface != null && !tunnelInterface.isInternal()) {
IpAddress tunnelIp = tunnelInterface.getTunnelDestination();
List<BigInteger> dpns = DhcpServiceUtils.getListOfDpns(dataBroker);
if (dpns.contains(dpnId)) {
return dhcpExternalTunnelManager.handleTunnelStateDown(tunnelIp, dpnId);
}
return Collections.emptyList();
}
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
// Support for VM migration use cases.
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(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).setInterfaceName(interfaceName).setSpa(subnetToDhcp.get().getPortFixedip()).setLportTag(interfaceDel.getIfIndex()).buildForRemoveFlow();
elanService.removeArpResponderFlow(arpInput);
}
}
futures.addAll(unInstallDhcpEntries(interfaceDel.getName(), dpnId));
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project netvirt by opendaylight.
the class DhcpInterfaceUpdateJob method call.
@Override
public List<ListenableFuture<Void>> call() {
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManager.getInterfaceInfoFromConfigDataStore(interfaceName);
if (iface == null) {
LOG.trace("Interface {} is not present in the config DS", interfaceName);
return Collections.emptyList();
}
if (Tunnel.class.equals(iface.getType())) {
IfTunnel tunnelInterface = iface.getAugmentation(IfTunnel.class);
if (tunnelInterface != null && !tunnelInterface.isInternal()) {
IpAddress tunnelIp = tunnelInterface.getTunnelDestination();
List<BigInteger> dpns = DhcpServiceUtils.getListOfDpns(dataBroker);
if (dpns.contains(dpnId)) {
if (operStatus == OperStatus.Down) {
return dhcpExternalTunnelManager.handleTunnelStateDown(tunnelIp, dpnId);
} else if (operStatus == OperStatus.Up) {
return dhcpExternalTunnelManager.handleTunnelStateUp(tunnelIp, dpnId);
}
}
}
}
return Collections.emptyList();
}
Aggregations