/usr/lib/python2.7/dist-packages/manila_ui/dashboards/admin/shares/tabs.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 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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | # Copyright 2014 OpenStack Foundation
#
# 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 tabs
from openstack_dashboard.api import base
from openstack_dashboard.api import neutron
from manila_ui.api import manila
from manila_ui.api import network
from manila_ui.dashboards.admin.shares import tables
from manila_ui.dashboards.admin.shares import utils
from manila_ui.dashboards import utils as common_utils
class SnapshotsTab(tabs.TableTab):
table_classes = (tables.SnapshotsTable, )
name = _("Snapshots")
slug = "snapshots_tab"
template_name = "horizon/common/_detail_table.html"
def _set_id_if_nameless(self, snapshots):
for snap in snapshots:
if not snap.name:
snap.name = snap.id
def get_snapshots_data(self):
snapshots = []
try:
snapshots = manila.share_snapshot_list(
self.request, search_opts={'all_tenants': True})
shares = manila.share_list(self.request)
share_names = dict([(share.id, share.name or share.id)
for share in shares])
for snapshot in snapshots:
snapshot.share = share_names.get(snapshot.share_id)
except Exception:
msg = _("Unable to retrieve snapshot list.")
exceptions.handle(self.request, msg)
# Gather our projects to correlate against IDs
utils.set_project_name_to_objects(self.request, snapshots)
return snapshots
class SharesTab(tabs.TableTab):
table_classes = (tables.SharesTable, )
name = _("Shares")
slug = "shares_tab"
template_name = "horizon/common/_detail_table.html"
def get_shares_data(self):
shares = []
try:
shares = manila.share_list(
self.request, search_opts={'all_tenants': True})
snapshots = manila.share_snapshot_list(
self.request, detailed=True, search_opts={'all_tenants': True})
share_ids_with_snapshots = []
for snapshot in snapshots:
share_ids_with_snapshots.append(snapshot.to_dict()['share_id'])
for share in shares:
if share.to_dict()['id'] in share_ids_with_snapshots:
setattr(share, 'has_snapshot', True)
else:
setattr(share, 'has_snapshot', False)
except Exception:
exceptions.handle(
self.request, _('Unable to retrieve share list.'))
# Gather our projects to correlate against IDs
utils.set_project_name_to_objects(self.request, shares)
return shares
class ShareTypesTab(tabs.TableTab):
table_classes = (tables.ShareTypesTable, )
name = _("Share Types")
slug = "share_types_tab"
template_name = "horizon/common/_detail_table.html"
def get_share_types_data(self):
try:
share_types = manila.share_type_list(self.request)
except Exception:
share_types = []
exceptions.handle(self.request,
_("Unable to retrieve share types"))
# Convert dict with extra specs to friendly view
for st in share_types:
st.extra_specs = common_utils.metadata_to_str(
st.extra_specs, 8, 45)
return share_types
class SecurityServiceTab(tabs.TableTab):
table_classes = (tables.SecurityServiceTable,)
name = _("Security Services")
slug = "security_services_tab"
template_name = "horizon/common/_detail_table.html"
def get_security_services_data(self):
try:
security_services = manila.security_service_list(
self.request, search_opts={'all_tenants': True})
except Exception:
security_services = []
exceptions.handle(self.request,
_("Unable to retrieve security services"))
utils.set_project_name_to_objects(self.request, security_services)
return security_services
class ShareNetworkTab(tabs.TableTab):
name = _("Share Networks")
slug = "share_networks_tab"
template_name = "horizon/common/_detail_table.html"
def __init__(self, tab_group, request):
if base.is_service_enabled(request, 'network'):
self.table_classes = (tables.NeutronShareNetworkTable,)
else:
self.table_classes = (tables.NovaShareNetworkTable,)
super(ShareNetworkTab, self).__init__(tab_group, request)
def get_share_networks_data(self):
try:
share_networks = manila.share_network_list(
self.request, detailed=True, search_opts={'all_tenants': True})
if base.is_service_enabled(self.request, 'network'):
neutron_net_names = dict((net.id, net.name) for net in
neutron.network_list(self.request))
neutron_subnet_names = dict((net.id, net.name) for net in
neutron.subnet_list(self.request))
for sn in share_networks:
sn.neutron_net = neutron_net_names.get(
sn.neutron_net_id) or sn.neutron_net_id or "-"
sn.neutron_subnet = neutron_subnet_names.get(
sn.neutron_subnet_id) or sn.neutron_subnet_id or "-"
else:
nova_net_names = dict(
[(net.id, net.label)
for net in network.network_list(self.request)])
for sn in share_networks:
sn.nova_net = nova_net_names.get(
sn.nova_net_id) or sn.nova_net_id or "-"
except Exception:
share_networks = []
exceptions.handle(self.request,
_("Unable to retrieve share networks"))
utils.set_project_name_to_objects(self.request, share_networks)
return share_networks
class ShareInstancesTab(tabs.TableTab):
table_classes = (tables.ShareInstancesTable,)
name = _("Share Instances")
slug = "share_instances_tab"
template_name = "horizon/common/_detail_table.html"
def get_share_instances_data(self):
try:
share_instances = manila.share_instance_list(self.request)
except Exception:
share_instances = []
exceptions.handle(
self.request, _("Unable to retrieve share instances."))
return share_instances
class ShareInstanceOverviewTab(tabs.Tab):
name = _("Overview")
slug = "overview"
template_name = ("admin/shares/_detail_share_instance.html")
def get_context_data(self, request):
return {"share_instance": self.tab_group.kwargs['share_instance']}
class ShareInstanceDetailTabs(tabs.TabGroup):
slug = "share_instance_details"
tabs = (ShareInstanceOverviewTab,)
class ShareServerTab(tabs.TableTab):
table_classes = (tables.ShareServerTable,)
name = _("Share Servers")
slug = "share_servers_tab"
template_name = "horizon/common/_detail_table.html"
def get_share_servers_data(self):
try:
share_servers = manila.share_server_list(
self.request)
except Exception:
share_servers = []
exceptions.handle(self.request,
_("Unable to retrieve share servers"))
utils.set_project_name_to_objects(self.request, share_servers)
return share_servers
class ShareServerOverviewTab(tabs.Tab):
name = _("Overview")
slug = "overview"
template_name = ("admin/shares/_detail_share_server.html")
def get_context_data(self, request):
return {"share_server": self.tab_group.kwargs['share_server']}
class ShareServerDetailTabs(tabs.TabGroup):
slug = "share_server_details"
tabs = (ShareServerOverviewTab,)
class ShareTabs(tabs.TabGroup):
slug = "share_tabs"
tabs = (SharesTab, SnapshotsTab, ShareNetworkTab, SecurityServiceTab,
ShareTypesTab, ShareServerTab, ShareInstancesTab)
sticky = True
class SnapshotOverviewTab(tabs.Tab):
name = _("Snapshot Overview")
slug = "snapshot_overview_tab"
template_name = ("admin/shares/"
"_snapshot_detail_overview.html")
def get_context_data(self, request):
return {"snapshot": self.tab_group.kwargs['snapshot']}
class SnapshotDetailTabs(tabs.TabGroup):
slug = "snapshot_details"
tabs = (SnapshotOverviewTab,)
|