コード例 #1
0
    def initialize(self):
        super(sig_proxy_off_base, self).initialize()
        rand_name = self.sub_stuff['cont'].get_unique_name()

        self.sub_stuff["rand_name"] = rand_name
        self.sub_stuff["subargs"].insert(0, "--name=\"%s\"" % rand_name)

        run_in_pipe_r, run_in_pipe_w = os.pipe()
        self.sub_stuff['file_desc'].append(run_in_pipe_r)
        self.sub_stuff['file_desc'].append(run_in_pipe_w)
        self.sub_stuff["run_in_pipe_w"] = run_in_pipe_w
        dkrcmd = AsyncDockerCmd(self, 'run', self.sub_stuff['subargs'])

        # Runs in background
        self.sub_stuff['cmdresult'] = dkrcmd.execute(run_in_pipe_r)
        self.sub_stuff['cmd_run'] = dkrcmd

        attach_options = self.config['attach_options_csv'].split(',')
        self.sub_stuff['subargs_a'] = attach_options

        dkrcmd.wait_for_ready()
        c_name = self.sub_stuff["rand_name"]
        self.sub_stuff["containers"].append(c_name)
        cid = self.sub_stuff["cont"].list_containers_with_name(c_name)

        self.failif(
            cid == [], "Unable to search container with name %s, detail: %s" %
            (c_name, dkrcmd))
コード例 #2
0
ファイル: attach.py プロジェクト: lmr/autotest-docker
    def initialize(self):
        super(simple_base, self).initialize()
        rand_name = self.sub_stuff['cont'].get_unique_name()
        self.sub_stuff["rand_name"] = rand_name
        self.sub_stuff["subargs"].insert(0, "--name=\"%s\"" % rand_name)

        run_in_pipe_r, run_in_pipe_w = os.pipe()
        self.sub_stuff['file_desc'].append(run_in_pipe_r)
        self.sub_stuff['file_desc'].append(run_in_pipe_w)
        self.sub_stuff["run_in_pipe_w"] = run_in_pipe_w
        dkrcmd = AsyncDockerCmd(self,
                                'run',
                                self.sub_stuff['subargs'],
                                verbose=True)

        # Runs in background
        self.sub_stuff['cmdresult'] = dkrcmd.execute(run_in_pipe_r)
        self.sub_stuff['cmd_run'] = dkrcmd
        self.wait_interactive_cmd()
        self.logdebug("Detail after waiting: %s", dkrcmd.cmdresult)

        attach_options = self.config['attach_options_csv'].split(',')
        self.sub_stuff['subargs_a'] = attach_options

        c_name = self.sub_stuff["rand_name"]
        self.sub_stuff["containers"].append(c_name)
        cid = self.sub_stuff["cont"].list_containers_with_name(c_name)

        self.failif(cid == [],
                    "Unable to search container with name %s" % (c_name))
コード例 #3
0
    def _init_container_attached(self, name):
        """
        Starts detached container and attaches it using docker attach
        """
        if self.config.get("run_options_csv"):
            subargs = [arg for arg in self.config["run_options_csv"].split(",")]
        else:
            subargs = []
        if self.tty:
            subargs.append("--tty=true")
        else:
            subargs.append("--tty=false")
        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 = DockerCmd(self, "run", subargs)
        self.sub_stuff["container_cmd"] = container
        mustpass(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)
        c_attach = AsyncDockerCmd(self, "attach", subargs)
        self.sub_stuff["container_cmd"] = c_attach  # overwrites finished cmd
        c_attach.execute()
コード例 #4
0
    def initialize(self):
        super(stop_base, self).initialize()
        # Prepare a container
        docker_containers = DockerContainers(self)
        name = docker_containers.get_unique_name()
        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)
コード例 #5
0
    def _init_container_attached(self, name):
        """
        Starts detached container and attaches it using docker attach
        """
        if self.config.get('run_options_csv'):
            subargs = [arg for arg in
                       self.config['run_options_csv'].split(',')]
        else:
            subargs = []
        if self.tty:
            subargs.append('--tty=true')
        else:
            subargs.append('--tty=false')
        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 = DockerCmd(self, 'run', subargs)
        self.sub_stuff['container_cmd'] = container
        mustpass(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)
        c_attach = AsyncDockerCmd(self, 'attach', subargs)
        self.sub_stuff['container_cmd'] = c_attach  # overwrites finished cmd
        c_attach.execute()
コード例 #6
0
ファイル: run_signal.py プロジェクト: Lorquas/autotest-docker
 def run_once(self):
     sig = getattr(signal, self.config['listen_signal'])
     dkrcmd = AsyncDockerCmd(self.parent_subtest, 'run',
                             self.sub_stuff['subargs'],
                             timeout=self.config['docker_timeout'])
     self.logdebug("Starting background docker command, timeout %s seconds: "
                  "%s", self.config['docker_timeout'], dkrcmd.command)
     dkrcmd.verbose = True
     # Runs in background
     cmdresult = self.sub_stuff['cmdresult'] = dkrcmd.execute()
     pid = dkrcmd.process_id
     ss = self.config['secret_sauce']
     while True:
         stdout = dkrcmd.stdout
         if stdout.count(ss) >= 1:
             break
         time.sleep(0.1)
     wait_start = self.config['wait_start']
     self.loginfo("Container running, waiting %d seconds to send signal"
                  % wait_start)
     # Allow noticable time difference for date command,
     # and eat into dkrcmd timeout after receiving signal.
     time.sleep(wait_start)
     self.failif(not utils.pid_is_alive(pid),
                 "Pid %s not running after wait: %s"
                 % (pid, cmdresult))
     self.loginfo("Signaling pid %d with signal %s",
                  pid, self.config['listen_signal'])
     utils.signal_pid(pid, sig)
     self.loginfo("Waiting up to %d seconds for exit",
                  dkrcmd.timeout)
     # Throw exception if takes > docker_timeout to exit
     dkrcmd.wait()
コード例 #7
0
ファイル: attach.py プロジェクト: Lorquas/autotest-docker
    def initialize(self):
        super(simple_base, self).initialize()
        rand_name = utils.generate_random_string(8)
        self.sub_stuff["rand_name"] = rand_name
        self.sub_stuff["subargs"].insert(0, "--name=\"%s\"" % rand_name)

        run_in_pipe_r, run_in_pipe_w = os.pipe()
        self.sub_stuff['file_desc'].append(run_in_pipe_r)
        self.sub_stuff['file_desc'].append(run_in_pipe_w)
        self.sub_stuff["run_in_pipe_w"] = run_in_pipe_w
        dkrcmd = AsyncDockerCmd(self.parent_subtest, 'run',
                                self.sub_stuff['subargs'],
                                verbose=True)

        # Runs in background
        self.sub_stuff['cmdresult'] = dkrcmd.execute(run_in_pipe_r)
        self.sub_stuff['cmd_run'] = dkrcmd
        self.wait_interactive_cmd()
        dkrcmd.update_result()
        self.logdebug("Detail after waiting: %s", dkrcmd)

        attach_options = self.config['attach_options_csv'].split(',')
        self.sub_stuff['subargs_a'] = attach_options

        c_name = self.sub_stuff["rand_name"]
        self.sub_stuff["containers"].append(c_name)
        cid = self.sub_stuff["cont"].list_containers_with_name(c_name)

        self.failif(cid == [],
                    "Unable to search container with name %s" % (c_name))
コード例 #8
0
    def _init_container_attached(self, name):
        if self.sub_stuff.get('run_options_csv'):
            subargs = [arg for arg in
                       self.sub_stuff['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")
        subargs.append("-c")
        subargs.append(self.config['exec_cmd'])
        container = DockerCmd(self, 'run', subargs)
        self.sub_stuff['container_cmd'] = container
        mustpass(container.execute())

        if self.sub_stuff.get('attach_options_csv'):
            subargs = [arg for arg in
                       self.sub_stuff['attach_options_csv'].split(',')]
        else:
            subargs = []
        subargs.append(name)
        c_attach = AsyncDockerCmd(self, 'attach', subargs)
        self.sub_stuff['container_cmd'] = c_attach  # overwrites finished cmd
        c_attach.execute()
コード例 #9
0
ファイル: stop.py プロジェクト: Acidburn0zzz/autotest-docker
 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)
コード例 #10
0
ファイル: attach.py プロジェクト: lsm5/autotest-docker
    def initialize(self):
        super(simple_base, self).initialize()
        rand_name = self.sub_stuff["cont"].get_unique_name()
        self.sub_stuff["rand_name"] = rand_name
        self.sub_stuff["subargs"].insert(0, '--name="%s"' % rand_name)

        run_in_pipe_r, run_in_pipe_w = os.pipe()
        self.sub_stuff["file_desc"].append(run_in_pipe_r)
        self.sub_stuff["file_desc"].append(run_in_pipe_w)
        self.sub_stuff["run_in_pipe_w"] = run_in_pipe_w
        dkrcmd = AsyncDockerCmd(self, "run", self.sub_stuff["subargs"], verbose=True)

        # Runs in background
        self.sub_stuff["cmdresult"] = dkrcmd.execute(run_in_pipe_r)
        self.sub_stuff["cmd_run"] = dkrcmd
        self.wait_interactive_cmd()
        self.logdebug("Detail after waiting: %s", dkrcmd.cmdresult)

        attach_options = self.config["attach_options_csv"].split(",")
        self.sub_stuff["subargs_a"] = attach_options

        c_name = self.sub_stuff["rand_name"]
        self.sub_stuff["containers"].append(c_name)
        cid = self.sub_stuff["cont"].list_containers_with_name(c_name)

        self.failif(cid == [], "Unable to search container with name %s" % (c_name))
コード例 #11
0
ファイル: attach.py プロジェクト: lsm5/autotest-docker
    def run_once(self):
        super(simple_base, self).run_once()
        self.loginfo("Starting background docker command, timeout %s seconds", self.config["docker_timeout"])

        attach_in_pipe_r, attach_in_pipe_w = os.pipe()
        self.sub_stuff["file_desc"].append(attach_in_pipe_r)
        self.sub_stuff["file_desc"].append(attach_in_pipe_w)

        self.sub_stuff["subargs_a"].append(self.sub_stuff["rand_name"])

        dkrcmd = AsyncDockerCmd(self, "attach", self.sub_stuff["subargs_a"], verbose=True)
        # Runs in background
        self.sub_stuff["cmd_attach"] = dkrcmd
        self.sub_stuff["cmdresult_attach"] = dkrcmd.execute(attach_in_pipe_r)
        self.wait_interactive_cmd()
        self.logdebug("Before input should be ignored: %s", dkrcmd.cmdresult)

        # This input should be ignored.
        os.write(self.sub_stuff["run_in_pipe_w"], self.config["interactive_cmd_run"] + "\n")

        self.logdebug("Before input should be passed: %s", dkrcmd.cmdresult)
        # This input should be passed to container.
        os.write(attach_in_pipe_w, self.config["interactive_cmd_attach"] + "\n")

        self.wait_interactive_cmd()
        self.logdebug("After input was passsed: %s", dkrcmd.cmdresult)
コード例 #12
0
ファイル: attach.py プロジェクト: lmr/autotest-docker
    def run_once(self):
        super(simple_base, self).run_once()
        self.loginfo("Starting background docker command, timeout %s seconds",
                     self.config['docker_timeout'])

        attach_in_pipe_r, attach_in_pipe_w = os.pipe()
        self.sub_stuff['file_desc'].append(attach_in_pipe_r)
        self.sub_stuff['file_desc'].append(attach_in_pipe_w)

        self.sub_stuff['subargs_a'].append(self.sub_stuff["rand_name"])

        dkrcmd = AsyncDockerCmd(self,
                                'attach',
                                self.sub_stuff['subargs_a'],
                                verbose=True)
        # Runs in background
        self.sub_stuff['cmd_attach'] = dkrcmd
        self.sub_stuff['cmdresult_attach'] = dkrcmd.execute(attach_in_pipe_r)
        self.wait_interactive_cmd()
        self.logdebug("Before input should be ignored: %s", dkrcmd.cmdresult)

        # This input should be ignored.
        os.write(self.sub_stuff["run_in_pipe_w"],
                 self.config['interactive_cmd_run'] + "\n")

        self.logdebug("Before input should be passed: %s", dkrcmd.cmdresult)
        # This input should be passed to container.
        os.write(attach_in_pipe_w,
                 self.config['interactive_cmd_attach'] + "\n")

        self.wait_interactive_cmd()
        self.logdebug("After input was passsed: %s", dkrcmd.cmdresult)
コード例 #13
0
ファイル: attach.py プロジェクト: cevich/autotest-docker
    def initialize(self):
        super(sig_proxy_off_base, self).initialize()
        rand_name = self.sub_stuff['cont'].get_unique_name()

        self.sub_stuff["rand_name"] = rand_name
        self.sub_stuff["subargs"].insert(0, "--name=\"%s\"" % rand_name)

        run_in_pipe_r, run_in_pipe_w = os.pipe()
        self.sub_stuff['file_desc'].append(run_in_pipe_r)
        self.sub_stuff['file_desc'].append(run_in_pipe_w)
        self.sub_stuff["run_in_pipe_w"] = run_in_pipe_w
        dkrcmd = AsyncDockerCmd(self, 'run', self.sub_stuff['subargs'])

        # Runs in background
        self.sub_stuff['cmdresult'] = dkrcmd.execute(run_in_pipe_r)
        self.sub_stuff['cmd_run'] = dkrcmd

        attach_options = self.config['attach_options_csv'].split(',')
        self.sub_stuff['subargs_a'] = attach_options

        self.wait_interactive_cmd()
        c_name = self.sub_stuff["rand_name"]
        self.sub_stuff["containers"].append(c_name)
        cid = self.sub_stuff["cont"].list_containers_with_name(c_name)

        self.failif(cid == [],
                    "Unable to search container with name %s, detail: %s"
                    % (c_name, dkrcmd))
コード例 #14
0
ファイル: attach.py プロジェクト: lsm5/autotest-docker
 def pull_image(self, image_name):
     dkrcmd = AsyncDockerCmd(self, "pull", [image_name], self.config["docker_timeout"], verbose=True)
     self.loginfo("Executing background command: %s" % dkrcmd)
     dkrcmd.execute()
     while not dkrcmd.done:
         self.loginfo("Pulling...")
         time.sleep(3)
     self.failif(dkrcmd.exit_status != 0, "Fail to download image %s" % image_name)
コード例 #15
0
ファイル: pull.py プロジェクト: edsantiago/autotest-docker
 def initialize(self):
     super(pull_base, self).initialize()
     self.sub_stuff['di'] = DockerImages(self)
     image_fn = self.init_image_fn()
     # set by run_once()
     self.sub_stuff['image_list'] = []
     dkrcmd = AsyncDockerCmd(self, 'pull', [image_fn])
     dkrcmd.quiet = False
     self.sub_stuff['dkrcmd'] = dkrcmd
     self.clean_all()
コード例 #16
0
ファイル: history.py プロジェクト: ldoktor/autotest-docker
 def run_once(self):
     super(history_base, self).run_once()
     dkrcmd = AsyncDockerCmd(self, 'history', self.complete_history_cmd(),
                             self.config['docker_history_timeout'])
     self.loginfo("Executing background command: %s" % dkrcmd)
     dkrcmd.execute()
     while not dkrcmd.done:
         self.loginfo("historyting...")
         time.sleep(3)
     self.sub_stuff["cmdresult"] = dkrcmd.wait()
コード例 #17
0
ファイル: tag.py プロジェクト: sibiaoluo/autotest-docker
 def run_once(self):
     super(tag_base, self).run_once()
     dkrcmd = AsyncDockerCmd(self, 'tag',
                             self.complete_docker_command_line())
     self.loginfo("Executing background command: %s" % dkrcmd)
     dkrcmd.execute()
     while not dkrcmd.done:
         self.loginfo("tagging...")
         time.sleep(3)
     self.sub_stuff["cmdresult"] = dkrcmd.wait()
コード例 #18
0
 def pull_image(self, image_name):
     dkrcmd = AsyncDockerCmd(self, 'pull', [image_name],
                             self.config['docker_timeout'])
     self.loginfo("Executing background command: %s" % dkrcmd)
     dkrcmd.execute()
     while not dkrcmd.done:
         self.loginfo("Pulling...")
         time.sleep(3)
     self.failif_ne(dkrcmd.exit_status, 0,
                    "Fail to download image %s" % image_name)
コード例 #19
0
 def run_once(self):
     super(history_base, self).run_once()
     dkrcmd = AsyncDockerCmd(self, 'history', self.complete_history_cmd(),
                             self.config['docker_history_timeout'])
     self.loginfo("Executing background command: %s" % dkrcmd)
     dkrcmd.execute()
     while not dkrcmd.done:
         self.loginfo("historyting...")
         time.sleep(3)
     self.sub_stuff["cmdresult"] = dkrcmd.wait()
コード例 #20
0
ファイル: pull.py プロジェクト: huyanhua/autotest-docker
 def initialize(self):
     super(pull_base, self).initialize()
     self.sub_stuff['di'] = DockerImages(self)
     image_fn = self.init_image_fn()
     # set by run_once()
     self.sub_stuff['image_list'] = []
     dkrcmd = AsyncDockerCmd(self, 'pull', [image_fn])
     dkrcmd.quiet = False
     self.sub_stuff['dkrcmd'] = dkrcmd
     self.clean_all()
コード例 #21
0
 def run_once(self):
     super(commit_base, self).run_once()
     dkrcmd = AsyncDockerCmd(self.parent_subtest, 'commit',
                             self.complete_docker_command_line(),
                             self.config['docker_commit_timeout'])
     self.loginfo("Executing background command: %s" % dkrcmd)
     dkrcmd.execute()
     while not dkrcmd.done:
         self.loginfo("Commiting...")
         time.sleep(3)
     self.sub_stuff["cmdresult"] = dkrcmd.wait()
コード例 #22
0
ファイル: start.py プロジェクト: chuanchang/autotest-docker
 def run_once(self):
     super(start_base, self).run_once()
     # 1. Run with no options
     dkrcmd = AsyncDockerCmd(self, 'start',
                             self.complete_docker_command_line(),
                             self.config['docker_start_timeout'])
     self.loginfo("Starting container...")
     self.loginfo("Executing background command: %s" % dkrcmd.command)
     dkrcmd.execute()
     dkrcmd.wait(60)
     self.sub_stuff["dkrcmd"] = dkrcmd
コード例 #23
0
ファイル: expose.py プロジェクト: edsantiago/autotest-docker
 def start_test_container(self, read_fd, write_fd):
     dc = self.sub_stuff["dc"]
     name = dc.get_unique_name()
     subargs = ["--interactive", "--publish-all", "--name", name, self.sub_stuff["builds"][-1].image_name, "sh"]
     async_dkrcmd = AsyncDockerCmd(self, "run", subargs)
     self.sub_stuff["async_dkrcmd"] = async_dkrcmd
     async_dkrcmd.execute(read_fd)
     os.close(read_fd)
     os.write(write_fd, 'echo "StArTeD!"\n')
     self.failif(not wait_for_output(lambda: async_dkrcmd.stdout, "StArTeD!", timeout=10), str(async_dkrcmd))
     return name
コード例 #24
0
 def postprocess(self):
     super(simple, self).postprocess()
     name = self.sub_stuff['container_name']
     logs = AsyncDockerCmd(self, "logs", ['-f', name])
     logs.execute()
     utils.wait_for(lambda: logs.stdout.count("\n") == 2, 5, step=0.1)
     out = logs.stdout
     self.failif(out.count("\n") != 2, "The container was executed twice, "
                 "there should be 2 lines with start dates, but is "
                 "%s.\nContainer output:\n%s" % (out.count("\n"), out))
     mustpass(DockerCmd(self, "kill", [name]).execute())
コード例 #25
0
ファイル: attach.py プロジェクト: cevich/autotest-docker
 def pull_image(self, image_name):
     dkrcmd = AsyncDockerCmd(self, 'pull', [image_name],
                             self.config['docker_timeout'])
     self.loginfo("Executing background command: %s" % dkrcmd)
     dkrcmd.execute()
     while not dkrcmd.done:
         self.loginfo("Pulling...")
         time.sleep(3)
     self.failif_ne(dkrcmd.exit_status, 0,
                    "Fail to download image %s"
                    % image_name)
コード例 #26
0
ファイル: start.py プロジェクト: Lorquas/autotest-docker
 def run_once(self):
     super(start_base, self).run_once()
     # 1. Run with no options
     dkrcmd = AsyncDockerCmd(self.parent_subtest, 'start',
                             self.complete_docker_command_line(),
                             self.config['docker_start_timeout'])
     self.loginfo("Executing background command: %s" % dkrcmd)
     dkrcmd.execute()
     while not dkrcmd.done:
         self.loginfo("Starting container...")
         time.sleep(3)
     self.sub_stuff["cmdresult"] = dkrcmd.wait()
コード例 #27
0
ファイル: rmi.py プロジェクト: zerolugithub/autotest-docker
 def run_once(self):
     super(rmi_base, self).run_once()
     # 1. Run with no options
     dkrcmd = AsyncDockerCmd(self, 'rmi',
                             self.complete_docker_command_line(),
                             self.config['docker_rmi_timeout'], True)
     self.loginfo("Executing background command: %s" % dkrcmd)
     dkrcmd.execute()
     while not dkrcmd.done:
         self.loginfo("Deleting image...")
         time.sleep(3)
     self.sub_stuff["cmdresult"] = dkrcmd.wait()
コード例 #28
0
ファイル: rmi.py プロジェクト: cevich/autotest-docker
 def run_once(self):
     super(rmi_base, self).run_once()
     # 1. Run with no options
     dkrcmd = AsyncDockerCmd(self, 'rmi',
                             self.complete_docker_command_line(),
                             self.config['docker_rmi_timeout'],
                             True)
     self.loginfo("Executing background command: %s" % dkrcmd)
     dkrcmd.execute()
     while not dkrcmd.done:
         self.loginfo("Deleting image...")
         time.sleep(3)
     self.sub_stuff["cmdresult"] = dkrcmd.wait()
コード例 #29
0
ファイル: build.py プロジェクト: xiaoqing-wei/autotest-docker
 def run_once(self):
     super(build, self).run_once()
     subargs = [self.config['docker_build_options'],
                "-t", self.stuff['image_name_tag'],
                self.srcdir]
     # Don't really need async here, just exercizing class
     dkrcmd = AsyncDockerCmd(self, 'build', subargs,
                             self.config['build_timeout_seconds'])
     self.loginfo("Executing background command: %s" % dkrcmd)
     dkrcmd.execute()
     while not dkrcmd.done:
         self.loginfo("Building...")
         time.sleep(3)
     self.stuff["cmdresult"] = dkrcmd.wait()
コード例 #30
0
ファイル: attach.py プロジェクト: Lorquas/autotest-docker
    def run_once(self):
        super(simple_base, self).run_once()
        self.loginfo("Starting background docker command, timeout %s seconds",
                     self.config['docker_timeout'])

        attach_in_pipe_r, attach_in_pipe_w = os.pipe()
        self.sub_stuff['file_desc'].append(attach_in_pipe_r)
        self.sub_stuff['file_desc'].append(attach_in_pipe_w)

        self.sub_stuff['subargs_a'].append(self.sub_stuff["rand_name"])

        dkrcmd = AsyncDockerCmd(self.parent_subtest, 'attach',
                                self.sub_stuff['subargs_a'],
                                verbose=True)
        # Runs in background
        self.sub_stuff['cmd_attach'] = dkrcmd
        self.sub_stuff['cmdresult_attach'] = dkrcmd.execute(attach_in_pipe_r)
        self.wait_interactive_cmd()
        dkrcmd.update_result()
        self.logdebug("Before input should be ignored: %s", dkrcmd)

        # This input should be ignored.
        os.write(self.sub_stuff["run_in_pipe_w"],
                 self.config['interactive_cmd_run'] + "\n")

        dkrcmd.update_result()
        self.logdebug("Before input should be passed: %s", dkrcmd)
        # This input should be passed to container.
        os.write(attach_in_pipe_w,
                 self.config['interactive_cmd_attach'] + "\n")

        self.wait_interactive_cmd()
        dkrcmd.update_result()
        self.logdebug("After input was passsed: %s", dkrcmd)
コード例 #31
0
ファイル: run_sigproxy.py プロジェクト: afomm/autotest-docker
 def _init_container_normal(self, name):
     if self.sub_stuff.get("run_options_csv"):
         subargs = [arg for arg in self.sub_stuff["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")
     subargs.append("-c")
     subargs.append(self.config["exec_cmd"])
     container = AsyncDockerCmd(self, "run", subargs)
     self.sub_stuff["container_cmd"] = container
     container.execute()
コード例 #32
0
ファイル: expose.py プロジェクト: chuanchang/autotest-docker
 def start_test_container(self, read_fd, write_fd):
     dc = self.sub_stuff['dc']
     name = dc.get_unique_name()
     subargs = ['--interactive', '--publish-all',
                '--name', name, self.sub_stuff['builds'][-1].image_name,
                'sh']
     async_dkrcmd = AsyncDockerCmd(self, 'run', subargs)
     self.sub_stuff['async_dkrcmd'] = async_dkrcmd
     async_dkrcmd.execute(read_fd)
     os.close(read_fd)
     os.write(write_fd, 'echo "StArTeD!"\n')
     self.failif(not wait_for_output(lambda: async_dkrcmd.stdout,
                                     "StArTeD!",
                                     timeout=10), str(async_dkrcmd))
     return name
コード例 #33
0
ファイル: run_exec.py プロジェクト: cevich/autotest-docker
 def start_base_container(self):
     reader, writer = os.pipe()
     # Exception could occur before os.close(reader) below
     self.sub_stuff['fds'].append(reader)
     self.sub_stuff['fds'].append(writer)
     self.sub_stuff['dkrcmd_stdin'] = writer
     dkrcmd = AsyncDockerCmd(self, 'run', self.sub_stuff['run_args'])
     dkrcmd.execute(reader)
     self.sub_stuff['containers'].append(self.sub_stuff['run_name'])
     os.close(reader)  # not needed anymore
     self.sub_stuff['dkrcmd'] = dkrcmd
     os.write(writer, 'echo "Started"\n')
     if not wait_for_output(lambda: dkrcmd.stdout, "Started"):
         raise DockerTestFail("Unable to start base container:\n %s" %
                              (dkrcmd))
コード例 #34
0
 def start_base_container(self):
     reader, writer = os.pipe()
     # Exception could occur before os.close(reader) below
     self.sub_stuff['fds'].append(reader)
     self.sub_stuff['fds'].append(writer)
     self.sub_stuff['dkrcmd_stdin'] = writer
     dkrcmd = AsyncDockerCmd(self, 'run', self.sub_stuff['run_args'])
     dkrcmd.execute(reader)
     self.sub_stuff['containers'].append(self.sub_stuff['run_name'])
     os.close(reader)  # not needed anymore
     self.sub_stuff['dkrcmd'] = dkrcmd
     os.write(writer, 'echo "Started"\n')
     if not wait_for_output(lambda: dkrcmd.stdout, "Started"):
         raise DockerTestFail("Unable to start base container:\n %s" %
                              (dkrcmd))
コード例 #35
0
 def _init_container_normal(self, name):
     if self.sub_stuff.get('run_options_csv'):
         subargs = [arg for arg in
                    self.sub_stuff['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")
     subargs.append("-c")
     subargs.append(self.config['exec_cmd'])
     container = AsyncDockerCmd(self, 'run', subargs)
     self.sub_stuff['container_cmd'] = container
     container.execute()
コード例 #36
0
 def _init_container_normal(self, name):
     if self.sub_stuff.get('run_options_csv'):
         subargs = [arg for arg in
                    self.sub_stuff['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")
     subargs.append("-c")
     subargs.append(self.config['exec_cmd'])
     container = AsyncDockerCmd(self, 'run', subargs)
     self.sub_stuff['container_cmd'] = container
     container.execute()
コード例 #37
0
ファイル: psa.py プロジェクト: zerolugithub/autotest-docker
 def initialize(self):
     super(psa, self).initialize()
     dc = self.stuff['dc'] = DockerContainers(self)
     dc.verify_output = True  # test subject, do extra checking
     name = self.stuff['container_name'] = dc.get_unique_name()
     cidfile = os.path.join(self.tmpdir, 'cidfile')
     self.stuff['cidfile'] = cidfile
     subargs = ['--cidfile', cidfile, '--name=%s' % name]
     fin = images.DockerImage.full_name_from_defaults(self.config)
     subargs.append(fin)
     subargs.append('/bin/bash')
     subargs.append('-c')
     # Write to a file when signal received
     # Loop forever until marker-file exists
     command = ("\""
                "echo 'foobar' > stop && "
                "rm -f stop && trap '/usr/bin/date +%%s> stop' USR1 && "
                "while ! [ -f stop ]; do /usr/bin/sleep 0.1s; done"
                "\"")
     subargs.append(command)
     self.stuff['cl0'] = dc.list_containers()
     dkrcmd = AsyncDockerCmd(self, 'run', subargs)
     self.stuff['dkrcmd'] = dkrcmd
     if os.path.isfile(cidfile):
         os.unlink(cidfile)
コード例 #38
0
    def _init_container_attached(self, name):
        if self.sub_stuff.get('run_options_csv'):
            subargs = [
                arg for arg in self.sub_stuff['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")
        subargs.append("-c")
        subargs.append(self.config['exec_cmd'])
        container = DockerCmd(self, 'run', subargs)
        self.sub_stuff['container_cmd'] = container
        mustpass(container.execute())

        if self.sub_stuff.get('attach_options_csv'):
            subargs = [
                arg for arg in self.sub_stuff['attach_options_csv'].split(',')
            ]
        else:
            subargs = []
        subargs.append(name)
        container = AsyncDockerCmd(self, 'attach', subargs)
        self.sub_stuff['container_cmd'] = container  # overwrites finished cmd
        container.execute()
コード例 #39
0
    def run_once(self):
        super(cp_symlink, self).run_once()

        self.sub_stuff['cname'] = DockerContainers(self).get_unique_name()

        # Run a container. It will wait for the presence of a signal file,
        # then check for presence of the xfer file and compare its contents
        # to the expected value. Different exit codes (tested in postprocess)
        # mean different errors.
        destdir = self.config['destdir']
        command = ('\'ln -s /tmp /mylink; echo READY; while [ ! -f /stop ]; do sleep 0.2s; done; xfer_file=%s/%s; test -f $xfer_file || exit 4; actual=$(< $xfer_file); expect="%s"; test "$actual" = "$expect" && exit 0; echo $xfer_file: bad content "$actual" - expected "$expect";exit 5\'' % (destdir, self.sub_stuff['xfer_file'], self.sub_stuff['xfer_content']))
        subargs = [ '--name=%s' % self.sub_stuff['cname'],
                    DockerImage.full_name_from_defaults(self.config),
                    '/bin/bash', '-c', command]
        self.sub_stuff['dkrcmd'] = AsyncDockerCmd(self, 'run', subargs)
        self.sub_stuff['dkrcmd'].execute()
        self.sub_stuff['dkrcmd'].wait_for_ready()

        # First: copy the desired destination file
        cp_dest = self.config['cp_dest']
        if '%' in cp_dest:
            cp_dest = cp_dest % self.sub_stuff['xfer_file']
        subargs = [ self.sub_stuff['xfer_file_local'],
                    "%s:%s" % (self.sub_stuff['cname'], cp_dest) ]
        mustpass(DockerCmd(self, 'cp', subargs).execute())

        # Second: create the signal file that tells the container to stop.
        # We don't use the content file as signal, first, because we
        # don't know if docker-cp is atomic, i.e. if we can have a race
        # condition where the destfile exists but does not have content;
        # and second, because there are situations in which docker-cp
        # to / (root) works but /tmp or /mylink->/tmp does not.
        subargs[1] = '%s:/stop' % self.sub_stuff['cname']
        mustpass(DockerCmd(self, 'cp', subargs).execute())
コード例 #40
0
ファイル: liverestore.py プロジェクト: cevich/autotest-docker
    def _start_container(self):
        """
        Start a container. All it does is emit output to stdout, one
        line per second. We don't care what the output is, we just
        care that the number of output lines increases over time.
        """
        c_name = self.stuff['dc'].get_unique_name()

        fin = DockerImage.full_name_from_defaults(self.config)
        subargs = ['--detach', '--name=' + c_name, fin,
                   'bash -c "echo READY;'
                   ' while :; do date +%s; sleep 1;done"']
        dkrcmd = AsyncDockerCmd(self, 'run', subargs)
        dkrcmd.execute()
        dkrcmd.wait_for_ready(c_name)
        self.stuff['container_name'] = c_name
コード例 #41
0
 def start_test_container(self, read_fd, write_fd):
     dc = self.sub_stuff['dc']
     name = dc.get_unique_name()
     subargs = [
         '--interactive', '--publish-all', '--name', name,
         self.sub_stuff['builds'][-1].image_name, 'sh'
     ]
     async_dkrcmd = AsyncDockerCmd(self, 'run', subargs)
     self.sub_stuff['async_dkrcmd'] = async_dkrcmd
     async_dkrcmd.execute(read_fd)
     os.close(read_fd)
     os.write(write_fd, 'echo "StArTeD!"\n')
     self.failif(
         not wait_for_output(
             lambda: async_dkrcmd.stdout, "StArTeD!", timeout=10),
         str(async_dkrcmd))
     return name
コード例 #42
0
ファイル: build.py プロジェクト: Acidburn0zzz/autotest-docker
 def run_once(self):
     super(build, self).run_once()
     subargs = [self.config['docker_build_options'],
                "-t", self.stuff['image_name_tag'],
                self.srcdir]
     # Don't really need async here, just exercizing class
     dkrcmd = AsyncDockerCmd(self, 'build', subargs,
                             self.config['build_timeout_seconds'],
                             verbose=True)
     dkrcmd.execute()
     nss = NotSeenString(getattr, dkrcmd, 'stdout')
     while not dkrcmd.done:
         if nss.has_new_line():
             self.loginfo("Building: %s" % nss)
         else:
             time.sleep(3)
     self.stuff["cmdresult"] = dkrcmd.wait()
コード例 #43
0
    def run_once(self):
        self.loginfo("Starting background docker command, timeout %s seconds",
                     self.config['docker_timeout'])

        in_pipe_r, in_pipe_w = os.pipe()
        dkrcmd = AsyncDockerCmd(self, 'run', self.sub_stuff['subargs'],
                                timeout=self.config['docker_timeout'])
        dkrcmd.verbose = True
        dkrcmd.timeout = 10
        # Runs in background
        dkrcmd.execute(in_pipe_r)
        self.sub_stuff['dkrcmd'] = dkrcmd
        wait = self.config['wait_interactive_cmd']
        icmd = self.config['interactive_cmd'] + "\n"
        # Allow noticable time difference for date command,
        # and eat into dkrcmd timeout after receiving signal.
        time.sleep(wait)
        os.write(in_pipe_w, icmd)

        self.loginfo("Waiting up to %d seconds for exit",
                     dkrcmd.timeout)
        # Throw exception if takes > docker_timeout to exit

        self.loginfo("Container running, waiting %d seconds to finish.", wait)
        self.logdebug("interactive cmds %s", icmd)
        time.sleep(wait)
        os.close(in_pipe_w)
        dkrcmd.wait()
コード例 #44
0
 def _start_container(self, name):
     """ Create, store in self.sub_stuff and execute container """
     self.sub_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")
     subargs.append("-c")
     subargs.append("'echo STARTED: $(date); while :; do sleep 0.1; done'")
     container = AsyncDockerCmd(self, 'run', subargs)
     container.execute()
     utils.wait_for(lambda: container.stdout.startswith("STARTED"), 5,
                    step=0.1)
コード例 #45
0
ファイル: attach.py プロジェクト: lsm5/autotest-docker
    def run_once(self):
        super(sig_proxy_off_base, self).run_once()
        self.loginfo("Starting background docker command, timeout %s seconds", self.config["docker_timeout"])

        self.sub_stuff["subargs_a"].append(self.sub_stuff["rand_name"])

        dkrcmd = AsyncDockerCmd(self, "attach", self.sub_stuff["subargs_a"], verbose=True)
        # Runs in background
        self.sub_stuff["cmd_attach"] = dkrcmd
        self.sub_stuff["cmdresult_attach"] = dkrcmd.execute()

        self.wait_interactive_cmd()

        pid = dkrcmd.process_id
        os.kill(pid, int(self.config["signal"]))

        self.wait_interactive_cmd()
        self.logdebug("After the killing: %s", dkrcmd.cmdresult)
コード例 #46
0
    def run_once(self):
        super(sig_proxy_off_base, self).run_once()
        self.loginfo("Starting background docker command, timeout %s seconds",
                     self.config['docker_timeout'])

        self.sub_stuff['subargs_a'].append(self.sub_stuff["rand_name"])

        dkrcmd = AsyncDockerCmd(self, 'attach', self.sub_stuff['subargs_a'])
        # Runs in background
        self.sub_stuff['cmd_attach'] = dkrcmd
        self.sub_stuff['cmdresult_attach'] = dkrcmd.execute()

        self.wait_interactive_cmd()

        pid = dkrcmd.process_id
        os.kill(pid, int(self.config["signal"]))

        self.wait_interactive_cmd()
        self.logdebug("After the killing: %s", dkrcmd.cmdresult)
コード例 #47
0
 def _init_container_normal(self, name):
     """
     Starts container
     """
     if self.config.get('run_options_csv'):
         subargs = [
             arg for arg in self.config['run_options_csv'].split(',')
         ]
     else:
         subargs = []
     if self.tty:
         subargs.append('--tty=true')
     else:
         subargs.append('--tty=false')
     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, verbose=False)
     self.sub_stuff['container_cmd'] = container
     container.execute()
コード例 #48
0
ファイル: wait.py プロジェクト: zerolugithub/autotest-docker
 def run_once(self):
     super(WaitBase, self).run_once()
     sss = self.sub_stuff
     subargs = [target.name for target in sss['targets']]
     # timeout set automatically from docker_timeout
     sss['dkrcmd'] = AsyncDockerCmd(self,
                                    'wait',
                                    subargs,
                                    verbose=self.config['wait_verbose'])
     self.execute_targets()
     sss['dkrcmd'].execute()
     self.execute_target_waits()
     sss['dkrcmd'].wait(self.config['docker_timeout'])
     self.finish_target_waits()
コード例 #49
0
 def run_once(self):
     super(start_base, self).run_once()
     # 1. Run with no options
     dkrcmd = AsyncDockerCmd(self, 'start',
                             self.complete_docker_command_line(),
                             self.config['docker_start_timeout'])
     self.loginfo("Starting container...")
     self.loginfo("Executing background command: %s" % dkrcmd.command)
     dkrcmd.execute()
     dkrcmd.wait(60)
     self.sub_stuff["dkrcmd"] = dkrcmd
コード例 #50
0
 def start_test_container(self, read_fd, write_fd):
     dc = self.sub_stuff['dc']
     name = dc.get_unique_name()
     subargs = [
         '--interactive', '--publish-all', '--name', name,
         self.sub_stuff['builds'][-1].image_name, 'sh'
     ]
     async_dkrcmd = AsyncDockerCmd(self, 'run', subargs)
     self.sub_stuff['async_dkrcmd'] = async_dkrcmd
     async_dkrcmd.execute(read_fd)
     os.close(read_fd)
     os.write(write_fd, b'\necho "R""EADY"\n')
     async_dkrcmd.wait_for_ready()
     return name
コード例 #51
0
 def initialize(self):
     super(volumes_one_source, self).initialize()
     num_containers = self.config['num_containers']
     commands = []
     self.sub_stuff['names'] = []
     exec_command = self.config['exec_command']
     cntr_path = self.config['cntr_path']
     host_path = self.tmpdir
     self.set_selinux_context(self, host_path)
     vols = ['--volume="%s:%s:z"' % (host_path, cntr_path)]
     fqin = [DockerImage.full_name_from_defaults(self.config)]
     for _ in range(num_containers):
         name = utils.generate_random_string(12)
         template_keys = {'write_path': os.path.join(cntr_path, name),
                          'name': name}
         self.sub_stuff['names'] += [name]
         cmd = [exec_command % template_keys]
         subargs = ['--name=%s' % (name)] + vols + fqin + cmd
         commands.append(AsyncDockerCmd(self, 'run', subargs))
     self.sub_stuff['commands'] = commands
コード例 #52
0
    def _start_container(self):
        """
        Start a container. All it does is emit output to stdout, one
        line per second. We don't care what the output is, we just
        care that the number of output lines increases over time.
        """
        c_name = self.stuff['dc'].get_unique_name()

        fin = DockerImage.full_name_from_defaults(self.config)
        subargs = ['--detach', '--name=' + c_name, fin,
                   'bash -c "echo READY;'
                   ' while :; do date +%s; sleep 1;done"']
        dkrcmd = AsyncDockerCmd(self, 'run', subargs)
        dkrcmd.execute()
        dkrcmd.wait_for_ready(c_name)
        self.stuff['container_name'] = c_name
コード例 #53
0
ファイル: wait.py プロジェクト: zerolugithub/autotest-docker
 def target_wait_dkrcmd(self, name, fqin, setup, wait_opr, sleep):
     del sleep  # not used for now
     del setup  # not used for now
     del fqin  # not used for now
     if wait_opr == 'stop':
         cmd = 'stop'
         subargs = [name]
     elif wait_opr == 'kill':
         cmd = 'kill'
         subargs = [name]
     elif wait_opr == 'remv':
         cmd = 'rm'
         subargs = ['--force', '--volumes', name]
     elif wait_opr == 'none':
         return None
     elif wait_opr.isdigit():
         cmd = 'kill'
         subargs = ['--signal', wait_opr, name]
     else:
         raise ValueError("Unsupported target_wait %s for target %s" %
                          (wait_opr, name))
     return AsyncDockerCmd(self, cmd, subargs,
                           self.config['target_verbose'])
コード例 #54
0
 def initialize(self):
     super(events, self).initialize()
     dc = self.stuff['dc'] = DockerContainers(self)
     fullname = dc.get_unique_name()
     fqin = DockerImage.full_name_from_defaults(self.config)
     # generic args have spots for some value substitution
     mapping = {'NAME': fullname, 'IMAGE': fqin}
     subargs = []
     for arg in self.config['run_args'].strip().split(','):
         tmpl = Template(arg)
         # Ignores placeholders not in mapping
         subargs.append(tmpl.safe_substitute(mapping))
     # test container executed later
     self.stuff['nfdc'] = DockerCmd(self, 'run', subargs)
     self.stuff['nfdc_cid'] = None
     # docker events command executed later
     events_cmd = AsyncDockerCmd(self, 'events', ['--since=0'])
     self.stuff['events_cmd'] = events_cmd
     self.stuff['events_cmdresult'] = None
     # These will be removed as expected events for cid are identified
     leftovers = self.config['expect_events'].strip().split(',')
     self.stuff['leftovers'] = leftovers
     for key, value in self.stuff.items():
         self.logdebug("init %s = %s", key, value)
コード例 #55
0
    def _start_idle_container(self):
        """
        Start a container. We only need it briefly, until we (the test,
        running in host space) can cd into its root filesystem. Container
        will spin idly until a semaphore file is removed.
        """
        c_name = self.stuff['dc'].get_unique_name()

        fin = DockerImage.full_name_from_defaults(self.config)
        self.stuff['trigger_file'] = trigger_file = 'DELETE-ME'
        subargs = [
            '--rm', '--name=' + c_name, fin,
            'bash -c "echo READY;touch /%s;'
            ' while [ -e /%s ]; do sleep 0.1; done"' %
            (trigger_file, trigger_file)
        ]
        dkrcmd = AsyncDockerCmd(self, 'run', subargs)
        dkrcmd.execute()
        dkrcmd.wait_for_ready(c_name)
        self.stuff['container_name'] = c_name
コード例 #56
0
ファイル: namespaces.py プロジェクト: wubob/autotest-docker
    def run_once(self):
        """
        Run a background container with --rm; while that's running, clone
        another process sharing the same mount namespace. That process
        will signal the container to finish, and when docker cleans it
        up (--rm) we expect no errors.
        """
        super(rmdir_mount, self).run_once()
        fin = DockerImage.full_name_from_defaults(self.config)
        name = DockerContainers(self).get_unique_name()

        # Create a state file; container will exit once this is deleted
        waitfile = 'state_file_for_signaling_the_container_to_exit'
        waitfile_local = os.path.join(self.tmpdir, waitfile)
        open(waitfile_local, 'a').close()

        # Basically: mount self.tmpdir as /tmp in container, constantly
        # check the state file, exit when it's deleted, then (--rm) have
        # docker clean it up.
        subargs = [
            '--rm', '-v',
            '%s:/tmp:z' % self.tmpdir, '--name', name, fin, 'bash', '-c',
            "'echo READY; while [ -e /tmp/%s ]; do sleep 0.1; done'" % waitfile
        ]
        dkrcmd = AsyncDockerCmd(self, 'run', subargs)
        self.sub_stuff['dkrcmd'] = dkrcmd
        dkrcmd.execute()
        dkrcmd.wait_for_ready(name, timeout=5)

        # Container is running. Now, in parallel: clone, delete state file,
        # and wait for container to terminate.
        in_n = ("rm -f %s;"
                " while :;do"
                "   docker inspect %s 2>/dev/null || exit 0;"
                " done" % (waitfile_local, name))
        self.sub_stuff['unshare'] = utils.run("unshare -m bash -c '%s'" % in_n)
コード例 #57
0
 def init_dockercmd(self):
     in_pipe_r, in_pipe_w = os.pipe()
     self.sub_stuff['stdin'] = in_pipe_r
     self.sub_stuff['stdin_write'] = in_pipe_w
     dkrcmd = AsyncDockerCmd(self, 'run', self.sub_stuff['subargs'])
     self.sub_stuff['dkrcmd'] = dkrcmd
コード例 #58
0
 def init_dkrcmd(self):
     subargs = self.sub_stuff['subargs']
     self.sub_stuff['dkrcmd'] = AsyncDockerCmd(self, 'run', subargs)
     self.logdebug("Initialized command: %s", self.sub_stuff['dkrcmd'])