Merge "Don't require mistralclient for password gen"

This commit is contained in:
Jenkins 2016-12-20 20:26:43 +00:00 committed by Gerrit Code Review
commit 0ffa15e23d
3 changed files with 13 additions and 9 deletions

View File

@ -161,7 +161,7 @@ class GeneratePasswordsAction(base.TripleOAction):
except heat_exc.HTTPNotFound:
stack_env = None
passwords = password_utils.generate_overcloud_passwords(wc, stack_env)
passwords = password_utils.generate_passwords(wc, stack_env)
# if passwords don't yet exist in mistral environment
if 'passwords' not in wf_env.variables:

View File

@ -49,13 +49,13 @@ class TestPasswords(base.TestCase):
"undercloud_ceilometer_snmpd_password": snmpd_password
})
# generate_overcloud_passwords will be called multiple times
# generate_passwords will be called multiple times
# but the order is based on how the strings are hashed, and thus
# not really predictable. So, make sure it is a unique one of the
# generated values
mock_create_creds.side_effect = keys
value = password_utils.generate_overcloud_passwords(mock_mistral)
value = password_utils.generate_passwords(mock_mistral)
self.assertIn(value['KeystoneCredential0'], keys)
self.assertIn(value['KeystoneCredential1'], keys)
self.assertIn(value['KeystoneFernetKey0'], keys)

View File

@ -29,11 +29,14 @@ _MIN_PASSWORD_SIZE = 25
LOG = logging.getLogger(__name__)
def generate_overcloud_passwords(mistralclient, stack_env=None):
"""Create the passwords needed for the overcloud
def generate_passwords(mistralclient=None, stack_env=None):
"""Create the passwords needed for deploying OpenStack via t-h-t.
This will create the set of passwords required by the overcloud, store
them in the output file path and return a dictionary of passwords.
This will create the set of passwords required by the undercloud and
overcloud installers that use tripleo-heat-templates and return them
as a dict. The mistralclient is optional and only used to obtain
the previously stored SnmpdReadonlyUserPassword supplied by the
undercloud to the overcloud deployment.
"""
passwords = {}
@ -51,8 +54,9 @@ def generate_overcloud_passwords(mistralclient, stack_env=None):
else:
# CephX keys aren't random strings
passwords[name] = create_cephx_key()
# The SnmpdReadonlyUserPassword is stored in a mistral env.
elif name == 'SnmpdReadonlyUserPassword':
# The underclouds SnmpdReadonlyUserPassword is stored in a mistral env
# for the overcloud.
elif mistralclient and name == 'SnmpdReadonlyUserPassword':
passwords[name] = get_snmpd_readonly_user_password(mistralclient)
elif name in ('KeystoneCredential0', 'KeystoneCredential1',
'KeystoneFernetKey0', 'KeystoneFernetKey1'):