本文整理汇总了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))
示例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")
示例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='')
示例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')
示例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
示例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
示例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
示例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()
示例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')
示例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')
示例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}')
示例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}')
示例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')
示例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
示例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))