Syspanel volume list once again shows all volumes.
* Fixes bug 1039788 * Was missing the all_tenants=1 search opt. Change-Id: I98647620690d8f79a65d92e47eef3fabeb3938e6
This commit is contained in:
parent
1048ac671a
commit
30ed984514
@ -508,8 +508,12 @@ def virtual_interfaces_list(request, instance_id):
|
||||
return novaclient(request).virtual_interfaces.list(instance_id)
|
||||
|
||||
|
||||
def volume_list(request):
|
||||
return cinderclient(request).volumes.list()
|
||||
def volume_list(request, search_opts=None):
|
||||
"""
|
||||
To see all volumes in the cloud as an admin you can pass in a special
|
||||
search option: {'all_tenants': 1}
|
||||
"""
|
||||
return cinderclient(request).volumes.list(search_opts=search_opts)
|
||||
|
||||
|
||||
def volume_get(request, volume_id):
|
||||
|
@ -42,32 +42,41 @@ class IndexView(tables.DataTableView):
|
||||
table_class = VolumesTable
|
||||
template_name = 'nova/volumes/index.html'
|
||||
|
||||
def get_data(self):
|
||||
# Gather our volumes
|
||||
def _get_volumes(self, search_opts=None):
|
||||
try:
|
||||
volumes = api.volume_list(self.request)
|
||||
return api.volume_list(self.request, search_opts=search_opts)
|
||||
except:
|
||||
volumes = []
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve volume list.'))
|
||||
|
||||
def _get_instances(self):
|
||||
try:
|
||||
instance_list = api.server_list(self.request)
|
||||
return api.server_list(self.request)
|
||||
except:
|
||||
instance_list = []
|
||||
exceptions.handle(self.request,
|
||||
_("Unable to retrieve volume/instance "
|
||||
"attachment information"))
|
||||
|
||||
instances = SortedDict([(inst.id, inst) for inst in instance_list])
|
||||
def _set_id_if_nameless(self, volumes, instances):
|
||||
for volume in volumes:
|
||||
# It is possible to create a volume with no name through the
|
||||
# EC2 API, use the ID in those cases.
|
||||
if not volume.display_name:
|
||||
volume.display_name = volume.id
|
||||
|
||||
def _set_attachments_string(self, volumes, instances):
|
||||
instances = SortedDict([(inst.id, inst) for inst in instances])
|
||||
for volume in volumes:
|
||||
for att in volume.attachments:
|
||||
server_id = att.get('server_id', None)
|
||||
att['instance'] = instances.get(server_id, None)
|
||||
|
||||
def get_data(self):
|
||||
volumes = self._get_volumes()
|
||||
instances = self._get_instances()
|
||||
self._set_id_if_nameless(volumes, instances)
|
||||
self._set_attachments_string(volumes, instances)
|
||||
return volumes
|
||||
|
||||
|
||||
|
@ -25,7 +25,8 @@ from horizon import test
|
||||
class VolumeTests(test.BaseAdminViewTests):
|
||||
@test.create_stubs({api: ('server_list', 'volume_list',)})
|
||||
def test_index(self):
|
||||
api.volume_list(IsA(http.HttpRequest)).AndReturn(self.volumes.list())
|
||||
api.volume_list(IsA(http.HttpRequest), search_opts={
|
||||
'all_tenants': 1}).AndReturn(self.volumes.list())
|
||||
api.server_list(IsA(http.HttpRequest)).AndReturn(self.servers.list())
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
@ -27,6 +27,13 @@ class IndexView(_IndexView):
|
||||
table_class = VolumesTable
|
||||
template_name = "syspanel/volumes/index.html"
|
||||
|
||||
def get_data(self):
|
||||
volumes = self._get_volumes(search_opts={'all_tenants': 1})
|
||||
instances = self._get_instances()
|
||||
self._set_id_if_nameless(volumes, instances)
|
||||
self._set_attachments_string(volumes, instances)
|
||||
return volumes
|
||||
|
||||
|
||||
class DetailView(_DetailView):
|
||||
template_name = "syspanel/volumes/detail.html"
|
||||
|
Loading…
x
Reference in New Issue
Block a user