summaryrefslogtreecommitdiff
path: root/nova/scheduler/filters/pci_passthrough_filter.py
diff options
context:
space:
mode:
Diffstat (limited to 'nova/scheduler/filters/pci_passthrough_filter.py')
-rw-r--r--nova/scheduler/filters/pci_passthrough_filter.py33
1 files changed, 10 insertions, 23 deletions
diff --git a/nova/scheduler/filters/pci_passthrough_filter.py b/nova/scheduler/filters/pci_passthrough_filter.py
index 36f0b5901c..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
@@ -54,28 +57,12 @@ class PciPassthroughFilter(filters.BaseHostFilter):
{'host_state': host_state, 'requests': pci_requests})
return False
- good_candidates = []
- for candidate in host_state.allocation_candidates:
- LOG.debug(
- 'PciPassthroughFilter tries allocation candidate: %s',
- candidate
- )
- if host_state.pci_stats.support_requests(
- pci_requests.requests,
- provider_mapping=candidate['mappings']
- ):
- LOG.debug(
- 'PciPassthroughFilter accepted allocation candidate: %s',
- candidate
- )
- good_candidates.append(candidate)
- else:
- LOG.debug(
- 'PciPassthroughFilter rejected allocation candidate: %s',
- candidate
- )
-
- host_state.allocation_candidates = good_candidates
+ 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"