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/rgw/rgw_role.cc | |
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/rgw/rgw_role.cc')
-rw-r--r-- | src/rgw/rgw_role.cc | 27 |
1 files changed, 27 insertions, 0 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(). |