+ private Integer getIfIndex(String ifName) {
+ GetUniqueIdInput getIdInput = new GetUniqueIdInputBuilder()
+ .setPoolName("interfaces").setIdKey(ifName)
+ .build();
+ //TODO: Proper error handling once IdManager code is complete
+ try {
+ Future<RpcResult<GetUniqueIdOutput>> result = idManager.getUniqueId(getIdInput);
+ RpcResult<GetUniqueIdOutput> rpcResult = result.get();
+ return rpcResult.getResult().getIdValue().intValue();
+ } catch (NullPointerException | InterruptedException | ExecutionException e) {
+ LOG.trace("",e);
+ }
+ /* This currently returns null, so let us get it from IdManager DS
+ * TODO: Start-delete-me
+ */
+
+ InstanceIdentifier.InstanceIdentifierBuilder<IdPool> idBuilder =
+ InstanceIdentifier.builder(Pools.class).child(IdPool.class, new IdPoolKey("interfaces"));
+ InstanceIdentifier<IdPool> id = idBuilder.build();
+ Optional<IdPool> globalPool = read(LogicalDatastoreType.OPERATIONAL, id);
+ Long newIdValue = null;
+ if (globalPool.isPresent()) {
+ IdPool pool = globalPool.get();
+ List<GeneratedIds> generatedIds = pool.getGeneratedIds();
+ if ((generatedIds != null) && !generatedIds.isEmpty()) {
+ for (GeneratedIds gen_id : generatedIds) {
+ if (gen_id.getIdKey().equals(ifName)) {
+ newIdValue = gen_id.getIdValue();
+ LOG.debug("Id {} found for interface %s ", newIdValue, ifName);
+ return newIdValue.intValue();
+ }
+ }
+ }
+ }
+ //TODO: End-delete-me
+ LOG.debug("Unable to get valid ifIndex for interface {}", ifName);
+ return 65535;
+ }
+