Allow unicode for metadata keys in publisher

I encountered a bug whith the following configuration in
monasca_field_definitions.yaml:

  metadata:
    cpu:
        - flavor_id: flavor["id"]
        - flavor_name: flavor["name"]

The problem was in _get_value_metadata_for_key(): sometimes keys
from ceilometer samples can be unicode.

Change-Id: I8914c2238f3a450393f07e6309f57451c8c45cf2
This commit is contained in:
Luka Peschke 2018-02-13 17:05:30 +01:00
parent 4a2c73685f
commit cdedb90ed8
1 changed files with 3 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import datetime
from jsonpath_rw_ext import parser
from oslo_log import log
from oslo_utils import timeutils
import six
import yaml
from ceilometer.ceilosca_mapping.ceilosca_mapping import (
@ -125,7 +126,8 @@ class MonascaDataFilter(object):
if len(val_matches) > 0:
# resolve the find to the first match and get value
val = val_matches[0].value
if not isinstance(val, str) and not isinstance(val, int):
if not isinstance(val, (str, six.text_type)) \
and not isinstance(val, int):
# Don't support lists or dicts or ...
raise CeiloscaMappingDefinitionException(
"Metadata format mismatch, value "