From 7a31137ec70147b5f5e187e9ef98ccb13bf2e359 Mon Sep 17 00:00:00 2001 From: Pritha Srivastava Date: Mon, 12 Feb 2024 12:32:11 +0530 Subject: [PATCH] dashboard/rgw: changes to use 'full_user_id' from rgw user info as 'uid' in dashboard. 'full_user_id' includes tenant and user id, and also namespace wherever it is non empty. Signed-off-by: Pritha Srivastava Reviewed-by: Nizamudeen A --- src/pybind/mgr/dashboard/controllers/rgw.py | 24 ++++++--------------- src/pybind/mgr/dashboard/tests/test_rgw.py | 2 ++ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/rgw.py b/src/pybind/mgr/dashboard/controllers/rgw.py index 661dc8afb6dad..28e2754afcf91 100644 --- a/src/pybind/mgr/dashboard/controllers/rgw.py +++ b/src/pybind/mgr/dashboard/controllers/rgw.py @@ -500,21 +500,6 @@ class RgwBucketUi(RgwBucket): @APIRouter('/rgw/user', Scope.RGW) @APIDoc("RGW User Management API", "RgwUser") class RgwUser(RgwRESTController): - def _append_uid(self, user): - """ - Append the user identifier that looks like [$]. - See http://docs.ceph.com/docs/jewel/radosgw/multitenancy/ for - more information. - :param user: The user parameters. - :type user: dict - :return: The modified user parameters including the 'uid' parameter. - :rtype: dict - """ - if isinstance(user, dict): - user['uid'] = '{}${}'.format(user['tenant'], user['user_id']) \ - if user['tenant'] else user['user_id'] - return user - @staticmethod def _keys_allowed(): permissions = AuthManager.get_user(JwtManager.get_username()).permissions_dict() @@ -550,7 +535,8 @@ class RgwUser(RgwRESTController): if not self._keys_allowed(): del result['keys'] del result['swift_keys'] - return self._append_uid(result) + result['uid'] = result['full_user_id'] + return result @Endpoint() @ReadPermission @@ -583,7 +569,8 @@ class RgwUser(RgwRESTController): if secret_key is not None: params['secret-key'] = secret_key result = self.proxy(daemon_name, 'PUT', 'user', params) - return self._append_uid(result) + result['uid'] = result['full_user_id'] + return result @allow_empty_body def set(self, uid, display_name=None, email=None, max_buckets=None, @@ -598,7 +585,8 @@ class RgwUser(RgwRESTController): if suspended is not None: params['suspended'] = suspended result = self.proxy(daemon_name, 'POST', 'user', params) - return self._append_uid(result) + result['uid'] = result['full_user_id'] + return result def delete(self, uid, daemon_name=None): try: diff --git a/src/pybind/mgr/dashboard/tests/test_rgw.py b/src/pybind/mgr/dashboard/tests/test_rgw.py index d9b8593a7d76d..b84838d10167a 100644 --- a/src/pybind/mgr/dashboard/tests/test_rgw.py +++ b/src/pybind/mgr/dashboard/tests/test_rgw.py @@ -282,6 +282,7 @@ class RgwUserControllerTestCase(ControllerTestCase): mock_proxy.return_value = { 'tenant': '', 'user_id': 'my_user_id', + 'full_user_id': 'my_user_id', 'keys': [], 'swift_keys': [] } @@ -297,6 +298,7 @@ class RgwUserControllerTestCase(ControllerTestCase): mock_proxy.return_value = { 'tenant': '', 'user_id': 'my_user_id', + 'full_user_id': 'my_user_id', 'keys': [], 'swift_keys': [] } -- 2.39.5