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());
}
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");
}
}
Aggregations