Example #1
0
    def queue_prefetch(self, image_meta):
        """This adds a image to be prefetched to the queue directory.

        If the image already exists in the queue directory or the
        prefetching directory, we ignore it.
        """
        image_id = image_meta['id']

        if self.hit(image_id):
            msg = "Skipping prefetch, image '%s' already cached" % image_id
            logger.warn(msg)
            raise exception.Invalid(msg)

        if self.is_image_currently_prefetching(image_id):
            msg = "Skipping prefetch, already prefetching image '%s'"\
                  % image_id
            logger.warn(msg)
            raise exception.Invalid(msg)

        if self.is_image_queued_for_prefetch(image_id):
            msg = "Skipping prefetch, image '%s' already queued for"\
                  " prefetching" % image_id
            logger.warn(msg)
            raise exception.Invalid(msg)

        prefetch_path = os.path.join(self.prefetch_path, str(image_id))

        # Touch the file to add it to the queue
        with open(prefetch_path, "w") as f:
            pass

        utils.set_xattr(prefetch_path, 'image_name', image_meta['name'])
Example #2
0
    def queue_prefetch(self, image_meta):
        """This adds a image to be prefetched to the queue directory.

        If the image already exists in the queue directory or the
        prefetching directory, we ignore it.
        """
        image_id = image_meta['id']

        if self.hit(image_id):
            msg = _("Skipping prefetch, image '%s' already cached") % image_id
            logger.warn(msg)
            raise exception.Invalid(msg)

        if self.is_image_currently_prefetching(image_id):
            msg = _("Skipping prefetch, already prefetching "
                    "image '%s'") % image_id
            logger.warn(msg)
            raise exception.Invalid(msg)

        if self.is_image_queued_for_prefetch(image_id):
            msg = _("Skipping prefetch, image '%s' already queued for"
                    " prefetching") % image_id
            logger.warn(msg)
            raise exception.Invalid(msg)

        prefetch_path = os.path.join(self.prefetch_path, str(image_id))

        # Touch the file to add it to the queue
        with open(prefetch_path, "w") as f:
            pass

        utils.set_xattr(prefetch_path, 'image_name', image_meta['name'])
Example #3
0
 def set_xattr(key, value):
     utils.set_xattr(incomplete_path, key, value)
Example #4
0
 def set_xattr(key, value):
     utils.set_xattr(incomplete_path, key, value)