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