本文整理汇总了Python中dockertest.containers.DockerContainers.list_containers_with_name方法的典型用法代码示例。如果您正苦于以下问题:Python DockerContainers.list_containers_with_name方法的具体用法?Python DockerContainers.list_containers_with_name怎么用?Python DockerContainers.list_containers_with_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dockertest.containers.DockerContainers
的用法示例。
在下文中一共展示了DockerContainers.list_containers_with_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: container_cleanup
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import list_containers_with_name [as 别名]
def container_cleanup(self):
"""
Cleanup the container
"""
if self.sub_stuff.get('container_name') is None:
return # Docker was not created, we are clean
containers = DockerContainers(self.parent_subtest)
name = self.sub_stuff['container_name']
conts = containers.list_containers_with_name(name)
if conts == []:
return # Docker was created, but apparently doesn't exist, clean
elif len(conts) > 1:
msg = ("Multiple containers matches name %s, not removing any of "
"them...", name)
raise xceptions.DockerTestError(msg)
NoFailDockerCmd(self, 'rm', ['--force', '--volumes', name],
verbose=False).execute()
示例2: postprocess
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import list_containers_with_name [as 别名]
def postprocess(self):
super(psa, self).postprocess()
cl0_len = len(self.stuff['cl0'])
cl1_len = len(self.stuff['cl1'])
cl2_len = len(self.stuff['cl2'])
self.failif(cl1_len <= cl0_len, "Container list length did not "
"increase.")
self.failif(cl1_len != cl2_len, "Third container list length did "
"not stay same as second list.")
# TODO: Use 'inspect' command output to get actual PID
# and utils.pid_is_alive(PID) to verify it's stopped
# Might as well do some more checking
dc = DockerContainers(self, 'cli') # check output
cnts = dc.list_containers_with_name(self.stuff['container_name'])
self.failif(len(cnts) < 1, "Test container not found in list")
cnt = cnts[0]
self.failif(str(cnt.status) != "Exit 0", "Exit status mismatch")