Merge "Replace generate password for alternative in passlib"

This commit is contained in:
Jenkins 2015-10-07 07:33:44 +00:00 committed by Gerrit Code Review
commit 827659b6ac
3 changed files with 7 additions and 14 deletions

View File

@ -6,6 +6,7 @@ pbr>=0.6,!=0.7,<1.0
Babel>=1.3
cliff>=1.7.0 # Apache-2.0
ipaddress
passlib>=1.6
python-ironic-inspector-client>=1.0.1
os-cloud-config
python-heatclient>=0.3.0

View File

@ -25,7 +25,7 @@ from unittest import TestCase
class TestPasswordsUtil(TestCase):
@mock.patch("os.path.isfile", return_value=False)
@mock.patch("tripleoclient.utils._generate_password",
@mock.patch("passlib.utils.generate_password",
return_value="PASSWORD")
def test_generate_passwords(self, generate_password_mock, isfile_mock):
@ -54,7 +54,7 @@ class TestPasswordsUtil(TestCase):
self.assertEqual(len(passwords), 13)
@mock.patch("os.path.isfile", return_value=True)
@mock.patch("tripleoclient.utils._generate_password",
@mock.patch("passlib.utils.generate_password",
return_value="PASSWORD")
def test_load_passwords(self, generate_password_mock, isfile_mock):
PASSWORDS = [

View File

@ -18,13 +18,13 @@ import hashlib
import json
import logging
import os
import passlib.utils as passutils
import re
import six
import struct
import subprocess
import sys
import time
import uuid
from tripleoclient import exceptions
@ -48,16 +48,7 @@ SERVICE_LIST = {
}
def _generate_password():
"""Create a random password
The password is made by taking a uuid and passing it though sha1sum.
We may change this in future to gain more entropy.
This is based on the tripleo command os-make-password
"""
uuid_str = six.text_type(uuid.uuid4()).encode("UTF-8")
return hashlib.sha1(uuid_str).hexdigest()
_MIN_PASSWORD_SIZE = 25
def generate_overcloud_passwords(output_file="tripleo-overcloud-passwords"):
@ -88,7 +79,8 @@ def generate_overcloud_passwords(output_file="tripleo-overcloud-passwords"):
"OVERCLOUD_SWIFT_PASSWORD",
)
passwords = dict((p, _generate_password()) for p in password_names)
passwords = dict((p, passutils.generate_password(size=_MIN_PASSWORD_SIZE))
for p in password_names)
with open(output_file, 'w') as f:
for name, password in passwords.items():