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


Python DockerContainers.list_containers_with_cid方法代码示例

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


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

示例1: cleanup

# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import list_containers_with_cid [as 别名]
 def cleanup(self):
     # Removes the docker safely
     super(restart_base, self).cleanup()
     if self.sub_stuff.get('container_id') is None:
         return  # Docker was not created, we are clean
     containers = DockerContainers(self.parent_subtest)
     cont_id = self.sub_stuff['container_id']
     conts = containers.list_containers_with_cid(cont_id)
     if conts == []:
         return  # Container created, but doesn't exist.  Desired end-state.
     elif len(conts) > 1:
         msg = ("Multiple containers matches id %s, not removing any of "
                "them...", cont_id)
         raise xceptions.DockerTestError(msg)
     DockerCmd(self, 'rm', ['--force', '--volumes', cont_id]).execute()
开发者ID:Acidburn0zzz,项目名称:autotest-docker,代码行数:17,代码来源:restart.py

示例2: initialize

# 需要导入模块: from dockertest.containers import DockerContainers [as 别名]
# 或者: from dockertest.containers.DockerContainers import list_containers_with_cid [as 别名]
    def initialize(self):
        super(restart_base, self).initialize()
        config.none_if_empty(self.config)
        self.sub_stuff['container_id'] = None
        self.sub_stuff['restart_cmd'] = None
        self.sub_stuff['stop_cmd'] = None
        self.sub_stuff['restart_result'] = None
        self.sub_stuff['stop_result'] = None

        containers = DockerContainers(self.parent_subtest)

        # Container
        if self.config.get('run_options_csv'):
            subargs = [arg for arg in
                       self.config['run_options_csv'].split(',')]
        else:
            subargs = []
        image = DockerImage.full_name_from_defaults(self.config)
        subargs.append(image)
        subargs.append("bash")
        subargs.append("-c")
        subargs.append(self.config['exec_cmd'])
        container = NoFailDockerCmd(self, 'run', subargs)
        cont_id = container.execute().stdout.strip()
        self.sub_stuff['container_id'] = cont_id
        container = containers.list_containers_with_cid(cont_id)
        if container == []:
            raise xceptions.DockerTestNAError("Fail to get docker with id: %s"
                                              % cont_id)

        # Prepare the "restart" command
        if self.config.get('restart_options_csv'):
            subargs = [arg for arg in
                       self.config['restart_options_csv'].split(',')]
        else:
            subargs = []
        subargs.append(cont_id)
        self.sub_stuff['restart_cmd'] = NoFailDockerCmd(self, 'restart',
                                                        subargs)

        # Prepare the "stop" command
        if self.config.get('stop_options_csv'):
            subargs = [arg for arg in
                       self.config['stop_options_csv'].split(',')]
        else:
            subargs = []
        subargs.append(cont_id)
        self.sub_stuff['stop_cmd'] = NoFailDockerCmd(self, 'stop', subargs)
开发者ID:Acidburn0zzz,项目名称:autotest-docker,代码行数:50,代码来源:restart.py


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