Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 1 | def handle(image): |
| 2 | from core.models import Controller, ControllerImages, Image |
| 3 | from collections import defaultdict |
| 4 | |
| 5 | if (image.kind == "container"): |
| 6 | # container images do not get instantiated |
| 7 | return |
| 8 | |
| 9 | controller_images = ControllerImages.objects.filter(image=image) |
| 10 | existing_controllers = [cs.controller for cs in controller_images] |
| 11 | |
| 12 | all_controllers = Controller.objects.all() |
| 13 | for controller in all_controllers: |
| 14 | if controller not in existing_controllers: |
| 15 | sd = ControllerImages(image=image, controller=controller) |
| 16 | sd.save() |
| 17 | |