Skip to content
Snippets Groups Projects

Run policy minor edits

Merged Matthew K Defenderfer requested to merge run-policy-minor-edits into main
1 file
+ 12
11
Compare changes
  • Side-by-side
  • Inline
@@ -20,10 +20,8 @@ def parse_args():
parser.add_argument('-o','--outdir', type=str,
help="Directory to store the policy output in",
default='/data/rc/gpfs-policy/data')
parser.add_argument('-f','--outfile', type=str,
help="Base name of the output file. Defaults to 'list-policy_[device-id]' where 'device-id'"
"is the device stem when device is a path or just device when it is a fileset. The final"
"file name will have the policy type, the job ID, and the run date tagged on the end")
parser.add_argument('-f','--log-prefix', type=str,
help="Prefix for the policy output file. Defaults to 'list-policy_[device-id]' where 'device-id' is the device stem. The final file name will have the policy type, the job ID, and the run date tagged on the end")
parser.add_argument('--with-dirs', action='store_true',
help="Include directories as entries in the policy output (Default: false)")
@@ -107,12 +105,12 @@ def validate_output_directory(outdir):
raise ValueError(f"{p} is not a valid output directory")
return p
def create_default_outfile(device):
def create_default_log_prefix(device):
if device.match('/data/user'):
outfile = 'list-policy_data_user'
log_prefix = 'list-policy_data_user'
else:
outfile = f'list-policy_{device.stem}'
return outfile
log_prefix = f'list-policy_{device.stem}'
return log_prefix
def main():
args = parse_args()
@@ -126,15 +124,18 @@ def main():
args['outdir'] = validate_output_directory(args['outdir'])
if args['outfile'] is None:
args['outfile'] = create_default_outfile(args['device'])
if args['log_prefix'] is None:
args['log_prefix'] = create_default_log_prefix(args['device'])
# Paths to policy definitions are hard-coded here and should not be altered in any way. This script gives elevated
# permissions to run the GPFS policy engine to non-admins. These are the only two policy files non-admins should
# use. Any other policy needs should go through an admin.
if args['with_dirs']:
args['policy'] = './policy-def/list-path-dirplus'
else:
args['policy'] = './policy-def/list-path-external'
cmd = "./submit-pol-job -o {outdir} -f {outfile} -P {policy} -N {nodes} -c {cores} -p {partition} -t {time} -m {mem_per_cpu} {device}".format(**args)
cmd = "./submit-pol-job -o {outdir} -f {log_prefix} -P {policy} -N {nodes} -c {cores} -p {partition} -t {time} -m {mem_per_cpu} {device}".format(**args)
print(f"Command: {cmd}")
subprocess.run(cmd,shell=True)
Loading