diff --git a/SAS/TMSS/client/bin/CMakeLists.txt b/SAS/TMSS/client/bin/CMakeLists.txt index d2bd6170e887de5af55d2c6ec98eb1adfcf656bc..34d5fafe0d18747a3981c8e0491e1e01dc941600 100644 --- a/SAS/TMSS/client/bin/CMakeLists.txt +++ b/SAS/TMSS/client/bin/CMakeLists.txt @@ -7,3 +7,4 @@ lofar_add_bin_scripts(tmss_get_subtask_successors) lofar_add_bin_scripts(tmss_schedule_subtask) lofar_add_bin_scripts(tmss_get_setting) lofar_add_bin_scripts(tmss_set_setting) +lofar_add_bin_scripts(tmss_populate) diff --git a/SAS/TMSS/client/bin/tmss_populate b/SAS/TMSS/client/bin/tmss_populate new file mode 100755 index 0000000000000000000000000000000000000000..b0dbfbb70cec36a46a7396ba3e7cdf33d8e4f2c1 --- /dev/null +++ b/SAS/TMSS/client/bin/tmss_populate @@ -0,0 +1,25 @@ +#!/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/>. + +import logging +from lofar.sas.tmss.client.populate import populate_schemas + +if __name__ == "__main__": + logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO) + populate_schemas() diff --git a/SAS/TMSS/client/lib/CMakeLists.txt b/SAS/TMSS/client/lib/CMakeLists.txt index 94606c743637ebf74951b6d15efd87ec369737eb..2281da0ee8a6417e0bfb8969ab55e43deb93ee65 100644 --- a/SAS/TMSS/client/lib/CMakeLists.txt +++ b/SAS/TMSS/client/lib/CMakeLists.txt @@ -4,6 +4,7 @@ include(PythonInstall) set(_py_files tmssbuslistener.py mains.py + populate.py tmss_http_rest_client.py ) diff --git a/SAS/TMSS/client/lib/populate.py b/SAS/TMSS/client/lib/populate.py new file mode 100644 index 0000000000000000000000000000000000000000..d6b0d9a6622d9516ce48022d11cd2798165cd66c --- /dev/null +++ b/SAS/TMSS/client/lib/populate.py @@ -0,0 +1,31 @@ +import json +import argparse +from pprint import pprint +from lofar.sas.tmss.client.tmss_http_rest_client import TMSSsession +from lofar.common.datetimeutils import parseDatetime + + +def populate_schemas(): + parser = argparse.ArgumentParser() + args = parser.parse_args() + + try: + with TMSSsession.create_from_dbcreds_for_ldap() as session: + session.post_template(template_path='common_schema_template', + name="base", + description='email address schema', + version='1', + schema={ + "$id": "http://127.0.0.1:8000/api/schemas/common/base/1/#", + "$schema": "http://json-schema.org/draft-06/schema#", + "definitions": { + "email": { + "type": "string", + "format": "email", + "pattern": "@example\\.com$", + "default": ""} + }}) + + except Exception as e: + print(e) + exit(1)