Add a method to the Guest XMLBuilder for getting all bootable devices of the guest definition with the option to exclude the redirdevs in the returned list. Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx> Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx> --- virtManager/domain.py | 5 +---- virtinst/guest.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/virtManager/domain.py b/virtManager/domain.py index 0b17e548e68e..14237eb4432a 100644 --- a/virtManager/domain.py +++ b/virtManager/domain.py @@ -1314,10 +1314,7 @@ class vmmDomain(vmmLibvirtObject): def get_bootable_devices(self): # redirdev can also be marked bootable, but it should be rarely # used and clutters the UI - devs = (self.xmlobj.devices.disk + - self.xmlobj.devices.interface + - self.xmlobj.devices.hostdev) - return devs + return self.xmlobj.get_bootable_devices(exclude_redirdev=True) def get_serialcon_devices(self): return self.xmlobj.devices.serial + self.xmlobj.devices.console diff --git a/virtinst/guest.py b/virtinst/guest.py index c0043cbc94c0..c1c175b6d75d 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -367,6 +367,19 @@ class Guest(XMLBuilder): self.devices.remove_child(dev) devices = XMLChildProperty(_DomainDevices, is_single=True) + def get_bootable_devices(self, exclude_redirdev=False): + """ + Returns bootable devices of the guest definition. If + @exclude_redirdev is `True` redirected devices will be + skipped in the output. + + """ + devices = self.devices + devs = devices.disk + devices.interface + devices.hostdev + if not exclude_redirdev: + devs = devs + devices.redirdev + return devs + def prefers_uefi(self): """ Return True if this config prefers UEFI. For example, -- 2.17.0 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list