Provide default implementation of fetch_pending to remove redundant code
authorSapan Bhatia <gwsapan@gmail.com>
Wed, 23 Jul 2014 12:59:30 +0000 (08:59 -0400)
committerSapan Bhatia <gwsapan@gmail.com>
Wed, 23 Jul 2014 12:59:30 +0000 (08:59 -0400)
from steps.

planetstack/openstack_observer/syncstep.py

index fc0cb0b..dcfea7d 100644 (file)
@@ -44,7 +44,16 @@ class SyncStep:
         return
 
     def fetch_pending(self, deletion=False):
-        return []
+        # This is the most common implementation of fetch_pending
+        # Steps should override it if they have their own logic
+        # for figuring out what objects are outstanding.
+        main_obj = self.provides[0]
+        if (not deleted):
+            objs = main_obj.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
+        else:
+            objs = main_obj.deleted_objects.all()
+
+        return objs
         #return Sliver.objects.filter(ip=None)
     
     def check_dependencies(self, obj, failed):