expect_false ceph mon feature set abcd --yes-i-really-mean-it
}
+function test_mon_priority_and_weight()
+{
+ for i in 0 1 65535; do
+ ceph mon set-weight a $i
+ w=$(ceph mon dump --format=json-pretty 2>/dev/null | jq '.mons[0].weight')
+ [[ "$w" == "$i" ]]
+ done
+
+ for i in -1 65536; do
+ expect_false ceph mon set-weight a $i
+ done
+}
+
function gen_secrets_file()
{
# lets assume we can have the following types
"name=addrs,type=CephString",
"set the addrs (IPs and ports) a specific monitor binds to",
"mon", "rw")
+COMMAND("mon set-weight " \
+ "name=name,type=CephString " \
+ "name=weight,type=CephInt,range=0|65535",
+ "set the weight for the specified mon",
+ "mon", "rw")
COMMAND("mon enable-msgr2",
"enable the msgr2 protocol on port 3300",
"mon", "rw")
ceph_assert(it != mon_info.end());
return it->second.weight;
}
+ void set_weight(const string& n, uint16_t v) {
+ auto it = mon_info.find(n);
+ ceph_assert(it != mon_info.end());
+ it->second.weight = v;
+ }
void encode(bufferlist& blist, uint64_t con_features) const;
void decode(bufferlist& blist) {
pending_map.set_addrvec(name, av);
pending_map.last_changed = ceph_clock_now();
propose = true;
+ } else if (prefix == "mon set-weight") {
+ string name;
+ int64_t weight;
+ if (!cmd_getval(g_ceph_context, cmdmap, "name", name) ||
+ !cmd_getval(g_ceph_context, cmdmap, "weight", weight)) {
+ err = -EINVAL;
+ goto reply;
+ }
+ if (!pending_map.contains(name)) {
+ ss << "mon." << name << " does not exist";
+ err = -ENOENT;
+ goto reply;
+ }
+ err = 0;
+ pending_map.set_weight(name, weight);
+ pending_map.last_changed = ceph_clock_now();
+ propose = true;
} else if (prefix == "mon enable-msgr2") {
if (!monmap.get_required_features().contains_all(
ceph::features::mon::FEATURE_NAUTILUS)) {