def _list_running_instances(self, context, all_instances):
        """List running instances (on all compute nodes).

        This method returns a dictionary with the following keys:
            - used_images
            - image_popularity
            - instance_names
        """
        used_images = {}
        image_popularity = {}
        instance_names = set()
        used_swap_images = set()
        instance_bdms = objects.BlockDeviceMappingList.bdms_by_instance_uuid(
            context, [instance.uuid for instance in all_instances])

        for instance in all_instances:
            # NOTE(mikal): "instance name" here means "the name of a directory
            # which might contain an instance" and therefore needs to include
            # historical permutations as well as the current one.
            instance_names.add(instance.name)
            instance_names.add(instance.uuid)
            if (self.resize_states in instance.task_state or
                    instance.vm_state == vm_states.RESIZED):
                instance_names.add(instance.name + '_resize')
                instance_names.add(instance.uuid + '_resize')

            for image_key in ['image_ref', 'kernel_id', 'ramdisk_id']:
                image_ref_str = getattr(instance, image_key)
                if image_ref_str is None:
                    continue
                local, remote, insts = used_images.get(image_ref_str,
                                                            (0, 0, []))
                if instance.host == CONF.host:
                    local += 1
                else:
                    remote += 1
                insts.append(instance.name)
                used_images[image_ref_str] = (local, remote, insts)

                image_popularity.setdefault(image_ref_str, 0)
                image_popularity[image_ref_str] += 1

            bdms = instance_bdms.get(instance.uuid)
            if bdms:
                swap = driver_block_device.convert_swap(bdms)
                if swap:
                    swap_image = 'swap_' + str(swap[0]['swap_size'])
                    used_swap_images.add(swap_image)

        return {'used_images': used_images,
                'image_popularity': image_popularity,
                'instance_names': instance_names,
                'used_swap_images': used_swap_images}
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/virt/imagecache.py/ImageCacheManager._list_running_instances/swapped operands of `in`