use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project genius by opendaylight.
the class ItmUtils method buildLogicalTunnelInterface.
public static Interface buildLogicalTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled) {
InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).build();
builder.addAugmentation(ParentRefs.class, parentRefs);
IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_IP_ADDRESS)).setTunnelSource(IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_IP_ADDRESS)).setInternal(true).setMonitorEnabled(false).setTunnelInterfaceType(TunnelTypeLogicalGroup.class).setTunnelRemoteIpFlow(false).build();
builder.addAugmentation(IfTunnel.class, tunnel);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project genius by opendaylight.
the class ItmUtils method buildStateTunnelList.
public static StateTunnelList buildStateTunnelList(StateTunnelListKey tlKey, String name, boolean state, TunnelOperStatus tunOpStatus, IInterfaceManager ifaceManager, DataBroker broker) {
StateTunnelListBuilder stlBuilder = new StateTunnelListBuilder();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = ItmUtils.getInterface(name, ifaceManager);
IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
if (ifTunnel == null || parentRefs == null) {
return null;
}
DstInfoBuilder dstInfoBuilder = new DstInfoBuilder();
SrcInfoBuilder srcInfoBuilder = new SrcInfoBuilder();
dstInfoBuilder.setTepIp(ifTunnel.getTunnelDestination());
srcInfoBuilder.setTepIp(ifTunnel.getTunnelSource());
// TODO: Add/Improve logic for device type
InternalTunnel internalTunnel = ItmUtils.ITM_CACHE.getInternalTunnel(name);
ExternalTunnel externalTunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
if (internalTunnel == null && externalTunnel == null) {
// both not present in cache. let us update and try again.
ItmUtils.updateTunnelsCache(broker);
internalTunnel = ItmUtils.ITM_CACHE.getInternalTunnel(name);
externalTunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
}
if (internalTunnel != null) {
srcInfoBuilder.setTepDeviceId(internalTunnel.getSourceDPN().toString()).setTepDeviceType(TepTypeInternal.class);
dstInfoBuilder.setTepDeviceId(internalTunnel.getDestinationDPN().toString()).setTepDeviceType(TepTypeInternal.class);
stlBuilder.setTransportType(internalTunnel.getTransportType());
} else if (externalTunnel != null) {
ExternalTunnel tunnel = ItmUtils.ITM_CACHE.getExternalTunnel(name);
srcInfoBuilder.setTepDeviceId(tunnel.getSourceDevice()).setTepDeviceType(getDeviceType(tunnel.getSourceDevice()));
dstInfoBuilder.setTepDeviceId(tunnel.getDestinationDevice()).setTepDeviceType(getDeviceType(tunnel.getDestinationDevice())).setTepIp(ifTunnel.getTunnelDestination());
stlBuilder.setTransportType(tunnel.getTransportType());
}
stlBuilder.setKey(tlKey).setTunnelInterfaceName(name).setOperState(tunOpStatus).setTunnelState(state).setDstInfo(dstInfoBuilder.build()).setSrcInfo(srcInfoBuilder.build());
return stlBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project genius by opendaylight.
the class ItmUtils method buildHwTunnelInterface.
public static Interface buildHwTunnelInterface(String tunnelIfName, String desc, boolean enabled, String topoId, String nodeId, Class<? extends TunnelTypeBase> tunType, IpAddress srcIp, IpAddress destIp, IpAddress gwIp, Boolean monitorEnabled, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, Integer monitorInterval) {
InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(tunnelIfName)).setName(tunnelIfName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
List<NodeIdentifier> nodeIds = new ArrayList<>();
NodeIdentifier hwNode = new NodeIdentifierBuilder().setKey(new NodeIdentifierKey(topoId)).setTopologyId(topoId).setNodeId(nodeId).build();
nodeIds.add(hwNode);
ParentRefs parent = new ParentRefsBuilder().setNodeIdentifier(nodeIds).build();
builder.addAugmentation(ParentRefs.class, parent);
IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(destIp).setTunnelGateway(gwIp).setTunnelSource(srcIp).setMonitorEnabled(monitorEnabled == null || monitorEnabled).setMonitorProtocol(monitorProtocol == null ? ITMConstants.DEFAULT_MONITOR_PROTOCOL : monitorProtocol).setMonitorInterval(DEFAULT_MONITORING_INTERVAL).setTunnelInterfaceType(tunType).setInternal(false).build();
builder.addAugmentation(IfTunnel.class, tunnel);
LOG.trace("iftunnel {} built from hwvtep {} ", tunnel, nodeId);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project genius by opendaylight.
the class ItmMonitorIntervalWorker method toggle.
private void toggle(String tunnelInterfaceName, WriteTransaction transaction) {
if (tunnelInterfaceName != null) {
LOG.debug("tunnel {} will have monitor interval {}", tunnelInterfaceName, interval);
InstanceIdentifier<IfTunnel> trunkIdentifier = ItmUtils.buildTunnelId(tunnelInterfaceName);
IfTunnel tunnel = new IfTunnelBuilder().setMonitorInterval(interval.longValue()).build();
transaction.merge(LogicalDatastoreType.CONFIGURATION, trunkIdentifier, tunnel);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel in project genius by opendaylight.
the class ItmMonitorToggleWorker method toggle.
private void toggle(String tunnelInterfaceName, WriteTransaction transaction) {
if (tunnelInterfaceName != null) {
InstanceIdentifier<IfTunnel> trunkIdentifier = ItmUtils.buildTunnelId(tunnelInterfaceName);
LOG.debug("TunnelMonitorToggleWorker: tunnelInterfaceName: {}, monitorProtocol = {}, " + "monitorEnable = {} ", tunnelInterfaceName, monitorProtocol, enabled);
IfTunnel tunnel = new IfTunnelBuilder().setMonitorEnabled(enabled).setMonitorProtocol(monitorProtocol).build();
transaction.merge(LogicalDatastoreType.CONFIGURATION, trunkIdentifier, tunnel);
}
}
Aggregations