will create a new monitor map with a new UUID (and with it, a new,
empty Ceph file system).
+.. option:: --generate
+
+ generate a new monmap based on the values on the command line or specified
+ in the ceph configuration. This is, in order of preference,
+
+ #. ``--monmap filename`` to specify a monmap to load
+ #. ``--mon-host 'host1,ip2'`` to specify a list of hosts or ip addresses
+ #. ``[mon.foo]`` sections containing ``mon addr`` settings in the config
+
+.. option:: --filter-initial-members
+
+ filter the initial monmap by applying the ``mon initial members``
+ setting. Monitors not present in that list will be removed, and
+ initial members not present in the map will be added with dummy
+ addresses.
+
.. option:: --add name ip:port
will add a monitor with the specified ip:port to the map.
#include "common/ceph_argparse.h"
#include "global/global_init.h"
#include "mon/MonMap.h"
+#include "include/str_list.h"
void usage()
{
- cout << " usage: [--print] [--create [--clobber][--fsid uuid]] [--add name 1.2.3.4:567] [--rm name] <mapfilename>" << std::endl;
+ cout << " usage: [--print] [--create [--clobber][--fsid uuid]] [--generate] [--filter-initial-members] [--add name 1.2.3.4:567] [--rm name] <mapfilename>" << std::endl;
exit(1);
}
bool create = false;
bool clobber = false;
bool modified = false;
+ bool generate = false;
+ bool filter = false;
map<string,entity_addr_t> add;
list<string> rm;
create = true;
} else if (ceph_argparse_flag(args, i, "--clobber", (char*)NULL)) {
clobber = true;
+ } else if (ceph_argparse_flag(args, i, "--generate", (char*)NULL)) {
+ generate = true;
+ } else if (ceph_argparse_flag(args, i, "--filter-initial-members", (char*)NULL)) {
+ filter = true;
} else if (ceph_argparse_flag(args, i, "--add", (char*)NULL)) {
string name = *i;
i = args.erase(i);
}
modified = true;
}
+
+ if (generate) {
+ int r = monmap.build_initial(g_ceph_context, cerr);
+ if (r < 0)
+ return r;
+ }
+
+ if (filter) {
+ // apply initial members
+ list<string> initial_members;
+ get_str_list(g_conf->mon_initial_members, initial_members);
+ if (initial_members.size()) {
+ cout << "initial_members " << initial_members << ", filtering seed monmap" << std::endl;
+ set<entity_addr_t> removed;
+ monmap.filter_initial_members(g_ceph_context, initial_members,
+ string(), entity_addr_t(),
+ &removed);
+ cout << "removed " << removed << std::endl;
+ }
+ modified = true;
+ }
+
if (!g_conf->fsid.is_zero()) {
monmap.fsid = g_conf->fsid;
cout << me << ": set fsid to " << monmap.fsid << std::endl;