summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasco Kaliyamoorthy <mkaliyam@redhat.com>2016-02-17 19:45:38 +0530
committerMasco Kaliyamoorthy <mkaliyam@redhat.com>2016-02-22 15:51:18 +0530
commit238e2351f8c616931b5be7cfba5ed153bb302bd8 (patch)
tree6d755b5401c73817829a25dfd605432651b49092
parenta153311a5e886e73b55fc96493c2d4a78f27dc6f (diff)
downloadhorizon-238e2351f8c616931b5be7cfba5ed153bb302bd8.tar.gz
Hide delete volume if it has snapshot
If the volume has a snapshot, it is not allowed to delete it. In tables the delete action is hidden but if we go to the volume detail page, the delete action is available. This patch hides the delete volume on detail page too. Change-Id: I4d8690b035dedd7ebcacb3479d346cfb3fb324f1 Closes-Bug: #1546423 (cherry picked from commit 49a1a6356d8239d5f463c4e09564171dcccaa662)
-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'])