diff --git a/cattle/__init__.py b/cattle/__init__.py index 97191f8..cb543ab 100644 --- a/cattle/__init__.py +++ b/cattle/__init__.py @@ -69,9 +69,10 @@ def physical_host_uuid_file(): return default_value('PHYSICAL_HOST_UUID_FILE', def_value) @staticmethod - def physical_host_uuid(): + def physical_host_uuid(force_write=False): return Config.get_uuid_from_file('PHYSICAL_HOST_UUID', - Config.physical_host_uuid_file()) + Config.physical_host_uuid_file(), + force_write=force_write) @staticmethod def setup_logger(): @@ -82,9 +83,14 @@ def do_ping(): return default_value('PING_ENABLED', 'true') == 'true' @staticmethod - def get_uuid_from_file(env_name, uuid_file): + def get_uuid_from_file(env_name, uuid_file, force_write=False): uuid = default_value(env_name, None) if uuid is not None: + if force_write: + if path.exists(uuid_file): + os.remove(uuid_file) + with open(uuid_file, 'w') as f: + f.write(uuid) return uuid return Config._get_uuid_from_file(uuid_file) diff --git a/main.py b/main.py index 3fa9eab..400403c 100755 --- a/main.py +++ b/main.py @@ -84,6 +84,8 @@ def main(): Config.set_secret_key(args.secret_key) Config.set_api_url(args.url) + Config.physical_host_uuid(force_write=True) + process_manager.init() plugins.load()