Merge "Change admin metadata config option name"

This commit is contained in:
Zuul 2024-03-13 22:27:21 +00:00 committed by Gerrit Code Review
commit 18ffa38116
4 changed files with 14 additions and 10 deletions

View File

@ -109,7 +109,7 @@ class ShareMetadataController(object):
def _update_share_metadata(self, context,
share_id, metadata,
delete=False):
ignore_keys = getattr(CONF, 'admin_metadata_keys', [])
ignore_keys = getattr(CONF, 'admin_only_metadata', [])
try:
share = self.share_api.get(context, share_id)
if set(metadata).intersection(set(ignore_keys)):
@ -178,8 +178,10 @@ class ShareMetadataController(object):
try:
share = self.share_api.get(context, share_id)
admin_metadata_keys = getattr(CONF, 'admin_metadata_keys', set())
if id in admin_metadata_keys:
admin_only_metadata_keys = (
getattr(CONF, 'admin_only_metadata', set())
)
if id in admin_only_metadata_keys:
policy.check_policy(context, 'share',
'update_admin_only_metadata')
db.share_metadata_delete(context, share['id'], id)

View File

@ -59,8 +59,8 @@ class ShareController(wsgi.Controller,
self.resource_locks_api = resource_locks.API()
self._access_view_builder = share_access_views.ViewBuilder()
self._migration_view_builder = share_migration_views.ViewBuilder()
self._conf_admin_metadata_keys = getattr(
CONF, 'admin_metadata_keys', []
self._conf_admin_only_metadata_keys = getattr(
CONF, 'admin_only_metadata', []
)
@wsgi.Controller.authorize('revert_to_snapshot')
@ -627,7 +627,7 @@ class ShareController(wsgi.Controller,
def _validate_metadata_for_update(self, req, share_id, metadata,
delete=True):
admin_metadata_ignore_keys = set(self._conf_admin_metadata_keys)
admin_metadata_ignore_keys = set(self._conf_admin_only_metadata_keys)
context = req.environ['manila.context']
if set(metadata).intersection(admin_metadata_ignore_keys):
try:
@ -705,7 +705,7 @@ class ShareController(wsgi.Controller,
@wsgi.Controller.authorize("delete_share_metadata")
def delete_metadata(self, req, resource_id, key):
context = req.environ['manila.context']
if key in self._conf_admin_metadata_keys:
if key in self._conf_admin_only_metadata_keys:
policy.check_policy(context, 'share',
'update_admin_only_metadata')
return self._delete_metadata(req, resource_id, key)

View File

@ -137,7 +137,7 @@ global_opts = [
help='Maximum time (in seconds) to keep a share in '
'awaiting_transfer state, after timeout, the share will '
'automatically be rolled back to the available state'),
cfg.ListOpt('admin_metadata_keys',
cfg.ListOpt('admin_only_metadata',
default=constants.AdminOnlyMetadata.SCHEDULER_FILTERS,
help='Metadata keys that should only be manipulated by '
'administrators.'),

View File

@ -1,6 +1,8 @@
---
upgrades:
- |
A new configuration option called ``admin_metadata_keys`` has been
A new configuration option called ``admin_only_metadata`` has been
introduced to assist cloud administrators while defining share
metadata that should only be modified by administrators.
metadata that should only be modified by administrators. This
configuration option defaults to the existing admin only metadata
keys, i.e., scheduler hints to preserve backwards compatibility.