mirror of
https://github.com/ceph/ceph
synced 2024-12-28 14:34:13 +00:00
rgw: radosgw-admin date params now also accept time
The date format now is "YYYY-MM-DD[ hh:mm:ss]". Got rid of the --time param for the old ops log stuff. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com> Conflicts: src/test/cli/radosgw-admin/help.t
This commit is contained in:
parent
6958aeb898
commit
4c19ecb9a3
@ -74,10 +74,9 @@ void _usage()
|
||||
cerr << " --bucket=<bucket>\n";
|
||||
cerr << " --pool=<pool>\n";
|
||||
cerr << " --object=<object>\n";
|
||||
cerr << " --date=<yyyy-mm-dd>\n";
|
||||
cerr << " --start-date=<yyyy-mm-dd>\n";
|
||||
cerr << " --end-date=<yyyy-mm-dd>\n";
|
||||
cerr << " --time=<HH:MM:SS>\n";
|
||||
cerr << " --date=<date>\n";
|
||||
cerr << " --start-date=<date>\n";
|
||||
cerr << " --end-date=<date>\n";
|
||||
cerr << " --bucket-id=<bucket-id>\n";
|
||||
cerr << " --format=<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 << "<date> := \"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;
|
||||
|
@ -45,10 +45,9 @@
|
||||
--bucket=<bucket>
|
||||
--pool=<pool>
|
||||
--object=<object>
|
||||
--date=<yyyy-mm-dd>
|
||||
--start-date=<yyyy-mm-dd>
|
||||
--end-date=<yyyy-mm-dd>
|
||||
--time=<HH:MM:SS>
|
||||
--date=<date>
|
||||
--start-date=<date>
|
||||
--end-date=<date>
|
||||
--bucket-id=<bucket-id>
|
||||
--format=<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
|
||||
|
||||
<date> := "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.
|
||||
|
Loading…
Reference in New Issue
Block a user