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

« back to all changes in this revision

Viewing changes to ceilometer/storage/__init__.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-03-06 14:44:28 UTC
  • mto: (28.1.1 utopic-proposed) (1.2.1)
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: package-import@ubuntu.com-20140306144428-rvphsh4igwyulzf0
Tags: upstream-2014.1~b3
ImportĀ upstreamĀ versionĀ 2014.1~b3

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
"""Storage backend management
19
19
"""
20
20
 
21
 
import urlparse
 
21
import six.moves.urllib.parse as urlparse
22
22
 
23
23
from oslo.config import cfg
24
24
import six
38
38
    cfg.StrOpt('database_connection',
39
39
               secret=True,
40
40
               default=None,
41
 
               help='DEPRECATED - Database connection string',
 
41
               help='DEPRECATED - Database connection string.',
42
42
               ),
43
43
]
44
44
 
48
48
STORAGE_OPTS = [
49
49
    cfg.IntOpt('time_to_live',
50
50
               default=-1,
51
 
               help="""number of seconds that samples are kept
52
 
in the database for (<= 0 means forever)"""),
 
51
               help="Number of seconds that samples are kept "
 
52
               "in the database for (<= 0 means forever)."),
53
53
]
54
54
 
55
55
cfg.CONF.register_opts(STORAGE_OPTS, group='database')
63
63
    """Error raised when the storage backend version is not good enough."""
64
64
 
65
65
 
 
66
class StorageBadAggregate(Exception):
 
67
    """Error raised when an aggregate is unacceptable to storage backend."""
 
68
    code = 400
 
69
 
 
70
 
66
71
def get_engine(conf):
67
72
    """Load the configured engine and return an instance."""
68
73
    if conf.database_connection:
161
166
 
162
167
def expirer():
163
168
    service.prepare_service()
164
 
    LOG.debug(_("Clearing expired metering data"))
165
 
    storage_conn = get_connection(cfg.CONF)
166
 
    storage_conn.clear_expired_metering_data(
167
 
        cfg.CONF.database.time_to_live)
 
169
    if cfg.CONF.database.time_to_live > 0:
 
170
        LOG.debug(_("Clearing expired metering data"))
 
171
        storage_conn = get_connection(cfg.CONF)
 
172
        storage_conn.clear_expired_metering_data(
 
173
            cfg.CONF.database.time_to_live)
 
174
    else:
 
175
        LOG.info(_("Nothing to clean, database time to live is disabled"))