Reformat _get_all_with_shared
This change set pulls the otherwise-unrelated reformatting out of [1]. There is no functional change. [1] https://review.openstack.org/#/c/377215/48/nova/objects/resource_provider.py@1275 Change-Id: I91540a3965ab81bea92b05441e37ae6365da6c68 blueprint: nested-resource-providers
This commit is contained in:
parent
a0ff3e2936
commit
55b6a2f5d3
|
@ -1331,31 +1331,21 @@ def _get_all_with_shared(ctx, resources):
|
||||||
joiner = sa.join
|
joiner = sa.join
|
||||||
if sps:
|
if sps:
|
||||||
joiner = sa.outerjoin
|
joiner = sa.outerjoin
|
||||||
inv_join = joiner(
|
# Add a join condition winnowing this copy of inventories table
|
||||||
rp_link, it,
|
# to only the resource class being analyzed in this loop...
|
||||||
sa.and_(
|
inv_join = joiner(rp_link, it,
|
||||||
jc,
|
sa.and_(jc, it.c.resource_class_id == rc_id))
|
||||||
# Add a join condition winnowing this copy of inventories table
|
|
||||||
# to only the resource class being analyzed in this loop...
|
|
||||||
it.c.resource_class_id == rc_id,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
lastij = it
|
lastij = it
|
||||||
usage_join = sa.outerjoin(
|
usage_join = sa.outerjoin(inv_join, ut,
|
||||||
inv_join, ut,
|
it.c.resource_provider_id == ut.c.resource_provider_id)
|
||||||
it.c.resource_provider_id == ut.c.resource_provider_id,
|
|
||||||
)
|
|
||||||
join_chain = usage_join
|
join_chain = usage_join
|
||||||
|
|
||||||
usage_cond = sa.and_(
|
usage_cond = sa.and_(
|
||||||
(
|
((sql.func.coalesce(ut.c.used, 0) + amount) <=
|
||||||
(sql.func.coalesce(ut.c.used, 0) + amount) <=
|
(it.c.total - it.c.reserved) * it.c.allocation_ratio),
|
||||||
(it.c.total - it.c.reserved) * it.c.allocation_ratio
|
|
||||||
),
|
|
||||||
it.c.min_unit <= amount,
|
it.c.min_unit <= amount,
|
||||||
it.c.max_unit >= amount,
|
it.c.max_unit >= amount,
|
||||||
amount % it.c.step_size == 0,
|
amount % it.c.step_size == 0)
|
||||||
)
|
|
||||||
if not sps:
|
if not sps:
|
||||||
where_conds.append(usage_cond)
|
where_conds.append(usage_cond)
|
||||||
else:
|
else:
|
||||||
|
@ -1366,24 +1356,19 @@ def _get_all_with_shared(ctx, resources):
|
||||||
it.c.resource_provider_id != sa.null(),
|
it.c.resource_provider_id != sa.null(),
|
||||||
usage_cond,
|
usage_cond,
|
||||||
),
|
),
|
||||||
sharing.c.resource_provider_id != sa.null(),
|
sharing.c.resource_provider_id != sa.null())
|
||||||
)
|
|
||||||
where_conds.append(cond)
|
where_conds.append(cond)
|
||||||
|
|
||||||
# We need to add the "butterfly" join now that produces the set of
|
# We need to add the "butterfly" join now that produces the set of
|
||||||
# resource providers associated with a provider that is sharing the
|
# resource providers associated with a provider that is sharing the
|
||||||
# resource via an aggregate
|
# resource via an aggregate
|
||||||
shared_join = sa.outerjoin(
|
shared_join = sa.outerjoin(join_chain, shared,
|
||||||
join_chain, shared,
|
rpt.c.id == shared.c.resource_provider_id)
|
||||||
rpt.c.id == shared.c.resource_provider_id,
|
sharing_join = sa.outerjoin(shared_join, sharing,
|
||||||
)
|
|
||||||
sharing_join = sa.outerjoin(
|
|
||||||
shared_join, sharing,
|
|
||||||
sa.and_(
|
sa.and_(
|
||||||
shared.c.aggregate_id == sharing.c.aggregate_id,
|
shared.c.aggregate_id == sharing.c.aggregate_id,
|
||||||
sharing.c.resource_provider_id.in_(sps),
|
sharing.c.resource_provider_id.in_(sps),
|
||||||
),
|
))
|
||||||
)
|
|
||||||
join_chain = sharing_join
|
join_chain = sharing_join
|
||||||
|
|
||||||
sel = sel.select_from(join_chain)
|
sel = sel.select_from(join_chain)
|
||||||
|
|
Loading…
Reference in New Issue