diff --git a/bin/cylc-register b/bin/cylc-register index 976e4db9f3e..187ea68ca84 100755 --- a/bin/cylc-register +++ b/bin/cylc-register @@ -67,10 +67,14 @@ def main(): ("[PATH]", "Suite definition directory (defaults to $PWD)")]) parser.add_option( - "--redirect", help="Allow an existing suite name and run directory " - "to be used with another suite.", + "--redirect", help="Allow an existing suite name and run directory" + " to be used with another suite.", action="store_true", default=False, dest="redirect") + parser.add_option( + "--run-dir", help="Symlink $HOME/cylc-run/REG to RUNDIR/REG.", + action="store", metavar="RUNDIR", default=None, dest="rundir") + opts, args = parser.parse_args() if len(args) == 2: reg, src = args @@ -79,7 +83,8 @@ def main(): src = None else: reg = src = None - SuiteSrvFilesManager().register(reg, src, redirect=opts.redirect) + SuiteSrvFilesManager().register( + reg, src, redirect=opts.redirect, rundir=opts.rundir) if __name__ == "__main__": diff --git a/lib/cylc/suite_srv_files_mgr.py b/lib/cylc/suite_srv_files_mgr.py index 3daba5f5c7a..0dd709f68fa 100644 --- a/lib/cylc/suite_srv_files_mgr.py +++ b/lib/cylc/suite_srv_files_mgr.py @@ -420,7 +420,7 @@ def parse_suite_arg(self, options, arg): name = os.path.basename(os.path.dirname(arg)) return name, path - def register(self, reg=None, source=None, redirect=False): + def register(self, reg=None, source=None, redirect=False, rundir=None): """Register a suite, or renew its registration. Create suite service directory and symlink to suite source location. @@ -459,7 +459,15 @@ def register(self, reg=None, source=None, redirect=False): # Create service dir if necessary. srv_d = self.get_suite_srv_dir(reg) - mkdir_p(srv_d) + if rundir is None: + mkdir_p(srv_d) + else: + suite_run_d, srv_d_name = os.path.split(srv_d) + alt_suite_run_d = os.path.join(rundir, reg) + alt_srv_d = os.path.join(rundir, reg, srv_d_name) + mkdir_p(alt_srv_d) + mkdir_p(os.path.dirname(suite_run_d)) + os.symlink(alt_suite_run_d, suite_run_d) # See if suite already has a source or not try: