Search in sources :

Example 16 with IdManagerService

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

the class VpnUtil method getUniqueId.

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.error("getUniqueId: RPC Call to Get Unique Id from pool {} with key {} returned with Errors {}", poolName, idKey, rpcResult.getErrors());
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("getUniqueId: Exception when getting Unique Id from pool {} for key {}", poolName, idKey, 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 17 with IdManagerService

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

the class NatUtil method createGroupId.

public static long createGroupId(String groupIdKey, IdManagerService idManager) {
    AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(NatConstants.SNAT_IDPOOL_NAME).setIdKey(groupIdKey).build();
    try {
        Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
        RpcResult<AllocateIdOutput> rpcResult = result.get();
        return rpcResult.getResult().getIdValue();
    } catch (NullPointerException | InterruptedException | ExecutionException e) {
        LOG.error("createGroupId : Creating Group with Key: {} failed", groupIdKey, 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 18 with IdManagerService

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

the class NatEvpnUtil method getLPortTagForRouter.

static long getLPortTagForRouter(String routerIdKey, IdManagerService idManager) {
    AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(IfmConstants.IFM_IDPOOL_NAME).setIdKey(routerIdKey).build();
    try {
        Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
        RpcResult<AllocateIdOutput> rpcResult = result.get();
        return rpcResult.getResult().getIdValue();
    } catch (NullPointerException | InterruptedException | ExecutionException e) {
        LOG.error("getLPortTagForRouter : ID manager failed while allocating lport_tag for router {}.", routerIdKey, 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 19 with IdManagerService

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

the class NatOverVxlanUtil method validateAndCreateVxlanVniPool.

public static void validateAndCreateVxlanVniPool(DataBroker broker, INeutronVpnManager neutronvpnManager, IdManagerService idManager, String poolName) {
    /*
         * 1. If a NatPool doesn't exist create it. 2. If a NatPool exists, but
         * the range value is changed incorrectly (say some allocations exist in
         * the old range), we should NOT honor the new range . Throw the WARN
         * but continue running NAT Service with Old range. 3. If a NatPool
         * exists, but the given range is wider than the earlier one, we should
         * attempt to allocate with the new range again(TODO)
         */
    long lowLimit = NatConstants.VNI_DEFAULT_LOW_VALUE;
    long highLimit = NatConstants.VNI_DEFAULT_HIGH_VALUE;
    String configureVniRange = neutronvpnManager.getOpenDaylightVniRangesConfig();
    if (configureVniRange != null) {
        String[] configureVniRangeSplit = configureVniRange.split(":");
        lowLimit = Long.parseLong(configureVniRangeSplit[0]);
        highLimit = Long.parseLong(configureVniRangeSplit[1]);
    }
    Optional<IdPool> existingIdPool = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(broker, LogicalDatastoreType.CONFIGURATION, getIdPoolInstance(poolName));
    if (existingIdPool.isPresent()) {
        IdPool odlVniIdPool = existingIdPool.get();
        long currentStartLimit = odlVniIdPool.getAvailableIdsHolder().getStart();
        long currentEndLimit = odlVniIdPool.getAvailableIdsHolder().getEnd();
        if (lowLimit == currentStartLimit && highLimit == currentEndLimit) {
            LOG.debug("validateAndCreateVxlanVniPool : OpenDaylight VXLAN VNI range pool already exists " + "with configured Range");
        } else {
            if (odlVniIdPool.getIdEntries() != null && odlVniIdPool.getIdEntries().size() != 0) {
                LOG.warn("validateAndCreateVxlanVniPool : Some Allocation already exists with old Range. " + "Cannot modify existing limit of OpenDaylight VXLAN VNI range pool");
            } else {
                LOG.debug("validateAndCreateVxlanVniPool : No VNI's allocated from OpenDaylight VXLAN VNI range " + "pool. Delete and re-create pool with new configured Range {}-{}", lowLimit, highLimit);
                deleteOpenDaylightVniRangesPool(idManager, poolName);
                createOpenDaylightVniRangesPool(idManager, poolName, lowLimit, highLimit);
            }
        }
    } else {
        createOpenDaylightVniRangesPool(idManager, poolName, lowLimit, highLimit);
    }
}
Also used : IdPool(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool)

Example 20 with IdManagerService

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

the class AclServiceUtils method allocateId.

public static Integer allocateId(IdManagerService idManager, String poolName, String idKey, Integer defaultId) {
    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()) {
            Integer allocatedId = rpcResult.getResult().getIdValue().intValue();
            LOG.debug("Allocated ACL ID: {} with key: {} into pool: {}", allocatedId, idKey, poolName);
            return allocatedId;
        } else {
            LOG.error("RPC Call to Get Unique Id for key {} from pool {} returned with Errors {}", idKey, poolName, rpcResult.getErrors());
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Exception when getting Unique Id for key {} from pool {} ", idKey, poolName, e);
    }
    return defaultId;
}
Also used : BigInteger(java.math.BigInteger) 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

ExecutionException (java.util.concurrent.ExecutionException)15 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)15 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)13 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)11 AllocateIdOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)8 ReleaseIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput)6 ReleaseIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder)6 Test (org.junit.Test)3 HwVtep (org.opendaylight.genius.itm.confighelpers.HwVtep)2 DPNTEPsInfoBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoBuilder)2 DPNTEPsInfoKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey)2 TunnelEndPointsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPointsBuilder)2 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)2 ExternalTunnelKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey)2 TransportZoneBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder)2 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)2 SubnetsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder)2 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey)2 DeviceVtepsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder)2 DeviceVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey)2