This file is indexed.

/usr/lib/python2.7/dist-packages/manila_ui/dashboards/admin/shares/workflows.py is in python-manila-ui 2.5.1-0.

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
#    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 django.utils.translation import ugettext_lazy as _

from horizon import exceptions
from horizon import forms
from horizon import workflows

from openstack_dashboard.api import keystone

from manila_ui.api import manila


class AddProjectAction(workflows.MembershipAction):

    def __init__(self, request, *args, **kwargs):
        super(AddProjectAction, self).__init__(request, *args, **kwargs)
        default_role_field_name = self.get_default_role_field_name()
        self.fields[default_role_field_name] = forms.CharField(required=False)
        self.fields[default_role_field_name].initial = 'member'

        field_name = self.get_member_field_name('member')
        self.fields[field_name] = forms.MultipleChoiceField(required=False)
        share_type_id = self.initial['id']

        # Get list of existing projects
        try:
            projects, __ = keystone.tenant_list(request)
        except Exception:
            err_msg = _('Unable to get list of projects.')
            exceptions.handle(request, err_msg)

        # Get list of projects with access to this Share Type
        try:
            share_type = manila.share_type_get(request, share_type_id)
            self.share_type_name = share_type.name
            projects_initial = manila.share_type_access_list(
                request, share_type)
        except Exception:
            err_msg = _('Unable to get information about share type access.')
            exceptions.handle(request, err_msg)

        self.fields[field_name].choices = [
            (project.id, project.name or project.id) for project in projects]
        self.fields[field_name].initial = [
            pr.project_id for pr in projects_initial]
        self.projects_initial = set(self.fields[field_name].initial)

    class Meta(object):
        name = _("Projects with access to share type")
        slug = "update_members"

    def handle(self, request, context):
        context.update({
            'name': self.share_type_name,
            'projects_add': self.projects_allow - self.projects_initial,
            'projects_remove': self.projects_initial - self.projects_allow,
        })
        return context

    def clean(self):
        cleaned_data = super(AddProjectAction, self).clean()
        self.projects_allow = set(
            cleaned_data[self.get_member_field_name('member')])
        return cleaned_data


class AddProjectStep(workflows.UpdateMembersStep):
    action_class = AddProjectAction
    available_list_title = _("Available projects")
    help_text = _("Allow project access to share type.")
    members_list_title = _("Selected projects")
    no_available_text = _("No projects found.")
    no_members_text = _("No projects selected.")
    depends_on = ("id", )
    show_roles = False


class ManageShareTypeAccessWorkflow(workflows.Workflow):
    slug = "manage_share_type_access"
    name = _("Manage Share Type Access")
    finalize_button_name = _("Manage Share Type Access")
    success_message = _('Updated access for share type "%s".')
    failure_message = _('Unable to update access for share type "%s".')
    success_url = 'horizon:admin:shares:index'
    default_steps = (AddProjectStep, )

    def format_status_message(self, message):
        return message % self.context['name']

    def handle(self, request, context):
        try:
            for project in self.context['projects_remove']:
                manila.share_type_access_remove(
                    request, self.context['id'], project)
            for project in self.context['projects_add']:
                manila.share_type_access_add(
                    request, self.context['id'], project)
            return True
        except Exception:
            exceptions.handle(request, _('Unable to update share type.'))
            return False