From 070fd98e7d67c5cd73a23b293167723dfbfeb9e5 Mon Sep 17 00:00:00 2001 From: Tom Barron Date: Mon, 1 Apr 2019 16:21:23 -0400 Subject: [PATCH] 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 --- .../dashboards/project/share_networks/views.py | 13 +++++++++---- ...-get-share-network-details-83e2882df1714506.yaml | 9 +++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/bug-1702396-fix-cannot-get-share-network-details-83e2882df1714506.yaml diff --git a/manila_ui/dashboards/project/share_networks/views.py b/manila_ui/dashboards/project/share_networks/views.py index e83a6db5..dcfdcec0 100644 --- a/manila_ui/dashboards/project/share_networks/views.py +++ b/manila_ui/dashboards/project/share_networks/views.py @@ -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.'), diff --git a/releasenotes/notes/bug-1702396-fix-cannot-get-share-network-details-83e2882df1714506.yaml b/releasenotes/notes/bug-1702396-fix-cannot-get-share-network-details-83e2882df1714506.yaml new file mode 100644 index 00000000..289a57ce --- /dev/null +++ b/releasenotes/notes/bug-1702396-fix-cannot-get-share-network-details-83e2882df1714506.yaml @@ -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.