Search in sources :

Example 1 with GetPortFromInterfaceOutputBuilder

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

the class TestOdlInterfaceRpcService method getPortFromInterface.

@Override
public Future<RpcResult<GetPortFromInterfaceOutput>> getPortFromInterface(GetPortFromInterfaceInput input) {
    RpcResultBuilder<GetPortFromInterfaceOutput> rpcResultBuilder;
    GetPortFromInterfaceOutputBuilder output = new GetPortFromInterfaceOutputBuilder().setDpid(DPN_ID).setPortname(INTERFACE_NAME).setPortno(PORT_NUMBER).setPhyAddress("1F:1F:1F:1F:1F:1F");
    rpcResultBuilder = RpcResultBuilder.success();
    rpcResultBuilder.withResult(output.build());
    return Futures.immediateFuture(rpcResultBuilder.build());
}
Also used : GetPortFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput) GetPortFromInterfaceOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutputBuilder)

Example 2 with GetPortFromInterfaceOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutputBuilder 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

GetPortFromInterfaceOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutputBuilder)2 BigInteger (java.math.BigInteger)1 Collections (java.util.Collections)1 GetPortFromInterfaceOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput)1 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)1