Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #214 from cjellick/host-uuid
Browse files Browse the repository at this point in the history
write physical host uuid if found in env vars
  • Loading branch information
ibuildthecloud committed Jan 22, 2016
2 parents 0102040 + 2bc64a1 commit cd9add4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cattle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit cd9add4

Please sign in to comment.