Check that the base image is available.

    Fails if the base image isn't added.
    This means the image should be added manually.
550037
def check_glance(session, image_name):
    
    gclient = glance.Client(GLANCE_VERSION, session=session,
                            region_name=os.environ['OS_REGION_NAME'])
    images = gclient.images.list()
    name_ids = [{'name': i['name'], 'id': i['id']} for i in images]
    if image_name not in list(map(itemgetter('name'), name_ids)):
        logger.error("[glance]: Image %s is missing" % image_name)
        raise Exception("Image %s is missing" % image_name)
    else:
        image = [i for i in name_ids if i['name'] == image_name]
        image_id = image[0]['id']
        logger.info("[glance]: Using image %s:%s" % (image_name, image_id))
    return image_id
1308552
def image?(new_file)
      content_type = model.content_type || new_file.content_type
      content_type.to_s.start_with? "image"
    end
37375
def on_art_image(self, *args):
        
        if self.art_image is not None:
            self.art_texture = self.art_image.texture
806883
private boolean isImagePullRequired(AbstractRemoteDockerImage image) {
        boolean isAllNamesRequired = isAllNamesRequired();
        boolean isAllTagsRequired  = isAllTagsRequired();
        boolean isAllDigestsRequired = isAllDigestsRequired();

        // All images are required ?
        boolean forcePulling = config.isForcePull();
        // We want to pull everything - so every image is required
        if (isAllNamesRequired && isAllTagsRequired && isAllDigestsRequired && forcePulling) {
            return true;
        }

        // Otherwise we check if the image data is full for specific tag(s)/sha256
        if (!isImageDataValid(image)) {
            return false;
        }

        // Data from the remote image
        List<String> imageTags = image.getImageTags();
        String imageDigest = image.getImageDigest();
        String imageName = image.getRepositoryName();

        if (imageTags == null || imageTags.isEmpty()) {
            logger.info("Image {} with Digest {} - does not have any tags and will be ignored", imageName, imageDigest);
            return false;
        }

        // Data from the config file
        List<String> configImageNames = config.getImageNames();
        List<String> configImageTags = config.getImageTags();
        List<String> configImageDigests = config.getImageDigests();

        boolean isNameMet;
        // Empty configuration = similar to using all names
        if (configImageNames == null) {
            isNameMet = true;
            logger.debug("Configuration - docker.pull.images was not found - using .*.* as default");
        }
        // 'Name' may have a regular expression match
        else {
            isNameMet = isAllNamesRequired || configImageNames.contains(imageName) || isMatchStringInList(imageName, configImageNames);
        }

        // 'Tag' may have a regular expression match
        // 'Tag' should consider pulling/ignoring images with the WS.Scanned tag - according to 'docker.pull.force' flag
        boolean isTagMet = false;
        if (configImageTags == null) {
            isTagMet = true;
            logger.debug("Configuration - docker.pull.tags was not found - using .*.* as default");
        }else {
            for(String currentTag : imageTags) {
                isTagMet = isTagMet || configImageTags.contains(currentTag) || isMatchStringInList(currentTag, configImageTags);
            }
        }

        // 'Digest' cannot have a regular expression match
        boolean isDigestMet = isAllDigestsRequired || configImageDigests.contains(imageDigest);

        // Do not pull images that are already tagged with WS.Scanned tag
        if (!forcePulling) {
            if (imageTags.contains(WS_SCANNED_TAG)) {
                logger.debug("Image {} - was scanned already", imageName);
                isTagMet = false;
            }
        }

        // Is this tag/sha256/name in the required tags/sha256/name list?
        boolean result = isNameMet && isTagMet && isDigestMet ;
        if (!result) {
            logger.debug("Image does not met the requirements: {}", image);
            logger.debug("Name met - {} , Tag met - {} , Digest met - {}", isNameMet, isTagMet, isDigestMet);
        }
        return result;
    }
772802
def _update_imageinfo(self):
        
        missing = self._missing_imageinfo()
        deferred = self.flags.get('defer_imageinfo')
        continuing = self.data.get('continue')

        if missing and not deferred and not continuing:
            self.get_imageinfo(show=False)
613981
def _prepare_base_image(self):
        
        if not self.base_image:
            return defer.succeed(True)

        if self.cheap_copy:
            clone_cmd = "qemu-img"
            clone_args = "create -b %(base)s -f qcow2 %(image)s"
        else:
            clone_cmd = "cp"
            clone_args = "%(base)s %(image)s"

        clone_args = clone_args % {
            "base": self.base_image,
            "image": self.image,
        }

        log.msg("Cloning base image: %s %s'" % (clone_cmd, clone_args))

        d = utils.getProcessValue(clone_cmd, clone_args.split())

        def _log_result(res):
            log.msg("Cloning exit code was: %d" % res)
            return res

        def _log_error(err):
            log.err("Cloning failed: %s" % err)
            return err

        d.addCallbacks(_log_result, _log_error)

        return d
459555
def image_needs_pushing(image):
    
    d = docker_client()
    try:
        d.images.get_registry_data(image)
    except docker.errors.APIError:
        # image not found on registry, needs pushing
        return True
    else:
        return False
1358063
def _resolve_base_image(self, build_json):
        """"""
        spec = build_json.get("spec")
        try:
            image_id = spec['triggeredBy'][0]['imageChangeBuild']['imageID']
        except (TypeError, KeyError, IndexError):
            # build not marked for auto-rebuilds; use regular base image
            base_image = self.workflow.builder.base_image
            self.log.info("using %s as base image.", base_image)
        else:
            # build has auto-rebuilds enabled
            self.log.info("using %s from build spec[triggeredBy] as base image.", image_id)
            base_image = ImageName.parse(image_id)  # any exceptions will propagate

        return base_image
194350
def check_animated(cls, raw_image):
        ""
        try:
            raw_image.seek(1)
        except EOFError:
            isanimated= False
        else:
            isanimated= True
            raise cls.AnimatedImageException
476142
def image_exists(self, image_name, image_tag):
        
        try:
            self.get_image(image_name, image_tag)
            return True
        except docker.errors.ImageNotFound:
            return False
892124
def has_custom_image(user_context, app_id):
  """"""
  possible_paths = _valid_custom_image_paths(user_context, app_id)
  return any(map(os.path.exists, possible_paths))
1095401
public function ModernoLoadingImageExists()
    {
        if ($image = $this->owner->ModernoLoadingImage()) {
            return ($image->exists() && file_exists($image->getFullPath()));
        }
        
        return false;
    }
237896
def is_installed(self, bug: Bug) -> bool:
        
        return self.__installation.build.is_installed(bug.image)
643326
def prev_img(self, loop=True):
        
        channel = self.get_current_channel()
        if channel is None:
            self.show_error("Please create a channel.", raisetab=True)
            return
        channel.prev_image()
        return True
576009
def is_installed(self, tool: Tool) -> bool:
        
        return self.__installation.build.is_installed(tool.image)
1124658
def set_image(self, image = None):
        
        
        if image is None or type(image) is not int:
            raise KPError("Need a new image number")
        else:
            self.image = image
            self.last_mod = datetime.now().replace(microsecond=0)
            return True
394004
def add_image(image)
      raise ArgumentError, "Invalid argument 'image'. Expected Image, got #{image.class}." unless image.is_a?(Image)
      @associated_instance_uids[image.uid] = image
      # If the ImageSeries of an added Image is not connected to this Frame yet, do so:
      add_series(image.series) unless series(image.series.uid)
    end