diff --git a/tripleo_common/tests/utils/test_config.py b/tripleo_common/tests/utils/test_config.py index 4f0fd2e7a..37d5a7bc5 100644 --- a/tripleo_common/tests/utils/test_config.py +++ b/tripleo_common/tests/utils/test_config.py @@ -396,3 +396,56 @@ class TestConfig(base.TestCase): self.assertEqual(1, len(w)) assert issubclass(w[-1].category, DeprecationWarning) assert "group:os-apply-config is deprecated" in str(w[-1].message) + + @patch('tripleo_common.utils.config.Config.get_config_dict') + @patch('tripleo_common.utils.config.Config.get_deployment_data') + def test_config_download_no_deployment_uuid(self, mock_deployment_data, + mock_config_dict): + heat = mock.MagicMock() + self.config = ooo_config.Config(heat) + stack = mock.MagicMock() + heat.stacks.get.return_value = stack + stack.outputs = [ + {'output_key': 'RoleNetHostnameMap', + 'output_value': { + 'Controller': { + 'ctlplane': [ + 'overcloud-controller-0.ctlplane.localdomain']}, + 'Compute': { + 'ctlplane': [ + 'overcloud-novacompute-0.ctlplane.localdomain', + 'overcloud-novacompute-1.ctlplane.localdomain', + 'overcloud-novacompute-2.ctlplane.localdomain']}}}, + {'output_key': 'ServerIdData', + 'output_value': { + 'server_ids': { + 'Controller': [ + '00b3a5e1-5e8e-4b55-878b-2fa2271f15ad'], + 'Compute': [ + 'a7db3010-a51f-4ae0-a791-2364d629d20d', + '8b07cd31-3083-4b88-a433-955f72039e2c', + '169b46f8-1965-4d90-a7de-f36fb4a830fe']}}}, + {'output_key': 'RoleGroupVars', + 'output_value': { + 'Controller': { + 'any_errors_fatal': 'yes', + 'max_fail_percentage': 15}, + 'Compute': { + 'any_errors_fatal': 'yes', + 'max_fail_percentage': 15}, + }}] + deployment_data, configs = self._get_config_data('config_data.yaml') + + # Set the deployment to TripleOSoftwareDeployment for the first + # deployment + deployment_data[0].attributes['value']['deployment'] = \ + 'TripleOSoftwareDeployment' + + self.configs = configs + mock_deployment_data.return_value = deployment_data + mock_config_dict.side_effect = self._get_config_dict + + self.tmp_dir = self.useFixture(fixtures.TempDir()).path + with warnings.catch_warnings(record=True) as w: + self.config.download_config(stack, self.tmp_dir) + assert "Skipping deployment" in str(w[-1].message) diff --git a/tripleo_common/utils/config.py b/tripleo_common/utils/config.py index fd5be4ca9..b62f9a064 100644 --- a/tripleo_common/utils/config.py +++ b/tripleo_common/utils/config.py @@ -215,6 +215,21 @@ class Config(object): server_roles = {} for deployment in deployments_data: + # Check if the deployment value is the resource name. If that's the + # case, Heat did not create a physical_resource_id for this + # deployment since it does not trigger on this stack action. Such + # as a deployment that only triggers on DELETE, but this is a stack + # create. If that's the case, just skip this deployment, otherwise + # it will result in a Not found error if we try and query the + # deployment API for this deployment. + if deployment.attributes['value'].get('deployment') == \ + 'TripleOSoftwareDeployment': + warnings.warn('Skipping deployment %s because it has no ' + 'valid uuid (physical_resource_id) ' + 'associated.' % + deployment.physical_resource_id) + continue + server_id = deployment.attributes['value']['server'] config_dict = self.get_config_dict(deployment)