Fix list_allocations for multi-host reservations

The get_reservation_allocations_by_host_ids function builds an
allocation dictionary that looks like this:

    allocations = {
        'r1': ['host1'],
        'r2': ['host1', 'host2']
    }

The list returned by this function was only using the first host of each
reservation:

    allocations[r['id']][0]

Loop over hosts to build the list of (reservation, lease, host) tuples.

Change-Id: I55b3cb4e736f6f747c8b3254c62fa40bac3f288f
Closes-Bug: #1958307
(cherry picked from commit 39c67f09b8)
This commit is contained in:
Pierre Riteau 2022-01-18 23:21:43 +01:00
parent e2b8f1f9dc
commit 61daf2d95d
2 changed files with 8 additions and 1 deletions

View File

@ -148,7 +148,8 @@ def get_reservation_allocations_by_host_ids(host_ids, start_date, end_date,
allocs = []
for r in reservations:
allocs.append((r['id'], r['lease_id'], allocations[r['id']][0]))
for host in allocations[r['id']]:
allocs.append((r['id'], r['lease_id'], host))
return allocs

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes result of the List Allocations API for reservations with multiple
physical hosts. For more details, see `bug 1958307
<https://bugs.launchpad.net/blazar/+bug/1958307>`_.