Ejemplo n.º 1
0
    def run_cephfs_shell_script(self,
                                script,
                                mount_x=None,
                                shell_conf_path=None,
                                opts=None,
                                stdout=None,
                                stderr=None,
                                stdin=None,
                                check_status=True):
        stdout = stdout or StringIO()
        stderr = stderr or StringIO()
        if mount_x is None:
            mount_x = self.mount_a

        scriptpath = tempfile_mkstemp(prefix='test-cephfs', text=True)[1]
        with open(scriptpath, 'w') as scriptfile:
            scriptfile.write(script)
        # copy script to the machine running cephfs-shell.
        mount_x.client_remote.put_file(scriptpath, scriptpath)
        mount_x.run_shell('chmod 755 ' + scriptpath)

        args = ["cephfs-shell", '-b', scriptpath]
        if shell_conf_path:
            args[1:1] = ["-c", shell_conf_path]
        log.info('Running script \"' + scriptpath + '\"')
        return mount_x.client_remote.run(args=args,
                                         stdout=stdout,
                                         stderr=stderr,
                                         stdin=stdin,
                                         check_status=True)
Ejemplo n.º 2
0
    def run_cephfs_shell_script(self, script, mount_x=None, stdin=None):
        if mount_x is None:
            mount_x = self.mount_a

        scriptpath = tempfile_mkstemp(prefix='test-cephfs', text=True)[1]
        with open(scriptpath, 'w') as scriptfile:
            scriptfile.write(script)
        # copy script to the machine running cephfs-shell.
        mount_x.client_remote.put_file(scriptpath, scriptpath)
        mount_x.run_shell('chmod 755 ' + scriptpath)

        args = ["cephfs-shell", "-c", mount_x.config_path, '-b', scriptpath]
        log.info('Running script \"' + scriptpath + '\"')
        return mount_x.client_remote.run(args=args, stdout=StringIO(),
                                         stderr=StringIO(), stdin=stdin)