make service look at slice.default_isolation
diff --git a/xos/core/models/service.py b/xos/core/models/service.py
index fe70820..c203b70 100644
--- a/xos/core/models/service.py
+++ b/xos/core/models/service.py
@@ -347,6 +347,8 @@
                      "trusty-server-multi-nic", # CloudLab
                     ]
 
+    LOOK_FOR_CONTAINER_IMAGES=["andybavier/docker-vcpe"]
+
     class Meta:
         proxy = True
 
@@ -449,20 +451,23 @@
         from core.models import Image
         # Implement the logic here to pick the image that should be used when
         # instantiating the VM that will hold the container.
-        for image_name in self.LOOK_FOR_IMAGES:
+
+        slice = self.provider_service.slices.all()
+        if not slice:
+            raise XOSProgrammingError("provider service has no slice")
+        slice = slice[0]
+
+        if slice.default_isolation in ["container", "container_vm"]:
+            look_for_images = self.LOOK_FOR_CONTAINER_IMAGES
+        else:
+            look_for_images = self.LOOK_FOR_IMAGES
+
+        for image_name in look_for_images:
             images = Image.objects.filter(name = image_name)
             if images:
                 return images[0]
 
-        raise XOSProgrammingError("No VPCE image (looked for %s)" % str(self.LOOK_FOR_IMAGES))
-
-    @property
-    def use_cobm(self):
-        return self.get_attribute("use_cobm", False)
-
-    @use_cobm.setter
-    def use_cobm(self, v):
-        self.set_attribute("use_cobm", v)
+        raise XOSProgrammingError("No VPCE image (looked for %s)" % str(self.look_for_images))
 
     @creator.setter
     def creator(self, value):
@@ -480,15 +485,16 @@
         nodes = sorted(nodes, key=lambda node: node.instances.all().count())
         return nodes[0]
 
-#    def pick_node_for_container_on_metal(self):
-#        from core.models import Node
-#        nodes = list(Node.objects.all())
-#        # TODO: logic to filter nodes by which nodes are up, and which
-#        #   nodes the slice can instantiate on.
-#        nodes = sorted(nodes, key=lambda node: node.containers.all().count())
-#        return nodes[0]
+    def save_instance(self, instance):
+        # Override this function to do custom pre-save or post-save processing,
+        # such as creating ports for containers.
+        instance.save()
 
-    def manage_container_in_instance(self):
+    def pick_vm(self):
+        # for container-in-VM, pick a VM
+        raise "Not Implemented"
+
+    def manage_container(self):
         from core.models import Instance, Flavor
 
         if self.deleted:
@@ -506,14 +512,24 @@
             if not flavors:
                 raise XOSConfigurationError("No m1.small flavor")
 
-            node =self.pick_node_for_instance()
-            instance = Instance(slice = self.provider_service.slices.all()[0],
+            node = self.pick_node_for_instance()
+            slice = self.provider_service.slices.all()[0]
+
+            if slice.default_isolation == "container_vm":
+                parent = self.pick_vm()
+            else:
+                parent = None
+
+            instance = Instance(slice = slice,
                             node = node,
                             image = self.image,
                             creator = self.creator,
                             deployment = node.site_deployment.deployment,
-                            flavor = flavors[0])
-            instance.save()
+                            flavor = flavors[0],
+                            isolation = slice.default_isolation,
+                            parent = parent)
+
+            self.save_instance(instance)
 
             try:
                 self.instance = instance
@@ -522,83 +538,11 @@
                 instance.delete()
                 raise
 
-#    def manage_container_on_metal(self):
-#        from core.models import Container, Instance, Flavor, Port
-#
-#        if self.deleted:
-#            return
-#
-#        if (self.container is not None):
-#            self.container.delete()
-#            self.container = None
-#
-#        if self.container is None:
-#            if not self.provider_service.slices.count():
-#                raise XOSConfigurationError("The VCPE service has no slices")
-#
-#            slice = self.provider_service.slices.all()[0]
-#            node = self.pick_node_for_container_on_metal()
-#
-#            # Our current docker network strategy requires that there be some
-#            # instance on the server that connects to the networks, so that
-#            # the containers can piggyback off of that configuration.
-#            instances = Instance.objects.filter(slice=slice, node=node)
-#            if not instances:
-#                flavors = Flavor.objects.filter(name="m1.small")
-#                if not flavors:
-#                    raise XOSConfigurationError("No m1.small flavor")
-#
-#                node =self.pick_node_for_instance()
-#                instance = Instance(slice = self.provider_service.slices.all()[0],
-#                                node = node,
-#                                image = self.image,
-#                                creator = self.creator,
-#                                deployment = node.site_deployment.deployment,
-#                                flavor = flavors[0])
-#                instance.save()
-#
-#            # Now make the container...
-#            container = Container(slice = slice,
-#                            node = node,
-#                            docker_image = "andybavier/docker-vcpe",
-#                            creator = self.creator,
-#                            no_sync=True)
-#            container.save()
-#
-#            # ... and add the ports for the container
-#            # XXX probably should be done in model_policy
-#            for network in slice.networks.all():
-#                if (network.name.endswith("-nat")):
-#                    continue
-#                port = Port(network = network,
-#                            container = container)
-#                port.save()
-#
-#            container.no_sync = False
-#            container.save()
-#
-#            try:
-#                self.container = container
-#                super(TenantWithContainer, self).save()
-#            except:
-#                container.delete()
-#                raise
-
-    def manage_container(self):
-#        if self.use_cobm:
-#            self.manage_container_on_metal()
-#        else:
-            self.manage_container_in_instance()
-
     def cleanup_container(self):
         if self.instance:
             # print "XXX cleanup instance", self.instance
             self.instance.delete()
             self.instance = None
-#        if self.container:
-#            # print "XXX cleanup container", self.container
-#            self.container.delete()
-#            self.container = None
 
 class CoarseTenant(Tenant):
     """ TODO: rename "CoarseTenant" --> "StaticTenant" """