summaryrefslogtreecommitdiff
path: root/ceilometer/polling
diff options
context:
space:
mode:
authorRafael Weingärtner <rafael@apache.org>2020-05-29 12:42:28 -0300
committerRafael Weingärtner <rafael@apache.org>2020-07-21 23:44:15 -0300
commit51119ddc1c7a98674ac9216cbfb890b1a2dab6a2 (patch)
tree48693d497fecac7f236d3eef21b2654bcf55450d /ceilometer/polling
parent57017afbcb2bab1791fe50ee6143f89368ba909e (diff)
downloadceilometer-51119ddc1c7a98674ac9216cbfb890b1a2dab6a2.tar.gz
Allow operations on Ceilometer dynamic pollster to reference the sample itself
This issue is to allow operators to create expressions that can reference the sample itself. Currently, the expression is allowed only for fields in the sample, and not the sample itself. We discovered this requirement when developing pollsters for Cinder; the attribute `volume_image_metadata` is not returned in the API response when it does not exist, therefore, we need a method to check if it exist before trying to retrieve it. Change-Id: I5d3eb04534afaeb556ddab4ef603a205745883b8
Diffstat (limited to 'ceilometer/polling')
-rw-r--r--ceilometer/polling/dynamic_pollster.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/ceilometer/polling/dynamic_pollster.py b/ceilometer/polling/dynamic_pollster.py
index 6cb5442a..db183308 100644
--- a/ceilometer/polling/dynamic_pollster.py
+++ b/ceilometer/polling/dynamic_pollster.py
@@ -138,8 +138,12 @@ class PollsterSampleExtractor(object):
attribute_key, json_object)
keys_and_operations = attribute_key.split("|")
attribute_key = keys_and_operations[0].strip()
- nested_keys = attribute_key.split(".")
- value = reduce(operator.getitem, nested_keys, json_object)
+
+ if attribute_key == ".":
+ value = json_object
+ else:
+ nested_keys = attribute_key.split(".")
+ value = reduce(operator.getitem, nested_keys, json_object)
return self.operate_value(keys_and_operations, value)