]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: make redundant osd.NNN argument optional
authorSage Weil <sage@inktank.com>
Tue, 11 Sep 2012 15:48:34 +0000 (08:48 -0700)
committerSage Weil <sage@inktank.com>
Tue, 11 Sep 2012 19:05:01 +0000 (12:05 -0700)
Instead of 'osd crush set NNN osd.NNN weight loc...', make the second
osd.NNN option optional, and allow either NNN or osd.NNN to specify the
osd id.  This makes the usage much more sane, but maintains backward
compatibility.

Signed-off-by: Sage Weil <sage@inktank.com>
doc/cluster-ops/control.rst
doc/ops/manage/crush.rst
src/mon/OSDMonitor.cc
src/test/cli/ceph/help.t
src/tools/ceph.cc

index d456012b8f2392ff98d628319653c1f84a9b5d89..9af4562ce2aa616a5f569e63d368a9e55afaa13c 100644 (file)
@@ -125,7 +125,7 @@ and state. ::
 Add or move a new item (OSD) with the given id/name/weight at the specified
 location. ::
 
-       ceph osd crush set {id} {name} {weight} [{loc1} [{loc2} ...]]
+       ceph osd crush set {id} {weight} [{loc1} [{loc2} ...]]
 
 Remove an existing item from the CRUSH map. ::
 
index f6c9312b881f5b5bed5a95295f6d6a3bc6e29616..5e277aea24009c8d61b52f1d9466039299a21076 100644 (file)
@@ -22,7 +22,7 @@ Adding a new device (OSD) to the map
 Adding new devices or moving existing devices to new positions in the
 CRUSH hierarchy can be done via the monitor.  The general form is::
 
-  $ ceph osd crush set <id> <name> <weight> [<loc> [<lo2> ...]]
+  $ ceph osd crush set <id> <weight> [<loc> [<lo2> ...]]
 
 where
 
@@ -46,7 +46,7 @@ where
 For example, if the OSD id is ``123``, we want a weight of ``1.0`` and
 the device is on host ``hostfoo`` and rack ``rackbar``::
 
-   $ ceph osd crush set 123 osd.123 1.0 root=default rack=rackbar host=hostfoo
+   $ ceph osd crush set 123 1.0 root=default rack=rackbar host=hostfoo
 
 will add it to the hierarchy, or move it from its previous position.
 (Note: for clusters created prior to v0.52, replace ``root=default``
@@ -57,7 +57,7 @@ does in the default Ceph CRUSH map generated during cluster creation).
 Note that if I later add another device in the same host but specify a
 different pool or rack::
 
-   $ ceph osd crush set 124 osd.124 1.0 root=nondefault rack=weirdrack host=hostfoo
+   $ ceph osd crush set 124 1.0 root=nondefault rack=weirdrack host=hostfoo
 
 the device will still be placed in host ``hostfoo`` at its current
 location (rack ``rackbar`` and pool ``default``).
index 0cdf062fb6f6e52ee864a3d72a7206931d18af45..8351c8bbe26b0aece026b08eea6ab503e31e143d 100644 (file)
@@ -1869,8 +1869,8 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
     }
     else if (m->cmd.size() >= 6 && m->cmd[1] == "crush" && m->cmd[2] == "set") {
       do {
-       // osd crush set <id> <name> <weight> [<loc1> [<loc2> ...]]
-       int id = parse_pos_long(m->cmd[3].c_str(), &ss);
+       // osd crush set <osd-id> [<osd.* name>] <weight> [<loc1> [<loc2> ...]]
+       int id = parse_osd_id(m->cmd[3].c_str(), &ss);
        if (id < 0) {
          err = -EINVAL;
          goto out;
@@ -1881,10 +1881,20 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
          goto out;
        }
 
-       string name = m->cmd[4];
-       float weight = atof(m->cmd[5].c_str());
+       int argpos = 4;
+       string name;
+       if (m->cmd[argpos].find("osd.") == 0) {
+         // old annoying usage, explicitly specifying osd.NNN name
+         name = m->cmd[argpos];
+         argpos++;
+       } else {
+         // new usage; infer name
+         name = "osd." + stringify(id);
+       }
+       float weight = atof(m->cmd[argpos].c_str());
+       argpos++;
        map<string,string> loc;
-       for (unsigned i = 6; i < m->cmd.size(); ++i) {
+       for (unsigned i = argpos; i < m->cmd.size(); ++i) {
          const char *s = m->cmd[i].c_str();
          const char *pos = strchr(s, '=');
          if (!pos)
index f0943303d3b6d250618cb595d7204d06850714aa..9ef93a63915472c7242b4f6efa709d1c88c8429d 100644 (file)
@@ -40,7 +40,7 @@
     ceph osd tell <osd-id or *> injectargs '--<switch> <value> [--<switch> <value>...]'
     ceph osd getcrushmap -o <file>
     ceph osd getmap -o <file>
-    ceph osd crush set <osd-id> <name> <weight> [<loc1> [<loc2> ...]]
+    ceph osd crush set <osd-id> <weight> [<loc1> [<loc2> ...]]
     ceph osd crush move <bucketname> <loc1> [<loc2> ...]
     ceph osd crush create-or-move <osd-id> <initial-weight> [<loc1> [<loc2> ...]]
     ceph osd crush reweight <name> <weight>
index 99af264ece02975a252177dc1c7969c8eb7cd996..fa449bfcd64b4fcb3a30b5886831cc75c1562cfa 100644 (file)
@@ -83,7 +83,7 @@ static void usage()
   cout << "  ceph osd tell <osd-id or *> injectargs '--<switch> <value> [--<switch> <value>...]'\n";
   cout << "  ceph osd getcrushmap -o <file>\n";
   cout << "  ceph osd getmap -o <file>\n";
-  cout << "  ceph osd crush set <osd-id> <name> <weight> [<loc1> [<loc2> ...]]\n";
+  cout << "  ceph osd crush set <osd-id> <weight> [<loc1> [<loc2> ...]]\n";
   cout << "  ceph osd crush move <bucketname> <loc1> [<loc2> ...]\n";
   cout << "  ceph osd crush create-or-move <osd-id> <initial-weight> [<loc1> [<loc2> ...]]\n";
   cout << "  ceph osd crush reweight <name> <weight>\n";