Merge "Stop rendering legacy NetworkConfig"

This commit is contained in:
Zuul 2022-10-11 05:40:44 +00:00 committed by Gerrit Code Review
commit 4939155688
3 changed files with 0 additions and 69 deletions

View File

@ -33,8 +33,6 @@ FAKE_STACK = {
'external_deploy_steps_tasks': [{'name': 'Fake external task',
'debug': 'name=hello',
'when': 'step|int == 1'}]}},
{'output_key': 'RoleNetworkConfigMap',
'output_value': {}},
{'output_key': 'RoleData',
'output_value': {
'FakeCompute': {

View File

@ -316,8 +316,6 @@ class TestConfig(base.TestCase):
'a7db3010-a51f-4ae0-a791-2364d629d20d',
'8b07cd31-3083-4b88-a433-955f72039e2c',
'169b46f8-1965-4d90-a7de-f36fb4a830fe']}}},
{'output_key': 'RoleNetworkConfigMap',
'output_value': {}},
{'output_key': 'AnsibleHostVarsMap',
'output_value': {
'Controller': {
@ -455,8 +453,6 @@ class TestConfig(base.TestCase):
'a7db3010-a51f-4ae0-a791-2364d629d20d',
'8b07cd31-3083-4b88-a433-955f72039e2c',
'169b46f8-1965-4d90-a7de-f36fb4a830fe']}}},
{'output_key': 'RoleNetworkConfigMap',
'output_value': {}},
{'output_key': 'RoleGroupVars',
'output_value': {
'Controller': {
@ -604,8 +600,6 @@ class TestConfig(base.TestCase):
'a7db3010-a51f-4ae0-a791-2364d629d20d',
'8b07cd31-3083-4b88-a433-955f72039e2c',
'169b46f8-1965-4d90-a7de-f36fb4a830fe']}}},
{'output_key': 'RoleNetworkConfigMap',
'output_value': {}},
{'output_key': 'RoleGroupVars',
'output_value': {
'Controller': {
@ -762,8 +756,6 @@ class TestConfig(base.TestCase):
'Compute': {
'any_errors_fatal': True,
'max_fail_percentage': 15}}},
{'output_key': 'RoleNetworkConfigMap',
'output_value': {}}
]
deployment_data, configs = \
self._get_config_data('config_data.yaml')
@ -877,37 +869,6 @@ class TestConfig(base.TestCase):
self.assertRaises(yaml.scanner.ScannerError,
self.config.validate_config, stack_config, yaml_file)
@patch('tripleo_common.utils.config.Config.get_role_network_config_data')
def test_render_role_network_config_empty_dict(
self, mock_get_role_net_config_data):
heat = mock.MagicMock()
heat.stacks.get.return_value = fakes.create_tht_stack()
config_mock = mock.MagicMock()
config_mock.config = {}
heat.software_configs.get.return_value = config_mock
self.config = ooo_config.Config(heat)
mock_get_role_net_config_data.return_value = dict(Controller='config')
config_dir = '/tmp/tht'
self.config.render_network_config(config_dir)
@patch.object(ooo_config.Config, '_open_file')
@patch('tripleo_common.utils.config.Config.get_role_network_config_data')
def test_render_role_network_config(self, mock_get_role_net_config_data,
mock_open):
heat = mock.MagicMock()
heat.stacks.get.return_value = fakes.create_tht_stack()
config_mock = mock.MagicMock()
config_mock.config = 'some config'
heat.software_configs.get.return_value = config_mock
self.config = ooo_config.Config(heat)
mock_get_role_net_config_data.return_value = dict(Controller='config')
config_dir = '/tmp/tht'
self.config.render_network_config(config_dir)
self.assertEqual(1, mock_open.call_count)
self.assertEqual('/tmp/tht/Controller/NetworkConfig',
mock_open.call_args_list[0][0][0])
class OvercloudConfigTest(base.TestCase):

View File

@ -58,9 +58,6 @@ class Config(object):
servers[server_id] = name.lower()
return servers
def get_role_network_config_data(self):
return self.stack_outputs.get("RoleNetworkConfigMap")
def get_deployment_data(self, stack,
nested_depth=constants.NESTED_DEPTH):
deployments = self.client.resources.list(
@ -235,28 +232,6 @@ class Config(object):
"error %s", yaml_file, e)
raise e
def render_network_config(self, config_dir):
role_network_config = self.get_role_network_config_data()
if role_network_config is None:
raise ValueError(
'Old network config templates are possibly used, '
'Please convert them before proceeding.')
for role, config in role_network_config.items():
config_path = os.path.join(config_dir, role, "NetworkConfig")
# check if it's actual config or heat config_id
# this will be dropped once we stop using SoftwareConfig
if config is None:
continue
if isinstance(config, dict):
str_config = json.dumps(config)
else:
str_config = self.client.software_configs.get(config).config
if str_config:
with self._open_file(config_path) as f:
f.write(str_config)
def write_config(self, stack, name, config_dir, config_type=None):
# Get role data:
role_data = self.stack_outputs.get('RoleData', {})
@ -575,9 +550,6 @@ class Config(object):
self.validate_config(template_data, host_var_server_path)
f.write(template_data)
# Render NetworkConfig data
self.render_network_config(config_dir)
shutil.copyfile(
os.path.join(templates_path, 'deployments.yaml'),
os.path.join(config_dir, 'deployments.yaml'))