]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Let the default quota settings take effect during user creation
authorroot <root@ceph-node1.homeoffice.wal-mart.com>
Mon, 23 May 2016 10:04:58 +0000 (15:34 +0530)
committerroot <root@ceph-node1.homeoffice.wal-mart.com>
Sun, 19 Jun 2016 07:40:49 +0000 (13:10 +0530)
Signed-off-by: Pavan Rallabhandi <PRallabhandi@walmartlabs.com>
src/rgw/rgw_rest_user.cc
src/rgw/rgw_user.cc

index e72f5acb5acb2ad68ebdcbd77b8fbb3e87484d54..e7ef10185c25fe54ece30d4dcdede0f9c92e7862 100644 (file)
@@ -152,6 +152,37 @@ void RGWOp_User_Create::execute()
   if (gen_key)
     op_state.set_generate_key();
 
+  RGWQuotaInfo bucket_quota;
+  RGWQuotaInfo user_quota;
+
+  if (s->cct->_conf->rgw_bucket_default_quota_max_objects >= 0) {
+    bucket_quota.max_objects = s->cct->_conf->rgw_bucket_default_quota_max_objects;
+    bucket_quota.enabled = true;
+  }
+
+  if (s->cct->_conf->rgw_bucket_default_quota_max_size >= 0) {
+    bucket_quota.max_size = s->cct->_conf->rgw_bucket_default_quota_max_size;
+    bucket_quota.enabled = true;
+  }
+
+  if (s->cct->_conf->rgw_user_default_quota_max_objects >= 0) {
+    user_quota.max_objects = s->cct->_conf->rgw_user_default_quota_max_objects;
+    user_quota.enabled = true;
+  }
+
+  if (s->cct->_conf->rgw_user_default_quota_max_size >= 0) {
+    user_quota.max_size = s->cct->_conf->rgw_user_default_quota_max_size;
+    user_quota.enabled = true;
+  }
+
+  if (bucket_quota.enabled) {
+    op_state.set_bucket_quota(bucket_quota);
+  }
+
+  if (user_quota.enabled) {
+    op_state.set_user_quota(user_quota);
+  }
+
   http_ret = RGWUserAdminOp_User::create(store, op_state, flusher);
 }
 
index 7ce8e8beaf72926bc6bfd3fcdca5f097aff437f2..5aa2b7d74a951c7f520026ef1b0318fecbfb9aed 100644 (file)
@@ -1935,8 +1935,18 @@ int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg)
   if (op_state.op_mask_specified)
     user_info.op_mask = op_state.get_op_mask();
 
-  if (op_state.has_bucket_quota())
+  if (op_state.has_bucket_quota()) {
     user_info.bucket_quota = op_state.get_bucket_quota();
+  } else {
+    if (cct->_conf->rgw_bucket_default_quota_max_objects >= 0) {
+      user_info.bucket_quota.max_objects = cct->_conf->rgw_bucket_default_quota_max_objects;
+      user_info.bucket_quota.enabled = true;
+    }
+    if (cct->_conf->rgw_bucket_default_quota_max_size >= 0) {
+      user_info.bucket_quota.max_size = cct->_conf->rgw_bucket_default_quota_max_size;
+      user_info.bucket_quota.enabled = true;
+    }
+  }
 
   if (op_state.temp_url_key_specified) {
     map<int, string>::iterator iter;
@@ -1946,8 +1956,18 @@ int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg)
     }
   }
 
-  if (op_state.has_user_quota())
+  if (op_state.has_user_quota()) {
     user_info.user_quota = op_state.get_user_quota();
+  } else {
+    if (cct->_conf->rgw_user_default_quota_max_objects >= 0) {
+      user_info.user_quota.max_objects = cct->_conf->rgw_user_default_quota_max_objects;
+      user_info.user_quota.enabled = true;
+    }
+    if (cct->_conf->rgw_user_default_quota_max_size >= 0) {
+      user_info.user_quota.max_size = cct->_conf->rgw_user_default_quota_max_size;
+      user_info.user_quota.enabled = true;
+    }
+  }
 
   // update the request
   op_state.set_user_info(user_info);