def get_local_image_mapping(self, image_ids): base_image_map = self.get_base_image_mapping() resources = {i: base_image_map[i] for i in image_ids if i in base_image_map} missing = list(set(image_ids) - set(resources.keys())) if missing: loaded = self.manager.get_resource_manager('ami').get_resources(missing, False) resources.update({image['ImageId']: image for image in loaded}) return resources
def get_local_image_mapping(self, image_ids): base_image_map = self.get_base_image_mapping() resources = {i: base_image_map[i] for i in image_ids if i in base_image_map} missing = list(set(image_ids) - set(resources.keys())) if missing: loaded = self.manager.get_resource_manager('ami').get_resources(missing, False) resources.update({image['ImageId']: image for image in loaded}) return resources
def initialize(self, asgs): super(ImageFilter, self).initialize(asgs) image_ids = set() for cfg in self.configs.values(): image_ids.add(cfg['ImageId']) results = self.manager.get_resource_manager('ami').resources() base_image_map = {i['ImageId']: i for i in results} resources = {i: base_image_map[i] for i in image_ids if i in base_image_map} missing = list(set(image_ids) - set(resources.keys())) if missing: loaded = self.manager.get_resource_manager('ami').get_resources(missing, False) resources.update({image['ImageId']: image for image in loaded}) self.images = resources