This file is indexed.

/usr/lib/python2.7/dist-packages/neutronclient/tests/unit/osc/v2/trunk/fakes.py is in python-neutronclient 1:6.0.0-2.

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
80
81
82
83
84
#   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.

import copy
import mock
import uuid


class FakeTrunk(object):
    """Fake one or more trunks."""
    @staticmethod
    def create_one_trunk(attrs=None):
        """Create a fake trunk.

        :param Dictionary attrs:
            A dictionary with all attributes
        :return:
            A Dictionary with id, name, description, admin_state_up, port_id,
            sub_ports, status and project_id
        """
        attrs = attrs or {}

        # Set default attributes.
        trunk_attrs = {
            'id': 'trunk-id-' + uuid.uuid4().hex,
            'name': 'trunk-name-' + uuid.uuid4().hex,
            'description': '',
            'port_id': 'port-' + uuid.uuid4().hex,
            'admin_state_up': True,
            'project_id': 'project-id-' + uuid.uuid4().hex,
            'status': 'ACTIVE',
            'sub_ports': [{'port_id': 'subport-' + uuid.uuid4().hex,
                           'segmentation_type': 'vlan',
                           'segmentation_id': 100}],
        }

        # Overwrite default attributes.
        trunk_attrs.update(attrs)
        return copy.deepcopy(trunk_attrs)

    @staticmethod
    def create_trunks(attrs=None, count=2):
        """Create multiple fake trunks.

        :param Dictionary attrs:
            A dictionary with all attributes
        :param int count:
            The number of routers to fake
        :return:
            A list of dictionaries faking the trunks
        """
        trunks = []
        for i in range(0, count):
            trunks.append(FakeTrunk.create_one_trunk(attrs))

        return trunks

    @staticmethod
    def get_trunks(trunks=None, count=2):
        """Get an iterable MagicMock object with a list of faked trunks.

        If trunks list is provided, then initialize the Mock object with the
        list. Otherwise create one.

        :param List trunks:
            A list of FakeResource objects faking trunks
        :param int count:
            The number of trunks to fake
        :return:
            An iterable Mock object with side_effect set to a list of faked
            trunks
        """
        if trunks is None:
            trunks = FakeTrunk.create_trunks(count)
        return mock.MagicMock(side_effect=trunks)