diff options
author | Yadnesh Kulkarni <ykulkarn@redhat.com> | 2023-04-04 10:51:06 +0530 |
---|---|---|
committer | Yadnesh Kulkarni <ykulkarn@redhat.com> | 2023-04-04 19:02:46 +0530 |
commit | 6e339d3e74df5460d372b3e2abce27664ddb1100 (patch) | |
tree | eac50f6786e342ab17a870d0faa6fd08cb6115ca /ceilometer/meter | |
parent | 7dd58d6f75ffcfe9a9097e9f83be3087000ad355 (diff) | |
download | ceilometer-6e339d3e74df5460d372b3e2abce27664ddb1100.tar.gz |
Add vanity names to notification samples
This change adds "project_name" and "user_name" fields to the
polling samples created from notifications of "event_type".
Also move caching helper functions into "ceilometer/cache_utils.py"
to make them accessible throughout the project.
Change-Id: I68bd4ee096b28a2fd952e749d56a6b3eed9bfb94
Diffstat (limited to 'ceilometer/meter')
-rw-r--r-- | ceilometer/meter/notifications.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/ceilometer/meter/notifications.py b/ceilometer/meter/notifications.py index 3846ac61..159f72bd 100644 --- a/ceilometer/meter/notifications.py +++ b/ceilometer/meter/notifications.py @@ -15,6 +15,7 @@ import itertools import os import re +from ceilometer import cache_utils from oslo_config import cfg from oslo_log import log from stevedore import extension @@ -165,8 +166,22 @@ class MeterDefinition(object): # NOTE(sileht): Transform the sample with multiple values per # attribute into multiple samples with one value per attribute. for values in zip(*samples_values): - yield dict((attributes[idx], value) - for idx, value in enumerate(values)) + sample = dict((attributes[idx], value) + for idx, value in enumerate(values)) + + # populate user_name and project_name fields in the sample + # created from notifications + if sample['user_id']: + sample['user_name'] = \ + cache_utils.resolve_uuid_from_cache( + self.conf, 'users', sample['user_id'] + ) + if sample['project_id']: + sample['project_name'] = \ + cache_utils.resolve_uuid_from_cache( + self.conf, 'projects', sample['project_id'] + ) + yield sample else: yield sample |