Make sure randomly generated auth password contains some upper case characters.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/b296ad82 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/b296ad82 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/b296ad82 Branch: refs/heads/trunk Commit: b296ad82a76e1089c9b22af24c0e18ae76537a0e Parents: dd00bc9 Author: Tomaz Muraus <[email protected]> Authored: Sun Apr 5 18:51:20 2015 +0200 Committer: Tomaz Muraus <[email protected]> Committed: Sun Apr 5 18:51:20 2015 +0200 ---------------------------------------------------------------------- libcloud/compute/base.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/b296ad82/libcloud/compute/base.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/base.py b/libcloud/compute/base.py index 4cfcf46..7c9066c 100644 --- a/libcloud/compute/base.py +++ b/libcloud/compute/base.py @@ -24,6 +24,7 @@ import time import hashlib import os import socket +import random import binascii from libcloud.utils.py3 import b @@ -1369,7 +1370,18 @@ class NodeDriver(BaseDriver): if 'password' in self.features['create_node']: value = os.urandom(16) value = binascii.hexlify(value).decode('ascii') - return NodeAuthPassword(value, generated=True) + + # Some providers require password to also include uppercase + # characters so convert some characters to uppercase + password = '' + for char in value: + if not char.isdigit() and char.islower(): + if random.randint(0, 1) == 1: + char = char.upper() + + password += char + + return NodeAuthPassword(password, generated=True) if auth: raise LibcloudError(
