summaryrefslogtreecommitdiff
path: root/nova/scheduler/filters/pci_passthrough_filter.py
diff options
context:
space:
mode:
authorBalazs Gibizer <gibi@redhat.com>2023-01-05 19:32:13 +0100
committerBalazs Gibizer <gibi@redhat.com>2023-01-20 17:17:48 +0100
commit87c0602537688c3da2291792a98caf9d9faf9d6c (patch)
tree95a9a8d5230bb54931ff27f419c7513c1254ce09 /nova/scheduler/filters/pci_passthrough_filter.py
parent6abbcc5033c86c1503d2e8018687476c16ebf6f2 (diff)
downloadnova-87c0602537688c3da2291792a98caf9d9faf9d6c.tar.gz
Factor out a mixin class for candidate aware filters
blueprint: pci-device-tracking-in-placement Change-Id: Id044131162e582cef41e424aa751e3cd3618ed0c
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"