Created
August 25, 2016 17:16
-
-
Save antoni/782d00c746ac11bab755c566a36d5ddd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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