several bug fixes
diff --git a/planetstack/openstack/manager.py b/planetstack/openstack/manager.py
index f912270..ed2769d 100644
--- a/planetstack/openstack/manager.py
+++ b/planetstack/openstack/manager.py
@@ -253,7 +253,8 @@
def save_sliver(self, sliver):
if not sliver.instance_id:
slice_memberships = SliceMembership.objects.filter(slice=sliver.slice)
- pubkeys = [sm.user.public_key for sm in slice_memberships if sm.user.public_key != null]
+ pubkeys = [sm.user.public_key for sm in slice_memberships if sm.user.public_key != null]
+ 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,
diff --git a/planetstack/openstack/observer.py b/planetstack/openstack/observer.py
index c0291ab..872cf58 100644
--- a/planetstack/openstack/observer.py
+++ b/planetstack/openstack/observer.py
@@ -20,7 +20,7 @@
self.sync_tenants()
self.sync_users()
#self.sync_user_tenant_roles()
- #self.sync_slivers()
+ self.sync_slivers()
time.sleep(7)
except:
traceback.print_exc()
@@ -58,13 +58,16 @@
pending_sites = Site.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
for site in pending_sites:
self.manager.save_site(site)
+ site.save()
site.enacted = datetime.now()
site.save(update_fields=['enacted'])
# get all slices that need to be synced (enacted < updated or enacted is None)
pending_slices = Slice.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
for slice in pending_slices:
+ self.manager.init_caller(slice.creator, slice.creator.site.login_base)
self.manager.save_slice(slice)
+ slice.save()
slice.enacted = datetime.now()
slice.save(update_fields=['enacted'])
@@ -102,6 +105,7 @@
pending_users = User.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
for user in pending_users:
self.manager.save_user(user)
+ user.save()
user.enacted = datetime.now()
user.save(update_fields=['enacted'])
@@ -130,10 +134,11 @@
# get all users that need to be synced (enacted < updated or enacted is None)
pending_slivers = Sliver.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
for sliver in pending_slivers:
- if sliver.creator:
+ if not sliver.instance_id and sliver.creator:
# update manager context
- self.manager.init_caller(sliver.creator)
+ self.manager.init_caller(sliver.creator, sliver.slice.name)
self.manager.save_sliver(sliver)
+ sliver.save()
sliver.enacted = datetime.now()
sliver.save(update_fields=['enacted'])