osd: ostream is enough for build_simple*

There is no need to specialize the argument into stringstream. It is
replaced by a ostream which is convenient to display errors directly to
cerr if appropriate.

Signed-off-by: Loic Dachary <loic@dachary.org>
osd: factorize build_simple_crush_map* rulesets creation

Group the rulesets created by build_simple_crush_map* into a helper:
build_simple_crush_rulesets()

Signed-off-by: Loic Dachary <loic@dachary.org>
crush: parse CEPH_ARGS in crushtool

The arguments are not given to global_init because the -c option would
conflict. Reading arguments from CEPH_ARGS the way other ceph tools do
is the only way to control verbosity ( via --debug_crush 0 for instance ).

Signed-off-by: Loic Dachary <loic@dachary.org>
crush: display args on crushtool failure

When the number of args provided to --build is not a multiple of 3,
display the arguments which do not comply.

For instance the --debug_crush 0 option is not consumed by global_init
in crushtool because, unlike most ceph tools, the arguments are not
passed to global_init. As a result --debug_crush 0 become part of the
arguments and triggers the failure.

   crushtool --debug_crush 0 --build --num_osds 320 node straw 4
   remaining args: [--debug_crush,0,node,straw,4]
   layers must be specified with 3-tuples of (name, buckettype, size)

Signed-off-by: Loic Dachary <loic@dachary.org>
crush: print --build debug information when verbose 2

instead of verbose 0

Signed-off-by: Loic Dachary <loic@dachary.org>
crush: crushtool --build uses OSDMap helpers for rulesets

Instead of creating a ruleset from scratch, use the
OSDMap::build_simple_crush_rulesets helper. It is more likely to match
the user expecations.

Signed-off-by: Loic Dachary <loic@dachary.org>
crush: crushtool --build informative messages

* dump the crush tree created by --build at debug level 1.

* display a warning at debug level 1 if there is more than one root. In
  most cases it is not what the user wants and it may be confusing
  because the ruleset will only apply to the first of root and have less
  devices under it as expected.

Signed-off-by: Loic Dachary <loic@dachary.org>
crush: crushtool emacs compile helper

Signed-off-by: Loic Dachary <loic@dachary.org>
crush: crushtool copyright notice update

Signed-off-by: Loic Dachary <loic@dachary.org>
crush: tests for crushtool --build

Signed-off-by: Loic Dachary <loic@dachary.org>
doc: crushtool man page nroff format

also includes a modification from a prior patch series that was not
formatted to nroff.

Signed-off-by: Loic Dachary <loic@dachary.org>
doc: update the crushtool manual page

* add information about CEPH_ARGS
* rework the --build documentation and example
* add an Author section
* replace vi with emacs for no good reason
* cleanup whitespace

Signed-off-by: Loic Dachary <loic@dachary.org>
doc: copyright s/2013/2014/

Signed-off-by: Loic Dachary <loic@dachary.org>
doc: format man pages with s/2013/2014/

Signed-off-by: Loic Dachary <loic@dachary.org>
Merge pull request #1075 from dachary/wip-crush

improve crushtool --build useability and documentation

Reviewed-by: Sage Weil <sage@inktank.com>