]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Added code to allow tenant name as part of role name also.
authorPritha Srivastava <prsrivas@redhat.com>
Thu, 23 Feb 2017 09:28:06 +0000 (14:58 +0530)
committerPritha Srivastava <prsrivas@redhat.com>
Tue, 7 Mar 2017 04:26:46 +0000 (09:56 +0530)
Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
src/rgw/rgw_role.cc
src/rgw/rgw_role.h

index 2089f83c259c9b505674d08f88f17d32324dc338..236fe6e6aa448b49cf0ab692946407ffa279d17e 100644 (file)
@@ -209,6 +209,8 @@ int RGWRole::get_by_id()
   if (ret < 0) {
     return ret;
   }
+
+  return 0;
 }
 
 int RGWRole::update()
@@ -381,11 +383,22 @@ bool RGWRole::validate_input()
     return false;
   }
 
-  std::regex regex_path("(\/[!-~]+\/)|(\/)");
+  std::regex regex_path("(/[!-~]+/)|(/)");
   if (! std::regex_match(path,regex_path)) {
     ldout(cct, 0) << "ERROR: Invalid chars in path " << dendl;
     return false;
   }
+
+  return true;
+}
+
+void RGWRole::extract_name_tenant(const std::string& str)
+{
+  size_t pos = str.find('$');
+  if (pos != std::string::npos) {
+    tenant = str.substr(0, pos);
+    name = str.substr(pos + 1);
+  }
 }
 
 void RGWRole::update_trust_policy(string& trust_policy)
index b6ec5fed021b4b7544c564618766697869b6414c..bccb576ed2d83c1e023d6687bcd22321e1afa929 100644 (file)
@@ -29,6 +29,7 @@ class RGWRole
   int read_info();
   void set_id(const string& id) { this->id = id; }
   bool validate_input();
+  void extract_name_tenant(const std::string& str);
 
 public:
   RGWRole(CephContext *cct,
@@ -45,6 +46,7 @@ public:
     tenant(std::move(tenant)) {
     if (this->path.empty())
       this->path = "/";
+    extract_name_tenant(this->name);
   }
 
   RGWRole(CephContext *cct,
@@ -54,7 +56,9 @@ public:
   : cct(cct),
     store(store),
     name(std::move(name)),
-    tenant(std::move(tenant)) {}
+    tenant(std::move(tenant)) {
+    extract_name_tenant(this->name);
+  }
 
   RGWRole(CephContext *cct,
           RGWRados *store,