Ignore blacklisted nodes when rendering network config
We don't include nodes blacklisted with 'DeploymentServerBlacklist' in 'ServerIdData' stack output, that is used to populate 'server_roles' dict. Let's ignore writing NetworkConfig for those. Change-Id: I837ed2dd7937a87055a8acff686ca3165dba3837 Closes-Bug: #1853247
This commit is contained in:
parent
abbd5c46f1
commit
750a479563
@ -871,12 +871,13 @@ class TestConfig(base.TestCase):
|
||||
|
||||
self.config = ooo_config.Config(heat)
|
||||
stack = mock.Mock()
|
||||
server_roles = dict(Controller='controller')
|
||||
mock_get_network_config_data.return_value = dict(Controller='config')
|
||||
server_roles = dict(node1='Controller')
|
||||
mock_get_network_config_data.return_value = dict(node1='config',
|
||||
node2='config')
|
||||
config_dir = '/tmp/tht'
|
||||
self.config.render_network_config(stack, config_dir, server_roles)
|
||||
self.assertEqual(2, mock_open.call_count)
|
||||
self.assertEqual('/tmp/tht/controller/Controller/NetworkConfig',
|
||||
self.assertEqual('/tmp/tht/Controller/node1/NetworkConfig',
|
||||
mock_open.call_args_list[0][0][0])
|
||||
self.assertEqual('/tmp/tht/controller/NetworkConfig',
|
||||
self.assertEqual('/tmp/tht/Controller/NetworkConfig',
|
||||
mock_open.call_args_list[1][0][0])
|
||||
|
@ -203,19 +203,23 @@ class Config(object):
|
||||
def render_network_config(self, stack, config_dir, server_roles):
|
||||
network_config = self.get_network_config_data(stack)
|
||||
for server, config in network_config.items():
|
||||
server_deployment_dir = os.path.join(
|
||||
config_dir, server_roles[server], server)
|
||||
self._mkdir(server_deployment_dir)
|
||||
network_config_path = os.path.join(
|
||||
server_deployment_dir, "NetworkConfig")
|
||||
network_config_role_path = os.path.join(
|
||||
config_dir, server_roles[server], "NetworkConfig")
|
||||
s_config = self.client.software_configs.get(config)
|
||||
if getattr(s_config, 'config', ''):
|
||||
with self._open_file(network_config_path) as f:
|
||||
f.write(s_config.config)
|
||||
with self._open_file(network_config_role_path) as f:
|
||||
f.write(s_config.config)
|
||||
if server in server_roles:
|
||||
server_deployment_dir = os.path.join(
|
||||
config_dir, server_roles[server], server)
|
||||
self._mkdir(server_deployment_dir)
|
||||
network_config_path = os.path.join(
|
||||
server_deployment_dir, "NetworkConfig")
|
||||
network_config_role_path = os.path.join(
|
||||
config_dir, server_roles[server], "NetworkConfig")
|
||||
s_config = self.client.software_configs.get(config)
|
||||
if getattr(s_config, 'config', ''):
|
||||
with self._open_file(network_config_path) as f:
|
||||
f.write(s_config.config)
|
||||
with self._open_file(network_config_role_path) as f:
|
||||
f.write(s_config.config)
|
||||
else:
|
||||
self.log.warning('Server with id %s is ignored from config '
|
||||
'(Possibly blacklisted)' % server)
|
||||
|
||||
def write_config(self, stack, name, config_dir, config_type=None):
|
||||
# Get role data:
|
||||
|
Loading…
Reference in New Issue
Block a user