예제 #1
0
def remove_image_by_id(host_id, long_id, force=False, noprune=False):
    try:
        _image = Image_Module()

        if not _image.set_host(host_id).check_health():
            return {
                "status": "failed",
                "result": {
                    "error": _("Error, Unable to connect to docker host!")
                },
                "notify_type": "failed"
            }

        _image.remove_by_id(
            long_id=long_id,
            force=force,
            noprune=noprune
        )

        return {
            "status": "passed",
            "result": "{}",
            "notify_type": "passed"
        }

    except Exception as e:
        return {
            "status": "error",
            "result": {
                "error": str(e)
            },
            "notify_type": "error"
        }
예제 #2
0
파일: images.py 프로젝트: megamcloud/Kraven
 def __init__(self):
     self.__request = Request()
     self.__response = Response()
     self.__helpers = Helpers()
     self.__form = Form()
     self.__host_module = Host_Module()
     self.__image_module = Image_Module()
     self.__logger = self.__helpers.get_logger(__name__)
예제 #3
0
def build_image(host_id, fileobj, tag, rm=False, nocache=False):
    try:
        _image = Image_Module()

        if not _image.set_host(host_id).check_health():
            return {
                "status": "failed",
                "result": {
                    "error": _("Error, Unable to connect to docker host!")
                },
                "notify_type": "failed"
            }

        result = _image.build(
            fileobj=fileobj,
            tag=tag,
            rm=rm,
            nocache=nocache
        )

        if result:
            return {
                "status": "passed",
                "result": "{}",
                "notify_type": "passed"
            }
        else:
            return {
                "status": "failed",
                "result": "{}",
                "notify_type": "failed"
            }

    except Exception as e:
        return {
            "status": "error",
            "result": {
                "error": str(e)
            },
            "notify_type": "error"
        }
예제 #4
0
def tag_image_by_id(host_id, long_id, repository, tag=None, force=False):
    try:
        _image = Image_Module()

        if not _image.set_host(host_id).check_health():
            return {
                "status": "failed",
                "result": {
                    "error": _("Error, Unable to connect to docker host!")
                },
                "notify_type": "failed"
            }

        result = _image.tag_by_id(
            long_id=long_id,
            repository=repository,
            tag=tag,
            force=force
        )

        if result:
            return {
                "status": "passed",
                "result": "{}",
                "notify_type": "passed"
            }
        else:
            return {
                "status": "failed",
                "result": "{}",
                "notify_type": "failed"
            }

    except Exception as e:
        return {
            "status": "error",
            "result": {
                "error": str(e)
            },
            "notify_type": "error"
        }
예제 #5
0
def pull_image(host_id, image_name):
    try:
        _image = Image_Module()

        if not _image.set_host(host_id).check_health():
            return {
                "status": "failed",
                "result": {
                    "error": _("Error, Unable to connect to docker host!")
                },
                "notify_type": "failed"
            }

        image_name = image_name.split(":")
        result = _image.pull(
            image_name[0],
            image_name[1]
        )
        if result:
            return {
                "status": "passed",
                "result": "{}",
                "notify_type": "passed"
            }
        else:
            return {
                "status": "failed",
                "result": "{}",
                "notify_type": "failed"
            }

    except Exception as e:
        return {
            "status": "error",
            "result": {
                "error": str(e)
            },
            "notify_type": "error"
        }
예제 #6
0
def prune_all_unused_images(host_id):
    try:
        _image = Image_Module()

        if not _image.set_host(host_id).check_health():
            return {
                "status": "failed",
                "result": {
                    "error": _("Error, Unable to connect to docker host!")
                },
                "notify_type": "failed"
            }

        result = _image.prune_all_unused()

        if result:
            return {
                "status": "passed",
                "result": "{}",
                "notify_type": "passed"
            }
        else:
            return {
                "status": "failed",
                "result": "{}",
                "notify_type": "failed"
            }

    except Exception as e:
        return {
            "status": "error",
            "result": {
                "error": str(e)
            },
            "notify_type": "error"
        }
예제 #7
0
파일: host.py 프로젝트: megamcloud/Kraven
 def tag_image_by_id(self, configs={}):
     _image = Image_Module()
     if _image.set_host(configs["host_id"]).check_health():
         print(
             _image.tag_by_id(configs["image_id"], configs["repository"],
                              configs["tag"]))
예제 #8
0
파일: host.py 프로젝트: megamcloud/Kraven
 def build_image(self, configs={}):
     _image = Image_Module()
     if _image.set_host(configs["host_id"]).check_health():
         print(
             _image.build(File().read(configs["dockerfile"]),
                          configs["tag"]))
예제 #9
0
파일: host.py 프로젝트: megamcloud/Kraven
 def remove_image_by_id(self, configs={}):
     _image = Image_Module()
     if _image.set_host(configs["host_id"]).check_health():
         print(
             _image.remove_by_id(configs["image_id"],
                                 configs["force"] == "True"))
예제 #10
0
파일: host.py 프로젝트: megamcloud/Kraven
 def get_image_by_id(self, configs={}):
     _image = Image_Module()
     if _image.set_host(configs["host_id"]).check_health():
         print(_image.get_by_id(configs["image_id"]))
예제 #11
0
파일: host.py 프로젝트: megamcloud/Kraven
 def remove_image_by_name(self, configs={}):
     _image = Image_Module()
     if _image.set_host(configs["host_id"]).check_health():
         print(_image.remove_by_name(configs["repository"], configs["tag"]))
예제 #12
0
파일: host.py 프로젝트: megamcloud/Kraven
 def prune_all_unused_images(self, configs={}):
     _image = Image_Module()
     if _image.set_host(configs["host_id"]).check_health():
         print(_image.prune_all_unused())
예제 #13
0
파일: host.py 프로젝트: megamcloud/Kraven
 def list_images(self, configs={}):
     _image = Image_Module()
     if _image.set_host(configs["host_id"]).check_health():
         print(_image.list())
예제 #14
0
파일: host.py 프로젝트: megamcloud/Kraven
 def pull_image(self, configs={}):
     _image = Image_Module()
     if _image.set_host(configs["host_id"]).check_health():
         print(_image.pull(configs["repository"], configs["tag"]))
예제 #15
0
파일: host.py 프로젝트: megamcloud/Kraven
 def check_health(self, configs={}):
     _image = Image_Module()
     if _image.set_host(configs["host_id"]).check_health():
         print("Host Up!")
     else:
         print("Host Down!")