1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
2 // vim: ts=8 sw=2 smarttab
13 #include <seastar/core/future.hh>
15 #include "common/ceph_argparse.h"
16 #include "include/expected.hpp"
18 namespace crimson::osd
{
20 void usage(const char* prog
);
22 inline uint64_t get_nonce()
24 if (auto pid
= getpid(); pid
== 1 || std::getenv("CEPH_USE_RANDOM_NONCE")) {
25 // we're running in a container; use a random number instead!
26 std::random_device rd
;
27 std::default_random_engine rng
{rd()};
28 return std::uniform_int_distribution
<uint64_t>{}(rng
);
34 seastar::future
<> populate_config_from_mon();
36 struct early_config_t
{
37 std::vector
<std::string
> early_args
;
38 std::vector
<std::string
> ceph_args
;
40 std::string cluster_name
{"ceph"};
41 std::string conf_file_list
;
42 CephInitParameters init_params
{CEPH_ENTITY_TYPE_OSD
};
44 /// Returned vector must not outlive in
45 auto to_ptr_vector(const std::vector
<std::string
> &in
) {
46 std::vector
<const char *> ret
;
47 ret
.reserve(in
.size());
49 std::begin(in
), std::end(in
),
50 std::back_inserter(ret
),
51 [](const auto &str
) { return str
.c_str(); });
55 std::vector
<const char *> get_early_args() {
56 return to_ptr_vector(early_args
);
59 std::vector
<const char *> get_ceph_args() {
60 return to_ptr_vector(ceph_args
);
63 void encode(ceph::buffer::list
& bl
) const {
64 ENCODE_START(1, 1, bl
);
65 encode(early_args
, bl
);
66 encode(ceph_args
, bl
);
67 encode(cluster_name
, bl
);
68 encode(conf_file_list
, bl
);
69 encode(init_params
, bl
);
73 void decode(ceph::buffer::list::const_iterator
& bl
) {
75 decode(early_args
, bl
);
76 decode(ceph_args
, bl
);
77 decode(cluster_name
, bl
);
78 decode(conf_file_list
, bl
);
79 decode(init_params
, bl
);
87 * Compile initial configuration information from command line arguments,
88 * config files, and monitors.
90 * This implementation forks off a worker process to do this work and must
91 * therefore be called very early in main(). (See implementation for an
94 tl::expected
<early_config_t
, int>
95 get_early_config(int argc
, const char *argv
[]);
99 WRITE_CLASS_ENCODER(crimson::osd::early_config_t
)