Merge pull request #54604 from garethgreenaway/2019_2_1_port_50706

[master] Porting #50706 to master
This commit is contained in:
Daniel Wozniak 2020-01-02 14:41:03 -07:00 committed by GitHub
commit ba07d5658a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -268,24 +268,34 @@ def percent(args=None):
@salt.utils.decorators.path.which('blkid')
def blkid(device=None):
def blkid(device=None, token=None):
'''
Return block device attributes: UUID, LABEL, etc. This function only works
on systems where blkid is available.
device
Device name from the system
token
Any valid token used for the search
CLI Example:
.. code-block:: bash
salt '*' disk.blkid
salt '*' disk.blkid /dev/sda
salt '*' disk.blkid token='UUID=6a38ee5-7235-44e7-8b22-816a403bad5d'
salt '*' disk.blkid token='TYPE=ext4'
'''
args = ""
cmd = ['blkid']
if device:
args = " " + device
cmd.append(device)
elif token:
cmd.extend(['-t', token])
ret = {}
blkid_result = __salt__['cmd.run_all']('blkid' + args, python_shell=False)
blkid_result = __salt__['cmd.run_all'](cmd, python_shell=False)
if blkid_result['retcode'] > 0:
return ret