+
+ static InstanceIdentifier<VpnInterfaces> getVpnInterfacesIdentifier() {
+ return InstanceIdentifier.builder(VpnInterfaces.class).build();
+ }
+
+ static InstanceIdentifier<Interface> getInterfaceIdentifier(String interfaceName) {
+ return InstanceIdentifier.builder(Interfaces.class)
+ .child(Interface.class, new InterfaceKey(interfaceName)).build();
+ }
+
+ public static String getNextHopLabelKey(String rd, String prefix){
+ String key = rd + VpnConstants.SEPARATOR + prefix;
+ return key;
+ }
+
+ static String getIpPrefix(String prefix) {
+ String prefixValues[] = prefix.split("/");
+ if (prefixValues.length == 1) {
+ prefix = prefix + PREFIX_SEPARATOR + DEFAULT_PREFIX_LENGTH ;
+ }
+ return prefix;
+ }
+
+ public static int getUniqueId(IdManagerService idManager, String poolName,String idKey) {
+ AllocateIdInput getIdInput = new AllocateIdInputBuilder()
+ .setPoolName(poolName)
+ .setIdKey(idKey).build();
+
+ try {
+ Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
+ RpcResult<AllocateIdOutput> rpcResult = result.get();
+ if(rpcResult.isSuccessful()) {
+ return rpcResult.getResult().getIdValue().intValue();
+ } else {
+ LOG.warn("RPC Call to Get Unique Id returned with Errors {}", rpcResult.getErrors());
+ }
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.warn("Exception when getting Unique Id",e);
+ }
+ return 0;
+ }