return "";
}
-int destroy_ec_profile(rados_t *cluster)
+int destroy_ec_profile(rados_t *cluster, std::ostream &oss)
{
- char *cmd[2];
- cmd[0] = (char *)"{\"prefix\": \"osd erasure-code-profile rm\", \"name\": \"testprofile\"}";
- cmd[1] = NULL;
- return rados_mon_command(*cluster, (const char **)cmd, 1, "", 0, NULL, 0, NULL, 0);
+ char *cmd[2];
+ cmd[0] = (char *)"{\"prefix\": \"osd erasure-code-profile rm\", \"name\": \"testprofile\"}";
+ cmd[1] = NULL;
+ int ret = rados_mon_command(*cluster, (const char **)cmd, 1, "", 0, NULL, 0, NULL, 0);
+ if (ret)
+ oss << "rados_mon_command: erasure-code-profile rm testprofile failed with error " << ret;
+ return ret;
+}
+
+int destroy_ruleset(rados_t *cluster,
+ std::string ruleset,
+ std::ostream &oss)
+{
+ char *cmd[2];
+ std::string tmp = ("{\"prefix\": \"osd crush rule rm\", \"name\":\"" +
+ ruleset + "\"}");
+ cmd[0] = (char*)tmp.c_str();
+ cmd[1] = NULL;
+ int ret = rados_mon_command(*cluster, (const char **)cmd, 1, "", 0, NULL, 0, NULL, 0);
+ if (ret)
+ oss << "rados_mon_command: osd crush rule rm " + ruleset + " failed with error " << ret;
+ return ret;
+}
+
+int destroy_ec_profile_and_ruleset(rados_t *cluster,
+ std::string ruleset,
+ std::ostream &oss)
+{
+ int ret;
+ ret = destroy_ec_profile(cluster, oss);
+ if (ret)
+ return ret;
+ return destroy_ruleset(cluster, ruleset, oss);
}
+ std::string set_pg_num(
+ rados_t *cluster, const std::string &pool_name, uint32_t pg_num)
+ {
+ // Wait for 'creating' to clear
+ int r = wait_for_healthy(cluster);
+ if (r != 0) {
+ goto err;
+ }
+
+ // Adjust pg_num
+ r = rados_pool_set(cluster, pool_name, "pg_num", stringify(pg_num));
+ if (r != 0) {
+ goto err;
+ }
+
+ // Wait for 'creating' to clear
+ r = wait_for_healthy(cluster);
+ if (r != 0) {
+ goto err;
+ }
+
+ return "";
+
+ err:
+ rados_shutdown(*cluster);
+ std::ostringstream oss;
+ oss << __func__ << "(" << pool_name << ") failed with error " << r;
+ return oss.str();
+ }
+
std::string create_one_ec_pool(const std::string &pool_name, rados_t *cluster)
{
std::string err = connect_cluster(cluster);