From: Abhishek Lekshmanan Date: Thu, 20 Jul 2017 09:08:30 +0000 (+0200) Subject: rgw: adminops API now supports tenant param for user creation X-Git-Tag: v12.1.3~24^2~23^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=af0e307aae679cbaede6979b6ea9d531721c4ce1;p=ceph.git rgw: adminops API now supports tenant param for user creation Allow `tenant` as a param for user creation API, also document this. Currently we still return a -ENOENT when an invalid tenant name is specified, while we could make it return -ERR_INVALID_TENANT, this would make rgw admin cli not return -ENOENT when an invalid tenant name is specified. Signed-off-by: Abhishek Lekshmanan --- diff --git a/doc/radosgw/adminops.rst b/doc/radosgw/adminops.rst index 597f4fe5d26..422dd16527a 100644 --- a/doc/radosgw/adminops.rst +++ b/doc/radosgw/adminops.rst @@ -321,6 +321,11 @@ generated key is added to the keyring without replacing an existing key pair. If ``access-key`` is specified and refers to an existing key owned by the user then it will be modified. +.. versionadded:: Luminous + +A ``tenant`` may either be specified as a part of uid or as an additional +request param. + :caps: users=write Syntax @@ -409,6 +414,14 @@ A tenant name may also specified as a part of ``uid``, by following the syntax ` :Example: False [False] :Required: No +.. versionadded:: Jewel +``tenant`` + +:Description: the Tenant under which a user is a part of. +:Type: string +:Example: tenant1 +:Required: No + Response Entities ~~~~~~~~~~~~~~~~~ diff --git a/src/rgw/rgw_rest_user.cc b/src/rgw/rgw_rest_user.cc index 711fd3a0c1d..8539c3ed766 100644 --- a/src/rgw/rgw_rest_user.cc +++ b/src/rgw/rgw_rest_user.cc @@ -76,6 +76,7 @@ void RGWOp_User_Create::execute() std::string secret_key; std::string key_type_str; std::string caps; + std::string tenant_name; bool gen_key; bool suspended; @@ -96,6 +97,7 @@ void RGWOp_User_Create::execute() RESTArgs::get_string(s, "secret-key", secret_key, &secret_key); RESTArgs::get_string(s, "key-type", key_type_str, &key_type_str); RESTArgs::get_string(s, "user-caps", caps, &caps); + RESTArgs::get_string(s, "tenant", tenant_name, &tenant_name); RESTArgs::get_bool(s, "generate-key", true, &gen_key); RESTArgs::get_bool(s, "suspended", false, &suspended); RESTArgs::get_int32(s, "max-buckets", default_max_buckets, &max_buckets); @@ -108,6 +110,10 @@ void RGWOp_User_Create::execute() return; } + if (!tenant_name.empty()) { + uid.tenant = tenant_name; + } + // TODO: validate required args are passed in. (for eg. uid and display_name here) op_state.set_user_id(uid); op_state.set_display_name(display_name);