Search in sources :

Example 6 with AllocateIdInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput in project netvirt by opendaylight.

the class DhcpAllocationPoolManager method createIdAllocation.

private long createIdAllocation(String groupIdKey, String idKey) {
    AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(groupIdKey).setIdKey(idKey).build();
    try {
        Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
        RpcResult<AllocateIdOutput> rpcResult = result.get();
        return rpcResult.getResult().getIdValue();
    } catch (NullPointerException | InterruptedException | ExecutionException e) {
        LOG.trace("Failed to allocate id for DHCP Allocation Pool Service", e);
    }
    return 0;
}
Also used : AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)

Example 7 with AllocateIdInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput in project netvirt by opendaylight.

the class ArpResponderUtil method retrieveStandardArpResponderGroupId.

/**
 * Uses the IdManager to retrieve ARP Responder GroupId from ELAN pool.
 *
 * @param idManager
 *            the id manager
 * @return the integer
 */
public static Long retrieveStandardArpResponderGroupId(IdManagerService idManager) {
    AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(ArpResponderConstant.ELAN_ID_POOL_NAME.value()).setIdKey(ArpResponderConstant.ARP_RESPONDER_GROUP_ID.value()).build();
    try {
        Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
        RpcResult<AllocateIdOutput> rpcResult = result.get();
        if (rpcResult.isSuccessful()) {
            LOG.trace("Retrieved Group Id is {}", rpcResult.getResult().getIdValue());
            return rpcResult.getResult().getIdValue();
        } else {
            LOG.warn("RPC Call to Allocate Id returned with Errors {}", rpcResult.getErrors());
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn("Exception when Allocating Id", e);
    }
    return 0L;
}
Also used : AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)

Example 8 with AllocateIdInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput in project genius by opendaylight.

the class ItmInternalTunnelAddTest method testBuild_all_tunnels_VXLANtype.

@Test
public void testBuild_all_tunnels_VXLANtype() {
    AllocateIdInput getIdInput1 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.102:VXLAN").build();
    AllocateIdInput getIdInput2 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.102:192.168.56.101:VXLAN").build();
    doReturn(idOutputOptional1).when(idManagerService).allocateId(getIdInput1);
    doReturn(idOutputOptional2).when(idManagerService).allocateId(getIdInput2);
    trunkInterfaceName1 = ItmUtils.getTrunkInterfaceName(parentInterfaceName, tepIp1, tepIp2, tunnelType1.getName());
    trunkInterfaceName2 = ItmUtils.getTrunkInterfaceName(parentInterfaceName, tepIp2, tepIp1, tunnelType1.getName());
    internalTunnel1 = ItmUtils.buildInternalTunnel(dpId1, dpId2, tunnelType1, trunkInterfaceName1);
    internalTunnel2 = ItmUtils.buildInternalTunnel(dpId2, dpId1, tunnelType1, trunkInterfaceName2);
    itmInternalTunnelAddWorker.buildAllTunnels(mdsalApiManager, cfgdDpnListVxlan, meshDpnListVxlan);
    // Add some verifications
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, internalTunnelIdentifierVxlan1, internalTunnel1, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, internalTunnelIdentifierVxlan2, internalTunnel2, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, dpnEndpointsIdentifier, dpnEndpointsVxlan);
}
Also used : AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 9 with AllocateIdInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput in project genius by opendaylight.

the class ItmInternalTunnelAddTest method testBuild_all_tunnels_GREtype.

@Test
public void testBuild_all_tunnels_GREtype() {
    AllocateIdInput getIdInput1 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.102:GRE").build();
    AllocateIdInput getIdInput2 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.102:192.168.56.101:GRE").build();
    doReturn(idOutputOptional1).when(idManagerService).allocateId(getIdInput1);
    doReturn(idOutputOptional2).when(idManagerService).allocateId(getIdInput2);
    trunkInterfaceName1 = ItmUtils.getTrunkInterfaceName(parentInterfaceName, tepIp1, tepIp2, tunnelType2.getName());
    trunkInterfaceName2 = ItmUtils.getTrunkInterfaceName(parentInterfaceName, tepIp2, tepIp1, tunnelType2.getName());
    internalTunnel1 = ItmUtils.buildInternalTunnel(dpId1, dpId2, tunnelType2, trunkInterfaceName1);
    internalTunnel2 = ItmUtils.buildInternalTunnel(dpId2, dpId1, tunnelType2, trunkInterfaceName2);
    itmInternalTunnelAddWorker.buildAllTunnels(mdsalApiManager, cfgdDpnListGre, meshDpnListGre);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, internalTunnelIdentifierGre1, internalTunnel1, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, internalTunnelIdentifierGre2, internalTunnel2, true);
    verify(mockWriteTx).merge(LogicalDatastoreType.CONFIGURATION, dpnEndpointsIdentifier, dpnEndpointsGre);
}
Also used : AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 10 with AllocateIdInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput in project genius by opendaylight.

the class IfmUtil method allocateId.

public static Integer allocateId(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 INVALID_ID;
}
Also used : AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)

Aggregations

AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)27 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)27 ExecutionException (java.util.concurrent.ExecutionException)19 AllocateIdOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)19 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)19 Test (org.junit.Test)8 CreateIdPoolInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput)6 CreateIdPoolInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 IdPool (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool)4 IdPoolBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolBuilder)4 IdPoolKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolKey)4 ArrayList (java.util.ArrayList)3 AllocateIdOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutputBuilder)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Optional (com.google.common.base.Optional)1 Futures (com.google.common.util.concurrent.Futures)1 UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)1 BigInteger (java.math.BigInteger)1 Collections (java.util.Collections)1