Search in sources :

Example 1 with GetEndpointIpForDpnInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInputBuilder in project netvirt by opendaylight.

the class GeniusProvider method getIpFromDpnId.

// TODO Should better use the Genius InterfaceManager to avoid duplicate code
// https://bugs.opendaylight.org/show_bug.cgi?id=8127
public Optional<String> getIpFromDpnId(DpnIdType dpnid) {
    GetEndpointIpForDpnInputBuilder builder = new GetEndpointIpForDpnInputBuilder();
    builder.setDpid(dpnid.getValue());
    GetEndpointIpForDpnInput input = builder.build();
    if (interfaceManagerRpcService == null) {
        LOG.error("getIpFromDpnId({}) failed (service couldn't be retrieved)", input);
        return Optional.empty();
    }
    try {
        LOG.debug("getIpFromDpnId: invoking rpc");
        RpcResult<GetEndpointIpForDpnOutput> output = interfaceManagerRpcService.getEndpointIpForDpn(input).get();
        if (!output.isSuccessful()) {
            LOG.error("getIpFromDpnId({}) failed: {}", input, output);
            return Optional.empty();
        }
        LOG.debug("getDpnIdFromInterfaceName({}) succeeded: {}", input, output);
        List<IpAddress> localIps = output.getResult().getLocalIps();
        // TODO need to figure out why it returns a list, using first entry for now
        return Optional.ofNullable(localIps).filter(ipAddresses -> !ipAddresses.isEmpty()).map(ipAddresses -> ipAddresses.get(0)).map(IpAddress::getIpv4Address).map(Ipv4Address::getValue);
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("getDpnIdFromInterfaceName failed to retrieve target interface name: ", e);
    }
    return Optional.empty();
}
Also used : Options(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options) OvsdbTerminationPointAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation) RpcProviderRegistry(org.opendaylight.controller.sal.binding.api.RpcProviderRegistry) GetEndpointIpForDpnInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInputBuilder) LoggerFactory(org.slf4j.LoggerFactory) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) OpenFlow13Utils(org.opendaylight.netvirt.sfc.classifier.utils.OpenFlow13Utils) GetDpnInterfaceListInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInputBuilder) GetEndpointIpForDpnInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInput) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) ServiceBindingNxActionRegLoadApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.bound.services.instruction.instruction.apply.actions._case.apply.actions.action.action.ServiceBindingNxActionRegLoadApplyActionsCaseBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) GetNodeconnectorIdFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInputBuilder) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces) BoundServicesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServicesKey) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) GetEndpointIpForDpnOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnOutput) List(java.util.List) ServicesInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.ServicesInfoKey) BoundServicesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServicesBuilder) Optional(java.util.Optional) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) ServiceModeIngress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeIngress) OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ServicesInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.ServicesInfo) Singleton(javax.inject.Singleton) ServiceTypeFlowBased(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceTypeFlowBased) ServiceBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceBindings) Inject(javax.inject.Inject) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) GetDpidFromInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInput) InterfaceTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeVxlan) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) InterfaceTypeBase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase) GetDpidFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder) ServiceModeEgress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeEgress) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) Logger(org.slf4j.Logger) StypeOpenflowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.StypeOpenflowBuilder) GetDpnInterfaceListInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInput) GetDpidFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutput) ExecutionException(java.util.concurrent.ExecutionException) StypeOpenflow(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.StypeOpenflow) GetNodeconnectorIdFromInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInput) GetNodeconnectorIdFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceOutput) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) GetDpnInterfaceListOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListOutput) DpnIdType(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.DpnIdType) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) InetAddresses(com.google.common.net.InetAddresses) Collections(java.util.Collections) GetEndpointIpForDpnInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInput) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) GetEndpointIpForDpnInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInputBuilder) ExecutionException(java.util.concurrent.ExecutionException) GetEndpointIpForDpnOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnOutput) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 2 with GetEndpointIpForDpnInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInputBuilder in project genius by opendaylight.

the class InterfacemgrProvider method getEndpointIpForDpn.

@Override
public String getEndpointIpForDpn(BigInteger dpnId) {
    GetEndpointIpForDpnInput input = new GetEndpointIpForDpnInputBuilder().setDpid(dpnId).build();
    Future<RpcResult<GetEndpointIpForDpnOutput>> output = interfaceManagerRpcService.getEndpointIpForDpn(input);
    try {
        RpcResult<GetEndpointIpForDpnOutput> ipForDpnOutputRpcResult = output.get();
        if (ipForDpnOutputRpcResult.isSuccessful()) {
            List<IpAddress> localIps = ipForDpnOutputRpcResult.getResult().getLocalIps();
            if (!localIps.isEmpty()) {
                return localIps.get(0).getIpv4Address().getValue();
            }
        }
    } catch (NullPointerException | InterruptedException | ExecutionException e) {
        LOG.warn("Exception when getting port for interface", e);
    }
    return null;
}
Also used : GetEndpointIpForDpnInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) GetEndpointIpForDpnInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInputBuilder) ExecutionException(java.util.concurrent.ExecutionException) GetEndpointIpForDpnOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnOutput)

Example 3 with GetEndpointIpForDpnInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInputBuilder in project genius by opendaylight.

the class InterfaceManagerConfigurationTest method checkTunnelRpcs.

private void checkTunnelRpcs() throws Exception {
    // 1. Test endpoint ip fetching for dpn-id
    GetEndpointIpForDpnInput endpointIpForDpnInput = new GetEndpointIpForDpnInputBuilder().setDpid(DPN_ID_2).build();
    Future<RpcResult<GetEndpointIpForDpnOutput>> endpointIpForDpnOutput = odlInterfaceRpcService.getEndpointIpForDpn(endpointIpForDpnInput);
    assertEqualBeans(EndPointIpFromDpn.newEndPointIpFromDpn(), endpointIpForDpnOutput.get().getResult());
    // 2. fetch tunnel type from interface-name
    GetTunnelTypeInput tunnelTypeInput = new GetTunnelTypeInputBuilder().setIntfName(TUNNEL_INTERFACE_NAME).build();
    Future<RpcResult<GetTunnelTypeOutput>> tunnelTypeOutput = odlInterfaceRpcService.getTunnelType(tunnelTypeInput);
    assertEqualBeans(TunnelTypeOutput.newTunnelTypeOutput(), tunnelTypeOutput.get().getResult());
}
Also used : GetTunnelTypeInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetTunnelTypeInput) GetEndpointIpForDpnInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetTunnelTypeInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetTunnelTypeInputBuilder) GetEndpointIpForDpnInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInputBuilder)

Aggregations

GetEndpointIpForDpnInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInput)3 GetEndpointIpForDpnInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnInputBuilder)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 ExecutionException (java.util.concurrent.ExecutionException)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 GetEndpointIpForDpnOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEndpointIpForDpnOutput)2 InetAddresses (com.google.common.net.InetAddresses)1 BigInteger (java.math.BigInteger)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)1 RpcProviderRegistry (org.opendaylight.controller.sal.binding.api.RpcProviderRegistry)1 IInterfaceManager (org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager)1 MDSALUtil (org.opendaylight.genius.mdsalutil.MDSALUtil)1 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)1 OpenFlow13Utils (org.opendaylight.netvirt.sfc.classifier.utils.OpenFlow13Utils)1