Merge "[stable-only] Fix legacy password handling" into stable/victoria

This commit is contained in:
Zuul 2021-03-12 12:23:30 +00:00 committed by Gerrit Code Review
commit 904d521ebe
2 changed files with 6 additions and 2 deletions

View File

@ -907,6 +907,7 @@ class PlanTest(base.TestCase):
existing_passwords = _EXISTING_PASSWORDS.copy() existing_passwords = _EXISTING_PASSWORDS.copy()
existing_passwords.pop("AdminPassword") existing_passwords.pop("AdminPassword")
existing_passwords.pop("PcsdPassword")
swift = mock.MagicMock(url="http://test.com") swift = mock.MagicMock(url="http://test.com")
mock_env = yaml.safe_dump({ mock_env = yaml.safe_dump({
@ -923,6 +924,7 @@ class PlanTest(base.TestCase):
mock_orchestration.stacks.environment.return_value = { mock_orchestration.stacks.environment.return_value = {
'parameter_defaults': { 'parameter_defaults': {
'AdminPassword': 'ExistingPasswordInHeat', 'AdminPassword': 'ExistingPasswordInHeat',
'PcsdPassword': 'MyPassword'
} }
} }
@ -938,6 +940,7 @@ class PlanTest(base.TestCase):
result = plan_utils.generate_passwords(swift, mock_orchestration) result = plan_utils.generate_passwords(swift, mock_orchestration)
existing_passwords["AdminPassword"] = "ExistingPasswordInHeat" existing_passwords["AdminPassword"] = "ExistingPasswordInHeat"
existing_passwords["PcsdPassword"] = "MyPassword"
# ensure old passwords used and no new generation # ensure old passwords used and no new generation
self.assertEqual(existing_passwords, result) self.assertEqual(existing_passwords, result)
mock_cache.assert_called_once_with( mock_cache.assert_called_once_with(

View File

@ -408,9 +408,10 @@ def generate_passwords(swift, heat, mistral=None,
# We don't modify these to avoid changing defaults # We don't modify these to avoid changing defaults
for pw_res in constants.LEGACY_HEAT_PASSWORD_RESOURCE_NAMES: for pw_res in constants.LEGACY_HEAT_PASSWORD_RESOURCE_NAMES:
try: try:
res = heat.resources.get(container, pw_res)
param_defaults = stack_env.get('parameter_defaults', {}) param_defaults = stack_env.get('parameter_defaults', {})
param_defaults[pw_res] = res.attributes['value'] if pw_res not in param_defaults:
res = heat.resources.get(container, pw_res)
param_defaults[pw_res] = res.attributes['value']
except heat_exc.HTTPNotFound: except heat_exc.HTTPNotFound:
LOG.debug('Heat resouce not found: %s' % pw_res) LOG.debug('Heat resouce not found: %s' % pw_res)
pass pass