Heat could not create samples with Ceilometer
Heat could not create samples with Ceilometer, because ceilometer client has change some key words in CREATION_ATTRIBUTES which is using by create sample. Change-Id: I8e8dc80ae1b666ae74e2b2c2b757e7f468c25de2 Closes-Bug: #1455421changes/01/183901/3
parent
60300b0149
commit
e4eeeed95a
|
@ -280,14 +280,14 @@ class WatchRule(object):
|
|||
def _to_ceilometer(self, data):
|
||||
clients = self.context.clients
|
||||
sample = {}
|
||||
sample['meter_type'] = 'gauge'
|
||||
sample['counter_type'] = 'gauge'
|
||||
|
||||
for k, d in iter(data.items()):
|
||||
if k == 'Namespace':
|
||||
continue
|
||||
sample['meter_name'] = k
|
||||
sample['sample_volume'] = d['Value']
|
||||
sample['meter_unit'] = d['Unit']
|
||||
sample['counter_name'] = k
|
||||
sample['counter_volume'] = d['Value']
|
||||
sample['counter_unit'] = d['Unit']
|
||||
dims = d.get('Dimensions', {})
|
||||
if isinstance(dims, list):
|
||||
dims = dims[0]
|
||||
|
|
|
@ -605,6 +605,52 @@ class WatchRuleTest(common.HeatTestCase):
|
|||
self.assertEqual(['DummyAction'], actions)
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_to_ceilometer(self):
|
||||
|
||||
rule = {u'EvaluationPeriods': u'1',
|
||||
u'AlarmDescription': u'test alarm',
|
||||
u'Period': u'300',
|
||||
u'ComparisonOperator': u'GreaterThanThreshold',
|
||||
u'Statistic': u'SampleCount',
|
||||
u'Threshold': u'2',
|
||||
u'MetricName': u'CreateDataMetric'}
|
||||
testdata = {u'CreateDataMetric': {"Unit": "Counter", "Value": "1"}}
|
||||
sample = dict()
|
||||
sample['counter_type'] = 'gauge'
|
||||
|
||||
for k, d in iter(testdata.items()):
|
||||
if k == 'Namespace':
|
||||
continue
|
||||
sample['counter_name'] = k
|
||||
sample['counter_volume'] = d['Value']
|
||||
sample['counter_unit'] = d['Unit']
|
||||
dims = d.get('Dimensions', {})
|
||||
if isinstance(dims, list):
|
||||
dims = dims[0]
|
||||
sample['resource_metadata'] = dims
|
||||
sample['resource_id'] = dims.get('InstanceId')
|
||||
|
||||
self.wr = watchrule.WatchRule(context=self.ctx,
|
||||
watch_name='create_data_test',
|
||||
stack_id=self.stack_id, rule=rule)
|
||||
self.wr.store()
|
||||
|
||||
self.m.StubOutWithMock(self.wr.context.clients.client('ceilometer').
|
||||
samples, 'create', True)
|
||||
|
||||
# fake samples.create callback
|
||||
def fake_create(counter_type, counter_name, counter_volume,
|
||||
counter_unit, resource_metadata, resource_id):
|
||||
pass
|
||||
|
||||
self.wr.context.clients.client('ceilometer').samples.\
|
||||
create(**sample).MultipleTimes().WithSideEffects(fake_create)
|
||||
self.m.ReplayAll()
|
||||
try:
|
||||
self.wr._to_ceilometer(testdata)
|
||||
except mox.UnexpectedMethodCallError:
|
||||
raise KeyError("Error input parameter")
|
||||
|
||||
def test_create_watch_data(self):
|
||||
rule = {u'EvaluationPeriods': u'1',
|
||||
u'AlarmDescription': u'test alarm',
|
||||
|
|
Loading…
Reference in New Issue