From: Sage Weil Date: Tue, 5 Feb 2013 22:30:34 +0000 (-0800) Subject: mon: 'osd crush rule create-simple ' X-Git-Tag: v0.58~141^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a04d3f0ab165b36172ca9dfb20221645d8085979;p=ceph.git mon: 'osd crush rule create-simple ' Simple command to create simple rules. Signed-off-by: Sage Weil --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index d8fd45bac906..23cebda7c996 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2412,6 +2412,48 @@ bool OSDMonitor::prepare_command(MMonCommand *m) return true; } } + else if (m->cmd.size() == 7 && + m->cmd[1] == "crush" && + m->cmd[2] == "rule" && + m->cmd[3] == "create-simple") { + string name = m->cmd[4]; + string root = m->cmd[5]; + string type = m->cmd[6]; + + if (osdmap.crush->rule_exists(name)) { + ss << "rule " << name << " already exists"; + err = 0; + goto out; + } + + bufferlist bl; + if (pending_inc.crush.length()) + bl = pending_inc.crush; + else + osdmap.crush->encode(bl); + CrushWrapper newcrush; + bufferlist::iterator p = bl.begin(); + newcrush.decode(p); + + if (newcrush.rule_exists(name)) { + ss << "rule " << name << " already exists"; + } else { + int rule = newcrush.add_simple_rule(name, root, type); + if (rule < 0) { + err = rule; + goto out; + } + + pending_inc.crush.clear(); + newcrush.encode(pending_inc.crush); + } + goto out; + } + + getline(ss, rs); + paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version())); + return true; + } else if (m->cmd[1] == "setmaxosd" && m->cmd.size() > 2) { int newmax = parse_pos_long(m->cmd[2].c_str(), &ss); if (newmax < 0) {