From 253dab442ff9d64c88ef5f25173441d3238dcfb0 Mon Sep 17 00:00:00 2001 From: Adam Cooper Date: Thu, 19 Jan 2023 13:37:07 -0600 Subject: [PATCH] Handle mixed leases when searching for reservations with counts (#35) In `chi.lease.get_node_reservation`, if a `count` is provided, the lookup will fail because it searches all reservations for the values of `min_count` and `max_count`. Floating IP reservations have only an `amount`, so the comparison fails. This change simply uses an invalid count for any reservations which have un-bounded counts. --- chi/lease.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chi/lease.py b/chi/lease.py index 985fa82..6d04d15 100644 --- a/chi/lease.py +++ b/chi/lease.py @@ -459,7 +459,7 @@ def _find_node_reservation(res): if res.get("resource_type") != "physical:host": return False if count is not None and not all( - int(res.get(key)) == count for key in ["min_count", "max_count"] + int(res.get(key, -1)) == count for key in ["min_count", "max_count"] ): return False rp = res.get("resource_properties")