This file is indexed.

/usr/lib/python2.7/dist-packages/neutronclient/neutron/v2_0/lb/v2/l7rule.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
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Copyright 2016 Radware LTD.
# 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 neutronclient._i18n import _
from neutronclient.common import utils
from neutronclient.neutron import v2_0 as neutronV20


def _get_policy_id(client, policy_id_or_name):
    return neutronV20.find_resourceid_by_name_or_id(
        client, 'l7policy', policy_id_or_name,
        cmd_resource='lbaas_l7policy')


class LbaasL7RuleMixin(object):

    def set_extra_attrs(self, parsed_args):
        self.parent_id = _get_policy_id(self.get_client(),
                                        parsed_args.l7policy)

    def add_known_arguments(self, parser):
        parser.add_argument(
            'l7policy', metavar='L7POLICY',
            help=_('ID or name of L7 policy this rule belongs to.'))


def _add_common_args(parser, is_create=True):
        parser.add_argument(
            '--type',
            required=is_create,
            type=utils.convert_to_uppercase,
            choices=['HOST_NAME', 'PATH', 'FILE_TYPE', 'HEADER', 'COOKIE'],
            help=_('Rule type.'))
        parser.add_argument(
            '--compare-type',
            required=is_create,
            type=utils.convert_to_uppercase,
            choices=['REGEX', 'STARTS_WITH', 'ENDS_WITH',
                     'CONTAINS', 'EQUAL_TO'],
            help=_('Rule compare type.'))
        parser.add_argument(
            '--invert-compare',
            dest='invert',
            action='store_true',
            help=_('Invert the compare type.'))
        parser.add_argument(
            '--key',
            help=_('Key to compare.'
                   ' Relevant for HEADER and COOKIE types only.'))
        parser.add_argument(
            '--value',
            required=is_create,
            help=_('Value to compare.'))


def _common_args2body(client, parsed_args, is_create=True):
    attributes = ['type', 'compare_type',
                  'invert', 'key', 'value', 'admin_state_up']
    if is_create:
        attributes.append('tenant_id')
    body = {}
    neutronV20.update_dict(parsed_args, body, attributes)
    return {'rule': body}


class ListL7Rule(LbaasL7RuleMixin, neutronV20.ListCommand):
    """LBaaS v2 List L7 rules that belong to a given L7 policy."""

    resource = 'rule'
    shadow_resource = 'lbaas_l7rule'
    pagination_support = True
    sorting_support = True

    list_columns = [
        'id', 'type', 'compare_type', 'invert', 'key', 'value',
        'admin_state_up', 'status'
    ]

    def take_action(self, parsed_args):
        self.parent_id = _get_policy_id(self.get_client(),
                                        parsed_args.l7policy)
        self.values_specs.append('--l7policy_id=%s' % self.parent_id)
        return super(ListL7Rule, self).take_action(parsed_args)


class ShowL7Rule(LbaasL7RuleMixin, neutronV20.ShowCommand):
    """LBaaS v2 Show information of a given rule."""

    resource = 'rule'
    shadow_resource = 'lbaas_l7rule'


class CreateL7Rule(LbaasL7RuleMixin, neutronV20.CreateCommand):
    """LBaaS v2 Create L7 rule."""

    resource = 'rule'
    shadow_resource = 'lbaas_l7rule'

    def add_known_arguments(self, parser):
        super(CreateL7Rule, self).add_known_arguments(parser)
        _add_common_args(parser)
        parser.add_argument(
            '--admin-state-down',
            dest='admin_state_up',
            action='store_false',
            help=_('Set admin state up to false'))

    def args2body(self, parsed_args):
        return _common_args2body(self.get_client(), parsed_args)


class UpdateL7Rule(LbaasL7RuleMixin, neutronV20.UpdateCommand):
    """LBaaS v2 Update a given L7 rule."""

    resource = 'rule'
    shadow_resource = 'lbaas_l7rule'

    def add_known_arguments(self, parser):
        super(UpdateL7Rule, self).add_known_arguments(parser)
        _add_common_args(parser, False)
        utils.add_boolean_argument(
            parser, '--admin-state-up',
            help=_('Specify the administrative state of the rule'
                   ' (True meaning "Up").'))

    def args2body(self, parsed_args):
        return _common_args2body(self.get_client(), parsed_args, False)


class DeleteL7Rule(LbaasL7RuleMixin, neutronV20.DeleteCommand):
    """LBaaS v2 Delete a given L7 rule."""

    resource = 'rule'
    shadow_resource = 'lbaas_l7rule'