Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
[plstackapi.git] / planetstack / core / xoslib / objects / sliceplus.py
index d3e618d..6bbbfa2 100644 (file)
@@ -1,6 +1,7 @@
 from core.models import Slice, SlicePrivilege, SliceRole, Sliver, Site, Node, User
 from plus import PlusObjectMixin
 from operator import itemgetter, attrgetter
+from rest_framework.exceptions import APIException
 
 class SlicePlus(Slice, PlusObjectMixin):
     class Meta:
@@ -30,9 +31,9 @@ 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);
+                sshCommand = sliver.get_ssh_command()
+                if sshCommand:
+                    sshCommands.append(sshCommand)
 
                     ready_sites[site.name] = ready_sites.get(site.name, 0) + 1
 
@@ -195,7 +196,7 @@ class SlicePlus(Slice, PlusObjectMixin):
                 nodes = self.get_node_allocation([site])
 
                 if (not nodes):
-                    raise ValueError("no nodes in site %s" % site_name)
+                    raise APIException(detail="no nodes in site %s" % site_name)
 
                 while (len(slivers) < desired_allocation):
                     # pick the least allocated node
@@ -273,7 +274,7 @@ class SlicePlus(Slice, PlusObjectMixin):
 
         # uh oh, we didn't find a network
 
-        raise ValueError("No network was found that ports could be set on")
+        raise APIException(detail="No network was found that ports could be set on")