Merge "Make "random" name more random"

This commit is contained in:
Jenkins 2015-05-13 13:31:58 +00:00 committed by Gerrit Code Review
commit 6757db997a
2 changed files with 9 additions and 2 deletions

View File

@ -96,7 +96,7 @@ class HeatScenario(base.Scenario):
:returns: object of stack
"""
stack_name = self._generate_random_name()
stack_name = self._generate_random_name(prefix="rally_stack_")
kw = {
"stack_name": stack_name,
"disable_rollback": True,

View File

@ -478,8 +478,14 @@ def iterate_per_tenants(users):
processed_tenants.add(user["tenant_id"])
yield (user, user["tenant_id"])
# NOTE(andreykurilin): Actually, this variable should be named as
# "_ASCII_LETTERS_AND_DIGITS", but since world is not ideal, name of variable
# can be non-ideal too.
_DIGITS_AND_ASCII_LETTERS = string.ascii_letters + string.digits
def generate_random_name(prefix="", length=16, choice=string.ascii_lowercase):
def generate_random_name(prefix="", length=16,
choice=_DIGITS_AND_ASCII_LETTERS):
"""Generates pseudo random name.
:param prefix: str, custom prefix for random name
@ -487,5 +493,6 @@ def generate_random_name(prefix="", length=16, choice=string.ascii_lowercase):
:param choice: str, chars for random choice
:returns: str, pseudo random name
"""
rand_part = "".join(random.choice(choice) for i in range(length))
return prefix + rand_part