OPTION(run_dir, OPT_STR, "/var/run/ceph") // the "/var/run/ceph" dir, created on daemon startup
OPTION(admin_socket, OPT_STR, "$run_dir/$cluster-$name.asok") // default changed by common_preinit()
OPTION(admin_socket_mode, OPT_STR, "") // permission bits to set for admin socket file, e.g., "0775", "0755"
-OPTION(crushtool, OPT_STR, "crushtool") // crushtool utility path
OPTION(daemonize, OPT_BOOL, false) // default changed by common_preinit()
OPTION(setuser, OPT_STR, "") // uid or user name
return r;
}
-int CrushTester::test_with_crushtool(const char *crushtool_cmd,
- int max_id, int timeout,
- int ruleset)
-{
- SubProcessTimed crushtool(crushtool_cmd, SubProcess::PIPE, SubProcess::CLOSE, SubProcess::PIPE, timeout);
- string opt_max_id = boost::lexical_cast<string>(max_id);
- crushtool.add_cmd_args(
- "-i", "-",
- "--test", "--check", opt_max_id.c_str(),
- "--min-x", "1",
- "--max-x", "50",
- NULL);
- if (ruleset >= 0) {
- crushtool.add_cmd_args(
- "--ruleset",
- stringify(ruleset).c_str(),
- NULL);
- }
- int ret = crushtool.spawn();
- if (ret != 0) {
- err << "failed run crushtool: " << crushtool.err();
- return ret;
- }
-
- bufferlist bl;
- ::encode(crush, bl, CEPH_FEATURES_SUPPORTED_DEFAULT);
- bl.write_fd(crushtool.get_stdin());
- crushtool.close_stdin();
- bl.clear();
- ret = bl.read_fd(crushtool.get_stderr(), 100 * 1024);
- if (ret < 0) {
- err << "failed read from crushtool: " << cpp_strerror(-ret);
- return ret;
- }
- bl.write_stream(err);
- if (crushtool.join() != 0) {
- err << crushtool.err();
- return -EINVAL;
- }
-
- return 0;
-}
-
namespace {
class BadCrushMap : public std::runtime_error {
public: