當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。