deferred sync for compute instances
diff --git a/xos/tosca/engine.py b/xos/tosca/engine.py
index b70bd94..fc1f10f 100644
--- a/xos/tosca/engine.py
+++ b/xos/tosca/engine.py
@@ -40,6 +40,8 @@
self.compute_dependencies()
+ self.deferred_sync = []
+
self.ordered_nodetemplates = []
self.ordered_names = self.topsort_dependencies()
print "ordered_names", self.ordered_names
@@ -133,12 +135,18 @@
for nodetemplate in self.ordered_nodetemplates:
self.execute_nodetemplate(user, nodetemplate)
+ for obj in self.deferred_sync:
+ self.log("Saving deferred sync obj %s" % obj)
+ obj.no_sync = False
+ obj.save()
+
def execute_nodetemplate(self, user, nodetemplate):
if nodetemplate.type in resources.resources:
cls = resources.resources[nodetemplate.type]
#print "work on", cls.__name__, nodetemplate.name
obj = cls(user, nodetemplate, self)
obj.create_or_update()
+ self.deferred_sync = self.deferred_sync + obj.deferred_sync
def destroy(self, user):
nodetemplates = self.ordered_nodetemplates
diff --git a/xos/tosca/resources/compute.py b/xos/tosca/resources/compute.py
index 1555d0d..c6574ba 100644
--- a/xos/tosca/resources/compute.py
+++ b/xos/tosca/resources/compute.py
@@ -83,8 +83,11 @@
xos_args = self.get_xos_args(name=name, index=index)
sliver = Sliver(**xos_args)
sliver.caller = self.user
+ sliver.no_sync = True
sliver.save()
+ self.deferred_sync.append(sliver)
+
self.info("Created Sliver '%s' on node '%s' using flavor '%s' and image '%s'" %
(str(sliver), str(sliver.node), str(sliver.flavor), str(sliver.image)))
diff --git a/xos/tosca/resources/xosresource.py b/xos/tosca/resources/xosresource.py
index 11a4958..9cd9a31 100644
--- a/xos/tosca/resources/xosresource.py
+++ b/xos/tosca/resources/xosresource.py
@@ -9,6 +9,7 @@
def __init__(self, user, nodetemplate, engine):
self.dirty = False
+ self.deferred_sync = []
self.user = user
self.nodetemplate = nodetemplate
self.engine = engine