Remove extraneous dependency

The rstr library relies on the normal random.SystemRandom() and does not
perform additional functionalites that would require a whole dependency
to be added to pegleg. This patch set places in the logic into pegleg's
crypto generation rather than using the whole rstr library.

Change-Id: I20c0ceae8ac7d11468f325cd6a4cc035fc176b14
Signed-off-by: Tin Lam <tin@irrational.io>
This commit is contained in:
tinlam 2019-03-20 22:08:00 -05:00 committed by Tin Lam
parent e3e5683765
commit cecaa73f57
2 changed files with 6 additions and 12 deletions

View File

@ -12,9 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from random import SystemRandom
from rstr import Rstr
import random
import string
__all__ = ['CryptoString']
@ -24,14 +22,11 @@ class CryptoString(object):
def __init__(self):
self._pool = string.ascii_letters + string.digits + string.punctuation
self._rs = Rstr(SystemRandom())
self._random = random.SystemRandom()
def get_crypto_string(self, len=24):
def get_crypto_string(self, length=24):
"""
Create and return a random cryptographic string,
of the ``len`` length.
Create and return a random cryptographic string of length ``length``.
"""
if len < 24:
len = 24
return self._rs.rstr(self._pool, len)
return ''.join(self._random.choice(self._pool)
for _ in range(max(24, length)))

View File

@ -6,7 +6,6 @@ cryptography==2.3.1
python-dateutil==2.7.3
# External dependencies
rstr==2.2.6
git+https://github.com/openstack/airship-deckhand.git@49ad9f38842f7f1ecb86d907d86d332f8186eb8c
git+https://github.com/openstack/airship-shipyard.git@44f7022df6438de541501c2fdd5c46df198b82bf#egg=shipyard_client&subdirectory=src/bin/shipyard_client
git+https://github.com/openstack/airship-promenade.git@a6e8fdbe22bd153c78a008b92cd5d1c245bc63e3