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

« back to all changes in this revision

Viewing changes to ceilometer/compute/util.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
1
#
2
2
# Copyright 2014 Red Hat, Inc
3
3
#
4
 
# Author: Eoghan Glynn <eglynn@redhat.com>
5
 
#
6
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
5
# not use this file except in compliance with the License. You may obtain
8
6
# a copy of the License at
15
13
# License for the specific language governing permissions and limitations
16
14
# under the License.
17
15
 
18
 
from oslo.config import cfg
 
16
from oslo_config import cfg
19
17
import six
20
18
 
21
19
 
 
20
# Below config is for collecting metadata which user defined in nova or else,
 
21
# and then storing it to Sample for future use according to user's requirement.
 
22
# Such as using it as OpenTSDB tags for metrics.
22
23
OPTS = [
23
24
    cfg.ListOpt('reserved_metadata_namespace',
24
25
                default=['metering.'],
26
27
    cfg.IntOpt('reserved_metadata_length',
27
28
               default=256,
28
29
               help='Limit on length of reserved metadata values.'),
 
30
    cfg.ListOpt('reserved_metadata_keys',
 
31
                default=[],
 
32
                help='List of metadata keys reserved for metering use. And '
 
33
                     'these keys are additional to the ones included in the '
 
34
                     'namespace.'),
29
35
]
30
36
 
31
37
cfg.CONF.register_opts(OPTS)
43
49
                k[len(prefix):].replace('.', '_') not in dest_metadata)
44
50
        )
45
51
        user_metadata.update(md)
 
52
 
 
53
    for metadata_key in cfg.CONF.reserved_metadata_keys:
 
54
        md = dict(
 
55
            (k.replace('.', '_'),
 
56
             v[:limit] if isinstance(v, six.string_types) else v)
 
57
            for k, v in src_metadata.items()
 
58
            if (k == metadata_key and
 
59
                k.replace('.', '_') not in dest_metadata)
 
60
        )
 
61
        user_metadata.update(md)
 
62
 
46
63
    if user_metadata:
47
64
        dest_metadata['user_metadata'] = user_metadata
48
65