Use trait strings in ProviderSummary objects
When ProviderSummary objects are created and then later serialized to JSON the traits attribute has been a list of Trait objects. At no point in the processing of that attribute does any caller want it to be a Trait. They are stored as TraitS but used as strings. Therefore, this change makes it so it is a list of strings, avoiding a few different instances of translating one way or the other, keeping the data in the format the system wants. Change-Id: Ia9d81ce87111ec3496d10ed254f069c04b9bdf3c
This commit is contained in:
parent
346509f8fa
commit
5f4da5e040
placement
handlers
objects
tests/functional/db
@ -192,8 +192,7 @@ def _transform_provider_summaries(p_sums, requests, want_version):
|
||||
ret[ps.resource_provider.uuid] = {'resources': resources}
|
||||
|
||||
if include_traits:
|
||||
ret[ps.resource_provider.uuid]['traits'] = [
|
||||
t.name for t in ps.traits]
|
||||
ret[ps.resource_provider.uuid]['traits'] = ps.traits
|
||||
|
||||
if enable_nested_providers:
|
||||
ret[ps.resource_provider.uuid]['parent_provider_uuid'] = (
|
||||
|
@ -484,7 +484,7 @@ def _alloc_candidates_single_provider(ctx, requested_resources, rp_tuples):
|
||||
alloc_requests.append(req_obj)
|
||||
# If this is a sharing provider, we have to include an extra
|
||||
# AllocationRequest for every possible anchor.
|
||||
traits = [trait.name for trait in rp_summary.traits]
|
||||
traits = rp_summary.traits
|
||||
if os_traits.MISC_SHARES_VIA_AGGREGATE in traits:
|
||||
anchors = set([p[1] for p in rp_obj.anchors_for_sharing_providers(
|
||||
ctx, [rp_summary.resource_provider.id])])
|
||||
@ -567,9 +567,7 @@ def _build_provider_summaries(context, usages, prov_traits):
|
||||
)
|
||||
summaries[rp_id] = summary
|
||||
|
||||
traits = prov_traits[rp_id]
|
||||
summary.traits = [trait_obj.Trait(context, name=tname)
|
||||
for tname in traits]
|
||||
summary.traits = prov_traits[rp_id]
|
||||
|
||||
rc_id = usage['resource_class_id']
|
||||
if rc_id is None:
|
||||
@ -627,7 +625,7 @@ def _check_traits_for_alloc_request(res_requests, summaries, required_traits,
|
||||
for res_req in res_requests:
|
||||
rp_id = res_req.resource_provider.id
|
||||
rp_summary = summaries[rp_id]
|
||||
rp_traits = set([trait.name for trait in rp_summary.traits])
|
||||
rp_traits = set(rp_summary.traits)
|
||||
|
||||
# Check if there are forbidden_traits
|
||||
conflict_traits = set(forbidden_traits) & set(rp_traits)
|
||||
|
@ -955,7 +955,7 @@ class AllocationCandidatesTestCase(tb.PlacementDbBaseTestCase):
|
||||
observed = {}
|
||||
for psum in candidates.provider_summaries:
|
||||
rpname = self.rp_uuid_to_name[psum.resource_provider.uuid]
|
||||
observed[rpname] = set(trait.name for trait in psum.traits)
|
||||
observed[rpname] = set(psum.traits)
|
||||
|
||||
self.assertEqual(expected, observed)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user