summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-03-05 00:42:20 +0000
committerGerrit Code Review <review@openstack.org>2016-03-05 00:42:21 +0000
commitd550e02ed60144ca010573085ad3a0de6fe31441 (patch)
tree64d4ca4a7879483ed3b21e62c3dcf654d82208d9
parent4c503dee06de9d5eab3fb3454a0830e6270ed27c (diff)
parent238e2351f8c616931b5be7cfba5ed153bb302bd8 (diff)
downloadhorizon-d550e02ed60144ca010573085ad3a0de6fe31441.tar.gz
Merge "Hide delete volume if it has snapshot" into stable/liberty
-rw-r--r--openstack_dashboard/dashboards/project/volumes/volumes/tests.py7
-rw-r--r--openstack_dashboard/dashboards/project/volumes/volumes/views.py4
2 files changed, 10 insertions, 1 deletions
diff --git a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py
index 1f0610239..d0e9b68aa 100644
--- a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py
+++ b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py
@@ -1072,15 +1072,20 @@ class VolumeViewTests(test.TestCase):
msg_prefix="The create button is not disabled")
@test.create_stubs({cinder: ('tenant_absolute_limits',
- 'volume_get',),
+ 'volume_get',
+ 'volume_snapshot_list'),
api.nova: ('server_get',)})
def test_detail_view(self):
volume = self.cinder_volumes.first()
server = self.servers.first()
+ snapshots = self.cinder_volume_snapshots.list()
volume.attachments = [{"server_id": server.id}]
cinder.volume_get(IsA(http.HttpRequest), volume.id).AndReturn(volume)
+ cinder.volume_snapshot_list(IsA(http.HttpRequest),
+ search_opts={'volume_id': volume.id})\
+ .AndReturn(snapshots)
api.nova.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
cinder.tenant_absolute_limits(IsA(http.HttpRequest))\
.AndReturn(self.cinder_limits['absolute'])
diff --git a/openstack_dashboard/dashboards/project/volumes/volumes/views.py b/openstack_dashboard/dashboards/project/volumes/volumes/views.py
index 257eb255f..b289a1974 100644
--- a/openstack_dashboard/dashboards/project/volumes/volumes/views.py
+++ b/openstack_dashboard/dashboards/project/volumes/volumes/views.py
@@ -70,6 +70,10 @@ class DetailView(tabs.TabView):
try:
volume_id = self.kwargs['volume_id']
volume = cinder.volume_get(self.request, volume_id)
+ snapshots = cinder.volume_snapshot_list(
+ self.request, search_opts={'volume_id': volume.id})
+ if snapshots:
+ setattr(volume, 'has_snapshot', True)
for att in volume.attachments:
att['instance'] = api.nova.server_get(self.request,
att['server_id'])