use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameInput in project genius by opendaylight.
the class ItmManagerRpcServiceTest method setupMocks.
private void setupMocks() {
deviceVteps = new DeviceVtepsBuilder().setIpAddress(ipAddress1).setKey(new DeviceVtepsKey(ipAddress1, "abc")).setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
deviceVtepsList.add(deviceVteps);
stringList.add(sourceDevice);
dpId1List.add(dpId1);
stringList.add("def");
trunkInterfaceName = ItmUtils.getTrunkInterfaceName(tunnelInterfaceName, String.valueOf(ipAddress1.getValue()), String.valueOf(ipAddress1.getValue()), tunnelType1.getName());
interfaceIdentifier = ItmUtils.buildId(trunkInterfaceName);
tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName1).setIpAddress(ipAddress1).setGwIpAddress(gtwyIp1).setInterfaceName(tunnelInterfaceName).setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType1).setSubnetMask(ipPrefixTest).setKey(new TunnelEndPointsKey(ipAddress1, portName1, tunnelType1, vlanId)).build();
tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(dpId1).setKey(new DPNTEPsInfoKey(dpId1)).setUp(true).setTunnelEndPoints(tunnelEndPointsListVxlan).build();
cfgdDpnListVxlan.add(dpntePsInfoVxlan);
dpnEndpoints = new DpnEndpointsBuilder().setDPNTEPsInfo(cfgdDpnListVxlan).build();
externalTunnel = new ExternalTunnelBuilder().setSourceDevice(sourceDevice).setDestinationDevice(destinationDevice).setTransportType(tunnelType1).setTunnelInterfaceName(tunnelInterfaceName).setKey(new ExternalTunnelKey(destinationDevice, sourceDevice, tunnelType1)).build();
internalTunnel = new InternalTunnelBuilder().setTunnelInterfaceNames(Collections.singletonList(tunnelInterfaceName)).setDestinationDPN(dpId2).setSourceDPN(dpId1).setTransportType(tunnelType1).setKey(new InternalTunnelKey(dpId2, dpId1, tunnelType1)).build();
getInternalOrExternalInterfaceNameInput = new GetInternalOrExternalInterfaceNameInputBuilder().setDestinationIp(ipAddress1).setSourceDpid(dpId1).setTunnelType(tunnelType2).build();
addExternalTunnelEndpointInput = new AddExternalTunnelEndpointInputBuilder().setTunnelType(tunnelType1).setDestinationIp(ipAddress1).build();
addL2GwDeviceInput = new AddL2GwDeviceInputBuilder().setIpAddress(ipAddress1).setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
deleteL2GwDeviceInput = new DeleteL2GwDeviceInputBuilder().setIpAddress(ipAddress1).setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
addL2GwMlagDeviceInput = new AddL2GwMlagDeviceInputBuilder().setIpAddress(ipAddress1).setNodeId(stringList).setTopologyId(destinationDevice).build();
deleteL2GwMlagDeviceInput = new DeleteL2GwMlagDeviceInputBuilder().setIpAddress(ipAddress1).setNodeId(stringList).setTopologyId(destinationDevice).build();
buildExternalTunnelFromDpnsInput = new BuildExternalTunnelFromDpnsInputBuilder().setTunnelType(tunnelType1).setDestinationIp(ipAddress1).setDpnId(dpId1List).build();
removeExternalTunnelFromDpnsInput = new RemoveExternalTunnelFromDpnsInputBuilder().setTunnelType(tunnelType1).setDestinationIp(ipAddress1).setDpnId(dpId1List).build();
removeExternalTunnelEndpointInput = new RemoveExternalTunnelEndpointInputBuilder().setTunnelType(tunnelType1).setDestinationIp(ipAddress1).build();
removeTerminatingServiceActionsInput = new RemoveTerminatingServiceActionsInputBuilder().setServiceId(vlanId).setDpnId(dpId1).build();
getTunnelInterfaceNameInput = new GetTunnelInterfaceNameInputBuilder().setTunnelType(tunnelType1).setSourceDpid(dpId1).setDestinationDpid(dpId2).build();
getExternalTunnelInterfaceNameInput = new GetExternalTunnelInterfaceNameInputBuilder().setTunnelType(tunnelType1).setDestinationNode(destinationDevice).setSourceNode(sourceDevice).build();
iface = ItmUtils.buildTunnelInterface(dpId1, trunkInterfaceName, String.format("%s %s", ItmUtils.convertTunnelTypetoString(tunnelType1), "Trunk Interface"), true, tunnelType1, tunnelEndPointsVxlan.getIpAddress(), ipAddress1, gtwyIp1, tunnelEndPointsVxlan.getVLANID(), false, false, monitorProtocol, null, false, null);
subnetsTest = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).setKey(new SubnetsKey(ipPrefixTest)).setDeviceVteps(deviceVtepsList).build();
subnetsList.add(subnetsTest);
transportZone = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType1).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
transportZoneList.add(transportZone);
transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
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.rpcs.rev160406.GetInternalOrExternalInterfaceNameInput in project genius by opendaylight.
the class ItmManagerRpcService method getInternalOrExternalInterfaceName.
@Override
public Future<RpcResult<GetInternalOrExternalInterfaceNameOutput>> getInternalOrExternalInterfaceName(GetInternalOrExternalInterfaceNameInput input) {
RpcResultBuilder<GetInternalOrExternalInterfaceNameOutput> resultBld = RpcResultBuilder.failed();
BigInteger srcDpn = input.getSourceDpid();
IpAddress dstIp = input.getDestinationIp();
InstanceIdentifier<ExternalTunnel> path1 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(String.valueOf(dstIp.getValue()), srcDpn.toString(), input.getTunnelType()));
Optional<ExternalTunnel> optExtTunnel = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path1, dataBroker);
if (optExtTunnel != null && optExtTunnel.isPresent()) {
ExternalTunnel extTunnel = optExtTunnel.get();
GetInternalOrExternalInterfaceNameOutputBuilder output = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(extTunnel.getTunnelInterfaceName());
resultBld = RpcResultBuilder.success();
resultBld.withResult(output.build());
} else {
Collection<DPNTEPsInfo> meshedDpnList = dpnTEPsInfoCache.getAllPresent();
// Look for external tunnels if not look for internal tunnel
for (DPNTEPsInfo teps : meshedDpnList) {
TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
if (dstIp.equals(firstEndPt.getIpAddress())) {
Optional<InternalTunnel> optTunnel = Optional.absent();
if (ItmUtils.isTunnelAggregationUsed(input.getTunnelType())) {
optTunnel = ItmUtils.getInternalTunnelFromDS(srcDpn, teps.getDPNID(), TunnelTypeLogicalGroup.class, dataBroker);
LOG.debug("MULTIPLE_VxLAN_TUNNELS: getInternalOrExternalInterfaceName {}", optTunnel);
}
if (!optTunnel.isPresent()) {
optTunnel = ItmUtils.getInternalTunnelFromDS(srcDpn, teps.getDPNID(), input.getTunnelType(), dataBroker);
}
if (optTunnel.isPresent()) {
InternalTunnel tunnel = optTunnel.get();
List<String> tunnelInterfaces = tunnel.getTunnelInterfaceNames();
if (tunnelInterfaces != null && !tunnelInterfaces.isEmpty()) {
GetInternalOrExternalInterfaceNameOutputBuilder output = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(tunnelInterfaces.get(0));
resultBld = RpcResultBuilder.success();
resultBld.withResult(output.build());
} else {
LOG.error("No tunnel interface found between source DPN {} ans destination IP {}", srcDpn, dstIp);
}
break;
} else {
LOG.error("Tunnel not found for source DPN {} ans destination IP {}", srcDpn, dstIp);
}
}
}
}
return Futures.immediateFuture(resultBld.build());
}
Aggregations