Ejemplo n.º 1
0
    def get_by_name(ce: CEClient, image_name: str):
        """Returns an image by its name."""
        res = ce.list_images(image_name)
        if not res:
            return None

        return Image(res[0])
Ejemplo n.º 2
0
    def get_by_url(ce: CEClient, image_url: str):
        image_url = ImageUrl(image_url)
        if image_url.is_family:
            image_data = ce.get_image_from_family(
                family_name=image_url.name, project_id=image_url.project_id)
        else:
            res = ce.list_images(image_name=image_url.name,
                                 project_id=image_url.project_id)
            image_data = res[0] if res else None

        if not image_data:
            return None

        return Image(image_data)