bool system_bucket, bool exclusive = true,
uint64_t auid = 0) = 0;
virtual int add_bucket_placement(std::string& new_placement) { return 0; }
+ virtual int remove_bucket_placement(std::string& new_placement) { return 0; }
+ virtual int list_placement_set(set<string>& names) { return 0; }
virtual int create_pools(vector<string>& names, vector<int>& retcodes, int auid = 0) { return -ENOTSUP; }
/** write an object to the storage device in the appropriate pool
with the given stats */
cerr << " bucket unlink unlink bucket from specified user\n";
cerr << " bucket stats returns bucket statistics\n";
cerr << " bucket info show bucket information\n";
- cerr << " pool add add an existing pool to those which can store buckets\n";
+ cerr << " pool add add an existing pool for data placement\n";
+ cerr << " pool rm remove an existing pool from data placement set\n";
+ cerr << " pools list list placement active set\n";
cerr << " policy read bucket/object policy\n";
cerr << " log list list log objects\n";
cerr << " log show dump a log from specific object or (bucket + date\n";
OPT_BUCKET_STATS,
OPT_POLICY,
OPT_POOL_ADD,
+ OPT_POOL_RM,
+ OPT_POOLS_LIST,
OPT_LOG_LIST,
OPT_LOG_SHOW,
OPT_LOG_RM,
strcmp(cmd, "buckets") == 0 ||
strcmp(cmd, "bucket") == 0 ||
strcmp(cmd, "pool") == 0 ||
+ strcmp(cmd, "pools") == 0 ||
strcmp(cmd, "log") == 0 ||
strcmp(cmd, "temp") == 0) {
*need_more = true;
} else if (strcmp(prev_cmd, "pool") == 0) {
if (strcmp(cmd, "add") == 0)
return OPT_POOL_ADD;
+ if (strcmp(cmd, "rm") == 0)
+ return OPT_POOL_RM;
+ } else if (strcmp(prev_cmd, "pools") == 0) {
+ if (strcmp(cmd, "list") == 0)
+ return OPT_POOLS_LIST;
}
return -EINVAL;
return usage();
}
- rgwstore->add_bucket_placement(pool_name);
+ int ret = rgwstore->add_bucket_placement(pool_name);
+ if (ret < 0)
+ cerr << "failed to add bucket placement: " << cpp_strerror(-ret) << std::endl;
+ }
+
+ if (opt_cmd == OPT_POOL_RM) {
+ if (pool_name.empty()) {
+ cerr << "need to specify pool to remove!" << std::endl;
+ return usage();
+ }
+
+ int ret = rgwstore->remove_bucket_placement(pool_name);
+ if (ret < 0)
+ cerr << "failed to remove bucket placement: " << cpp_strerror(-ret) << std::endl;
+ }
+
+ if (opt_cmd == OPT_POOLS_LIST) {
+ set<string> pools;
+ int ret = rgwstore->list_placement_set(pools);
+ if (ret < 0) {
+ cerr << "could not list placement set: " << cpp_strerror(-ret) << std::endl;
+ return ret;
+ }
+ formatter->reset();
+ formatter->open_array_section("pools");
+ set<string>::iterator siter;
+ for (siter = pools.begin(); siter != pools.end(); ++siter) {
+ formatter->open_object_section("pool");
+ formatter->dump_string("name", *siter);
+ formatter->close_section();
+ }
+ formatter->close_section();
+ formatter->flush(cout);
+ cout << std::endl;
}
if (opt_cmd == OPT_BUCKET_STATS) {
return ret;
}
+int RGWRados::remove_bucket_placement(std::string& old_pool)
+{
+ rgw_obj obj(pi_buckets_rados, avail_pools);
+ int ret = tmap_del(obj, old_pool);
+ return ret;
+}
+
+int RGWRados::list_placement_set(set<string>& names)
+{
+ bufferlist header;
+ map<string, bufferlist> m;
+ string pool_name;
+
+ rgw_obj obj(pi_buckets_rados, avail_pools);
+ int ret = tmap_get(obj, header, m);
+ if (ret < 0)
+ return ret;
+
+ names.clear();
+ map<string, bufferlist>::iterator miter;
+ for (miter = m.begin(); miter != m.end(); ++miter) {
+ names.insert(miter->first);
+ }
+
+ return names.size();
+}
+
int RGWRados::create_pools(vector<string>& names, vector<int>& retcodes, int auid)
{
vector<string>::iterator iter;
bucket link link bucket to specified user
bucket unlink unlink bucket from specified user
bucket stats returns bucket statistics
- pool add add an existing pool to those which can store buckets
- pool info show pool information
- pool create generate pool information (requires bucket)
+ bucket info show bucket information
+ pool add add an existing pool for data placement
+ pool rm remove an existing pool from data placement set
+ pools list list placement active set
policy read bucket/object policy
log list list log objects
log show dump a log from specific object or (bucket + date