From b84ec35d13d2129b9c0871f3527fbe1498bbbd2b Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Tue, 23 Jan 2024 14:21:01 +0100 Subject: [PATCH] TMSS-2890: cmdline prog to call the new endpoint to remove the stations in a new copy --- SAS/TMSS/client/bin/CMakeLists.txt | 1 + ...ve_stations_from_scheduling_unit_blueprint | 23 +++++++++++++++++++ SAS/TMSS/client/lib/mains.py | 20 ++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100755 SAS/TMSS/client/bin/tmss_remove_stations_from_scheduling_unit_blueprint diff --git a/SAS/TMSS/client/bin/CMakeLists.txt b/SAS/TMSS/client/bin/CMakeLists.txt index ad1a2d0a733..fde59c564ac 100644 --- a/SAS/TMSS/client/bin/CMakeLists.txt +++ b/SAS/TMSS/client/bin/CMakeLists.txt @@ -12,6 +12,7 @@ lofar_add_bin_scripts(tmss_get_setting) lofar_add_bin_scripts(tmss_set_setting) lofar_add_bin_scripts(tmss_populate) lofar_add_bin_scripts(tmss_submit_trigger) +lofar_add_bin_scripts(tmss_remove_stations_from_scheduling_unit_blueprint) lofar_add_bin_scripts(tmss_wait_for_subtask_state) lofar_add_bin_scripts(tmss_get_subtask_l2stationspecs) lofar_add_bin_scripts(tmss_mark_scheduling_unit_dynamically_scheduled) diff --git a/SAS/TMSS/client/bin/tmss_remove_stations_from_scheduling_unit_blueprint b/SAS/TMSS/client/bin/tmss_remove_stations_from_scheduling_unit_blueprint new file mode 100755 index 00000000000..688e3c1db69 --- /dev/null +++ b/SAS/TMSS/client/bin/tmss_remove_stations_from_scheduling_unit_blueprint @@ -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_scheduling_unit_blueprint_copy_without_given_stations + +if __name__ == "__main__": + main_create_scheduling_unit_blueprint_copy_without_given_stations() diff --git a/SAS/TMSS/client/lib/mains.py b/SAS/TMSS/client/lib/mains.py index e085cdf6edd..24c2fc27d59 100644 --- a/SAS/TMSS/client/lib/mains.py +++ b/SAS/TMSS/client/lib/mains.py @@ -418,3 +418,23 @@ def main_create_lofar2_sibling_scheduling_unit(): exit(1) +def main_create_scheduling_unit_blueprint_copy_without_given_stations(): + parser = argparse.ArgumentParser() + parser.add_argument("scheduling_unit_blueprint_id", type=int, help="The ID of the TMSS scheduling_unit_blueprint from which the station(s) have to be removed.") + parser.add_argument("stations_to_be_removed", type=str, help="A comma seperated string of stations.") + 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: + stations_to_be_removed = [s.strip() for s in args.stations_to_be_removed.split(',')] + scheduling_unit_blueprint_copy = session.create_scheduling_unit_blueprint_copy_without_given_stations(args.scheduling_unit_blueprint_id, + stations_to_be_removed, + retry_count=args.retry_count) + print("Here is your new scheduling_unit without station(s)", ','.join(stations_to_be_removed), scheduling_unit_blueprint_copy['url']) + except Exception as e: + print(e) + exit(1) + + -- GitLab