Merge pull request #24730 from pritha-srivastava/wip-rgw-role-fixes

rgw: Minor fixes to radosgw-admin commands for a role.

Reviewed-by: Matt Benjamin <mbenjami@redhat.com>
This commit is contained in:
Yuri Weinstein 2018-11-19 08:44:10 -08:00 committed by GitHub
commit a2083445f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -934,7 +934,7 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_
} else if (strcmp(prev_cmd, "role") == 0) {
if (strcmp(cmd, "create") == 0)
return OPT_ROLE_CREATE;
if (strcmp(cmd, "delete") == 0)
if (strcmp(cmd, "rm") == 0)
return OPT_ROLE_DELETE;
if (strcmp(cmd, "get") == 0)
return OPT_ROLE_GET;
@ -5090,26 +5090,20 @@ int main(int argc, const char **argv)
return -EINVAL;
}
/* The following two calls will be replaced by read_decode_json or something
similar when the code for AWS Policies is in place */
bufferlist bl;
int ret = read_input(assume_role_doc, bl);
if (ret < 0) {
cerr << "ERROR: failed to read input: " << cpp_strerror(-ret) << std::endl;
return ret;
}
JSONParser p;
if (!p.parse(bl.c_str(), bl.length())) {
cout << "ERROR: failed to parse JSON: " << assume_role_doc << std::endl;
bufferlist bl = bufferlist::static_from_string(assume_role_doc);
try {
const rgw::IAM::Policy p(g_ceph_context, tenant, bl);
} catch (rgw::IAM::PolicyParseException& e) {
cerr << "failed to parse policy: " << e.what() << std::endl;
return -EINVAL;
}
string trust_policy = bl.to_str();
RGWRole role(g_ceph_context, store, role_name, tenant);
ret = role.get();
if (ret < 0) {
return -ret;
}
role.update_trust_policy(trust_policy);
role.update_trust_policy(assume_role_doc);
ret = role.update();
if (ret < 0) {
return -ret;