本文整理汇总了Python中dockertest.containers.DockerContainers.kill_container_by_long_id方法的典型用法代码示例。如果您正苦于以下问题:Python DockerContainers.kill_container_by_long_id方法的具体用法?Python DockerContainers.kill_container_by_long_id怎么用?Python DockerContainers.kill_container_by_long_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dockertest.containers.DockerContainers
的用法示例。
在下文中一共展示了DockerContainers.kill_container_by_long_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: postprocess
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import kill_container_by_long_id [as 别名]
def postprocess(self):
self.loginfo("postprocess()")
# Raise exception if problems found
OutputGood(self.sub_stuff["cmdresult"])
self.failif_ne(
self.sub_stuff["cmdresult"].exit_status, 0, "Non-zero commit exit status: %s" % self.sub_stuff["cmdresult"]
)
im = self.check_image_exists(self.sub_stuff["new_image_name"])
# Needed for cleanup
self.sub_stuff["image_list"] = im
self.failif(len(im) < 1, "Failed to look up committed image ")
self.check_file_in_image()
# Check if is possible start image with default command.
dc = DockerCmd(
self, "run", ["--rm", self.sub_stuff["image_list"][0].long_id], timeout=self.config["docker_timeout"]
)
results = dc.execute()
dct = DockerContainers(self)
cnts = dct.list_containers()
for cont in cnts:
if cont.image_name == self.sub_stuff["image_list"][0].full_name:
try:
dct.kill_container_by_long_id(cont.long_id)
except ValueError:
pass
dc = DockerCmd(self, "rm", ["-f", cont.long_id])
rm_results = dc.execute()
self.failif_ne(rm_results.exit_status, 0, "Non-zero commit exit status: %s" % rm_results)
self.failif_ne(results.exit_status, 0, "Non-zero commit exit status: %s" % results)
self.failif(not self.sub_stuff["rand_data"] in results.stdout, "Unexpected command result: %s" % results.stdout)
示例2: try_kill
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import kill_container_by_long_id [as 别名]
def try_kill(subtest, cidfilename, cmdresult):
docker_containers = DockerContainers(subtest)
try:
cidfile = open(cidfilename, 'rb')
cid = cidfile.read()
if len(cid) < 12:
raise ValueError()
else:
docker_containers.kill_container_by_long_id(cid.strip())
except ValueError:
subtest.logdebug("Container %s not found to kill", cid[:12])
except IOError:
subtest.logdebug("Container never ran for %s", cmdresult)
示例3: postprocess
# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import kill_container_by_long_id [as 别名]
def postprocess(self):
super(commit_base, self).postprocess()
# Raise exception if problems found
OutputGood(self.sub_stuff['cmdresult'])
self.failif(self.sub_stuff['cmdresult'].exit_status != 0,
"Non-zero commit exit status: %s"
% self.sub_stuff['cmdresult'])
im = self.check_image_exists(self.sub_stuff["new_image_name"])
# Needed for cleanup
self.sub_stuff['image_list'] = im
self.failif(len(im) < 1,
"Failed to look up committed image ")
self.check_file_in_image()
# Check if is possible start image with default command.
dc = DockerCmd(self.parent_subtest, "run",
[self.sub_stuff['image_list'][0].long_id],
timeout=self.config['docker_timeout'])
results = dc.execute()
dct = DockerContainers(self.parent_subtest)
cnts = dct.list_containers()
for cont in cnts:
if cont.image_name == self.sub_stuff['image_list'][0].full_name:
try:
dct.kill_container_by_long_id(cont.long_id)
except ValueError:
pass
dc = DockerCmd(self.parent_subtest, "rm", ["-f", cont.long_id])
rm_results = dc.execute()
self.failif(rm_results.exit_status != 0,
"Non-zero commit exit status: %s"
% rm_results)
self.failif(results.exit_status != 0,
"Non-zero commit exit status: %s"
% results)
self.failif(not self.config['check_results_contain'] in results.stdout,
"Unable to start image with default command: %s"
% results)