summaryrefslogtreecommitdiff
path: root/ceilometer/sample.py
diff options
context:
space:
mode:
authorliu-sheng <liusheng@huawei.com>2015-06-16 11:00:07 +0800
committerliu-sheng <liusheng@huawei.com>2015-06-24 17:11:59 +0800
commit98581c243af9cd1bf02e8940b216a2129af2d052 (patch)
treed65bcf372a5cfd0057e1c7bf202e85c456d3ceb5 /ceilometer/sample.py
parent1ffc1c4664656bc9637c3928a7254755648f215b (diff)
downloadceilometer-98581c243af9cd1bf02e8940b216a2129af2d052.tar.gz
Add handler of sample creation notification
This change add a notification handler of sample.create event, which is emitted when posting samples via /v2/meters API. The sample's info is include in the payload of notification. Partially implements: blueprint api-no-pipeline Change-Id: I3941b851249c0f70f864bae32da154819b3e5dd7
Diffstat (limited to 'ceilometer/sample.py')
-rw-r--r--ceilometer/sample.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/ceilometer/sample.py b/ceilometer/sample.py
index ec10ea61..25c9f586 100644
--- a/ceilometer/sample.py
+++ b/ceilometer/sample.py
@@ -54,10 +54,12 @@ cfg.CONF.register_opts(OPTS)
# Resource ID: the resource ID
# Timestamp: when the sample has been read
# Resource metadata: various metadata
+# id: an uuid of a sample, can be taken from API when post sample via API
class Sample(object):
def __init__(self, name, type, unit, volume, user_id, project_id,
- resource_id, timestamp, resource_metadata, source=None):
+ resource_id, timestamp, resource_metadata, source=None,
+ id=None):
self.name = name
self.type = type
self.unit = unit
@@ -68,7 +70,7 @@ class Sample(object):
self.timestamp = timestamp
self.resource_metadata = resource_metadata
self.source = source or cfg.CONF.sample_source
- self.id = str(uuid.uuid1())
+ self.id = id or str(uuid.uuid1())
def as_dict(self):
return copy.copy(self.__dict__)