implement fetch_pending()
diff --git a/planetstack/observer/steps/sync_slivers.py b/planetstack/observer/steps/sync_slivers.py
index adab39d..e119b0e 100644
--- a/planetstack/observer/steps/sync_slivers.py
+++ b/planetstack/observer/steps/sync_slivers.py
@@ -7,21 +7,25 @@
class SyncSlivers(OpenStackSyncStep):
provides=[Sliver]
requested_interval=0
+
+ def fetch_pending(self):
+ return Sliver.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
+
def sync_record(self, slice):
if not sliver.instance_id:
- nics = self.get_requested_networks(sliver.slice)
- file("/tmp/scott-manager","a").write("slice: %s\nreq: %s\n" % (str(sliver.slice.name), str(nics)))
- slice_memberships = SliceMembership.objects.filter(slice=sliver.slice)
- pubkeys = [sm.user.public_key for sm in slice_memberships if sm.user.public_key]
- pubkeys.append(sliver.creator.public_key)
- instance = self.driver.spawn_instance(name=sliver.name,
- key_name = sliver.creator.keyname,
- image_id = sliver.image.image_id,
- hostname = sliver.node.name,
- pubkeys = pubkeys,
- nics = nics )
- sliver.instance_id = instance.id
- sliver.instance_name = getattr(instance, 'OS-EXT-SRV-ATTR:instance_name')
+ nics = self.get_requested_networks(sliver.slice)
+ file("/tmp/scott-manager","a").write("slice: %s\nreq: %s\n" % (str(sliver.slice.name), str(nics)))
+ slice_memberships = SliceMembership.objects.filter(slice=sliver.slice)
+ pubkeys = [sm.user.public_key for sm in slice_memberships if sm.user.public_key]
+ pubkeys.append(sliver.creator.public_key)
+ instance = self.driver.spawn_instance(name=sliver.name,
+ key_name = sliver.creator.keyname,
+ image_id = sliver.image.image_id,
+ hostname = sliver.node.name,
+ pubkeys = pubkeys,
+ nics = nics )
+ sliver.instance_id = instance.id
+ sliver.instance_name = getattr(instance, 'OS-EXT-SRV-ATTR:instance_name')
if sliver.instance_id and ("numberCores" in sliver.changed_fields):
self.driver.update_instance_metadata(sliver.instance_id, {"cpu_cores": str(sliver.numberCores)})