def prune_unused_networks(host_id): try: _network = Network_Module() if not _network.set_host(host_id).check_health(): return { "status": "failed", "result": { "error": _("Error, Unable to connect to docker host!") }, "notify_type": "failed" } result = _network.prune() 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" }
def __init__(self): self.__request = Request() self.__response = Response() self.__helpers = Helpers() self.__form = Form() self.__host_module = Host_Module() self.__network_module = Network_Module() self.__logger = self.__helpers.get_logger(__name__)
def disconnect_network_container(host_id): try: _network = Network_Module() if not _network.set_host(host_id).check_health(): return { "status": "failed", "result": { "error": _("Error, Unable to connect to docker host!") }, "notify_type": "failed" } except Exception as e: return { "status": "error", "result": { "error": str(e) }, "notify_type": "error" }
def remove_network(self, configs={}): _network = Network_Module() if _network.set_host(configs["host_id"]).check_health(): print(_network.remove(configs["network_id"]))
def prune_networks(self, configs={}): _network = Network_Module() if _network.set_host(configs["host_id"]).check_health(): print(_network.prune())