From 257b66a8fcd9a64dbcf939b3dbe7ddd58c69c7ee Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Thu, 30 Nov 2023 11:20:10 +0100 Subject: [PATCH] TMSS-2836: made command line tool tmss_create_lofar2_sibling to call the create_lofar2_sibling endpoint --- SAS/TMSS/client/bin/CMakeLists.txt | 1 + .../client/bin/tmss_create_lofar2_sibling | 23 +++++++++++++++++++ SAS/TMSS/client/lib/mains.py | 15 ++++++++++++ 3 files changed, 39 insertions(+) create mode 100755 SAS/TMSS/client/bin/tmss_create_lofar2_sibling diff --git a/SAS/TMSS/client/bin/CMakeLists.txt b/SAS/TMSS/client/bin/CMakeLists.txt index 64d7017bd77..ad1a2d0a733 100644 --- a/SAS/TMSS/client/bin/CMakeLists.txt +++ b/SAS/TMSS/client/bin/CMakeLists.txt @@ -20,3 +20,4 @@ lofar_add_bin_scripts(tmss_schedule_scheduling_unit_at_given_starttime) lofar_add_bin_scripts(tmss_unschedule_scheduling_unit) lofar_add_bin_scripts(tmss_create_and_process_feedback_for_subtask_from_specification_and_set_to_finished) lofar_add_bin_scripts(tmss_reset_schedule) +lofar_add_bin_scripts(tmss_create_lofar2_sibling) diff --git a/SAS/TMSS/client/bin/tmss_create_lofar2_sibling b/SAS/TMSS/client/bin/tmss_create_lofar2_sibling new file mode 100755 index 00000000000..78ed13ba3e7 --- /dev/null +++ b/SAS/TMSS/client/bin/tmss_create_lofar2_sibling @@ -0,0 +1,23 @@ +#!/usr/bin/python3 + +# Copyright (C) 2012-2015 ASTRON (Netherlands Institute for Radio Astronomy) +# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This file is part of the LOFAR software suite. +# The LOFAR software suite is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# The LOFAR software suite is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. + +from lofar.sas.tmss.client.mains import main_create_lofar2_sibling_scheduling_unit + +if __name__ == "__main__": + main_create_lofar2_sibling_scheduling_unit() diff --git a/SAS/TMSS/client/lib/mains.py b/SAS/TMSS/client/lib/mains.py index ea67160fdfb..e085cdf6edd 100644 --- a/SAS/TMSS/client/lib/mains.py +++ b/SAS/TMSS/client/lib/mains.py @@ -403,3 +403,18 @@ def main_reset_schedule(): exit(1) +def main_create_lofar2_sibling_scheduling_unit(): + parser = argparse.ArgumentParser() + parser.add_argument("scheduling_unit_blueprint_id", type=int, help="The ID of the TMSS scheduling_unit_blueprint for which we want to create a Lofar2 sibling.") + parser.add_argument('-R', '--rest_api_credentials', type=str, default='TMSSClient', help='TMSS django REST API credentials name, default: TMSSClient') + parser.add_argument('-r', '--retry_count', type=int, default=DEFAULT_CLIENT_RETRY_COUNT, help='Retry <retry_count> times upon (recoverable) failure, default: [%default]') + args = parser.parse_args() + + try: + with TMSSsession.create_from_dbcreds_for_ldap(dbcreds_name=args.rest_api_credentials) as session: + pprint(session.create_lofar2_sibling_scheduling_unit(args.scheduling_unit_blueprint_id, retry_count=args.retry_count)) + except Exception as e: + print(e) + exit(1) + + -- GitLab