Ejemplo n.º 1
0
    def _clean_dir(self):
        """
        Image removal specific cleaning function,
        to relink the "latest" image version
        if the removed directory was the previous "latest" version.
        """
        super()._clean_dir()

        link_latest_image(os.path.join(BASE_IMAGE_DIR,
                                       self.config["image"]["name"]))
Ejemplo n.º 2
0
    def _link_latest_image(self):
        """
        Link the latest version of the image to ``/latest``
        """
        image_name_dir = os.path.join(BASE_IMAGE_DIR, self.name)
        latest_image = os.path.join(image_name_dir, "latest")

        if not os.path.exists(latest_image):
            # Assume this image is the latest if the latest symlink is missing
            os.symlink(self.image_path, latest_image)
            self.is_latest = True
            return

        if not os.path.islink(latest_image):
            # This isn't technically fatal, but should raise a warning
            logger.warning(
                "Latest image is not a symlink, not trying to link")
            return

        self.is_latest = link_latest_image(image_name_dir)