diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 8b5699c3896..b3b4485d704 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -74,10 +74,9 @@ void _usage() cerr << " --bucket=\n"; cerr << " --pool=\n"; cerr << " --object=\n"; - cerr << " --date=\n"; - cerr << " --start-date=\n"; - cerr << " --end-date=\n"; - cerr << " --time=\n"; + cerr << " --date=\n"; + cerr << " --start-date=\n"; + cerr << " --end-date=\n"; cerr << " --bucket-id=\n"; cerr << " --format= specify output format for certain operations: xml,\n"; cerr << " json\n"; @@ -90,6 +89,9 @@ void _usage() cerr << " --skip-zero-entries log show only dumps entries that don't have zero value\n"; cerr << " in one of the numeric field\n"; cerr << " --yes-i-really-mean-it required for certain operations\n"; + cerr << "\n"; + cerr << " := \"YYYY-MM-DD[ hh:mm:ss]\"\n"; + cerr << "\n"; generic_client_usage(); } @@ -514,16 +516,34 @@ enum ObjectKeyType { KEY_TYPE_S3, }; -static void parse_date(string& date, uint64_t *epoch) +static void parse_date(string& date, uint64_t *epoch, string *out_date = NULL, string *out_time = NULL) { struct tm tm; memset(&tm, 0, sizeof(tm)); const char *p = strptime(date.c_str(), "%Y-%m-%d", &tm); - if (p && !*p) { // success! - time_t t = timegm(&tm); + if (p) { + if (*p == ' ') { + p++; + strptime(p, " %I:%M:%S", &tm); + } + } else { + return; + } + time_t t = timegm(&tm); + if (epoch) *epoch = (uint64_t)t; + + if (out_date) { + char buf[32]; + strftime(buf, sizeof(buf), "%F", &tm); + *out_date = buf; + } + if (out_time) { + char buf[32]; + strftime(buf, sizeof(buf), "%T", &tm); + *out_time = buf; } } @@ -538,7 +558,7 @@ int main(int argc, char **argv) std::string user_id, access_key, secret_key, user_email, display_name; std::string bucket_name, pool_name, object; - std::string date, time, subuser, access, format; + std::string date, subuser, access, format; std::string start_date, end_date; std::string key_type_str; ObjectKeyType key_type = KEY_TYPE_S3; @@ -623,16 +643,14 @@ int main(int argc, char **argv) auid = tmp; } else if (ceph_argparse_witharg(args, i, &val, "--max-buckets", (char*)NULL)) { max_buckets = atoi(val.c_str()); - } else if (ceph_argparse_witharg(args, i, &val, "--date", (char*)NULL)) { + } else if (ceph_argparse_witharg(args, i, &val, "--date", "--time", (char*)NULL)) { date = val; if (end_date.empty()) end_date = date; - } else if (ceph_argparse_witharg(args, i, &val, "--start-date", (char*)NULL)) { + } else if (ceph_argparse_witharg(args, i, &val, "--start-date", "--start-time", (char*)NULL)) { start_date = val; - } else if (ceph_argparse_witharg(args, i, &val, "--end-date", (char*)NULL)) { + } else if (ceph_argparse_witharg(args, i, &val, "--end-date", "--end-time", (char*)NULL)) { end_date = val; - } else if (ceph_argparse_witharg(args, i, &val, "--time", (char*)NULL)) { - time = val; } else if (ceph_argparse_witharg(args, i, &val, "--access", (char*)NULL)) { access = val; perm_mask = str_to_perm(access.c_str()); @@ -1093,7 +1111,9 @@ int main(int argc, char **argv) cerr << "date wasn't specified" << std::endl; return usage(); } - int r = store->remove_temp_objects(date, time); + string parsed_date, parsed_time; + parse_date(date, NULL, &parsed_date, &parsed_time); + int r = store->remove_temp_objects(parsed_date, parsed_time); if (r < 0) { cerr << "failure removing temp objects: " << cpp_strerror(r) << std::endl; return 1; diff --git a/src/test/cli/radosgw-admin/help.t b/src/test/cli/radosgw-admin/help.t index 94b6ce4febd..75a18aaa455 100644 --- a/src/test/cli/radosgw-admin/help.t +++ b/src/test/cli/radosgw-admin/help.t @@ -45,10 +45,9 @@ --bucket= --pool= --object= - --date= - --start-date= - --end-date= - --time= + --date= + --start-date= + --end-date= --bucket-id= --format= specify output format for certain operations: xml, json @@ -61,6 +60,9 @@ --skip-zero-entries log show only dumps entries that don't have zero value in one of the numeric field --yes-i-really-mean-it required for certain operations + + := "YYYY-MM-DD[ hh:mm:ss]" + --conf/-c Read configuration from the given configuration file -d Run in foreground, log to stderr. -f Run in foreground, log to usual location.