diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/rgw/driver/rados/config/store.cc | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/rgw/driver/rados/config/store.cc')
-rw-r--r-- | src/rgw/driver/rados/config/store.cc | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/rgw/driver/rados/config/store.cc b/src/rgw/driver/rados/config/store.cc new file mode 100644 index 000000000..ec2b034a8 --- /dev/null +++ b/src/rgw/driver/rados/config/store.cc @@ -0,0 +1,52 @@ +// vim: ts=8 sw=2 smarttab ft=cpp + +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2022 Red Hat, Inc. + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#include "include/rados/librados.hpp" +#include "common/errno.h" +#include "impl.h" +#include "store.h" + +namespace rgw::rados { + +RadosConfigStore::RadosConfigStore(std::unique_ptr<ConfigImpl> impl) + : impl(std::move(impl)) +{ +} + +RadosConfigStore::~RadosConfigStore() = default; + + +auto create_config_store(const DoutPrefixProvider* dpp) + -> std::unique_ptr<RadosConfigStore> +{ + auto impl = std::make_unique<ConfigImpl>(dpp->get_cct()->_conf); + + // initialize a Rados client + int r = impl->rados.init_with_context(dpp->get_cct()); + if (r < 0) { + ldpp_dout(dpp, -1) << "Rados client initialization failed with " + << cpp_strerror(-r) << dendl; + return nullptr; + } + r = impl->rados.connect(); + if (r < 0) { + ldpp_dout(dpp, -1) << "Rados client connection failed with " + << cpp_strerror(-r) << dendl; + return nullptr; + } + + return std::make_unique<RadosConfigStore>(std::move(impl)); +} + +} // namespace rgw::rados |