> Here is my updated and untested proposal. I still plan to test this this morning.
> https://pastebin.ubuntu.com/p/DfQqmqDZQJ/
>
> * Some disks may not have serial indicated, and that's OK. Use the
> supplied path instead if present.
I would avoid relaxing this to prevent using the wrong disk. MAAS knows the serial
numbers of the disks.
> * grub_device means we mean to image THAT device, so we shouldn't keep
> the entire list of devices as plausible image targets.
grub_device can be set on more than one disk. In which case we still need to handle the case where we've been given to valid targets and selecting one.
+ if i.get("grub_device"):
+ serial = i.get("serial")
+ if serial:
+ devices = [block.lookup_disk(serial)]
+ LOG.info("choosing device %s based on grub_device flag "
+ "and serial", devices[0])
+ break
This is the general idea; as soon as we meet the selection criteria
we can exit the loop and we have THE specified disk. Note that
block.lookup_disk(serial) may not find the disk in which case it throws
a ValueError; I suggest we continue searching of lookup fails.
> Here is my updated and untested proposal. I still plan to test this this morning. /pastebin. ubuntu. com/p/DfQqmqDZQ J/
> https:/
>
> * Some disks may not have serial indicated, and that's OK. Use the
> supplied path instead if present.
I would avoid relaxing this to prevent using the wrong disk. MAAS knows the serial
numbers of the disks.
> * grub_device means we mean to image THAT device, so we shouldn't keep
> the entire list of devices as plausible image targets.
grub_device can be set on more than one disk. In which case we still need to handle the case where we've been given to valid targets and selecting one.
+ if i.get(" grub_device" ): lookup_ disk(serial) ]
+ serial = i.get("serial")
+ if serial:
+ devices = [block.
+ LOG.info("choosing device %s based on grub_device flag "
+ "and serial", devices[0])
+ break
This is the general idea; as soon as we meet the selection criteria disk(serial) may not find the disk in which case it throws
we can exit the loop and we have THE specified disk. Note that
block.lookup_
a ValueError; I suggest we continue searching of lookup fails.