Skip to content
Snippets Groups Projects
Commit 00cf7c9a authored by Jörn Künsemöller's avatar Jörn Künsemöller
Browse files

Task #10701 - processed review

parent 66bb5416
No related branches found
No related tags found
No related merge requests found
......@@ -5343,12 +5343,12 @@ SAS/TriggerServices/lib/trigger_service.py -text
SAS/TriggerServices/lib/trigger_service_rpc.py -text
SAS/TriggerServices/test/CMakeLists.txt -text
SAS/TriggerServices/test/setup_queues_and_services.sh -text
SAS/TriggerServices/test/t_trigger_service.in/trigger_misc_testing_nov2016.xml -text
SAS/TriggerServices/test/t_trigger_service.in/trigger_testing_20_03_17.xml -text
SAS/TriggerServices/test/t_trigger_service.py -text
SAS/TriggerServices/test/t_trigger_service.run -text
SAS/TriggerServices/test/t_trigger_service.sh -text
SAS/TriggerServices/test/trigger-testing.xml -text
SAS/TriggerServices/test/trigger_misc_testing_nov2016.xml -text
SAS/TriggerServices/test/trigger_testing_20_03_17.xml -text
SAS/XML_generator/CMakeLists.txt -text
SAS/XML_generator/src/CMakeLists.txt -text
SAS/XML_generator/src/xmlgen -text
......
lofar_find_package(Python 2.7 REQUIRED)
lofar_package(TriggerServices 0.1 DEPENDS PyMessaging MoMQueryService)
lofar_package(TriggerServices 0.1 DEPENDS PyMessaging MoMQueryService SpecificationServices)
include(PythonInstall)
......
......@@ -62,20 +62,11 @@ def _validate_trigger(trigger_xml):
logger.error(msg)
raise Exception(msg+" -> " + response["error"])
# def _validate_lofarspec(lofar_xml):
# response = validationrpc.validate_specification(lofar_xml)
# if not response["valid"]:
# msg = "Translation to Lofar specification failed!"
# logger.error(msg)
# raise Exception(msg+" -> " + response["error"])
def _add_trigger(username, hostname, projectname, metadata):
logger.info("Adding trigger")
response = momqueryrpc.add_trigger(username,hostname ,projectname,metadata)
#trigger_id = response.get('trigger_id')
trigger_id = response['row_id'] # no dict?
#trigger_id = '42'
_send_notification(username, trigger_id)
trigger_id = response['row_id']
_send_notification(username, hostname, projectname, trigger_id, metadata)
return trigger_id
def _get_project_priority(project):
......@@ -94,12 +85,17 @@ def _translate_trigger_to_specification(trigger_xml, trigger_id, job_priority):
logger.info("translating trigger to spec")
response = translationrpc.trigger_to_specification(trigger_xml, trigger_id, job_priority)
spec = response.get("specification")
#_validate_lofarspec(spec) # translation service return valid specs only, so not needed
return spec
def _send_notification(user, trigger_id):
def _send_notification(user, host, project, trigger_id, metadata):
try:
msg = EventMessage(context=TRIGGER_ADDITION_NOTIFICATION_SUBJECT, content="Trigger from "+str(user)+" was added under ID "+str(trigger_id))
content={ "user": user,
"host": host,
"project": project,
"trigger_id": trigger_id,
"metadata": metadata
}
msg = EventMessage(context=content)
notification_bus.send(msg)
except Exception as err:
logger.error("Could not send notification ->" + str(err))
......
......@@ -4,5 +4,3 @@ include(FindPythonModule)
find_python_module(mock REQUIRED)
lofar_add_test(t_trigger_service)
lofar_add_data_files(trigger_testing_20_03_17.xml)
\ No newline at end of file
......@@ -29,7 +29,7 @@ from lofar.specificationservices.translation_service import SpecificationTransla
from mock import mock
TRIGGER_PATH = '/share/trigger_testing_20_03_17.xml'
TRIGGER_PATH = 't_trigger_service.in/trigger_testing_20_03_17.xml'
TEST_USER = 'test'
TEST_HOST = 'localhost'
TEST_PROJECT = 'myproject'
......@@ -40,7 +40,7 @@ class TestTriggerHandler(unittest.TestCase):
def setUpClass(cls):
p = os.getenv('LOFARROOT')
with open(p+TRIGGER_PATH) as f:
with open(TRIGGER_PATH) as f:
cls.trigger_xml = f.read()
with mock.patch('lofar.triggerservices.trigger_service.notification_bus'):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment