from ganeti import objects
-def _my_uuidgen():
- """Poor-man's uuidgen using the uuidgen binary.
-
- """
- result = utils.RunCmd(["uuidgen", "-r"])
- if result.failed:
- return None
- return result.stdout.rstrip('\n')
-
-
-try:
- import uuid
- _uuidgen = uuid.uuid4
-except ImportError:
- _uuidgen = _my_uuidgen
-
-
class ConfigWriter:
"""The interface to the cluster configuration.
"""
def __init__(self, cfg_file=None, offline=False):
+ self.write_count = 0
self._config_data = None
self._config_time = None
self._config_size = None
existing.update(exceptions)
retries = 64
while retries > 0:
- unique_id = _uuidgen()
+ unique_id = utils.GetUUID()
if unique_id not in existing and unique_id is not None:
break
else:
f.close()
# we don't need to do os.close(fd) as f.close() did it
os.rename(name, destination)
+ self.write_count += 1
# re-set our cache as not to re-read the config file
try:
st = os.stat(destination)