Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add -q option to dump mmapplypolicy command and quit
  • Loading branch information
root committed Nov 11, 2020
1 parent 68d70ee commit a4a6a4f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gpfs-scan-files.py
Expand Up @@ -69,10 +69,10 @@ def _ncheck_output(cmds):
def get_hostname():
return os.uname()[1]

def run_mmapplypolicy(exefile, target_dir, policy_file, temp_dir, out_dir, include_dir_file):
def run_mmapplypolicy(exefile, target_dir, policy_file, temp_dir, out_dir, include_dir_file, cmdonly=False):
# Ensure we are runnning mmapplypolicy on the correct host
hostname = get_hostname()
if not hostname in MMAPPLY_HOSTS:
if not hostname in MMAPPLY_HOSTS and not cmdonly:
print_error(" When using the -s option, you must run on one of the DDN NSD nodes (%s)" % ",".join(MMAPPLY_HOSTS))
# Create output directories
if not os.path.isdir(out_dir ): os.makedirs(out_dir )
Expand Down Expand Up @@ -104,6 +104,9 @@ def run_mmapplypolicy(exefile, target_dir, policy_file, temp_dir, out_dir, inclu
cmd = "%(exefile)s %(target_dir)s -s %(temp_dir)s -I defer -P %(policy_file)s -f %(out_dir)s -a4" % locals()
else:
cmd = "%(exefile)s %(target_dir)s -s %(temp_dir)s -I defer -P %(policy_file)s -f %(out_dir)s -i %(include_dir_file)s -a4" % locals()
if cmdonly:
print ("mmapplypolicy command is (%s)" % cmd)
sys.exit()
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out,err = p.communicate()
with open(out_dir + "/mm.out", "w") as fout: print(out,file=fout)
Expand Down Expand Up @@ -259,7 +262,7 @@ def add_date(datetime, days):
# Read arguments from command line
def parse_args(args):
try:
opts,args = getopt.getopt(sys.argv[1:],'s:p:D:C:H:hId:o:i:')
opts,args = getopt.getopt(sys.argv[1:],'s:p:D:C:H:hId:o:i:q')
except getopt.GetoptError as e:
Usage(" ERROR: " + str(e))
opts = dict(opts)
Expand Down Expand Up @@ -294,6 +297,7 @@ def Usage(msg=None):
-I Create new empty datbase file in DBNAME given by -D
-o Output directory for mmapplypolicy, must be on scratch partition.
Only valid with -s option. Default value is %s
-q With -s, print mmapplypolicy command only
""" % DEF_OUTDIR )
if msg:
print();print(msg);print()
Expand Down Expand Up @@ -344,7 +348,7 @@ def main():
policy_file = out_dir + "/policy_file"
target_dir = opts['-s']
include_dir_file = opts['-i'] if '-i' in opts else None
rc = run_mmapplypolicy(MMAPPLYPOLICY,target_dir,policy_file,temp_dir,out_dir, include_dir_file)
rc = run_mmapplypolicy(MMAPPLYPOLICY,target_dir,policy_file,temp_dir,out_dir, include_dir_file, '-q' in opts)
#rc = run_test(temp_dir,out_dir)
if rc>0: print_warn(" mmapplypolicy return code is (%d)" % rc)

Expand Down

0 comments on commit a4a6a4f

Please sign in to comment.