def get_allocation(app, resource, id): scheduler = ResourceCollection( app.libres_context).scheduler_by_id(resource) if scheduler: allocation = scheduler.allocations_by_ids((id, )).first() # always get the master, even if another id is requested return allocation and allocation.get_master()