]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw-admin: user create is idempotent
authorYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 17 Apr 2012 23:45:19 +0000 (16:45 -0700)
committerSage Weil <sage@newdream.net>
Wed, 18 Apr 2012 04:38:12 +0000 (21:38 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
Reviewed-by: Sage Weil <sage@newdream.net>
src/rgw/rgw_admin.cc

index b915147869d0574a2899363aa371ea7fc05076bc..692f2f83fec772b6be2c3ef0c21a07040629a1ea 100644 (file)
@@ -723,8 +723,14 @@ int main(int argc, char **argv)
 
     if (opt_cmd == OPT_USER_CREATE) {
       if (found) {
-        cerr << "error: user already exists" << std::endl;
-        return 1;
+        if (info.display_name.compare(display_name) != 0 ||
+            info.user_email.compare(user_email) != 0) {
+          cerr << "error: user already exists with different display_name/email" << std::endl;
+          return 1;
+        }
+        /* turn into OPT_USER_MODIFY */
+        opt_cmd = OPT_USER_MODIFY;
+        user_modify_op = true;
       }
     } else if (!found) {
       cerr << "error reading user info, aborting" << std::endl;