[placement] quash unicode warning with shared provider

trait.name is expected to be unicode and sqlalchemy will warn when it
doesn't get that. The os_traits library creates default quoted strings
for its symbols, so it needs a six.text_type wrapper to shut the warning
up.

Closes-Bug: #1707168
Change-Id: Id9d859830d584d650ea748c8c5274156a30fd773
This commit is contained in:
Chris Dent
2017-07-28 11:25:13 +01:00
parent 23c4eb3438
commit 5728a575c7

View File

@@ -738,7 +738,9 @@ def _get_providers_with_shared_capacity(ctx, rc_id, amount):
rp_to_rpt_join, t_tbl,
sa.and_(
rpt_tbl.c.trait_id == t_tbl.c.id,
t_tbl.c.name == os_traits.MISC_SHARES_VIA_AGGREGATE,
# The traits table wants unicode trait names, but os_traits
# presents native str, so we need to cast.
t_tbl.c.name == six.text_type(os_traits.MISC_SHARES_VIA_AGGREGATE),
),
)