本文整理汇总了Python中docker.APIClient.info方法的典型用法代码示例。如果您正苦于以下问题:Python APIClient.info方法的具体用法?Python APIClient.info怎么用?Python APIClient.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docker.APIClient
的用法示例。
在下文中一共展示了APIClient.info方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: detect_daemon_type
# 需要导入模块: from docker import APIClient [as 别名]
# 或者: from docker.APIClient import info [as 别名]
def detect_daemon_type(worker_api, timeout=5):
""" Try to detect the daemon type
Only wait for timeout seconds.
:param worker_api: Docker daemon url
:param timeout: Time to wait for the response
:return: host type info
"""
if not worker_api or not worker_api.startswith("tcp://"):
return None
segs = worker_api.split(":")
if len(segs) != 3:
logger.error("Invalid daemon url = ", worker_api)
return None
try:
client = Client(base_url=worker_api, version="auto", timeout=timeout)
info = client.info()
server_version = info['ServerVersion']
if not server_version:
logger.warning("info().ServerVersion cannot be empty")
return None
if server_version.startswith('swarm'):
return WORKER_TYPES[1]
try:
if info['Swarm']['Cluster']['ID'] != '':
return WORKER_TYPES[1]
except Exception as e:
logger.debug(e)
return WORKER_TYPES[0]
except Exception as e:
logger.error(e)
return None