use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel in project genius by opendaylight.
the class TepCommandHelperTest method setupMocks.
private void setupMocks() {
System.setOut(new PrintStream(outContent));
instanceIdentifierList.add(transportZoneIdentifier);
instanceIdentifierList.add(vtepsIdentifier);
instanceIdentifierList.add(subnetsIdentifier);
DeviceVteps deviceVteps = new DeviceVtepsBuilder().setIpAddress(ipAddress1).setKey(new DeviceVtepsKey(ipAddress1, sourceDevice)).setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
vteps = new VtepsBuilder().setPortname(portName1).setDpnId(dpId2).setIpAddress(ipAddress1).setKey(new VtepsKey(dpId2, portName1)).build();
vtepsTest = new VtepsBuilder().build();
deviceVtepsList.add(deviceVteps);
vtepsList.add(vteps);
subnetsTest = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).setKey(new SubnetsKey(ipPrefixTest)).setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
subnetsList.add(subnetsTest);
transportZone = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType1).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
transportZoneNew = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType2).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
transportZoneList.add(transportZone);
transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
transportZonesNew = new TransportZonesBuilder().setTransportZone(transportZoneListNew).build();
tunnelMonitorInterval = new TunnelMonitorIntervalBuilder().setInterval(10000).build();
tunnelMonitorParams = new TunnelMonitorParamsBuilder().setEnabled(true).build();
InternalTunnel internalTunnelTest = new InternalTunnelBuilder().setSourceDPN(dpId1).setDestinationDPN(dpId2).setTunnelInterfaceNames(Collections.singletonList(tunnelInterfaceName)).setKey(new InternalTunnelKey(dpId1, dpId2, tunnelType1)).setTransportType(tunnelType1).build();
internalTunnelList.add(internalTunnelTest);
StateTunnelList stateTunnelListTest = new StateTunnelListBuilder().setTunnelInterfaceName(tunnelInterfaceName).setOperState(TunnelOperStatus.Up).build();
stateTunnelList.add(stateTunnelListTest);
lowerLayerIfList.add(dpId1.toString());
interfaceTest = new InterfaceBuilder().setOperStatus(Interface.OperStatus.Up).setAdminStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus.Up).setPhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress.getDefaultInstance("AA:AA:AA:AA:AA:AA")).setIfIndex(100).setLowerLayerIf(lowerLayerIfList).setType(L2vlan.class).build();
interfaceTestNew = ItmUtils.buildTunnelInterface(dpId1, tunnelInterfaceName, destinationDevice, enabled, TunnelTypeVxlan.class, ipAddress1, ipAddress2, gtwyIp1, vlanId, true, enabled, monitorProtocol, interval, false, null);
doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel in project genius by opendaylight.
the class ItmUtils method getTunnelsofTzone.
public static List<String> getTunnelsofTzone(List<HwVtep> hwVteps, String tzone, DataBroker dataBroker, Boolean hwVtepsExist) {
List<String> tunnels = new ArrayList<>();
InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzone)).build();
Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
if (transportZoneOptional.isPresent()) {
TransportZone transportZone = transportZoneOptional.get();
Class<? extends TunnelTypeBase> tunType = transportZone.getTunnelType();
if (transportZone.getSubnets() != null && !transportZone.getSubnets().isEmpty()) {
for (Subnets sub : transportZone.getSubnets()) {
if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
for (Vteps vtepLocal : sub.getVteps()) {
for (Vteps vtepRemote : sub.getVteps()) {
if (!vtepLocal.equals(vtepRemote)) {
InternalTunnelKey key = new InternalTunnelKey(vtepRemote.getDpnId(), vtepLocal.getDpnId(), tunType);
InstanceIdentifier<InternalTunnel> intIID = InstanceIdentifier.builder(TunnelList.class).child(InternalTunnel.class, key).build();
Optional<InternalTunnel> tunnelsOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, intIID, dataBroker);
if (tunnelsOptional.isPresent()) {
List<String> tunnelInterfaceNames = tunnelsOptional.get().getTunnelInterfaceNames();
if (tunnelInterfaceNames != null && !tunnelInterfaceNames.isEmpty()) {
String tunnelInterfaceName = tunnelInterfaceNames.get(0);
LOG.trace("Internal Tunnel added {}", tunnelInterfaceName);
tunnels.add(tunnelInterfaceName);
}
}
}
}
if (hwVteps != null && !hwVteps.isEmpty()) {
for (HwVtep hwVtep : hwVteps) {
tunnels.add(getExtTunnel(hwVtep.getNodeId(), vtepLocal.getDpnId().toString(), tunType, dataBroker));
tunnels.add(getExtTunnel(vtepLocal.getDpnId().toString(), hwVtep.getNodeId(), tunType, dataBroker));
}
}
}
}
}
}
if (hwVtepsExist) {
for (HwVtep hwVtep : hwVteps) {
for (HwVtep hwVtepOther : hwVteps) {
if (!hwVtep.getHwIp().equals(hwVtepOther.getHwIp())) {
tunnels.add(getExtTunnel(hwVtep.getNodeId(), hwVtepOther.getNodeId(), tunType, dataBroker));
tunnels.add(getExtTunnel(hwVtepOther.getNodeId(), hwVtep.getNodeId(), tunType, dataBroker));
}
}
}
}
}
return tunnels;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel 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