def get_running_apps(): apps_list = [] dclient = docker.from_env() apps = dclient.containers.list() for app in apps: attrs = app.attrs attrs.update(conv2dict("name", app.name)) attrs.update(conv2dict("ports", app.ports)) attrs.update(conv2dict("short_id", app.short_id)) apps_list.append(attrs) return apps_list
def get_app(app_name): dclient = docker.from_env() try: app = dclient.containers.get(app_name) except Exception as exc: raise HTTPException(status_code=exc.response.status_code, detail=exc.explanation) attrs = app.attrs attrs.update(conv2dict("ports", app.ports)) attrs.update(conv2dict("short_id", app.short_id)) attrs.update(conv2dict("name", app.name)) return attrs
def check_app_update(app_name): dclient = docker.from_env() try: app = dclient.containers.get(app_name) except Exception as exc: raise HTTPException(status_code=exc.response.status_code, detail=exc.explanation) if app.attrs["Config"]["Image"]: if _check_updates(app.attrs["Config"]["Image"]): app.attrs.update(conv2dict("isUpdatable", True)) app.attrs.update(conv2dict("name", app.name)) app.attrs.update(conv2dict("ports", app.ports)) app.attrs.update(conv2dict("short_id", app.short_id)) return app.attrs
def get_apps(): apps_list = [] try: dclient = docker.from_env() except docker.errors.DockerException as exc: raise HTTPException(status_code=500, detail=exc.args) try: apps = dclient.containers.list(all=True) except Exception as exc: raise HTTPException(status_code=exc.response.status_code, detail=exc.explanation) for app in apps: attrs = app.attrs attrs.update(conv2dict("name", app.name)) attrs.update(conv2dict("ports", app.ports)) attrs.update(conv2dict("short_id", app.short_id)) apps_list.append(attrs) return apps_list