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;
}
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;
}
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;
}
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);
}
}
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;
}
Aggregations