Make generic group check work with admin table

Previously allowed() methods in DeleteVolume and DeleteVolumeSnapshot
actions assume that the cinder generic group is always available.
The current admin volume and volume snapshot tables do not load
generic group information, so these allowed() methods failed and
as a result these delete actions are not shown.
This commit checks if a volume belongs to a generic group in more
robust way. This change makes the project volume table work with
deployments without the generic group as well.

Change-Id: Idd887434153966d9188acaf08346fa6a0f0e6719
Closes-Bug: #1787065
(cherry picked from commit e5d6f54e99)
This commit is contained in:
Akihiro Motoki 2018-08-15 01:52:10 +00:00 committed by Ivan Kolodyazhny
parent ad60941e89
commit f0c1fa1987
2 changed files with 2 additions and 2 deletions

View File

@ -99,7 +99,7 @@ class DeleteVolumeSnapshot(policy.PolicyTargetMixin, tables.DeleteAction):
def allowed(self, request, datum=None):
if datum:
# Can't delete snapshot if part of group snapshot
if datum.group_snapshot:
if getattr(datum, 'group_snapshot_id', None):
return False
return True

View File

@ -120,7 +120,7 @@ class DeleteVolume(VolumePolicyTargetMixin, tables.DeleteAction):
if getattr(volume, 'consistencygroup_id', None):
return False
# Can't delete volume if part of volume group
if volume.group:
if getattr(volume, 'group_id', None):
return False
return (volume.status in DELETABLE_STATES and
not getattr(volume, 'has_snapshot', False))