~ubuntu-branches/ubuntu/vivid/ceilometer/vivid

« back to all changes in this revision

Viewing changes to ceilometer/alarm/storage/impl_sqlalchemy.py

  • Committer: Package Import Robot
  • Author(s): James Page, Corey Bryant, James Page
  • Date: 2015-02-19 14:59:07 UTC
  • mfrom: (1.2.3)
  • Revision ID: package-import@ubuntu.com-20150219145907-9jojybdsl64zcn14
Tags: 2015.1~b2-0ubuntu1
[ Corey Bryant ]
* New upstream release.
  - d/control: Align requirements with upstream.
  - d/p/skip-test.patch: Rebased.

[ James Page ]
* d/rules,d/p/skip-gabbi.patch: Skip tests that rely on python-gabbi until
  packaging and MIR is complete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# Author: John Tran <jhtran@att.com>
3
 
#         Julien Danjou <julien@danjou.info>
4
 
#
5
1
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
2
# not use this file except in compliance with the License. You may obtain
7
3
# a copy of the License at
19
15
from __future__ import absolute_import
20
16
import os
21
17
 
22
 
from oslo.config import cfg
23
18
from oslo.db.sqlalchemy import session as db_session
 
19
from oslo_config import cfg
24
20
from sqlalchemy import desc
25
21
 
26
22
import ceilometer
136
132
                                          row.insufficient_data_actions),
137
133
                                      rule=row.rule,
138
134
                                      time_constraints=row.time_constraints,
139
 
                                      repeat_actions=row.repeat_actions)
 
135
                                      repeat_actions=row.repeat_actions,
 
136
                                      severity=row.severity)
140
137
 
141
138
    def _retrieve_alarms(self, query):
142
139
        return (self._row_to_alarm_model(x) for x in query.all())
143
140
 
144
141
    def get_alarms(self, name=None, user=None, state=None, meter=None,
145
142
                   project=None, enabled=None, alarm_id=None, pagination=None,
146
 
                   alarm_type=None):
 
143
                   alarm_type=None, severity=None):
147
144
        """Yields a lists of alarms that match filters.
148
145
 
149
146
        :param name: Optional name for alarm.
155
152
        :param alarm_id: Optional alarm_id to return one alarm.
156
153
        :param pagination: Optional pagination query.
157
154
        :param alarm_type: Optional alarm type.
 
155
        :param severity: Optional alarm severity
158
156
        """
159
157
 
160
158
        if pagination:
176
174
            query = query.filter(models.Alarm.state == state)
177
175
        if alarm_type is not None:
178
176
            query = query.filter(models.Alarm.type == alarm_type)
 
177
        if severity is not None:
 
178
            query = query.filter(models.Alarm.severity == severity)
179
179
 
180
180
        query = query.order_by(desc(models.Alarm.timestamp))
181
181
        alarms = self._retrieve_alarms(query)
250
250
 
251
251
    def get_alarm_changes(self, alarm_id, on_behalf_of,
252
252
                          user=None, project=None, alarm_type=None,
253
 
                          start_timestamp=None, start_timestamp_op=None,
254
 
                          end_timestamp=None, end_timestamp_op=None):
 
253
                          severity=None, start_timestamp=None,
 
254
                          start_timestamp_op=None, end_timestamp=None,
 
255
                          end_timestamp_op=None):
255
256
        """Yields list of AlarmChanges describing alarm history
256
257
 
257
258
        Changes are always sorted in reverse order of occurrence, given
270
271
        :param user: Optional ID of user to return changes for
271
272
        :param project: Optional ID of project to return changes for
272
273
        :param alarm_type: Optional change type
 
274
        :param severity: Optional alarm severity
273
275
        :param start_timestamp: Optional modified timestamp start range
274
276
        :param start_timestamp_op: Optional timestamp start range operation
275
277
        :param end_timestamp: Optional modified timestamp end range
288
290
            query = query.filter(models.AlarmChange.project_id == project)
289
291
        if alarm_type is not None:
290
292
            query = query.filter(models.AlarmChange.type == alarm_type)
 
293
        if severity is not None:
 
294
            query = query.filter(models.AlarmChange.severity == severity)
291
295
        if start_timestamp:
292
296
            if start_timestamp_op == 'gt':
293
297
                query = query.filter(