conf: initialize IDs after reading config file

Installation_id and node_id are stored in the data dir.
For this reason they should be read/created only after the
config has been parsed.
This way they can be retrieved or stored at the right location.

Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
This commit is contained in:
Antonio Quartulli 2018-01-29 17:16:41 +08:00
parent 34976c7602
commit 639744e047
No known key found for this signature in database
GPG key ID: 07A53C580EF2CD74

View file

@ -509,6 +509,10 @@ class Config(object):
converted[k] = v
return converted
def initialize_post_conf_load(self):
settings.installation_id = settings.get_installation_id()
settings.node_id = settings.get_node_id()
def load_conf_file_settings(self):
if conf_file:
path = conf_file
@ -528,6 +532,9 @@ class Config(object):
except (IOError, OSError) as err:
log.info('%s: Failed to update settings from %s', err, path)
#initialize members depending on config file
self.initialize_post_conf_load()
def _fix_old_conf_file_settings(self, settings_dict):
if 'API_INTERFACE' in settings_dict:
settings_dict['api_host'] = settings_dict['API_INTERFACE']
@ -628,7 +635,5 @@ def initialize_settings(load_conf_file=True):
if settings is None:
settings = Config(FIXED_SETTINGS, ADJUSTABLE_SETTINGS,
environment=get_default_env())
settings.installation_id = settings.get_installation_id()
settings.node_id = settings.get_node_id()
if load_conf_file:
settings.load_conf_file_settings()