use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutputBuilder in project netvirt by opendaylight.
the class TestOdlInterfaceRpcService method getDpidFromInterface.
@Override
public Future<RpcResult<GetDpidFromInterfaceOutput>> getDpidFromInterface(GetDpidFromInterfaceInput input) {
String ifName = input.getIntfName();
// if the ifName is INTERFACE_NAME_NO_EXIST, then an empty response will be returned
GetDpidFromInterfaceOutputBuilder builder = new GetDpidFromInterfaceOutputBuilder();
if (ifName == GeniusProviderTestParams.INTERFACE_NAME) {
builder.setDpid(GeniusProviderTestParams.DPN_ID);
} else if (ifName == GeniusProviderTestParams.INTERFACE_NAME_INVALID) {
return Futures.immediateFuture(RpcResultBuilder.<GetDpidFromInterfaceOutput>failed().withError(ErrorType.APPLICATION, "Invalid data.").build());
}
return Futures.immediateFuture(RpcResultBuilder.<GetDpidFromInterfaceOutput>success(builder.build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutputBuilder in project genius by opendaylight.
the class InterfaceManagerServiceImpl method getDpidFromInterface.
@Override
public ListenableFuture<GetDpidFromInterfaceOutput> getDpidFromInterface(GetDpidFromInterfaceInput input) {
String interfaceName = input.getIntfName();
BigInteger dpId;
InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
Interface interfaceInfo = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
if (interfaceInfo == null) {
throw new IllegalArgumentException(getDpidFromInterfaceErrorMessage(interfaceName, "missing Interface in Config DataStore"));
}
if (Tunnel.class.equals(interfaceInfo.getType())) {
ParentRefs parentRefs = interfaceInfo.getAugmentation(ParentRefs.class);
dpId = parentRefs.getDatapathNodeIdentifier();
} else {
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);
} else {
throw new IllegalArgumentException(getDpidFromInterfaceErrorMessage(interfaceName, "missing Interface-state"));
}
}
return Futures.immediateFuture(new GetDpidFromInterfaceOutputBuilder().setDpid(dpId).build());
}
Aggregations