|
4 | 4 | This script should be run before SRAM external users sync so that the sync has accurate user information as input. |
5 | 5 |
|
6 | 6 | Example: |
7 | | -To migrate SRAM groups to non-SRAM groups and output the results in a log file : |
8 | | -python3 sram-migration-script.py -f sram-groups-to-non-sram.py |
| 7 | +To migrate SRAM groups to non-SRAM groups: |
| 8 | +python3 sram-migration-script.py -c non-sram -f sram-groups-to-non-sram.csv |
9 | 9 |
|
10 | | -To output the results in a log file : |
11 | | -python3 sram-migration-script.py -l -f sram-groups-to-non-sram.py |
12 | | -
|
13 | | -To dry run the migration script : |
14 | | -python3 sram-migration-script.py -d -f sram-groups-to-non-sram.py |
| 10 | +To output the results in a log file: |
| 11 | +python3 sram-migration-script.py -c non-sram -f sram-groups-to-non-sram.csv -l |
15 | 12 |
|
| 13 | +To dry run the migration script: |
| 14 | +python3 sram-migration-script.py -c non-sram -f sram-groups-to-non-sram.csv -d |
16 | 15 | """ |
17 | 16 | import argparse |
18 | 17 | import subprocess |
19 | 18 |
|
20 | 19 |
|
21 | 20 | def parse_args(): |
| 21 | + """Parse command-line arguments.""" |
22 | 22 | parser = argparse.ArgumentParser( |
23 | 23 | prog="sram-migration-script.py", |
24 | 24 | description=__doc__, |
25 | | - formatter_class=argparse.RawTextHelpFormatter) |
26 | | - parser.add_argument("-l", "--log-file", action='store_true', |
27 | | - help="If log file parameter is true then write to log at: /var/lib/irods/log/sram-migration.log") |
28 | | - parser.add_argument("-d", "--dry-run", action='store_true', |
29 | | - help="Run the migration script offline.") |
30 | | - parser.add_argument("-c", "--convert-group", type=str, required=True, |
31 | | - help="Convert the group to either 'sram' or 'non-sram' group.") |
32 | | - parser.add_argument("-f", "--file-name", type=str, required=True, |
33 | | - help="CSV file containing SRAM group names to be migrated to non-SRAM group.") |
| 25 | + formatter_class=argparse.RawTextHelpFormatter |
| 26 | + ) |
| 27 | + parser.add_argument( |
| 28 | + "-l", "--log-file", |
| 29 | + action='store_true', |
| 30 | + help="Write output to log file at /var/lib/irods/log/sram-migration.log" |
| 31 | + ) |
| 32 | + parser.add_argument( |
| 33 | + "-d", "--dry-run", |
| 34 | + action='store_true', |
| 35 | + help="Run the migration script in dry-run mode without making changes" |
| 36 | + ) |
| 37 | + parser.add_argument( |
| 38 | + "-c", "--convert-group", |
| 39 | + type=str, |
| 40 | + required=True, |
| 41 | + choices=['sram', 'non-sram'], |
| 42 | + help="Convert groups to either 'sram' or 'non-sram'" |
| 43 | + ) |
| 44 | + parser.add_argument( |
| 45 | + "-f", "--file-name", |
| 46 | + type=str, |
| 47 | + required=True, |
| 48 | + help="Path to CSV file containing group names to be migrated" |
| 49 | + ) |
34 | 50 | return parser.parse_args() |
35 | 51 |
|
36 | 52 | def main(): |
| 53 | + """Execute the SRAM migration rule.""" |
37 | 54 | args = parse_args() |
38 | 55 | rule_name = "/etc/irods/yoda-ruleset/tools/sram/sram-migration.r" |
39 | 56 | log_loc = f"*log_loc={args.log_file if args.log_file else ''}" |
|
0 commit comments