Thanks to Fan Zhiqiang, I found ceilometer/compute/util.py has a method "add_reserved_user_metadata" can have the func with configurable getting metadata.
However, there seems some bug there that will made return a dict with empty key.
For example:
If src_metadata is like 'metadata': {'project_cos': 'dev', 'fqdn': 'localhost'}
Add I define in ceilometer.conf with "reserved_metadata_namespace=project_cos,fqdn",
then what I got with add_reserved_user_metadata method will be {'': 'localhost'}. Notice the key is empty, and there's only 1 entry rather than 2.
I was confusing with below statement:
md = dict( (k[len(prefix):].replace('.', '_'), v[:limit] if isinstance(v, six.string_types) else v)
why key have slicing operation with length of prefix? Then how could I define prefix if metadata's key didn't start with one same prefix?
So I suggest to change to below statement to make it more common to use with various naming convention key in metadata.
md = dict( (k.replace('.', '_'), v[:limit] if isinstance(v, six.string_types) else v)
Thanks to Fan Zhiqiang, I found ceilometer/ compute/ util.py has a method "add_reserved_ user_metadata" can have the func with configurable getting metadata.
However, there seems some bug there that will made return a dict with empty key.
For example:
If src_metadata is like 'metadata': {'project_cos': 'dev', 'fqdn': 'localhost'} metadata_ namespace= project_ cos,fqdn" , user_metadata method will be {'': 'localhost'}. Notice the key is empty, and there's only 1 entry rather than 2.
Add I define in ceilometer.conf with "reserved_
then what I got with add_reserved_
I was confusing with below statement:
(k[ len(prefix) :].replace( '.', '_'),
v[ :limit] if isinstance(v, six.string_types) else v)
md = dict(
why key have slicing operation with length of prefix? Then how could I define prefix if metadata's key didn't start with one same prefix?
So I suggest to change to below statement to make it more common to use with various naming convention key in metadata.
(k. replace( '.', '_'),
v[ :limit] if isinstance(v, six.string_types) else v)
md = dict(