Show share network details to non-admin

Horizon attempts to show associated share servers when displaying
share network details in the project share-networks dashboard.  But
unless the horizon user is an admin this generates a 403 exception
which in turn causes Horizon to pop-up an error message about being
unable to retrieve share network details.

So instead catch exceptions collecting share server information in
this context and continue on gracefully, presenting the share server
details that are available.

Change-Id: I822ba95dc8e41df2775f908c287565f5da6a7e9d
Closes-Bug: #1702396
This commit is contained in:
Tom Barron 2019-04-01 16:21:23 -04:00
parent ca9cb26eee
commit 070fd98e7d
2 changed files with 18 additions and 4 deletions

View File

@ -136,10 +136,15 @@ class Detail(tabs.TabView):
for ss in share_net.sec_services:
ss.type = utils.get_nice_security_service_type(ss)
server_search_opts = {'share_network_id': share_net_id}
share_servs = manila.share_server_list(
self.request,
search_opts=server_search_opts)
share_net.share_servers = share_servs
try:
share_servs = manila.share_server_list(
self.request,
search_opts=server_search_opts)
# Non admins won't be able to get share servers
except Exception:
share_servs = []
if share_servs:
share_net.share_servers = share_servs
except Exception:
exceptions.handle(self.request,
_('Unable to retrieve share network details.'),

View File

@ -0,0 +1,9 @@
---
fixes:
- |
Fixed an issue where an error message popped up about not being able to
retrieve share network details when an ordinary user attempted to see these
because the user wasn't authorized for certain admin-only ``share server``
information. In this circumstance we now handle this situation gracefully
behind the scenes and display all the share network information for which
the end user is authorized.