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

Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
This commit is contained in:
Pritha Srivastava 2018-10-24 13:01:36 +05:30
parent 82a98163af
commit 08b8c7e0b3

View File

@ -928,7 +928,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;
@ -5062,26 +5062,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;