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


Python DockerContainers.list_containers方法代码示例

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


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

示例1: postprocess

# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import list_containers [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)
开发者ID:edsantiago,项目名称:autotest-docker,代码行数:36,代码来源:check_default_cmd.py

示例2: cleanup

# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import list_containers [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)
开发者ID:Lorquas,项目名称:autotest-docker,代码行数:29,代码来源:run.py

示例3: init_use_names

# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import list_containers [as 别名]
 def init_use_names(self, use_names=False):
     if use_names:
         conts = self.sub_stuff['containers']
         containers = DockerContainers(self.parent_subtest)
         containers = containers.list_containers()
         cont_ids = [cont['id'] for cont in conts]
         for cont in containers:
             if cont.long_id in cont_ids:
                 if use_names is not True and random.choice((True, False)):
                     continue    # 50% chance of using id vs. name
                 # replace the id with name
                 cont_idx = cont_ids.index(cont.long_id)
                 conts[cont_idx]['id'] = cont.container_name
开发者ID:sibiaoluo,项目名称:autotest-docker,代码行数:15,代码来源:wait.py

示例4: postprocess

# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import list_containers [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)
开发者ID:Lorquas,项目名称:autotest-docker,代码行数:43,代码来源:check_default_cmd.py


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