X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=vpnservice.git;a=blobdiff_plain;f=itm%2Fitm-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Fitm%2Fimpl%2FItmProvider.java;fp=itm%2Fitm-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Fitm%2Fimpl%2FItmProvider.java;h=1a4c02961f0f1ffc4df07d779646b3a8ea2825df;hp=b805a629c9bc6b3546a2c226225f26e16f957da9;hb=15e44d5b9ad65ece6e59c00fc272ae499c4f7d8c;hpb=1cddfc772b08569953f28a0679818aac75a9c30a;ds=sidebyside diff --git a/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java index b805a629..1a4c0296 100644 --- a/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java +++ b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java @@ -9,6 +9,7 @@ package org.opendaylight.vpnservice.itm.impl; import java.math.BigInteger; import java.util.List; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import org.opendaylight.controller.md.sal.binding.api.DataBroker; @@ -21,9 +22,13 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager; import org.opendaylight.vpnservice.itm.api.IITMProvider; +import org.opendaylight.vpnservice.itm.globals.ITMConstants; import org.opendaylight.vpnservice.itm.listeners.TransportZoneListener; import org.opendaylight.vpnservice.itm.rpc.ItmManagerRpcService; import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.OdlInterfaceRpcService; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.ItmRpcService; @@ -40,6 +45,7 @@ public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMPro private DataBroker dataBroker; private NotificationPublishService notificationPublishService; private ItmManagerRpcService itmRpcService ; + private IdManagerService idManager; private NotificationService notificationService; private TransportZoneListener tzChangeListener; private RpcProviderRegistry rpcProviderRegistry; @@ -57,10 +63,11 @@ public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMPro LOG.info("ItmProvider Session Initiated"); try { dataBroker = session.getSALService(DataBroker.class); + idManager = getRpcProviderRegistry().getRpcService(IdManagerService.class); itmManager = new ITMManager(dataBroker); - tzChangeListener = new TransportZoneListener(dataBroker) ; - itmRpcService = new ItmManagerRpcService(dataBroker); + tzChangeListener = new TransportZoneListener(dataBroker, idManager) ; + itmRpcService = new ItmManagerRpcService(dataBroker, idManager); final BindingAwareBroker.RpcRegistration rpcRegistration = getRpcProviderRegistry().addRpcImplementation(ItmRpcService.class, itmRpcService); itmRpcService.setMdsalManager(mdsalManager); itmManager.setMdsalManager(mdsalManager); @@ -68,6 +75,7 @@ public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMPro itmManager.setMdsalManager(mdsalManager); tzChangeListener.setItmManager(itmManager); tzChangeListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker); + createIdPool(); } catch (Exception e) { LOG.error("Error initializing services", e); } @@ -100,5 +108,19 @@ public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMPro LOG.info("ItmProvider Closed"); } - + private void createIdPool() { + CreateIdPoolInput createPool = new CreateIdPoolInputBuilder() + .setPoolName(ITMConstants.ITM_IDPOOL_NAME) + .setLow(ITMConstants.ITM_IDPOOL_START) + .setHigh(new BigInteger(ITMConstants.ITM_IDPOOL_SIZE).longValue()) + .build(); + try { + Future> result = idManager.createIdPool(createPool); + if ((result != null) && (result.get().isSuccessful())) { + LOG.debug("Created IdPool for ITM Service"); + } + } catch (InterruptedException | ExecutionException e) { + LOG.error("Failed to create idPool for ITM Service",e); + } + } }