Search in sources :

Example 1 with GetInternalOrExternalInterfaceNameOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutputBuilder in project genius by opendaylight.

the class ItmManagerRpcServiceTest method setUp.

@Before
public void setUp() throws Exception {
    deviceVteps = new DeviceVtepsBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setKey(new DeviceVtepsKey(ItmTestConstants.IP_ADDRESS_3, ItmTestConstants.SOURCE_DEVICE)).setNodeId(ItmTestConstants.SOURCE_DEVICE).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
    deviceVtepsList.add(deviceVteps);
    stringList.add(ItmTestConstants.SOURCE_DEVICE);
    dpId1List.add(ItmTestConstants.DP_ID_1);
    stringList.add(ItmTestConstants.SOURCE_DEVICE_2);
    trunkInterfaceName = ItmUtils.getTrunkInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME, String.valueOf(ItmTestConstants.IP_ADDRESS_3.getValue()), String.valueOf(ItmTestConstants.IP_ADDRESS_3.getValue()), ItmTestConstants.TUNNEL_TYPE_VXLAN.getName());
    interfaceIdentifier = ItmUtils.buildId(trunkInterfaceName);
    tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(ItmTestConstants.VLAN_ID).setPortname(ItmTestConstants.PORT_NAME_1).setIpAddress(ItmTestConstants.IP_ADDRESS_3).setGwIpAddress(ItmTestConstants.GTWY_IP_1).setInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME).setTzMembership(ItmUtils.createTransportZoneMembership(ItmTestConstants.TZ_NAME)).setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setSubnetMask(ItmTestConstants.IP_PREFIX_TEST).setKey(new TunnelEndPointsKey(ItmTestConstants.IP_ADDRESS_3, ItmTestConstants.PORT_NAME_1, ItmTestConstants.TUNNEL_TYPE_VXLAN, ItmTestConstants.VLAN_ID)).build();
    tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
    dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(ItmTestConstants.DP_ID_1).setKey(new DPNTEPsInfoKey(ItmTestConstants.DP_ID_1)).setUp(true).setTunnelEndPoints(tunnelEndPointsListVxlan).build();
    cfgdDpnListVxlan.add(dpntePsInfoVxlan);
    dpnEndpoints = new DpnEndpointsBuilder().setDPNTEPsInfo(cfgdDpnListVxlan).build();
    internalTunnel = new InternalTunnelBuilder().setTunnelInterfaceNames(Collections.singletonList(ItmTestConstants.PARENT_INTERFACE_NAME)).setDestinationDPN(ItmTestConstants.DP_ID_2).setSourceDPN(ItmTestConstants.DP_ID_1).setTransportType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setKey(new InternalTunnelKey(ItmTestConstants.DP_ID_2, ItmTestConstants.DP_ID_1, ItmTestConstants.TUNNEL_TYPE_VXLAN)).build();
    getExternalInterfaceNameInput = new GetInternalOrExternalInterfaceNameInputBuilder().setDestinationIp(ItmTestConstants.IP_ADDRESS_3).setSourceDpid(ItmTestConstants.DP_ID_1).setTunnelType(ItmTestConstants.TUNNEL_TYPE_MPLS_OVER_GRE).build();
    getInternalInterfaceNameInput = new GetInternalOrExternalInterfaceNameInputBuilder().setDestinationIp(ItmTestConstants.IP_ADDRESS_3).setSourceDpid(ItmTestConstants.DP_ID_1).setTunnelType(ItmTestConstants.TUNNEL_TYPE_MPLS_OVER_GRE).build();
    addExternalTunnelEndpointInput = new AddExternalTunnelEndpointInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationIp(ItmTestConstants.IP_ADDRESS_3).build();
    addL2GwDeviceInput = new AddL2GwDeviceInputBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setNodeId(ItmTestConstants.SOURCE_DEVICE).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
    deleteL2GwDeviceInput = new DeleteL2GwDeviceInputBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setNodeId(ItmTestConstants.SOURCE_DEVICE).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
    addL2GwMlagDeviceInput = new AddL2GwMlagDeviceInputBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setNodeId(stringList).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
    deleteL2GwMlagDeviceInput = new DeleteL2GwMlagDeviceInputBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setNodeId(stringList).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
    buildExternalTunnelFromDpnsInput = new BuildExternalTunnelFromDpnsInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationIp(ItmTestConstants.IP_ADDRESS_3).setDpnId(dpId1List).build();
    removeExternalTunnelFromDpnsInput = new RemoveExternalTunnelFromDpnsInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationIp(ItmTestConstants.IP_ADDRESS_3).setDpnId(dpId1List).build();
    removeExternalTunnelEndpointInput = new RemoveExternalTunnelEndpointInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationIp(ItmTestConstants.IP_ADDRESS_3).build();
    getTunnelInterfaceNameInput = new GetTunnelInterfaceNameInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setSourceDpid(ItmTestConstants.DP_ID_1).setDestinationDpid(ItmTestConstants.DP_ID_2).build();
    getExternalTunnelInterfaceNameInput = new GetExternalTunnelInterfaceNameInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationNode(ItmTestConstants.DESTINATION_DEVICE).setSourceNode(ItmTestConstants.SOURCE_DEVICE).build();
    iface = ItmUtils.buildTunnelInterface(ItmTestConstants.DP_ID_1, trunkInterfaceName, String.format("%s %s", ItmUtils.convertTunnelTypetoString(ItmTestConstants.TUNNEL_TYPE_VXLAN), "Trunk Interface"), true, ItmTestConstants.TUNNEL_TYPE_VXLAN, tunnelEndPointsVxlan.getIpAddress(), ItmTestConstants.IP_ADDRESS_3, ItmTestConstants.GTWY_IP_1, tunnelEndPointsVxlan.getVLANID(), false, false, ItmTestConstants.MONITOR_PROTOCOL, null, false, null);
    subnetsTest = new SubnetsBuilder().setGatewayIp(ItmTestConstants.GTWY_IP_1).setVlanId(ItmTestConstants.VLAN_ID).setKey(new SubnetsKey(ItmTestConstants.IP_PREFIX_TEST)).setDeviceVteps(deviceVtepsList).build();
    subnetsList.add(subnetsTest);
    transportZone = new TransportZoneBuilder().setZoneName(ItmTestConstants.TZ_NAME).setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setKey(new TransportZoneKey(ItmTestConstants.TZ_NAME)).setSubnets(subnetsList).build();
    transportZoneList.add(transportZone);
    transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
    // build external tunnel objects
    externalTunnel = new ExternalTunnelBuilder().setSourceDevice(ItmTestConstants.DP_ID_1.toString()).setDestinationDevice(String.valueOf(ItmTestConstants.IP_ADDRESS_3.getValue())).setTransportType(TunnelTypeMplsOverGre.class).setTunnelInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME).build();
    externalTunnel2 = new ExternalTunnelBuilder().setSourceDevice(ItmTestConstants.SOURCE_DEVICE).setDestinationDevice(ItmTestConstants.DESTINATION_DEVICE).setTransportType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setTunnelInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME).build();
    getInternalOrExternalInterfaceNameOutput = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME).build();
    // commit external tunnel into config DS
    ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier, externalTunnel, dataBroker);
    ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier2, externalTunnel2, dataBroker);
    // commit internal tunnel into config DS
    ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, internalTunnelIdentifier, internalTunnel, dataBroker);
    // commit dpnEndpoints into config DS
    ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, dpnEndpointsIdentifier, dpnEndpoints, dataBroker);
    // commit TZ into config DS
    ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, transportZonesIdentifier, transportZones, dataBroker);
}
Also used : BuildExternalTunnelFromDpnsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.BuildExternalTunnelFromDpnsInputBuilder) SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) AddL2GwDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwDeviceInputBuilder) GetInternalOrExternalInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameInputBuilder) TransportZonesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder) DeviceVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey) GetExternalTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameInputBuilder) RemoveExternalTunnelFromDpnsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.RemoveExternalTunnelFromDpnsInputBuilder) DPNTEPsInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey) SubnetsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder) InternalTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelBuilder) AddL2GwMlagDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddL2GwMlagDeviceInputBuilder) TunnelEndPointsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPointsKey) DPNTEPsInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoBuilder) InternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelKey) GetTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInputBuilder) TunnelTypeMplsOverGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre) AddExternalTunnelEndpointInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.AddExternalTunnelEndpointInputBuilder) TunnelEndPointsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPointsBuilder) DeleteL2GwMlagDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.DeleteL2GwMlagDeviceInputBuilder) DeviceVtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder) ExternalTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelBuilder) DeleteL2GwDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.DeleteL2GwDeviceInputBuilder) GetInternalOrExternalInterfaceNameOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutputBuilder) DpnEndpointsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnEndpointsBuilder) TransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder) RemoveExternalTunnelEndpointInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.RemoveExternalTunnelEndpointInputBuilder) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey) Before(org.junit.Before)

Example 2 with GetInternalOrExternalInterfaceNameOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutputBuilder 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());
}
Also used : GetInternalOrExternalInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutput) ExternalTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList) ExternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey) ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel) InternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel) TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) TunnelTypeLogicalGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup) GetInternalOrExternalInterfaceNameOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutputBuilder) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Aggregations

GetInternalOrExternalInterfaceNameOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutputBuilder)2 BigInteger (java.math.BigInteger)1 Before (org.junit.Before)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 TunnelTypeLogicalGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup)1 TunnelTypeMplsOverGre (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeMplsOverGre)1 DpnEndpointsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnEndpointsBuilder)1 ExternalTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)1 DPNTEPsInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)1 DPNTEPsInfoBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoBuilder)1 DPNTEPsInfoKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey)1 TunnelEndPoints (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints)1 TunnelEndPointsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPointsBuilder)1 TunnelEndPointsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPointsKey)1 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)1 ExternalTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelBuilder)1 ExternalTunnelKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey)1 InternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel)1 InternalTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelBuilder)1 InternalTunnelKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelKey)1