]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add create_config_store() factory
authorCasey Bodley <cbodley@redhat.com>
Wed, 31 Aug 2022 02:57:39 +0000 (22:57 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 28 Sep 2022 21:48:00 +0000 (17:48 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/common/options/rgw.yaml.in
src/rgw/rgw_sal.cc
src/rgw/rgw_sal.h

index e758da2e0033fff41d103bc9ced6f805b37aafad..32735ea94eabfdd61917ac4fb6ba22a7002f94ef 100644 (file)
@@ -3482,6 +3482,17 @@ options:
   - dbstore
   - motr
   - daos
+- name: rgw_config_store
+  type: str
+  level: advanced
+  desc: Configuration storage backend
+  default: rados
+  services:
+  - rgw
+  enum_values:
+  - rados
+  - dbstore
+  - json
 - name: rgw_filter
   type: str
   level: advanced
@@ -3508,6 +3519,24 @@ options:
   default: dbstore
   services:
   - rgw
+- name: dbstore_config_uri
+  type: str
+  level: advanced
+  desc: 'Config database URI. URIs beginning with file: refer to local files opened with SQLite.'
+  default: file:/var/lib/ceph/radosgw/dbstore-config.db
+  see_also:
+  - rgw_config_store
+  services:
+  - rgw
+- name: rgw_json_config
+  type: str
+  level: advanced
+  desc: Path to a json file that contains the static zone and zonegroup configuration. Requires rgw_config_store=json.
+  default: /var/lib/ceph/radosgw/config.json
+  see_also:
+  - rgw_config_store
+  services:
+  - rgw
 - name: motr_profile_fid
   type: str
   level: advanced
index 1798775dcc0097c901ab9073fb09c92110183db9..90786ac49c996c72caded26ffa7e4c2e121e2fca 100644 (file)
 
 #include "rgw_sal.h"
 #include "rgw_sal_rados.h"
+#include "store/rados/config/store.h"
+#include "store/json_config/store.h"
 #include "rgw_d3n_datacache.h"
 
 #ifdef WITH_RADOSGW_DBSTORE
 #include "rgw_sal_dbstore.h"
+#include "store/dbstore/config/store.h"
 #endif
 
 #ifdef WITH_RADOSGW_MOTR
@@ -374,6 +377,33 @@ StoreManager::Config StoreManager::get_config(bool admin, CephContext* cct)
   return cfg;
 }
 
+auto StoreManager::create_config_store(const DoutPrefixProvider* dpp,
+                                       std::string_view type)
+  -> std::unique_ptr<rgw::sal::ConfigStore>
+{
+  try {
+    if (type == "rados") {
+      return rgw::rados::create_config_store(dpp);
+#ifdef WITH_RADOSGW_DBSTORE
+    } else if (type == "dbstore") {
+      const auto uri = g_conf().get_val<std::string>("dbstore_config_uri");
+      return rgw::dbstore::create_config_store(dpp, uri);
+#endif
+    } else if (type == "json") {
+      auto filename = g_conf().get_val<std::string>("rgw_json_config");
+      return rgw::sal::create_json_config_store(dpp, filename);
+    } else {
+      ldpp_dout(dpp, -1) << "ERROR: unrecognized config store type '"
+          << type << "'" << dendl;
+      return nullptr;
+    }
+  } catch (const std::exception& e) {
+    ldpp_dout(dpp, -1) << "ERROR: failed to initialize config store '"
+        << type << "': " << e.what() << dendl;
+  }
+  return nullptr;
+}
+
 namespace rgw::sal {
 int Object::range_to_ofs(uint64_t obj_size, int64_t &ofs, int64_t &end)
 {
index 1152a1242cf08ffce7cdbbfc3bb38c6f4eec1469..8bb2f476ddc727e02c4ea38396db99a7c2558d75 100644 (file)
@@ -1605,6 +1605,12 @@ public:
 
   /** Get the config for stores/filters */
   static Config get_config(bool admin, CephContext* cct);
+
+  /** Create a ConfigStore */
+  static auto create_config_store(const DoutPrefixProvider* dpp,
+                                  std::string_view type)
+      -> std::unique_ptr<rgw::sal::ConfigStore>;
+
 };
 
 /** @} */