當前位置: 首頁>>代碼示例>>Python>>正文


Python api.execute方法代碼示例

本文整理匯總了Python中fabric.api.execute方法的典型用法代碼示例。如果您正苦於以下問題:Python api.execute方法的具體用法?Python api.execute怎麽用?Python api.execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fabric.api的用法示例。


在下文中一共展示了api.execute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_command

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def run_command(self, hosts, parallel_pool_size=1):
        from fabric.api import execute, sudo, env, parallel
        if env.ssh_config_path and os.path.isfile(os.path.expanduser(env.ssh_config_path)):
            env.use_ssh_config = True
        env.forward_agent = True
        # pass `-E` to sudo to preserve environment for ssh agent forwarding
        env.sudo_prefix = "sudo -SE -p '%(sudo_prompt)s' "
        env.user = self.user_name
        env.password = self.password
        env.hosts = hosts
        env.warn_only = True

        def _task():
            result = sudo(self.command, user=self.user_as)
            return result

        task = _task
        if parallel_pool_size > 1:
            task = parallel(pool_size=parallel_pool_size)(_task)

        res = execute(task)
        return res 
開發者ID:dimagi,項目名稱:commcare-cloud,代碼行數:24,代碼來源:utils.py

示例2: getrunning

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def getrunning(config):
    """
    Gets all the running Cassandra processes so you know if C* is fully running across the cluster
    """
    _set_hosts(config)
    results = execute(_getpid)
    i = 1
    completed = 0
    for host, result in results.items():
        print "host {} [{}] pid is [{}]".format(i, host, result.strip())
        i += 1
        if len(result) > 1:
            completed += 1

    print "-"*50
    print "{} out of {} hosts are running C*".format(completed, len(results))
    print "-"*50 
開發者ID:CrowdStrike,項目名稱:cassandra-tools,代碼行數:19,代碼來源:fabfile.py

示例3: _bootstrapcass

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def _bootstrapcass():

    # FIX HOSTS FILE for metrics to record remote IP properly
    host  = 'ip-%s' % env.host_string.replace('.','-')
    sudo('sed -i "/127/c\\127.0.0.1 {} localhost" /etc/hosts'.format(host))

    sudo("apt-get update")

    # install required packages
    sudo("""apt-get -y install --fix-missing libjna-java binutils pssh pbzip2 xfsprogs schedtool zip unzip ruby openssl ruby-dev libruby1.9.1 curl liblzo2-dev ntp subversion python-pip  unzip xfsprogs ethtool""")

    # install sysadmin tools
    sudo("apt-get -y install --fix-missing iftop sysstat htop s3cmd nethogs nmon dstat tree collectd collectd-utils")

    execute(_installjava)

    #fix clocksource -> network performance
    sudo("echo tsc > /sys/devices/system/clocksource/clocksource0/current_clocksource") 
開發者ID:CrowdStrike,項目名稱:cassandra-tools,代碼行數:20,代碼來源:fabfile.py

示例4: swarm_init

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def swarm_init():
    """
    enable Docker swarm mode
    """
    def init():
        if not init.join_command:
            fabricio.run(
                'docker swarm init --advertise-addr {0}'.format(fab.env.host),
                ignore_errors=True,
                quiet=False,
            )
            join_token = fabricio.run(
                'docker swarm join-token --quiet manager',
                ignore_errors=True,
            )
            init.join_command = (
                'docker swarm join --token {join_token} {host}:2377'
            ).format(join_token=join_token, host=fab.env.host)
        else:
            fabricio.run(init.join_command, ignore_errors=True, quiet=False)

    init.join_command = None
    with fab.settings(hosts=hosts):
        fab.execute(init) 
開發者ID:renskiy,項目名稱:fabricio,代碼行數:26,代碼來源:fabfile.py

示例5: execute

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def execute(*args, **kwargs):  # pragma: no cover
    warnings.warn(
        'fabricio.execute() is deprecated in favour of fabric.api.execute()',
        DeprecationWarning,
    )
    warnings.warn(
        'fabricio.execute() is deprecated and will be removed in v0.6, '
        'use fabric.api.execute() instead',
        RuntimeWarning, stacklevel=2,
    )
    try:
        task, args = args[0], args[1:]
    except IndexError:
        raise TypeError('must provide task to execute')
    default_name = '{command}.{task_name}({id})'.format(
        command=fab.env.command,
        task_name=getattr(task, 'name', task.__name__),
        id=id(task),
    )
    with utils.patch(task, 'name', get_task_name(task) or default_name):
        return fab.execute(task, *args, **kwargs) 
開發者ID:renskiy,項目名稱:fabricio,代碼行數:23,代碼來源:tasks.py

示例6: test_rollback

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def test_rollback(self, revert, migrate_back):
        tasks_list = tasks.DockerTasks(service=TestContainer(), hosts=['host'])
        rollback = mock.Mock()
        rollback.attach_mock(migrate_back, 'migrate_back')
        rollback.attach_mock(revert, 'revert')
        revert.return_value = True

        # with migrate_back disabled
        tasks_list.rollback.name = '{0}__migrate_disabled'.format(self)
        fab.execute(tasks_list.rollback, migrate_back='no')
        migrate_back.assert_not_called()
        revert.assert_called_once()
        rollback.reset_mock()

        # default case
        tasks_list.rollback.name = '{0}__default'.format(self)
        fab.execute(tasks_list.rollback)
        self.assertListEqual(
            [mock.call.migrate_back(), mock.call.revert()],
            rollback.mock_calls,
        )
        rollback.reset_mock() 
開發者ID:renskiy,項目名稱:fabricio,代碼行數:24,代碼來源:test_tasks.py

示例7: configure_idm_external_auth

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def configure_idm_external_auth(idm_password=None):
    """Configure the Satellite6 Server for External Authentication.

    Expects the following environment variables:

    IDM_PASSWORD
        IDM Server Password to fetch a token.

    """
    result = run('id admin')
    if result.failed:
        print('Please execute enroll_idm before configuring External Auth')
        sys.exit(1)
    if idm_password is None:
        idm_password = os.environ.get('IDM_PASSWORD')
    run('echo {0} | kinit admin'.format(idm_password))
    run('ipa service-add HTTP/$(hostname)')
    run('satellite-installer --foreman-ipa-authentication=true')
    run('foreman-maintain service restart') 
開發者ID:SatelliteQE,項目名稱:automation-tools,代碼行數:21,代碼來源:__init__.py

示例8: init

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def init():
    # local("grep rsa ~/.ssh/known_hosts > known_hosts")
    local("python derivekey.py --store")
    execute(passcache) 
開發者ID:gdanezis,項目名稱:rscoin,代碼行數:6,代碼來源:fabfile.py

示例9: deploy

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def deploy():
    execute(gitall)
    execute(keys)
    execute(loaddir)
    execute(loadsecret) 
開發者ID:gdanezis,項目名稱:rscoin,代碼行數:7,代碼來源:fabfile.py

示例10: experiment1

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def experiment1():
    env.messages = 2000
    env.expname = "experiment1"
    local( "rm -rf experiment1" )
    local( "mkdir experiment1" )
    execute( "experiment1run" )
    execute( "experiment1pre" )
    execute( "experiment1actual" )
    execute( "experiment1collect" )

    local("python exp1plot.py experiment1")
    local("python estthroughput.py %s > %s/stats.txt" % (env.expname, env.expname)) 
開發者ID:gdanezis,項目名稱:rscoin,代碼行數:14,代碼來源:fabfile.py

示例11: __init__

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def __init__(self, user_name, password, command, user_as=None):
        """
        :param user_name: Username to login with
        :param password: Password of the user
        :param command: command to execute (This command will be executed using sudo. )
        """
        self.user_name = user_name
        self.password = password
        self.command = command
        self.user_as = user_as 
開發者ID:dimagi,項目名稱:commcare-cloud,代碼行數:12,代碼來源:utils.py

示例12: _setup_env

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def _setup_env(env_name):
    env.env_name = env_name
    load_env()
    _set_code_branch(env.default_branch)
    _confirm_environment_time(env_name)
    execute(env_common)
    execute(_confirm_deploying_same_code) 
開發者ID:dimagi,項目名稱:commcare-cloud,代碼行數:9,代碼來源:fabfile.py

示例13: kill_stale_celery_workers

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def kill_stale_celery_workers():
    """
    Kills celery workers that failed to properly go into warm shutdown
    """
    execute(release.kill_stale_celery_workers) 
開發者ID:dimagi,項目名稱:commcare-cloud,代碼行數:7,代碼來源:fabfile.py

示例14: rollback_formplayer

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def rollback_formplayer():
    execute(formplayer.rollback_formplayer)
    execute(supervisor.restart_formplayer) 
開發者ID:dimagi,項目名稱:commcare-cloud,代碼行數:5,代碼來源:fabfile.py

示例15: reverse_patch

# 需要導入模塊: from fabric import api [as 別名]
# 或者: from fabric.api import execute [as 別名]
def reverse_patch(patchfile=None):
    """
    Used to reverse a git patch created via `git format-patch`. Usage:

        fab <env> reverse_patch:patchfile=/path/to/patch

    Note: Only use this when absolutely necessary. Normally we should use regular
    deploy. This is only used for patching when we do not have access to the Internet.
    """
    if not patchfile:
        print(red("Must specify patch filepath"))
        exit()
    execute(release.reverse_patch, patchfile)
    silent_services_restart(use_current_release=True) 
開發者ID:dimagi,項目名稱:commcare-cloud,代碼行數:16,代碼來源:fabfile.py


注:本文中的fabric.api.execute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。