consolidate API code for core and plus, fix access/default change in sliceplus, shore up caller arguments in update
diff --git a/planetstack/core/xoslib/objects/sliceplus.py b/planetstack/core/xoslib/objects/sliceplus.py
index 6bbbfa2..47c93d7 100644
--- a/planetstack/core/xoslib/objects/sliceplus.py
+++ b/planetstack/core/xoslib/objects/sliceplus.py
@@ -135,6 +135,9 @@
return nodeList
def save(self, *args, **kwargs):
+ if (not hasattr(self,"caller")) or self.caller==None:
+ raise APIException("no self.caller in SlicePlus.save")
+
updated_image = self.has_field_changed("default_image")
updated_flavor = self.has_field_changed("default_flavor")
@@ -210,6 +213,7 @@
flavor = self.default_flavor,
creator = self.creator,
deployment = node.site_deployment.deployment)
+ sliver.caller = self.caller
slivers.append(sliver)
if (not noAct):
print "added sliver", sliver
@@ -222,7 +226,10 @@
def save_users(self, noAct = False):
new_users = self._update_users
- default_role = SliceRole.objects.get(role="default")
+ try:
+ default_role = SliceRole.objects.get(role="access")
+ except:
+ default_role = SliceRole.objects.get(role="default")
slice_privs = self.sliceprivileges.all()
slice_user_ids = [priv.user.id for priv in slice_privs]
@@ -230,6 +237,7 @@
for user_id in new_users:
if (user_id not in slice_user_ids):
priv = SlicePrivilege(slice=self, user=User.objects.get(id=user_id), role=default_role)
+ priv.caller = self.caller
if (not noAct):
priv.save()
@@ -256,6 +264,7 @@
continue
if network.ports:
network.ports = self._network_ports
+ network.caller = self.caller
if (not noAct):
network.save()
return
@@ -268,6 +277,7 @@
continue
if network.template.translation=="NAT":
network.ports = self._network_ports
+ network.caller = self.caller
if (not noAct):
network.save()
return