cout << " --default set entity (realm, zonegroup, zone) as default\n";
cout << " --read-only set zone as read-only (when adding to zonegroup)\n";
cout << " --endpoints=<list> zone endpoints\n";
+ cout << " --tier-type=<type> zone tier type\n";
+ cout << " --tier-config=<k>=<v>[,...]\n";
+ cout << " set zone tier config keys, values\n";
+ cout << " --tier-config-rm=<k>[,...]\n";
+ cout << " unset zone tier config keys\n";
+ cout << " --tier_type=<type> zone tier type\n";
cout << " --fix besides checking bucket index, will also fix it\n";
cout << " --check-objects bucket check: rebuilds bucket index according to\n";
cout << " actual objects state\n";
tab_dump("data sync", width, data_status);
}
-int main(int argc, char **argv)
+static void parse_tier_config_param(const string& s, map<string, string>& out)
+{
+ list<string> confs;
+ get_str_list(s, ",", confs);
+ for (auto c : confs) {
+ ssize_t pos = c.find("=");
+ if (pos < 0) {
+ out[c] = "";
+ } else {
+ out[c.substr(0, pos)] = c.substr(pos + 1);
+ }
+ }
+}
+
+int main(int argc, char **argv)
{
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
string source_zone_name;
string source_zone; /* zone id */
+ string tier_type;
+ bool tier_type_specified = false;
+
+ map<string, string> tier_config_add;
+ map<string, string> tier_config_rm;
+
+
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
get_str_list(val, endpoints);
} else if (ceph_argparse_witharg(args, i, &val, "--source-zone", (char*)NULL)) {
source_zone_name = val;
+ } else if (ceph_argparse_witharg(args, i, &val, "--tier-type", (char*)NULL)) {
+ tier_type = val;
+ tier_type_specified = true;
+ } else if (ceph_argparse_witharg(args, i, &val, "--tier-config", (char*)NULL)) {
+ parse_tier_config_param(val, tier_config_add);
+ } else if (ceph_argparse_witharg(args, i, &val, "--tier-config-rm", (char*)NULL)) {
+ parse_tier_config_param(val, tier_config_rm);
} else if (strncmp(*i, "-", 1) == 0) {
cerr << "ERROR: invalid flag " << *i << std::endl;
return EINVAL;
cerr << "unable to initialize zone: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
+ string *ptier_type = (tier_type_specified ? &tier_type : nullptr);
+ zone.tier_config = tier_config_add;
+
ret = zonegroup.add_zone(zone,
(is_master_set ? &is_master : NULL),
(is_read_only_set ? &read_only : NULL),
- endpoints);
+ endpoints, ptier_type);
if (ret < 0) {
cerr << "failed to add zone " << zone_name << " to zonegroup " << zonegroup.get_name() << ": "
<< cpp_strerror(-ret) << std::endl;
}
if (!zonegroup_id.empty() || !zonegroup_name.empty()) {
+ string *ptier_type = (tier_type_specified ? &tier_type : nullptr);
ret = zonegroup.add_zone(zone,
(is_master_set ? &is_master : NULL),
(is_read_only_set ? &read_only : NULL),
- endpoints);
+ endpoints,
+ ptier_type);
if (ret < 0) {
cerr << "failed to add zone " << zone_name << " to zonegroup " << zonegroup.get_name()
<< ": " << cpp_strerror(-ret) << std::endl;
need_zone_update = true;
}
+ for (auto add : tier_config_add) {
+ zone.tier_config[add.first] = add.second;
+ need_zone_update = true;
+ }
+
+ for (auto rm : tier_config_rm) {
+ zone.tier_config.erase(rm.first);
+ need_zone_update = true;
+ }
+
if (need_zone_update) {
ret = zone.update();
if (ret < 0) {
cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
+ string *ptier_type = (tier_type_specified ? &tier_type : nullptr);
ret = zonegroup.add_zone(zone,
(is_master_set ? &is_master : NULL),
(is_read_only_set ? &read_only : NULL),
- endpoints);
+ endpoints, ptier_type);
if (ret < 0) {
cerr << "failed to update zonegroup: " << cpp_strerror(-ret) << std::endl;
return -ret;