mirror of
https://github.com/ceph/ceph
synced 2025-01-29 14:34:40 +00:00
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:
parent
e5b6eb45ba
commit
a7e9a7b648
@ -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");
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user