SSH commands dialog
[plstackapi.git] / planetstack / core / xoslib / objects / sliceplus.py
index cd86fce..9187bff 100644 (file)
@@ -19,6 +19,7 @@ class SlicePlus(Slice, PlusObjectMixin):
             used_sites = {}
             used_deployments = {}
             sliverCount = 0
+            sshCommands = []
             for sliver in self.slivers.all():
                 site = sliver.node.site_deployment.site
                 deployment = sliver.node.site_deployment.deployment
@@ -26,6 +27,10 @@ class SlicePlus(Slice, PlusObjectMixin):
                 used_deployments[deployment.name] = used_deployments.get(deployment.name, 0) + 1
                 sliverCount = sliverCount + 1
 
+                if (sliver.instance_id and sliver.instance_name):
+                    sshCommand = 'ssh -o "ProxyCommand ssh -q %s@%s" ubuntu@%s' % (sliver.instance_id, sliver.node.name, sliver.instance_name)
+                    sshCommands.append(sshCommand);
+
             users = {}
             for priv in SlicePrivilege.objects.filter(slice=self):
                 if not (priv.user.id in users.keys()):
@@ -37,7 +42,8 @@ class SlicePlus(Slice, PlusObjectMixin):
                     "sliverCount": sliverCount,
                     "siteCount": len(used_sites.keys()),
                     "users": users,
-                    "roles": []}
+                    "roles": [],
+                    "sshCommands": sshCommands}
 
         if user:
             auser = self._sliceInfo["users"].get(user.id, None)
@@ -131,6 +137,11 @@ class SlicePlus(Slice, PlusObjectMixin):
     def save_site_allocation(self, noAct = False, reset=False):
         print "save_site_allocation, reset=",reset
 
+        if (not self._site_allocation):
+            # Must be a sliver that was just created, and has not site_allocation
+            # field.
+            return
+
         all_slice_slivers = self.slivers.all()
         for site_name in self._site_allocation.keys():
             desired_allocation = self._site_allocation[site_name]