JSONDecoder::decode_json("default_region", default_region, obj);
}
-string RGWRegion::get_pool_name(CephContext *cct)
+int RGWRegion::get_pool_name(CephContext *cct, string *pool_name)
{
- string pool_name = cct->_conf->rgw_region_root_pool;
- if (pool_name.empty()) {
- pool_name = RGW_DEFAULT_REGION_ROOT_POOL;
+ *pool_name = cct->_conf->rgw_region_root_pool;
+ if (pool_name->empty()) {
+ *pool_name = RGW_DEFAULT_REGION_ROOT_POOL;
+ } else if ((*pool_name)[0] != '.') {
+ derr << "ERROR: region root pool name must start with a period" << dendl;
+ return -EINVAL;
}
- return pool_name;
+ return 0;
}
int RGWRegion::read_default(RGWDefaultRegionInfo& default_info)
{
- string pool_name = get_pool_name(cct);
+ string pool_name;
+
+ int ret = get_pool_name(cct, &pool_name);
+ if (ret < 0) {
+ return ret;
+ }
string oid = cct->_conf->rgw_default_region_info_oid;
if (oid.empty()) {
rgw_bucket pool(pool_name.c_str());
bufferlist bl;
- int ret = rgw_get_system_obj(store, NULL, pool, oid, bl, NULL, NULL);
+ ret = rgw_get_system_obj(store, NULL, pool, oid, bl, NULL, NULL);
if (ret < 0)
return ret;
int RGWRegion::set_as_default()
{
- string pool_name = get_pool_name(cct);
+ string pool_name;
+ int ret = get_pool_name(cct, &pool_name);
+ if (ret < 0)
+ return ret;
string oid = cct->_conf->rgw_default_region_info_oid;
if (oid.empty()) {
::encode(default_info, bl);
- int ret = rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), false, NULL, 0, NULL);
+ ret = rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), false, NULL, 0, NULL);
if (ret < 0)
return ret;
int RGWRegion::read_info(const string& region_name)
{
- string pool_name = get_pool_name(cct);
+ string pool_name;
+ int ret = get_pool_name(cct, &pool_name);
+ if (ret < 0)
+ return ret;
+
rgw_bucket pool(pool_name.c_str());
bufferlist bl;
string oid = region_info_oid_prefix + name;
- int ret = rgw_get_system_obj(store, NULL, pool, oid, bl, NULL, NULL);
+ ret = rgw_get_system_obj(store, NULL, pool, oid, bl, NULL, NULL);
if (ret < 0) {
lderr(cct) << "failed reading region info from " << pool << ":" << oid << ": " << cpp_strerror(-ret) << dendl;
return ret;
int RGWRegion::store_info(bool exclusive)
{
- string pool_name = get_pool_name(cct);
+ string pool_name;
+ int ret = get_pool_name(cct, &pool_name);
+ if (ret < 0)
+ return ret;
rgw_bucket pool(pool_name.c_str());
bufferlist bl;
::encode(*this, bl);
- int ret = rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), exclusive, NULL, 0, NULL);
+ ret = rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), exclusive, NULL, 0, NULL);
return ret;
}
}
}
-string RGWZoneParams::get_pool_name(CephContext *cct)
+int RGWZoneParams::get_pool_name(CephContext *cct, string *pool_name)
{
- string pool_name = cct->_conf->rgw_zone_root_pool;
- if (pool_name.empty()) {
- pool_name = RGW_DEFAULT_ZONE_ROOT_POOL;
+ *pool_name = cct->_conf->rgw_zone_root_pool;
+ if (pool_name->empty()) {
+ *pool_name = RGW_DEFAULT_ZONE_ROOT_POOL;
+ } else if ((*pool_name)[0] != '.') {
+ derr << "ERROR: zone root pool name must start with a period" << dendl;
+ return -EINVAL;
}
- return pool_name;
+
+ return 0;
}
void RGWZoneParams::init_name(CephContext *cct, RGWRegion& region)
{
init_name(cct, region);
- string pool_name = get_pool_name(cct);
+ string pool_name;
+ int ret = get_pool_name(cct, &pool_name);
+ if (ret < 0)
+ return ret;
rgw_bucket pool(pool_name.c_str());
bufferlist bl;
string oid = zone_info_oid_prefix + name;
- int ret = rgw_get_system_obj(store, NULL, pool, oid, bl, NULL, NULL);
+ ret = rgw_get_system_obj(store, NULL, pool, oid, bl, NULL, NULL);
if (ret < 0)
return ret;
{
init_name(cct, region);
- string pool_name = get_pool_name(cct);
+ string pool_name;
+ int ret = get_pool_name(cct, &pool_name);
+ if (ret < 0)
+ return ret;
rgw_bucket pool(pool_name.c_str());
string oid = zone_info_oid_prefix + name;
bufferlist bl;
::encode(*this, bl);
- int ret = rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), false, NULL, 0, NULL);
+ ret = rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), false, NULL, 0, NULL);
return ret;
}
int RGWRados::list_regions(list<string>& regions)
{
- string pool_name = RGWRegion::get_pool_name(cct);
+ string pool_name;
+ int ret = RGWRegion::get_pool_name(cct, &pool_name);
+ if (ret < 0)
+ return ret;
return list_raw_prefixed_objs(pool_name, region_info_oid_prefix, regions);
}
int RGWRados::list_zones(list<string>& zones)
{
- string pool_name = RGWZoneParams::get_pool_name(cct);
+ string pool_name;
+ int ret = RGWZoneParams::get_pool_name(cct, &pool_name);
+ if (ret < 0)
+ return ret;
return list_raw_prefixed_objs(pool_name, zone_info_oid_prefix, zones);
}