From 254a89bbb38951d13929ec8ed2d40b38521efcd9 Mon Sep 17 00:00:00 2001 From: Aleksandr Mogylchenko Date: Wed, 1 Mar 2017 16:56:13 +0100 Subject: [PATCH] Use CPU_LIMIT and MEMORY_LIMIT when rendering Just two more variables added to rendering scope (prefernce is not to add os.environ dict entirely). Change-Id: Ibc6e8b91055f411b058505d14c2d83fbc826cdd4 Depends-On: Iadd0529d166ef1dad1697215bbc181104a7b926e --- fuel_ccp_entrypoint/start_script.py | 2 ++ fuel_ccp_entrypoint/tests/test_fuel_ccp_entrypoint.py | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fuel_ccp_entrypoint/start_script.py b/fuel_ccp_entrypoint/start_script.py index 206f127..9fafc6f 100644 --- a/fuel_ccp_entrypoint/start_script.py +++ b/fuel_ccp_entrypoint/start_script.py @@ -518,6 +518,8 @@ def get_variables(role_name): LOG.info("Get CCP environment variables") variables['node_name'] = os.environ['CCP_NODE_NAME'] variables['pod_name'] = os.environ['CCP_POD_NAME'] + variables['memory_limit'] = os.environ['MEMORY_LIMIT'] + variables['cpu_limit'] = os.environ['CPU_LIMIT'] LOG.debug("Creating network topology ") variables["network_topology"] = create_network_topology(meta_info, variables) diff --git a/fuel_ccp_entrypoint/tests/test_fuel_ccp_entrypoint.py b/fuel_ccp_entrypoint/tests/test_fuel_ccp_entrypoint.py index 24176cf..3ee3fcb 100644 --- a/fuel_ccp_entrypoint/tests/test_fuel_ccp_entrypoint.py +++ b/fuel_ccp_entrypoint/tests/test_fuel_ccp_entrypoint.py @@ -75,11 +75,15 @@ class TestGetVariables(base.TestCase): super(TestGetVariables, self).setUp() os.environ['CCP_NODE_NAME'] = 'node1' os.environ['CCP_POD_NAME'] = 'pod1' + os.environ['MEMORY_LIMIT'] = '7859277824' + os.environ['CPU_LIMIT'] = '4' def tearDown(self): super(TestGetVariables, self).tearDown() del os.environ['CCP_NODE_NAME'] del os.environ['CCP_POD_NAME'] + del os.environ['MEMORY_LIMIT'] + del os.environ['CPU_LIMIT'] @mock.patch('six.moves.builtins.open', mock.mock_open()) @mock.patch('json.load') @@ -93,7 +97,9 @@ class TestGetVariables(base.TestCase): 'role_name': 'role', 'network_topology': 'network_topology', 'node_name': 'node1', - 'pod_name': 'pod1' + 'pod_name': 'pod1', + 'cpu_limit': '4', + 'memory_limit': '7859277824' } self.assertEqual(r_value, e_value) @@ -144,6 +150,8 @@ class TestGetVariables(base.TestCase): 'role_name': 'fake_role', 'network_topology': 'network_topology', 'node_name': 'node1', + 'cpu_limit': '4', + 'memory_limit': '7859277824', 'pod_name': 'pod1', 'a': { 'b': {