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


Python env.forward_agent方法代碼示例

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


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

示例1: run_command

# 需要導入模塊: from fabric.api import env [as 別名]
# 或者: from fabric.api.env import forward_agent [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: configure_env

# 需要導入模塊: from fabric.api import env [as 別名]
# 或者: from fabric.api.env import forward_agent [as 別名]
def configure_env():
    ''' Configures the fabric env. '''
    config = get_config()
    stage = get_stage()
    stage_config = get_stage_config(stage)
    env.user = stage_config.get('user') or config['user']
    env.port = stage_config.get('port') or config['port']
    env.cwd = stage_config.get('cwd') or config['cwd']
    env.key_filename = stage_config.get(
        'key_filename') or config['key_filename']
    env.hosts = [stage_config['host']]
    ssh_forward_agent = stage_config.get(
        'ssh_forward_agent') or config['ssh_forward_agent']

    env.forward_agent = (
        ssh_forward_agent and
        str(ssh_forward_agent).lower() == 'true'
    )

    # If Verbose logging is turned on show verbose logs.
    verbose_logging = stage_config.get('verbose_logging') or config[
        'verbose_logging']

    if str(verbose_logging).lower() == 'true':
        set_verbose_logging() 
開發者ID:kabirbaidhya,項目名稱:boss,代碼行數:27,代碼來源:init.py

示例3: deploy_baseimage

# 需要導入模塊: from fabric.api import env [as 別名]
# 或者: from fabric.api.env import forward_agent [as 別名]
def deploy_baseimage(image, hypervisors=[]):
    """Task to deploy specific image to set of hypervisors

    The following environment variables affect this command:

    PROVISIONING_HOSTS
        Set of hypervisor FQDNs/IPs to deploy image to

    :param str image: Image name to be deployed (without extension .img)
    :param list hypervisors: Set of hypervisor FQDNs/IPs to deploy image to

    """
    hypervisors = hypervisors or os.environ.get('PROVISIONING_HOSTS', '')
    if isinstance(hypervisors, str):
        hypervisors = hypervisors.split()

    tmpimg = run('mktemp')
    run('qemu-img convert /var/lib/libvirt/images/{}.img -O qcow2 {}'.format(image, tmpimg))
    src_fqdn = run('hostname')

    for target in hypervisors:
        if target == src_fqdn:  # omit image hosting machine from deployment
            continue
        if env.forward_agent:  # set by `-A` fab option and ssh agent must be available
            run('scp -p {} {}:{}'.format(tmpimg, target, tmpimg), warn_only=True)
        else:  # no ssh agent, scp works only 3way
            get(tmpimg, tmpimg)
            with settings(host_string=target):
                put(tmpimg, tmpimg)

        with settings(host_string=target):
            run('qemu-img convert {} -O raw /var/lib/libvirt/images/{}.img'.format(tmpimg, image))
            run('rm -f {}'.format(tmpimg))

    run('rm -f {}'.format(tmpimg)) 
開發者ID:SatelliteQE,項目名稱:automation-tools,代碼行數:37,代碼來源:baseimage.py


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