mon: ignore election messages from outside monmap

These shouldn't(tm) happen with new code, but with old code they do.  And
if we get them, elector can try to monmap->get_inst() on them and crash.
Throw them out here; they're nonsense from our perspective anyway if the
peer isn't part of our monmap.

Signed-off-by: Sage Weil <sage@inktank.com>
qa: add a bunch of mon bootstrap tests

These's are comprehensive because a lot of the startup logic is about
picking a local address, and it's difficult to do test that on a single
host.  They cover the other variables surrounding mon bringing up, though:

 - part of initial monmap, or not
 - new nodes given all prior nodes, or not
 - new nodes have self included in monmap seed, or not
 - initial quorum members

Signed-off-by: Sage Weil <sage@inktank.com>
mon: clean up initial_members code slightly

Don't recalc rank unless we need to.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: drop mon_initial_hosts

Bad idea.

Signed-off-by: Sage Weil <sage@inktank.com>
monmap: move monmap generation from ip/host list into MonMap

Also generalize the prefix so it's explicit in the caller and a bit less
magic.

Signed-off-by: Sage Weil <sage@inktank.com>
admin_socket: match first word against command

This lets us do commands that take arguments.  We assume space is the
separator.

Signed-off-by: Sage Weil <sage@inktank.com>
cephtool: multiword admin socket commands

Slurp up anything on the command line that isn't an option, so that you can
do

 ceph --admin-socket /path/to/asok foo bar baz

instead of

 ceph --admin-socket /path/to/asok 'foo bar baz'

Signed-off-by: Sage Weil <sage@inktank.com>
mon: all starting with empty monmap

It's okay to start up with an empty monmap.  It just means that you must:

 * set 'mon initial members'
 * feed hints via the admin socket, or learn hints from other mons probing
   us

Signed-off-by: Sage Weil <sage@inktank.com>
mon: 'add_bootstrap_peer_hint <addr>' via admin socket

Let user add peer hints via the admin socket while bootstrapping.  Once we
have joined a cluster this command is ignored.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: add peers probing us to extra peer list

If we are probed by another monitor, add them to our extra probe list. This
lets us rely on the active probe/reply to gather information and not infer
anything from here.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: set our addr when populating monmap with initial members

If the seed monmap doesn't contain us and we are populating it with
initial members, and one of those members is us, use our addr instead of
using a dummy one.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: learn peer addrs when probing

If we have a monmap with dummy addrs for initial members, and we probe one
of those peers and learn their address, update our monmap appropriately.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: simplify/clean up dummy addrs used for initial members

Use a complete blank IP, but set the nonce.  This way
entity_addr_t::is_blank_ip() works.  We're also outside of the namespace of
possible addrs that the mons *could* use, which is a bit cleaner.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: send join message if we are in monmap with blank addr

Being in the monmap with a blank ip is possible if we were a initial member
seed but weren't part of the first election/quorum.  If that's the case,
first update ourselves before we try to call an election and join the
quorum.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: add -or- update blank mon addr with join command

Update blank addrs with the join command (in addition to adding new mons).

Signed-off-by: Sage Weil <sage@inktank.com>
qa: add mon test for seeding bootstrap mon peers via admin socket

Signed-off-by: Sage Weil <sage@inktank.com>
mon: always mark seed/mkfs monmap as epoch 0

This isn't strictly necessary, since the MonmapMonitor resets this on first
commit, but it's cleaner.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: move initial_members filtering into MonMap method

This is cleaner.  Also, we can perform/test this functionality from the
monmaptool.

Signed-off-by: Sage Weil <sage@inktank.com>
monmap: move build_initial() from MonClient

This belongs here, not in MonClient.

Signed-off-by: Sage Weil <sage@inktank.com>
monmaptool: add --generate, --filter-initial options

Generate a monmap from conf/args, and apply the mon initial hosts to it.

Signed-off-by: Sage Weil <sage@inktank.com>