当前位置: 首页>>代码示例>>Python>>正文


Python APIClient.remove_network方法代码示例

本文整理汇总了Python中docker.APIClient.remove_network方法的典型用法代码示例。如果您正苦于以下问题:Python APIClient.remove_network方法的具体用法?Python APIClient.remove_network怎么用?Python APIClient.remove_network使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在docker.APIClient的用法示例。


在下文中一共展示了APIClient.remove_network方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cleanup_host

# 需要导入模块: from docker import APIClient [as 别名]
# 或者: from docker.APIClient import remove_network [as 别名]
def cleanup_host(worker_api, timeout=5):
    """
    Cleanup a container host when use removes the host

    Maybe we will remove the networks?

    :param worker_api: Docker daemon url
    :param timeout: timeout to wait
    :return:
    """
    if not worker_api or not worker_api.startswith("tcp://"):
        logger.error("Invalid worker_api={}".format(worker_api))
        return False
    try:
        client = Client(base_url=worker_api, version="auto", timeout=timeout)
        net_names = [x["Name"] for x in client.networks()]
        for cs_type in CONSENSUS_PLUGINS_FABRIC_V1:
            net_name = CLUSTER_NETWORK + "_{}".format(cs_type)
            if net_name in net_names:
                logger.debug("Remove network {}".format(net_name))
                client.remove_network(net_name)
            else:
                logger.warning("Network {} not exists!".format(net_name))
    except Exception as e:
        logger.error("Exception happens!")
        logger.error(e)
        return False
    return True
开发者ID:arindbha,项目名称:cello,代码行数:30,代码来源:docker_swarm.py

示例2: _clean_network

# 需要导入模块: from docker import APIClient [as 别名]
# 或者: from docker.APIClient import remove_network [as 别名]
 def _clean_network(self):
     client = Client(base_url=self._docker_host, version="auto", timeout=10)
     networks = client.networks(names=["%s_default" % self._project_name])
     id_removes = [e["Id"] for e in networks]
     for network_id in id_removes:
         client.remove_network(network_id)
         LOG.debug("Remove network id {}".format(network_id))
开发者ID:arindbha,项目名称:cello,代码行数:9,代码来源:__init__.py

示例3: _clean_project_networks

# 需要导入模块: from docker import APIClient [as 别名]
# 或者: from docker.APIClient import remove_network [as 别名]
def _clean_project_networks(worker_api, name_prefix, timeout=5):
    """
    Clean cluster node networks

    All containers with the name prefix will be removed.

    :param worker_api: Docker daemon url
    :param name_prefix: image name prefix
    :param timeout: Time to wait for the response
    :return: None
    """
    logger.debug("Clean project networks, worker_api={}, prefix={}".format(
        worker_api, name_prefix))
    client = Client(base_url=worker_api, version="auto", timeout=timeout)
    networks = client.networks(names=["%s_default" % name_prefix])
    id_removes = [e['Id'] for e in networks]
    for network_id in id_removes:
        client.remove_network(network_id)
        logger.debug("Remove network id {}".format(network_id))
开发者ID:arindbha,项目名称:cello,代码行数:21,代码来源:docker_swarm.py


注:本文中的docker.APIClient.remove_network方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。