本文整理汇总了Python中dockertest.images.DockerImages.remove_image_by_image_obj方法的典型用法代码示例。如果您正苦于以下问题:Python DockerImages.remove_image_by_image_obj方法的具体用法?Python DockerImages.remove_image_by_image_obj怎么用?Python DockerImages.remove_image_by_image_obj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dockertest.images.DockerImages
的用法示例。
在下文中一共展示了DockerImages.remove_image_by_image_obj方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cleanup
# 需要导入模块: from dockertest.images import DockerImages [as 别名]
# 或者: from dockertest.images.DockerImages import remove_image_by_image_obj [as 别名]
def cleanup(self):
super(run, self).cleanup()
# Clean up all containers
dc = DockerContainers(self)
for cobj in dc.list_containers():
self.logwarning("Found leftover container: %s", cobj.container_name)
try:
dc.kill_container_by_obj(cobj)
except ValueError:
pass # already dead
else:
self.logdebug("Killed container %s, waiting up to %d seconds "
"for it to exit", cobj.container_name,
dc.timeout)
dc.wait_by_obj(cobj)
self.logdebug("Removing container %s", cobj.container_name)
dc.remove_by_obj(cobj)
# Clean up all non-default images
fqin = DockerImage.full_name_from_defaults(self.config)
di = DockerImages(self)
def_img_obj = di.list_imgs_with_full_name(fqin)[0]
for img_obj in di.list_imgs():
if img_obj.full_name != def_img_obj.full_name:
self.logwarning("Found leftover image: %s", img_obj)
di.remove_image_by_image_obj(img_obj)
else:
self.logdebug("Not removing default image: %s", def_img_obj)
示例2: cleanup
# 需要导入模块: from dockertest.images import DockerImages [as 别名]
# 或者: from dockertest.images.DockerImages import remove_image_by_image_obj [as 别名]
def cleanup(self):
super(commit_base, self).cleanup()
# Auto-converts "yes/no" to a boolean
if (self.config['remove_after_test'] and
'image_list' in self.sub_stuff):
dkrcmd = DockerCmd(self.parent_subtest, "rm",
['--volumes', '--force',
self.sub_stuff["container"]])
cmdresult = dkrcmd.execute()
msg = (" removed test container: %s" % self.sub_stuff["container"])
if cmdresult.exit_status == 0:
self.loginfo("Successfully" + msg)
else:
self.logwarning("Failed" + msg)
for image in self.sub_stuff["image_list"]:
try:
di = DockerImages(self.parent_subtest)
self.logdebug("Removing image %s", image.full_name)
di.remove_image_by_image_obj(image)
self.loginfo("Successfully removed test image: %s",
image.full_name)
except error.CmdError, e:
error_text = "tagged in multiple repositories"
if not error_text in e.result_obj.stderr:
raise
示例3: cleanup
# 需要导入模块: from dockertest.images import DockerImages [as 别名]
# 或者: from dockertest.images.DockerImages import remove_image_by_image_obj [as 别名]
def cleanup(self):
super(pull_base, self).cleanup()
# Auto-converts "yes/no" to a boolean
if (self.config['remove_after_test'] and
'image_list' in self.sub_stuff):
for image in self.sub_stuff["image_list"]:
try:
di = DockerImages(self.parent_subtest)
di.remove_image_by_image_obj(image)
self.loginfo("Successfully removed test image")
except error.CmdError:
self.logwarning("Image not exist.")
示例4: cleanup
# 需要导入模块: from dockertest.images import DockerImages [as 别名]
# 或者: from dockertest.images.DockerImages import remove_image_by_image_obj [as 别名]
def cleanup(self):
super(tag_base, self).cleanup()
# Auto-converts "yes/no" to a boolean
if (self.config['remove_after_test'] and
'image_list' in self.sub_stuff):
for image in self.sub_stuff["image_list"]:
di = DockerImages(self.parent_subtest)
self.logdebug("Removing image %s", image.full_name)
try:
di.remove_image_by_image_obj(image)
except error.CmdError, e:
err = e.result_obj.stderr
if not "tagged in multiple repositories" in err:
raise
self.loginfo("Successfully removed test image: %s",
image.full_name)