From 05c12da33c030cda9aa55ac02b5c016084f49987 Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Wed, 28 Sep 2016 06:53:10 +0000
Subject: [PATCH] Task #9607: handle obsolete status

---
 SAS/OTDB_Services/OTDBBusListener.py                       | 5 +++++
 .../OTDBtoRATaskStatusPropagator/propagator.py             | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/SAS/OTDB_Services/OTDBBusListener.py b/SAS/OTDB_Services/OTDBBusListener.py
index d699cf878a5..65b740a38e4 100644
--- a/SAS/OTDB_Services/OTDBBusListener.py
+++ b/SAS/OTDB_Services/OTDBBusListener.py
@@ -93,6 +93,8 @@ class OTDBBusListener(AbstractBusListener):
             self.onObservationFinished(treeId, modificationTime)
         elif msg.content['state'] == 'aborted':
             self.onObservationAborted(treeId, modificationTime)
+        elif msg.content['state'] == 'obsolete':
+            self.onObservationObsolete(treeId, modificationTime)
 
     def onObservationDescribed(self, treeId, modificationTime):
         pass
@@ -130,4 +132,7 @@ class OTDBBusListener(AbstractBusListener):
     def onObservationAborted(self, treeId, modificationTime):
         pass
 
+    def onObservationObsolete(self, treeId, modificationTime):
+        pass
+
 __all__ = ["OTDBBusListener"]
diff --git a/SAS/ResourceAssignment/OTDBtoRATaskStatusPropagator/propagator.py b/SAS/ResourceAssignment/OTDBtoRATaskStatusPropagator/propagator.py
index eb8ce5cce69..3b14e604617 100644
--- a/SAS/ResourceAssignment/OTDBtoRATaskStatusPropagator/propagator.py
+++ b/SAS/ResourceAssignment/OTDBtoRATaskStatusPropagator/propagator.py
@@ -47,8 +47,8 @@ class OTDBtoRATaskStatusPropagator(OTDBBusListener):
 
     def _update_radb_task_status(self, otdb_id, task_status):
         try:
-            if task_status in ['approved', 'prescheduled']:
-                radb_task = self.radb.getTask(otdb_id=treeId)
+            if task_status in ['approved', 'prescheduled', 'obsolete']:
+                radb_task = self.radb.getTask(otdb_id=otdb_id)
                 if (radb_task and
                     radb_task['cluster'] == 'CEP4' and
                     radb_task['status'] in ['queued', 'active', 'completing']):
@@ -105,6 +105,9 @@ class OTDBtoRATaskStatusPropagator(OTDBBusListener):
     def onObservationConflict(self, treeId, modificationTime):
         self._update_radb_task_status(treeId, 'conflict')
 
+    def onObservationObsolete(self, treeId, modificationTime):
+        self._update_radb_task_status(treeId, 'obsolete')
+
     def onObservationPrescheduled(self, treeId, modificationTime):
         self._update_radb_task_status(treeId, 'prescheduled')
 
-- 
GitLab