use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project genius by opendaylight.
the class TepCommandHelper method configureTunnelType.
public void configureTunnelType(String transportZoneName, String tunnelType) {
LOG.debug("configureTunnelType {} for transportZone {}", tunnelType, transportZoneName);
TransportZone transportZoneFromConfigDS = ItmUtils.getTransportZoneFromConfigDS(transportZoneName, dataBroker);
Class<? extends TunnelTypeBase> tunType;
validateTunnelType(transportZoneName, tunnelType, transportZoneFromConfigDS);
if (transportZoneFromConfigDS != null) {
if (!transportZoneName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
LOG.debug("Transport zone {} with tunnel type {} already exists. No action required.", transportZoneName, tunnelType);
return;
} else {
tunnelType = StringUtils.upperCase(tunnelType);
tunType = ItmUtils.TUNNEL_TYPE_MAP.get(tunnelType);
if (transportZoneFromConfigDS.getTunnelType().equals(tunType)) {
// controller restart, then nothing to do now. Just return.
return;
}
}
}
// get tunnel-type
tunnelType = StringUtils.upperCase(tunnelType);
tunType = ItmUtils.TUNNEL_TYPE_MAP.get(tunnelType);
TransportZones transportZones = null;
List<TransportZone> tzList = null;
InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
Optional<TransportZones> tzones = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
TransportZone tzone = new TransportZoneBuilder().setKey(new TransportZoneKey(transportZoneName)).setTunnelType(tunType).build();
if (tzones.isPresent()) {
tzList = tzones.get().getTransportZone();
if (tzList == null || tzList.isEmpty()) {
tzList = new ArrayList<>();
}
} else {
tzList = new ArrayList<>();
}
tzList.add(tzone);
transportZones = new TransportZonesBuilder().setTransportZone(tzList).build();
ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, path, transportZones, dataBroker);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project genius by opendaylight.
the class ItmExternalTunnelAddWorker method wireUp.
// for tunnels from TOR device
private boolean wireUp(String topoId, String srcNodeid, IpAddress srcIp, String dstNodeId, IpAddress dstIp, IpPrefix srcSubnet, IpAddress gwIp, IpPrefix dstSubnet, Class<? extends TunnelTypeBase> tunType, Boolean monitorEnabled, Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, WriteTransaction transaction) {
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
IpAddress gwyIpAddress = srcSubnet.equals(dstSubnet) ? gatewayIpObj : gwIp;
String parentIf = ItmUtils.getHwParentIf(topoId, srcNodeid);
String tunTypeStr = tunType.getName();
String tunnelIfName = ItmUtils.getTrunkInterfaceName(parentIf, new String(srcIp.getValue()), new String(dstIp.getValue()), tunTypeStr);
LOG.debug(" Creating ExternalTrunk Interface with parameters Name - {}, parent I/f name - {}, " + "source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp, dstIp, gwyIpAddress);
Interface hwTunnelIf = ItmUtils.buildHwTunnelInterface(tunnelIfName, String.format("%s %s", tunType.getName(), "Trunk Interface"), true, topoId, srcNodeid, tunType, srcIp, dstIp, gwyIpAddress, monitorEnabled, monitorProtocol, monitorInterval);
InstanceIdentifier<Interface> ifIID = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey(tunnelIfName)).build();
LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", ifIID, hwTunnelIf);
ItmUtils.ITM_CACHE.addInterface(hwTunnelIf);
transaction.merge(LogicalDatastoreType.CONFIGURATION, ifIID, hwTunnelIf, true);
// also update itm-state ds?
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dstNodeId), getExternalTunnelKey(srcNodeid), tunType));
ExternalTunnel tnl = ItmUtils.buildExternalTunnel(getExternalTunnelKey(srcNodeid), getExternalTunnelKey(dstNodeId), tunType, tunnelIfName);
transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true);
ItmUtils.ITM_CACHE.addExternalTunnel(tnl);
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project genius by opendaylight.
the class ItmExternalTunnelAddWorker method tunnelsFromhWVtep.
private void tunnelsFromhWVtep(List<HwVtep> cfgdHwVteps, WriteTransaction transaction, Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol) {
for (HwVtep hwTep : cfgdHwVteps) {
InstanceIdentifier<TransportZone> tzonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(hwTep.getTransportZone())).build();
Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, tzonePath, dataBroker);
Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
if (transportZoneOptional.isPresent()) {
TransportZone tzone = transportZoneOptional.get();
// do we need to check tunnel type?
if (tzone.getSubnets() != null && !tzone.getSubnets().isEmpty()) {
for (Subnets sub : tzone.getSubnets()) {
if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
if (hwVtepDS.getIpAddress().equals(hwTep.getHwIp())) {
// dont mesh with self
continue;
}
LOG.trace("wire up {} and {}", hwTep, hwVtepDS);
if (!wireUp(hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), hwTep.getIpPrefix(), hwTep.getGatewayIP(), sub.getPrefix(), tunType, false, monitorInterval, monitorProtocol, transaction)) {
LOG.error("Unable to build tunnel {} -- {}", hwTep.getHwIp(), hwVtepDS.getIpAddress());
}
// TOR2-TOR1
LOG.trace("wire up {} and {}", hwVtepDS, hwTep);
if (!wireUp(hwTep.getTopoId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), hwTep.getNodeId(), hwTep.getHwIp(), sub.getPrefix(), sub.getGatewayIp(), hwTep.getIpPrefix(), tunType, false, monitorInterval, monitorProtocol, transaction)) {
LOG.error("Unable to build tunnel {} -- {}", hwVtepDS.getIpAddress(), hwTep.getHwIp());
}
}
}
if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
for (Vteps vtep : sub.getVteps()) {
if (vtep.getIpAddress().equals(hwTep.getHwIp())) {
continue;
}
// TOR-OVS
String cssID = vtep.getDpnId().toString();
LOG.trace("wire up {} and {}", hwTep, vtep);
if (!wireUp(hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), cssID, vtep.getIpAddress(), hwTep.getIpPrefix(), hwTep.getGatewayIP(), sub.getPrefix(), tunType, false, monitorInterval, monitorProtocol, transaction)) {
LOG.error("Unable to build tunnel {} -- {}", hwTep.getHwIp(), vtep.getIpAddress());
}
// OVS-TOR
LOG.trace("wire up {} and {}", vtep, hwTep);
boolean useOfTunnel = ItmUtils.falseIfNull(vtep.isOptionOfTunnel());
if (!wireUp(vtep.getDpnId(), vtep.getPortname(), sub.getVlanId(), vtep.getIpAddress(), useOfTunnel, hwTep.getNodeId(), hwTep.getHwIp(), sub.getPrefix(), sub.getGatewayIp(), hwTep.getIpPrefix(), tunType, false, monitorInterval, monitorProtocol, transaction)) {
LOG.debug("wireUp returned false");
}
}
}
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project genius by opendaylight.
the class ItmExternalTunnelDeleteWorker method deleteTunnels.
public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, Collection<DPNTEPsInfo> dpnTepsList, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
LOG.trace(" Delete Tunnels towards DC Gateway with Ip {}", extIp);
if (dpnTepsList == null || dpnTepsList.isEmpty()) {
LOG.debug("no vtep to delete");
return Collections.emptyList();
}
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
for (DPNTEPsInfo teps : dpnTepsList) {
TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
String interfaceName = firstEndPt.getInterfaceName();
String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName, new String(firstEndPt.getIpAddress().getValue()), new String(extIp.getValue()), tunType.getName());
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
ItmUtils.ITM_CACHE.removeInterface(trunkInterfaceName);
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, ItmUtils.getExternalTunnelKey(String.valueOf(extIp.getValue()), teps.getDPNID().toString(), tunType));
writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, path);
LOG.debug("Deleting tunnel towards DC gateway, Tunnel interface name {} ", trunkInterfaceName);
ItmUtils.ITM_CACHE.removeExternalTunnel(trunkInterfaceName);
// Release the Ids for the trunk interface Name
ItmUtils.releaseIdForTrunkInterfaceName(interfaceName, new String(firstEndPt.getIpAddress().getValue()), new String(extIp.getValue()), tunType.getName());
}
return Collections.singletonList(writeTransaction.submit());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project genius by opendaylight.
the class ItmInternalTunnelAddWorker method createInternalTunnel.
private static void createInternalTunnel(BigInteger srcDpnId, BigInteger dstDpnId, Class<? extends TunnelTypeBase> tunType, String trunkInterfaceName, WriteTransaction transaction) {
InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(TunnelList.class).child(InternalTunnel.class, new InternalTunnelKey(dstDpnId, srcDpnId, tunType));
InternalTunnel tnl = ItmUtils.buildInternalTunnel(srcDpnId, dstDpnId, tunType, trunkInterfaceName);
// Switching to individual transaction submit as batching latencies is causing ELAN failures.
// Will revert when ELAN can handle this.
// ITMBatchingUtils.update(path, tnl, ITMBatchingUtils.EntityType.DEFAULT_CONFIG);
transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true);
ItmUtils.ITM_CACHE.addInternalTunnel(tnl);
}
Aggregations