This file is indexed.

/usr/lib/python2.7/dist-packages/osprofiler/drivers/ceilometer.py is in python-osprofiler 1.15.2-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Copyright 2016 Mirantis Inc.
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from osprofiler.drivers import base
from osprofiler import exc


class Ceilometer(base.Driver):
    def __init__(self, connection_str, **kwargs):
        """Driver receiving profiled information from ceilometer."""
        super(Ceilometer, self).__init__(connection_str)
        try:
            import ceilometerclient.client
        except ImportError:
            raise exc.CommandError(
                "To use this command, you should install "
                "'ceilometerclient' manually. Use command:\n "
                "'pip install python-ceilometerclient'.")

        try:
            self.client = ceilometerclient.client.get_client(
                kwargs["ceilometer_api_version"], **kwargs)
        except Exception as e:
            if hasattr(e, "http_status") and e.http_status == 401:
                msg = "Invalid OpenStack Identity credentials."
            else:
                msg = "Error occurred while connecting to Ceilometer: %s." % e
            raise exc.CommandError(msg)

    @classmethod
    def get_name(cls):
        return "ceilometer"

    def get_report(self, base_id):
        """Retrieves and parses notification from ceilometer.

        :param base_id: Base id of trace elements.
        """

        _filter = [{"field": "base_id", "op": "eq", "value": base_id}]

        # limit is hardcoded in this code state. Later that will be changed via
        # connection string usage
        notifications = [n.to_dict()
                         for n in self.client.events.list(_filter,
                                                          limit=100000)]

        for n in notifications:
            traits = n["traits"]

            def find_field(f_name):
                return [t["value"] for t in traits if t["name"] == f_name][0]

            trace_id = find_field("trace_id")
            parent_id = find_field("parent_id")
            name = find_field("name")
            project = find_field("project")
            service = find_field("service")
            host = find_field("host")
            timestamp = find_field("timestamp")

            payload = n.get("raw", {}).get("payload", {})

            self._append_results(trace_id, parent_id, name, project, service,
                                 host, timestamp, payload)

        return self._parse_results()