Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@antoni
Created August 25, 2016 17:16
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 antoni/782d00c746ac11bab755c566a36d5ddd to your computer and use it in GitHub Desktop.
Save antoni/782d00c746ac11bab755c566a36d5ddd to your computer and use it in GitHub Desktop.
def _parse_boot_device_list(boot_device_list):
"""
Returns boot devices order specified by current_assigned_sequence field
(a list with names of the devices)
"""
boot_order = []
for _, devices in boot_device_list.items():
for boot_device in devices:
id_parts = boot_device.id.split("#")
sequence_name = id_parts[1]
device_name = id_parts[2]
# Parse boot sequences only (HDD sequences are also available)
if sequence_name == "BootSeq":
boot_order.append((boot_device.current_assigned_sequence, device_name))
return [ordered_device[1] for ordered_device in sorted(boot_order, key=lambda device: device[0])]
# Przykładowe wywołanie (uwaga: dla Lenovo rzuci NotImplementedError
print(_parse_boot_device_list(wsclient.list_boot_devices()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment