]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_admin: policy dump --xml backward compatibility 8036/head
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 10 Mar 2016 22:15:09 +0000 (14:15 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 10 Mar 2016 22:22:19 +0000 (14:22 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_bucket.cc
src/rgw/rgw_bucket.h

index d7ba50cccf2b69bd007eb89448ef9c2249aa55c2..ed0e21fd485c5e4877ecbd4c251f1095aa89f803 100644 (file)
@@ -3462,10 +3462,18 @@ int main(int argc, char **argv)
   }
 
   if (opt_cmd == OPT_POLICY) {
-    int ret = RGWBucketAdminOp::get_policy(store, bucket_op, f);
-    if (ret < 0) {
-      cerr << "ERROR: failed to get policy: " << cpp_strerror(-ret) << std::endl;
-      return -ret;
+    if (format == "xml") {
+      int ret = RGWBucketAdminOp::dump_s3_policy(store, bucket_op, cout);
+      if (ret < 0) {
+        cerr << "ERROR: failed to get policy: " << cpp_strerror(-ret) << std::endl;
+        return -ret;
+      }
+    } else {
+      int ret = RGWBucketAdminOp::get_policy(store, bucket_op, f);
+      if (ret < 0) {
+        cerr << "ERROR: failed to get policy: " << cpp_strerror(-ret) << std::endl;
+        return -ret;
+      }
     }
   }
 
index 9b2294c15a2a54934c4ef0b08b5785ab23366c2e..a070508c3150c9e792b7902ce93bd449474731b8 100644 (file)
@@ -1012,6 +1012,20 @@ int RGWBucketAdminOp::get_policy(RGWRados *store, RGWBucketAdminOpState& op_stat
   return 0;
 }
 
+int RGWBucketAdminOp::dump_s3_policy(RGWRados *store, RGWBucketAdminOpState& op_state,
+                  ostream& os)
+{
+  RGWAccessControlPolicy_S3 policy(store->ctx());
+
+  int ret = get_policy(store, op_state, policy);
+  if (ret < 0)
+    return ret;
+
+  policy.to_xml(os);
+
+  return 0;
+}
+
 int RGWBucketAdminOp::unlink(RGWRados *store, RGWBucketAdminOpState& op_state)
 {
   RGWBucket bucket;
index 924c636021fd50145958e2b19073456fe7393ee3..069d81825db329a7811edd5557b98be7e7bd352e 100644 (file)
@@ -292,7 +292,8 @@ public:
                   RGWFormatterFlusher& flusher);
   static int get_policy(RGWRados *store, RGWBucketAdminOpState& op_state,
                   RGWAccessControlPolicy& policy);
-
+  static int dump_s3_policy(RGWRados *store, RGWBucketAdminOpState& op_state,
+                  ostream& os);
 
   static int unlink(RGWRados *store, RGWBucketAdminOpState& op_state);
   static int link(RGWRados *store, RGWBucketAdminOpState& op_state, string *err_msg = NULL);