mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
added random integer module to mod_random.py
fixes #24407 this will help solve it
This commit is contained in:
parent
508d7ddb91
commit
3613cc9659
1 changed files with 19 additions and 0 deletions
|
@ -7,6 +7,7 @@ Provides access to randomness generators.
|
|||
from __future__ import absolute_import
|
||||
# Import python libs
|
||||
import hashlib
|
||||
import random
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils.pycrypto
|
||||
|
@ -118,3 +119,21 @@ def shadow_hash(crypt_salt=None, password=None, algorithm='sha512'):
|
|||
salt '*' random.shadow_hash 'My5alT' 'MyP@asswd' md5
|
||||
'''
|
||||
return salt.utils.pycrypto.gen_hash(crypt_salt, password, algorithm)
|
||||
|
||||
def rand_int(start=1, end=10):
|
||||
'''
|
||||
.. versionadded: 2015.5.1
|
||||
|
||||
Returns a random integer number between the start and end number.
|
||||
|
||||
start : 1
|
||||
Any valid integer number
|
||||
|
||||
end : 10
|
||||
Any valid integer number
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' random.rand_int 1 10
|
||||
'''
|
||||
return random.randint(start, end)
|
||||
|
|
Loading…
Add table
Reference in a new issue