当前位置: 首页>>代码示例>>Python>>正文


Python env.hosts方法代码示例

本文整理汇总了Python中fabric.api.env.hosts方法的典型用法代码示例。如果您正苦于以下问题:Python env.hosts方法的具体用法?Python env.hosts怎么用?Python env.hosts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fabric.api.env的用法示例。


在下文中一共展示了env.hosts方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_command

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [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: localhost

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [as 别名]
def localhost(skip_ssh=False):
    """
    Sets up a development environment to pretend that localhost is a remote server
    """
    if not skip_ssh:
        env.hosts = ['127.0.0.1']

    env.user = env.deploy_user = 'calthorpe'
    env.deploy_user = 'calthorpe'
    env.virtualenv_directory = '/srv/calthorpe_env'
    env.password = 'Calthorpe123'
    env.DATA_DUMP_PATH = '/srv/datadump'
    env.settings = 'dev'
    env.dev = True
    env.use_ssl = False
    env.client = 'default' 
开发者ID:CalthorpeAnalytics,项目名称:urbanfootprint,代码行数:18,代码来源:__init__.py

示例3: build

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [as 别名]
def build(build_type='prod'):
    """
        Drops and recreates the databases for development, then initializes main
        This will raise an error if 127.0.0.1 is not in env.hosts to protect live databases
        Make sure complete migration scripts exist prior to running this
    :return:
    """
    restart_supervisor()
    prepare_build_or_deploy(build_type=build_type)
    start = datetime.datetime.now()
    recreate_db(build_type)
    with cd(get_django_setting(build_type, 'ROOT_PATH')):
        manage_py('syncdb --noinput', build_type)
        manage_py('migrate', build_type)
        manage_py('collectstatic --noinput', build_type)
        setup_tilestache_user()
    build_database(build_type=build_type)
    post_build_database()
    end = datetime.datetime.now()
    elapsed = end - start
    print elapsed
    npm_install() 
开发者ID:CalthorpeAnalytics,项目名称:urbanfootprint,代码行数:24,代码来源:methods.py

示例4: configure_env

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [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

示例5: call_and_assert_install_with_rpm_specifier

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [as 别名]
def call_and_assert_install_with_rpm_specifier(self, mock_download_rpm, mock_check_rpm, mock_execute, location,
                                                   rpm_specifier, rpm_path):
        if location == 'local' or location == 'download':
            server.install(rpm_specifier)
            if location == 'local':
                mock_download_rpm.assert_not_called()
            else:
                self.assertTrue(mock_download_rpm.called)
            mock_check_rpm.assert_called_with(rpm_path)
            mock_execute.assert_called_with(server.deploy_install_configure,
                                            rpm_path, hosts=get_host_list())
        elif location == 'none':
            self.assertRaises(SystemExit, server.install, rpm_specifier)
            mock_check_rpm.assert_not_called()
            mock_execute.assert_not_called()
        else:
            exit('Cannot assert because of invalid location: %s' % location) 
开发者ID:prestodb,项目名称:presto-admin,代码行数:19,代码来源:test_server.py

示例6: getrunning

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [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

示例7: cmd

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [as 别名]
def cmd(config, cmd):
    """ EXECS a unix command on the remote hosts: fab -i ~/.ssh/id_cass -u ubuntu cmd:config=c4-ebs-hvm,cmd="df -h" """

    # Examples
    # fab cmd:config=c4-ebs-hvm,cmd="java -version 2>&1 | grep version  | awk '{print $NF}'"
    # fab cmd:config=c4-ebs-hvm,cmd="grep MAX_HEAP_SIZE /etc/dse/cassandra/cassandra-env.sh | grep G"

    # delete commit log with lots of files
    #fab -u ubuntu  cmd:config=c4-ebs-hvm,cmd="find /raid0/cassandra/commitlog -name '*.log' -print0 | xargs -0 sudo rm"

    # remove files
    # fab  -u ubuntu cmd:c4-ebs-hvm,cmd="find /raid0/cassandra/commitlog/* -name "*.log" -print0 | xargs -0 sudo rm"
    _set_hosts(config)
    results = execute(_exec, cmd=cmd)
    i = 1
    for host, result in results.items():
        print "host {} [{}] result is [{}]".format(i, host, result.strip())
        i += 1 
开发者ID:CrowdStrike,项目名称:cassandra-tools,代码行数:20,代码来源:fabfile.py

示例8: _bootstrapcass

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [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

示例9: _yamlfile

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [as 别名]
def _yamlfile(config):
    host = env.host_string
    src_file = "configs/{}/cassandra.yaml".format(config)
    green("Syncing YAML File from [{}]".format(src_file))
    dest_file = "{}/cassandra.yaml".format(config_dir)
    put(src_file, dest_file, use_sudo=True)
    aftertext = "rpc_address: {}".format(host)
    sed(dest_file,before='rpc_address: \$HOST',after=aftertext,use_sudo=True,backup=".bak")

    aftertext = "listen_address: {}".format(host)
    sed(dest_file,before='listen_address: \$HOST',after=aftertext,use_sudo=True,backup='')

    # grab the first 3 hosts in the host file and use as seed nodes, could be improved
    seed_str = ",".join(env.hosts[0:3])
    aftertext = 'seeds: "{}"'.format(seed_str)
    sed(dest_file,before='seeds: \$SEEDS',after=aftertext,use_sudo=True,backup='') 
开发者ID:CrowdStrike,项目名称:cassandra-tools,代码行数:18,代码来源:fabfile.py

示例10: _get_vagrant_connection

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [as 别名]
def _get_vagrant_connection():
    local('vagrant up')
    result = local('vagrant ssh-config', capture=True)
    hostname = re.findall(r'HostName\s+([^\n]+)', result)[0]
    port = re.findall(r'Port\s+([^\n]+)', result)[0]
    env.hosts = ['%s:%s' % (hostname, port)]
    env.user = re.findall(r'User\s+([^\n]+)', result)[0]
    env.key_filename = re.findall(r'IdentityFile\s+([^\n]+)', result)[0].lstrip("\"").rstrip("\"") 
开发者ID:dhamaniasad,项目名称:crestify,代码行数:10,代码来源:fabfile.py

示例11: production

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [as 别名]
def production():
    global SERVER_ENV, UWSGI_ENV, DB_DIR, DB_FILE
    env.hosts = ['haoli-normal-06-vpn-dns']
    env.user = 'haoli'
    SERVER_ENV = 'production'
    UWSGI_ENV = 'production'
    DB_DIR = config.ProductionConfig.DB_DIR
    DB_FILE = config.ProductionConfig.DB_FILE

#development Env 
开发者ID:sibosend,项目名称:openvpn-admin-ui,代码行数:12,代码来源:fabfile.py

示例12: development

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [as 别名]
def development():
    global SERVER_ENV, UWSGI_ENV, DB_DIR, DB_FILE
    env.hosts = ['192.168.0.121']
    env.user = 'admin'
    SERVER_ENV = 'development'
    UWSGI_ENV = 'development'
    DB_DIR = config.DevelopmentConfig.DB_DIR
    DB_FILE = config.DevelopmentConfig.DB_FILE 
开发者ID:sibosend,项目名称:openvpn-admin-ui,代码行数:10,代码来源:fabfile.py

示例13: devserver

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [as 别名]
def devserver():
    global SERVER_ENV, UWSGI_ENV, DB_DIR, DB_FILE
    env.hosts = ['local-vm-win10-centos6']
    env.user = 'caritasem'
    SERVER_ENV = 'development'
    UWSGI_ENV = 'development'
    DB_DIR = config.DevelopmentConfig.DB_DIR
    DB_FILE = config.DevelopmentConfig.DB_FILE 
开发者ID:sibosend,项目名称:openvpn-admin-ui,代码行数:10,代码来源:fabfile.py

示例14: _require_target

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [as 别名]
def _require_target():
    require('root', 'code_root', 'hosts', 'deploy_env',
            provided_by=('staging', 'production', 'softlayer')) 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:5,代码来源:fabfile.py

示例15: rollback

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import hosts [as 别名]
def rollback():
    """
    Rolls back the servers to the previous release if it exists and is same
    across servers.
    """
    number_of_releases = execute(release.get_number_of_releases)
    if not all(n > 1 for n in number_of_releases):
        print(red('Aborting because there are not enough previous releases.'))
        exit()

    releases = execute(release.get_previous_release)

    unique_releases = set(releases.values())
    if len(unique_releases) != 1:
        print(red('Aborting because not all hosts would rollback to same release'))
        exit()

    unique_release = unique_releases.pop()

    if not unique_release:
        print(red('Aborting because release path is empty. '
                  'This probably means there are no releases to rollback to.'))
        exit()

    if not console.confirm('Do you wish to rollback to release: {}'.format(unique_release), default=False):
        print(blue('Exiting.'))
        exit()

    exists = execute(release.ensure_release_exists, unique_release)

    if all(exists.values()):
        print(blue('Updating current and restarting services'))
        execute(release.update_current, unique_release)
        silent_services_restart(use_current_release=True)
        execute(release.mark_last_release_unsuccessful)
    else:
        print(red('Aborting because not all hosts have release'))
        exit() 
开发者ID:dimagi,项目名称:commcare-cloud,代码行数:40,代码来源:fabfile.py


注:本文中的fabric.api.env.hosts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。