use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInput in project netvirt by opendaylight.
the class GeniusProvider method getInterfacesFromNode.
public List<Interfaces> getInterfacesFromNode(NodeId nodeId) {
// getPortsOnBridge() only returns Tunnel ports, so instead using getDpnInterfaceList.
GetDpnInterfaceListInputBuilder inputBuilder = new GetDpnInterfaceListInputBuilder();
inputBuilder.setDpid(BigInteger.valueOf(Long.parseLong(nodeId.getValue().split(":")[1])));
GetDpnInterfaceListInput input = inputBuilder.build();
try {
LOG.debug("getInterfacesFromNode: invoking rpc");
RpcResult<GetDpnInterfaceListOutput> output = interfaceManagerRpcService.getDpnInterfaceList(input).get();
if (!output.isSuccessful()) {
LOG.error("getInterfacesFromNode({}) failed: {}", input, output);
return Collections.emptyList();
}
LOG.debug("getInterfacesFromNode({}) succeeded: {}", input, output);
return output.getResult().getInterfaces();
} catch (InterruptedException | ExecutionException e) {
LOG.error("getInterfacesFromNode failed to retrieve target interface name: ", e);
}
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInput in project genius by opendaylight.
the class InterfaceManagerConfigurationTest method testDpnToInterfaceList.
@Ignore
@Test
public void testDpnToInterfaceList() throws Exception {
// Write into DpnToInterfaceList
createDpnToInterface(DPN_ID_1, "23701c04-7e58-4c65-9425-78a80d49a218", L2vlan.class);
// Test interface list fetching from dpnId
GetDpnInterfaceListInput dpnInterfaceListInput = new GetDpnInterfaceListInputBuilder().setDpid(DPN_ID_1).build();
Future<RpcResult<GetDpnInterfaceListOutput>> dpnInterfaceListOutput = odlInterfaceRpcService.getDpnInterfaceList(dpnInterfaceListInput);
List<Interfaces> actualDpnInterfaceList = dpnInterfaceListOutput.get().getResult().getInterfaces();
assertEqualBeans(ExpectedInterfaceListFromDpn.checkDpnToInterfaceList(), actualDpnInterfaceList.get(0));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInput in project genius by opendaylight.
the class InterfaceManagerServiceImpl method getDpnInterfaceList.
@Override
public ListenableFuture<GetDpnInterfaceListOutput> getDpnInterfaceList(GetDpnInterfaceListInput input) {
BigInteger dpnid = input.getDpid();
InstanceIdentifier<DpnToInterface> id = InstanceIdentifier.builder(DpnToInterfaceList.class).child(DpnToInterface.class, new DpnToInterfaceKey(dpnid)).build();
Optional<DpnToInterface> entry = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, id, dataBroker);
if (!entry.isPresent()) {
LOG.warn("Could not find Operational DpnToInterface info for DPN {}. Returning empty list", dpnid);
return buildEmptyInterfaceListResult();
}
List<InterfaceNameEntry> interfaceNameEntries = entry.get().getInterfaceNameEntry();
if (interfaceNameEntries == null || interfaceNameEntries.isEmpty()) {
LOG.debug("No Interface list found in Operational for DPN {}", dpnid);
return buildEmptyInterfaceListResult();
}
List<Interfaces> interfaceList = new ArrayList<>();
interfaceNameEntries.forEach((interfaceNameEntry) -> {
InterfacesBuilder intf = new InterfacesBuilder().setInterfaceName(interfaceNameEntry.getInterfaceName()).setInterfaceType(interfaceNameEntry.getInterfaceType());
interfaceList.add(intf.build());
});
// TODO as above, simplify the success case later, as we have the failure case below
return Futures.immediateFuture(new GetDpnInterfaceListOutputBuilder().setInterfaces(interfaceList).build());
}
Aggregations