diff options
author | Jenkins <jenkins@review.openstack.org> | 2012-12-12 18:18:58 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2012-12-12 18:18:58 +0000 |
commit | f3c08f607699cdee5a5f23214ef53feb48a91257 (patch) | |
tree | a2003febe5388c7aeb07c0a924662dd43d3f9648 /nova/utils.py | |
parent | 02e83e1028bca92a64493c7c14be2e2ae19fb8a4 (diff) | |
parent | 32af3c94bd62c46713a44bf75f2e4989f8b98bc4 (diff) | |
download | nova-f3c08f607699cdee5a5f23214ef53feb48a91257.tar.gz nova-f3c08f607699cdee5a5f23214ef53feb48a91257.tar.xz nova-f3c08f607699cdee5a5f23214ef53feb48a91257.zip |
Merge "Properly scope password options"
Diffstat (limited to 'nova/utils.py')
-rw-r--r-- | nova/utils.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/nova/utils.py b/nova/utils.py index 2491c5fcb..859fe5df8 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -64,12 +64,17 @@ monkey_patch_opts = [ ], help='List of modules/decorators to monkey patch'), ] -LOG = logging.getLogger(__name__) +utils_opts = [ + cfg.IntOpt('password_length', + default=12, + help='Length of generated instance admin passwords'), + cfg.BoolOpt('disable_process_locking', + default=False, + help='Whether to disable inter-process locks'), +] CONF = cfg.CONF CONF.register_opts(monkey_patch_opts) -CONF.register_opt( - cfg.BoolOpt('disable_process_locking', default=False, - help='Whether to disable inter-process locks')) +CONF.register_opts(utils_opts) CONF.import_opt('glance_host', 'nova.config') CONF.import_opt('glance_port', 'nova.config') CONF.import_opt('glance_protocol', 'nova.config') @@ -77,6 +82,8 @@ CONF.import_opt('instance_usage_audit_period', 'nova.config') CONF.import_opt('rootwrap_config', 'nova.config') CONF.import_opt('service_down_time', 'nova.config') +LOG = logging.getLogger(__name__) + # Used for looking up extensions of text # to their 'multiplied' byte amount BYTE_MULTIPLIERS = { @@ -423,7 +430,7 @@ def last_completed_audit_period(unit=None, before=None): return (begin, end) -def generate_password(length=20, symbolgroups=DEFAULT_PASSWORD_SYMBOLS): +def generate_password(length=None, symbolgroups=DEFAULT_PASSWORD_SYMBOLS): """Generate a random password from the supplied symbol groups. At least one symbol from each group will be included. Unpredictable @@ -432,6 +439,9 @@ def generate_password(length=20, symbolgroups=DEFAULT_PASSWORD_SYMBOLS): Believed to be reasonably secure (with a reasonable password length!) """ + if length is None: + length = CONF.password_length + r = random.SystemRandom() # NOTE(jerdfelt): Some password policies require at least one character |