crush: display item name in CrushWrapper::dump_rule()

When an item name is available used it instead of displaying the number.

Signed-off-by: Loic Dachary <loic@dachary.org>
This commit is contained in:
Loic Dachary 2014-02-09 21:40:08 +01:00
parent e5b6eb45ba
commit a7e9a7b648
2 changed files with 10 additions and 1 deletions

View File

@ -1200,7 +1200,14 @@ void CrushWrapper::dump_rule(int ruleset, Formatter *f) const
break;
case CRUSH_RULE_TAKE:
f->dump_string("op", "take");
f->dump_int("item", get_rule_arg1(ruleset, j));
{
int item = get_rule_arg1(ruleset, j);
const char *name = get_item_name(item);
if (name == NULL)
f->dump_int("item", item);
else
f->dump_string("item", name);
}
break;
case CRUSH_RULE_EMIT:
f->dump_string("op", "emit");

View File

@ -533,6 +533,8 @@ TEST(CrushWrapper, dump_rules) {
f->flush(ss);
delete f;
EXPECT_EQ(0, ss.str().find("<rule><rule_id>0</rule_id><rule_name>NAME</rule_name>"));
EXPECT_NE(string::npos,
ss.str().find("<step><op>take</op><item>default</item></step>"));
}
delete c;