当前位置: 首页>>代码示例>>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;未经允许,请勿转载。