From d193ed84ae2886d89b899e02e9642e61bdab462a Mon Sep 17 00:00:00 2001 From: Shwetha K Acharya Date: Mon, 31 Dec 2018 10:55:21 +0530 Subject: tools/glusterfind: option to display only files/directories Updated full find to filter for files and directories. --full --type f lists only the files, --full --type d lists only the directories, --full (by default) lists both files and directories. fixes: #579 Change-Id: If2c91a21a131667d5de34635c1846013e8fa20b7 Signed-off-by: Shwetha K Acharya --- tools/glusterfind/src/main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tools/glusterfind/src/main.py') diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py index dd44cfbfb74..8719b786127 100644 --- a/tools/glusterfind/src/main.py +++ b/tools/glusterfind/src/main.py @@ -165,6 +165,7 @@ def run_cmd_nodes(task, args, **kwargs): (["--no-encode"] if args.no_encode else []) + \ (["--only-namespace-changes"] if args.only_namespace_changes else []) + \ + (["--type", args.type]) + \ (["--field-separator", FS] if args.full else []) opts["node_outfile"] = node_outfile @@ -203,6 +204,7 @@ def run_cmd_nodes(task, args, **kwargs): (["--no-encode"] if args.no_encode else []) + \ (["--only-namespace-changes"] if args.only_namespace_changes else []) + \ + (["--type", args.type]) + \ (["--field-separator", FS] if args.full else []) opts["node_outfile"] = node_outfile @@ -370,6 +372,9 @@ def _get_args(): help="Tag prefix for file names emitted during" " a full find operation; default: \"NEW\"", default="NEW") + parser_pre.add_argument('--type', help="type: f, f-files only" + " d, d-directories only, by default = both", + default='both', choices=["f", "d", "both"]) parser_pre.add_argument("--field-separator", help="Field separator string", default=" ") @@ -399,6 +404,9 @@ def _get_args(): help="Tag prefix for file names emitted during" " a full find operation; default: \"NEW\"", default="NEW") + parser_query.add_argument('--type', help="type: f, f-files only" + " d, d-directories only, by default = both", + default='both', choices=["f", "d", "both"]) parser_query.add_argument("--field-separator", help="Field separator string", default=" ") @@ -589,6 +597,8 @@ def mode_query(session_dir, args): enable_volume_options(args) # Test options + if not args.full and args.type in ["f", "d"]: + fail("--type can only be used with --full") 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) @@ -656,6 +666,9 @@ def mode_pre(session_dir, args): mkdirp(os.path.dirname(args.outfile), exit_on_err=True, logger=logger) + if not args.full and args.type in ["f", "d"]: + fail("--type can only be used with --full") + # If Pre status file exists and running pre command again if os.path.exists(status_file_pre) and not args.regenerate_outfile: fail("Post command is not run after last pre, " -- cgit