diff options
Diffstat (limited to 'nova/scheduler/filters/pci_passthrough_filter.py')
-rw-r--r-- | nova/scheduler/filters/pci_passthrough_filter.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/nova/scheduler/filters/pci_passthrough_filter.py b/nova/scheduler/filters/pci_passthrough_filter.py index f08899586a..992879072a 100644 --- a/nova/scheduler/filters/pci_passthrough_filter.py +++ b/nova/scheduler/filters/pci_passthrough_filter.py @@ -20,7 +20,10 @@ from nova.scheduler import filters LOG = logging.getLogger(__name__) -class PciPassthroughFilter(filters.BaseHostFilter): +class PciPassthroughFilter( + filters.BaseHostFilter, + filters.CandidateFilterMixin, +): """Pci Passthrough Filter based on PCI request Filter that schedules instances on a host if the host has devices @@ -47,10 +50,24 @@ class PciPassthroughFilter(filters.BaseHostFilter): pci_requests = spec_obj.pci_requests if not pci_requests or not pci_requests.requests: return True - if (not host_state.pci_stats or - not host_state.pci_stats.support_requests(pci_requests.requests)): + + if not host_state.pci_stats: + LOG.debug("%(host_state)s doesn't have the required PCI devices" + " (%(requests)s)", + {'host_state': host_state, 'requests': pci_requests}) + return False + + good_candidates = self.filter_candidates( + host_state, + lambda candidate: host_state.pci_stats.support_requests( + pci_requests.requests, provider_mapping=candidate["mappings"] + ), + ) + + if not good_candidates: LOG.debug("%(host_state)s doesn't have the required PCI devices" " (%(requests)s)", {'host_state': host_state, 'requests': pci_requests}) return False + return True |