summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Pavlov <apavlov@mirantis.com>2017-03-07 17:39:10 +0400
committerAndrey Pavlov <apavlov@mirantis.com>2017-03-07 17:39:10 +0400
commitde9c9bf2ed06592bde83c358cf3eb3b781905609 (patch)
treea81ddbab683405e6f76368859f3c44e417531f90
parent94b4940afa70ff1ba2b1f4f1bb7e1622391e84c5 (diff)
Take configs from global secretHEADmaster
Notes
Notes (review): Code-Review+2: Sergey Reshetnyak <sreshetniak@mirantis.com> Code-Review+2: Artur Zarzycki <azarzycki@mirantis.com> Workflow+1: Artur Zarzycki <azarzycki@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 07 Mar 2017 13:53:13 +0000 Reviewed-on: https://review.openstack.org/442483 Project: openstack/fuel-ccp-etcd Branch: refs/heads/master
-rw-r--r--service/files/entrypoint.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/service/files/entrypoint.py b/service/files/entrypoint.py
index d20c938..e8462e8 100644
--- a/service/files/entrypoint.py
+++ b/service/files/entrypoint.py
@@ -18,7 +18,7 @@ logging.basicConfig(format=LOG_FORMAT,
18LOG = logging.getLogger(__name__) 18LOG = logging.getLogger(__name__)
19 19
20GLOBALS_PATH = '/etc/ccp/globals/globals.json' 20GLOBALS_PATH = '/etc/ccp/globals/globals.json'
21 21GLOBALS_SECRETS_PATH = '/etc/ccp/global-secrets/global-secrets.json'
22 22
23def retry(f): 23def retry(f):
24 @functools.wraps(f) 24 @functools.wraps(f)
@@ -36,12 +36,25 @@ def retry(f):
36 return wrap 36 return wrap
37 37
38 38
39def merge_configs(variables, new_config):
40 for k, v in new_config.items():
41 if k not in variables:
42 variables[k] = v
43 continue
44 if isinstance(v, dict) and isinstance(variables[k], dict):
45 merge_configs(variables[k], v)
46 else:
47 variables[k] = v
48
49
39class Configuration(): 50class Configuration():
40 def __init__(self, config_file): 51 def __init__(self):
41 LOG.info("Getting global variables from %s", config_file)
42 values = {} 52 values = {}
43 with open(config_file) as f: 53 with open(GLOBALS_PATH) as f:
44 global_conf = json.load(f) 54 global_conf = json.load(f)
55 with open(GLOBALS_SECRETS_PATH) as f:
56 secrets = json.load(f)
57 merge_configs(global_conf, secrets)
45 for key in ['etcd', 'namespace', 'security', 'cluster_domain']: 58 for key in ['etcd', 'namespace', 'security', 'cluster_domain']:
46 values[key] = global_conf[key] 59 values[key] = global_conf[key]
47 hostname = socket.gethostname() 60 hostname = socket.gethostname()
@@ -179,7 +192,7 @@ def _get_etcd_member_id(peers, name):
179 192
180 193
181if __name__ == "__main__": 194if __name__ == "__main__":
182 config = Configuration(GLOBALS_PATH) 195 config = Configuration()
183 etcd_members_api = config.members_api 196 etcd_members_api = config.members_api
184 try: 197 try:
185 # The only reliable way to determine if etcd cluster exists is to query 198 # The only reliable way to determine if etcd cluster exists is to query