From 5b7cf0415ef4106666a1ed7824e2f9f6968d03ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20K=C3=BCnsem=C3=B6ller?= <jkuensem@physik.uni-bielefeld.de> Date: Wed, 18 Jan 2017 17:50:29 +0000 Subject: [PATCH] Task #9895 - fixed cmake build of rest interface --- .gitattributes | 4 + CMake/LofarPackageList.cmake | 4 +- SAS/Specification_Services/lib/LofarBase.xsd | 49 ++++++---- .../lib/LofarHistorical.xsd | 15 +++ .../lib/LofarSpecification.xsd | 96 ++++++++++++------- .../lib/LofarTrigger.xsd | 13 ++- .../lib/specification_service.py | 9 +- .../lib/specification_service_rpc.py | 5 + SAS/Trigger_Services/CMakeLists.txt | 1 + SAS/Trigger_Services/bin/triggerrestinterface | 3 +- .../django_rest/CMakeLists.txt | 12 +++ SAS/Trigger_Services/django_rest/manage.py | 10 +- .../django_rest/restinterface/CMakeLists.txt | 16 ++++ .../django_rest/restinterface/settings.py | 3 +- .../triggerinterface/CMakeLists.txt | 13 +++ .../restinterface/triggerinterface/config.py | 8 ++ .../restinterface/triggerinterface/views.py | 19 +++- SAS/Trigger_Services/lib/CMakeLists.txt | 4 +- 18 files changed, 212 insertions(+), 72 deletions(-) create mode 100644 SAS/Trigger_Services/django_rest/CMakeLists.txt create mode 100644 SAS/Trigger_Services/django_rest/restinterface/CMakeLists.txt create mode 100644 SAS/Trigger_Services/django_rest/restinterface/triggerinterface/CMakeLists.txt create mode 100644 SAS/Trigger_Services/django_rest/restinterface/triggerinterface/config.py diff --git a/.gitattributes b/.gitattributes index a37329e50f2..24d6c3305ed 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5804,6 +5804,7 @@ SAS/Trigger_Services/__init__.py -text SAS/Trigger_Services/bin/CMakeLists.txt -text SAS/Trigger_Services/bin/triggerrestinterface -text SAS/Trigger_Services/bin/triggerservice -text +SAS/Trigger_Services/django_rest/CMakeLists.txt -text SAS/Trigger_Services/django_rest/db.sqlite3 -text SAS/Trigger_Services/django_rest/manage.py -text SAS/Trigger_Services/django_rest/restinterface/.idea/.name -text @@ -5816,12 +5817,15 @@ SAS/Trigger_Services/django_rest/restinterface/.idea/scopes/scope_settings.xml - SAS/Trigger_Services/django_rest/restinterface/.idea/triggerservice.iml -text SAS/Trigger_Services/django_rest/restinterface/.idea/vcs.xml -text SAS/Trigger_Services/django_rest/restinterface/.idea/workspace.xml -text +SAS/Trigger_Services/django_rest/restinterface/CMakeLists.txt -text SAS/Trigger_Services/django_rest/restinterface/__init__.py -text SAS/Trigger_Services/django_rest/restinterface/credentials.py -text SAS/Trigger_Services/django_rest/restinterface/settings.py -text +SAS/Trigger_Services/django_rest/restinterface/triggerinterface/CMakeLists.txt -text SAS/Trigger_Services/django_rest/restinterface/triggerinterface/__init__.py -text SAS/Trigger_Services/django_rest/restinterface/triggerinterface/admin.py -text SAS/Trigger_Services/django_rest/restinterface/triggerinterface/apps.py -text +SAS/Trigger_Services/django_rest/restinterface/triggerinterface/config.py -text SAS/Trigger_Services/django_rest/restinterface/triggerinterface/migrations/__init__.py -text SAS/Trigger_Services/django_rest/restinterface/triggerinterface/models.py -text SAS/Trigger_Services/django_rest/restinterface/triggerinterface/serializers.py -text diff --git a/CMake/LofarPackageList.cmake b/CMake/LofarPackageList.cmake index 224e4953cb1..4902023b84f 100644 --- a/CMake/LofarPackageList.cmake +++ b/CMake/LofarPackageList.cmake @@ -1,7 +1,7 @@ # - Create for each LOFAR package a variable containing the absolute path to # its source directory. # -# Generated by gen_LofarPackageList_cmake.sh at Mo 16. Jan 19:06:42 CET 2017 +# Generated by gen_LofarPackageList_cmake.sh at Mi 18. Jan 18:25:10 CET 2017 # # ---- DO NOT EDIT ---- # @@ -163,6 +163,8 @@ if(NOT DEFINED LOFAR_PACKAGE_LIST_INCLUDED) set(SystemStatusService_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SAS/ResourceAssignment/SystemStatusService) set(OTDBtoRATaskStatusPropagator_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SAS/ResourceAssignment/OTDBtoRATaskStatusPropagator) set(RAScripts_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SAS/ResourceAssignment/RAScripts) + set(restinterface_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SAS/Trigger_Services/django_rest/restinterface) + set(triggerinterface_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SAS/Trigger_Services/django_rest/restinterface/triggerinterface) set(CCU_MAC_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SubSystems/CCU_MAC) set(LCU_MAC_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SubSystems/LCU_MAC) set(MCU_MAC_SOURCE_DIR ${CMAKE_SOURCE_DIR}/SubSystems/MCU_MAC) diff --git a/SAS/Specification_Services/lib/LofarBase.xsd b/SAS/Specification_Services/lib/LofarBase.xsd index f57e33e1461..604f3479d32 100644 --- a/SAS/Specification_Services/lib/LofarBase.xsd +++ b/SAS/Specification_Services/lib/LofarBase.xsd @@ -1,7 +1,10 @@ <?xml version="1.0" encoding="utf-8" ?> -<xsd:schema targetNamespace="http://www.astron.nl/LofarBase" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.astron.nl/LofarBase"> +<xsd:schema targetNamespace="http://www.astron.nl/LofarBase" version="0.3" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.astron.nl/LofarBase"> <xsd:annotation> - <xsd:documentation>Definitions of base types for LOFAR XML objects</xsd:documentation> + <xsd:documentation>Definitions of base types for LOFAR XML objects + + Names and types match MoM3 but will need to be redesigned for MoM 4 or maybe even for Responsive Telescope. + </xsd:documentation> </xsd:annotation> <xsd:annotation> <xsd:documentation>============================LOFAR common simple types============================ @@ -13,15 +16,21 @@ <xsd:restriction base="xsd:string"> <xsd:enumeration value="MoM"/> <xsd:enumeration value="SAS"/> - <xsd:enumeration value="Temporary"/><!--Only needs to be unique within a single XML. Parser will need to assign permanent Ids--> + <xsd:enumeration value="Temporary"/><!--Only needs to be unique within a single XML. Recipient will need to assign permanent Ids--> </xsd:restriction> </xsd:simpleType> + <xsd:simpleType name="UUID"> + <xsd:restriction base="xsd:string"> + <xsd:pattern value="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"/> + </xsd:restriction> + </xsd:simpleType> <xsd:complexType name="Identifier"> <xsd:sequence> <xsd:element name="source" type="xsd:string"/> <xsd:choice> <xsd:element name="identifier" type="xsd:nonNegativeInteger"/> <xsd:element name="topology" type="xsd:string"/><!--For backward compatibility with MoM 3--> + <xsd:element name="uuid" type="UUID"/><!--For forward compatibility with MoM 4--> </xsd:choice> <xsd:element name="description" minOccurs="0" type="xsd:string"/><!-- mostly for debugging --> </xsd:sequence> @@ -42,8 +51,9 @@ <xsd:sequence> <xsd:element name="name" type="xsd:string"/> <xsd:element name="email" type="xsd:string"/> - <xsd:element name="affiliation" minOccurs="0" type="xsd:string"/> <!-- Does this need to point to an affiliation record--> - <!-- Do we need anything else like address or phone number? --> + <xsd:element name="phoneNumber" type="xsd:string"/> + <xsd:element name="affiliation" minOccurs="0" type="xsd:string"/> <!-- Does this need to point to an affiliation record? --> + <!-- Do we need anything else like address? --> </xsd:sequence> </xsd:complexType> <xsd:annotation> @@ -95,11 +105,11 @@ <xsd:element name="description" type="xsd:string"/> <xsd:element name="processingCluster" type="ProcessingCluster"/> <xsd:element name="instrument" type="Instrument"/> - <xsd:element name="defaultTemplate" type="xsd:string"/> <!-- user Strategy, to not be OTDB specific ? --> + <xsd:element name="defaultTemplate" type="xsd:string"/> <!-- use Strategy, to not be OTDB specific ? --> <xsd:element name="tbbPiggybackAllowed" type="xsd:boolean"/> <xsd:element name="aartfaacPiggybackAllowed" type="xsd:boolean"/> - <xsd:element name="correlatedData" type="xsd:boolean"/> - <xsd:element name="filteredData" type="xsd:boolean"/> + <xsd:element name="correlatedData" type="xsd:boolean"/> + <xsd:element name="filteredData" type="xsd:boolean"/> <!-- not sure what this is --> <xsd:element name="beamformedData" type="xsd:boolean"/> <xsd:element name="coherentStokesData" type="xsd:boolean"/> <xsd:element name="incoherentStokesData" type="xsd:boolean"/> @@ -111,7 +121,7 @@ <xsd:element minOccurs="0" name="coherentDedisperseChannels" type="xsd:boolean"/> <xsd:element minOccurs="0" name="tiedArrayBeams" type="ArrayBeams"/> <xsd:element minOccurs="0" name="stokes" type="Stokes"/> - <xsd:element minOccurs="0" name="bypassPff" type="xsd:boolean"/> + <xsd:element minOccurs="0" name="bypassPff" type="xsd:boolean"/> <!-- Might need to be bypassPPF --> <xsd:element name="enableSuperterp" type="xsd:boolean"/> <xsd:element name="numberOfBitsPerSample" type="xsd:nonNegativeInteger"/> </xsd:sequence> @@ -235,6 +245,10 @@ <xsd:enumeration value="LBA Sparse Odd"/> <xsd:enumeration value="LBA X"/> <xsd:enumeration value="LBA Y"/> + <xsd:enumeration value="HBA Zero Inner"/> + <xsd:enumeration value="HBA One Inner"/> + <xsd:enumeration value="HBA Dual Inner"/> + <xsd:enumeration value="HBA Joined Inner"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="Instrument"> @@ -258,7 +272,7 @@ <xsd:enumeration value="210-250 MHz"/> </xsd:restriction> </xsd:simpleType> - <xsd:complexType name="Clock"> + <xsd:complexType name="Clock"><!-- FIXME this doesn't seem correct--> <xsd:sequence> <xsd:element minOccurs="0" name="channelWidth" type="Frequency"/> <xsd:element minOccurs="0" name="samplesPerSecond" type="xsd:double"/> @@ -307,7 +321,7 @@ <xsd:element name="equinox" type="Equinox"/> <!-- xsd:element name="duration" type="xsd:duration"/> <xsd:element name="startTime" type="xsd:dateTime"/> - <xsd:element name="endTime" type="xsd:dateTime"/ --> + <xsd:element name="endTime" type="xsd:dateTime"/ for LOFAR 2.0 this might be needed again--> <!-- xsd:element name="centralFrequency" type="mom2:Frequency"/> <xsd:element name="bandWidth" type="mom2:Frequency"/ --> <xsd:element name="subbandsSpecification" type="SubbandsSpecification"/> @@ -327,11 +341,11 @@ </xsd:extension> </xsd:complexContent> </xsd:complexType> - <xsd:complexType name="SubbandsSpecification"><!-- FIXME what do we need?--> + <xsd:complexType name="SubbandsSpecification"><!-- FIXME We only use SubbandArray? --> <xsd:sequence> - <xsd:element minOccurs="0" name="bandWidth" type="Frequency"/> + <!-- xsd:element minOccurs="0" name="bandWidth" type="Frequency"/> <xsd:element minOccurs="0" name="centralFrequency" type="Frequency"/> - <xsd:element minOccurs="0" name="contiguous" type="xsd:boolean"/> + <xsd:element minOccurs="0" name="contiguous" type="xsd:boolean"/ --> <xsd:element minOccurs="0" name="subbands" type="SubbandArray"/> </xsd:sequence> </xsd:complexType><!-- xsd:complexType name="CustomSubbandsSpecification"/ --> @@ -371,8 +385,8 @@ <xsd:element minOccurs="0" name="demixingParameters" type="DemixingParameters"/> <xsd:element minOccurs="0" name="bbsParameters" type="BbsParameters"/> <xsd:element minOccurs="0" name="flaggingStrategy" type="xsd:string"/> - <!-- xsd:element minOccurs="0" name="frequencyIntegrationStep" type="xsd:nonNegativeInteger"/ --> - <!-- xsd:element minOccurs="0" name="timeIntegrationStep" type="xsd:nonNegativeInteger"/ --> + <xsd:element minOccurs="0" name="frequencyIntegrationStep" type="xsd:nonNegativeInteger"/> + <xsd:element minOccurs="0" name="timeIntegrationStep" type="xsd:nonNegativeInteger"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> @@ -407,6 +421,7 @@ <xsd:element name="name" type="xsd:string"/> <xsd:element name="description" type="xsd:string"/> <xsd:element name="processingCluster" type="ProcessingCluster"/> + <xsd:element name="defaultTemplate" type="xsd:string"/> <xsd:element minOccurs="0" name="imagerIntegrationTime" type="xsd:double"/> </xsd:sequence> </xsd:extension> @@ -451,7 +466,7 @@ <xsd:annotation> <xsd:documentation>============================System task related types============================ - This section describes ... information. + Section for system tasks, but cannot be stored in MoM easily at the moment. (Ingest could). </xsd:documentation> </xsd:annotation> <xsd:complexType name="Ingest" abstract="true"/> diff --git a/SAS/Specification_Services/lib/LofarHistorical.xsd b/SAS/Specification_Services/lib/LofarHistorical.xsd index 25e446e4f0f..4be8080abc4 100644 --- a/SAS/Specification_Services/lib/LofarHistorical.xsd +++ b/SAS/Specification_Services/lib/LofarHistorical.xsd @@ -14,6 +14,21 @@ TBD </xsd:documentation> </xsd:annotation> + <xsd:complexType name="Trigger"><!-- This is a placeholder, needs to be refactored with the LofarTrigger.xsd, only difference is the TriggerId --> + <xsd:sequence> + <xsd:element name="version" type="xsd:string"/> + <xsd:element name="name" type="xsd:string"/> + <xsd:element name="description" type="xsd:string"/> + <xsd:element name="projectReference" type="base:ProjectReference"/> + <xsd:element name="submitter" type="base:ContactInformation"/><!-- Do we want to enforce this as the authenticated user? --> + <xsd:element name="userName" type="xsd:string"/><!-- The same as the authenticated user? --> + <xsd:element name="comment" type="xsd:string" minOccurs="0"/><!--Might not be needed?--> + <xsd:element name="event" type="base:Event"/><!--Maybe there should be EventList?--> + <xsd:element name="specification" type="spec:Specification"/> + <xsd:element name="generatorVersion" type="xsd:string"/> + <xsd:element name="TriggerId" type="base:Identifier"/> + </xsd:sequence> + </xsd:complexType> <!-- UV DataProduct related declarations --> <!--xsd:element name="uvDataProduct" substitutionGroup="mom2:anyDataProduct" type="UVDataProduct"/> <xsd:complexType name="UVDataProduct"> diff --git a/SAS/Specification_Services/lib/LofarSpecification.xsd b/SAS/Specification_Services/lib/LofarSpecification.xsd index f6a30b1184b..37d4d3a0822 100644 --- a/SAS/Specification_Services/lib/LofarSpecification.xsd +++ b/SAS/Specification_Services/lib/LofarSpecification.xsd @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8" ?> -<xsd:schema targetNamespace="http://www.astron.nl/LofarSpecification" version="0.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.astron.nl/LofarSpecification" xmlns:base="http://www.astron.nl/LofarBase"> +<xsd:schema targetNamespace="http://www.astron.nl/LofarSpecification" version="0.3" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.astron.nl/LofarSpecification" xmlns:base="http://www.astron.nl/LofarBase"> <xsd:import schemaLocation="LofarBase.xsd" namespace="http://www.astron.nl/LofarBase"/> <xsd:annotation> <xsd:documentation>Definitions for LOFAR specification submission @@ -45,7 +45,7 @@ <xsd:enumeration value="LST"/> </xsd:restriction> </xsd:simpleType> - <xsd:complexType name="ActivityTimeWindowSpecification"> <!-- An activity will also have an actual (resolved/allocated) time window, this is specific to specifying it --> + <xsd:complexType name="ActivityTimeWindowSpecification"> <!-- An activity will also have an actual (resolved/allocated) time window, this is specific to specifying --> <xsd:sequence> <xsd:element name="timeFrame" default="UT"> </xsd:element> @@ -86,7 +86,7 @@ <xsd:element name="minimumConstraint" type="xsd:integer"/> <xsd:element name="maximumConstraint" minOccurs="0" type="xsd:integer"/> </xsd:sequence> - <xsd:element name="stations" type="base:Stations"/> + <xsd:element name="stations" minOccurs="0" type="base:Stations"/> </xsd:choice> </xsd:sequence> </xsd:complexType> @@ -105,24 +105,49 @@ </xsd:extension> </xsd:complexContent> </xsd:complexType> + <xsd:simpleType name="QualityOfServiceType"> + <xsd:restriction base="xsd:string"><!-- These names are not very clear to me without explanation. JDM will have a look at better names --> + <xsd:enumeration value="THROUGHPUT"/> <!-- The current and default behavior --> + <xsd:enumeration value="LATENCY"/> <!-- This job needs to be optimized for fast data delivery --> + <xsd:enumeration value="IDLE"/> <!-- Jobs that should only be ran if the telescope is idle (test jobs for example). --> + </xsd:restriction> + </xsd:simpleType> + <xsd:simpleType name="StatusType"> <!-- some of these might need to be in base: --> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="opened"/> + <xsd:enumeration value="approved"/> + <xsd:enumeration value="scheduled"/> + </xsd:restriction> + </xsd:simpleType> + <xsd:simpleType name="PriorityType"> <!-- some of these might need to be in base: --> + <xsd:restriction base="xsd:integer"> + <xsd:minInclusive value="1"/> + <xsd:maxInclusive value="16"/> + </xsd:restriction> + </xsd:simpleType> <xsd:complexType name="Activity"> <xsd:sequence> <xsd:element name="temporaryIdentifier" type="base:Identifier"/> - <xsd:choice><!--Or should we be specific to the subtypes here?--> + <xsd:choice> <xsd:element name="observation" type="Observation"/> - <xsd:element name="measurement" type="base:Measurement"/><!-- maybe explicit part of Observation but makes it hard to make Relations?--> - <!-- we want to be specific about which types can generate wich types of dataproducts/entities --> + <xsd:element name="measurement" type="base:Measurement"/><!-- Should be explicit part of Observation but makes it hard to make Relations--> <xsd:element name="pipeline" type="base:Pipeline"/> <xsd:element name="ingest" type="base:Ingest"/> <xsd:element name="cleanup" type="base:Cleanup"/> </xsd:choice> <xsd:element name="status" minOccurs="0" type="xsd:string"/><!-- default would be opened, might need to be come an enum --> + <xsd:element name="qualityOfService" type="QualityOfServiceType" default="THROUGHPUT"/><!-- qualityOfService and TriggerId might need to move to the base: classes --> + <xsd:element name="priority" type="PriorityType"/> + <xsd:element name="TriggerId" minOccurs="0" type="base:Identifier"/> </xsd:sequence> </xsd:complexType> <xsd:annotation> <xsd:documentation>============================LOFAR Specification entities============================ - TBD + Entities describe datasets not individual data products. + MoM calls this "Placeholder dataproducts" and it is implemented this way for backward compatibility with that system. + We don't need actual dataproducts here, as those don't exist yet, just a reference to the types we want to create. + It might need a bit more detail with Coherent Stokes and Incoherent Stokes, which currently is coded into the topology (!!) </xsd:documentation> </xsd:annotation> <xsd:simpleType name="DataProductType"> @@ -147,12 +172,22 @@ These relations allow more flexibility than a purely nested structure. They can show the different ways that objects are related to allow for different types of visualisation. + + We decided not to make specific [Class]Identifiers because they would still all be a base:Identifier. We need to check if + relations are pointing to the correct classes outside of the XSD validation. + + Objects that are defined in the specification XML should contain temporary Identifiers, but Relations can point to an existing Identifier + from e.g. MoM or SAS. How to check this isn't clear yet, but will need to be handled at some point. + + We want to be specific about which types of activities can generate wich types of dataproducts/entities but we can't enforce that in the XSD right now + because we can't use specific [Class]Identifiers in a meaningful way. </xsd:documentation> </xsd:annotation> - <xsd:simpleType name="ChildRelationType"> + <xsd:simpleType name="ChildRelationType"><!-- folders contain other folders or activities. Only observations contain measurements--> <xsd:restriction base="xsd:string"> - <xsd:enumeration value="folder-folder"/> <!-- should be made more specific --> + <xsd:enumeration value="folder-folder"/> <xsd:enumeration value="folder-activity"/> + <xsd:enumeration value="observation-measurement"/> </xsd:restriction> </xsd:simpleType> <xsd:complexType name="ChildRelation"> @@ -166,50 +201,52 @@ </xsd:extension> </xsd:complexContent> </xsd:complexType> - <xsd:simpleType name="SibblingRelationType"> + <xsd:simpleType name="SiblingRelationType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="group"/> - <xsd:enumeration value="calibrator"/><!-- Not correct FIXME--> + <xsd:enumeration value="slice"/><!-- can currently not be stored in MoM --> </xsd:restriction> </xsd:simpleType> - <xsd:complexType name="SibblingRelation"><!-- We need to make this smarter for other sibbling relations--> + <xsd:complexType name="SiblingRelation"><!-- We need to make this smarter for other sibbling relations--> <xsd:complexContent> <xsd:extension base="Relation"> <xsd:sequence> - <xsd:element name="sibbling" minOccurs="1" maxOccurs="unbounded" type="base:Identifier"/> + <xsd:element name="sibling" minOccurs="1" maxOccurs="unbounded" type="base:Identifier"/> <xsd:element name="type" type="SibblingRelationType"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> - <xsd:simpleType name="ProducerRelationType"> + <xsd:simpleType name="TwinRelationType"> <xsd:restriction base="xsd:string"> - <xsd:enumeration value="output"/><!-- ProducedBy, needs better name?--> + <xsd:enumeration value="predecessor-successor"/> + <xsd:enumeration value="calibrator-target"/><!-- can currently not be stored properly in MoM --> </xsd:restriction> </xsd:simpleType> - <xsd:complexType name="ProducerRelation"> + <xsd:complexType name="TwinRelation"><!-- We need to make this smarter for other sibbling relations--> <xsd:complexContent> <xsd:extension base="Relation"> <xsd:sequence> - <xsd:element name="activity" type="base:Identifier"/> - <xsd:element name="entity" type="base:Identifier"/> - <xsd:element name="type" type="ProducerRelationType"/> + <xsd:element name="first" type="base:Identifier"/> + <xsd:element name="second" type="base:Identifier"/> + <xsd:element name="type" type="TwinRelationType"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> - <xsd:simpleType name="UserRelationType"> + <xsd:simpleType name="ActivityEntityRelationType"> <xsd:restriction base="xsd:string"> - <xsd:enumeration value="input"/><!-- UsedBy, needs better name?--> + <xsd:enumeration value="user"/><!-- Entity used by activity, needs better name?--> + <xsd:enumeration value="producer"/><!-- Entity produced by activity, needs better name?--> </xsd:restriction> </xsd:simpleType> - <xsd:complexType name="UserRelation"> + <xsd:complexType name="ActivityEntityRelation"> <xsd:complexContent> <xsd:extension base="Relation"> <xsd:sequence> <xsd:element name="entity" type="base:Identifier"/> <xsd:element name="activity" type="base:Identifier"/> - <xsd:element name="type" type="UserRelationType"/> + <xsd:element name="type" type="ActivityEntityRelationType"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> @@ -223,23 +260,14 @@ contain other objects. Activities and entities should and can't be related to the project directly. </xsd:documentation> </xsd:annotation> - <xsd:simpleType name="QualityOfServiceType"> - <xsd:restriction base="xsd:string"><!-- These names are not very clear to me without explanation --> - <xsd:enumeration value="THROUGHPUT"/> <!-- The current and default behavior --> - <xsd:enumeration value="LATENCY"/> <!-- This job needs to be optimized for fast data delivery --> - <xsd:enumeration value="IDLE"/> <!-- Jobs that should only be ran if the telescope is idle (test jobs for example). --> - </xsd:restriction> - </xsd:simpleType> <xsd:complexType name="Specification"> <xsd:sequence> <xsd:element name="version" type="xsd:string"/> <xsd:element name="projectReference" type="base:ProjectReference"/> <xsd:element name="userName" type="xsd:string"/> - <xsd:element name="comment" type="xsd:string" minOccurs="0"/><!--Might not be needed?--> + <xsd:element name="comment" type="xsd:string" minOccurs="0"/><!-- Freeform field for the user, will not be machine interpreted --> <xsd:element name="generatorVersion" type="xsd:string"/> - <xsd:element name="priority" type="xsd:nonNegativeInteger"/> - <xsd:element name="qualityOfService" type="QualityOfServiceType" default="THROUGHPUT"/> - <xsd:element name="container" type="Container" maxOccurs="unbounded"/> <!-- do we want it all in one container? without maxOccurs="unbounded"--> + <xsd:element name="container" type="Container" maxOccurs="unbounded"/> <xsd:element name="activity" type="Activity" minOccurs="0" maxOccurs="unbounded"/> <xsd:element name="entity" type="Entity" minOccurs="0" maxOccurs="unbounded"/> <xsd:element name="relation" type="Relation" minOccurs="0" maxOccurs="unbounded"/> diff --git a/SAS/Specification_Services/lib/LofarTrigger.xsd b/SAS/Specification_Services/lib/LofarTrigger.xsd index 31a71e228d4..300574807cb 100644 --- a/SAS/Specification_Services/lib/LofarTrigger.xsd +++ b/SAS/Specification_Services/lib/LofarTrigger.xsd @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8" ?> -<xsd:schema targetNamespace="http://www.astron.nl/LofarTrigger" version="0.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.astron.nl/LofarTrigger" xmlns:spec="http://www.astron.nl/LofarSpecification" xmlns:base="http://www.astron.nl/LofarBase"> +<xsd:schema targetNamespace="http://www.astron.nl/LofarTrigger"version="0.3" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.astron.nl/LofarTrigger" xmlns:spec="http://www.astron.nl/LofarSpecification" xmlns:base="http://www.astron.nl/LofarBase"> <xsd:import schemaLocation="LofarSpecification.xsd" namespace="http://www.astron.nl/LofarSpecification"/> <xsd:import schemaLocation="LofarBase.xsd" namespace="http://www.astron.nl/LofarBase"/> <xsd:annotation> @@ -17,12 +17,11 @@ <xsd:element name="name" type="xsd:string"/> <xsd:element name="description" type="xsd:string"/> <xsd:element name="projectReference" type="base:ProjectReference"/> - <xsd:element name="submitter" type="base:ContactInformation"/><!-- Do we want to enforce this as the authenticated user? --> - <xsd:element name="userName" type="xsd:string"/><!-- The same as the authenticated user? --> - <xsd:element name="comment" type="xsd:string" minOccurs="0"/><!--Might not be needed?--> - <xsd:element name="qualityOfService" type="spec:QualityOfServiceType"/><!--Might not be needed?--> - <xsd:element name="event" type="base:Event" maxOccurs="unbounded"/><!--Maybe there should be EventList?--> - <xsd:element name="specification" type="spec:Specification"/> + <xsd:element name="contactInformation" type="base:ContactInformation"/><!-- Does not need to be the authenticated user --> + <xsd:element name="userName" type="xsd:string"/><!-- The same as the authenticated user --> + <xsd:element name="comment" type="xsd:string" minOccurs="0"/><!-- Freeform field for the user, will not be machine interpreted --> + <xsd:element name="event" ref="base:Event"/><!--We only support one event, in the case of multiple events, the trigger was generated by a meta event caused by the other events.--> + <xsd:element name="specification" ref="spec:Specification"/> <xsd:element name="generatorVersion" type="xsd:string"/> </xsd:sequence> </xsd:complexType> diff --git a/SAS/Specification_Services/lib/specification_service.py b/SAS/Specification_Services/lib/specification_service.py index 660f6a5890a..0db2ee78f95 100644 --- a/SAS/Specification_Services/lib/specification_service.py +++ b/SAS/Specification_Services/lib/specification_service.py @@ -21,7 +21,7 @@ # with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -XMLPATH_TRIGGER="../test/trigger.xml" +#XMLPATH_TRIGGER="../test/trigger.xml" from lxml import etree from StringIO import StringIO @@ -106,12 +106,13 @@ class SpecificationHandler(MessageHandlerInterface): return id - def get_specification(self, id): + def get_specification(self, user, id): logger.info("getting spec of id "+str(id)) # todo: return real trigger info as xml # for testing: - with open(XMLPATH_TRIGGER) as xml: - return xml.read() +# with open(XMLPATH_TRIGGER) as xml: +# return xml.read() + return "This functionality is not implemented yet, sorry!" def create_service(servicename=SPECIFICATION_SERVICENAME, busname=SPECIFICATION_BUSNAME): diff --git a/SAS/Specification_Services/lib/specification_service_rpc.py b/SAS/Specification_Services/lib/specification_service_rpc.py index ffffd259de1..b632bd02bf9 100644 --- a/SAS/Specification_Services/lib/specification_service_rpc.py +++ b/SAS/Specification_Services/lib/specification_service_rpc.py @@ -21,3 +21,8 @@ class SpecificationRPC(RPCWrapper): return result + def get_specification(self, user, id): + logger.info("Requesting specification XML for user, id -> "+user+","+id) + result = self.rpc('get_specification', user, id=id) + logger.info("Received specification XML -> " +str(result)) + return result \ No newline at end of file diff --git a/SAS/Trigger_Services/CMakeLists.txt b/SAS/Trigger_Services/CMakeLists.txt index ec8a8566b00..d903ea2745b 100644 --- a/SAS/Trigger_Services/CMakeLists.txt +++ b/SAS/Trigger_Services/CMakeLists.txt @@ -7,3 +7,4 @@ include(PythonInstall) add_subdirectory(lib) add_subdirectory(bin) add_subdirectory(test) +add_subdirectory(django_rest) diff --git a/SAS/Trigger_Services/bin/triggerrestinterface b/SAS/Trigger_Services/bin/triggerrestinterface index f24434e3e3b..0bbaccbe037 100755 --- a/SAS/Trigger_Services/bin/triggerrestinterface +++ b/SAS/Trigger_Services/bin/triggerrestinterface @@ -23,7 +23,8 @@ echo "---" echo "! This is for testing only, properly deploy in Apache for production use!" echo "---" -python ../django_rest/manage.py runserver +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +python $DIR/../lib/python2.7/site-packages/lofar/triggerservices/manage.py runserver diff --git a/SAS/Trigger_Services/django_rest/CMakeLists.txt b/SAS/Trigger_Services/django_rest/CMakeLists.txt new file mode 100644 index 00000000000..40a8561bb9b --- /dev/null +++ b/SAS/Trigger_Services/django_rest/CMakeLists.txt @@ -0,0 +1,12 @@ +lofar_find_package(Python 2.7 REQUIRED) +include(PythonInstall) + +set(_py_files + manage.py + urls.py + ) + +python_install(${_py_files} + DESTINATION lofar/triggerservices/) + +lofar_add_package(restinterface) \ No newline at end of file diff --git a/SAS/Trigger_Services/django_rest/manage.py b/SAS/Trigger_Services/django_rest/manage.py index db7262f3817..334cb48af14 100755 --- a/SAS/Trigger_Services/django_rest/manage.py +++ b/SAS/Trigger_Services/django_rest/manage.py @@ -2,7 +2,9 @@ import os import sys -if __name__ == "__main__": + + +def main(argv): os.environ.setdefault("DJANGO_SETTINGS_MODULE", "restinterface.settings") try: from django.core.management import execute_from_command_line @@ -19,4 +21,8 @@ if __name__ == "__main__": "forget to activate a virtual environment?" ) raise - execute_from_command_line(sys.argv) + execute_from_command_line(argv) + + +if __name__ == "__main__": + main(sys.argv) \ No newline at end of file diff --git a/SAS/Trigger_Services/django_rest/restinterface/CMakeLists.txt b/SAS/Trigger_Services/django_rest/restinterface/CMakeLists.txt new file mode 100644 index 00000000000..38ca0a32d77 --- /dev/null +++ b/SAS/Trigger_Services/django_rest/restinterface/CMakeLists.txt @@ -0,0 +1,16 @@ +lofar_find_package(Python 2.7 REQUIRED) +include(PythonInstall) + +set(_py_files + __init__.py + credentials.py + settings.py + urls.py + wsgi.py + ) + +python_install(${_py_files} + DESTINATION lofar/triggerservices/restinterface/) + + +lofar_add_package(triggerinterface) \ No newline at end of file diff --git a/SAS/Trigger_Services/django_rest/restinterface/settings.py b/SAS/Trigger_Services/django_rest/restinterface/settings.py index 8d4545d5ed5..ba983c0af9e 100644 --- a/SAS/Trigger_Services/django_rest/restinterface/settings.py +++ b/SAS/Trigger_Services/django_rest/restinterface/settings.py @@ -125,7 +125,8 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.10/howto/static-files/ -STATIC_URL = BASE_DIR+'/static/' +STATIC_URL = '/static/' +STATIC_ROOT = BASE_DIR+'/static/' REST_FRAMEWORK = { diff --git a/SAS/Trigger_Services/django_rest/restinterface/triggerinterface/CMakeLists.txt b/SAS/Trigger_Services/django_rest/restinterface/triggerinterface/CMakeLists.txt new file mode 100644 index 00000000000..11e603f2d2f --- /dev/null +++ b/SAS/Trigger_Services/django_rest/restinterface/triggerinterface/CMakeLists.txt @@ -0,0 +1,13 @@ +lofar_find_package(Python 2.7 REQUIRED) +include(PythonInstall) + +set(_py_files + __init__.py + config.py + admin.py + apps.py + views.py + ) + +python_install(${_py_files} + DESTINATION lofar/triggerservices/restinterface/triggerinterface) \ No newline at end of file diff --git a/SAS/Trigger_Services/django_rest/restinterface/triggerinterface/config.py b/SAS/Trigger_Services/django_rest/restinterface/triggerinterface/config.py new file mode 100644 index 00000000000..071bba080a2 --- /dev/null +++ b/SAS/Trigger_Services/django_rest/restinterface/triggerinterface/config.py @@ -0,0 +1,8 @@ + +""" Config file for trigger rest interface """ + +# Messaging + + +DEFAULT_TRIGGER_SUBMISSION_NOTIFICATION_BUSNAME='lofar.ts.notification' +DEFAULT_TRIGGER_SUBMISSION_NOTIFICATION_SUBJECT='TS.TriggerSubmitted' \ No newline at end of file diff --git a/SAS/Trigger_Services/django_rest/restinterface/triggerinterface/views.py b/SAS/Trigger_Services/django_rest/restinterface/triggerinterface/views.py index fec0448679c..ad2fc98c8c1 100644 --- a/SAS/Trigger_Services/django_rest/restinterface/triggerinterface/views.py +++ b/SAS/Trigger_Services/django_rest/restinterface/triggerinterface/views.py @@ -21,12 +21,18 @@ from StringIO import StringIO from lofar.triggerservices.trigger_service_rpc import TriggerRPC from lofar.specificationservices.specification_service_rpc import SpecificationRPC +from lofar.messaging import ToBus, EventMessage + import logging import traceback logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) triggerrpc = TriggerRPC() +specrpc = SpecificationRPC() + +from config import DEFAULT_TRIGGER_SUBMISSION_NOTIFICATION_BUSNAME, DEFAULT_TRIGGER_SUBMISSION_NOTIFICATION_SUBJECT +notification_bus = ToBus(address=DEFAULT_TRIGGER_SUBMISSION_NOTIFICATION_BUSNAME, broker=None) class TriggerListView(views.APIView): @@ -80,6 +86,11 @@ class TriggerListView(views.APIView): def _handle_trigger(self, user, xml): return triggerrpc.handle_trigger(user, xml) + def _sendNotification(self, user, IP): + msg = EventMessage(context=DEFAULT_TRIGGER_SUBMISSION_NOTIFICATION_SUBJECT, content="Trigger received by "+str(user)+" (IP:"+IP+")") + notification_bus.send(msg) + + class TriggerView(views.APIView): @@ -93,10 +104,10 @@ class TriggerView(views.APIView): try: if 'pk' in kwargs: identifier = kwargs.get('pk') - logger.info('requested id is: '+str(id)) + logger.info('requested id is: '+str(identifier)) logger.info('requesting user is:'+ str(request.user)) - xml = self._get_specification(identifier) + xml = self._get_specification(str(request.user), str(identifier)) # EITHER DIRECT RESPONSE: return Response(xml) @@ -122,11 +133,11 @@ class TriggerView(views.APIView): return Response("Unable to retrieve the requested trigger, sorry!", status=status.HTTP_404_NOT_FOUND) - def _get_specification(self, identifier): + def _get_specification(self, user, identifier): logger.info("Getting spec from specification service") - response = SpecificationRPC.get_specification(identifier) + response = specrpc.get_specification(user, identifier) return response # test json data: diff --git a/SAS/Trigger_Services/lib/CMakeLists.txt b/SAS/Trigger_Services/lib/CMakeLists.txt index 5ff5fef8c95..87745ebc0cc 100644 --- a/SAS/Trigger_Services/lib/CMakeLists.txt +++ b/SAS/Trigger_Services/lib/CMakeLists.txt @@ -8,4 +8,6 @@ set(_py_files ) python_install(${_py_files} - DESTINATION lofar/triggerservices) \ No newline at end of file + DESTINATION lofar/triggerservices) + + -- GitLab