From cbe888772740764b1e345da7ffcc5136f2cd9001 Mon Sep 17 00:00:00 2001 From: Andrey Pavlov Date: Thu, 29 Sep 2016 09:55:11 +0300 Subject: [PATCH] Adding "node_name" config variable "node_name" variable will take the value of CCP_NODE_NAME env variable and will be used during jinja rendering. Support of CCP_* env vars will be removed after migration to "node_name". Change-Id: I8ebbbd94803ccb9a8d13eede2db7db8b13673937 Depends-On: I3e83b4f80737e795446bfd5c7a3941bd5e6ecbf6 --- fuel_ccp_entrypoint/start_script.py | 2 ++ fuel_ccp_entrypoint/tests/test_fuel_ccp_entrypoint.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fuel_ccp_entrypoint/start_script.py b/fuel_ccp_entrypoint/start_script.py index aade4ac..c761b49 100644 --- a/fuel_ccp_entrypoint/start_script.py +++ b/fuel_ccp_entrypoint/start_script.py @@ -336,6 +336,8 @@ def get_variables(role_name): for k in os.environ: if k.startswith('CCP_'): variables[k] = os.environ[k] + if os.environ.get('CCP_NODE_NAME'): + variables['node_name'] = os.environ['CCP_NODE_NAME'] LOG.debug("Getting meta info from %s", META_FILE) LOG.debug("Creating network topology configuration") variables["network_topology"] = create_network_topology(meta_info, diff --git a/fuel_ccp_entrypoint/tests/test_fuel_ccp_entrypoint.py b/fuel_ccp_entrypoint/tests/test_fuel_ccp_entrypoint.py index 61ea9e5..89ecb1d 100644 --- a/fuel_ccp_entrypoint/tests/test_fuel_ccp_entrypoint.py +++ b/fuel_ccp_entrypoint/tests/test_fuel_ccp_entrypoint.py @@ -74,10 +74,12 @@ class TestGetVariables(base.TestCase): def setUp(self): super(TestGetVariables, self).setUp() os.environ['CCP_VAR_FOO'] = 'CCP_VAL_FOO' + os.environ['CCP_NODE_NAME'] = 'node1' def tearDown(self): super(TestGetVariables, self).tearDown() del os.environ['CCP_VAR_FOO'] + del os.environ['CCP_NODE_NAME'] @mock.patch('six.moves.builtins.open', mock.mock_open()) @mock.patch('json.load') @@ -92,7 +94,9 @@ class TestGetVariables(base.TestCase): 'glob': 'glob_val', 'role_name': 'role', 'network_topology': 'network_topology', - 'CCP_VAR_FOO': 'CCP_VAL_FOO' + 'node_name': 'node1', + 'CCP_VAR_FOO': 'CCP_VAL_FOO', + 'CCP_NODE_NAME': 'node1' } self.assertEqual(r_value, e_value)