| 1 |
#!/usr/bin/env python3 |
| 2 |
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. |
| 3 |
# Copyright (C) NIWA & British Crown (Met Office) & Contributors. |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
"""cylc remote-init [OPTIONS] ARGS |
| 18 |
|
| 19 |
(This command is for internal use.) |
| 20 |
|
| 21 |
Initialise an install target. |
| 22 |
|
| 23 |
Initialisation creates a workflow run directory on the install target, |
| 24 |
"$HOME/cylc-run/<WORKFLOW_ID>/". The .service directory is also created and |
| 25 |
populated with the install target authentication files and the contact file. |
| 26 |
|
| 27 |
Symlinks are created for run, work, share, share/cycle, log directories, |
| 28 |
configured in the global.flow. |
| 29 |
|
| 30 |
Return: |
| 31 |
0: |
| 32 |
On success or if initialisation not required (REMOTE_INIT_DONE) |
| 33 |
1: |
| 34 |
Error occurred when symlinking. |
| 35 |
2: |
| 36 |
Unexpected authentication keys exist. |
| 37 |
3: |
| 38 |
Any other unexpected error occurred. |
| 39 |
""" |
| 40 |
|
| 41 |
import sys |
| 42 |
|
| 43 |
from cylc.flow.option_parsers import CylcOptionParser as COP |
| 44 |
from cylc.flow.task_remote_cmd import remote_init |
| 45 |
from cylc.flow.terminal import cli_function |
| 46 |
|
| 47 |
|
| 48 |
INTERNAL = True |
| 49 |
|
| 50 |
|
| 51 |
def get_option_parser() -> COP: |
| 52 |
parser = COP( |
| 53 |
__doc__, |
| 54 |
argdoc=[ |
| 55 |
("INSTALL_TARGET", "Target to be initialised"), |
| 56 |
("RUND", "The run directory of the workflow"), |
| 57 |
COP.optional( |
| 58 |
('DIRS_TO_BE_SYMLINKED ...', "Directories to be symlinked") |
| 59 |
) |
| 60 |
], |
| 61 |
color=False |
| 62 |
) |
| 63 |
|
| 64 |
return parser |
| 65 |
|
| 66 |
|
| 67 |
@cli_function(get_option_parser) |
| 68 |
def main(parser, options, install_target, rund, *dirs_to_be_symlinked): |
| 69 |
sys.exit( |
| 70 |
remote_init( |
| 71 |
install_target, |
| 72 |
rund, |
| 73 |
*dirs_to_be_symlinked, |
| 74 |
) |
| 75 |
) |