summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-02-19 16:34:50 -0800
committerYehuda Sadeh <yehuda@inktank.com>2013-02-19 16:34:50 -0800
commit6a07608ceac4524120ef60ce456998e41f750248 (patch)
tree9ed33c1dd7a795d3c6e4e9559b305d4a5590f9f7
parent17ec5c4da63bcb1f53d1dd058575fbe9eefa6bba (diff)
downloadceph-6a07608ceac4524120ef60ce456998e41f750248.tar.gz
rgw: admin command to show region info
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_admin.cc25
-rw-r--r--src/rgw/rgw_rados.cc26
-rw-r--r--src/rgw/rgw_rados.h19
3 files changed, 56 insertions, 14 deletions
diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc
index e55613f3e21..01792999670 100644
--- a/src/rgw/rgw_admin.cc
+++ b/src/rgw/rgw_admin.cc
@@ -850,12 +850,19 @@ int main(int argc, char **argv)
return usage();
}
+ bool region_op = (opt_cmd == OPT_REGION_INFO);
+
+
user_modify_op = (opt_cmd == OPT_USER_MODIFY || opt_cmd == OPT_SUBUSER_MODIFY ||
opt_cmd == OPT_SUBUSER_CREATE || opt_cmd == OPT_SUBUSER_RM ||
opt_cmd == OPT_KEY_CREATE || opt_cmd == OPT_KEY_RM || opt_cmd == OPT_USER_RM ||
opt_cmd == OPT_CAPS_ADD || opt_cmd == OPT_CAPS_RM);
- store = RGWStoreManager::get_storage(g_ceph_context, false);
+ if (region_op) {
+ store = RGWStoreManager::get_raw_storage(g_ceph_context);
+ } else {
+ store = RGWStoreManager::get_storage(g_ceph_context, false);
+ }
if (!store) {
cerr << "couldn't init storage provider" << std::endl;
return 5; //EIO
@@ -863,6 +870,22 @@ int main(int argc, char **argv)
StoreDestructor store_destructor(store);
+ if (region_op) {
+ if (opt_cmd == OPT_REGION_INFO) {
+ RGWRegion region;
+ int ret = region.init(g_ceph_context, store);
+ if (ret < 0) {
+ cerr << "failed to init region: " << cpp_strerror(-ret) << std::endl;
+ }
+
+ encode_json("region", region, formatter);
+ formatter->flush(cout);
+ cout << std::endl;
+ }
+
+ return 0;
+ }
+
if (opt_cmd != OPT_USER_CREATE &&
opt_cmd != OPT_LOG_SHOW && opt_cmd != OPT_LOG_LIST && opt_cmd != OPT_LOG_RM &&
user_id.empty()) {
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index 85b2f98b164..ddc4da74dff 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -149,7 +149,7 @@ int RGWRegion::set_as_default()
return 0;
}
-int RGWRegion::init(CephContext *_cct, RGWRados *_store, bool create_region)
+int RGWRegion::init(CephContext *_cct, RGWRados *_store)
{
cct = _cct;
store = _store;
@@ -161,7 +161,7 @@ int RGWRegion::init(CephContext *_cct, RGWRados *_store, bool create_region)
if (name.empty()) {
int r = read_default();
if (r == -ENOENT) {
- r = init_default();
+ r = create_default();
if (r < 0)
return r;
r = set_as_default();
@@ -179,9 +179,6 @@ int RGWRegion::init(CephContext *_cct, RGWRados *_store, bool create_region)
string oid = region_info_oid_prefix + "." + name;
int ret = rgw_get_obj(store, NULL, pool, oid, bl);
- if (ret == -ENOENT && create_region) {
- return init_default();
- }
if (ret < 0) {
lderr(cct) << "failed reading region info from " << pool << ":" << oid << ": " << cpp_strerror(-ret) << dendl;
return ret;
@@ -198,7 +195,7 @@ int RGWRegion::init(CephContext *_cct, RGWRados *_store, bool create_region)
return 0;
}
-int RGWRegion::init_default()
+int RGWRegion::create_default()
{
name = "default";
string zone_name = "default";
@@ -392,7 +389,7 @@ int RGWRados::init_complete()
{
int ret;
- ret = region.init(cct, this, create_region);
+ ret = region.init(cct, this);
if (ret < 0)
return ret;
@@ -3782,6 +3779,21 @@ RGWRados *RGWStoreManager::init_storage_provider(CephContext *cct, bool use_gc_t
return store;
}
+RGWRados *RGWStoreManager::init_raw_storage_provider(CephContext *cct)
+{
+ RGWRados *store = NULL;
+ store = new RGWRados;
+
+ store->set_context(cct);
+
+ if (store->init_rados() < 0) {
+ delete store;
+ return NULL;
+ }
+
+ return store;
+}
+
void RGWStoreManager::close_storage(RGWRados *store)
{
if (!store)
diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h
index 4b9460beb17..05105d5a149 100644
--- a/src/rgw/rgw_rados.h
+++ b/src/rgw/rgw_rados.h
@@ -337,8 +337,8 @@ struct RGWRegion {
}
string get_pool_name(CephContext *cct);
- int init(CephContext *_cct, RGWRados *_store, bool create_zone);
- int init_default();
+ int init(CephContext *_cct, RGWRados *_store);
+ int create_default();
int store_info(bool exclusive);
int read_default();
int set_as_default();
@@ -470,7 +470,6 @@ protected:
string region_name;
string zone_name;
- bool create_region;
bool create_zone;
public:
@@ -480,11 +479,14 @@ public:
bucket_id_lock("rados_bucket_id"), max_bucket_id(0),
cct(NULL), rados(NULL),
pools_initialized(false),
- create_region(false), create_zone(false) {}
+ create_zone(false) {}
+
+ void set_context(CephContext *_cct) {
+ cct = _cct;
+ }
void set_region(const string& name, bool create) {
region_name = name;
- create_region = create;
}
void set_zone(const string& name, bool create) {
@@ -507,7 +509,7 @@ public:
CephContext *ctx() { return cct; }
/** do all necessary setup of the storage device */
int initialize(CephContext *_cct, bool _use_gc_thread) {
- cct = _cct;
+ set_context(cct);
use_gc_thread = _use_gc_thread;
return initialize();
}
@@ -890,7 +892,12 @@ public:
RGWRados *store = init_storage_provider(cct, use_gc_thread);
return store;
}
+ static RGWRados *get_raw_storage(CephContext *cct) {
+ RGWRados *store = init_raw_storage_provider(cct);
+ return store;
+ }
static RGWRados *init_storage_provider(CephContext *cct, bool use_gc_thread);
+ static RGWRados *init_raw_storage_provider(CephContext *cct);
static void close_storage(RGWRados *store);
};