diff options
| author | Milind Changire <mchangir@redhat.com> | 2017-06-06 12:27:28 +0530 | 
|---|---|---|
| committer | Aravinda VK <avishwan@redhat.com> | 2017-06-12 05:14:08 +0000 | 
| commit | dbdf56ae3f87fc2765ad9cb528c1cfbadfde96ec (patch) | |
| tree | aff5239f7e72699671f6f725534aa8c13e209161 /tools/glusterfind/src/main.py | |
| parent | 64588d4f6d69ce6e9b82335d12fa6c42794c38fa (diff) | |
tools/glusterfind: add --end-time option
Add optional --end-time argument to be used with --since-time
when using the "query" command.
"start" and "end" times are passed in the command-line to
changelog.py only if --full has not been specified on command-line.
-1 is passed to changelog.py as end time if user has not supplied
--end-time on command-line.
brickfind.py:
Remove unused "start" command-line argument.
Also:
Minor indentation changes to keep flake8-2.7 happy.
Change-Id: I063ef5459916f711503881ade5c4fc32374edad0
BUG: 1453151
Signed-off-by: Milind Changire <mchangir@redhat.com>
Reviewed-on: https://review.gluster.org/17439
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Aravinda VK <avishwan@redhat.com>
Diffstat (limited to 'tools/glusterfind/src/main.py')
| -rw-r--r-- | tools/glusterfind/src/main.py | 40 | 
1 files changed, 28 insertions, 12 deletions
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py index e6199a17a3c..3d0f02a65d4 100644 --- a/tools/glusterfind/src/main.py +++ b/tools/glusterfind/src/main.py @@ -139,9 +139,11 @@ def run_cmd_nodes(task, args, **kwargs):              cmd = [change_detector,                     args.session,                     args.volume, +                   host,                     brick, -                   node_outfile, -                   str(kwargs.get("start"))] + \ +                   node_outfile] + \ +                ([str(kwargs.get("start")), str(kwargs.get("end"))] +                    if not args.full else []) + \                  ([tag] if tag is not None else []) + \                  ["--output-prefix", args.output_prefix] + \                  (["--debug"] if args.debug else []) + \ @@ -174,9 +176,11 @@ def run_cmd_nodes(task, args, **kwargs):              cmd = [change_detector,                     args.session,                     args.volume, +                   host,                     brick, -                   node_outfile, -                   str(kwargs.get("start"))] + \ +                   node_outfile] + \ +                ([str(kwargs.get("start")), str(kwargs.get("end"))] +                    if not args.full else []) + \                  ([tag] if tag is not None else []) + \                  ["--only-query"] + \                  ["--output-prefix", args.output_prefix] + \ @@ -362,6 +366,8 @@ def _get_args():                                action=StoreAbsPath)      parser_query.add_argument("--since-time", help="UNIX epoch time since "                                "which listing is required", type=int) +    parser_query.add_argument("--end-time", help="UNIX epoch time upto " +                              "which listing is required", type=int)      parser_query.add_argument("--no-encode",                                help="Do not encode path in output file",                                action="store_true") @@ -569,27 +575,37 @@ def mode_query(session_dir, args):      enable_volume_options(args)      # Test options -    if not args.since_time and not args.full: -        fail("Please specify either --since-time or --full", logger=logger) +    if not args.since_time and not args.end_time and not args.full: +        fail("Please specify either {--since-time and optionally --end-time} " +             "or --full", logger=logger) -    if args.since_time and args.full: -        fail("Please specify either --since-time or --full, but not both", +    if args.since_time and args.end_time and args.full: +        fail("Please specify either {--since-time and optionally --end-time} " +             "or --full, but not both",               logger=logger) +    if args.end_time and not args.since_time: +        fail("Please specify --since-time as well", logger=logger) +      # Start query command processing +    start = -1 +    end = -1      if args.since_time:          start = args.since_time +        if args.end_time: +            end = args.end_time      else:          start = 0  # --full option is handled separately      logger.debug("Query is called - Session: %s, Volume: %s, " -                 "Start time: %s" -                 % ("default", args.volume, start)) +                 "Start time: %s, End time: %s" +                 % ("default", args.volume, start, end))      prefix = datetime.now().strftime("%Y%m%d-%H%M%S-%f-")      gtmpfilename = prefix + next(tempfile._get_candidate_names()) -    run_cmd_nodes("query", args, start=start, tmpfilename=gtmpfilename) +    run_cmd_nodes("query", args, start=start, end=end, +                  tmpfilename=gtmpfilename)      # Merger      if args.full: @@ -648,7 +664,7 @@ def mode_pre(session_dir, args):      prefix = datetime.now().strftime("%Y%m%d-%H%M%S-%f-")      gtmpfilename = prefix + next(tempfile._get_candidate_names()) -    run_cmd_nodes("pre", args, start=start, tmpfilename=gtmpfilename) +    run_cmd_nodes("pre", args, start=start, end=-1, tmpfilename=gtmpfilename)      # Merger      if args.full:  | 
