Skip to content

Commit

Permalink
common/cmdparse: emit proper json
Browse files Browse the repository at this point in the history
Instead of '"req": "false"', emit '"req": false'.  Same for conditional.

Luckily, the clients don't really care about this change, as
ceph_argparse.py argdesc interpets the JSON like so:

            self.req = req in (True, 'True', 'true')
            self.positional = positional in (True, 'True', 'true')

Clean up command definitions to use lowercase 'false', but tolerate
both for backward compat during upgrade and to tolerate future errors.

Signed-off-by: Sage Weil <sage@newdream.net>
  • Loading branch information
liewegas committed Jun 4, 2021
1 parent 65d60b2 commit 3123ab6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
12 changes: 9 additions & 3 deletions src/common/cmdparse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,16 @@ dump_cmd_to_json(Formatter *f, uint64_t features, const string& cmd)
desckv["positional"] = "false";
}
for (auto [key, value] : desckv) {
if (key == "positional" && !HAVE_FEATURE(features, SERVER_QUINCY)) {
continue;
if (key == "positional") {
if (!HAVE_FEATURE(features, SERVER_QUINCY)) {
continue;
}
f->dump_bool(key, value == "true" || value == "True");
} else if (key == "req" && HAVE_FEATURE(features, SERVER_QUINCY)) {
f->dump_bool(key, value == "true" || value == "True");
} else {
f->dump_string(key, value);
}
f->dump_string(key, value);
}
f->close_section(); // attribute object for individual desc
}
Expand Down
4 changes: 2 additions & 2 deletions src/mgr/MgrCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ COMMAND("service status",
"dump service state", "service", "r")

COMMAND("config show " \
"name=who,type=CephString name=key,type=CephString,req=False",
"name=who,type=CephString name=key,type=CephString,req=false",
"Show running configuration",
"mgr", "r")
COMMAND("config show-with-defaults " \
Expand All @@ -203,7 +203,7 @@ COMMAND("device ls-by-host name=host,type=CephString",
"mgr", "r")
COMMAND("device set-life-expectancy name=devid,type=CephString "\
"name=from,type=CephString "\
"name=to,type=CephString,req=False",
"name=to,type=CephString,req=false",
"Set predicted device life expectancy",
"mgr", "rw")
COMMAND("device rm-life-expectancy name=devid,type=CephString",
Expand Down
4 changes: 2 additions & 2 deletions src/mon/MonCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ COMMAND("config rm"
"config", "rw")
COMMAND("config get "
"name=who,type=CephString "
"name=key,type=CephString,req=False",
"name=key,type=CephString,req=false",
"Show configuration option(s) for an entity",
"config", "r")
COMMAND("config dump",
Expand All @@ -1310,7 +1310,7 @@ COMMAND("config ls",
COMMAND("config assimilate-conf",
"Assimilate options from a conf, and return a new, minimal conf file",
"config", "rw")
COMMAND("config log name=num,type=CephInt,req=False",
COMMAND("config log name=num,type=CephInt,req=false",
"Show recent history of config changes",
"config", "r")
COMMAND("config reset "
Expand Down

0 comments on commit 3123ab6

Please sign in to comment.