VOL-400: configurable alloc-id and gemport-id with min gemid=1024
change requests for previous patch set. Working on itest coverage
added itests for new parameters including explicit zero test
so that if zero is used it is same as if not used and it will auto
select the next available id (alloc-id or gemport-id)
Change-Id: I2c41e0a0811614aa9c1c77ad52a13b0dd504385b
diff --git a/common/utils/indexpool.py b/common/utils/indexpool.py
index 24f57ff..d85d1ef 100644
--- a/common/utils/indexpool.py
+++ b/common/utils/indexpool.py
@@ -18,6 +18,21 @@
log.info("exception-fail-to-allocate-id-all-bits-in-use")
return None
+ def allocate(self, index):
+ try:
+ _pos = index - self.offset
+ if not (0 <= _pos < self.max_entries):
+ log.info("{}-out-of-range".format(index))
+ return None
+ if self.indices[_pos]:
+ log.info("{}-is-already-allocated".format(index))
+ return None
+ self.indices.set(1, _pos)
+ return index
+
+ except IndexError:
+ return None
+
def release(self, index):
index -= self.offset
_pos = (index,)