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


Python env.host_string方法代码示例

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


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

示例1: _dseperf

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host_string [as 别名]
def _dseperf():
    """ based on updated DSE performance doc from 4/23/2015 """
    sudo("add-apt-repository -y ppa:webupd8team/java")
    sudo("apt-get update")
    sudo("apt-get install -y oracle-java8-installer oracle-java8-set-default")

    sudo("echo tsc > /sys/devices/system/clocksource/clocksource0/current_clocksource")

    sudo("apt-get install -y schedtool")

    #sudo('echo "vm.dirty_expire_centisecs = 10" >> /etc/sysctl.d/dirty.conf')
    #sudo("sysctl -p /etc/sysctl.d/dirty.conf")

    # 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)) 
开发者ID:CrowdStrike,项目名称:cassandra-tools,代码行数:18,代码来源:fabfile.py

示例2: _bootstrapcass

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

示例3: _yamlfile

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

示例4: __action

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host_string [as 别名]
def __action(**kwargs):
    redata = kwargs['redata']
    jdata = kwargs['jdata']
    if ShouldRun(redata, jdata):
        env.gateway = redata['data']['gateway']
        env.host_string = redata['data']['host_string']
        env.user = redata['data']['username']
        env.key = redata['data']['sshkey']
        env.disable_known_hosts = True
        env.warn_only = True
        env.abort_on_prompts = True
        env.shell = "/bin/sh -c"
        try:
            results = run_cmd(redata['data']['cmd'])
            if results.succeeded:
                return True
            else:
                raise Exception(
                    'Command Execution Failed: {0} - {1}'.format(results.return_code, results))
        except:
            raise Exception(
                'Command failed to execute') 
开发者ID:Runbook,项目名称:runbook,代码行数:24,代码来源:__init__.py

示例5: check

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host_string [as 别名]
def check(**kwargs):
    ''' Login over SSH and execute shell command '''
    jdata = kwargs['jdata']
    logger = kwargs['logger']

    env.gateway = jdata['data']['gateway']
    env.host_string = jdata['data']['host_string']
    env.user = jdata['data']['username']
    env.key = jdata['data']['sshkey']
    env.shell = "/bin/sh -c"
    env.disable_known_hosts = True
    env.warn_only = True
    env.abort_on_prompts = True
    try:
        results = run_cmd(jdata['data']['cmd'])
        logger.debug("execute-shell-command: requested command" +
                     " returned with exit code {0}".format(results.return_code))
        if results.succeeded:
            return True
        else:
            return False
    except:
        return None 
开发者ID:Runbook,项目名称:runbook,代码行数:25,代码来源:__init__.py

示例6: check

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host_string [as 别名]
def check(**kwargs):
    ''' Login over SSH and execute shell command '''
    jdata = kwargs['jdata']
    logger = kwargs['logger']

    env.gateway = jdata['data']['gateway']
    env.host_string = jdata['data']['host_string']
    env.user = jdata['data']['username']
    env.key = jdata['data']['sshkey']
    env.shell = "/bin/sh -c"
    env.disable_known_hosts = True
    env.warn_only = True
    env.abort_on_prompts = True
    results = run_cmd("uptime")
    if results.succeeded:
        data = results.split()
        load = float(data[-3].rstrip(","))
    else:
        return None

    logger.debug("load-average: 1 minute load average is {0}".format(load))
    if load < float(jdata['data']['threshold']):
        return True
    else:
        return False 
开发者ID:Runbook,项目名称:runbook,代码行数:27,代码来源:__init__.py

示例7: _get_connection_args

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host_string [as 别名]
def _get_connection_args(base_url, remote_port, local_port):
    if env.host_string:
        if base_url:
            proto_idx = base_url.find(':/')
            if proto_idx >= 0:
                proto = base_url[:proto_idx]
                address = base_url[proto_idx + 2:]
                if proto in ('http+unix', 'unix'):
                    if address[:3] == '//':
                        address = address[1:]
                    elif address[0] != '/':
                        address = ''.join(('/', address))
                    return _get_socat_tunnel(address, local_port)
                return _get_local_tunnel(address.lstrip('/'), remote_port, local_port)
            elif base_url[0] == '/':
                return _get_socat_tunnel(base_url, local_port)
            return _get_local_tunnel(base_url, remote_port, local_port)
        return _get_socat_tunnel(DEFAULT_SOCKET, local_port)
    return base_url, None 
开发者ID:merll,项目名称:docker-fabric,代码行数:21,代码来源:apiclient.py

示例8: get_connection

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host_string [as 别名]
def get_connection(self, *args, **kwargs):
        """
        Create a new connection, or return an existing one from the cache. Uses Fabric's current ``env.host_string``
        and the URL to the Docker service.

        :param args: Additional arguments for the client constructor, if a new client has to be instantiated.
        :param kwargs: Additional keyword args for the client constructor, if a new client has to be instantiated.
        """
        key = env.get('host_string'), kwargs.get('base_url', env.get('docker_base_url'))
        default_config = _get_default_config(None)
        if default_config:
            if key not in self:
                self[key] = default_config
            return default_config.get_client()
        config = self.get_or_create_connection(key, self.configuration_class, *args, **kwargs)
        return config.get_client() 
开发者ID:merll,项目名称:docker-fabric,代码行数:18,代码来源:base.py

示例9: deploy

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host_string [as 别名]
def deploy():
    env.host_string = config.HOST_STRING
    with cd('/var/www/test'):
        with shell_env(MODE='PRODUCTION'):
            run('git reset --hard HEAD')
            run('git pull')
            run('npm install')
            run('gulp')
            with prefix('source venv/bin/activate'):
                run('pip install -r requirements.txt')
                run('python manage.py db upgrade')
                run('python manage.py build')
            run('supervisorctl restart test') 
开发者ID:Akagi201,项目名称:learning-python,代码行数:15,代码来源:fabfile.py

示例10: restart

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host_string [as 别名]
def restart():
    env.host_string = config.HOST_STRING
    run('supervisorctl restart test') 
开发者ID:Akagi201,项目名称:learning-python,代码行数:5,代码来源:fabfile.py

示例11: deploy

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host_string [as 别名]
def deploy():
    env.host_string = config.HOST_STRING
    with cd('/var/www/#{project}'):
        with shell_env(MODE='PRODUCTION'):
            run('git reset --hard HEAD')
            run('git pull')
            run('npm install')
            run('gulp')
            with prefix('source venv/bin/activate'):
                run('pip install -r requirements.txt')
                run('python manage.py db upgrade')
                run('python manage.py build')
            run('supervisorctl restart #{project}') 
开发者ID:hustlzp,项目名称:Flask-Boost,代码行数:15,代码来源:fabfile.py

示例12: restart

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host_string [as 别名]
def restart():
    env.host_string = config.HOST_STRING
    run('supervisorctl restart #{project}') 
开发者ID:hustlzp,项目名称:Flask-Boost,代码行数:5,代码来源:fabfile.py

示例13: update

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host_string [as 别名]
def update():
    u"""Function defining all steps required to properly update application."""

    # Django app refresh:
    with cd('/var/www/volontulo'):
        run('git checkout -f {}'.format(env_vars[env.host_string]['git_branch']))
        run('git pull')

    with contextlib.nested(
        prefix('workon volontulo'),
        cd('/var/www/volontulo/backend'),
    ):
        run('pip install --upgrade -r requirements/base.txt')

    # Django site refresh:
    with contextlib.nested(
        cd('/var/www/volontulo/backend'),
        prefix('workon volontulo')
    ):
        run('python manage.py migrate --traceback')

    # Angular assets refresh:
    with contextlib.nested(
        prefix('nvm use {}'.format(NODE_VERSION)),
        cd('/var/www/volontulo/frontend'),
    ):
        run('npm install .')
        run('$(npm bin)/ng build --prod --env={}'.format(env.host_string))
        run('$(npm bin)/ng build --prod --env={} --app 1 --output-hashing=false'.format(env.host_string))
        run('./node_modules/.bin/webpack --config webpack.server.config.js --progress --colors')

    run('systemctl restart uwsgi.service')
    run('systemctl restart nginx')
    run('systemctl restart pm2-www-data.service') 
开发者ID:CodeForPoznan,项目名称:volontulo,代码行数:36,代码来源:fabfile.py

示例14: _restart_cass

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host_string [as 别名]
def _restart_cass(sleep):
    with settings(warn_only=True):
        print "Restarting {} with a sleep of {}".format(env.host_string, sleep)
        sudo("service cassandra restart")
        time.sleep(float(sleep))

#@parallel 
开发者ID:CrowdStrike,项目名称:cassandra-tools,代码行数:9,代码来源:fabfile.py

示例15: _start_cass

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import host_string [as 别名]
def _start_cass(sleep):
    with settings(warn_only=True):
        print "Starting {} with a sleep of {}".format(env.host_string, sleep)
        sudo("service cassandra start")
        time.sleep(float(sleep)) 
开发者ID:CrowdStrike,项目名称:cassandra-tools,代码行数:7,代码来源:fabfile.py


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