]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: role: move populate from svc->role
authorAbhishek Lekshmanan <abhishek@suse.com>
Wed, 21 Oct 2020 10:45:09 +0000 (12:45 +0200)
committerPritha Srivastava <prsrivas@redhat.com>
Mon, 6 Jun 2022 10:49:42 +0000 (16:19 +0530)
As populate creates uuids etc which are only needed in direct calls to rgw_admin

Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
src/rgw/rgw_role.cc
src/rgw/services/svc_role_rados.cc

index ecd8683c6d0dfd652aab8a53e4c695f3ff579885..8efad78b893a9655712474880be7d5c4d46b5e44 100644 (file)
@@ -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().
index 7b148d8affbde78ab4f936495f804db6e63507ee..fdadf8ca3c229449a4af49208ab7e50fb903505d 100644 (file)
@@ -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;
   }