Added CdistUtils class to manage indices

This commit is contained in:
M.Ravi 2017-08-31 15:05:45 +02:00
commit 89ba4b6d04
3 changed files with 51 additions and 12 deletions

26
utils/cdist_utils.py Normal file
View file

@ -0,0 +1,26 @@
import cdist.integration as cdist_integration
class CdistUtilts():
@staticmethod
def get_cdist_index():
"""
Returns the next available instance index.
This is useful while making simultaneous configurations of
the same host.
:return: the next available index
"""
cdist_instance_index = cdist_integration.instance_index
cdist_index = next(cdist_instance_index)
return cdist_index
@staticmethod
def free_cdist_index(cdist_index):
"""
Frees up the index that was used during configuring a host
using cdist.
:param cdist_index: The index to be freed
:return:
"""
cdist_instance_index = cdist_integration.instance_index
cdist_instance_index.free(cdist_index)