blob: 153b6b3a3cffd6a041a9d796c30f4566a12f991a [file] [log] [blame]
Scott Bakeraf599eb2017-03-21 12:43:26 -07001from synchronizers.new_base.modelaccessor import *
Scott Bakerb63ea792016-08-11 10:24:48 -07002
Scott Bakeraf599eb2017-03-21 12:43:26 -07003def handle(image):
Scott Bakerb63ea792016-08-11 10:24:48 -07004 if (image.kind == "container"):
5 # container images do not get instantiated
6 return
7
Scott Baker75bae452017-03-27 20:10:58 -07008 controller_images = ControllerImages.objects.filter(image_id=image.id)
Scott Bakera0a688a2017-03-28 11:59:56 -07009 existing_controllers = [cs.controller for cs in controller_images]
10 existing_controller_ids = [c.id for c in existing_controllers]
11
12 all_controllers = Controller.objects.all()
Scott Bakerb63ea792016-08-11 10:24:48 -070013 for controller in all_controllers:
Scott Bakera0a688a2017-03-28 11:59:56 -070014 if controller.id not in existing_controller_ids:
Scott Bakerb63ea792016-08-11 10:24:48 -070015 sd = ControllerImages(image=image, controller=controller)
16 sd.save()
17