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


Python containers.DockerContainers类代码示例

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


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

示例1: postprocess

    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,代码行数:34,代码来源:check_default_cmd.py

示例2: cleanup

 def cleanup(self):
     """
     Cleanup the containers defined in self.sub_stuff['containers']
     """
     if self.config['remove_after_test']:
         dc = DockerContainers(self)
         dc.clean_all(self.sub_stuff.get("containers"))
开发者ID:chuanchang,项目名称:autotest-docker,代码行数:7,代码来源:ps_size.py

示例3: _init_container

    def _init_container(self):
        """ Create, store in self.stuff and execute container """
        try:
            fin = DockerImage.full_name_from_defaults(self.config)
        except ValueError:
            raise DockerTestNAError("Empty test image name configured,"
                                    "did you set one for this test?")

        docker_containers = DockerContainers(self)
        name = docker_containers.get_unique_name()
        self.stuff['container_name'] = name
        if self.config.get('run_options_csv'):
            subargs = [arg for arg in
                       self.config['run_options_csv'].split(',')]
        else:
            subargs = []
        subargs.append("--name %s" % name)

        subargs.append(fin)
        subargs.append("bash")
        container = NoFailDockerCmd(self, 'run', subargs)
        self.stuff['container_cmd'] = container
        container.execute()

        if self.config.get('attach_options_csv'):
            subargs = [arg for arg in
                       self.config['attach_options_csv'].split(',')]
        else:
            subargs = []
        subargs.append(name)
        container = AsyncDockerCmd(self, 'attach', subargs)
        self.stuff['container_cmd'] = container  # overwrites finished cmd
        stdin = os.pipe()
        self.stuff['container_stdin'] = stdin[1]
        container.execute(stdin[0])
开发者ID:ldoktor,项目名称:autotest-docker,代码行数:35,代码来源:top.py

示例4: cleanup

 def cleanup(self):
     super(run_base, self).cleanup()
     if self.config['remove_after_test']:
         dc = DockerContainers(self)
         dc.clean_all(self.sub_stuff.get("containers"))
         di = DockerImages(self)
         di.clean_all(self.sub_stuff.get("images"))
开发者ID:cevich,项目名称:autotest-docker,代码行数:7,代码来源:run.py

示例5: initialize

 def initialize(self):
     super(simple, self).initialize()
     config.none_if_empty(self.config)
     # Get free name
     docker_containers = DockerContainers(self)
     name = docker_containers.get_unique_name()
     self.sub_stuff['container_name'] = name
开发者ID:cevich,项目名称:autotest-docker,代码行数:7,代码来源:simple.py

示例6: _init_container

    def _init_container(self):
        """ Create, store in self.stuff and execute container """
        docker_containers = DockerContainers(self)
        prefix = self.config["container_name_prefix"]
        name = docker_containers.get_unique_name(prefix, length=4)
        self.stuff['container_name'] = name
        if self.config.get('run_options_csv'):
            subargs = [arg for arg in
                       self.config['run_options_csv'].split(',')]
        else:
            subargs = []
        subargs.append("--name %s" % name)
        fin = DockerImage.full_name_from_defaults(self.config)
        subargs.append(fin)
        subargs.append("bash")
        container = NoFailDockerCmd(self, 'run', subargs)
        self.stuff['container_cmd'] = container
        container.execute()

        if self.config.get('attach_options_csv'):
            subargs = [arg for arg in
                       self.config['attach_options_csv'].split(',')]
        else:
            subargs = []
        subargs.append(name)
        container = AsyncDockerCmd(self, 'attach', subargs)
        self.stuff['container_cmd'] = container  # overwrites finished cmd
        stdin = os.pipe()
        self.stuff['container_stdin'] = stdin[1]
        container.execute(stdin[0])
开发者ID:Lorquas,项目名称:autotest-docker,代码行数:30,代码来源:top.py

示例7: initialize

    def initialize(self):
        super(run_memory_base, self).initialize()
        docker_containers = DockerContainers(self.parent_subtest)
        image = DockerImage.full_name_from_defaults(self.config)
        unit_list = ['', 'b', 'B', 'k', 'K', 'm', 'M', 'g', 'G']
        memory_list = []
        self.sub_stuff['name'] = []
        args = []

        if self.config['expect_success'] == "PASS":
            memory_value = str(self.config['memory_value'])
            if memory_value is not '0':
                for unit in unit_list:
                    memory_list.append(memory_value + unit)
            else:
                memory_list.append('0')
        else:
            memory_list.append(self.config['memory_min_invalid'])
            memory_list.append(self.config['memory_max_invalid'])
            memory_list.append(self.config['memory_invalid'])

        for memory in memory_list:
            prefix = self.config['memory_name_prefix']
            name = docker_containers.get_unique_name(prefix, length=4)
            if self.config['expect_success'] == "PASS":
                self.sub_stuff['name'].append(name)
            args.append(self.combine_subargs(name,
                                             memory,
                                             image,
                                             '/bin/bash'))
        self.sub_stuff['subargs'] = args
        self.sub_stuff['container_memory'] = memory_list
        self.sub_stuff['cgroup_memory'] = []
        self.sub_stuff['result'] = []
开发者ID:Lorquas,项目名称:autotest-docker,代码行数:34,代码来源:run_memory.py

示例8: initialize

 def initialize(self):
     super(stop_base, self).initialize()
     # Prepare a container
     docker_containers = DockerContainers(self.parent_subtest)
     prefix = self.config["stop_name_prefix"]
     name = docker_containers.get_unique_name(prefix, length=4)
     self.sub_stuff['container_name'] = name
     config.none_if_empty(self.config)
     if self.config.get('run_options_csv'):
         subargs = [arg for arg in
                    self.config['run_options_csv'].split(',')]
     subargs.append("--name %s" % name)
     fin = DockerImage.full_name_from_defaults(self.config)
     subargs.append(fin)
     subargs.append("bash")
     subargs.append("-c")
     subargs.append(self.config['exec_cmd'])
     container = AsyncDockerCmd(self, 'run', subargs)
     self.sub_stuff['container_cmd'] = container
     container.execute()
     time.sleep(self.config['wait_start'])
     # Prepare the "stop" command
     if self.config.get('stop_options_csv'):
         subargs = [arg for arg in
                    self.config['stop_options_csv'].split(',')]
     subargs.append(name)
     self.sub_stuff['stop_cmd'] = DockerCmd(self, 'stop', subargs)
开发者ID:Acidburn0zzz,项目名称:autotest-docker,代码行数:27,代码来源:stop.py

示例9: cleanup

 def cleanup(self):
     """
     Cleanup the container
     """
     super(run_user, self).cleanup()
     if self.config['remove_after_test']:
         dc = DockerContainers(self)
         dc.clean_all([self.stuff.get("container")])
开发者ID:chuanchang,项目名称:autotest-docker,代码行数:8,代码来源:run_user.py

示例10: cleanup

 def cleanup(self):
     super(run_attach_stdout, self).cleanup()
     dc = DockerContainers(self.parent_subtest)
     name = self.sub_stuff["rand_name"]
     try:
         dc.kill_container_by_name(name)
     except ValueError:
         pass  #  death was the goal
     dc.remove_by_name(self.sub_stuff["rand_name"])
开发者ID:Lorquas,项目名称:autotest-docker,代码行数:9,代码来源:run_attach_stdout.py

示例11: initialize

 def initialize(self):
     super(simple, self).initialize()
     self._init_stuff()
     config.none_if_empty(self.config)
     # Get free name
     prefix = self.config["container_name_prefix"]
     docker_containers = DockerContainers(self.parent_subtest)
     name = docker_containers.get_unique_name(prefix, length=4)
     self.sub_stuff['container_name'] = name
开发者ID:Lorquas,项目名称:autotest-docker,代码行数:9,代码来源:simple.py

示例12: initialize

 def initialize(self):
     super(diff_base, self).initialize()
     dc = DockerContainers(self)
     name = self.sub_stuff['name'] = dc.get_unique_name()
     fin = DockerImage.full_name_from_defaults(self.config)
     subargs = ['--name=%s' % (name), fin]
     subargs = subargs + self.config['command'].split(',')
     nfdc = DockerCmd(self, 'run', subargs)
     mustpass(nfdc.execute())
开发者ID:chuanchang,项目名称:autotest-docker,代码行数:9,代码来源:diff.py

示例13: initialize

 def initialize(self):
     super(flag, self).initialize()
     self.stuff["containter_name"] = []
     self.stuff["subargs"] = []
     self.stuff["cmdresult"] = []
     docker_containers = DockerContainers(self)
     self.logdebug("Generating ramdom name will take 1 minute")
     cname = docker_containers.get_unique_name("docker", "test", 4)
     self.stuff["containter_name"] = cname
开发者ID:Acidburn0zzz,项目名称:autotest-docker,代码行数:9,代码来源:flag.py

示例14: initialize

 def initialize(self):
     super(run_attach_stdout, self).initialize()
     dc = DockerContainers(self.parent_subtest)
     self.sub_stuff["rand_name"] = rand_name = dc.get_unique_name()
     self.sub_stuff["rand_data"] = utils.generate_random_string(8)
     self.sub_stuff["subargs"].insert(0, "--name=\"%s\"" % rand_name)
     attach_options = self.config['attach_options_csv'].split(',')
     attach_options.append(rand_name)
     self.sub_stuff['attach_options'] = attach_options
     self.sub_stuff["rpipe"], self.sub_stuff["wpipe"] = os.pipe()
开发者ID:Lorquas,项目名称:autotest-docker,代码行数:10,代码来源:run_attach_stdout.py

示例15: cleanup

 def cleanup(self):
     super(commit_base, self).cleanup()
     if self.config["remove_after_test"]:
         dc = DockerContainers(self)
         container = self.sub_stuff.get("container")
         if container:
             dc.clean_all([container])
         di = di = DockerImages(self)
         images = [img.full_name for img in self.sub_stuff.get("image_list", [])]
         di.clean_all(images)
开发者ID:afomm,项目名称:autotest-docker,代码行数:10,代码来源:commit.py


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