Search in sources :

Example 6 with GetPortFromInterfaceInput

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

the class InterfaceManagerServiceImpl method getPortFromInterface.

@Override
public ListenableFuture<GetPortFromInterfaceOutput> getPortFromInterface(GetPortFromInterfaceInput input) {
    String interfaceName = input.getIntfName();
    BigInteger dpId = null;
    long portNo = 0;
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(interfaceName);
    if (ifState != null) {
        String lowerLayerIf = ifState.getLowerLayerIf().get(0);
        NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
        dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
        portNo = IfmUtil.getPortNumberFromNodeConnectorId(nodeConnectorId);
        String phyAddress = ifState.getPhysAddress().getValue();
        // TODO as above, simplify the success case later, as we have the failure case below
        return Futures.immediateFuture(new GetPortFromInterfaceOutputBuilder().setDpid(dpId).setPortname(interfaceName).setPortno(portNo).setPhyAddress(phyAddress).build());
    } else {
        throw new IllegalArgumentException("Retrieval of Port for the key " + interfaceName + " failed due to missing Interface state");
    }
}
Also used : Collections(java.util.Collections) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger) GetPortFromInterfaceOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutputBuilder)

Aggregations

GetPortFromInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInput)4 GetPortFromInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInputBuilder)4 GetPortFromInterfaceOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 ExecutionException (java.util.concurrent.ExecutionException)3 GetPortFromInterfaceOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutputBuilder)2 BigInteger (java.math.BigInteger)1 Collections (java.util.Collections)1 GetDpidFromInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInput)1 GetDpidFromInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder)1 GetEgressActionsForInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInput)1 GetEgressActionsForInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder)1 GetEgressInstructionsForInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressInstructionsForInterfaceInput)1 GetEgressInstructionsForInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressInstructionsForInterfaceInputBuilder)1 GetInterfaceTypeInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceTypeInput)1 GetInterfaceTypeInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceTypeInputBuilder)1 GetNodeconnectorIdFromInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInput)1 GetNodeconnectorIdFromInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInputBuilder)1 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)1