Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] Porting #50706 to master #54604

Merged
merged 3 commits into from
Jan 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions salt/modules/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down