]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/neorados/common_tests.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / test / neorados / common_tests.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2020 Red Hat, Inc.
7 * Author: Adam C. Emerson <aemerson@redhat.com>
8 *
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
13 */
14
15 #include <string>
16 #include <string_view>
17
18 #include "include/neorados/RADOS.hpp"
19
20 std::string get_temp_pool_name(std::string_view prefix = {});
21
22 template<typename CompletionToken>
23 auto create_pool(neorados::RADOS& r, std::string_view pname,
24 CompletionToken&& token)
25 {
26 boost::asio::async_completion<CompletionToken,
27 void(boost::system::error_code,
28 std::int64_t)> init(token);
29 r.create_pool(pname, std::nullopt,
30 [&r, pname = std::string(pname),
31 h = std::move(init.completion_handler)]
32 (boost::system::error_code ec) mutable {
33 r.lookup_pool(
34 pname,
35 [h = std::move(h)]
36 (boost::system::error_code ec, std::int64_t pool) mutable {
37 std::move(h)(ec, pool);
38 });
39 });
40 return init.result.get();
41 }