Skip to content

Instantly share code, notes, and snippets.

@ErwanAliasr1
Last active April 13, 2016 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErwanAliasr1/6bab31f84e1f34cec768017a367d66f9 to your computer and use it in GitHub Desktop.
Save ErwanAliasr1/6bab31f84e1f34cec768017a367d66f9 to your computer and use it in GitHub Desktop.
def get_scratch_devices2(remote):
"""
Extract the list of free block device from a host
"""
used_block_devices = get_used_block_devices(remote)
used_block_devices.append(get_root_device(remote))
translated_uuids = translate_block_UUID(used_block_devices)
expanded_block_devices = expand_dm_devices(translated_uuids)
translated_block_devices = translate_block_devices_path(expanded_block_devices)
final_used_block_devices = partitions_to_block_device(translated_block_devices)
all_block_devices = translate_block_devices_path(expand_dm_devices(get_block_devices()))
final_all_block_devices = partitions_to_block_device(all_block_devices)
free_block_devices = get_free_block_devices(final_all_block_devices, final_used_block_devices)
# If we didn't got a single used device,
if len(free_block_devices) == len(final_all_block_devices):
log.error("All block devices are seen as free ! That will surely damage data")
# We return an empty list to avoid listing a mis-detected used device
return []
return free_block_devices
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment