コード例 #1
0
ファイル: utils.py プロジェクト: khattori/kimpira
def run_command(command, node=None, account=None, sudo=False, host=None, user=None, password=None, warn_only=False):
    managers = _get_context(node, account, sudo, host, user, password)
    if warn_only:
        managers.append(settings(warn_only=True))
    with nested(*managers):
        if node or host:
            try:
                if sudo:
                    return sudo_run(command)
                else:
                    return run(command)
            except NetworkError, e:
                return ErrorResult(e)
        else:
コード例 #2
0
ファイル: utils.py プロジェクト: khattori/kimpira
def run_script(script_file, args, node, account=None, sudo=False, host=None, user=None, password=None):
    managers = _get_context(node, account, sudo, host, user, password)
    with nested(*managers):
        try:
            remote_path = run('mktemp')
            try:
                put(script_file, remote_path, mirror_local_mode=True)
                command = remote_path + ' ' + args
                if sudo:
                    return sudo_run(command)
                else:
                    return run(command)
            finally:
                run('rm %s' % remote_path)
        except NetworkError, e:
            return ErrorResult(e)
コード例 #3
0
ファイル: utils.py プロジェクト: khattori/kimpira
def run_command(command,
                node=None,
                account=None,
                sudo=False,
                host=None,
                user=None,
                password=None,
                warn_only=False):
    managers = _get_context(node, account, sudo, host, user, password)
    if warn_only:
        managers.append(settings(warn_only=True))
    with nested(*managers):
        if node or host:
            try:
                if sudo:
                    return sudo_run(command)
                else:
                    return run(command)
            except NetworkError, e:
                return ErrorResult(e)
        else:
コード例 #4
0
ファイル: utils.py プロジェクト: khattori/kimpira
def run_script(script_file,
               args,
               node,
               account=None,
               sudo=False,
               host=None,
               user=None,
               password=None):
    managers = _get_context(node, account, sudo, host, user, password)
    with nested(*managers):
        try:
            remote_path = run('mktemp')
            try:
                put(script_file, remote_path, mirror_local_mode=True)
                command = remote_path + ' ' + args
                if sudo:
                    return sudo_run(command)
                else:
                    return run(command)
            finally:
                run('rm %s' % remote_path)
        except NetworkError, e:
            return ErrorResult(e)