use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project genius by opendaylight.
the class ItmTepAddWorker method call.
@Override
public List<ListenableFuture<Void>> call() {
List<ListenableFuture<Void>> futures = new ArrayList<>();
this.meshedDpnList = ItmUtils.getDpnTEPsInfos(dataBroker);
LOG.debug("Invoking Internal Tunnel build method with Configured DpnList {} ; Meshed DpnList {} ", cfgdDpnList, meshedDpnList);
futures.addAll(itmInternalTunnelAddWorker.buildAllTunnels(mdsalManager, cfgdDpnList, meshedDpnList));
// IF EXTERNAL TUNNELS NEEDS TO BE BUILT, DO IT HERE. IT COULD BE TO DC GATEWAY OR TOR SWITCH
List<DcGatewayIp> dcGatewayIpList = ItmUtils.getDcGatewayIpList(dataBroker);
if (dcGatewayIpList != null && !dcGatewayIpList.isEmpty()) {
for (DcGatewayIp dcGatewayIp : dcGatewayIpList) {
futures.addAll(externalTunnelAddWorker.buildTunnelsToExternalEndPoint(cfgdDpnList, dcGatewayIp.getIpAddress(), dcGatewayIp.getTunnnelType()));
}
}
// futures.addAll(ItmExternalTunnelAddWorker.buildTunnelsToExternalEndPoint(dataBroker,meshedDpnList, extIp) ;
LOG.debug("invoking build hwVtepTunnels with hwVteplist {}", cfgdHwVteps);
futures.addAll(externalTunnelAddWorker.buildHwVtepsTunnels(cfgdDpnList, cfgdHwVteps));
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project genius by opendaylight.
the class ItmTepRemoveWorker method call.
@Override
public List<ListenableFuture<Void>> call() {
List<ListenableFuture<Void>> futures = new ArrayList<>();
this.meshedDpnList = dpnTEPsInfoCache.getAllPresent();
futures.addAll(itmInternalTunnelDeleteWorker.deleteTunnels(mdsalManager, delDpnList, meshedDpnList));
LOG.debug("Invoking Internal Tunnel delete method with DpnList to be deleted {} ; Meshed DpnList {} ", delDpnList, meshedDpnList);
// IF EXTERNAL TUNNELS NEEDS TO BE DELETED, DO IT HERE, IT COULD BE TO DC GATEWAY OR TOR SWITCH
List<DcGatewayIp> dcGatewayIpList = ItmUtils.getDcGatewayIpList(dataBroker);
if (dcGatewayIpList != null && !dcGatewayIpList.isEmpty()) {
List<DPNTEPsInfo> dpnDeleteList = new ArrayList<>();
for (DPNTEPsInfo dpnTEPInfo : delDpnList) {
List<TunnelEndPoints> tunnelEndPointsList = dpnTEPInfo.getTunnelEndPoints();
if (tunnelEndPointsList.size() == 1) {
dpnDeleteList.add(dpnTEPInfo);
} else {
LOG.error("DPNTEPInfo not available in data store for dpnId {}. Unable to delete external tunnel " + "for dpn ", dpnTEPInfo.getDPNID());
}
}
for (DcGatewayIp dcGatewayIp : dcGatewayIpList) {
futures.addAll(ItmExternalTunnelDeleteWorker.deleteTunnels(dataBroker, dpnDeleteList, meshedDpnList, dcGatewayIp.getIpAddress(), dcGatewayIp.getTunnnelType()));
}
}
futures.addAll(ItmExternalTunnelDeleteWorker.deleteHwVtepsTunnels(dataBroker, delDpnList, cfgdHwVteps, this.originalTZone));
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project genius by opendaylight.
the class TepCommandHelper method showTeps.
@SuppressWarnings("checkstyle:RegexpSinglelineJava")
public void showTeps(boolean monitorEnabled, int monitorInterval, CommandSession session) throws TepException {
boolean flag = false;
InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
if (transportZonesOptional.isPresent()) {
TransportZones transportZones = transportZonesOptional.get();
if (transportZones.getTransportZone() == null || transportZones.getTransportZone().isEmpty()) {
handleError("No teps configured", session);
return;
}
List<String> result = new ArrayList<>();
result.add(String.format("Tunnel Monitoring (for VXLAN tunnels): %s", monitorEnabled ? "On" : "Off"));
result.add(String.format("Tunnel Monitoring Interval (for VXLAN tunnels): %d", monitorInterval));
result.add(System.lineSeparator());
result.add(String.format("%-16s %-16s %-16s %-12s %-12s %-12s %-16s %-12s", "TransportZone", "TunnelType", "SubnetMask", "GatewayIP", "VlanID", "DpnID", "IPAddress", "PortName"));
result.add("---------------------------------------------------------------------------------------------" + "---------------------------------");
for (TransportZone tz : transportZones.getTransportZone()) {
if (tz.getSubnets() == null || tz.getSubnets().isEmpty()) {
LOG.error("Transport Zone {} has no subnets", tz.getZoneName());
continue;
}
for (Subnets sub : tz.getSubnets()) {
if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
LOG.error("Transport Zone {} subnet {} has no vteps", tz.getZoneName(), sub.getPrefix());
continue;
}
for (Vteps vtep : sub.getVteps()) {
flag = true;
String strTunnelType;
if (tz.getTunnelType().equals(TunnelTypeGre.class)) {
strTunnelType = ITMConstants.TUNNEL_TYPE_GRE;
} else {
strTunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
}
result.add(String.format("%-16s %-16s %-16s %-12s %-12s %-12s %-16s %-12s", tz.getZoneName(), strTunnelType, new String(sub.getPrefix().getValue()), new String(sub.getGatewayIp().getValue()), sub.getVlanId().toString(), vtep.getDpnId().toString(), new String(vtep.getIpAddress().getValue()), vtep.getPortname()));
}
}
}
if (session != null) {
if (flag) {
for (String print : result) {
System.out.println(print);
}
} else {
System.out.println("No teps to display");
}
}
} else if (session != null) {
System.out.println("No teps configured");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels 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.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels 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());
}
Aggregations