use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.
the class ItmTunnelAggregationHelper method updateLogicalTunnelState.
public void updateLogicalTunnelState(Interface ifStateOrigin, Interface ifStateUpdated, int tunnelAction, DataBroker broker) {
if (!tunnelAggregationEnabled || ifStateUpdated == null) {
LOG.debug("MULTIPLE_VxLAN_TUNNELS: updateLogicalTunnelState - wrong configuration -" + " tunnelAggregationEnabled {} ifStateUpdated {}", tunnelAggregationEnabled, ifStateUpdated);
return;
}
String ifName = ifStateUpdated.getName();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = ItmUtils.getInterface(ifName, interfaceManager);
IfTunnel ifTunnel = iface != null ? iface.getAugmentation(IfTunnel.class) : null;
if (iface == null || ifTunnel == null) {
LOG.debug("MULTIPLE_VxLAN_TUNNELS: updateLogicalTunnelState - not tunnel interface {}", ifName);
return;
}
String logicTunnelName = null;
if (ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeLogicalGroup.class)) {
logicTunnelName = ifStateUpdated.getName();
} else {
ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
if (ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class) && parentRefs != null) {
logicTunnelName = parentRefs.getParentInterface();
}
}
if (logicTunnelName != null) {
TunnelAggregationUpdateWorker worker = new TunnelAggregationUpdateWorker(ifStateOrigin, ifStateUpdated, iface, null, tunnelAction, broker);
jobCoordinator.enqueueJob(logicTunnelName, worker);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.
the class ItmExternalTunnelAddWorker method createTunnelsFromOVSinTransportZone.
private void createTunnelsFromOVSinTransportZone(String zoneName, DPNTEPsInfo dpn, TunnelEndPoints tep, WriteTransaction transaction, Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol) {
InstanceIdentifier<TransportZone> tzonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(zoneName)).build();
Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, tzonePath, dataBroker);
if (transportZoneOptional.isPresent()) {
TransportZone transportZone = transportZoneOptional.get();
// do we need to check tunnel type?
if (transportZone.getSubnets() != null && !transportZone.getSubnets().isEmpty()) {
for (Subnets sub : transportZone.getSubnets()) {
if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
// dont mesh if hwVteps and OVS-tep have same ip-address
if (hwVtepDS.getIpAddress().equals(tep.getIpAddress())) {
continue;
}
final String cssID = dpn.getDPNID().toString();
String nodeId = hwVtepDS.getNodeId();
boolean useOfTunnel = ItmUtils.falseIfNull(tep.isOptionOfTunnel());
LOG.trace("wire up {} and {}", tep, hwVtepDS);
if (!wireUp(dpn.getDPNID(), tep.getPortname(), sub.getVlanId(), tep.getIpAddress(), useOfTunnel, nodeId, hwVtepDS.getIpAddress(), tep.getSubnetMask(), sub.getGatewayIp(), sub.getPrefix(), transportZone.getTunnelType(), false, monitorInterval, monitorProtocol, transaction)) {
LOG.error("Unable to build tunnel {} -- {}", tep.getIpAddress(), hwVtepDS.getIpAddress());
}
// TOR-OVS
LOG.trace("wire up {} and {}", hwVtepDS, tep);
if (!wireUp(hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), cssID, tep.getIpAddress(), sub.getPrefix(), sub.getGatewayIp(), tep.getSubnetMask(), transportZone.getTunnelType(), false, monitorInterval, monitorProtocol, transaction)) {
LOG.error("Unable to build tunnel {} -- {}", hwVtepDS.getIpAddress(), tep.getIpAddress());
}
}
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.
the class ItmExternalTunnelDeleteWorker method tunnelsDeletion.
private static void tunnelsDeletion(List<DPNTEPsInfo> cfgdDpnList, List<HwVtep> cfgdhwVteps, TransportZone originalTZone, WriteTransaction writeTransaction, DataBroker dataBroker) {
if (cfgdDpnList != null) {
for (DPNTEPsInfo dpn : cfgdDpnList) {
if (dpn.getTunnelEndPoints() != null) {
for (TunnelEndPoints srcTep : dpn.getTunnelEndPoints()) {
for (TzMembership zone : srcTep.getTzMembership()) {
deleteTunnelsInTransportZone(zone.getZoneName(), dpn, srcTep, cfgdhwVteps, dataBroker, writeTransaction);
}
}
}
}
}
if (cfgdhwVteps != null && !cfgdhwVteps.isEmpty()) {
for (HwVtep hwTep : cfgdhwVteps) {
LOG.trace("processing hwTep from list {}", hwTep);
for (HwVtep hwTepRemote : cfgdhwVteps) {
if (!hwTep.getHwIp().equals(hwTepRemote.getHwIp())) {
deleteTrunksTorTor(dataBroker, hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), hwTepRemote.getTopoId(), hwTepRemote.getNodeId(), hwTepRemote.getHwIp(), TunnelTypeVxlan.class, writeTransaction);
}
}
// do we need to check tunnel type?
LOG.trace("subnets under tz {} are {}", originalTZone.getZoneName(), originalTZone.getSubnets());
if (originalTZone.getSubnets() != null && !originalTZone.getSubnets().isEmpty()) {
for (Subnets sub : originalTZone.getSubnets()) {
if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
LOG.trace("hwtepDS exists {}", hwVtepDS);
// for mlag case and non-m-lag case, isnt it enough to just check ipaddress?
if (hwVtepDS.getIpAddress().equals(hwTep.getHwIp())) {
// dont delete tunnels with self
continue;
}
// TOR-TOR
LOG.trace("deleting tor-tor {} and {}", hwTep, hwVtepDS);
deleteTrunksTorTor(dataBroker, hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), originalTZone.getTunnelType(), writeTransaction);
}
}
if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
for (Vteps vtep : sub.getVteps()) {
// TOR-OVS
LOG.trace("deleting tor-css-tor {} and {}", hwTep, vtep);
String parentIf = ItmUtils.getInterfaceName(vtep.getDpnId(), vtep.getPortname(), sub.getVlanId());
deleteTrunksOvsTor(dataBroker, vtep.getDpnId(), parentIf, vtep.getIpAddress(), hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), originalTZone.getTunnelType(), writeTransaction);
}
}
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.
the class IfmUtil method getEgressActionInfosForInterface.
/**
* Returns the list of egress actions for a given interface.
*
* @param interfaceInfo the interface to look up
* @param portNo port number
* @param ifaceType the type of the interface
* @param tunnelKey the tunnel key
* @param actionKeyStart the start for the first key assigned for the new actions
* @param isDefaultEgress if it is the default egress
* @param ifIndex interface index
* @param groupId group Id
* @return list of actions for the interface
*/
// The following suppression is for javac, not for checkstyle
@SuppressWarnings("fallthrough")
@SuppressFBWarnings("SF_SWITCH_FALLTHROUGH")
public static List<ActionInfo> getEgressActionInfosForInterface(Interface interfaceInfo, String portNo, InterfaceInfo.InterfaceType ifaceType, Long tunnelKey, int actionKeyStart, boolean isDefaultEgress, int ifIndex, long groupId) {
List<ActionInfo> result = new ArrayList<>();
switch(ifaceType) {
case MPLS_OVER_GRE:
// fall through
case GRE_TRUNK_INTERFACE:
if (!isDefaultEgress) {
// stores the value coming from a VXLAN tunnel
if (tunnelKey == null) {
tunnelKey = 0L;
}
}
// fall through
case VXLAN_TRUNK_INTERFACE:
if (!isDefaultEgress) {
if (tunnelKey != null) {
result.add(new ActionSetFieldTunnelId(actionKeyStart++, BigInteger.valueOf(tunnelKey)));
}
} else {
// For OF Tunnels default egress actions need to set tunnelIps
IfTunnel ifTunnel = interfaceInfo.getAugmentation(IfTunnel.class);
if (BooleanUtils.isTrue(ifTunnel.isTunnelRemoteIpFlow() && ifTunnel.getTunnelDestination() != null)) {
result.add(new ActionSetTunnelDestinationIp(actionKeyStart++, ifTunnel.getTunnelDestination()));
}
if (BooleanUtils.isTrue(ifTunnel.isTunnelSourceIpFlow() && ifTunnel.getTunnelSource() != null)) {
result.add(new ActionSetTunnelSourceIp(actionKeyStart++, ifTunnel.getTunnelSource()));
}
}
// fall through
case VLAN_INTERFACE:
if (isDefaultEgress) {
IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
LOG.trace("get egress actions for l2vlan interface: {}", vlanIface);
boolean isVlanTransparent = false;
int vlanVid = 0;
if (vlanIface != null) {
vlanVid = vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue();
isVlanTransparent = vlanIface.getL2vlanMode() == IfL2vlan.L2vlanMode.Transparent;
}
if (vlanVid != 0 && !isVlanTransparent) {
result.add(new ActionPushVlan(actionKeyStart++));
result.add(new ActionSetFieldVlanVid(actionKeyStart++, vlanVid));
}
result.add(new ActionOutput(actionKeyStart++, new Uri(portNo)));
} else {
addEgressActionInfosForInterface(ifIndex, actionKeyStart, result);
}
break;
case LOGICAL_GROUP_INTERFACE:
if (isDefaultEgress) {
result.add(new ActionGroup(groupId));
} else {
addEgressActionInfosForInterface(ifIndex, actionKeyStart, result);
}
break;
default:
LOG.warn("Interface Type {} not handled yet", ifaceType);
break;
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.
the class AlivenessMonitorUtils method startLLDPMonitoring.
public void startLLDPMonitoring(IfTunnel ifTunnel, String trunkInterfaceName) {
// LLDP monitoring for the tunnel interface
if (lldpMonitoringEnabled(ifTunnel)) {
MonitorStartInput lldpMonitorInput = new MonitorStartInputBuilder().setConfig(new ConfigBuilder().setSource(new SourceBuilder().setEndpointType(getInterfaceForMonitoring(trunkInterfaceName, ifTunnel.getTunnelSource())).build()).setMode(MonitoringMode.OneOne).setProfileId(allocateProfile(FAILURE_THRESHOLD, ifTunnel.getMonitorInterval(), MONITORING_WINDOW, EtherTypes.Lldp)).build()).build();
try {
Future<RpcResult<MonitorStartOutput>> result = alivenessMonitorService.monitorStart(lldpMonitorInput);
RpcResult<MonitorStartOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
long monitorId = rpcResult.getResult().getMonitorId();
ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
createOrUpdateInterfaceMonitorIdMap(tx, trunkInterfaceName, monitorId);
createOrUpdateMonitorIdInterfaceMap(tx, trunkInterfaceName, monitorId);
LOG.trace("Started LLDP monitoring with id {}", monitorId);
}), LOG, "Error starting monitoring");
} else {
LOG.warn("RPC Call to start monitoring returned with Errors {}", rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when starting monitoring", e);
}
}
}
Aggregations