diff options
author | Abhishek Lekshmanan <abhishek@suse.com> | 2020-10-21 12:45:09 +0200 |
---|---|---|
committer | Pritha Srivastava <prsrivas@redhat.com> | 2022-06-06 12:49:42 +0200 |
commit | 5f9f977fd8ebce8028d7f07efd030cbbdb4ef2a1 (patch) | |
tree | 7cd73ef8453e612dd7885b24aa23b96081882657 /src | |
parent | rgw: role: use create_role from svc (diff) | |
download | ceph-5f9f977fd8ebce8028d7f07efd030cbbdb4ef2a1.tar.xz ceph-5f9f977fd8ebce8028d7f07efd030cbbdb4ef2a1.zip |
rgw: role: move populate from svc->role
As populate creates uuids etc which are only needed in direct calls to rgw_admin
Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/rgw/rgw_role.cc | 27 | ||||
-rw-r--r-- | src/rgw/services/svc_role_rados.cc | 28 |
2 files changed, 28 insertions, 27 deletions
diff --git a/src/rgw/rgw_role.cc b/src/rgw/rgw_role.cc index ecd8683c6d0..8efad78b893 100644 --- a/src/rgw/rgw_role.cc +++ b/src/rgw/rgw_role.cc @@ -72,12 +72,39 @@ int RGWRole::store_path(const DoutPrefixProvider *dpp, bool exclusive, optional_ set_objv_tracker(&objv_tracker)); } +// Creation time +auto generate_ctime() { + real_clock::time_point t = real_clock::now(); + + struct timeval tv; + real_clock::to_timeval(t, tv); + + char buf[30]; + struct tm result; + gmtime_r(&tv.tv_sec, &result); + strftime(buf,30,"%Y-%m-%dT%H:%M:%S", &result); + sprintf(buf + strlen(buf),".%dZ",(int)tv.tv_usec/1000); + string ct; + ct.assign(buf, strlen(buf)); + return ct; +} + + int RGWRole::create(const DoutPrefixProvider *dpp, bool exclusive, optional_yield y) { if (!validate_input(dpp)) { ldpp_dout(dpp, 0) << "ERROR: invalid input " << dendl; return -EINVAL; } + + uuid_d new_role_id; + new_role_id.generate_random(); + + id = new_role_id.to_string(); + arn = role_arn_prefix + tenant + ":role" + path + name; + creation_date = generate_ctime(); + + RGWObjVersionTracker objv_tracker; return role_ctl->create(*this, y, dpp, RGWRoleCtl::PutParams(). diff --git a/src/rgw/services/svc_role_rados.cc b/src/rgw/services/svc_role_rados.cc index 7b148d8affb..fdadf8ca3c2 100644 --- a/src/rgw/services/svc_role_rados.cc +++ b/src/rgw/services/svc_role_rados.cc @@ -107,33 +107,7 @@ public: mtime(_mtime), exclusive(_exclusive), pattrs(_pattrs), y(_y), dpp(dpp) {} - // Creation time - auto generate_ctime() { - real_clock::time_point t = real_clock::now(); - - struct timeval tv; - real_clock::to_timeval(t, tv); - - char buf[30]; - struct tm result; - gmtime_r(&tv.tv_sec, &result); - strftime(buf,30,"%Y-%m-%dT%H:%M:%S", &result); - sprintf(buf + strlen(buf),".%dZ",(int)tv.tv_usec/1000); - return std::string(std::begin(buf), std::end(buf)); - } - - - void populate_info(rgw::sal::RGWRole& info) { - uuid_d new_role_id; - new_role_id.generate_random(); - - info.set_id(new_role_id.to_string()); - info.set_arn(role_arn_prefix + info.get_tenant() + ":role" + info.get_path() + info.get_name()); - info.set_creation_date(generate_ctime()); - } - int prepare() { - if (exclusive) { // TODO replace this with a stat call instead we don't really need to read // the values here @@ -152,7 +126,7 @@ public: } } - populate_info(info); + return 0; } |