Fix Manage Replicas button availability

Some share types don't support replication. It should be checked along with
the replication availability itself to make "Manage Replicas" button properly
enabled or disabled.

Change-Id: I736e993125870b44b4105d544ab433692a04b657
Closes-Bug: #1619244
This commit is contained in:
Tatiana Ovchinnikova 2016-09-12 13:29:24 +03:00
parent 8be1120326
commit b8fd858d63
4 changed files with 12 additions and 4 deletions

View File

@ -203,8 +203,9 @@ class ManageReplicas(tables.LinkAction):
classes = ("btn-edit",)
policy_rules = (("share", "share:replica_get_all"),)
def allowed(self, request, *args, **kwargs):
return manila.is_replication_enabled()
def allowed(self, request, share):
share_replication_enabled = share.replication_type is not None
return manila.is_replication_enabled() and share_replication_enabled
class SharesTable(shares_tables.SharesTable):

View File

@ -229,8 +229,9 @@ class ManageReplicas(tables.LinkAction):
classes = ("btn-edit",)
policy_rules = (("share", "share:replica_get_all"),)
def allowed(self, request, *args, **kwargs):
return manila.is_replication_enabled()
def allowed(self, request, share):
share_replication_enabled = share.replication_type is not None
return manila.is_replication_enabled() and share_replication_enabled
class AddRule(tables.LinkAction):

View File

@ -76,6 +76,7 @@ nameless_share = shares.Share(
'share_server_id': '1',
'share_network_id': '7f3d1c33-8d00-4511-29df-a2def31f3b5d',
'availability_zone': 'Test AZ',
'replication_type': None,
'mount_snapshot_support': False})
share_with_metadata = shares.Share(
@ -91,6 +92,7 @@ share_with_metadata = shares.Share(
'share_server_id': '1',
'share_network_id': '7f3d1c33-8d00-4511-29df-a2def31f3b5d',
'availability_zone': 'Test AZ',
'replication_type': 'readable',
'mount_snapshot_support': False})
other_share = shares.Share(
@ -107,6 +109,7 @@ other_share = shares.Share(
'share_server_id': '1',
'share_network_id': '7f3d1c33-8d00-4511-29df-a2def31f3b5d',
'availability_zone': 'Test AZ',
'replication_type': 'readable',
'mount_snapshot_support': False})
share_replica = share_replicas.ShareReplica(

View File

@ -0,0 +1,3 @@
---
fixes:
- Fixed Manage Replicas button availability.