Well the code itself is clearly fragile because it's blindly pop'ing a result from what could be an empty list:
def get_instance_pci_devs(inst, request_id=None):
"""Get the devices allocated to one or all requests for an instance.
- For generic PCI request, the request id is None.
- For sr-iov networking, the request id is a valid uuid
- There are a couple of cases where all the PCI devices allocated to an
instance need to be returned. Refer to libvirt driver that handles
soft_reboot and hard_boot of 'xen' instances.
"""
pci_devices = inst.pci_devices
if pci_devices is None:
return []
return [device for device in pci_devices if device.request_id == request_id or request_id == 'all']
Well the code itself is clearly fragile because it's blindly pop'ing a result from what could be an empty list:
def get_instance_ pci_devs( inst, request_id=None):
"""Get the devices allocated to one or all requests for an instance.
- For generic PCI request, the request id is None.
device. request_ id == request_id or request_id == 'all']
- For sr-iov networking, the request id is a valid uuid
- There are a couple of cases where all the PCI devices allocated to an
instance need to be returned. Refer to libvirt driver that handles
soft_reboot and hard_boot of 'xen' instances.
"""
pci_devices = inst.pci_devices
if pci_devices is None:
return []
return [device for device in pci_devices if