def create_aodh_metrics_threshold_alarm(resource_id=None, name=None): if not name: name = '%s-%s' % ('test_', random.randrange(0, 100000, 1)) met = TempestClients.gnocchi().metric.create(resource_id=resource_id, name='test', archive_policy_name='high') metric = met[AodhProps.ID] rule_opts = dict(threshold='100', aggregation_method='mean', comparison_operator='lt', metrics=[metric]) rule = {AodhProps.METRICS_THRESHOLD_RULE: rule_opts} aodh_request = _aodh_request(AodhProps.METRICS_THRESHOLD, resource_id=resource_id, name=name, rule=rule) TempestClients.aodh().alarm.create(aodh_request) time.sleep(10)
def _get_gnocchi_resource_id(): return TempestClients.gnocchi().resource.list()[0][AodhProps.ID]
def delete_all_gnocchi_metrics(): metrics = TempestClients.gnocchi().metric.list() for metric in metrics: TempestClients.gnocchi().metric.delete(metric[AodhProps.ID]) time.sleep(10)