use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel in project netvirt by opendaylight.
the class DhcpInterfaceEventListener method update.
@Override
protected void update(InstanceIdentifier<Interface> identifier, Interface original, Interface update) {
// We're only interested in Vlan and Tunnel ports
if (!L2vlan.class.equals(update.getType()) && !Tunnel.class.equals(update.getType())) {
return;
}
if ((original.getOperStatus().getIntValue() ^ update.getOperStatus().getIntValue()) == 0) {
LOG.trace("Interface operstatus {} is same", update.getOperStatus());
return;
}
if (original.getOperStatus().equals(OperStatus.Unknown) || update.getOperStatus().equals(OperStatus.Unknown)) {
LOG.trace("New/old interface state is unknown not handling");
return;
}
List<String> ofportIds = update.getLowerLayerIf();
if (ofportIds == null || ofportIds.isEmpty()) {
return;
}
NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
BigInteger dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
String interfaceName = update.getName();
DhcpInterfaceUpdateJob job = new DhcpInterfaceUpdateJob(dhcpExternalTunnelManager, dataBroker, interfaceName, dpnId, update.getOperStatus(), interfaceManager);
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel in project netvirt by opendaylight.
the class DhcpInterfaceEventListener method add.
@Override
protected void add(InstanceIdentifier<Interface> identifier, Interface add) {
// We're only interested in Vlan and Tunnel ports
if (!L2vlan.class.equals(add.getType()) && !Tunnel.class.equals(add.getType())) {
return;
}
String interfaceName = add.getName();
LOG.trace("DhcpInterfaceAddJob to be created for interface {}", interfaceName);
List<String> ofportIds = add.getLowerLayerIf();
if (ofportIds == null || ofportIds.isEmpty()) {
return;
}
Port port = dhcpManager.getNeutronPort(interfaceName);
if (NeutronConstants.IS_DHCP_PORT.test(port)) {
return;
}
dhcpPortCache.put(interfaceName, port);
NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
BigInteger dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
DhcpInterfaceAddJob job = new DhcpInterfaceAddJob(dhcpManager, dhcpExternalTunnelManager, dataBroker, add, dpnId, interfaceManager, elanService);
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel in project netvirt by opendaylight.
the class DhcpExternalTunnelManager method chooseDpn.
/**
* Choose a dpn among the list of elanDpns such that it has lowest count of being the designated dpn.
* @param tunnelIp The tunnel Ip address
* @param elanInstanceName The elan instance name
* @param dpns The data path nodes
* @return The designated dpn
*/
private BigInteger chooseDpn(IpAddress tunnelIp, String elanInstanceName, List<BigInteger> dpns) {
BigInteger designatedDpnId = DhcpMConstants.INVALID_DPID;
if (dpns != null && dpns.size() != 0) {
List<BigInteger> candidateDpns = DhcpServiceUtils.getDpnsForElan(elanInstanceName, broker);
candidateDpns.retainAll(dpns);
LOG.trace("Choosing new dpn for tunnelIp {}, elanInstanceName {}, among elanDpns {}", tunnelIp, elanInstanceName, candidateDpns);
boolean elanDpnAvailableFlag = true;
if (candidateDpns.isEmpty()) {
candidateDpns = dpns;
elanDpnAvailableFlag = false;
}
int size = 0;
L2GatewayDevice device = getDeviceFromTunnelIp(tunnelIp);
if (device == null) {
LOG.trace("Could not find any device for elanInstanceName {} and tunnelIp {}", elanInstanceName, tunnelIp);
handleUnableToDesignateDpn(tunnelIp, elanInstanceName);
return designatedDpnId;
}
for (BigInteger dpn : candidateDpns) {
String hwvtepNodeId = device.getHwvtepNodeId();
if (!elanDpnAvailableFlag) {
if (!isTunnelConfigured(dpn, hwvtepNodeId)) {
LOG.trace("Tunnel is not configured on dpn {} to TOR {}", dpn, hwvtepNodeId);
continue;
}
} else if (!isTunnelUp(hwvtepNodeId, dpn)) {
LOG.trace("Tunnel is not up between dpn {} and TOR {}", dpn, hwvtepNodeId);
continue;
}
Set<Pair<IpAddress, String>> tunnelIpElanNameSet = designatedDpnsToTunnelIpElanNameCache.get(dpn);
if (tunnelIpElanNameSet == null) {
designatedDpnId = dpn;
break;
}
if (size == 0 || tunnelIpElanNameSet.size() < size) {
size = tunnelIpElanNameSet.size();
designatedDpnId = dpn;
}
}
writeDesignatedSwitchForExternalTunnel(designatedDpnId, tunnelIp, elanInstanceName);
return designatedDpnId;
}
handleUnableToDesignateDpn(tunnelIp, elanInstanceName);
return designatedDpnId;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel in project netvirt by opendaylight.
the class DhcpExternalTunnelManager method installRemoteMcastMac.
public void installRemoteMcastMac(final BigInteger designatedDpnId, final IpAddress tunnelIp, final String elanInstanceName) {
if (designatedDpnId.equals(DhcpMConstants.INVALID_DPID)) {
return;
}
jobCoordinator.enqueueJob(getJobKey(elanInstanceName), () -> {
if (!entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE, HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
LOG.info("Installing remote McastMac is not executed for this node.");
return Collections.emptyList();
}
LOG.info("Installing remote McastMac");
L2GatewayDevice device = getDeviceFromTunnelIp(tunnelIp);
if (device == null) {
LOG.error("Unable to get L2Device for tunnelIp {} and elanInstanceName {}", tunnelIp, elanInstanceName);
return Collections.emptyList();
}
String tunnelInterfaceName = getExternalTunnelInterfaceName(String.valueOf(designatedDpnId), device.getHwvtepNodeId());
if (tunnelInterfaceName != null) {
Interface tunnelInterface = interfaceManager.getInterfaceInfoFromConfigDataStore(tunnelInterfaceName);
if (tunnelInterface == null) {
LOG.trace("Tunnel Interface is not present {}", tunnelInterfaceName);
return Collections.emptyList();
}
return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> putRemoteMcastMac(tx, elanInstanceName, device, tunnelInterface.getAugmentation(IfTunnel.class).getTunnelSource())));
}
return Collections.emptyList();
});
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel in project netvirt by opendaylight.
the class DhcpExternalTunnelManager method getExternalTunnelInterfaceName.
public String getExternalTunnelInterfaceName(String sourceNode, String dstNode) {
String tunnelInterfaceName = null;
Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
try {
Future<RpcResult<GetExternalTunnelInterfaceNameOutput>> output = itmRpcService.getExternalTunnelInterfaceName(new GetExternalTunnelInterfaceNameInputBuilder().setSourceNode(sourceNode).setDestinationNode(dstNode).setTunnelType(tunType).build());
RpcResult<GetExternalTunnelInterfaceNameOutput> rpcResult = output.get();
if (rpcResult.isSuccessful()) {
tunnelInterfaceName = rpcResult.getResult().getInterfaceName();
LOG.trace("Tunnel interface name: {}", tunnelInterfaceName);
} else {
LOG.warn("RPC call to ITM.GetExternalTunnelInterfaceName failed with error: {}", rpcResult.getErrors());
}
} catch (NullPointerException | InterruptedException | ExecutionException e) {
LOG.error("Failed to get external tunnel interface name for sourceNode: {} and dstNode: {}", sourceNode, dstNode, e);
}
return tunnelInterfaceName;
}
Aggregations