$ monmaptool --add foo 3.4.5.6:7890 mymonmap
monmaptool: monmap file mymonmap
monmaptool: map already contains mon.foo
- usage: [--print] [--create [--clobber][--fsid uuid]]
- [--enable-all-features]
- [--generate] [--set-initial-members]
- [--add name 1.2.3.4:567] [--rm name]
- [--feature-list [plain|parseable]]
- [--feature-set <value> [--optional|--persistent]]
- [--feature-unset <value> [--optional|--persistent]] <mapfilename>
+ monmaptool -h for usage
[1]
$ monmaptool --print mymonmap
$ monmaptool --feature-set foo /tmp/test.monmap.1234
unknown features name 'foo' or unable to parse value: Expected option value to be integer, got 'foo'
- usage: [--print] [--create [--clobber][--fsid uuid]]
- [--enable-all-features]
- [--generate] [--set-initial-members]
- [--add name 1.2.3.4:567] [--rm name]
- [--feature-list [plain|parseable]]
- [--feature-set <value> [--optional|--persistent]]
- [--feature-unset <value> [--optional|--persistent]] <mapfilename>
+ monmaptool -h for usage
[1]
$ monmaptool --feature-set kraken --feature-set 64 --optional --feature-set 32 --persistent /tmp/test.monmap.1234
monmaptool: monmap file mymonmap
monmaptool: removing doesnotexist
monmaptool: map does not contain doesnotexist
- usage: [--print] [--create [--clobber][--fsid uuid]]
- [--enable-all-features]
- [--generate] [--set-initial-members]
- [--add name 1.2.3.4:567] [--rm name]
- [--feature-list [plain|parseable]]
- [--feature-set <value> [--optional|--persistent]]
- [--feature-unset <value> [--optional|--persistent]] <mapfilename>
+ monmaptool -h for usage
[1]
$ monmaptool --print mymonmap
void usage()
{
- cout << " usage: [--print] [--create [--clobber][--fsid uuid]]\n"
+ cout << "usage: monmaptool [--print] [--create [--clobber] [--fsid uuid]]\n"
<< " [--enable-all-features]\n"
<< " [--generate] [--set-initial-members]\n"
<< " [--add name 1.2.3.4:567] [--rm name]\n"
<< " [--feature-unset <value> [--optional|--persistent]] "
<< "<mapfilename>"
<< std::endl;
+}
+
+void helpful_exit()
+{
+ cerr << "monmaptool -h for usage" << std::endl;
exit(1);
}
string name = *i;
i = args.erase(i);
if (i == args.end())
- usage();
+ helpful_exit();
entity_addr_t addr;
if (!addr.parse(*i)) {
cerr << me << ": invalid ip:port '" << *i << "'" << std::endl;
string name = *i;
i = args.erase(i);
if (i == args.end())
- usage();
+ helpful_exit();
entity_addrvec_t addrs;
if (!addrs.parse(*i)) {
cerr << me << ": invalid ip:port '" << *i << "'" << std::endl;
f.type = feature_op_t::type_t::PARSEABLE;
} else if (format != "plain") {
cerr << "invalid format type for list: '" << val << "'" << std::endl;
- usage();
+ helpful_exit();
}
features.push_back(f);
// parse value
feature_op_t f(feature_op_t::op_t::OP_SET);
if (!f.parse_value(val, &cerr)) {
- usage();
+ helpful_exit();
}
features.push_back(f);
// parse value
feature_op_t f(feature_op_t::op_t::OP_UNSET);
if (!f.parse_value(val, &cerr)) {
- usage();
+ helpful_exit();
}
features.push_back(f);
} else if (ceph_argparse_flag(args, i, "--optional", (char*)NULL)) {
if (features.empty()) {
- usage();
+ helpful_exit();
}
features.back().set_optional();
} else if (ceph_argparse_flag(args, i, "--persistent", (char*)NULL)) {
if (features.empty()) {
- usage();
+ helpful_exit();
}
features.back().set_persistent();
} else {
}
if (args.empty()) {
cerr << me << ": must specify monmap filename" << std::endl;
- usage();
+ helpful_exit();
}
else if (args.size() > 1) {
cerr << me << ": too many arguments" << std::endl;
- usage();
+ helpful_exit();
}
fn = args[0];
entity_addrvec_t addrs;
if (monmap.contains(p.first)) {
cerr << me << ": map already contains mon." << p.first << std::endl;
- usage();
+ helpful_exit();
}
if (addr.get_port() == 0) {
if (monmap.persistent_features.contains_all(
}
if (monmap.contains(addrs)) {
cerr << me << ": map already contains " << addrs << std::endl;
- usage();
+ helpful_exit();
}
monmap.add(p.first, addrs);
}
for (auto& p : addv) {
if (monmap.contains(p.first)) {
cerr << me << ": map already contains mon." << p.first << std::endl;
- usage();
+ helpful_exit();
}
if (monmap.contains(p.second)) {
cerr << me << ": map already contains " << p.second << std::endl;
- usage();
+ helpful_exit();
}
monmap.add(p.first, p.second);
}
cout << me << ": removing " << p << std::endl;
if (!monmap.contains(p)) {
cerr << me << ": map does not contain " << p << std::endl;
- usage();
+ helpful_exit();
}
monmap.remove(p);
}
modified = true;
}
- if (!print && !modified && !show_features)
- usage();
+ if (!print && !modified && !show_features) {
+ cerr << "no action specified" << std::endl;
+ helpful_exit();
+ }
if (print)
monmap.print(cout);