return 0;
}
-static int update_mkfs(MonitorDBStore& st)
+static int update_mkfs(MonitorDBStore& st, const string& monmap_path)
{
MonMap monmap;
- int r = monmap.build_initial(g_ceph_context, true, cerr);
- if (r) {
- cerr << "no initial monitors" << std::endl;
- return -EINVAL;
+ if (!monmap_path.empty()) {
+ cout << __func__ << " pulling initial monmap from " << monmap_path << std::endl;
+ bufferlist bl;
+ string err;
+ int r = bl.read_file(monmap_path.c_str(), &err);
+ if (r < 0) {
+ cerr << "failed to read monmap from " << monmap_path << ": "
+ << cpp_strerror(r) << std::endl;
+ return r;
+ }
+ monmap.decode(bl);
+ } else {
+ cout << __func__ << " generating seed initial monmap" << std::endl;
+ int r = monmap.build_initial(g_ceph_context, true, cerr);
+ if (r) {
+ cerr << "no initial monitors" << std::endl;
+ return -EINVAL;
+ }
}
monmap.print(cout);
bufferlist bl;
{
po::options_description op_desc("Allowed 'rebuild' options");
string keyring_path;
+ string monmap_path;
op_desc.add_options()
("keyring", po::value<string>(&keyring_path),
- "path to the client.admin key");
+ "path to the client.admin key")
+ ("monmap", po::value<string>(&monmap_path),
+ "path to the initial monmap");
po::variables_map op_vm;
int r = parse_cmd_args(&op_desc, nullptr, nullptr, subcmds, &op_vm);
if (r) {
if ((r = update_paxos(st))) {
return r;
}
- if ((r = update_mkfs(st))) {
+ if ((r = update_mkfs(st, monmap_path))) {
return r;
}
if ((r = update_monitor(st))) {