Skip to content
Snippets Groups Projects
Commit a1dfdc0b authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-272: added script for populating schemas

parent 2003c8e3
No related branches found
No related tags found
1 merge request!213Resolve TMSS-272
...@@ -7,3 +7,4 @@ lofar_add_bin_scripts(tmss_get_subtask_successors) ...@@ -7,3 +7,4 @@ lofar_add_bin_scripts(tmss_get_subtask_successors)
lofar_add_bin_scripts(tmss_schedule_subtask) lofar_add_bin_scripts(tmss_schedule_subtask)
lofar_add_bin_scripts(tmss_get_setting) lofar_add_bin_scripts(tmss_get_setting)
lofar_add_bin_scripts(tmss_set_setting) lofar_add_bin_scripts(tmss_set_setting)
lofar_add_bin_scripts(tmss_populate)
#!/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()
...@@ -4,6 +4,7 @@ include(PythonInstall) ...@@ -4,6 +4,7 @@ include(PythonInstall)
set(_py_files set(_py_files
tmssbuslistener.py tmssbuslistener.py
mains.py mains.py
populate.py
tmss_http_rest_client.py tmss_http_rest_client.py
) )
......
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment