Update mount_volumes to match build_volume_report
This commit is contained in:
parent
29d4e80f7e
commit
1616379398
1 changed files with 9 additions and 5 deletions
|
|
@ -183,6 +183,12 @@ def mount_volumes(device_path=None, read_write=False, scan_corestorage=False):
|
||||||
NOTE: If device_path is specified then only volumes
|
NOTE: If device_path is specified then only volumes
|
||||||
under that path will be mounted.
|
under that path will be mounted.
|
||||||
"""
|
"""
|
||||||
|
def _get_volumes(dev) -> list:
|
||||||
|
"""Convert lsblk JSON tree to a flat list of items, returns list."""
|
||||||
|
volumes = [dev]
|
||||||
|
for child in dev.get('children', []):
|
||||||
|
volumes.extend(_get_volumes(child))
|
||||||
|
return volumes
|
||||||
json_data = {}
|
json_data = {}
|
||||||
volumes = []
|
volumes = []
|
||||||
containers = []
|
containers = []
|
||||||
|
|
@ -199,12 +205,10 @@ def mount_volumes(device_path=None, read_write=False, scan_corestorage=False):
|
||||||
json_data = get_json_from_command(cmd)
|
json_data = get_json_from_command(cmd)
|
||||||
|
|
||||||
# Build list of volumes
|
# Build list of volumes
|
||||||
for dev in json_data.get('blockdevices', []):
|
for dev in _get_volumes(json_data.get('blockdevices', [])):
|
||||||
volumes.append(dev)
|
volumes.append(dev)
|
||||||
for child in dev.get('children', []):
|
if dev.get('parttype', '') == UUID_CORESTORAGE:
|
||||||
volumes.append(child)
|
containers.append(dev['name'])
|
||||||
if child['parttype'] == UUID_CORESTORAGE:
|
|
||||||
containers.append(child['name'])
|
|
||||||
|
|
||||||
# Scan CoreStorage containers
|
# Scan CoreStorage containers
|
||||||
if scan_corestorage:
|
if scan_corestorage:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue