From 0a7af329f5386fa5fb2a2f9ebc02a2ca38bb9b17 Mon Sep 17 00:00:00 2001 From: Gaurav Aradhye Date: Wed, 6 Aug 2014 15:13:38 +0530 Subject: [PATCH] CLOUDSTACK-7255: Fixed marvin issue related to creating random account usernames Signed-off-by: Santhosh Edukulla --- tools/marvin/marvin/lib/base.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index 3a1f7e670a2..80596fcfcbd 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -104,11 +104,13 @@ class Account: cmd.lastname = services["lastname"] cmd.password = services["password"] - - username = "-".join([services["username"], - random_gen(id=apiclient.id)]) - # Trim username to 99 characters to prevent failure - cmd.username = username[:99] if len(username) > 99 else username + username = services["username"] + # Limit account username to 99 chars to avoid failure + # 6 chars start string + 85 chars apiclientid + 6 chars random string + 2 chars joining hyphen string = 99 + username = username[:6] + apiclientid = apiclient.id[-85:] if len(apiclient.id) > 85 else apiclient.id + cmd.username = "-".join([username, + random_gen(id=apiclientid, size=6)]) if "accountUUID" in services: cmd.accountid = "-".join([services["accountUUID"], random_gen()])