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 <abhishek@suse.com>
This commit is contained in:
Abhishek Lekshmanan 2017-07-20 11:08:30 +02:00
parent 5c8d27363c
commit af0e307aae
2 changed files with 19 additions and 0 deletions

View File

@ -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
~~~~~~~~~~~~~~~~~

View File

@ -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);