Skip to content
Snippets Groups Projects

Fix some merge errors

2 files
+ 51
31
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 22
15
@@ -12,6 +12,7 @@ outdir="/data/rc/gpfs-policy/data"
policy_file="./policy-def/list-path-external"
device="scratch"
output_log_prefix=""
dry_run=""
############################################################
# Help #
@@ -33,7 +34,9 @@ Runs mmapplypolicy on the specified device/fileset. The policy file dictates the
Usage: $0 [ -h ] [ -o | --outdir ] [ -f | --output-prefix ] [ -P | --policy-file ] device
options:
-h|--help Print this Help.
-h|--help Print this Help.
--dry-run Do not run the policy command or any command that modifies any files or directories such as
mkdir
Required:
device GPFS fileset/directory apply the policy to. Can be
@@ -53,7 +56,7 @@ EOF
exit 0
}
args=$(getopt -a -o ho:f:P: --long help,outdir:,output-prefix:,policy-file: -- "$@")
args=$(getopt -a -o ho:f:P: --long help,outdir:,output-prefix:,policy-file:,dry-run -- "$@")
if [[ $? -gt 0 ]]; then
usage
@@ -67,7 +70,8 @@ do
-h | --help) help ;;
-o | --outdir) outdir=$2 ; shift 2 ;;
-f | --output-prefix) output_log_prefix=$2 ; shift 2 ;;
-P | --policy-file) policy_file=$2 ; shift 2 ;;
-P | --policy-file) policy_file=$2 ; shift 2 ;;
--dry-run) dry_run=true ; shift 1 ;;
--) shift; break ;;
*) >&2 echo Unsupported option: $1
usage ;;
@@ -86,7 +90,7 @@ if [[ -z "$device" ]]; then
usage
fi
# create default output_log_prefix if not specified in the arguments
# set default output_log_prefix if not specified in the arguments
if [[ -z "$output_log_prefix"]]; then
modified_device=$(echo "$device" | sed -e 's|^/||' -e 's|/$||' -e 's|/|-|g')
output_log_prefix="list-policy_${modified_device}"
@@ -95,7 +99,6 @@ fi
# create temporary working directory for list aggregation
tmpglobal=$outdir/slurm-tmp-${SLURM_JOBID}
tmpscratch=$outdir/slurm-tmp-${SLURM_JOBID}
mkdir -p $tmpglobal
nodes=`scontrol show hostnames "${SLURM_JOB_NODELIST}" | tr '\n' ',' | sed -e 's/,$//'`
cores="${SLURM_CPUS_PER_TASK}"
@@ -118,13 +121,17 @@ cmd="mmapplypolicy ${device} -I defer \
# report final command in job log
echo $cmd
# run policy command
$cmd
# tag output file with run metadata
outfile=`ls -t $tmpglobal | head -1`
if [[ "$outfile" != "" ]]
then
mv -n $tmpglobal/$outfile $tmpglobal/../${output_log_prefix}_$filetag
fi
rmdir $tmpglobal
if [[ -z "${dry_run}" ]]; then
mkdir -p $tmpglobal
# run policy command
$cmd
# tag output file with run metadata
outfile=`ls -t $tmpglobal | head -1`
if [[ "$outfile" != "" ]]
then
mv -n $tmpglobal/$outfile $tmpglobal/../${output_log_prefix}_$filetag
fi
rmdir $tmpglobal
fi
\ No newline at end of file
Loading