Add hash_type argument to key module fingerprint functions

This commit is contained in:
Adam Mendlik 2016-12-28 09:41:25 -07:00
parent d0f4c300b7
commit c8681269a4

View file

@ -11,31 +11,43 @@ import os
import salt.utils
def finger():
def finger(hash_type=None):
'''
Return the minion's public key fingerprint
hash_type
The hash algorithm used to calculate the fingerprint
CLI Example:
.. code-block:: bash
salt '*' key.finger
'''
# MD5 here is temporary. Change to SHA256 when retired.
return salt.utils.pem_finger(os.path.join(__opts__['pki_dir'], 'minion.pub'),
sum_type=__opts__.get('hash_type', 'md5'))
if hash_type is None:
hash_type = __opts__['hash_type']
return salt.utils.pem_finger(
os.path.join(__opts__['pki_dir'], 'minion.pub'),
sum_type=hash_type)
def finger_master():
def finger_master(hash_type=None):
'''
Return the fingerprint of the master's public key on the minion.
hash_type
The hash algorithm used to calculate the fingerprint
CLI Example:
.. code-block:: bash
salt '*' key.finger_master
'''
# MD5 here is temporary. Change to SHA256 when retired.
return salt.utils.pem_finger(os.path.join(__opts__['pki_dir'], 'minion_master.pub'),
sum_type=__opts__.get('hash_type', 'md5'))
if hash_type is None:
hash_type = __opts__['hash_type']
return salt.utils.pem_finger(
os.path.join(__opts__['pki_dir'], 'minion_master.pub'),
sum_type=hash_type)