FIX in manage_container() when there are different VMs exist with different images in a slice
Change-Id: I54b24a1cbda08f72adb1f57b559950f1de1a0dc5
diff --git a/xos/core/models/service.py b/xos/core/models/service.py
index d3a8f98..8ff9348 100644
--- a/xos/core/models/service.py
+++ b/xos/core/models/service.py
@@ -757,10 +757,12 @@
# such as creating ports for containers.
instance.save()
- def pick_least_loaded_instance_in_slice(self, slices):
+ def pick_least_loaded_instance_in_slice(self, slices, image):
for slice in slices:
if slice.instances.all().count() > 0:
for instance in slice.instances.all():
+ if instance.image != image:
+ continue
# Pick the first instance that has lesser than 5 tenants
if self.count_of_tenants_of_an_instance(instance) < 5:
return instance
@@ -795,7 +797,7 @@
if self.get_attribute("use_same_instance_for_multiple_tenants", default=False):
# Find if any existing instances can be used for this tenant
slices = self.provider_service.slices.all()
- instance = self.pick_least_loaded_instance_in_slice(slices)
+ instance = self.pick_least_loaded_instance_in_slice(slices, self.image)
if not instance:
slice = self.provider_service.slices.all()[0]